hexsha stringlengths 40 40 | size int64 7 1.05M | ext stringclasses 13 values | lang stringclasses 1 value | max_stars_repo_path stringlengths 4 269 | max_stars_repo_name stringlengths 5 108 | max_stars_repo_head_hexsha stringlengths 40 40 | max_stars_repo_licenses listlengths 1 9 | max_stars_count int64 1 191k ⌀ | max_stars_repo_stars_event_min_datetime stringlengths 24 24 ⌀ | max_stars_repo_stars_event_max_datetime stringlengths 24 24 ⌀ | max_issues_repo_path stringlengths 4 269 | max_issues_repo_name stringlengths 5 116 | max_issues_repo_head_hexsha stringlengths 40 40 | max_issues_repo_licenses listlengths 1 9 | max_issues_count int64 1 67k ⌀ | max_issues_repo_issues_event_min_datetime stringlengths 24 24 ⌀ | max_issues_repo_issues_event_max_datetime stringlengths 24 24 ⌀ | max_forks_repo_path stringlengths 4 269 | max_forks_repo_name stringlengths 5 116 | max_forks_repo_head_hexsha stringlengths 40 40 | max_forks_repo_licenses listlengths 1 9 | max_forks_count int64 1 105k ⌀ | max_forks_repo_forks_event_min_datetime stringlengths 24 24 ⌀ | max_forks_repo_forks_event_max_datetime stringlengths 24 24 ⌀ | content stringlengths 7 1.05M | avg_line_length float64 1.21 330k | max_line_length int64 6 990k | alphanum_fraction float64 0.01 0.99 | author_id stringlengths 2 40 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
bace3891a327416cd367e230de6bf75a85aca29a | 3,832 | cpp | C++ | wpb_mani_description/src/wpb_mani_test.cpp | 6-robot/wpb_mani | 6aa6e2d8713c8d018a422e4665ff8fcd7e299ad0 | [
"BSD-3-Clause"
] | 4 | 2021-02-08T03:55:26.000Z | 2021-12-13T12:06:34.000Z | wpb_mani_description/src/wpb_mani_test.cpp | 6-robot/wpb_mani | 6aa6e2d8713c8d018a422e4665ff8fcd7e299ad0 | [
"BSD-3-Clause"
] | null | null | null | wpb_mani_description/src/wpb_mani_test.cpp | 6-robot/wpb_mani | 6aa6e2d8713c8d018a422e4665ff8fcd7e299ad0 | [
"BSD-3-Clause"
] | 1 | 2021-06-08T01:17:54.000Z | 2021-06-08T01:17:54.000Z | /*********************************************************************
* Software License Agreement (BSD License)
*
* Copyright (c) 2017-2020, Waterplus http://www.6-robot.com
* 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 WaterPlus 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,
* FOOTPRINTAL, 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 ZhangWanjie
********************************************************************/
#include <ros/ros.h>
#include <sensor_msgs/JointState.h>
#include <math.h>
#include <vector>
#include <string>
static double fDegToAng = 3.1415926/180;
static double fAngToDeg = 180/3.1415926;
static double fJointAngle[6];
static int nJointSpeed[6];
int main(int argc, char** argv)
{
ros::init(argc,argv,"wpb_mani_test");
ROS_INFO("[wpb_mani_test]");
ros::NodeHandle n;
for(int i=0;i<5;i++)
{
fJointAngle[i] = 0;
nJointSpeed[i] = 1500;
}
ros::Publisher joint_state_pub = n.advertise<sensor_msgs::JointState>("/joint_states",10);
sensor_msgs::JointState msg;
std::vector<std::string> joint_name(11);
std::vector<double> joint_pos(11);
joint_name[0] = "front_left_wheel_joint";
joint_name[1] = "front_right_wheel_joint";
joint_name[2] = "back_right_wheel_joint";
joint_name[3] = "back_left_wheel_joint";
joint_name[4] = "kinect_height";
joint_name[5] = "kinect_pitch";
joint_name[6] = "joint1";
joint_name[7] = "joint2";
joint_name[8] = "joint3";
joint_name[9] = "joint4";
joint_name[10] = "gripper";
joint_pos[0] = 0.0f;
joint_pos[1] = 0.0f;
joint_pos[2] = 0.0f;
joint_pos[3] = 0.0f;
joint_pos[4] = 0.0f;
joint_pos[5] = 0.0f;
joint_pos[6] = 0.0f;
joint_pos[7] = 0.0f;
joint_pos[8] = 0.0f;
joint_pos[9] = 0.0f;
joint_pos[10] = 0.0f;
int nCount = 0;
ros::Rate r(30);
while(n.ok())
{
nCount += 5;
joint_pos[0] = (float)nCount*0.01;
joint_pos[1] = (float)nCount*-0.01;
joint_pos[2] = (float)nCount*-0.01;
joint_pos[3] = (float)nCount*0.01;
msg.header.stamp = ros::Time::now();
msg.header.seq ++;
msg.name = joint_name;
msg.position = joint_pos;
joint_state_pub.publish(msg);
ros::spinOnce();
r.sleep();
}
} | 35.813084 | 94 | 0.625 | 6-robot |
bacecdee6338b7f7be7809e6720c6657bd8ef62d | 3,855 | cpp | C++ | src/Pyros3D/Rendering/PostEffects/Effects/MotionBlurEffect.cpp | Peixinho/Pyros3D | d6857ce99f3731a851ca5e7d67afbb13aafd18e0 | [
"MIT"
] | 20 | 2016-02-15T23:22:06.000Z | 2021-12-07T00:13:49.000Z | src/Pyros3D/Rendering/PostEffects/Effects/MotionBlurEffect.cpp | Peixinho/Pyros3D | d6857ce99f3731a851ca5e7d67afbb13aafd18e0 | [
"MIT"
] | 1 | 2017-09-04T00:28:19.000Z | 2017-09-05T11:00:12.000Z | src/Pyros3D/Rendering/PostEffects/Effects/MotionBlurEffect.cpp | Peixinho/Pyros3D | d6857ce99f3731a851ca5e7d67afbb13aafd18e0 | [
"MIT"
] | 3 | 2016-08-10T02:44:08.000Z | 2021-05-28T23:03:10.000Z | //============================================================================
// Name : MotionBlur.h
// Author : Duarte Peixinho
// Version :
// Copyright : ;)
// Description : MotionBlur Effect
//============================================================================
#include <Pyros3D/Rendering/PostEffects/Effects/MotionBlurEffect.h>
namespace p3d {
MotionBlurEffect::MotionBlurEffect(const uint32 Tex1, Texture* VelocityMap, const uint32 Width, const uint32 Height) : IEffect(Width, Height)
{
// Set RTT
UseRTT(Tex1);
UseCustomTexture(VelocityMap);
//Vec2 res = Vec2(Width, Height);
f32 vel = 3.25f;
//texResHandle = AddUniform(Uniform("uTexResolution", Uniforms::DataType::Vec2, &res));
velHandle = AddUniform(Uniform("uVelocityScale", Uniforms::DataType::Float, &vel));
VertexShaderString =
#if defined(GLES2)
"#define varying_in varying\n"
"#define varying_out varying\n"
"#define attribute_in attribute\n"
"#define texture_2D texture2D\n"
"#define texture_cube textureCube\n"
"precision mediump float;"
#else
"#define varying_in in\n"
"#define varying_out out\n"
"#define attribute_in in\n"
"#define texture_2D texture\n"
"#define texture_cube texture\n"
#if defined(GLES3)
"precision mediump float;\n"
#endif
#endif
"varying_out vec2 vTexcoord;\n"
"void main() {\n"
"gl_Position = vec4(-1.0 + vec2((gl_VertexID & 1) << 2, (gl_VertexID & 2) << 1), 0.0, 1.0);\n"
"vTexcoord = (gl_Position.xy+1.0)*0.5;\n"
"}";
// Create Fragment Shader
FragmentShaderString =
"#define MAX_SAMPLES 32\n"
#if defined(GLES2)
"#define varying_in varying\n"
"#define varying_out varying\n"
"#define attribute_in attribute\n"
"#define texture_2D texture2D\n"
"#define texture_cube textureCube\n"
"precision mediump float;"
#else
"#define varying_in in\n"
"#define varying_out out\n"
"#define attribute_in in\n"
"#define texture_2D texture\n"
"#define texture_cube texture\n"
#if defined(GLES3)
"precision mediump float;\n"
#endif
#endif
#if defined(GLES2)
"vec4 FragColor;\n"
#else
"out vec4 FragColor;\n"
#endif
"varying_in vec2 vTexcoord;\n"
"uniform sampler2D uTex0;\n"
"uniform sampler2D uTex1;\n"
"uniform vec2 uTexResolution;\n"
"uniform float uVelocityScale;\n"
"void main() {\n"
"vec2 texelSize = 1.0 / vec2(textureSize(uTex0, 0));\n"
"vec2 screenTexCoords = gl_FragCoord.xy * texelSize;\n"
"vec2 velocity = texture(uTex1, screenTexCoords).rg;\n"
"velocity *= uVelocityScale;\n"
"float speed = length(velocity / texelSize);\n"
"float nSamples = clamp(int(speed), 1, MAX_SAMPLES);\n"
"vec4 oResult = texture(uTex0, screenTexCoords);\n"
"for (int i = 1; i < nSamples; ++i) {\n"
" vec2 offset = velocity * (float(i) / float(nSamples - 1) - 0.5);\n"
" oResult += texture(uTex0, screenTexCoords + offset);\n"
"}\n"
"FragColor = oResult / float(nSamples);\n"
#if defined(GLES2)
"gl_FragColor = FragColor;\n"
#endif
"}";
CompileShaders();
}
MotionBlurEffect::~MotionBlurEffect() {
}
void MotionBlurEffect::SetCurrentFPS(const f32 ¤tfps) {
this->cfps = currentfps;
f32 v = cfps/tfps;
velHandle->SetValue(&v);
}
void MotionBlurEffect::SetTargetFPS(const f32 &targetfps) {
this->tfps = targetfps;
f32 v = cfps/tfps;
velHandle->SetValue(&v);
}
};
| 33.232759 | 146 | 0.563684 | Peixinho |
bad2205c1145c3e50a827c1857e29df7e7cfb777 | 11,867 | cc | C++ | src/rewriter/calculator_rewriter_test.cc | mcognetta/mozc | 1f4fa17372bd196e87042738a16ab08bf904bcbf | [
"BSD-3-Clause"
] | null | null | null | src/rewriter/calculator_rewriter_test.cc | mcognetta/mozc | 1f4fa17372bd196e87042738a16ab08bf904bcbf | [
"BSD-3-Clause"
] | null | null | null | src/rewriter/calculator_rewriter_test.cc | mcognetta/mozc | 1f4fa17372bd196e87042738a16ab08bf904bcbf | [
"BSD-3-Clause"
] | null | null | null | // Copyright 2010-2020, Google Inc.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "rewriter/calculator_rewriter.h"
#include <memory>
#include <string>
#include "base/logging.h"
#include "base/system_util.h"
#include "config/config_handler.h"
#include "converter/converter_interface.h"
#include "converter/converter_mock.h"
#include "converter/segments.h"
#include "engine/engine_interface.h"
#include "engine/mock_data_engine_factory.h"
#include "protocol/commands.pb.h"
#include "protocol/config.pb.h"
#include "request/conversion_request.h"
#include "rewriter/calculator/calculator_interface.h"
#include "rewriter/calculator/calculator_mock.h"
#include "testing/base/public/googletest.h"
#include "testing/base/public/gunit.h"
namespace mozc {
namespace {
void AddCandidate(const std::string &key, const std::string &value,
Segment *segment) {
Segment::Candidate *candidate = segment->add_candidate();
candidate->Init();
candidate->value = value;
candidate->content_value = value;
candidate->content_key = key;
}
void AddSegment(const std::string &key, const std::string &value,
Segments *segments) {
Segment *segment = segments->push_back_segment();
segment->set_key(key);
AddCandidate(key, value, segment);
}
void SetSegment(const std::string &key, const std::string &value,
Segments *segments) {
segments->Clear();
AddSegment(key, value, segments);
}
const char kCalculationDescription[] = "計算結果";
bool ContainsCalculatedResult(const Segment::Candidate &candidate) {
return candidate.description.find(kCalculationDescription) !=
std::string::npos;
}
// If the segment has a candidate which was inserted by CalculatorRewriter,
// then return its index. Otherwise return -1.
int GetIndexOfCalculatedCandidate(const Segments &segments) {
CHECK_EQ(segments.segments_size(), 1);
for (size_t i = 0; i < segments.segment(0).candidates_size(); ++i) {
const Segment::Candidate &candidate = segments.segment(0).candidate(i);
if (ContainsCalculatedResult(candidate)) {
return i;
}
}
return -1;
}
} // namespace
class CalculatorRewriterTest : public ::testing::Test {
protected:
CalculatorRewriterTest() {
convreq_.set_request(&request_);
convreq_.set_config(&config_);
}
static bool InsertCandidate(const CalculatorRewriter &calculator_rewriter,
const std::string &value, size_t insert_pos,
Segment *segment) {
return calculator_rewriter.InsertCandidate(value, insert_pos, segment);
}
CalculatorMock &calculator_mock() { return calculator_mock_; }
CalculatorRewriter *BuildCalculatorRewriterWithConverterMock() {
converter_mock_.reset(new ConverterMock);
return new CalculatorRewriter(converter_mock_.get());
}
void SetUp() override {
SystemUtil::SetUserProfileDirectory(FLAGS_test_tmpdir);
// use mock
CalculatorFactory::SetCalculator(&calculator_mock_);
request_.Clear();
config::ConfigHandler::GetDefaultConfig(&config_);
config_.set_use_calculator(true);
}
void TearDown() override {
// Clear the mock test calculator
CalculatorFactory::SetCalculator(nullptr);
}
ConversionRequest convreq_;
commands::Request request_;
config::Config config_;
private:
CalculatorMock calculator_mock_;
std::unique_ptr<ConverterInterface> converter_mock_;
};
TEST_F(CalculatorRewriterTest, InsertCandidateTest) {
std::unique_ptr<CalculatorRewriter> calculator_rewriter(
BuildCalculatorRewriterWithConverterMock());
{
Segment segment;
segment.set_key("key");
// Insertion should be failed if segment has no candidate beforehand
EXPECT_FALSE(InsertCandidate(*calculator_rewriter, "value", 0, &segment));
}
// Test insertion at each position of candidates list
for (int i = 0; i <= 2; ++i) {
Segment segment;
segment.set_key("key");
AddCandidate("key", "test", &segment);
AddCandidate("key", "test2", &segment);
EXPECT_TRUE(InsertCandidate(*calculator_rewriter, "value", i, &segment));
const Segment::Candidate &candidate = segment.candidate(i);
EXPECT_EQ(candidate.value, "value");
EXPECT_EQ(candidate.content_value, "value");
EXPECT_EQ(candidate.content_key, "key");
EXPECT_NE(0, candidate.attributes & Segment::Candidate::NO_LEARNING);
// Description should be "計算結果"
EXPECT_EQ(candidate.description, kCalculationDescription);
}
}
TEST_F(CalculatorRewriterTest, BasicTest) {
// Pretend "key" is calculated to "value".
calculator_mock().SetCalculatePair("key", "value", true);
std::unique_ptr<CalculatorRewriter> calculator_rewriter(
BuildCalculatorRewriterWithConverterMock());
const int counter_at_first = calculator_mock().calculation_counter();
Segments segments;
SetSegment("test", "test", &segments);
calculator_rewriter->Rewrite(convreq_, &segments);
EXPECT_EQ(GetIndexOfCalculatedCandidate(segments), -1);
EXPECT_EQ(calculator_mock().calculation_counter(), counter_at_first + 1);
SetSegment("key", "key", &segments);
calculator_rewriter->Rewrite(convreq_, &segments);
int index = GetIndexOfCalculatedCandidate(segments);
EXPECT_NE(index, -1);
EXPECT_EQ(segments.segment(0).candidate(index).value, "value");
EXPECT_EQ(calculator_mock().calculation_counter(), counter_at_first + 2);
}
// CalculatorRewriter should convert an expression which is separated to
// multiple conversion segments. This test verifies it.
TEST_F(CalculatorRewriterTest, SeparatedSegmentsTest) {
// Pretend "1+1=" is calculated to "2".
calculator_mock().SetCalculatePair("1+1=", "2", true);
// Since this test depends on the actual implementation of
// Converter::ResizeSegments(), we cannot use converter mock here. However,
// the test itself is independent of data.
std::unique_ptr<EngineInterface> engine_(MockDataEngineFactory::Create());
std::unique_ptr<CalculatorRewriter> calculator_rewriter(
new CalculatorRewriter(engine_->GetConverter()));
// Push back separated segments.
Segments segments;
AddSegment("1", "1", &segments);
AddSegment("+", "+", &segments);
AddSegment("1", "1", &segments);
AddSegment("=", "=", &segments);
calculator_rewriter->Rewrite(convreq_, &segments);
EXPECT_EQ(segments.segments_size(), 1); // merged
int index = GetIndexOfCalculatedCandidate(segments);
EXPECT_NE(index, -1);
// Secondary result with expression (description: "1+1=2");
EXPECT_TRUE(
ContainsCalculatedResult(segments.segment(0).candidate(index + 1)));
EXPECT_EQ("2", segments.segment(0).candidate(index).value);
EXPECT_EQ("1+1=2", segments.segment(0).candidate(index + 1).value);
}
// CalculatorRewriter should convert an expression starting with '='.
TEST_F(CalculatorRewriterTest, ExpressionStartingWithEqualTest) {
// Pretend "=1+1" is calculated to "2".
calculator_mock().SetCalculatePair("=1+1", "2", true);
std::unique_ptr<CalculatorRewriter> calculator_rewriter(
BuildCalculatorRewriterWithConverterMock());
const ConversionRequest request;
Segments segments;
SetSegment("=1+1", "=1+1", &segments);
calculator_rewriter->Rewrite(request, &segments);
int index = GetIndexOfCalculatedCandidate(segments);
EXPECT_NE(-1, index);
EXPECT_EQ("2", segments.segment(0).candidate(index).value);
EXPECT_TRUE(
ContainsCalculatedResult(segments.segment(0).candidate(index + 1)));
// CalculatorRewriter should append the result to the side '=' exists.
EXPECT_EQ("2=1+1", segments.segment(0).candidate(index + 1).value);
}
// Verify the description of calculator candidate.
TEST_F(CalculatorRewriterTest, DescriptionCheckTest) {
const char kExpression[] = "5・(8/4)ー7%3+6^−1*9=";
// Expected description
const std::string description = kCalculationDescription;
// Pretend kExpression is calculated to "3"
calculator_mock().SetCalculatePair(kExpression, "3", true);
std::unique_ptr<CalculatorRewriter> calculator_rewriter(
BuildCalculatorRewriterWithConverterMock());
Segments segments;
AddSegment(kExpression, kExpression, &segments);
calculator_rewriter->Rewrite(convreq_, &segments);
const int index = GetIndexOfCalculatedCandidate(segments);
EXPECT_EQ(segments.segment(0).candidate(index).description, description);
EXPECT_TRUE(
ContainsCalculatedResult(segments.segment(0).candidate(index + 1)));
}
TEST_F(CalculatorRewriterTest, ConfigTest) {
calculator_mock().SetCalculatePair("1+1=", "2", true);
// Since this test depends on the actual implementation of
// Converter::ResizeSegments(), we cannot use converter mock here. However,
// the test itself is independent of data.
std::unique_ptr<EngineInterface> engine_(MockDataEngineFactory::Create());
std::unique_ptr<CalculatorRewriter> calculator_rewriter(
new CalculatorRewriter(engine_->GetConverter()));
{
Segments segments;
AddSegment("1", "1", &segments);
AddSegment("+", "+", &segments);
AddSegment("1", "1", &segments);
AddSegment("=", "=", &segments);
config_.set_use_calculator(true);
EXPECT_TRUE(calculator_rewriter->Rewrite(convreq_, &segments));
}
{
Segments segments;
AddSegment("1", "1", &segments);
AddSegment("+", "+", &segments);
AddSegment("1", "1", &segments);
AddSegment("=", "=", &segments);
config_.set_use_calculator(false);
EXPECT_FALSE(calculator_rewriter->Rewrite(convreq_, &segments));
}
}
TEST_F(CalculatorRewriterTest, MobileEnvironmentTest) {
std::unique_ptr<EngineInterface> engine_(MockDataEngineFactory::Create());
std::unique_ptr<CalculatorRewriter> rewriter(
new CalculatorRewriter(engine_->GetConverter()));
{
request_.set_mixed_conversion(true);
EXPECT_EQ(RewriterInterface::ALL, rewriter->capability(convreq_));
}
{
request_.set_mixed_conversion(false);
EXPECT_EQ(RewriterInterface::CONVERSION, rewriter->capability(convreq_));
}
}
TEST_F(CalculatorRewriterTest, EmptyKeyTest) {
std::unique_ptr<EngineInterface> engine_(MockDataEngineFactory::Create());
std::unique_ptr<CalculatorRewriter> calculator_rewriter(
new CalculatorRewriter(engine_->GetConverter()));
{
Segments segments;
AddSegment("", "1", &segments);
config_.set_use_calculator(true);
EXPECT_FALSE(calculator_rewriter->Rewrite(convreq_, &segments));
}
}
} // namespace mozc
| 36.179878 | 78 | 0.733884 | mcognetta |
bad44eb45c38c0009b04cd2f484bcf1b438c9396 | 3,670 | hpp | C++ | 3rd-party/apache/xsec/src/xsec/enc/XSECCryptoX509.hpp | okean/cpputils | 812cf41f04d66c28a5eb46dedab6e782c49e0f7a | [
"Naumen",
"Condor-1.1",
"MS-PL"
] | 1 | 2019-08-30T02:34:29.000Z | 2019-08-30T02:34:29.000Z | 3rd-party/apache/xsec/src/xsec/enc/XSECCryptoX509.hpp | okean/cpputils | 812cf41f04d66c28a5eb46dedab6e782c49e0f7a | [
"Naumen",
"Condor-1.1",
"MS-PL"
] | null | null | null | 3rd-party/apache/xsec/src/xsec/enc/XSECCryptoX509.hpp | okean/cpputils | 812cf41f04d66c28a5eb46dedab6e782c49e0f7a | [
"Naumen",
"Condor-1.1",
"MS-PL"
] | null | null | null | /**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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.
*/
/*
* XSEC
*
* XSECCryptoX509:= A base class for handling X509 (V3) certificates
*
* Author(s): Berin Lautenbach
*
* $Id: XSECCryptoX509.hpp 1125514 2011-05-20 19:08:33Z scantor $
*
*/
#ifndef XSECCRYPTOX509_INCLUDE
#define XSECCRYPTOX509_INCLUDE
#include <xsec/framework/XSECDefs.hpp>
#include <xsec/enc/XSECCryptoKey.hpp>
#include <xsec/utils/XSECSafeBuffer.hpp>
/**
* \brief Interface class for X509 certificates.
* @ingroup crypto
*
* The library uses classes derived from this to process X509 Certificates.
*
* Strictly speaking, this class is not required (and is completely
* <em>Optional</em>. However it is used by
* XSECKeyInfoResolverDefault to extract a key from a certificate in cases
* where the caller is not worried about the trust level of the certificate.
*
*/
class DSIG_EXPORT XSECCryptoX509 {
public :
/** @name Constructors and Destructors */
//@{
XSECCryptoX509() {};
virtual ~XSECCryptoX509() {};
//@}
/** @name Key Interface methods */
//@{
/**
* \brief Return the type of the key stored in the certificate.
*
* The implementation is expected to extract the key from the
* certificate and determine the type.
*
*/
virtual XSECCryptoKey::KeyType getPublicKeyType() const = 0;
/**
* \brief Get a copy of the public key.
*
* The implementation should extract the key from the certificate,
* create an instance of the appropriate key type, and return it.
*
*/
virtual XSECCryptoKey * clonePublicKey() const = 0;
/**
* \brief Returns a string that identifies the crypto owner of this library.
*/
virtual const XMLCh * getProviderName() const = 0;
//@}
/** @name Load and Get the certificate */
//@{
/**
* \brief Load a certificate into the object.
*
* Take a base64 DER encoded certificate and load.
*
* @param buf A buffer containing the Base64 encoded certificate
* @param len The number of bytes of data in the certificate.
*/
virtual void loadX509Base64Bin(const char * buf, unsigned int len) = 0;
/**
* \brief Load a PEM encoded certificate into the object.
*
* Take a PEM encoded certificate and load.
*
* @param buf A buffer containing the PEM encoded certificate
* @param len The number of bytes of data in the certificate.
* (0 if the string is null terminated.)
*/
void loadX509PEM(const char * buf, unsigned int len = 0);
/**
* \brief Get a Base64 DER encoded copy of the certificate
*
* @returns A safeBuffer containing the DER encoded certificate
*/
virtual safeBuffer &getDEREncodingSB(void) = 0; // Get the DER string
/**
* \brief Get a Base64 DER encoded copy of the certificate
*
* @returns A safeBuffer containing the DER encoded certificate
*/
virtual const safeBuffer &getDEREncodingSB(void) const = 0; // Get the DER string
//@}
};
#endif /* XSECCRYPTOX509_INCLUDE */
| 25.486111 | 83 | 0.708992 | okean |
bad5c2147b8f8a6ea7de87d310289fb411af4bf1 | 9,926 | cpp | C++ | Moco/Moco/Components/PositionMotion.cpp | zhengsizehrb/opensim-moco | 9844abc640a34d818a4bb21ef4fea3c3cb0f34ed | [
"Apache-2.0"
] | 41 | 2019-11-13T10:29:20.000Z | 2022-03-10T17:42:30.000Z | Moco/Moco/Components/PositionMotion.cpp | zhengsizehrb/opensim-moco | 9844abc640a34d818a4bb21ef4fea3c3cb0f34ed | [
"Apache-2.0"
] | 165 | 2019-11-13T00:55:57.000Z | 2022-03-04T19:02:26.000Z | Moco/Moco/Components/PositionMotion.cpp | zhengsizehrb/opensim-moco | 9844abc640a34d818a4bb21ef4fea3c3cb0f34ed | [
"Apache-2.0"
] | 15 | 2020-01-24T23:57:57.000Z | 2021-12-10T21:59:46.000Z | /* -------------------------------------------------------------------------- *
* OpenSim Moco: PositionMotion.cpp *
* -------------------------------------------------------------------------- *
* Copyright (c) 2019 Stanford University and the Authors *
* *
* Author(s): Christopher Dembia *
* *
* 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 "PositionMotion.h"
#include "../MocoUtilities.h"
#include <OpenSim/Common/Function.h>
#include <OpenSim/Common/GCVSplineSet.h>
#include <OpenSim/Simulation/Model/Model.h>
#include <OpenSim/Simulation/SimbodyEngine/Coordinate.h>
#include <OpenSim/Simulation/StatesTrajectory.h>
using namespace OpenSim;
class SimTKPositionMotionImplementation
: public SimTK::Motion::Custom::Implementation {
public:
void setFunctions(std::vector<Function*> functions) {
m_functions = std::move(functions);
}
SimTK::Motion::Level getLevel(const SimTK::State&) const override {
return SimTK::Motion::Level::Position;
}
/// nq: The number of generalized coordinates for this MobilizedBody.
/// q: The values of the generalized coordinates to set, with length nq.
void calcPrescribedPosition(
const SimTK::State& s, int nq, SimTK::Real* q) const override {
if (m_functions.size()) {
for (int i = 0; i < nq; ++i) {
m_funcArgs[0] = s.getTime();
q[i] = m_functions[i]->calcValue(m_funcArgs);
}
}
}
void calcPrescribedPositionDot(
const SimTK::State& s, int nq, SimTK::Real* qdot) const override {
if (m_functions.size()) {
for (int i = 0; i < nq; ++i) {
m_funcArgs[0] = s.getTime();
qdot[i] = m_functions[i]->calcDerivative(
m_qdotDerivComponents, m_funcArgs);
}
}
}
void calcPrescribedPositionDotDot(const SimTK::State& s, int nq,
SimTK::Real* qdotdot) const override {
if (m_functions.size()) {
for (int i = 0; i < nq; ++i) {
m_funcArgs[0] = s.getTime();
qdotdot[i] = m_functions[i]->calcDerivative(
m_qdotdotDerivComponents, m_funcArgs);
}
}
}
private:
std::vector<Function*> m_functions;
mutable SimTK::Vector m_funcArgs = SimTK::Vector(1);
static const std::vector<int> m_qdotDerivComponents;
static const std::vector<int> m_qdotdotDerivComponents;
};
const std::vector<int>
SimTKPositionMotionImplementation::m_qdotDerivComponents = {0};
const std::vector<int>
SimTKPositionMotionImplementation::m_qdotdotDerivComponents = {0, 0};
class SimTKPositionMotion : public SimTK::Motion::Custom {
public:
SimTKPositionMotion(SimTK::MobilizedBody& mobod)
: Motion::Custom(mobod, new SimTKPositionMotionImplementation()) {}
void setFunctions(std::vector<Function*> functions) {
static_cast<SimTKPositionMotionImplementation&>(updImplementation())
.setFunctions(std::move(functions));
}
};
void PositionMotion::setPositionForCoordinate(
const Coordinate& coord, const Function& position) {
const auto path = coord.getAbsolutePathString();
auto pos = std::unique_ptr<Function>(position.clone());
pos->setName(path);
if (get_functions().contains(path)) {
upd_functions().set(get_functions().getIndex(path), *pos);
} else {
upd_functions().adoptAndAppend(pos.release());
}
}
void PositionMotion::setEnabled(SimTK::State& state, bool enabled) const {
for (auto& motion : m_motions) {
if (enabled) {
motion.enable(state);
} else {
motion.disable(state);
}
}
}
bool PositionMotion::getEnabled(const SimTK::State& state) const {
if (m_motions.size() && !m_motions[0].isDisabled(state)) return true;
return false;
}
std::unique_ptr<PositionMotion> PositionMotion::createFromTable(
const Model& model, const TimeSeriesTable& table,
bool allowExtraColumns) {
auto posmot = std::unique_ptr<PositionMotion>(new PositionMotion());
const auto& labels = table.getColumnLabels();
// TODO: Avoid splining extra columns.
GCVSplineSet splines(table);
for (auto label : labels) {
std::string coordPath = label;
if (endsWith(label, "/value")) {
// This assumes that the coordinate is not named "value".
coordPath = label.substr(0, label.find("/value"));
const auto& coord = model.getComponent<Coordinate>(coordPath);
const auto path = coord.getAbsolutePathString();
posmot->setPositionForCoordinate(coord, splines.get(label));
} else {
OPENSIM_THROW_IF(!model.findComponent<Component>(coordPath) &&
!allowExtraColumns,
Exception, "Column '{}' is not a coordinate.", label);
}
}
return posmot;
}
std::unique_ptr<PositionMotion> PositionMotion::createFromStatesTrajectory(
const Model& model, const StatesTrajectory& statesTraj) {
const auto coords = model.getCoordinatesInMultibodyTreeOrder();
std::vector<std::string> coordSVNames;
for (const auto& coord : coords) {
coordSVNames.push_back(coord->getStateVariableNames()[0]);
}
return createFromTable(
model, statesTraj.exportToTable(model, coordSVNames));
}
TimeSeriesTable PositionMotion::exportToTable(
const std::vector<double>& time) const {
TimeSeriesTable table(time);
std::vector<std::string> labels;
SimTK::Vector value((int)time.size());
SimTK::Vector speed((int)time.size());
SimTK::Vector thisTime(1);
for (int ifunc = 0; ifunc < get_functions().getSize(); ++ifunc) {
for (int itime = 0; itime < (int)time.size(); ++itime) {
thisTime[0] = time[itime];
value[itime] = get_functions().get(ifunc).calcValue(thisTime);
speed[itime] = get_functions().get(ifunc).calcDerivative(
std::vector<int>{0}, thisTime);
}
const std::string& name = get_functions().get(ifunc).getName();
table.appendColumn(name + "/value", value);
table.appendColumn(name + "/speed", speed);
}
return table;
}
void PositionMotion::extendAddToSystem(SimTK::MultibodySystem& system) const {
Super::extendAddToSystem(system);
auto& matter = system.updMatterSubsystem();
m_motions.clear();
for (int imb = 0; imb < matter.getNumBodies(); ++imb) {
auto& mobod = matter.updMobilizedBody(SimTK::MobilizedBodyIndex(imb));
m_motions.push_back(SimTKPositionMotion(mobod));
m_motions.back().setDisabledByDefault(!get_default_enabled());
}
}
void PositionMotion::extendRealizeTopology(SimTK::State& state) const {
Super::extendRealizeTopology(state);
// Ensure all coordinates are prescribed.
const auto coords = getModel().getComponentList<Coordinate>();
for (const auto& coord : coords) {
const auto& path = coord.getAbsolutePathString();
OPENSIM_THROW_IF(!get_functions().contains(path), Exception,
"No function provided for coordinate '{}'.", path);
}
// Create a mapping from SimTK position DOFs to OpenSim Coordinates.
// We identify a SimTK DOF as a MobilizedBodyIndex and a Q index.
std::map<std::pair<SimTK::MobilizedBodyIndex, int>, std::string>
indicesToCoordName;
for (int i = 0; i < get_functions().getSize(); ++i) {
const auto& path = get_functions().get(i).getName();
const auto& coord = getModel().getComponent<Coordinate>(path);
const auto mbi = coord.getBodyIndex();
const auto qIndex = coord.getMobilizerQIndex();
indicesToCoordName[std::make_pair(mbi, qIndex)] = path;
}
auto& matter = getSystem().getMatterSubsystem();
for (SimTK::MobilizedBodyIndex mbi(0); mbi < matter.getNumBodies(); ++mbi) {
auto& mobod = matter.getMobilizedBody(mbi);
// Create the vector of functions to provide to the SimTK::Motion for
// this MobilizedBody.
std::vector<Function*> mobodFunctions;
for (int iq = 0; iq < mobod.getNumQ(state); ++iq) {
const auto key = std::make_pair(mbi, iq);
// This skips over unused quaternion slots, as indicesToCoordName
// doesn't have entries for such slots.
if (indicesToCoordName.count(key)) {
const auto& coordName = indicesToCoordName.at(key);
mobodFunctions.push_back(
const_cast<Function*>(&get_functions().get(coordName)));
}
}
auto& motion = const_cast<SimTK::Motion&>(m_motions[mbi]);
auto& customMotion = static_cast<SimTKPositionMotion&>(motion);
customMotion.setFunctions(std::move(mobodFunctions));
}
}
| 42.969697 | 80 | 0.600544 | zhengsizehrb |
bad6779f3a43d884ba1d4858e69817cc2f488bb3 | 437 | hpp | C++ | src/util.hpp | alissonmoura/roc_namedpipe | 4f3078c9248520d1ce30f0d31fe0058e07a55998 | [
"MIT"
] | null | null | null | src/util.hpp | alissonmoura/roc_namedpipe | 4f3078c9248520d1ce30f0d31fe0058e07a55998 | [
"MIT"
] | null | null | null | src/util.hpp | alissonmoura/roc_namedpipe | 4f3078c9248520d1ce30f0d31fe0058e07a55998 | [
"MIT"
] | null | null | null | #pragma once
#include <string>
namespace util
{
/**
* @brief Get the namedpipe path. It will get the namedpipe path from the
* environment variable NAMED_PIPE_PATH. If it doesn't exist it will use the
* path: \\\\.\\pipe\\mynamedpipe
*
* @return std::string It returns the namedpipe path as string. The move
* semantics is done implicitly.
*/
std::string get_namedpipe_path();
constexpr auto BUFSIZE = 4096;
} // namespace util
| 24.277778 | 76 | 0.723112 | alissonmoura |
bad6f1f81faf2ecb629adeb3a6be1f57467647e6 | 37,502 | cc | C++ | sws/modules/common/osacache.cc | ut-osa/syncchar | eba20da163260b6ae1ef3e334ad2137873a8d625 | [
"BSD-3-Clause"
] | null | null | null | sws/modules/common/osacache.cc | ut-osa/syncchar | eba20da163260b6ae1ef3e334ad2137873a8d625 | [
"BSD-3-Clause"
] | null | null | null | sws/modules/common/osacache.cc | ut-osa/syncchar | eba20da163260b6ae1ef3e334ad2137873a8d625 | [
"BSD-3-Clause"
] | 1 | 2019-05-14T16:36:45.000Z | 2019-05-14T16:36:45.000Z | // MetaTM Project
// File Name: osacache.cc
//
// Description:
//
// Operating Systems & Architecture Group
// University of Texas at Austin - Department of Computer Sciences
// Copyright 2006, 2007. All Rights Reserved.
// See LICENSE file for license terms.
#include "memaccess.h"
#include "osaassert.h"
#include "simulator.h"
#include "osacache.h"
#include "osacommon.h"
int gnCacheAttrs = -1;
const char ** gvszCacheStats = NULL;
// g-cache and tx-cache support a different
// set of statistics. Output of stats for
// caches is table-driven, so we just need
// different attribute tables for each.
// -------------------------------------
// G-CACHE statistics attributes:
// -------------------------------------
int gnGCacheAttrs = 17;
const char * gvszGCacheStats[] = {
"stat_copy_back",
"stat_data_read",
"stat_data_read_miss",
"stat_data_write",
"stat_data_write_miss",
"stat_dev_data_read",
"stat_dev_data_write",
"stat_inst_fetch",
"stat_inst_fetch_miss",
"stat_lost_stall_cycles",
"stat_mesi_exclusive_to_shared",
"stat_mesi_invalidate",
"stat_mesi_modified_to_shared",
"stat_transaction",
"stat_uc_data_read",
"stat_uc_data_write",
"stat_uc_inst_fetch",
NULL
};
// -------------------------------------
// TX-CACHE statistics attributes:
// -------------------------------------
int gnTxCacheAttrs = 66;
const char * gvszTxCacheStats[] = {
"stat_transactions",
"stat_dev_data_read",
"stat_dev_data_write",
"stat_uc_inst_fetch",
"stat_uc_data_read",
"stat_uc_data_write",
"stat_lost_stall_cycles",
"stat_data_read_miss",
"stat_inst_fetch_miss",
"stat_tmesi_invalidate",
"stat_tmesi_modified_to_shared",
"stat_tmesi_shared_to_modified",
"stat_tmesi_exclusive_to_shared",
"stat_tmesi_tm_to_ts",
"stat_tmesi_tm_to_tmi",
"stat_tmesi_ts_to_tmi",
"stat_tmesi_m_to_tm",
"stat_tmesi_m_to_tmi",
"stat_tmesi_m_to_ts",
"stat_tmesi_exclusive_to_modified",
"stat_tmesi_e_to_tmi",
"stat_tmesi_e_to_te",
"stat_tmesi_e_to_ts",
"stat_tmesi_s_to_tmi",
"stat_tmesi_s_to_ts",
"stat_tmesi_tm_to_m",
"stat_tmesi_tm_to_s",
"stat_tmesi_tmi_to_m",
"stat_tmesi_tmi_to_e",
"stat_tmesi_tmi_to_s",
"stat_tmesi_te_to_m",
"stat_tmesi_te_to_e",
"stat_tmesi_te_to_s",
"stat_tmesi_te_to_tmi",
"stat_tmesi_te_to_ts",
"stat_tmesi_ts_to_m",
"stat_tmesi_ts_to_e",
"stat_tmesi_ts_to_s",
"stat_conflicting_reads",
"stat_conflicting_write",
"stat_detected_conflicts",
"stat_local_undetected_conflicts",
"stat_predicted_conflicts",
"stat_unpredicted_conflicts",
"stat_asymmetric_conflicts",
"stat_data_write",
"stat_data_write_miss",
"stat_write_back",
"stat_overflow_count",
"stat_ov_conflicts",
"stat_data_read",
"stat_inst_fetch",
"stat_copy_back",
"stat_txR_miss",
"stat_txR_hit",
"stat_txW_miss",
"stat_txW_hit",
"stat_tx_upgrade",
"stat_tx_upgrade_noblock",
"stat_tx_commits",
"stat_tx_aborts",
"stat_tx_references",
"stat_tx_reads",
"stat_tx_writes",
"stat_stack_asymmetric_conflicts",
"stat_tx_early_releases",
NULL
};
const char * gvszTxsbStats[] = {
"stat_tx_memops",
"stat_tx_loads",
"stat_tx_stores",
"stat_tx_commits",
"stat_tx_aborts",
"stat_tx_overflows",
"stat_tx_conflicts",
"stat_tx_asymmetric_conflicts",
"stat_tx_coherence_inv",
"stat_memops",
"stat_unstallable",
"stat_loads",
"stat_stores",
"stat_coherence_inv",
"stat_loads_from_q",
"stat_tx_loads_from_q",
"stat_repeat_stores",
"stat_tx_repeat_stores",
"stat_total_latency",
"stat_cumulative_len",
"stat_cumulative_deferred",
"stat_enqueued_memops",
"stat_tx_enqueued_memops",
"stat_qfull_memops",
"stat_tx_qfull_memops",
"stat_max_qlen",
"stat_min_qlen",
"stat_qsamples",
NULL
};
/**
* initialize_cache_stats()
* Tx-cache and g-cache report a different set of statistics.
* We drive the reporting with a global table of stats attributes,
* so we select the proper table based on whether we're using
* a cache with transaction support.
*/
void initialize_cache_stats(bool busetx) {
gnCacheAttrs = busetx ? gnTxCacheAttrs : gnGCacheAttrs;
gvszCacheStats = busetx ? gvszTxCacheStats : gvszGCacheStats;
}
/**
* reset_one_cache_stats()
* Reset (by brute force!) all the statistics
* for a given cache pointed to by the conf_object_t *
* pCache.
*/
void reset_one_cache_stats( system_component_object_t * pCache )
{
integer_attribute_t av;
int nCacheAttrs = 0;
while( gvszCacheStats[nCacheAttrs] != NULL ) {
// av.u.integer = 0;
// av.kind = Sim_Val_Integer;
av = INT_ATTRIFY(0);
osa_sim_set_integer_attribute( pCache, gvszCacheStats[nCacheAttrs], &av );
nCacheAttrs++;
}
}
/**
* reset_one_storebuffer_stats()
* Reset all the statistics
* for a given store buffer
*/
void reset_one_storebuffer_stats(system_component_object_t * psb) {
integer_attribute_t av;
int nattrs = 0;
while(gvszTxsbStats[nattrs]) {
av = INT_ATTRIFY(0);
osa_sim_set_integer_attribute(psb, gvszTxsbStats[nattrs], &av);
nattrs++;
}
}
/**
* reset_cache_statistics()
* Called when OSA_CLEARSTATS magic breakpoint
* occurs--iterates over caches defined on the
* timing model chain, and resets statistics for
* devices on that chain.
*/
void reset_cache_statistics( int nCaches, const char *prefix )
{
int i;
char szICacheName[OSATXM_BUFSIZE];
char szDCacheName[OSATXM_BUFSIZE];
char szL2CacheName[OSATXM_BUFSIZE];
char szStorebufferName[OSATXM_BUFSIZE];
system_component_object_t * picache = NULL;
system_component_object_t * pdcache = NULL;
system_component_object_t * pl2cache = NULL;
system_component_object_t * pstorebuffer = NULL;
for (i=0; i<nCaches; i++) {
sprintf( szICacheName, "%sicache%d", prefix, i );
sprintf( szDCacheName, "%sdcache%d", prefix, i );
sprintf( szL2CacheName, "%sl2cache%d", prefix, i );
sprintf( szStorebufferName, "%ssb%d", prefix, i );
picache = osa_get_object_by_name( szICacheName );
pdcache = osa_get_object_by_name( szDCacheName );
pl2cache = osa_get_object_by_name( szL2CacheName );
pstorebuffer = osa_get_object_by_name( szStorebufferName );
if(picache != NULL)
reset_one_cache_stats( picache );
if(pdcache != NULL)
reset_one_cache_stats( pdcache );
if(pl2cache != NULL)
reset_one_cache_stats( pl2cache );
if(pstorebuffer != NULL)
reset_one_cache_stats( pstorebuffer );
// Clear the general exception that may have arisen if the
// caches don't exist
//OSA_TODO: SimExc_General??
if(osa_sim_get_error() == SimExc_General){
osa_sim_clear_error();
}
}
system_component_object_t * staller = NULL;
if(NULL != (staller = osa_get_object_by_name("staller"))) {
string_attribute_t av = STRING_ATTRIFY("");
osa_sim_set_string_attribute(staller, "statistics", &av );
}
}
/**
* dump_cache_stat_attrs()
* Iterate over the list of cache stats attrs
* available for caches, and print to the output
* stream the cache name, attribute name, and attribute
* value for the cache specified by the conf_object_t * pCache.
*/
void dump_cache_stat_attrs( ostream * pStream,
system_component_object_t * pCache,
char * lpszCacheName ) {
// integer_attribute_t av;
// integer_attribute_t *pAttrValue = &av;
int nCacheAttrs = 0;
while( gvszCacheStats[nCacheAttrs] != NULL ) {
//av = osa_sim_get_integer_attribute( pCache, gvszCacheStats[nCacheAttrs] );
int arg = osa_sim_get_integer_attribute( pCache, gvszCacheStats[nCacheAttrs] );
*pStream << lpszCacheName << ": " << gvszCacheStats[nCacheAttrs];
*pStream << ":\t" << arg << endl;
nCacheAttrs++;
// SIM_free_attribute(av);
}
}
/**
* tabular_cache_stat_attrs()
* Iterate over the list of cache stats attrs
* available for caches, and print to the output
* stream the cache name, attribute name, and attribute
* value for the cache specified by the conf_object_t * pCache.
* Output is in tabular form, with the delimiter
* specified.
*/
void tabular_cache_stat_attrs( ostream * pStream,
system_component_object_t * pCache,
char * lpszCacheName,
const char * lpszDelimiter,
bool bRowNames ) {
// integer_attribute_t av;
//integer_attribute_t *pAttrValue = &av;
int nCacheAttrs = 0;
if( bRowNames )
*pStream << lpszCacheName << lpszDelimiter;
while( gvszCacheStats[nCacheAttrs] != NULL ) {
//av = osa_sim_get_integer_attribute( pCache, gvszCacheStats[nCacheAttrs] );
int arg = osa_sim_get_integer_attribute( pCache, gvszCacheStats[nCacheAttrs] );
//*pStream << INTEGER_ARGUMENT << lpszDelimiter;
*pStream << arg << lpszDelimiter;
nCacheAttrs++;
// osa_sim_free_attribute(av);
}
*pStream << endl;
}
/**
* dump_cache_table_headers()
* Dump a delimiter-separated list of column
* names. If the bRowNames flag is set, this
* means the number of columns needs to be shifted
* one to accomodate the extra column
*/
void dump_cache_table_headers( ostream * pStream,
const char * lpszDelimiter,
bool bRowNames,
bool bColNames ) {
if( !bColNames )
return;
int nCacheAttrs = 0;
if( bRowNames )
*pStream << "" << lpszDelimiter;
while( gvszCacheStats[nCacheAttrs] != NULL ) {
*pStream << gvszCacheStats[nCacheAttrs] << lpszDelimiter;
nCacheAttrs++;
}
*pStream << endl;
}
/**
* dump_sb_stat_attrs()
* Iterate over the list of storebuffer stats attrs
* available for caches, and print to the output
* stream the cache name, attribute name, and attribute
* value for the cache specified by the conf_object_t * ptxsb.
*/
void dump_sb_stat_attrs(ostream * pStream,
system_component_object_t * ptxsb,
char * lpsz) {
int nCacheAttrs = 0;
while(gvszTxsbStats[nCacheAttrs] != NULL ) {
int arg = osa_sim_get_integer_attribute( ptxsb, gvszTxsbStats[nCacheAttrs] );
*pStream << lpsz << ": " << gvszTxsbStats[nCacheAttrs];
*pStream << ":\t" << arg << endl;
nCacheAttrs++;
}
}
/**
* tabular_sb_stat_attrs()
* Iterate over the list of storebuffer stats attrs
* available for caches, and print to the output
* stream the store buffer name, attribute name, and attribute.
* Output is in tabular form, with the delimiter
* specified.
*/
void tabular_sb_stat_attrs(ostream * pStream,
system_component_object_t * ptxsb,
char * lpsz,
const char * lpszDelimiter,
bool bRowNames) {
int nCacheAttrs = 0;
if( bRowNames )
*pStream << lpsz << lpszDelimiter;
while( gvszTxsbStats[nCacheAttrs] != NULL ) {
int arg = osa_sim_get_integer_attribute(ptxsb, gvszTxsbStats[nCacheAttrs] );
*pStream << arg << lpszDelimiter;
nCacheAttrs++;
}
*pStream << endl;
}
/**
* dump_sb_table_headers()
* Dump a delimiter-separated list of column
* names. If the bRowNames flag is set, this
* means the number of columns needs to be shifted
* one to accomodate the extra column
*/
void dump_sb_table_headers(ostream * pStream,
const char * lpszDelimiter,
bool bRowNames,
bool bColNames ) {
if( !bColNames )
return;
int nCacheAttrs = 0;
if( bRowNames )
*pStream << "" << lpszDelimiter;
while( gvszTxsbStats[nCacheAttrs] != NULL ) {
*pStream << gvszTxsbStats[nCacheAttrs] << lpszDelimiter;
nCacheAttrs++;
}
*pStream << endl;
}
/**
* dump_cache_statistics()
* Called when OSA_DUMPSTATS magic breakpoint
* occurs--iterates over caches defined on the
* timing model chain, and dumps statistics for
* devices on that chain to the ostream supplied.
*/
void dump_cache_statistics( int nCaches,
ostream * pStream,
int bTabular,
const char * lpszDelim,
bool bRowNames,
bool bColNames,
const char *prefix) {
int i;
char szsb[OSATXM_BUFSIZE];
char szICacheName[OSATXM_BUFSIZE];
char szDCacheName[OSATXM_BUFSIZE];
char szL2CacheName[OSATXM_BUFSIZE];
system_component_object_t * picache = NULL;
system_component_object_t * pdcache = NULL;
system_component_object_t * pl2cache = NULL;
system_component_object_t * pstorebuffer = NULL;
system_component_object_t * pstaller = NULL;
for (i=0; i<nCaches; i++) {
sprintf( szICacheName, "%sicache%d", prefix, i );
sprintf( szDCacheName, "%sdcache%d", prefix, i );
sprintf( szL2CacheName, "%sl2cache%d", prefix, i );
picache = osa_get_object_by_name( szICacheName );
pdcache = osa_get_object_by_name( szDCacheName );
pl2cache = osa_get_object_by_name( szL2CacheName );
*pStream << "Cache Statistics for CPU " << i << ": (";
if(picache) *pStream << szICacheName << ",";
if(pdcache) *pStream << szDCacheName;
if(pl2cache) *pStream << ", " << szL2CacheName;
*pStream << ")" << endl;
*pStream << "--------------------------------------------------" << endl;
if( bTabular ) {
dump_cache_table_headers( pStream, lpszDelim, true, true );
if(picache != NULL)
tabular_cache_stat_attrs( pStream, picache, szICacheName, lpszDelim, true );
if(pdcache != NULL){
tabular_cache_stat_attrs( pStream, pdcache, szDCacheName, lpszDelim, true );
}
if(pl2cache != NULL)
tabular_cache_stat_attrs( pStream, pl2cache, szL2CacheName, lpszDelim, true );
} else {
if(picache != NULL)
dump_cache_stat_attrs( pStream, picache, szICacheName );
if(pdcache != NULL)
dump_cache_stat_attrs( pStream, pdcache, szDCacheName );
if(pl2cache != NULL)
dump_cache_stat_attrs( pStream, pl2cache, szL2CacheName );
}
// Clear the general exception that may have arisen if the
// caches don't exist
if (osa_sim_get_error() != NO_ERROR){
osa_sim_clear_error();
}
}
*pStream << "--------------------------------------------------" << endl;
for (i=0; i<nCaches; i++) {
sprintf( szsb, "%ssb%d", prefix, i );
pstorebuffer = osa_get_object_by_name( szsb );
if(!pstorebuffer)
continue;
*pStream << "Store Buffer Statistics for CPU " << i << ": (";
if(pstorebuffer) *pStream << szsb;
*pStream << ")" << endl;
*pStream << "--------------------------------------------------" << endl;
if( bTabular ) {
dump_sb_table_headers( pStream, lpszDelim, true, true );
tabular_sb_stat_attrs( pStream, pstorebuffer, szsb, lpszDelim, true );
} else {
dump_sb_stat_attrs( pStream, pstorebuffer, szsb );
}
// Clear the general exception that may have arisen if the
// caches don't exist
if (osa_sim_get_error() != NO_ERROR){
osa_sim_clear_error();
}
}
*pStream << "--------------------------------------------------" << endl;
pstaller = osa_get_object_by_name("staller");
if(pstaller) {
attr_value_t statsattr = SIM_get_attribute(pstaller, "statistics");
string ststats = statsattr.u.string;
*pStream << "Staller statistics" << endl;
*pStream << ststats;
*pStream << "Staller time series" << endl;
attr_value_t epochlist;
attr_value_t avlist = SIM_get_attribute(pstaller, "epoch_time_series");
for(int i=0; i<avlist.u.list.size; i++) {
epochlist = avlist.u.list.vector[i];
int epochsize = epochlist.u.list.size;
*pStream << "[";
for(int j=0; j<epochsize; j++) {
*pStream << epochlist.u.list.vector[j].u.floating;
if(j!=epochsize-1) *pStream << ",";
}
*pStream << "]" << endl;
}
*pStream << "--------------------------------------------------" << endl;
}
}
/*
* If the timing_model attribute is set, we need to
* also pass the memory transaction on to it, and
* add any cycle cost estimates it returns to the
* current penalty. We cannot, however, return 0 and
* expect consistent results. If the rest of the timing
* chain fails to come up with anything reasonable,
* return a 1 cycle penalty to ensure forward progress.
*/
osa_cycles_t
collect_cache_timing( TIMING_SIGNATURE )
{
int penalty = 0;
osamod_t * pOsaTxm = (osamod_t *) pConfObject;
/*
* Here we distribute the memory transaction to
* any attribute/interface that is registered as
* interested in the the timing_model interface
* half of memory transactions. For osatxm, there
* are two such attributes:
* 1) timing_model
* 2) caches.
* ---------------------------
* Collect mem-transaction penalty in cycles
* for both (Both should probably not be set or
* we will over-charge for the memory operation!).
*/
if( pOsaTxm->ppCaches != NULL
&& !((pOsaTxm->type == SYNCCHAR ||
pOsaTxm->type == SYNCCOUNT ||
pOsaTxm->type == COMMON
)// Don't "double-count" cycles if modules are chained
&& pOsaTxm->timing_model != NULL)) {
int nProcessor = pOsaTxm->minfo->getCpuNum(OSA_get_sim_cpu());
int nCaches = pOsaTxm->nCaches;
if( nProcessor >= nCaches ) {
cout << "collect_cache_timing: SEVERE ERROR: nCaches = " << nCaches << "\n";
}
if( pOsaTxm->tx_trace && false ) {
cout << "mem tx src cpu:" << nProcessor << "-> cache timing chain\n";
}
timing_model_interface_t * pTIfc = pOsaTxm->ppCachesIfc[nProcessor];
conf_object_t * pCache = pOsaTxm->ppCaches[nProcessor];
OSA_assert( pTIfc != NULL , pOsaTxm);
OSA_assert( pCache != NULL , pOsaTxm);
penalty += pTIfc->operate( TIMING_ARGUMENTS_1 );
}
if( pOsaTxm->timing_model != NULL ) {
if( pOsaTxm->tx_trace ) {
// Before uncommenting this, know that it build breaks on 64-bit..
// fprintf( stdout, "pOsaTxm = %08x, g_osatxm = %08x\n",
// (unsigned int) pOsaTxm,
// (unsigned int) g_osatxm );
// fprintf( stdout, "pOsaTxm->timing_ifc = %08x, pOsaTxm->timing_model = %08x\n",
// (unsigned int) pOsaTxm->timing_ifc,
// (unsigned int) pOsaTxm->timing_model );
}
penalty += pOsaTxm->timing_ifc->operate( TIMING_ARGUMENTS_2 );
}
return penalty;
}
/**
* set_timing_model()
* set the timing model attribute
* which allows timing model chaining
*/
osa_attr_set_t
set_timing_model( SIMULATOR_SET_GENERIC_ATTRIBUTE_SIGNATURE )
{
osamod_t *pOsaTxm = (osamod_t *) obj;
#ifdef _USE_SIMICS //OSA_TODO What about QEMU?
if( pAttrValue->kind == Sim_Val_Nil) {
pOsaTxm->timing_model = NULL;
pOsaTxm->timing_ifc = NULL;
} else
#endif
{
pOsaTxm->timing_ifc = (timing_model_interface_t *)
osa_sim_get_interface( GENERIC_ARGUMENT,
TIMING_MODEL_INTERFACE);
if( osa_sim_clear_error() ) {
//OSA_TODO
#ifdef _USE_SIMICS
SIM_log_error( &pOsaTxm->log, 1,
"osatxm::set_timing_model: "
"object '%s' does not provide the timing model "
"interface.", pAttrValue->u.object->name );
#endif
return INTERFACE_NOT_FOUND_ERR;
}
pOsaTxm->timing_model = GENERIC_ARGUMENT;
}
return ATTR_OK;
}
/**
* get_timing_model()
* get the timing model attribute
* which allows timing model chaining
*/
generic_attribute_t
get_timing_model( SIMULATOR_GET_ATTRIBUTE_SIGNATURE )
{
osamod_t *pOsaTxm = (osamod_t *)obj;
return GENERIC_ATTRIFY(pOsaTxm->timing_model);
}
/**
* set_caches()
* set the list of caches,
* which is a simics list attribute
* containing per-cpu caches interested
* in knowing about memory transactions
* the bus.
*/
osa_attr_set_t //OSA_TODO: Lots of work needed here
set_caches( SIMULATOR_SET_LIST_ATTRIBUTE_SIGNATURE )
{
int i;
generic_attribute_t *pCache = NULL;
osamod_t * pOsaTxm = (osamod_t*) obj;
int nCaches = LIST_ARGUMENT_SIZE;
MM_FREE( pOsaTxm->ppCaches );
MM_FREE( pOsaTxm->ppCachesIfc );
pOsaTxm->nCaches = nCaches;
pOsaTxm->ppCaches = MM_MALLOC( nCaches, system_component_object_t *);
pOsaTxm->ppCachesIfc = MM_MALLOC( nCaches, timing_model_interface_t * );
for( i=0; i<nCaches; i++ ) {
pCache = &LIST_ARGUMENT(i);
pOsaTxm->ppCachesIfc[i] = (timing_model_interface_t *)
osa_sim_get_interface( GENERIC_ATTR(*pCache),
TIMING_MODEL_INTERFACE );
if( osa_sim_clear_error()) {
#ifdef _USE_SIMICS
SIM_log_error( &pOsaTxm->log, 1,
"set_caches: "
"object %d does not provide the timing model "
"listen interface.", i);
#else
std::cout << "\nset caches: object "
<< i <<" does not provide the timing model listen interface.";
#endif
pOsaTxm->nCaches = 0;
MM_FREE(pOsaTxm->ppCaches);
MM_FREE(pOsaTxm->ppCachesIfc);
pOsaTxm->ppCaches = NULL;
pOsaTxm->ppCachesIfc = NULL;
return INTERFACE_NOT_FOUND_ERR;
}
pOsaTxm->ppCaches[i] = pCache->u.object;
}
return ATTR_OK;
}
/**
* get_caches()
* get the list of caches,
* which is a simics list attribute
* containing per-cpu cache objects interested
* in knowing about memory transactions
* the bus.
*/
list_attribute_t
get_caches( SIMULATOR_GET_ATTRIBUTE_SIGNATURE )
{
int i;
list_attribute_t avReturn;
osamod_t * pOsaTxm = (osamod_t *) obj;
#ifdef _USE_SIMICS
avReturn.kind = Sim_Val_Nil;
#endif
if( pOsaTxm->ppCaches ) {
avReturn = osa_sim_allocate_list(pOsaTxm->nCaches);
/*
avReturn.kind = Sim_Val_List;
avReturn.u.list.vector = MM_MALLOC( pOsaTxm->nCaches, attr_value_t);
avReturn.u.list.size = pOsaTxm->nCaches;
*/
for (i=0; i<pOsaTxm->nCaches; i++) {
/*avReturn.u.list.vector[i].kind = Sim_Val_Object;
avReturn.u.list.vector[i].u.object = pOsaTxm->ppCaches[i];
*/
LIST_ATTR(avReturn, i) = GENERIC_ATTRIFY(pOsaTxm->ppCaches[i]);
}
}
return avReturn;
}
/*
* find_staller
* chase through the cache hierarchy until we find a staller
* object, or conclude that one is not present. Don't assume
* a particular structure to the hierarchy, other than that
* there must be a splitter at the cpu (for i/d).
*/
system_component_object_t *
find_staller(system_component_object_t *pConfObject, int procNum) {
osamod_t * osamod = (osamod_t *) pConfObject;
system_component_object_t *pstorebuffer = NULL;
system_component_object_t *pcache = NULL;
system_component_object_t *pstaller = NULL;
system_component_object_t *psplitter = NULL;
system_component_object_t *pbranch = NULL;
if(NULL == osamod->ppCaches) return NULL;
if(NULL == (psplitter = osamod->ppCaches[procNum]))
goto clear_exception;
if(NULL == (pbranch = osa_sim_get_generic_attribute(psplitter, "dbranch")))
goto clear_exception;
if(NULL == (pstorebuffer = osa_sim_get_generic_attribute(pbranch, "cache")))
goto clear_exception;
if(NULL == (pcache = osa_sim_get_generic_attribute(pstorebuffer, "timing_model")))
goto clear_exception;
do {
/* follow timing_model connections until we find a staller */
if(NULL == (pstaller = osa_sim_get_generic_attribute(pcache, "timing_model")))
goto clear_exception;
pcache = pstaller;
} while(strncmp(pstaller->name, "staller", strlen("staller")));
return pstaller;
clear_exception:
if (osa_sim_get_error ()!= NO_ERROR)
osa_sim_clear_error();
return NULL;
}
/*
* find_l1_dcache
* chase through the cache hierarchy until we find a staller
* object, or conclude that one is not present. Don't assume
* a particular structure to the hierarchy, other than that
* there must be a splitter at the cpu (for i/d).
*/
system_component_object_t *
find_l1_dcache(system_component_object_t *pConfObject, int procNum) {
osamod_t * osamod = (osamod_t *) pConfObject;
system_component_object_t *pstorebuffer = NULL;
system_component_object_t *pcache = NULL;
system_component_object_t *psplitter = NULL;
system_component_object_t *pbranch = NULL;
if(NULL == osamod->ppCaches) return NULL;
if(NULL == (psplitter = osamod->ppCaches[procNum]))
goto clear_exception;
if(NULL == (pbranch = osa_sim_get_generic_attribute(psplitter, "dbranch")))
goto clear_exception;
if(NULL == (pstorebuffer = osa_sim_get_generic_attribute(pbranch, "cache")))
goto clear_exception;
if(NULL == (pcache = osa_sim_get_generic_attribute(pstorebuffer, "timing_model")))
goto clear_exception;
return pcache;
clear_exception:
if (osa_sim_get_error ()!= NO_ERROR)
osa_sim_clear_error();
return NULL;
}
/*
* hierarchy_entry
* get a pointer to the object at the top
* of the cache hierarchy.
*/
system_component_object_t *
hierarchy_entry(system_component_object_t *pConfObject, int procNum) {
osamod_t * osamod = (osamod_t *) pConfObject;
system_component_object_t *psplitter = NULL;
if(NULL == osamod->ppCaches) return NULL;
if(NULL == (psplitter = osamod->ppCaches[procNum]))
goto clear_exception;
return psplitter;
clear_exception:
if (osa_sim_get_error ()!= NO_ERROR)
osa_sim_clear_error();
return NULL;
}
/*
* memhier_exercise
* perform a load or store in the memory hierarchy--
* this only exercises the traffic and computes latency. No data are
* actually read or written to or from physmem. NB: caller must
* provide logical to physical mapping!
*/
osa_cycles_t
memhier_exercise(system_component_object_t * obj,
osa_logical_address_t laddr,
osa_physical_address_t paddr,
unsigned int bytes,
int procNum,
bool isread) {
osa_cycles_t latency = 0;
timing_model_interface_t * ifc = NULL;
system_component_object_t * top = hierarchy_entry(obj, procNum);
if(top) {
generic_transaction_t mt;
memset(&mt, 0, sizeof mt);
mt.logical_address = laddr;
mt.physical_address = paddr;
mt.size = bytes;
mt.may_stall = 1;
mt.ini_type = Sim_Initiator_CPU;
mt.ini_ptr = (conf_object_t *) obj;
mt.exception = Sim_PE_No_Exception;
SIM_set_mem_op_type(&mt, isread ? Sim_Trans_Load : Sim_Trans_Store);
ifc = (timing_model_interface_t *) SIM_get_interface(top,
TIMING_MODEL_INTERFACE);
if(ifc) {
latency += ifc->operate(top, NULL, NULL, &mt);
}
if(osa_sim_get_error ()!= NO_ERROR)
osa_sim_clear_error();
}
return latency;
}
/*
* memhier_load()
* perform a load in the memory hierarchy.
*/
osa_cycles_t
memhier_load(system_component_object_t * obj,
osa_logical_address_t laddr,
osa_physical_address_t paddr,
unsigned int bytes,
int procNum) {
return memhier_exercise(obj,
laddr,
paddr,
bytes,
procNum,
true);
}
/*
* memhier_store()
* perform a store in the memory hierarchy.
*/
osa_cycles_t
memhier_store(system_component_object_t * obj,
osa_logical_address_t laddr,
osa_physical_address_t paddr,
unsigned int bytes,
int procNum) {
return memhier_exercise(obj,
laddr,
paddr,
bytes,
procNum,
false);
}
/*
* memhier_load_block
* perform a load in the memory hierarchy with
* given granularity--this only exercises the traffic
* and computes latency. No data are actually read from
* physmem. WARNING: if the memop crosses a cache line
* boundary, this routine will miss it--achtung!
*/
osa_cycles_t
memhier_load_block(system_component_object_t * obj,
osa_logical_address_t laddr,
osa_physical_address_t paddr,
unsigned int granularity,
unsigned int bytes,
int procNum) {
return memhier_load(obj,
laddr & ~(granularity-1),
paddr & ~(granularity-1),
granularity,
procNum);
}
/*
* memhier_store_block
* perform a store in the memory hierarchy with
* given granularity--this only exercises the traffic
* and computes latency. No data are actually written to
* physmem. WARNING: if the memop crosses a cache line
* boundary, this routine will miss it!
*/
osa_cycles_t
memhier_store_block(system_component_object_t * obj,
osa_logical_address_t laddr,
osa_physical_address_t paddr,
unsigned int granularity,
unsigned int bytes,
int procNum) {
return memhier_store(obj,
laddr & ~(granularity-1),
paddr & ~(granularity-1),
granularity,
procNum);
}
/*
* find_storebuffer
* chase through the cache hierarchy until we find a storebuffer
*/
system_component_object_t *
find_storebuffer(system_component_object_t *pConfObject, int procNum) {
osamod_t * osamod = (osamod_t *) pConfObject;
system_component_object_t *pstorebuffer = NULL;
system_component_object_t *psplitter = NULL;
system_component_object_t *pbranch = NULL;
if(NULL == osamod->ppCaches) return NULL;
if(NULL == (psplitter = osamod->ppCaches[procNum]))
goto clear_exception;
if(NULL == (pbranch = osa_sim_get_generic_attribute(psplitter, "dbranch")))
goto clear_exception;
if(NULL == (pstorebuffer = osa_sim_get_generic_attribute(pbranch, "cache")))
goto clear_exception;
return pstorebuffer;
clear_exception:
if (osa_sim_get_error ()!= NO_ERROR)
osa_sim_clear_error();
return NULL;
}
int get_l1_dcache_size(system_component_object_t *pConfObject, int procNum) {
int size = 0;
osamod_t * osamod = (osamod_t *) pConfObject;
if(!osamod->ppCaches) return size;
conf_object_t *pdcache = find_l1_dcache(pConfObject, procNum);
if (pdcache != NULL) {
int line_number = osa_sim_get_integer_attribute(pdcache, "config_line_number");
int line_size = osa_sim_get_integer_attribute(pdcache, "config_line_size");
size = line_number * line_size;
} else {
if (osa_sim_get_error ()!= NO_ERROR) {
osa_sim_clear_error();
}
}
return size;
}
unsigned int
get_txcache_size(system_component_object_t *pConfObject, int procNum) {
return get_l1_dcache_size(pConfObject, procNum);
}
unsigned int
get_txcache_block_size(system_component_object_t *pConfObject, int procNum) {
int size = 0;
osamod_t * osamod = (osamod_t *) pConfObject;
if(!osamod->ppCaches || !osamod->ppCaches[procNum]) return 0;
conf_object_t * pdcache = find_l1_dcache(pConfObject, procNum);
if (pdcache != NULL) {
size = osa_sim_get_integer_attribute(pdcache, "config_line_size");
} else {
if(osa_sim_get_error ()!= NO_ERROR) {
osa_sim_clear_error();
}
}
return size;
}
/*
* get_cache_perturb
* chase down the cache hierarchy until we find a staller,
* which is assumed to be a trans-staller-plus, from which
* we can extract the cache perturbation attributes.
* Technically, we could probably just use the global
* staller object, but this technique is more general,
* and since we're only going to do this once at startup,
* the performance hit of traversing the whole heirarchy
* is not such a big deal.
*/
void get_cache_perturb(system_component_object_t *pConfObject,
int procNum,
int *pcache_perturb,
int *pcache_seed) {
osamod_t * osamod = (osamod_t *) pConfObject;
system_component_object_t *pstaller = NULL;
OSA_assert((pcache_perturb && pcache_seed), osamod);
*pcache_perturb = *pcache_seed = 0;
if(NULL == osamod->ppCaches) return;
if(NULL == (pstaller = find_staller(pConfObject, procNum)))
return;
*pcache_perturb = osa_sim_get_integer_attribute(pstaller, "cache_perturb");
*pcache_seed = osa_sim_get_integer_attribute(pstaller, "seed");
return;
}
void enable_cache_perturb(system_component_object_t *pConfObject, int procNum){
osamod_t * osamod = (osamod_t *) pConfObject;
if(!osamod->nCaches)
return; // nothing to do!
system_component_object_t *pstaller = NULL;
boolean_attribute_t av = BOOL_ATTRIFY(1);
if(NULL == osamod->ppCaches){
cout << "Warning - cannot enable cache perturbation without the cache hierarchy" << endl;
return;
}
if(NULL == (pstaller = find_staller(pConfObject, procNum)))
return;
if(ATTR_OK != osa_sim_set_boolean_attribute(pstaller, "past_bios", &av))
goto clear_exception;
return;
clear_exception:
if (osa_sim_get_error ()!= NO_ERROR)
osa_sim_clear_error();
}
osa_cycles_t commitTxCache(system_component_object_t *obj,
int currentTxID) {
osa_cycles_t latency = 0;
abort_commit_interface_t * ifc = NULL;
system_component_object_t * pdcache = NULL;
system_component_object_t * pstorebuffer = NULL;
osamod_t * osamod = (osamod_t *) obj;
int procNum = osamod->minfo->getCpuNum(OSA_get_sim_cpu());
if(!osamod->use_txcache ||
!osamod->ppCaches ||
!osamod->ppCaches[procNum])
goto clear_exception;
if(NULL == (pdcache = find_l1_dcache(obj, procNum)))
goto clear_exception;
osamod->abort_commit_ifc = (abort_commit_interface_t *) osa_sim_get_interface(pdcache, "abort-commit-interface");
latency += osamod->abort_commit_ifc->commitTx(pdcache, currentTxID);
if(NULL == (pstorebuffer = find_storebuffer(obj, procNum)))
goto clear_exception;
ifc = (abort_commit_interface_t *) osa_sim_get_interface(pstorebuffer, "abort-commit-interface");
latency += ifc->commitTx(pstorebuffer, currentTxID);
return latency;
clear_exception:
if (osa_sim_get_error ()!= NO_ERROR)
osa_sim_clear_error();
return latency;
}
osa_cycles_t abortTxCache(conf_object_t * obj, int currentTxID, int procNum) {
osa_cycles_t latency = 0;
osamod_t * osamod = (osamod_t *) obj;
conf_object_t *pdcache = NULL;
conf_object_t *pstorebuffer = NULL;
abort_commit_interface_t * ifc = NULL;
if(!osamod->use_txcache || !osamod->ppCaches)
goto clear_exception;
if(NULL == (pdcache = find_l1_dcache(obj, procNum)))
goto clear_exception;
osamod->abort_commit_ifc = (abort_commit_interface_t *) osa_sim_get_interface(pdcache, "abort-commit-interface");
latency += osamod->abort_commit_ifc->abortTx(pdcache, currentTxID);
if(NULL == (pstorebuffer = find_storebuffer(obj, procNum)))
goto clear_exception;
ifc = (abort_commit_interface_t *) osa_sim_get_interface(pstorebuffer, "abort-commit-interface");
latency += ifc->abortTx(pstorebuffer, currentTxID);
return latency;
clear_exception:
if (SIM_get_pending_exception ()!= NO_ERROR)
SIM_clear_exception();
return latency;
}
void earlyRelease(system_component_object_t *obj,
osa_physical_address_t paddr,
osa_logical_address_t laddr,
int currentTxID) {
abort_commit_interface_t * ifc = NULL;
system_component_object_t *pdcache = NULL;
system_component_object_t *pstorebuffer = NULL;
osamod_t * osamod = (osamod_t *) obj;
int procNum = osamod->minfo->getCpuNum(OSA_get_sim_cpu());
if(!osamod->use_txcache ||
!osamod->ppCaches ||
!osamod->ppCaches[procNum])
goto clear_exception;
if(NULL == (pdcache = find_l1_dcache(obj, procNum)))
goto clear_exception;
osamod->abort_commit_ifc = (abort_commit_interface_t *) osa_sim_get_interface(pdcache, "abort-commit-interface");
osamod->abort_commit_ifc->earlyRelease(pdcache, paddr, laddr, currentTxID);
if(NULL == (pstorebuffer = find_storebuffer(obj, procNum)))
goto clear_exception;
ifc = (abort_commit_interface_t *) osa_sim_get_interface(pstorebuffer, "abort-commit-interface");
ifc->earlyRelease(pstorebuffer, paddr, laddr, currentTxID);
return;
clear_exception:
if (osa_sim_get_error ()!= NO_ERROR)
osa_sim_clear_error();
}
/*
* Local variables:
* c-indent-level: 3
* c-basic-offset: 3
* indent-tabs-mode: nil
* tab-width: 3
* End:
*
* vim: ts=3 sw=3 expandtab
*/
| 33.070547 | 116 | 0.646259 | ut-osa |
bad818c0912e9953676db2a077bd411ec714a159 | 2,560 | cpp | C++ | src/engine/scene/camera/OrthoCamera.cpp | zapolnov/TankHero | a907417dc171cb0d4ea04539ae09ba37ee7782ab | [
"MIT"
] | null | null | null | src/engine/scene/camera/OrthoCamera.cpp | zapolnov/TankHero | a907417dc171cb0d4ea04539ae09ba37ee7782ab | [
"MIT"
] | null | null | null | src/engine/scene/camera/OrthoCamera.cpp | zapolnov/TankHero | a907417dc171cb0d4ea04539ae09ba37ee7782ab | [
"MIT"
] | null | null | null | #include "OrthoCamera.h"
#include <glm/gtc/matrix_transform.hpp>
OrthoCamera::OrthoCamera()
: mLeft(-1.0f)
, mTop(1.0f)
, mRight(1.0f)
, mBottom(-1.0f)
, mNearZ(-10.0f)
, mFarZ(10.0f)
{
}
void OrthoCamera::setLeft(float left)
{
if (mLeft != left) {
mLeft = left;
invalidateProjectionMatrix();
}
}
void OrthoCamera::setTop(float top)
{
if (mTop != top) {
mTop = top;
invalidateProjectionMatrix();
}
}
void OrthoCamera::setRight(float right)
{
if (mRight != right) {
mRight = right;
invalidateProjectionMatrix();
}
}
void OrthoCamera::setBottom(float bottom)
{
if (mBottom != bottom) {
mBottom = bottom;
invalidateProjectionMatrix();
}
}
void OrthoCamera::setDimensions(float left, float right, float bottom, float top)
{
if (mLeft != left || mRight != right || mBottom != bottom || mTop != top) {
mLeft = left;
mRight = right;
mTop = top;
mBottom = bottom;
invalidateProjectionMatrix();
}
}
void OrthoCamera::setSize(float width, float height)
{
float oldSizeX = (mRight - mLeft);
float oldSizeY = (mBottom - mTop);
if (oldSizeX == width && oldSizeY == height)
return;
float centerX = mLeft + oldSizeX * 0.5f;
float centerY = mTop + oldSizeY * 0.5f;
float halfWidth = width * 0.5f;
float halfHeight = height * 0.5f;
if (mLeft > mRight)
halfWidth = -halfWidth;
if (mTop > mBottom)
halfHeight = -halfHeight;
mLeft = centerX - halfWidth;
mRight = centerX + halfWidth;
mTop = centerY - halfHeight;
mBottom = centerY + halfHeight;
invalidateProjectionMatrix();
}
void OrthoCamera::setNearZ(float nearZ)
{
if (mNearZ != nearZ) {
mNearZ = nearZ;
invalidateProjectionMatrix();
}
}
void OrthoCamera::setFarZ(float farZ)
{
if (mFarZ != farZ) {
mFarZ = farZ;
invalidateProjectionMatrix();
}
}
void OrthoCamera::setZRange(float nearZ, float farZ)
{
if (mNearZ != nearZ || mFarZ != farZ) {
mNearZ = nearZ;
mFarZ = farZ;
invalidateProjectionMatrix();
}
}
bool OrthoCamera::unproject2D(glm::vec2& point)
{
point = glm::vec2(inverseProjectionViewMatrix() * glm::vec4(point, 0.0f, 1.0f));
return true;
}
void OrthoCamera::calcProjectionMatrix(glm::mat4& m) const
{
m = glm::ortho(mLeft, mRight, mBottom, mTop, mNearZ, mFarZ);
}
void OrthoCamera::calcViewMatrix(glm::mat4& m) const
{
m = glm::mat4(1.0f);
}
| 20.645161 | 84 | 0.603125 | zapolnov |
bada555810c2c66cf5c07f4c5f30bcfab431ad44 | 9,358 | cpp | C++ | src/gpu/GrTextureRenderTargetProxy.cpp | aam/skia | e7bc0844989faff96aa22ae052cc8603d6f8c6b9 | [
"BSD-3-Clause"
] | 1 | 2021-04-09T23:24:57.000Z | 2021-04-09T23:24:57.000Z | src/gpu/GrTextureRenderTargetProxy.cpp | aam/skia | e7bc0844989faff96aa22ae052cc8603d6f8c6b9 | [
"BSD-3-Clause"
] | null | null | null | src/gpu/GrTextureRenderTargetProxy.cpp | aam/skia | e7bc0844989faff96aa22ae052cc8603d6f8c6b9 | [
"BSD-3-Clause"
] | null | null | null | /*
* Copyright 2016 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#include "src/gpu/GrTextureRenderTargetProxy.h"
#include "include/gpu/GrTexture.h"
#include "src/gpu/GrCaps.h"
#include "src/gpu/GrContextPriv.h"
#include "src/gpu/GrRenderTarget.h"
#include "src/gpu/GrRenderTargetProxyPriv.h"
#include "src/gpu/GrSurfacePriv.h"
#include "src/gpu/GrSurfaceProxyPriv.h"
#include "src/gpu/GrTexturePriv.h"
#include "src/gpu/GrTextureProxyPriv.h"
// Deferred version
// This class is virtually derived from GrSurfaceProxy (via both GrTextureProxy and
// GrRenderTargetProxy) so its constructor must be explicitly called.
GrTextureRenderTargetProxy::GrTextureRenderTargetProxy(const GrCaps& caps,
const GrBackendFormat& format,
const GrSurfaceDesc& desc,
int sampleCnt,
GrSurfaceOrigin origin,
GrMipMapped mipMapped,
GrMipMapsStatus mipMapsStatus,
const GrSwizzle& texSwizzle,
const GrSwizzle& outSwizzle,
SkBackingFit fit,
SkBudgeted budgeted,
GrProtected isProtected,
GrInternalSurfaceFlags surfaceFlags,
UseAllocator useAllocator)
: GrSurfaceProxy(format, desc, GrRenderable::kYes, origin, texSwizzle, fit, budgeted,
isProtected, surfaceFlags, useAllocator)
// for now textures w/ data are always wrapped
, GrRenderTargetProxy(caps, format, desc, sampleCnt, origin, texSwizzle, outSwizzle, fit,
budgeted, isProtected, surfaceFlags, useAllocator)
, GrTextureProxy(format, desc, origin, mipMapped, mipMapsStatus, texSwizzle, fit, budgeted,
isProtected, surfaceFlags, useAllocator) {
this->initSurfaceFlags(caps);
}
// Lazy-callback version
GrTextureRenderTargetProxy::GrTextureRenderTargetProxy(const GrCaps& caps,
LazyInstantiateCallback&& callback,
const GrBackendFormat& format,
const GrSurfaceDesc& desc,
int sampleCnt,
GrSurfaceOrigin origin,
GrMipMapped mipMapped,
GrMipMapsStatus mipMapsStatus,
const GrSwizzle& texSwizzle,
const GrSwizzle& outSwizzle,
SkBackingFit fit,
SkBudgeted budgeted,
GrProtected isProtected,
GrInternalSurfaceFlags surfaceFlags,
UseAllocator useAllocator)
: GrSurfaceProxy(std::move(callback), format, desc, GrRenderable::kYes, origin, texSwizzle,
fit, budgeted, isProtected, surfaceFlags, useAllocator)
// Since we have virtual inheritance, we initialize GrSurfaceProxy directly. Send null
// callbacks to the texture and RT proxies simply to route to the appropriate constructors.
, GrRenderTargetProxy(LazyInstantiateCallback(), format, desc, sampleCnt, origin,
texSwizzle, outSwizzle, fit, budgeted, isProtected, surfaceFlags,
useAllocator, WrapsVkSecondaryCB::kNo)
, GrTextureProxy(LazyInstantiateCallback(), format, desc, origin, mipMapped, mipMapsStatus,
texSwizzle, fit, budgeted, isProtected, surfaceFlags, useAllocator) {
this->initSurfaceFlags(caps);
}
// Wrapped version
// This class is virtually derived from GrSurfaceProxy (via both GrTextureProxy and
// GrRenderTargetProxy) so its constructor must be explicitly called.
GrTextureRenderTargetProxy::GrTextureRenderTargetProxy(sk_sp<GrSurface> surf,
GrSurfaceOrigin origin,
const GrSwizzle& texSwizzle,
const GrSwizzle& outSwizzle,
UseAllocator useAllocator)
: GrSurfaceProxy(surf, origin, texSwizzle, SkBackingFit::kExact, useAllocator)
, GrRenderTargetProxy(surf, origin, texSwizzle, outSwizzle, useAllocator)
, GrTextureProxy(surf, origin, texSwizzle, useAllocator) {
SkASSERT(surf->asTexture());
SkASSERT(surf->asRenderTarget());
SkASSERT(fSurfaceFlags == fTarget->surfacePriv().flags());
SkASSERT((this->numSamples() <= 1 ||
fTarget->getContext()->priv().caps()->msaaResolvesAutomatically()) !=
this->requiresManualMSAAResolve());
}
void GrTextureRenderTargetProxy::initSurfaceFlags(const GrCaps& caps) {
// FBO 0 should never be wrapped as a texture render target.
SkASSERT(!this->rtPriv().glRTFBOIDIs0());
if (this->numSamples() > 1 && !caps.msaaResolvesAutomatically()) {
// MSAA texture-render-targets always require manual resolve if we are not using a
// multisampled-render-to-texture extension.
//
// NOTE: This is the only instance where we need to set the manual resolve flag on a proxy.
// Any other proxies that require manual resolve (e.g., wrapBackendTextureAsRenderTarget())
// will be wrapped, and the wrapped version of the GrSurface constructor will automatically
// get the manual resolve flag when copying the target GrSurface's flags.
fSurfaceFlags |= GrInternalSurfaceFlags::kRequiresManualMSAAResolve;
}
}
size_t GrTextureRenderTargetProxy::onUninstantiatedGpuMemorySize() const {
int colorSamplesPerPixel = this->numSamples();
if (colorSamplesPerPixel > 1) {
// Add one to account for the resolve buffer.
++colorSamplesPerPixel;
}
// TODO: do we have enough information to improve this worst case estimate?
return GrSurface::ComputeSize(this->config(), this->width(), this->height(),
colorSamplesPerPixel, this->proxyMipMapped(),
!this->priv().isExact());
}
bool GrTextureRenderTargetProxy::instantiate(GrResourceProvider* resourceProvider) {
if (this->isLazy()) {
return false;
}
const GrUniqueKey& key = this->getUniqueKey();
if (!this->instantiateImpl(resourceProvider, this->numSamples(), this->numStencilSamples(),
GrRenderable::kYes, this->mipMapped(),
key.isValid() ? &key : nullptr)) {
return false;
}
if (key.isValid()) {
SkASSERT(key == this->getUniqueKey());
}
SkASSERT(this->peekRenderTarget());
SkASSERT(this->peekTexture());
return true;
}
sk_sp<GrSurface> GrTextureRenderTargetProxy::createSurface(
GrResourceProvider* resourceProvider) const {
sk_sp<GrSurface> surface =
this->createSurfaceImpl(resourceProvider, this->numSamples(), this->numStencilSamples(),
GrRenderable::kYes, this->mipMapped());
if (!surface) {
return nullptr;
}
SkASSERT(surface->asRenderTarget());
SkASSERT(surface->asTexture());
return surface;
}
#ifdef SK_DEBUG
void GrTextureRenderTargetProxy::onValidateSurface(const GrSurface* surface) {
// Anything checked here should also be checking the GrTextureProxy version
SkASSERT(surface->asTexture());
SkASSERT(GrMipMapped::kNo == this->proxyMipMapped() ||
GrMipMapped::kYes == surface->asTexture()->texturePriv().mipMapped());
// Anything checked here should also be checking the GrRenderTargetProxy version
SkASSERT(surface->asRenderTarget());
SkASSERT(surface->asRenderTarget()->numSamples() == this->numSamples());
SkASSERT(surface->asTexture()->texturePriv().textureType() == this->textureType());
GrInternalSurfaceFlags proxyFlags = fSurfaceFlags;
GrInternalSurfaceFlags surfaceFlags = surface->surfacePriv().flags();
// Only non-RT textures can be read only.
SkASSERT(!(proxyFlags & GrInternalSurfaceFlags::kReadOnly));
SkASSERT(!(surfaceFlags & GrInternalSurfaceFlags::kReadOnly));
SkASSERT(((int)proxyFlags & kGrInternalTextureRenderTargetFlagsMask) ==
((int)surfaceFlags & kGrInternalTextureRenderTargetFlagsMask));
}
#endif
| 51.136612 | 100 | 0.574695 | aam |
badb4f5ece70e2a8bd2bb7cdcf9e0b88602e4f70 | 1,432 | cpp | C++ | search/search_tests/localities_source_tests.cpp | smartyw/organicmaps | 9b10eb9d3ed6833861cef294c2416cc98b15e10d | [
"Apache-2.0"
] | 4,879 | 2015-09-30T10:56:36.000Z | 2022-03-31T18:43:03.000Z | search/search_tests/localities_source_tests.cpp | smartyw/organicmaps | 9b10eb9d3ed6833861cef294c2416cc98b15e10d | [
"Apache-2.0"
] | 7,549 | 2015-09-30T10:52:53.000Z | 2022-03-31T22:04:22.000Z | search/search_tests/localities_source_tests.cpp | smartyw/organicmaps | 9b10eb9d3ed6833861cef294c2416cc98b15e10d | [
"Apache-2.0"
] | 1,493 | 2015-09-30T10:43:06.000Z | 2022-03-21T09:16:49.000Z | #include "testing/testing.hpp"
#include "generator/generator_tests_support/test_with_classificator.hpp"
#include "indexer/classificator.hpp"
#include "search/localities_source.hpp"
#include <algorithm>
#include <cstdint>
#include <string>
#include <vector>
using namespace std;
using generator::tests_support::TestWithClassificator;
UNIT_CLASS_TEST(TestWithClassificator, Smoke)
{
search::LocalitiesSource ls;
vector<vector<string>> const expectedPaths = {
{"place", "town"},
{"place", "city"},
{"place", "city", "capital"},
{"place", "city", "capital", "2"},
{"place", "city", "capital", "3"},
{"place", "city", "capital", "4"},
{"place", "city", "capital", "5"},
{"place", "city", "capital", "6"},
{"place", "city", "capital", "7"},
{"place", "city", "capital", "8"},
{"place", "city", "capital", "9"},
{"place", "city", "capital", "10"},
{"place", "city", "capital", "11"},
};
vector<uint32_t> expectedTypes;
for (auto const & path : expectedPaths)
expectedTypes.push_back(classif().GetTypeByPath(path));
sort(expectedTypes.begin(), expectedTypes.end());
vector<uint32_t> localitiesSourceTypes;
ls.ForEachType([&localitiesSourceTypes](uint32_t type) { localitiesSourceTypes.push_back(type); });
sort(localitiesSourceTypes.begin(), localitiesSourceTypes.end());
TEST_EQUAL(expectedTypes, localitiesSourceTypes, ());
}
| 29.833333 | 101 | 0.651536 | smartyw |
badc4f7b8eb4d5da2a7292a419aa2f4aeeeae723 | 6,041 | cpp | C++ | CSC201/assignments/Test/Chukwudi_Peter_OFOMA_-_CSC201_CA1_Update_1.cpp | ochudi/ochudi-CSC201 | 3a792beef4780960c725ef9bf6c4af96110c373d | [
"MIT"
] | null | null | null | CSC201/assignments/Test/Chukwudi_Peter_OFOMA_-_CSC201_CA1_Update_1.cpp | ochudi/ochudi-CSC201 | 3a792beef4780960c725ef9bf6c4af96110c373d | [
"MIT"
] | null | null | null | CSC201/assignments/Test/Chukwudi_Peter_OFOMA_-_CSC201_CA1_Update_1.cpp | ochudi/ochudi-CSC201 | 3a792beef4780960c725ef9bf6c4af96110c373d | [
"MIT"
] | null | null | null | #include<iostream>
#include<string>
using namespace std;
string Question[]= {"Which of the following is the correct identifier?", "Which of the following is the address operator?","Which of the following features must be supported by any programming language to become a pure object-oriented programming language?","Which of the following refers to characteristics of an array?","If we stored five elements or data items in an array, what will be the index address or the index number of the array's last data item?","Which of the following is the correct syntax for declaring the array?","Which of the following is the correct syntax for accessing the first element?","Which of the following gives the 4th element of the array?","Which type of memory is used by an Array in C++ programming language?","Which one of the following is the correct definition of the is_array(); function in C++?"};
string OptionA[]= {" $var_name","@","Encapsulation","An array is a set of similar data items","2","int array{};","array[2];","array[2];","Contiguous","It checks that the specified variable is of the array or not"};
string OptionB[]= {"VAR_123","#","Inheritance","An array is a set of distinct data items","3","int array [5];","array[0]","array[3]","None-contiguous","It checks that the specified array of single dimension or not"};
string OptionC[]= {"varname@","&","Polymorphism","An array can hold different types of datatypes","4","Array[5];","Array[5];","Array[5];","Both A and B","It checks that the array specified of multi-dimension or not"};
string OptionD[]= {"None of the above","%","All of the above","None of the above","5","None of the above","array[1]","array[1]","Not mentioned","Both B and C"};
string Answer[]= {"B","C","D","A","C","B","B","B","A","A" };
string YourOption[]= {"","","","","","","","","",""};
int score=0;
char start;
void begin() {
cout<<"\t\tWelcome to C++ quiz game"<<endl;
cout<<"\t\t-------------------------"<<endl;
}
void rules() {
cout<<"\t\tRules of the game"<<endl;
cout<<"\t\t------------------"<<endl;
cout<<"You are expected to answer 10 questions"<<endl;
cout<<"You can skip a question and return to it later"<<endl;
cout<<"To answer a question enter the right option on the keyboard and Press Enter"<<endl;
cout<<"To skip a question Press N"<<endl;
cout<<"To go back to previous questions Press P"<<endl;
cout<<"To submit Press F\n\n"<<endl;
}
void play (string *Question, string *OptionA, string *OptionB, string *OptionC, string *OptionD, string *YourOption) {
int counter=0;
string answer;
bool submit=false;
do {
if(counter==10) {
terminal:
cout<<"This is the last question\nPress F to Submit\nPress P to go back to Previous Question\n\n "<<endl;
} else {
cout<<"Question "<<counter+1<<endl;
cout<<*(Question+counter)<<endl;
cout<<"A. "<<*(OptionA+counter)<<" B. "<<*(OptionB+counter)<<endl;
cout<<"C. "<<*(OptionC+counter)<<" D. "<<*(OptionD+counter)<<endl;
if(*(YourOption+counter)=="") {
} else {
cout<<"You selected "<<*(YourOption+counter)<<endl;
}
}
repeat:
cout<<"Enter your Answer ";
cin>>answer;
if((counter==10)&&((answer=="A")||(answer=="a")||(answer=="B")||(answer=="b")||
(answer=="C")||(answer=="c")||(answer=="D")||(answer=="d")||(answer=="N")||(answer=="n")
) ) {
goto terminal;
} else {
if((answer=="A")||(answer=="a")) {
*(YourOption+counter)="A";
counter=counter+1;
cout<<endl;
} else if((answer=="B")||(answer=="b")) {
*(YourOption+counter)="B";
counter=counter+1;
cout<<endl;
} else if((answer=="C")||(answer=="c")) {
*(YourOption+counter)="C";
counter=counter+1;
cout<<endl;
} else if((answer=="D")||(answer=="d")) {
*(YourOption+counter)="D";
counter=counter+1;
cout<<endl;
} else if((answer=="N")||(answer=="n")) {
if(counter==9) {
cout<<"This is the last question"<<endl;
cout<<endl;
} else {
counter=counter+1;
cout<<"Next question"<<endl;
cout<<endl;
}
} else if((answer=="P")||(answer=="p")) {
if(counter==0) {
cout<<"This is the first question"<<endl;
cout<<endl;
} else {
counter=counter-1;
cout<<"Previous question"<<endl;
cout<<endl;
}
} else if((answer=="F")||(answer=="f")) {
submit=true;
cout<<"Processing"<<endl;
cout<<endl;
}
else {
cout<<"Wrong Option"<<endl;
goto repeat;
}
}
} while(submit==false);
}
int result (string *YourOption, string *Answer) {
int score=0;
for(int i=0; i<10; i++) {
if(*(YourOption+i)==*(Answer+i) ) {
score=score+1;
}
}
return score;
}
void viewscript (string *Question, string *OptionA, string *OptionB, string *OptionC, string *OptionD, string *Answer, string *YourOption) {
viewing:
cout<<"To view your script Press V "<<endl;
string view;
cin>>view;
if((view=="V")||(view=="v")) {
for(int counter=0; counter<10; counter++) {
cout<<"Question "<<counter+1<<endl;
cout<<*(Question+counter)<<endl;
cout<<"A. "<<*(OptionA+counter)<<" B. "<<*(OptionB+counter)<<endl;
cout<<"C. "<<*(OptionC+counter)<<" D. "<<*(OptionD+counter)<<endl;
cout<<"Correct Option :"<<Answer[counter]<<" Your Choice: "<<*(YourOption+counter)<<" ";
if(*(YourOption+counter)==Answer[counter]) {
cout<<" Correct!\n\n"<<endl;
} else {
cout<<" Wrong!\n\n"<<endl;
}
}
} else {
cout<<"You entered the wrong Option "<<endl;
goto viewing;
}
}
int main() {
begin();
loop:
cout<<"Press 1 to Start"<<endl;
cout<<"Press 2 to Exit"<<endl;
cin>>start;
if(start=='1') {
rules();
play(&Question[0], &OptionA[0], &OptionB[0], &OptionC[0], &OptionD[0], &YourOption[0]);
score= result (&YourOption[0], &Answer[0]);
cout<<"You scored " <<score<<" out of 10"<<endl;
viewscript(&Question[0], &OptionA[0], &OptionB[0], &OptionC[0], &OptionD[0], &Answer[0], &YourOption[0]);
} else if(start=='2') {
return 0;
} else {
cout<<"You entered a wrong value\n"<<endl;
goto loop;
}
return 0;
}
| 36.173653 | 837 | 0.610992 | ochudi |
bade94be8d911b912be813d1e8e9263627e2637b | 14,240 | cpp | C++ | wrappers/C/telplugins_properties_api.cpp | sys-bio/rrplugins | 03af6ea70d73462ad88103f1e446dc0c5f3f971c | [
"Apache-2.0"
] | null | null | null | wrappers/C/telplugins_properties_api.cpp | sys-bio/rrplugins | 03af6ea70d73462ad88103f1e446dc0c5f3f971c | [
"Apache-2.0"
] | 8 | 2015-12-02T18:20:43.000Z | 2021-08-20T17:13:34.000Z | wrappers/C/telplugins_properties_api.cpp | sys-bio/telPlugins | 03af6ea70d73462ad88103f1e446dc0c5f3f971c | [
"Apache-2.0"
] | 3 | 2015-01-27T18:53:45.000Z | 2015-07-13T17:07:50.000Z | #pragma hdrstop
#include <string>
#include "rr/rrRoadRunner.h"
#include "rrplugins/common/telException.h"
#include "rrplugins/common/telLogger.h"
#include "rrplugins/common/telOSSpecifics.h"
#include "rrplugins/common/telTelluriumData.h"
#include "telplugins_properties_api.h"
#include "telplugins_c_api.h"
#include "telplugins_cpp_support.h"
#include "rrplugins/common/telProperty.h"
#include "rrplugins/common/telPropertyBase.h"
#include <iostream>
//---------------------------------------------------------------------------
using namespace std;
using namespace tlp;
using namespace tlpc;
//using tlp::TelluriumData;
TELHandle tlp_cc tpCreateProperty(const char* label, const char* type, const char* _hint, void* value)
{
start_try
char* hint = (char*) _hint;
if(!hint)
{
hint = (char*) "";
}
if(string(type) == string("bool"))
{
bool iniVal = false;
if(value != NULL)
{
//cast it
bool* val = (bool*) value;
iniVal = (*val);
}
Property<bool>* para = new Property<bool>(iniVal, label, hint);
gHM.registerHandle(para, typeid(static_cast<PropertyBase*>(para)).name());
return para;
}
if(string(type) == string("int"))
{
int iniVal = 0;
if(value != NULL)
{
//cast it
int* val = (int*) value;
iniVal = (*val);
}
Property<int> *para = new Property<int>(iniVal, label, hint);
gHM.registerHandle(para, typeid(static_cast<PropertyBase*>(para)).name());
return para;
}
//Don't support type 'float', it just causes problems. Make it a double
if(string(type) == string("float"))
{
double iniVal = 0;
if(value != NULL)
{
//cast it
double* dVal = (double*) value;
iniVal = (*dVal);
}
Property<double> *para = new Property<double>(iniVal, label, hint);
gHM.registerHandle(para, typeid(static_cast<PropertyBase*>(para)).name());
return para;
}
if(string(type) == string("double"))
{
double iniVal = 0;
if(value != NULL)
{
//cast it
double* dVal = (double*) value;
iniVal = (*dVal);
}
Property<double> *para = new Property<double>(iniVal, label, hint);
gHM.registerHandle(para, typeid(static_cast<PropertyBase*>(para)).name());
return para;
}
//if(string(type) == string("string"))
//{
// char* iniVal = "";
// if(value != NULL)
// {
// //cast it
// char* *val = (char**) value;
// iniVal = (*val);
// }
// Property<char*> *para = new Property<char*>(iniVal, label, hint);
// return para;
//}
if(string(type) == string("std::string") || string(type) == string("string"))
{
string iniVal = "";
if(value != NULL)
{
//cast it
string* val = (string*) value;
iniVal = (*val);
}
Property<string> *para = new Property<string>(iniVal, label, hint);
gHM.registerHandle(para, typeid(static_cast<PropertyBase*>(para)).name());
return para;
}
if(string(type) == string("listOfProperties"))
{
Properties iniVal;
if(value != NULL)
{
//cast it
Properties* val = (Properties*) value;
iniVal = (*val);
}
Property<Properties> *para = new Property<Properties>(iniVal, label, hint);
gHM.registerHandle(para, typeid(static_cast<PropertyBase*>(para)).name());
return para;
}
if(string(type) == string("telluriumData"))
{
TelluriumData iniVal;
if(value != NULL)
{
//cast it
TelluriumData* val = (TelluriumData*) value;
iniVal = (*val);
}
Property<TelluriumData> *para = new Property<TelluriumData>(iniVal, label, hint);
gHM.registerHandle(para, typeid(static_cast<PropertyBase*>(para)).name());
return para;
}
return NULL;
catch_ptr_macro
}
bool tlp_cc tpFreeProperty(TELHandle paraHandle)
{
start_try
PropertyBase* para = castHandle<PropertyBase>(paraHandle, __FUNC__);
delete para;
return true;
catch_bool_macro
}
TELHandle tlp_cc tpCreatePropertyList()
{
start_try
Properties* props = new Properties();
gHM.registerHandle(props, typeid(props).name());
if(!props)
{
throw("Failed to create a list of Properties");
}
else
{
return props;
}
catch_ptr_macro
}
bool tlp_cc tpFreeProperties(TELHandle handle)
{
start_try
Properties* props = castHandle<Properties>(handle, __FUNC__);
delete props;
return true;
catch_bool_macro
}
bool tlp_cc tpAddPropertyToList(TELHandle handle, TELHandle para)
{
start_try
Properties* paras = castHandle<Properties>(handle, __FUNC__);
PropertyBase* bPara = castHandle<PropertyBase>(para, __FUNC__);
paras->add(bPara, false);
return true;
catch_bool_macro
}
char* tlp_cc tpGetPropertyInfo(TELHandle handle)
{
start_try
PropertyBase* para = castHandle<PropertyBase>(handle, __FUNC__);
stringstream s;
s<<"Name="<<para->getName()<<"\tType="<<para->getType()<<"\tDescription="<<para->getDescription()<<"\tHint="<<para->getHint();
return tlp::createText(s.str());
catch_ptr_macro
}
bool tlp_cc tpSetPropertyDescription(TELHandle handle, const char* value)
{
start_try
PropertyBase* para = castHandle<PropertyBase>(handle, __FUNC__);
para->setDescription(string(value));
return true;
catch_bool_macro
}
char* tlp_cc tpGetPropertyDescription(TELHandle handle)
{
start_try
PropertyBase* para = castHandle<PropertyBase>(handle, __FUNC__);
return tlp::createText(para->getDescription());
catch_ptr_macro
}
bool tlp_cc tpSetPropertyHint(TELHandle handle, const char* value)
{
start_try
PropertyBase* para = castHandle<PropertyBase>(handle, __FUNC__);
para->setHint(string(value));
return true;
catch_bool_macro
}
bool tlp_cc tpSetPropertyByString(TELHandle handle, const char* value)
{
start_try
PropertyBase* para = castHandle<PropertyBase>(handle, __FUNC__);
if(value)
{
string val(value);
para->setValueFromString(val);
return true;
}
return false;
catch_bool_macro
}
bool tlp_cc tpSetBoolProperty(TELHandle handle, bool value)
{
start_try
Property<bool>* para = castHandle< Property<bool> >(handle, __FUNC__);
para->setValue(value);
return true;
catch_bool_macro
}
bool tlp_cc tpGetBoolProperty(TELHandle handle, bool* value)
{
start_try
Property<bool>* para = castHandle< Property<bool> >(handle, __FUNC__);
(*value) = para->getValue();
return true;
catch_bool_macro
}
bool tlp_cc tpSetIntProperty(TELHandle handle, int value)
{
start_try
Property<int>* para = castHandle< Property<int> >(handle,__FUNC__);
para->setValue(value);
return true;
catch_bool_macro
}
bool tlp_cc tpGetIntProperty(TELHandle handle, int *value)
{
start_try
Property<int>* para = castHandle< Property<int> >(handle, __FUNC__);
(*value) = para->getValue();
return true;
catch_bool_macro
}
bool tlp_cc tpSetDoubleProperty(TELHandle handle, double value)
{
start_try
Property<double>* para = castHandle< Property<double> >(handle, __FUNC__);
para->setValue(value);
return true;
catch_bool_macro
}
bool tlp_cc tpGetDoubleProperty(TELHandle handle, double *value)
{
start_try
Property<double>* para = castHandle< Property<double> >(handle, __FUNC__);
(*value) = para->getValue();
return true;
catch_bool_macro
}
bool tlp_cc tpSetStringProperty(TELHandle handle, char* value)
{
start_try
PropertyBase* base = castHandle< PropertyBase >(handle, __FUNC__);
if(!base) {
RRPLOG(lError) << "tpSetStringProperty: Failed to get handle";
throw std::runtime_error("Failed to get handle");
}
Property<string>* para = dynamic_cast< Property<string>* >(base);
if(!para) {
// can't dyncast string props; check typeid, better than nothing
//if (std::string(typeid(*base)).name().find("Property") == std::string::npos) {
// RRPLOG(lError) << "tpSetStringProperty: Failed to cast property";
// RRPLOG(lError) << "tpSetStringProperty: typeinfo = " << typeid(*base).name();
//}
para = static_cast< Property<string>* >(base); // so much for type safety
//throw std::runtime_error("Failed to cast property");
}
string temp(value);
para->setValueFromString(temp);
return true;
catch_bool_macro
}
bool tlp_cc tpGetStringProperty(TELHandle handle, const char* (*value))
{
start_try
Property<string>* para = castHandle< Property<string> >(handle, __FUNC__);
(*value) = para->getValue().c_str();
return true;
catch_bool_macro
}
bool tlp_cc tpSetListProperty(TELHandle handle, void* value)
{
start_try
Property<Properties>* para = castHandle< Property<Properties> >(handle, __FUNC__);
para->setValue((Properties*)(value));
return true;
catch_bool_macro
}
bool tlp_cc tpGetListProperty(TELHandle handle, void* (value))
{
start_try
Property<Properties>* para = castHandle< Property<Properties> >(handle, __FUNC__);
Properties* assignTo = castHandle<Properties>(value, __FUNC__);
(assignTo) = (para->getValuePointer());
return true;
catch_bool_macro
}
bool tlp_cc tpSetTelluriumDataProperty(TELHandle handle, void* value)
{
start_try
PropertyBase* base = castHandle< PropertyBase >(handle, __FUNC__);
if(!base) {
RRPLOG(lError) << "tpSetTelluriumDataProperty: Failed to get handle";
throw std::runtime_error("Failed to get handle");
}
Property<TelluriumData>* para = dynamic_cast< Property<TelluriumData>* >(base);
if(!para) {
RRPLOG(lError) << "tpSetTelluriumDataProperty: Failed to cast property";
throw std::runtime_error("Failed to cast property");
}
TelluriumData* data = (TelluriumData*) value;
data->byteCheck();
para->setValue(*data);
return true;
catch_bool_macro
}
bool tlp_cc tpGetTelluriumDataProperty(TELHandle handle, void* value)
{
start_try
Property<TelluriumData>* para = castHandle< Property<TelluriumData> >(handle, __FUNC__);
TelluriumData* assignTo = castHandle< TelluriumData >(value, __FUNC__);
(*assignTo) = (para->getValueReference());
return true;
catch_bool_macro
}
char* tlp_cc tpGetPropertyValueAsString(TELHandle handle)
{
start_try
PropertyBase* para = castHandle<PropertyBase>(handle, __FUNC__);
string val = para->getValueAsString();
return tlp::createText(val);
catch_ptr_macro
}
void* tlp_cc tpGetPropertyValueHandle(TELHandle handle)
{
start_try
PropertyBase* para = castHandle<PropertyBase>(handle, __FUNC__);
return para->getValueHandle();
catch_ptr_macro
}
char* tlp_cc tpGetPropertyName(TELHandle handle)
{
start_try
PropertyBase* para = castHandle<PropertyBase>(handle, __FUNC__);
return tlp::createText(para->getName());
catch_ptr_macro
}
char* tlp_cc tpGetPropertyHint(TELHandle handle)
{
start_try
PropertyBase* para = castHandle<PropertyBase>(handle, __FUNC__);
return tlp::createText(para->getHint());
catch_ptr_macro
}
char* tlp_cc tpGetPropertyType(TELHandle handle)
{
start_try
PropertyBase* para = castHandle<PropertyBase>(handle, __FUNC__);
char* text = tlp::createText(para->getType());
return text;
catch_ptr_macro
}
TELHandle tlp_cc tpGetFirstProperty(TELHandle handle)
{
start_try
Properties *paras = castHandle<Properties>(handle, __FUNC__);
return paras->getFirst();
catch_ptr_macro
}
TELHandle tlp_cc tpGetNextProperty(TELHandle handle)
{
start_try
Properties *paras = castHandle<Properties>(handle, __FUNC__);
return paras->getNext();
catch_ptr_macro
}
TELHandle tlp_cc tpGetPreviousProperty(TELHandle handle)
{
start_try
Properties *paras = castHandle<Properties>(handle, __FUNC__);
return paras->getPrevious();
catch_ptr_macro
}
TELHandle tlp_cc tpGetCurrentProperty(TELHandle handle)
{
start_try
Properties *paras = castHandle<Properties>(handle, __FUNC__);
return paras->getCurrent();
catch_ptr_macro
}
bool tlp_cc tpClearPropertyList(TELHandle handle)
{
start_try
Properties* paras = castHandle<Properties>(handle, __FUNC__);
return paras->clear();
catch_bool_macro
}
TELHandle tlp_cc tpGetProperty(TELHandle handle, const char* name)
{
start_try
Properties* props = castHandle<Properties>(handle, __FUNC__);
return props->getProperty(name);
catch_ptr_macro
}
char* tlp_cc tpGetNamesFromPropertyList(TELHandle handle)
{
start_try
Properties* paras = castHandle<Properties>(handle, __FUNC__);
tlp::StringList aList;
for(int i = 0; i < paras->count(); i++)
{
aList.add((*paras)[i]->getName());
}
return tlp::createText(aList.asString().c_str());
catch_ptr_macro
}
| 29.421488 | 134 | 0.60302 | sys-bio |
bade9ad191f29e084b0bcd3161f6db83a7c296a2 | 1,213 | hpp | C++ | source/quantum-script-extension-task-version.hpp | g-stefan/quantum-script-extension-task | d7d4f5a2d276fec951ca3bced371306d9307da45 | [
"MIT",
"Unlicense"
] | null | null | null | source/quantum-script-extension-task-version.hpp | g-stefan/quantum-script-extension-task | d7d4f5a2d276fec951ca3bced371306d9307da45 | [
"MIT",
"Unlicense"
] | null | null | null | source/quantum-script-extension-task-version.hpp | g-stefan/quantum-script-extension-task | d7d4f5a2d276fec951ca3bced371306d9307da45 | [
"MIT",
"Unlicense"
] | null | null | null | //
// Quantum Script Extension Task
//
// Copyright (c) 2020-2021 Grigore Stefan <g_stefan@yahoo.com>
// Created by Grigore Stefan <g_stefan@yahoo.com>
//
// MIT License (MIT) <http://opensource.org/licenses/MIT>
//
#ifndef QUANTUM_SCRIPT_EXTENSION_TASK_VERSION_HPP
#define QUANTUM_SCRIPT_EXTENSION_TASK_VERSION_HPP
#define QUANTUM_SCRIPT_EXTENSION_TASK_VERSION_ABCD 2,1,0,19
#define QUANTUM_SCRIPT_EXTENSION_TASK_VERSION_STR "2.1.0"
#define QUANTUM_SCRIPT_EXTENSION_TASK_VERSION_STR_BUILD "19"
#define QUANTUM_SCRIPT_EXTENSION_TASK_VERSION_STR_DATETIME "2021-08-09 17:38:06"
#ifndef XYO_RC
#ifndef QUANTUM_SCRIPT_EXTENSION_TASK__EXPORT_HPP
#include "quantum-script-extension-task--export.hpp"
#endif
namespace Quantum {
namespace Script {
namespace Extension {
namespace Task {
namespace Version {
QUANTUM_SCRIPT_EXTENSION_TASK_EXPORT const char *version();
QUANTUM_SCRIPT_EXTENSION_TASK_EXPORT const char *build();
QUANTUM_SCRIPT_EXTENSION_TASK_EXPORT const char *versionWithBuild();
QUANTUM_SCRIPT_EXTENSION_TASK_EXPORT const char *datetime();
};
};
};
};
};
#endif
#endif
| 28.880952 | 88 | 0.728772 | g-stefan |
badf75ce5a0b810c40cb0437c640a3888ac551d4 | 6,797 | cpp | C++ | Base/PLCore/src/Xml/XmlAttribute.cpp | ktotheoz/pixellight | 43a661e762034054b47766d7e38d94baf22d2038 | [
"MIT"
] | 83 | 2015-01-08T15:06:14.000Z | 2021-07-20T17:07:00.000Z | Base/PLCore/src/Xml/XmlAttribute.cpp | PixelLightFoundation/pixellight | 43a661e762034054b47766d7e38d94baf22d2038 | [
"MIT"
] | 27 | 2019-06-18T06:46:07.000Z | 2020-02-02T11:11:28.000Z | Base/PLCore/src/Xml/XmlAttribute.cpp | naetherm/PixelLight | d7666f5b49020334cbb5debbee11030f34cced56 | [
"MIT"
] | 40 | 2015-02-25T18:24:34.000Z | 2021-03-06T09:01:48.000Z | /*********************************************************\
* File: XmlAttribute.cpp *
*
* Copyright (C) 2002-2013 The PixelLight Team (http://www.pixellight.org/)
*
* This file is part of PixelLight.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software
* and associated documentation files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or
* substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
* BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
\*********************************************************/
//[-------------------------------------------------------]
//[ Includes ]
//[-------------------------------------------------------]
#include <stdio.h>
#include "PLCore/File/File.h"
#include "PLCore/Xml/XmlParsingData.h"
#include "PLCore/Xml/XmlDocument.h"
#include "PLCore/Xml/XmlAttribute.h"
//[-------------------------------------------------------]
//[ Namespace ]
//[-------------------------------------------------------]
namespace PLCore {
//[-------------------------------------------------------]
//[ Public functions ]
//[-------------------------------------------------------]
/**
* @brief
* Default constructor
*/
XmlAttribute::XmlAttribute() :
m_pDocument(nullptr),
m_pPreviousAttribute(nullptr),
m_pNextAttribute(nullptr)
{
}
/**
* @brief
* Destructor
*/
XmlAttribute::~XmlAttribute()
{
}
/**
* @brief
* Examines the value string
*/
XmlBase::EQueryResult XmlAttribute::QueryIntValue(int &nValue) const
{
int nBackup = nValue;
EQueryResult nResult = (sscanf(m_sValue.GetASCII(), "%d", &nValue) == 1) ? Success : WrongType;
if (nResult != Success)
nValue = nBackup;
return nResult;
}
/**
* @brief
* Examines the value string
*/
XmlBase::EQueryResult XmlAttribute::QueryDoubleValue(double &dValue) const
{
double dBackup = dValue;
EQueryResult nResult = (sscanf(m_sValue.GetASCII(), "%lf", &dValue) == 1) ? Success : WrongType;
if (nResult != Success)
dValue = dBackup;
return nResult;
}
//[-------------------------------------------------------]
//[ Public virtual XmlBase functions ]
//[-------------------------------------------------------]
bool XmlAttribute::Save(File &cFile, uint32 nDepth)
{
String sName, sValue;
EncodeString(m_sName, sName);
EncodeString(m_sValue, sValue);
if (sValue.IsSubstring('\"'))
cFile.Print(sName + "='" + sValue + '\'');
else
cFile.Print(sName + "=\"" + sValue + '\"');
// Done
return true;
}
String XmlAttribute::ToString(uint32 nDepth) const
{
String sName, sValue;
EncodeString(m_sName, sName);
EncodeString(m_sValue, sValue);
if (sValue.IsSubstring('\"'))
return sName + "='" + sValue + '\'';
else
return sName + "=\"" + sValue + '\"';
}
const char *XmlAttribute::Parse(const char *pszData, XmlParsingData *pData, EEncoding nEncoding)
{
pszData = SkipWhiteSpace(pszData, nEncoding);
if (!pszData || !*pszData)
return nullptr; // Error!
if (pData) {
pData->Stamp(pszData, nEncoding);
m_cCursor = pData->Cursor();
}
// Read the name, the '=' and the value
const char *pszError = pszData;
pszData = ReadName(pszData, m_sName, nEncoding);
if (!pszData || !*pszData) {
// Set error code
if (m_pDocument)
m_pDocument->SetError(ErrorReadingAttributes, pszError, pData, nEncoding);
// Error!
return nullptr;
}
pszData = SkipWhiteSpace(pszData, nEncoding);
if (!pszData || !*pszData || *pszData != '=') {
// Set error code
if (m_pDocument)
m_pDocument->SetError(ErrorReadingAttributes, pszData, pData, nEncoding);
// Error!
return nullptr;
}
++pszData; // skip '='
pszData = SkipWhiteSpace(pszData, nEncoding);
if (!pszData || !*pszData) {
// Set error code
if (m_pDocument)
m_pDocument->SetError(ErrorReadingAttributes, pszData, pData, nEncoding);
// Error!
return nullptr;
}
// Constants
const char szSingleQuote = '\'';
const char szDoubleQuote = '\"';
if (*pszData == szSingleQuote) {
++pszData;
const char *pszEnd = "\'"; // Single quote in string
pszData = ReadText(pszData, m_sValue, false, pszEnd, false, nEncoding);
} else if (*pszData == szDoubleQuote) {
++pszData;
const char *pszEnd = "\""; // Double quote in string
pszData = ReadText(pszData, m_sValue, false, pszEnd, false, nEncoding);
} else {
// All attribute values should be in single or double quotes.
// But this is such a common error that the parser will try
// its best, even without them.
m_sValue = "";
while ( pszData && *pszData // Existence
&& !IsWhiteSpace( *pszData ) // Whitespace
&& *pszData != '/' && *pszData != '>' ) { // Tag end
if (*pszData == szSingleQuote || *pszData == szDoubleQuote) {
// We did not have an opening quote but seem to have a closing one. Give up and throw an error.
// Set error code
if (m_pDocument)
m_pDocument->SetError(ErrorReadingAttributes, pszData, pData, nEncoding);
// Error!
return nullptr;
}
m_sValue += *pszData;
++pszData;
}
}
// Done
return pszData;
}
//[-------------------------------------------------------]
//[ Private functions ]
//[-------------------------------------------------------]
/**
* @brief
* Copy constructor
*/
XmlAttribute::XmlAttribute(const XmlAttribute &cSource) :
m_pDocument(nullptr),
m_pPreviousAttribute(nullptr),
m_pNextAttribute(nullptr)
{
// No implementation because the copy constructor is never used
}
/**
* @brief
* Copy operator
*/
XmlAttribute &XmlAttribute::operator =(const XmlAttribute &cSource)
{
// No implementation because the copy operator is never used
return *this;
}
//[-------------------------------------------------------]
//[ Namespace ]
//[-------------------------------------------------------]
} // PLCore
| 28.923404 | 99 | 0.575254 | ktotheoz |
bae03e902140e51b613d5a106808a6c13f035087 | 2,575 | cc | C++ | lite/arm/math/shuffle_channel.cc | banbishan/Paddle-Lite | 02517c12c31609f413a1c47a83e25d3fbff07074 | [
"Apache-2.0"
] | 1 | 2019-08-21T05:54:42.000Z | 2019-08-21T05:54:42.000Z | lite/arm/math/shuffle_channel.cc | banbishan/Paddle-Lite | 02517c12c31609f413a1c47a83e25d3fbff07074 | [
"Apache-2.0"
] | null | null | null | lite/arm/math/shuffle_channel.cc | banbishan/Paddle-Lite | 02517c12c31609f413a1c47a83e25d3fbff07074 | [
"Apache-2.0"
] | 1 | 2019-10-11T09:34:49.000Z | 2019-10-11T09:34:49.000Z | // Copyright (c) 2019 PaddlePaddle Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include "lite/arm/math/shuffle_channel.h"
#include <typeinfo>
#include "lite/arm/math/funcs.h"
namespace paddle {
namespace lite {
namespace arm {
namespace math {
template <typename Dtype>
void shuffle_kernel(
Dtype* output, const Dtype* input, int group_row, int group_col, int len) {
for (int i = 0; i < group_row; ++i) {
for (int j = 0; j < group_col; ++j) {
const Dtype* p_i = input + (i * group_col + j) * len;
Dtype* p_o = output + (j * group_row + i) * len;
memcpy(p_o, p_i, len * sizeof(Dtype));
}
}
}
template <>
void shuffle_channel<float>(const float* inputs,
float* outputs,
int group,
int num,
int channel,
int height,
int width) {
int fea_size = channel * height * width;
int spatial_size = height * width;
int group_row = group;
int group_col = channel / group;
for (int i = 0; i < num; ++i) {
shuffle_kernel(outputs + i * fea_size,
inputs + i * fea_size,
group_row,
group_col,
spatial_size);
}
}
template <>
void shuffle_channel<char>(const char* inputs,
char* outputs,
int group,
int num,
int channel,
int height,
int width) {
int fea_size = channel * height * width;
int spatial_size = height * width;
int group_row = group;
int group_col = channel / group;
for (int i = 0; i < num; ++i) {
shuffle_kernel(outputs + i * fea_size,
inputs + i * fea_size,
group_row,
group_col,
spatial_size);
}
}
} // namespace math
} // namespace arm
} // namespace lite
} // namespace paddle
| 31.402439 | 79 | 0.555728 | banbishan |
bae04be8750d9747a35a419a739f3ca3f5f0bc34 | 148 | cpp | C++ | src/Property.cpp | barsnadcat/space_tycoon_model | 6029746f2e1a8e9585ba6fa5913f2690e9ea2d91 | [
"MIT"
] | null | null | null | src/Property.cpp | barsnadcat/space_tycoon_model | 6029746f2e1a8e9585ba6fa5913f2690e9ea2d91 | [
"MIT"
] | null | null | null | src/Property.cpp | barsnadcat/space_tycoon_model | 6029746f2e1a8e9585ba6fa5913f2690e9ea2d91 | [
"MIT"
] | null | null | null | #include <Property.h>
ObjectSP Property::GetOwner() const
{
return mOwner.lock();
}
void Property::SetOwner(ObjectSP owner)
{
mOwner = owner;
}
| 12.333333 | 39 | 0.709459 | barsnadcat |
bae15dcebe76e6e7d8d7b579ca465deded4cb9d6 | 3,759 | hpp | C++ | src/sensor_configuration.hpp | gsbecerrag/cppagent | f64b1906be32b43656b905e1f5d17c4e7ccbf094 | [
"Apache-2.0"
] | null | null | null | src/sensor_configuration.hpp | gsbecerrag/cppagent | f64b1906be32b43656b905e1f5d17c4e7ccbf094 | [
"Apache-2.0"
] | null | null | null | src/sensor_configuration.hpp | gsbecerrag/cppagent | f64b1906be32b43656b905e1f5d17c4e7ccbf094 | [
"Apache-2.0"
] | null | null | null | //
// Copyright Copyright 2009-2019, AMT – The Association For Manufacturing Technology (“AMT”)
// 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.
//
#pragma once
#include "component_configuration.hpp"
#include "globals.hpp"
#include <utility>
#include <vector>
namespace mtconnect
{
class SensorConfiguration : public ComponentConfiguration
{
public:
struct Calibration
{
Calibration(std::string date, std::string nextDate, std::string initials)
: m_date(std::move(date)),
m_nextDate(std::move(nextDate)),
m_initials(std::move(initials))
{
}
Calibration(const Calibration &other)
: m_date(other.m_date), m_nextDate(other.m_nextDate), m_initials(other.m_initials)
{
}
Calibration()
{
}
~Calibration()
{
}
std::string m_date;
std::string m_nextDate;
std::string m_initials;
};
class Channel
{
public:
Channel(std::string calibrationDate, std::string nextCalibrationDate, std::string initials,
const std::map<std::string, std::string> &attrs)
: m_attributes(attrs),
m_calibration(std::move(calibrationDate), std::move(nextCalibrationDate),
std::move(initials))
{
}
Channel(const Channel &other)
: m_attributes(other.m_attributes),
m_description(other.m_description),
m_calibration(other.m_calibration)
{
}
~Channel()
{
}
void setDescription(const std::string &desc)
{
m_description = desc;
}
const std::string &getDescription() const
{
return m_description;
}
const std::map<std::string, std::string> &getAttributes() const
{
return m_attributes;
}
const Calibration &getCalibration() const
{
return m_calibration;
}
protected:
std::map<std::string, std::string> m_attributes;
std::string m_description;
Calibration m_calibration;
};
// Sensor Configuration begins here
public:
SensorConfiguration(std::string firmwareVer, std::string calibrationDate,
std::string nextCalibrationDate, std::string initials, std::string rest)
: m_firmwareVersion(std::move(firmwareVer)),
m_calibration(std::move(calibrationDate), std::move(nextCalibrationDate),
std::move(initials)),
m_rest(std::move(rest))
{
}
virtual ~SensorConfiguration()
{
}
void addChannel(const Channel &channel)
{
m_channels.emplace_back(channel);
}
const std::vector<Channel> &getChannels() const
{
return m_channels;
}
const Calibration &getCalibration() const
{
return m_calibration;
}
const std::string &getRest() const
{
return m_rest;
}
const std::string &getFirmwareVersion() const
{
return m_firmwareVersion;
}
protected:
std::string m_firmwareVersion;
Calibration m_calibration;
std::string m_rest;
std::vector<Channel> m_channels;
};
} // namespace mtconnect
| 26.659574 | 97 | 0.621708 | gsbecerrag |
bae3a9f93960469136c83bf8de62eaff77843471 | 2,143 | cc | C++ | iree/hal/cts/descriptor_set_test.cc | NatashaKnk/iree | e4bafcf8b11041c3279f4a8620a3096c5aebf33a | [
"Apache-2.0"
] | null | null | null | iree/hal/cts/descriptor_set_test.cc | NatashaKnk/iree | e4bafcf8b11041c3279f4a8620a3096c5aebf33a | [
"Apache-2.0"
] | 4 | 2021-01-05T09:58:18.000Z | 2021-02-11T10:50:12.000Z | iree/hal/cts/descriptor_set_test.cc | marbre/iree | ce1af180c87ed4b4501d4a7b6f2b2617624440c0 | [
"Apache-2.0"
] | null | null | null | // Copyright 2021 The IREE Authors
//
// Licensed under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
#include <cstddef>
#include <string>
#include <vector>
#include "iree/base/api.h"
#include "iree/hal/api.h"
#include "iree/hal/cts/cts_test_base.h"
#include "iree/hal/testing/driver_registry.h"
#include "iree/testing/gtest.h"
#include "iree/testing/status_matchers.h"
namespace iree {
namespace hal {
namespace cts {
class DescriptorSetTest : public CtsTestBase {};
// TODO(scotttodd): enable once any driver implements non-push descriptor sets
// * also test with buffers in the bindings
// * also test usage in iree_hal_command_buffer_bind_descriptor_set
TEST_P(DescriptorSetTest, DISABLED_CreateWithTwoBindings) {
iree_hal_descriptor_set_layout_t* descriptor_set_layout;
iree_hal_descriptor_set_layout_binding_t descriptor_set_layout_bindings[] = {
{/*binding=*/0, /*type=*/IREE_HAL_DESCRIPTOR_TYPE_STORAGE_BUFFER},
{/*binding=*/1, /*type=*/IREE_HAL_DESCRIPTOR_TYPE_STORAGE_BUFFER},
};
IREE_ASSERT_OK(iree_hal_descriptor_set_layout_create(
device_, IREE_HAL_DESCRIPTOR_SET_LAYOUT_USAGE_TYPE_IMMUTABLE,
IREE_ARRAYSIZE(descriptor_set_layout_bindings),
descriptor_set_layout_bindings, &descriptor_set_layout));
iree_hal_descriptor_set_binding_t descriptor_set_bindings[] = {
{/*binding=*/0, /*buffer=*/NULL, /*offset=*/0, /*length=*/0},
{/*binding=*/1, /*buffer=*/NULL, /*offset=*/0, /*length=*/0},
};
iree_hal_descriptor_set_t* descriptor_set;
IREE_ASSERT_OK(iree_hal_descriptor_set_create(
device_, descriptor_set_layout, IREE_ARRAYSIZE(descriptor_set_bindings),
descriptor_set_bindings, &descriptor_set));
iree_hal_descriptor_set_release(descriptor_set);
iree_hal_descriptor_set_layout_release(descriptor_set_layout);
}
INSTANTIATE_TEST_SUITE_P(
AllDrivers, DescriptorSetTest,
::testing::ValuesIn(testing::EnumerateAvailableDrivers()),
GenerateTestName());
} // namespace cts
} // namespace hal
} // namespace iree
| 35.716667 | 79 | 0.766682 | NatashaKnk |
bae517785b2f8a3b7f06d3cfa95d67a5d2371f2d | 2,211 | cpp | C++ | DX11Castle/Camera.cpp | codetorex/dx11_engine | 4f7a076d07e94a9ffa5508fd72abf796e0db3526 | [
"MIT"
] | null | null | null | DX11Castle/Camera.cpp | codetorex/dx11_engine | 4f7a076d07e94a9ffa5508fd72abf796e0db3526 | [
"MIT"
] | null | null | null | DX11Castle/Camera.cpp | codetorex/dx11_engine | 4f7a076d07e94a9ffa5508fd72abf796e0db3526 | [
"MIT"
] | null | null | null | #include "stdafx.h"
#include "Camera.h"
#include "Engine.h"
void CameraTPSController::Update()
{
HWND k = GetForegroundWindow();
if ( k != Engine.m_Renderer.m_Window.m_Hwnd )
{
return;
}
XMVECTOR direction = m_Cam.Focus - m_Cam.Eye;
XMVECTOR magnitude = XMVector3Length( direction );
direction = XMVector3Normalize( direction );
XMVECTOR upnorm = XMVector3Normalize( m_Cam.Up );
XMVECTOR right = XMVector3Cross( direction, upnorm );
XMVECTOR forewardVec = direction * (m_MoveSpeed * Engine.m_Time.m_Diff);
if ( m_Forward )
{
m_Cam.Eye += forewardVec;
m_Cam.Focus += forewardVec;
}
else if ( m_Backward )
{
m_Cam.Eye -= forewardVec;
m_Cam.Focus -= forewardVec;
}
XMVECTOR strafeVec = -right * (m_MoveSpeed * Engine.m_Time.m_Diff);
if ( m_StrafeRight )
{
m_Cam.Eye += strafeVec;
m_Cam.Focus += strafeVec;
}
else if ( m_StrafeLeft )
{
m_Cam.Eye -= strafeVec;
m_Cam.Focus -= strafeVec;
}
POINT p;
GetCursorPos( &p );
m_MouseDiffX = p.x - 500;
m_MouseDiffY = p.y - 500;
SetCursorPos( 500, 500 );
if ( m_MouseDiffY != 0 )
{
XMVECTOR direction = m_Cam.Focus - m_Cam.Eye;
XMVECTOR magnitude = XMVector3Length( direction );
direction = XMVector3Normalize( direction );
XMVECTOR upnorm = XMVector3Normalize( m_Cam.Up );
XMVECTOR right = XMVector3Cross( direction, upnorm );
XMMATRIX rotation = XMMatrixRotationNormal( -right, XMConvertToRadians( (float)m_MouseDiffY * m_RotationSpeed ) );
m_Cam.Focus = (XMVector3Transform( direction, rotation ) * magnitude) + m_Cam.Eye;
m_Cam.Up = XMVector3Transform( m_Cam.Up, rotation );
}
if ( m_MouseDiffX != 0 )
{
XMVECTOR direction = m_Cam.Focus - m_Cam.Eye;
XMVECTOR magnitude = XMVector3Length( direction );
direction = XMVector3Normalize( direction );
XMVECTOR upnorm = XMVector3Normalize( m_Cam.Up );
XMVECTOR right = XMVector3Cross( direction, upnorm );
XMMATRIX rotation = XMMatrixRotationNormal( XMVectorSet( 0.0f, 1.0f, 0.0f, 0 ),
XMConvertToRadians( (float)m_MouseDiffX * m_RotationSpeed ) );
m_Cam.Focus = (XMVector3Transform( direction, rotation ) * magnitude) + m_Cam.Eye;
m_Cam.Up = XMVector3Transform( m_Cam.Up, rotation );
}
m_Cam.Update();
}
| 24.566667 | 116 | 0.701493 | codetorex |
bae520d44586e26d1692d2350f307fd7ebbe6fe8 | 6,208 | hpp | C++ | include/o80/standalone.hpp | intelligent-soft-robots/o80 | 61ab6bab0fc1015337dcb26150cfb23414202bd0 | [
"BSD-3-Clause"
] | 3 | 2020-08-24T09:57:29.000Z | 2021-04-20T15:43:09.000Z | include/o80/standalone.hpp | intelligent-soft-robots/o80 | 61ab6bab0fc1015337dcb26150cfb23414202bd0 | [
"BSD-3-Clause"
] | 9 | 2020-10-15T14:55:08.000Z | 2021-06-29T08:38:17.000Z | include/o80/standalone.hpp | intelligent-soft-robots/o80 | 61ab6bab0fc1015337dcb26150cfb23414202bd0 | [
"BSD-3-Clause"
] | 5 | 2020-07-02T14:05:50.000Z | 2021-10-04T17:19:28.000Z | // Copyright (c) 2019 Max Planck Gesellschaft
// Author : Vincent Berenz
#pragma once
#include "o80/back_end.hpp"
#include "o80/burster.hpp"
#include "o80/driver.hpp"
#include "o80/frequency_manager.hpp"
#include "o80/observation.hpp"
#include "o80/time.hpp"
#include "o80_internal/standalone_runner.hpp"
#include "synchronizer/leader.hpp"
namespace o80
{
/**
* ! if an instance of Standalone of the related segment_id is
* running, will send a stop request to this standalone.
*/
void please_stop(std::string segment_id)
{
shared_memory::set<bool>(segment_id, "should_stop", true);
try
{
synchronizer::Leader leader(segment_id + "_synchronizer");
leader.pulse();
}
catch (...)
{
}
}
/**
* ! A Standalone encapsulates and organize the
* the communication between a (robot_interfaces) driver, a
* (robot_interfaces) frontend, a (robot_interfaces) backend and
* a (o80) backend : at each iteration, information about the current state of
* the robot actuators are passed by the frontend to the backend,
* which passes to the driver desired states values.
* @tparam QUEUE_SIZE number of commands that can be hosted
* in the command queue at any point of time.
* Exceptions will be
* thrown if more commands are queued.
* @tparam NB_ACTUATORS number of actuators of the robot
* @tparam RI_ACTION template to the (robot_interfaces) frontend
* @tparam ROBOT_OUT template to the (robot_interfaces) frontend
* @tparam o80_STATE template to the (o80) BackEnd
* @tparam EXTENDED_STATE class encapsulating supplementary arbitrary
* information (i.e. supplementary to the current actuators state) that will be
* sent from the (robot_interfaces) frontend to the backend (which will add
* these information to the observations)
*/
template <int QUEUE_SIZE,
int NB_ACTUATORS,
class DRIVER,
class o80_STATE,
class o80_EXTENDED_STATE>
class Standalone
{
public:
static constexpr int queue_size = QUEUE_SIZE;
static constexpr int nb_actuators = NB_ACTUATORS;
public:
typedef std::shared_ptr<DRIVER> DriverPtr;
typedef o80_STATE o80State;
typedef o80_EXTENDED_STATE o80ExtendedState;
typedef DRIVER o80DRIVER;
private:
typedef BackEnd<QUEUE_SIZE, NB_ACTUATORS, o80_STATE, o80_EXTENDED_STATE>
o80Backend;
public:
/**
* Creates instances of:
* - (robot_interfaces) backend
* - (robot interfaces) frontend
* - (o80) BackEnd
* @param ri_driver robot_interfaces robot driver
* @param frequency desired frequency
* @param segment_id shared memory segment id for o80 BackEnd.
*/
Standalone(DriverPtr driver_ptr, double frequency, std::string segment_id);
~Standalone();
/**
* ! Starts the robot interfaces backend
*/
void start();
/**
* ! Stops the robot interfaces backend
*/
void stop();
/**
* ! - If bursting is false, performs one iteration and then wait for the
* time requied to match the desired frequency.
* - If bursting is true, hang until the o80
* FrontEnd calls "burst".
*
*/
bool spin(bool bursting = false);
/**
* ! Similar to spin, and the extended state is added to the observation
* that is written to the shared memory by the o80 BackEnd.
*
*/
bool spin(o80_EXTENDED_STATE& extended_state, bool bursting = false);
/**
* ! user code to convert the observation read from robot_interfaces
* frontend into the current o80 States.
*/
virtual o80::States<NB_ACTUATORS, o80_STATE> convert(
const typename DRIVER::DRIVER_OUT& observation) = 0;
/**
* ! user code to convert the desired states generated by the o80 BackEnd
* into action required by the robot_interfaces frontend.
*/
virtual typename DRIVER::DRIVER_IN convert(
const o80::States<NB_ACTUATORS, o80_STATE>& states) = 0;
/**
* ! converts the observation as returned by the robot_interfaces
* frontend into the o80 extended state (optional)
*/
virtual void enrich_extended_state(
o80_EXTENDED_STATE& extended_state,
const typename DRIVER::DRIVER_OUT& observation){};
private:
bool iterate(const TimePoint& time_now, o80_EXTENDED_STATE& extended_state);
private:
double frequency_;
Microseconds period_;
FrequencyManager frequency_manager_;
TimePoint now_;
std::shared_ptr<Burster> burster_;
std::string segment_id_;
DriverPtr driver_ptr_;
o80Backend o8o_backend_;
};
template <class RobotDriver, class o80Standalone, typename... Args>
void start_action_timed_standalone(std::string segment_id,
double frequency,
bool bursting,
Args&&... args);
/**
* @brief instantiates instances of (robot_interfaces) RobotDriver
* and of (o80) Standalone,
* and starts them in a thread. A runtime exception is thrown
* if another standalone of the same segment_id has already
* been started.
* tparam Args template arguments of the driver
* param segment id o80 BackEnd segment id
* param frequency frequency at which the standalone will iterate
* (non bursting mode)
* param bursting if true, will run in bursting mode, i.e.
* the standalone will iterate only when the o80
* frontend calls its burst function.
* param args arguments for the driver
*/
template <class RobotDriver, class o80Standalone, typename... Args>
void start_standalone(std::string segment_id,
double frequency,
bool bursting,
Args&&... args);
/**
* ! Stop the standalone of the specified segment_id.
* A runtime error is thrown if no such standalone is running.
*/
void stop_standalone(std::string segment_id);
/**
* ! Returns true if the standalone is iterating.
* (returns also false if the standalone does not exist)
*/
bool standalone_is_running(std::string segment_id);
#include "standalone.hxx"
} // namespace o80
| 32.333333 | 80 | 0.676385 | intelligent-soft-robots |
bae7a775e596886e63c58c30d94314ac79438201 | 72,498 | cpp | C++ | Tools/STM32FW/STM32Cube_FW_F7_V1.16.2/Projects/STM32F769I_EVAL/Demonstrations/TouchGFX/Gui/generated/images/src/Audio/pause_notPressed.cpp | ramkumarkoppu/NUCLEO-F767ZI-ESW | 85e129d71ee8eccbd0b94b5e07e75b6b91679ee8 | [
"MIT"
] | null | null | null | Tools/STM32FW/STM32Cube_FW_F7_V1.16.2/Projects/STM32F769I_EVAL/Demonstrations/TouchGFX/Gui/generated/images/src/Audio/pause_notPressed.cpp | ramkumarkoppu/NUCLEO-F767ZI-ESW | 85e129d71ee8eccbd0b94b5e07e75b6b91679ee8 | [
"MIT"
] | null | null | null | Tools/STM32FW/STM32Cube_FW_F7_V1.16.2/Projects/STM32F769I_EVAL/Demonstrations/TouchGFX/Gui/generated/images/src/Audio/pause_notPressed.cpp | ramkumarkoppu/NUCLEO-F767ZI-ESW | 85e129d71ee8eccbd0b94b5e07e75b6b91679ee8 | [
"MIT"
] | null | null | null | // Generated by imageconverter. Please, do not edit!
#include <touchgfx/hal/Config.hpp>
LOCATION_EXTFLASH_PRAGMA
KEEP extern const unsigned char _pause_notPressed[] LOCATION_EXTFLASH_ATTRIBUTE = { // 60x60 ARGB8888 pixels.
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf7,0xf5,0xf4,0xff,0xf7,0xf5,0xf3,0xff,0xf7,0xf4,0xf3,0xff,0xf7,0xf5,0xf4,0xff,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf7,0xf5,0xf4,0xff,0xf7,0xf5,0xf4,0xff,0xf7,0xf5,0xf3,0xff,0xf7,0xf4,0xf3,0xff,0xf7,0xf5,0xf3,0xff,0xf7,0xf5,0xf3,0xff,0xf7,0xf5,0xf4,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf7,0xf5,0xf4,0xff,0xf2,0xee,0xed,0xff,0xed,0xe7,0xe7,0xff,0xe9,0xe2,0xe1,0xff,0xe7,0xe0,0xdf,0xff,0xe6,0xdf,0xde,0xff,0xe6,0xdf,0xde,0xff,0xe6,0xdf,0xde,0xff,0xe7,0xe1,0xdf,0xff,0xe9,0xe3,0xe1,0xff,0xf0,0xeb,0xea,0xff,0xf7,0xf4,0xf4,0xff,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf5,0xf2,0xf1,0xff,0xed,0xe9,0xe7,0xff,0xe7,0xe1,0xdf,0xff,0xe6,0xe0,0xde,0xff,
0xe6,0xdf,0xde,0xff,0xe6,0xdf,0xde,0xff,0xe6,0xdf,0xde,0xff,0xe7,0xe0,0xde,0xff,0xe8,0xe2,0xdf,0xff,0xed,0xe8,0xe7,0xff,0xf3,0xef,0xee,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0xeb,0xe6,0xe4,0xff,0xde,0xd5,0xd2,0xff,0xd2,0xc5,0xc2,0xff,0xc8,0xb8,0xb4,0xff,0xc3,0xb2,0xae,0xff,0xc1,0xb0,0xab,0xff,0xc0,0xaf,0xab,0xff,0xc1,0xb0,0xac,0xff,0xc4,0xb3,0xaf,0xff,0xc8,0xb9,0xb5,0xff,0xd8,0xce,0xcc,0xff,0xeb,0xe6,0xe4,0xff,0xf6,0xf3,0xf3,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf2,0xee,0xec,0xff,0xe6,0xdf,0xdd,0xff,0xd4,0xc8,0xc4,0xff,0xc3,0xb4,0xaf,0xff,0xc2,0xb1,0xac,0xff,0xc0,0xaf,0xab,0xff,0xc0,0xaf,0xab,0xff,0xc0,0xaf,0xab,0xff,0xc2,0xb1,0xac,0xff,
0xc6,0xb6,0xb1,0xff,0xd2,0xc6,0xc3,0xff,0xe0,0xd7,0xd5,0xff,0xec,0xe7,0xe6,0xff,0xf7,0xf5,0xf4,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf5,0xf2,0xf2,0xff,0xde,0xd5,0xd3,0xff,0xc9,0xb9,0xb5,0xff,0xb4,0x9f,0x99,0xff,0xa3,0x8a,0x82,0xff,
0x9b,0x80,0x78,0xff,0x97,0x7b,0x73,0xff,0x96,0x7a,0x72,0xff,0x98,0x7c,0x74,0xff,0x9c,0x81,0x7a,0xff,0xa3,0x8b,0x84,0xff,0xbf,0xae,0xa9,0xff,0xde,0xd5,0xd2,0xff,0xf0,0xec,0xeb,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf5,0xf1,0xf0,0xff,0xe9,0xe2,0xe0,0xff,0xd5,0xc9,0xc6,0xff,0xb7,0xa3,0x9d,0xff,0x9c,0x82,0x79,0xff,0x99,0x7d,0x75,0xff,0x97,0x7a,0x73,0xff,0x96,0x79,0x72,0xff,0x96,0x7a,0x72,0xff,0x98,0x7d,0x74,0xff,0x9f,0x86,0x7d,0xff,0xb4,0xa0,0x9a,0xff,0xca,0xbc,0xb8,0xff,0xe0,0xd7,0xd5,0xff,
0xf2,0xee,0xed,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf2,0xef,0xee,0xff,0xd4,0xc9,0xc5,0xff,0xb7,0xa4,0x9e,0xff,0x9c,0x81,0x79,0xff,0x85,0x64,0x5a,0xff,0x7b,0x57,0x4d,0xff,0x76,0x51,0x47,0xff,0x75,0x4f,0x45,0xff,0x77,0x52,0x48,0xff,
0x7c,0x59,0x4f,0xff,0x86,0x66,0x5c,0xff,0xab,0x94,0x8e,0xff,0xd3,0xc8,0xc4,0xff,0xec,0xe6,0xe5,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf1,0xed,0xec,0xff,0xe1,0xd9,0xd7,0xff,
0xc7,0xb8,0xb4,0xff,0x9f,0x85,0x7e,0xff,0x7d,0x5a,0x4f,0xff,0x78,0x54,0x49,0xff,0x76,0x51,0x46,0xff,0x75,0x4f,0x45,0xff,0x75,0x50,0x45,0xff,0x77,0x53,0x48,0xff,0x80,0x5f,0x54,0xff,0x9c,0x82,0x7a,0xff,0xba,0xa7,0xa1,0xff,0xd6,0xca,0xc7,0xff,0xee,0xe9,0xe8,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0xed,0xec,0xff,0xce,0xc1,0xbd,0xff,0xad,0x97,0x90,0xff,0x8e,0x70,0x66,0xff,0x74,0x4f,0x44,0xff,0x69,0x40,0x34,0xff,0x63,0x39,0x2d,0xff,0x62,0x38,0x2b,0xff,0x65,0x3b,0x2f,0xff,0x6b,0x43,0x37,0xff,0x75,0x51,0x46,0xff,0x9f,0x86,0x7e,0xff,0xcd,0xc0,0xbc,0xff,
0xe9,0xe3,0xe1,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xee,0xea,0xea,0xff,0xdd,0xd4,0xd1,0xff,0xbf,0xaf,0xaa,0xff,0x92,0x75,0x6c,0xff,0x6b,0x43,0x37,0xff,0x66,0x3d,0x30,0xff,
0x63,0x39,0x2c,0xff,0x62,0x37,0x2b,0xff,0x62,0x38,0x2c,0xff,0x65,0x3c,0x2f,0xff,0x6f,0x49,0x3d,0xff,0x8f,0x71,0x68,0xff,0xb0,0x9b,0x94,0xff,0xd0,0xc3,0xbf,0xff,0xeb,0xe6,0xe4,0xff,0xf7,0xf5,0xf4,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xef,0xeb,0xea,0xff,
0xcb,0xbe,0xb9,0xff,0xa8,0x90,0x88,0xff,0x86,0x66,0x5c,0xff,0x6b,0x44,0x37,0xff,0x5e,0x34,0x26,0xff,0x59,0x2c,0x1e,0xff,0x57,0x2b,0x1d,0xff,0x5a,0x2e,0x20,0xff,0x61,0x37,0x29,0xff,0x6c,0x46,0x3a,0xff,0x98,0x7e,0x76,0xff,0xc9,0xbc,0xb8,0xff,0xe7,0xe2,0xdf,0xff,0xf6,0xf5,0xf4,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xed,0xe9,0xe8,0xff,0xda,0xd1,0xce,0xff,0xbb,0xaa,0xa4,0xff,0x8a,0x6c,0x62,0xff,0x61,0x37,0x2a,0xff,0x5b,0x30,0x22,0xff,0x58,0x2c,0x1e,0xff,0x57,0x2a,0x1c,0xff,0x58,0x2b,0x1e,0xff,0x5a,0x2e,0x22,0xff,
0x66,0x3d,0x30,0xff,0x87,0x68,0x5e,0xff,0xab,0x94,0x8d,0xff,0xcd,0xbf,0xbb,0xff,0xea,0xe4,0xe2,0xff,0xf6,0xf4,0xf4,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xef,0xeb,0xea,0xff,0xcb,0xbe,0xb9,0xff,0xa8,0x90,0x88,0xff,0x86,0x66,0x5c,0xff,0x6b,0x44,0x37,0xff,
0x5e,0x34,0x26,0xff,0x59,0x2c,0x1e,0xff,0x57,0x2b,0x1d,0xff,0x5a,0x2e,0x20,0xff,0x61,0x37,0x29,0xff,0x6c,0x46,0x3a,0xff,0x98,0x7e,0x76,0xff,0xc9,0xbc,0xb8,0xff,0xe7,0xe2,0xdf,0xff,0xf6,0xf5,0xf4,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xed,0xe9,0xe8,0xff,0xda,0xd1,0xce,0xff,0xbb,0xaa,0xa4,0xff,0x8a,0x6c,0x62,0xff,0x61,0x37,0x2a,0xff,0x5b,0x30,0x22,0xff,0x58,0x2c,0x1e,0xff,0x57,0x2a,0x1c,0xff,0x58,0x2b,0x1e,0xff,0x5a,0x2e,0x22,0xff,0x66,0x3d,0x30,0xff,0x87,0x68,0x5e,0xff,0xab,0x94,0x8d,0xff,0xcd,0xbf,0xbb,0xff,
0xea,0xe4,0xe2,0xff,0xf6,0xf4,0xf4,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xef,0xeb,0xea,0xff,0xcb,0xbe,0xb9,0xff,0xa8,0x90,0x88,0xff,0x86,0x66,0x5c,0xff,0x6b,0x44,0x37,0xff,0x5e,0x34,0x26,0xff,0x59,0x2c,0x1e,0xff,0x57,0x2b,0x1d,0xff,0x5a,0x2e,0x20,0xff,
0x61,0x37,0x29,0xff,0x6c,0x46,0x3a,0xff,0x98,0x7e,0x76,0xff,0xc9,0xbc,0xb8,0xff,0xe7,0xe2,0xdf,0xff,0xf6,0xf5,0xf4,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xed,0xe9,0xe8,0xff,0xda,0xd1,0xce,0xff,
0xbb,0xaa,0xa4,0xff,0x8a,0x6c,0x62,0xff,0x61,0x37,0x2a,0xff,0x5b,0x30,0x22,0xff,0x58,0x2c,0x1e,0xff,0x57,0x2a,0x1c,0xff,0x58,0x2b,0x1e,0xff,0x5a,0x2e,0x22,0xff,0x66,0x3d,0x30,0xff,0x87,0x68,0x5e,0xff,0xab,0x94,0x8d,0xff,0xcd,0xbf,0xbb,0xff,0xea,0xe4,0xe2,0xff,0xf6,0xf4,0xf4,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xef,0xeb,0xea,0xff,0xcb,0xbe,0xb9,0xff,0xa8,0x90,0x88,0xff,0x86,0x66,0x5c,0xff,0x6b,0x44,0x37,0xff,0x5e,0x34,0x26,0xff,0x59,0x2c,0x1e,0xff,0x57,0x2b,0x1d,0xff,0x5a,0x2e,0x20,0xff,0x61,0x37,0x29,0xff,0x6c,0x46,0x3a,0xff,0x98,0x7e,0x76,0xff,0xc9,0xbc,0xb8,0xff,
0xe7,0xe2,0xdf,0xff,0xf6,0xf5,0xf4,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xed,0xe9,0xe8,0xff,0xda,0xd1,0xce,0xff,0xbb,0xaa,0xa4,0xff,0x8a,0x6c,0x62,0xff,0x61,0x37,0x2a,0xff,0x5b,0x30,0x22,0xff,
0x58,0x2c,0x1e,0xff,0x57,0x2a,0x1c,0xff,0x58,0x2b,0x1e,0xff,0x5a,0x2e,0x22,0xff,0x66,0x3d,0x30,0xff,0x87,0x68,0x5e,0xff,0xab,0x94,0x8d,0xff,0xcd,0xbf,0xbb,0xff,0xea,0xe4,0xe2,0xff,0xf6,0xf4,0xf4,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xef,0xeb,0xea,0xff,
0xcb,0xbe,0xb9,0xff,0xa8,0x90,0x88,0xff,0x86,0x66,0x5c,0xff,0x6b,0x44,0x37,0xff,0x5e,0x34,0x26,0xff,0x59,0x2c,0x1e,0xff,0x57,0x2b,0x1d,0xff,0x5a,0x2e,0x20,0xff,0x61,0x37,0x29,0xff,0x6c,0x46,0x3a,0xff,0x98,0x7e,0x76,0xff,0xc9,0xbc,0xb8,0xff,0xe7,0xe2,0xdf,0xff,0xf6,0xf5,0xf4,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xed,0xe9,0xe8,0xff,0xda,0xd1,0xce,0xff,0xbb,0xaa,0xa4,0xff,0x8a,0x6c,0x62,0xff,0x61,0x37,0x2a,0xff,0x5b,0x30,0x22,0xff,0x58,0x2c,0x1e,0xff,0x57,0x2a,0x1c,0xff,0x58,0x2b,0x1e,0xff,0x5a,0x2e,0x22,0xff,
0x66,0x3d,0x30,0xff,0x87,0x68,0x5e,0xff,0xab,0x94,0x8d,0xff,0xcd,0xbf,0xbb,0xff,0xea,0xe4,0xe2,0xff,0xf6,0xf4,0xf4,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xef,0xeb,0xea,0xff,0xcb,0xbe,0xb9,0xff,0xa8,0x90,0x88,0xff,0x86,0x66,0x5c,0xff,0x6b,0x44,0x37,0xff,
0x5e,0x34,0x26,0xff,0x59,0x2c,0x1e,0xff,0x57,0x2b,0x1d,0xff,0x5a,0x2e,0x20,0xff,0x61,0x37,0x29,0xff,0x6c,0x46,0x3a,0xff,0x98,0x7e,0x76,0xff,0xc9,0xbc,0xb8,0xff,0xe7,0xe2,0xdf,0xff,0xf6,0xf5,0xf4,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xed,0xe9,0xe8,0xff,0xda,0xd1,0xce,0xff,0xbb,0xaa,0xa4,0xff,0x8a,0x6c,0x62,0xff,0x61,0x37,0x2a,0xff,0x5b,0x30,0x22,0xff,0x58,0x2c,0x1e,0xff,0x57,0x2a,0x1c,0xff,0x58,0x2b,0x1e,0xff,0x5a,0x2e,0x22,0xff,0x66,0x3d,0x30,0xff,0x87,0x68,0x5e,0xff,0xab,0x94,0x8d,0xff,0xcd,0xbf,0xbb,0xff,
0xea,0xe4,0xe2,0xff,0xf6,0xf4,0xf4,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xef,0xeb,0xea,0xff,0xcb,0xbe,0xb9,0xff,0xa8,0x90,0x88,0xff,0x86,0x66,0x5c,0xff,0x6b,0x44,0x37,0xff,0x5e,0x34,0x26,0xff,0x59,0x2c,0x1e,0xff,0x57,0x2b,0x1d,0xff,0x5a,0x2e,0x20,0xff,
0x61,0x37,0x29,0xff,0x6c,0x46,0x3a,0xff,0x98,0x7e,0x76,0xff,0xc9,0xbc,0xb8,0xff,0xe7,0xe2,0xdf,0xff,0xf6,0xf5,0xf4,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xed,0xe9,0xe8,0xff,0xda,0xd1,0xce,0xff,
0xbb,0xaa,0xa4,0xff,0x8a,0x6c,0x62,0xff,0x61,0x37,0x2a,0xff,0x5b,0x30,0x22,0xff,0x58,0x2c,0x1e,0xff,0x57,0x2a,0x1c,0xff,0x58,0x2b,0x1e,0xff,0x5a,0x2e,0x22,0xff,0x66,0x3d,0x30,0xff,0x87,0x68,0x5e,0xff,0xab,0x94,0x8d,0xff,0xcd,0xbf,0xbb,0xff,0xea,0xe4,0xe2,0xff,0xf6,0xf4,0xf4,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xef,0xeb,0xea,0xff,0xcb,0xbe,0xb9,0xff,0xa8,0x90,0x88,0xff,0x86,0x66,0x5c,0xff,0x6b,0x44,0x37,0xff,0x5e,0x34,0x26,0xff,0x59,0x2c,0x1e,0xff,0x57,0x2b,0x1d,0xff,0x5a,0x2e,0x20,0xff,0x61,0x37,0x29,0xff,0x6c,0x46,0x3a,0xff,0x98,0x7e,0x76,0xff,0xc9,0xbc,0xb8,0xff,
0xe7,0xe2,0xdf,0xff,0xf6,0xf5,0xf4,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xed,0xe9,0xe8,0xff,0xda,0xd1,0xce,0xff,0xbb,0xaa,0xa4,0xff,0x8a,0x6c,0x62,0xff,0x61,0x37,0x2a,0xff,0x5b,0x30,0x22,0xff,
0x58,0x2c,0x1e,0xff,0x57,0x2a,0x1c,0xff,0x58,0x2b,0x1e,0xff,0x5a,0x2e,0x22,0xff,0x66,0x3d,0x30,0xff,0x87,0x68,0x5e,0xff,0xab,0x94,0x8d,0xff,0xcd,0xbf,0xbb,0xff,0xea,0xe4,0xe2,0xff,0xf6,0xf4,0xf4,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xef,0xeb,0xea,0xff,
0xcb,0xbe,0xb9,0xff,0xa8,0x90,0x88,0xff,0x86,0x66,0x5c,0xff,0x6b,0x44,0x37,0xff,0x5e,0x34,0x26,0xff,0x59,0x2c,0x1e,0xff,0x57,0x2b,0x1d,0xff,0x5a,0x2e,0x20,0xff,0x61,0x37,0x29,0xff,0x6c,0x46,0x3a,0xff,0x98,0x7e,0x76,0xff,0xc9,0xbc,0xb8,0xff,0xe7,0xe2,0xdf,0xff,0xf6,0xf5,0xf4,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xed,0xe9,0xe8,0xff,0xda,0xd1,0xce,0xff,0xbb,0xaa,0xa4,0xff,0x8a,0x6c,0x62,0xff,0x61,0x37,0x2a,0xff,0x5b,0x30,0x22,0xff,0x58,0x2c,0x1e,0xff,0x57,0x2a,0x1c,0xff,0x58,0x2b,0x1e,0xff,0x5a,0x2e,0x22,0xff,
0x66,0x3d,0x30,0xff,0x87,0x68,0x5e,0xff,0xab,0x94,0x8d,0xff,0xcd,0xbf,0xbb,0xff,0xea,0xe4,0xe2,0xff,0xf6,0xf4,0xf4,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xef,0xeb,0xea,0xff,0xcb,0xbe,0xb9,0xff,0xa8,0x90,0x88,0xff,0x86,0x66,0x5c,0xff,0x6b,0x44,0x37,0xff,
0x5e,0x34,0x26,0xff,0x59,0x2c,0x1e,0xff,0x57,0x2b,0x1d,0xff,0x5a,0x2e,0x20,0xff,0x61,0x37,0x29,0xff,0x6c,0x46,0x3a,0xff,0x98,0x7e,0x76,0xff,0xc9,0xbc,0xb8,0xff,0xe7,0xe2,0xdf,0xff,0xf6,0xf5,0xf4,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xed,0xe9,0xe8,0xff,0xda,0xd1,0xce,0xff,0xbb,0xaa,0xa4,0xff,0x8a,0x6c,0x62,0xff,0x61,0x37,0x2a,0xff,0x5b,0x30,0x22,0xff,0x58,0x2c,0x1e,0xff,0x57,0x2a,0x1c,0xff,0x58,0x2b,0x1e,0xff,0x5a,0x2e,0x22,0xff,0x66,0x3d,0x30,0xff,0x87,0x68,0x5e,0xff,0xab,0x94,0x8d,0xff,0xcd,0xbf,0xbb,0xff,
0xea,0xe4,0xe2,0xff,0xf6,0xf4,0xf4,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xef,0xeb,0xea,0xff,0xcb,0xbe,0xb9,0xff,0xa8,0x90,0x88,0xff,0x86,0x66,0x5c,0xff,0x6b,0x44,0x37,0xff,0x5e,0x34,0x26,0xff,0x59,0x2c,0x1e,0xff,0x57,0x2b,0x1d,0xff,0x5a,0x2e,0x20,0xff,
0x61,0x37,0x29,0xff,0x6c,0x46,0x3a,0xff,0x98,0x7e,0x76,0xff,0xc9,0xbc,0xb8,0xff,0xe7,0xe2,0xdf,0xff,0xf6,0xf5,0xf4,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xed,0xe9,0xe8,0xff,0xda,0xd1,0xce,0xff,
0xbb,0xaa,0xa4,0xff,0x8a,0x6c,0x62,0xff,0x61,0x37,0x2a,0xff,0x5b,0x30,0x22,0xff,0x58,0x2c,0x1e,0xff,0x57,0x2a,0x1c,0xff,0x58,0x2b,0x1e,0xff,0x5a,0x2e,0x22,0xff,0x66,0x3d,0x30,0xff,0x87,0x68,0x5e,0xff,0xab,0x94,0x8d,0xff,0xcd,0xbf,0xbb,0xff,0xea,0xe4,0xe2,0xff,0xf6,0xf4,0xf4,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xef,0xeb,0xea,0xff,0xcb,0xbe,0xb9,0xff,0xa8,0x90,0x88,0xff,0x86,0x66,0x5c,0xff,0x6b,0x44,0x37,0xff,0x5e,0x34,0x26,0xff,0x59,0x2c,0x1e,0xff,0x57,0x2b,0x1d,0xff,0x5a,0x2e,0x20,0xff,0x61,0x37,0x29,0xff,0x6c,0x46,0x3a,0xff,0x98,0x7e,0x76,0xff,0xc9,0xbc,0xb8,0xff,
0xe7,0xe2,0xdf,0xff,0xf6,0xf5,0xf4,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xed,0xe9,0xe8,0xff,0xda,0xd1,0xce,0xff,0xbb,0xaa,0xa4,0xff,0x8a,0x6c,0x62,0xff,0x61,0x37,0x2a,0xff,0x5b,0x30,0x22,0xff,
0x58,0x2c,0x1e,0xff,0x57,0x2a,0x1c,0xff,0x58,0x2b,0x1e,0xff,0x5a,0x2e,0x22,0xff,0x66,0x3d,0x30,0xff,0x87,0x68,0x5e,0xff,0xab,0x94,0x8d,0xff,0xcd,0xbf,0xbb,0xff,0xea,0xe4,0xe2,0xff,0xf6,0xf4,0xf4,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xef,0xeb,0xea,0xff,
0xcb,0xbe,0xb9,0xff,0xa8,0x90,0x88,0xff,0x86,0x66,0x5c,0xff,0x6b,0x44,0x37,0xff,0x5e,0x34,0x26,0xff,0x59,0x2c,0x1e,0xff,0x57,0x2b,0x1d,0xff,0x5a,0x2e,0x20,0xff,0x61,0x37,0x29,0xff,0x6c,0x46,0x3a,0xff,0x98,0x7e,0x76,0xff,0xc9,0xbc,0xb8,0xff,0xe7,0xe2,0xdf,0xff,0xf6,0xf5,0xf4,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xed,0xe9,0xe8,0xff,0xda,0xd1,0xce,0xff,0xbb,0xaa,0xa4,0xff,0x8a,0x6c,0x62,0xff,0x61,0x37,0x2a,0xff,0x5b,0x30,0x22,0xff,0x58,0x2c,0x1e,0xff,0x57,0x2a,0x1c,0xff,0x58,0x2b,0x1e,0xff,0x5a,0x2e,0x22,0xff,
0x66,0x3d,0x30,0xff,0x87,0x68,0x5e,0xff,0xab,0x94,0x8d,0xff,0xcd,0xbf,0xbb,0xff,0xea,0xe4,0xe2,0xff,0xf6,0xf4,0xf4,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xef,0xeb,0xea,0xff,0xcb,0xbe,0xb9,0xff,0xa8,0x90,0x88,0xff,0x86,0x66,0x5c,0xff,0x6b,0x44,0x37,0xff,
0x5e,0x34,0x26,0xff,0x59,0x2c,0x1e,0xff,0x57,0x2b,0x1d,0xff,0x5a,0x2e,0x20,0xff,0x61,0x37,0x29,0xff,0x6c,0x46,0x3a,0xff,0x98,0x7e,0x76,0xff,0xc9,0xbc,0xb8,0xff,0xe7,0xe2,0xdf,0xff,0xf6,0xf5,0xf4,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xed,0xe9,0xe8,0xff,0xda,0xd1,0xce,0xff,0xbb,0xaa,0xa4,0xff,0x8a,0x6c,0x62,0xff,0x61,0x37,0x2a,0xff,0x5b,0x30,0x22,0xff,0x58,0x2c,0x1e,0xff,0x57,0x2a,0x1c,0xff,0x58,0x2b,0x1e,0xff,0x5a,0x2e,0x22,0xff,0x66,0x3d,0x30,0xff,0x87,0x68,0x5e,0xff,0xab,0x94,0x8d,0xff,0xcd,0xbf,0xbb,0xff,
0xea,0xe4,0xe2,0xff,0xf6,0xf4,0xf4,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xef,0xeb,0xea,0xff,0xcb,0xbe,0xb9,0xff,0xa8,0x90,0x88,0xff,0x86,0x66,0x5c,0xff,0x6b,0x44,0x37,0xff,0x5e,0x34,0x26,0xff,0x59,0x2c,0x1e,0xff,0x57,0x2b,0x1d,0xff,0x5a,0x2e,0x20,0xff,
0x61,0x37,0x29,0xff,0x6c,0x46,0x3a,0xff,0x98,0x7e,0x76,0xff,0xc9,0xbc,0xb8,0xff,0xe7,0xe2,0xdf,0xff,0xf6,0xf5,0xf4,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xed,0xe9,0xe8,0xff,0xda,0xd1,0xce,0xff,
0xbb,0xaa,0xa4,0xff,0x8a,0x6c,0x62,0xff,0x61,0x37,0x2a,0xff,0x5b,0x30,0x22,0xff,0x58,0x2c,0x1e,0xff,0x57,0x2a,0x1c,0xff,0x58,0x2b,0x1e,0xff,0x5a,0x2e,0x22,0xff,0x66,0x3d,0x30,0xff,0x87,0x68,0x5e,0xff,0xab,0x94,0x8d,0xff,0xcd,0xbf,0xbb,0xff,0xea,0xe4,0xe2,0xff,0xf6,0xf4,0xf4,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xef,0xeb,0xea,0xff,0xcb,0xbe,0xb9,0xff,0xa8,0x90,0x88,0xff,0x86,0x66,0x5c,0xff,0x6b,0x44,0x37,0xff,0x5e,0x34,0x26,0xff,0x59,0x2c,0x1e,0xff,0x57,0x2b,0x1d,0xff,0x5a,0x2e,0x20,0xff,0x61,0x37,0x29,0xff,0x6c,0x46,0x3a,0xff,0x98,0x7e,0x76,0xff,0xc9,0xbc,0xb8,0xff,
0xe7,0xe2,0xdf,0xff,0xf6,0xf5,0xf4,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xed,0xe9,0xe8,0xff,0xda,0xd1,0xce,0xff,0xbb,0xaa,0xa4,0xff,0x8a,0x6c,0x62,0xff,0x61,0x37,0x2a,0xff,0x5b,0x30,0x22,0xff,
0x58,0x2c,0x1e,0xff,0x57,0x2a,0x1c,0xff,0x58,0x2b,0x1e,0xff,0x5a,0x2e,0x22,0xff,0x66,0x3d,0x30,0xff,0x87,0x68,0x5e,0xff,0xab,0x94,0x8d,0xff,0xcd,0xbf,0xbb,0xff,0xea,0xe4,0xe2,0xff,0xf6,0xf4,0xf4,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xef,0xeb,0xea,0xff,
0xcb,0xbe,0xb9,0xff,0xa8,0x90,0x88,0xff,0x86,0x66,0x5c,0xff,0x6b,0x44,0x37,0xff,0x5e,0x34,0x26,0xff,0x59,0x2c,0x1e,0xff,0x57,0x2b,0x1d,0xff,0x5a,0x2e,0x20,0xff,0x61,0x37,0x29,0xff,0x6c,0x46,0x3a,0xff,0x98,0x7e,0x76,0xff,0xc9,0xbc,0xb8,0xff,0xe7,0xe2,0xdf,0xff,0xf6,0xf5,0xf4,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xed,0xe9,0xe8,0xff,0xda,0xd1,0xce,0xff,0xbb,0xaa,0xa4,0xff,0x8a,0x6c,0x62,0xff,0x61,0x37,0x2a,0xff,0x5b,0x30,0x22,0xff,0x58,0x2c,0x1e,0xff,0x57,0x2a,0x1c,0xff,0x58,0x2b,0x1e,0xff,0x5a,0x2e,0x22,0xff,
0x66,0x3d,0x30,0xff,0x87,0x68,0x5e,0xff,0xab,0x94,0x8d,0xff,0xcd,0xbf,0xbb,0xff,0xea,0xe4,0xe2,0xff,0xf6,0xf4,0xf4,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xef,0xeb,0xea,0xff,0xcb,0xbe,0xb9,0xff,0xa8,0x90,0x88,0xff,0x86,0x66,0x5c,0xff,0x6b,0x44,0x37,0xff,
0x5e,0x34,0x26,0xff,0x59,0x2c,0x1e,0xff,0x57,0x2b,0x1d,0xff,0x5a,0x2e,0x20,0xff,0x61,0x37,0x29,0xff,0x6c,0x46,0x3a,0xff,0x98,0x7e,0x76,0xff,0xc9,0xbc,0xb8,0xff,0xe7,0xe2,0xdf,0xff,0xf6,0xf5,0xf4,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xed,0xe9,0xe8,0xff,0xda,0xd1,0xce,0xff,0xbb,0xaa,0xa4,0xff,0x8a,0x6c,0x62,0xff,0x61,0x37,0x2a,0xff,0x5b,0x30,0x22,0xff,0x58,0x2c,0x1e,0xff,0x57,0x2a,0x1c,0xff,0x58,0x2b,0x1e,0xff,0x5a,0x2e,0x22,0xff,0x66,0x3d,0x30,0xff,0x87,0x68,0x5e,0xff,0xab,0x94,0x8d,0xff,0xcd,0xbf,0xbb,0xff,
0xea,0xe4,0xe2,0xff,0xf6,0xf4,0xf4,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xef,0xeb,0xea,0xff,0xcb,0xbe,0xb9,0xff,0xa8,0x90,0x88,0xff,0x86,0x66,0x5c,0xff,0x6b,0x44,0x37,0xff,0x5e,0x34,0x26,0xff,0x59,0x2c,0x1e,0xff,0x57,0x2b,0x1d,0xff,0x5a,0x2e,0x20,0xff,
0x61,0x37,0x29,0xff,0x6c,0x46,0x3a,0xff,0x98,0x7e,0x76,0xff,0xc9,0xbc,0xb8,0xff,0xe7,0xe2,0xdf,0xff,0xf6,0xf5,0xf4,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xed,0xe9,0xe8,0xff,0xda,0xd1,0xce,0xff,
0xbb,0xaa,0xa4,0xff,0x8a,0x6c,0x62,0xff,0x61,0x37,0x2a,0xff,0x5b,0x30,0x22,0xff,0x58,0x2c,0x1e,0xff,0x57,0x2a,0x1c,0xff,0x58,0x2b,0x1e,0xff,0x5a,0x2e,0x22,0xff,0x66,0x3d,0x30,0xff,0x87,0x68,0x5e,0xff,0xab,0x94,0x8d,0xff,0xcd,0xbf,0xbb,0xff,0xea,0xe4,0xe2,0xff,0xf6,0xf4,0xf4,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xef,0xeb,0xea,0xff,0xcb,0xbe,0xb9,0xff,0xa8,0x90,0x88,0xff,0x86,0x66,0x5c,0xff,0x6b,0x44,0x37,0xff,0x5e,0x34,0x26,0xff,0x59,0x2c,0x1e,0xff,0x57,0x2b,0x1d,0xff,0x5a,0x2e,0x20,0xff,0x61,0x37,0x29,0xff,0x6c,0x46,0x3a,0xff,0x98,0x7e,0x76,0xff,0xc9,0xbc,0xb8,0xff,
0xe7,0xe2,0xdf,0xff,0xf6,0xf5,0xf4,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xed,0xe9,0xe8,0xff,0xda,0xd1,0xce,0xff,0xbb,0xaa,0xa4,0xff,0x8a,0x6c,0x62,0xff,0x61,0x37,0x2a,0xff,0x5b,0x30,0x22,0xff,
0x58,0x2c,0x1e,0xff,0x57,0x2a,0x1c,0xff,0x58,0x2b,0x1e,0xff,0x5a,0x2e,0x22,0xff,0x66,0x3d,0x30,0xff,0x87,0x68,0x5e,0xff,0xab,0x94,0x8d,0xff,0xcd,0xbf,0xbb,0xff,0xea,0xe4,0xe2,0xff,0xf6,0xf4,0xf4,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xef,0xeb,0xea,0xff,
0xcb,0xbe,0xb9,0xff,0xa8,0x90,0x88,0xff,0x86,0x66,0x5c,0xff,0x6b,0x44,0x37,0xff,0x5e,0x34,0x26,0xff,0x59,0x2c,0x1e,0xff,0x57,0x2b,0x1d,0xff,0x5a,0x2e,0x20,0xff,0x61,0x37,0x29,0xff,0x6c,0x46,0x3a,0xff,0x98,0x7e,0x76,0xff,0xc9,0xbc,0xb8,0xff,0xe7,0xe2,0xdf,0xff,0xf6,0xf5,0xf4,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xed,0xe9,0xe8,0xff,0xda,0xd1,0xce,0xff,0xbb,0xaa,0xa4,0xff,0x8a,0x6c,0x62,0xff,0x61,0x37,0x2a,0xff,0x5b,0x30,0x22,0xff,0x58,0x2c,0x1e,0xff,0x57,0x2a,0x1c,0xff,0x58,0x2b,0x1e,0xff,0x5a,0x2e,0x22,0xff,
0x66,0x3d,0x30,0xff,0x87,0x68,0x5e,0xff,0xab,0x94,0x8d,0xff,0xcd,0xbf,0xbb,0xff,0xea,0xe4,0xe2,0xff,0xf6,0xf4,0xf4,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xef,0xeb,0xea,0xff,0xcb,0xbe,0xb9,0xff,0xa8,0x90,0x88,0xff,0x86,0x66,0x5c,0xff,0x6b,0x44,0x37,0xff,
0x5e,0x34,0x26,0xff,0x59,0x2c,0x1e,0xff,0x57,0x2b,0x1d,0xff,0x5a,0x2e,0x20,0xff,0x61,0x37,0x29,0xff,0x6c,0x46,0x3a,0xff,0x98,0x7e,0x76,0xff,0xc9,0xbc,0xb8,0xff,0xe7,0xe2,0xdf,0xff,0xf6,0xf5,0xf4,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xed,0xe9,0xe8,0xff,0xda,0xd1,0xce,0xff,0xbb,0xaa,0xa4,0xff,0x8a,0x6c,0x62,0xff,0x61,0x37,0x2a,0xff,0x5b,0x30,0x22,0xff,0x58,0x2c,0x1e,0xff,0x57,0x2a,0x1c,0xff,0x58,0x2b,0x1e,0xff,0x5a,0x2e,0x22,0xff,0x66,0x3d,0x30,0xff,0x87,0x68,0x5e,0xff,0xab,0x94,0x8d,0xff,0xcd,0xbf,0xbb,0xff,
0xea,0xe4,0xe2,0xff,0xf6,0xf4,0xf4,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xef,0xeb,0xea,0xff,0xcb,0xbe,0xb9,0xff,0xa8,0x90,0x88,0xff,0x86,0x66,0x5c,0xff,0x6b,0x44,0x37,0xff,0x5e,0x34,0x26,0xff,0x59,0x2c,0x1e,0xff,0x57,0x2b,0x1d,0xff,0x5a,0x2e,0x20,0xff,
0x61,0x37,0x29,0xff,0x6c,0x46,0x3a,0xff,0x98,0x7e,0x76,0xff,0xc9,0xbc,0xb8,0xff,0xe7,0xe2,0xdf,0xff,0xf6,0xf5,0xf4,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xed,0xe9,0xe8,0xff,0xda,0xd1,0xce,0xff,
0xbb,0xaa,0xa4,0xff,0x8a,0x6c,0x62,0xff,0x61,0x37,0x2a,0xff,0x5b,0x30,0x22,0xff,0x58,0x2c,0x1e,0xff,0x57,0x2a,0x1c,0xff,0x58,0x2b,0x1e,0xff,0x5a,0x2e,0x22,0xff,0x66,0x3d,0x30,0xff,0x87,0x68,0x5e,0xff,0xab,0x94,0x8d,0xff,0xcd,0xbf,0xbb,0xff,0xea,0xe4,0xe2,0xff,0xf6,0xf4,0xf4,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xef,0xeb,0xea,0xff,0xcb,0xbe,0xb9,0xff,0xa8,0x90,0x88,0xff,0x86,0x66,0x5c,0xff,0x6b,0x44,0x37,0xff,0x5e,0x34,0x26,0xff,0x59,0x2c,0x1e,0xff,0x57,0x2b,0x1d,0xff,0x5a,0x2e,0x20,0xff,0x61,0x37,0x29,0xff,0x6c,0x46,0x3a,0xff,0x98,0x7e,0x76,0xff,0xc9,0xbc,0xb8,0xff,
0xe7,0xe2,0xdf,0xff,0xf6,0xf5,0xf4,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xed,0xe9,0xe8,0xff,0xda,0xd1,0xce,0xff,0xbb,0xaa,0xa4,0xff,0x8a,0x6c,0x62,0xff,0x61,0x37,0x2a,0xff,0x5b,0x30,0x22,0xff,
0x58,0x2c,0x1e,0xff,0x57,0x2a,0x1c,0xff,0x58,0x2b,0x1e,0xff,0x5a,0x2e,0x22,0xff,0x66,0x3d,0x30,0xff,0x87,0x68,0x5e,0xff,0xab,0x94,0x8d,0xff,0xcd,0xbf,0xbb,0xff,0xea,0xe4,0xe2,0xff,0xf6,0xf4,0xf4,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xef,0xeb,0xea,0xff,
0xcb,0xbe,0xb9,0xff,0xa8,0x90,0x88,0xff,0x86,0x66,0x5c,0xff,0x6b,0x44,0x37,0xff,0x5e,0x34,0x26,0xff,0x59,0x2c,0x1e,0xff,0x57,0x2b,0x1d,0xff,0x5a,0x2e,0x20,0xff,0x61,0x37,0x29,0xff,0x6c,0x46,0x3a,0xff,0x98,0x7e,0x76,0xff,0xc9,0xbc,0xb8,0xff,0xe7,0xe2,0xdf,0xff,0xf6,0xf5,0xf4,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xed,0xe9,0xe8,0xff,0xda,0xd1,0xce,0xff,0xbb,0xaa,0xa4,0xff,0x8a,0x6c,0x62,0xff,0x61,0x37,0x2a,0xff,0x5b,0x30,0x22,0xff,0x58,0x2c,0x1e,0xff,0x57,0x2a,0x1c,0xff,0x58,0x2b,0x1e,0xff,0x5a,0x2e,0x22,0xff,
0x66,0x3d,0x30,0xff,0x87,0x68,0x5e,0xff,0xab,0x94,0x8d,0xff,0xcd,0xbf,0xbb,0xff,0xea,0xe4,0xe2,0xff,0xf6,0xf4,0xf4,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xef,0xeb,0xea,0xff,0xcb,0xbe,0xb9,0xff,0xa8,0x90,0x88,0xff,0x86,0x66,0x5c,0xff,0x6b,0x44,0x37,0xff,
0x5e,0x34,0x26,0xff,0x59,0x2c,0x1e,0xff,0x57,0x2b,0x1d,0xff,0x5a,0x2e,0x20,0xff,0x61,0x37,0x29,0xff,0x6c,0x46,0x3a,0xff,0x98,0x7e,0x76,0xff,0xc9,0xbc,0xb8,0xff,0xe7,0xe2,0xdf,0xff,0xf6,0xf5,0xf4,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xed,0xe9,0xe8,0xff,0xda,0xd1,0xce,0xff,0xbb,0xaa,0xa4,0xff,0x8a,0x6c,0x62,0xff,0x61,0x37,0x2a,0xff,0x5b,0x30,0x22,0xff,0x58,0x2c,0x1e,0xff,0x57,0x2a,0x1c,0xff,0x58,0x2b,0x1e,0xff,0x5a,0x2e,0x22,0xff,0x66,0x3d,0x30,0xff,0x87,0x68,0x5e,0xff,0xab,0x94,0x8d,0xff,0xcd,0xbf,0xbb,0xff,
0xea,0xe4,0xe2,0xff,0xf6,0xf4,0xf4,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xef,0xeb,0xea,0xff,0xcb,0xbe,0xb9,0xff,0xa8,0x90,0x88,0xff,0x86,0x66,0x5c,0xff,0x6b,0x44,0x37,0xff,0x5e,0x34,0x26,0xff,0x59,0x2c,0x1e,0xff,0x57,0x2b,0x1d,0xff,0x5a,0x2e,0x20,0xff,
0x61,0x37,0x29,0xff,0x6c,0x46,0x3a,0xff,0x98,0x7e,0x76,0xff,0xc9,0xbc,0xb8,0xff,0xe7,0xe2,0xdf,0xff,0xf6,0xf5,0xf4,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xed,0xe9,0xe8,0xff,0xda,0xd1,0xce,0xff,
0xbb,0xaa,0xa4,0xff,0x8a,0x6c,0x62,0xff,0x61,0x37,0x2a,0xff,0x5b,0x30,0x22,0xff,0x58,0x2c,0x1e,0xff,0x57,0x2a,0x1c,0xff,0x58,0x2b,0x1e,0xff,0x5a,0x2e,0x22,0xff,0x66,0x3d,0x30,0xff,0x87,0x68,0x5e,0xff,0xab,0x94,0x8d,0xff,0xcd,0xbf,0xbb,0xff,0xea,0xe4,0xe2,0xff,0xf6,0xf4,0xf4,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xef,0xeb,0xea,0xff,0xcb,0xbe,0xb9,0xff,0xa8,0x90,0x88,0xff,0x86,0x66,0x5c,0xff,0x6b,0x44,0x37,0xff,0x5e,0x34,0x26,0xff,0x59,0x2c,0x1e,0xff,0x57,0x2b,0x1d,0xff,0x5a,0x2e,0x20,0xff,0x61,0x37,0x29,0xff,0x6c,0x46,0x3a,0xff,0x98,0x7e,0x76,0xff,0xc9,0xbc,0xb8,0xff,
0xe7,0xe2,0xdf,0xff,0xf6,0xf5,0xf4,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xed,0xe9,0xe8,0xff,0xda,0xd1,0xce,0xff,0xbb,0xaa,0xa4,0xff,0x8a,0x6c,0x62,0xff,0x61,0x37,0x2a,0xff,0x5b,0x30,0x22,0xff,
0x58,0x2c,0x1e,0xff,0x57,0x2a,0x1c,0xff,0x58,0x2b,0x1e,0xff,0x5a,0x2e,0x22,0xff,0x66,0x3d,0x30,0xff,0x87,0x68,0x5e,0xff,0xab,0x94,0x8d,0xff,0xcd,0xbf,0xbb,0xff,0xea,0xe4,0xe2,0xff,0xf6,0xf4,0xf4,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xef,0xeb,0xea,0xff,
0xcb,0xbe,0xb9,0xff,0xa8,0x90,0x88,0xff,0x86,0x66,0x5c,0xff,0x6b,0x44,0x37,0xff,0x5e,0x34,0x26,0xff,0x59,0x2c,0x1e,0xff,0x57,0x2b,0x1d,0xff,0x5a,0x2e,0x20,0xff,0x61,0x37,0x29,0xff,0x6c,0x46,0x3a,0xff,0x98,0x7e,0x76,0xff,0xc9,0xbc,0xb8,0xff,0xe7,0xe2,0xdf,0xff,0xf6,0xf5,0xf4,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xed,0xe9,0xe8,0xff,0xda,0xd1,0xce,0xff,0xbb,0xaa,0xa4,0xff,0x8a,0x6c,0x62,0xff,0x61,0x37,0x2a,0xff,0x5b,0x30,0x22,0xff,0x58,0x2c,0x1e,0xff,0x57,0x2a,0x1c,0xff,0x58,0x2b,0x1e,0xff,0x5a,0x2e,0x22,0xff,
0x66,0x3d,0x30,0xff,0x87,0x68,0x5e,0xff,0xab,0x94,0x8d,0xff,0xcd,0xbf,0xbb,0xff,0xea,0xe4,0xe2,0xff,0xf6,0xf4,0xf4,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xef,0xeb,0xea,0xff,0xcb,0xbe,0xb9,0xff,0xa8,0x90,0x88,0xff,0x86,0x66,0x5c,0xff,0x6b,0x44,0x37,0xff,
0x5e,0x34,0x26,0xff,0x59,0x2c,0x1e,0xff,0x57,0x2b,0x1d,0xff,0x5a,0x2e,0x20,0xff,0x61,0x37,0x29,0xff,0x6c,0x46,0x3a,0xff,0x98,0x7e,0x76,0xff,0xc9,0xbc,0xb8,0xff,0xe7,0xe2,0xdf,0xff,0xf6,0xf5,0xf4,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xed,0xe9,0xe8,0xff,0xda,0xd1,0xce,0xff,0xbb,0xaa,0xa4,0xff,0x8a,0x6c,0x62,0xff,0x61,0x37,0x2a,0xff,0x5b,0x30,0x22,0xff,0x58,0x2c,0x1e,0xff,0x57,0x2a,0x1c,0xff,0x58,0x2b,0x1e,0xff,0x5a,0x2e,0x22,0xff,0x66,0x3d,0x30,0xff,0x87,0x68,0x5e,0xff,0xab,0x94,0x8d,0xff,0xcd,0xbf,0xbb,0xff,
0xea,0xe4,0xe2,0xff,0xf6,0xf4,0xf4,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xef,0xeb,0xea,0xff,0xcb,0xbe,0xb9,0xff,0xa8,0x90,0x88,0xff,0x86,0x66,0x5c,0xff,0x6b,0x44,0x37,0xff,0x5e,0x34,0x26,0xff,0x59,0x2c,0x1e,0xff,0x57,0x2b,0x1d,0xff,0x5a,0x2e,0x20,0xff,
0x61,0x37,0x29,0xff,0x6c,0x46,0x3a,0xff,0x98,0x7e,0x76,0xff,0xc9,0xbc,0xb8,0xff,0xe7,0xe2,0xdf,0xff,0xf6,0xf5,0xf4,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xed,0xe9,0xe8,0xff,0xda,0xd1,0xce,0xff,
0xbb,0xaa,0xa4,0xff,0x8a,0x6c,0x62,0xff,0x61,0x37,0x2a,0xff,0x5b,0x30,0x22,0xff,0x58,0x2c,0x1e,0xff,0x57,0x2a,0x1c,0xff,0x58,0x2b,0x1e,0xff,0x5a,0x2e,0x22,0xff,0x66,0x3d,0x30,0xff,0x87,0x68,0x5e,0xff,0xab,0x94,0x8d,0xff,0xcd,0xbf,0xbb,0xff,0xea,0xe4,0xe2,0xff,0xf6,0xf4,0xf4,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xef,0xeb,0xea,0xff,0xcb,0xbe,0xb9,0xff,0xa8,0x90,0x88,0xff,0x86,0x66,0x5c,0xff,0x6b,0x44,0x37,0xff,0x5e,0x34,0x26,0xff,0x59,0x2c,0x1e,0xff,0x57,0x2b,0x1d,0xff,0x5a,0x2e,0x20,0xff,0x61,0x37,0x29,0xff,0x6c,0x46,0x3a,0xff,0x98,0x7e,0x76,0xff,0xc9,0xbc,0xb8,0xff,
0xe7,0xe2,0xdf,0xff,0xf6,0xf5,0xf4,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xed,0xe9,0xe8,0xff,0xda,0xd1,0xce,0xff,0xbb,0xaa,0xa4,0xff,0x8a,0x6c,0x62,0xff,0x61,0x37,0x2a,0xff,0x5b,0x30,0x22,0xff,
0x58,0x2c,0x1e,0xff,0x57,0x2a,0x1c,0xff,0x58,0x2b,0x1e,0xff,0x5a,0x2e,0x22,0xff,0x66,0x3d,0x30,0xff,0x87,0x68,0x5e,0xff,0xab,0x94,0x8d,0xff,0xcd,0xbf,0xbb,0xff,0xea,0xe4,0xe2,0xff,0xf6,0xf4,0xf4,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xef,0xeb,0xea,0xff,
0xcb,0xbe,0xb9,0xff,0xa8,0x90,0x88,0xff,0x86,0x66,0x5c,0xff,0x6b,0x44,0x37,0xff,0x5e,0x34,0x26,0xff,0x59,0x2c,0x1e,0xff,0x57,0x2b,0x1d,0xff,0x5a,0x2e,0x20,0xff,0x61,0x37,0x29,0xff,0x6c,0x46,0x3a,0xff,0x98,0x7e,0x76,0xff,0xc9,0xbc,0xb8,0xff,0xe7,0xe2,0xdf,0xff,0xf6,0xf5,0xf4,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xed,0xe9,0xe8,0xff,0xda,0xd1,0xce,0xff,0xbb,0xaa,0xa4,0xff,0x8a,0x6c,0x62,0xff,0x61,0x37,0x2a,0xff,0x5b,0x30,0x22,0xff,0x58,0x2c,0x1e,0xff,0x57,0x2a,0x1c,0xff,0x58,0x2b,0x1e,0xff,0x5a,0x2e,0x22,0xff,
0x66,0x3d,0x30,0xff,0x87,0x68,0x5e,0xff,0xab,0x94,0x8d,0xff,0xcd,0xbf,0xbb,0xff,0xea,0xe4,0xe2,0xff,0xf6,0xf4,0xf4,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xef,0xeb,0xea,0xff,0xcb,0xbe,0xb9,0xff,0xa8,0x90,0x88,0xff,0x86,0x66,0x5c,0xff,0x6b,0x44,0x37,0xff,
0x5e,0x34,0x26,0xff,0x59,0x2c,0x1e,0xff,0x57,0x2b,0x1d,0xff,0x5a,0x2e,0x20,0xff,0x61,0x37,0x29,0xff,0x6c,0x46,0x3a,0xff,0x98,0x7e,0x76,0xff,0xc9,0xbc,0xb8,0xff,0xe7,0xe2,0xdf,0xff,0xf6,0xf5,0xf4,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xed,0xe9,0xe8,0xff,0xda,0xd1,0xce,0xff,0xbb,0xaa,0xa4,0xff,0x8a,0x6c,0x62,0xff,0x61,0x37,0x2a,0xff,0x5b,0x30,0x22,0xff,0x58,0x2c,0x1e,0xff,0x57,0x2a,0x1c,0xff,0x58,0x2b,0x1e,0xff,0x5a,0x2e,0x22,0xff,0x66,0x3d,0x30,0xff,0x87,0x68,0x5e,0xff,0xab,0x94,0x8d,0xff,0xcd,0xbf,0xbb,0xff,
0xea,0xe4,0xe2,0xff,0xf6,0xf4,0xf4,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xef,0xeb,0xea,0xff,0xcb,0xbe,0xb9,0xff,0xa8,0x90,0x88,0xff,0x86,0x66,0x5c,0xff,0x6b,0x44,0x37,0xff,0x5e,0x34,0x26,0xff,0x59,0x2c,0x1e,0xff,0x57,0x2b,0x1d,0xff,0x5a,0x2e,0x20,0xff,
0x61,0x37,0x29,0xff,0x6c,0x46,0x3a,0xff,0x98,0x7e,0x76,0xff,0xc9,0xbc,0xb8,0xff,0xe7,0xe2,0xdf,0xff,0xf6,0xf5,0xf4,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xed,0xe9,0xe8,0xff,0xda,0xd1,0xce,0xff,
0xbb,0xaa,0xa4,0xff,0x8a,0x6c,0x62,0xff,0x61,0x37,0x2a,0xff,0x5b,0x30,0x22,0xff,0x58,0x2c,0x1e,0xff,0x57,0x2a,0x1c,0xff,0x58,0x2b,0x1e,0xff,0x5a,0x2e,0x22,0xff,0x66,0x3d,0x30,0xff,0x87,0x68,0x5e,0xff,0xab,0x94,0x8d,0xff,0xcd,0xbf,0xbb,0xff,0xea,0xe4,0xe2,0xff,0xf6,0xf4,0xf4,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xef,0xeb,0xea,0xff,0xcb,0xbe,0xb9,0xff,0xa8,0x91,0x89,0xff,0x87,0x67,0x5d,0xff,0x6c,0x45,0x38,0xff,0x60,0x35,0x28,0xff,0x5a,0x2d,0x20,0xff,0x58,0x2c,0x1e,0xff,0x5b,0x30,0x22,0xff,0x61,0x38,0x2b,0xff,0x6d,0x47,0x3b,0xff,0x99,0x7f,0x77,0xff,0xca,0xbd,0xb8,0xff,
0xe7,0xe2,0xdf,0xff,0xf6,0xf5,0xf4,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xed,0xe9,0xe8,0xff,0xda,0xd2,0xce,0xff,0xbb,0xaa,0xa5,0xff,0x8b,0x6d,0x64,0xff,0x62,0x38,0x2b,0xff,0x5c,0x31,0x23,0xff,
0x5a,0x2d,0x1f,0xff,0x58,0x2b,0x1d,0xff,0x59,0x2c,0x1f,0xff,0x5c,0x30,0x22,0xff,0x67,0x3e,0x31,0xff,0x88,0x69,0x5f,0xff,0xac,0x95,0x8e,0xff,0xcd,0xc0,0xbb,0xff,0xea,0xe4,0xe2,0xff,0xf6,0xf4,0xf4,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0xec,0xeb,0xff,
0xcc,0xbe,0xba,0xff,0xa9,0x93,0x8b,0xff,0x89,0x6a,0x60,0xff,0x6f,0x48,0x3c,0xff,0x62,0x38,0x2b,0xff,0x5d,0x31,0x24,0xff,0x5b,0x2f,0x21,0xff,0x5e,0x33,0x26,0xff,0x64,0x3b,0x2e,0xff,0x70,0x4a,0x3e,0xff,0x9b,0x81,0x79,0xff,0xcb,0xbe,0xb9,0xff,0xe7,0xe2,0xe0,0xff,0xf7,0xf5,0xf4,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xee,0xea,0xe8,0xff,0xdb,0xd3,0xcf,0xff,0xbc,0xac,0xa6,0xff,0x8d,0x70,0x66,0xff,0x64,0x3b,0x2f,0xff,0x5f,0x34,0x27,0xff,0x5c,0x30,0x23,0xff,0x5b,0x2f,0x21,0xff,0x5c,0x30,0x22,0xff,0x5e,0x33,0x26,0xff,
0x69,0x41,0x35,0xff,0x8b,0x6b,0x61,0xff,0xad,0x97,0x90,0xff,0xce,0xc1,0xbc,0xff,0xea,0xe4,0xe3,0xff,0xf7,0xf4,0xf4,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0xec,0xeb,0xff,0xce,0xc2,0xbe,0xff,0xad,0x98,0x91,0xff,0x8e,0x71,0x67,0xff,0x75,0x51,0x44,0xff,
0x6a,0x42,0x35,0xff,0x64,0x3b,0x2e,0xff,0x62,0x39,0x2c,0xff,0x65,0x3d,0x2f,0xff,0x6b,0x44,0x38,0xff,0x76,0x52,0x47,0xff,0xa0,0x87,0x7f,0xff,0xcd,0xc1,0xbc,0xff,0xe9,0xe3,0xe1,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xee,0xeb,0xea,0xff,0xdc,0xd4,0xd2,0xff,0xbf,0xaf,0xab,0xff,0x92,0x76,0x6d,0xff,0x6b,0x44,0x38,0xff,0x66,0x3d,0x30,0xff,0x64,0x3a,0x2d,0xff,0x62,0x39,0x2c,0xff,0x63,0x39,0x2c,0xff,0x66,0x3d,0x30,0xff,0x70,0x4a,0x3e,0xff,0x90,0x72,0x69,0xff,0xb1,0x9c,0x95,0xff,0xd0,0xc4,0xbf,0xff,
0xeb,0xe6,0xe4,0xff,0xf7,0xf5,0xf4,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf3,0xef,0xee,0xff,0xd5,0xcb,0xc7,0xff,0xb9,0xa7,0xa1,0xff,0x9f,0x86,0x7e,0xff,0x89,0x6a,0x60,0xff,0x80,0x5e,0x53,0xff,0x7b,0x58,0x4c,0xff,0x79,0x56,0x4b,0xff,0x7c,0x59,0x4e,0xff,
0x81,0x60,0x55,0xff,0x8b,0x6b,0x62,0xff,0xae,0x98,0x92,0xff,0xd4,0xca,0xc6,0xff,0xec,0xe7,0xe6,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf1,0xee,0xec,0xff,0xe2,0xdb,0xd8,0xff,
0xc9,0xbb,0xb7,0xff,0xa2,0x8a,0x82,0xff,0x80,0x60,0x55,0xff,0x7d,0x5a,0x4f,0xff,0x7a,0x57,0x4c,0xff,0x79,0x56,0x4a,0xff,0x7a,0x56,0x4b,0xff,0x7c,0x59,0x4e,0xff,0x85,0x65,0x5a,0xff,0xa0,0x87,0x7f,0xff,0xbc,0xaa,0xa4,0xff,0xd7,0xcd,0xc9,0xff,0xee,0xea,0xe8,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf6,0xf2,0xf2,0xff,0xdf,0xd6,0xd4,0xff,0xc9,0xbb,0xb6,0xff,0xb5,0xa1,0x9b,0xff,0xa4,0x8c,0x84,0xff,0x9c,0x82,0x7a,0xff,0x99,0x7d,0x75,0xff,0x98,0x7c,0x73,0xff,0x99,0x7e,0x76,0xff,0x9e,0x83,0x7b,0xff,0xa5,0x8d,0x85,0xff,0xc0,0xb0,0xaa,0xff,0xde,0xd6,0xd3,0xff,
0xf0,0xec,0xeb,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf4,0xf2,0xf0,0xff,0xe9,0xe3,0xe1,0xff,0xd5,0xca,0xc7,0xff,0xb7,0xa5,0x9f,0xff,0x9d,0x84,0x7b,0xff,0x9a,0x80,0x76,0xff,
0x98,0x7d,0x74,0xff,0x97,0x7c,0x73,0xff,0x98,0x7c,0x73,0xff,0x9a,0x7f,0x76,0xff,0xa1,0x88,0x7f,0xff,0xb6,0xa2,0x9c,0xff,0xcb,0xbe,0xb9,0xff,0xe0,0xd8,0xd5,0xff,0xf1,0xee,0xed,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0xea,0xe4,0xe3,0xff,0xdc,0xd2,0xd0,0xff,0xcf,0xc2,0xbe,0xff,0xc4,0xb4,0xaf,0xff,0xbf,0xae,0xa9,0xff,0xbd,0xab,0xa6,0xff,0xbc,0xaa,0xa5,0xff,0xbd,0xac,0xa6,0xff,0xc0,0xae,0xaa,0xff,0xc5,0xb5,0xb0,0xff,0xd6,0xcb,0xc8,0xff,0xea,0xe5,0xe2,0xff,0xf5,0xf3,0xf2,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0xed,0xec,0xff,0xe3,0xdd,0xdb,0xff,0xd0,0xc4,0xc0,0xff,0xbf,0xaf,0xaa,0xff,0xbd,0xac,0xa7,0xff,0xbc,0xab,0xa5,0xff,0xbc,0xaa,0xa4,0xff,0xbc,0xaa,0xa5,0xff,0xbd,0xac,0xa6,0xff,
0xc2,0xb2,0xac,0xff,0xcf,0xc3,0xbf,0xff,0xdd,0xd5,0xd2,0xff,0xeb,0xe6,0xe4,0xff,0xf6,0xf4,0xf3,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf5,0xf2,0xf1,0xff,0xee,0xea,0xe8,0xff,0xe8,0xe2,0xe0,0xff,0xe3,0xdb,0xd9,0xff,
0xe1,0xd8,0xd6,0xff,0xdf,0xd7,0xd4,0xff,0xdf,0xd7,0xd4,0xff,0xe0,0xd7,0xd5,0xff,0xe1,0xd8,0xd6,0xff,0xe3,0xdb,0xd9,0xff,0xec,0xe6,0xe5,0xff,0xf5,0xf3,0xf2,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf2,0xef,0xee,0xff,0xe8,0xe3,0xe1,0xff,0xe0,0xd9,0xd6,0xff,0xe0,0xd7,0xd5,0xff,0xdf,0xd7,0xd4,0xff,0xdf,0xd6,0xd4,0xff,0xdf,0xd6,0xd4,0xff,0xe0,0xd8,0xd4,0xff,0xe2,0xdb,0xd7,0xff,0xe8,0xe2,0xe1,0xff,0xef,0xeb,0xea,0xff,0xf5,0xf3,0xf2,0xff,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
};
| 259.849462 | 320 | 0.797001 | ramkumarkoppu |
bae7af9f96ac323b1756038a83b28a645927897c | 12,260 | hpp | C++ | gtsam/gtsam/gpstk/PRSolution2.hpp | mfkiwl/RobustGNSS | f7774af62eb6eaf2198b5a7ca6f2a63dc87a4f7f | [
"MIT"
] | 105 | 2017-12-02T14:39:49.000Z | 2022-02-19T18:20:25.000Z | trunk/gtsam/gpstk/PRSolution2.hpp | shaolinbit/PPP-BayesTree | 6f469775277a1a33447bf4c19603c796c2c63c75 | [
"MIT"
] | 5 | 2018-09-04T15:15:59.000Z | 2020-09-08T08:51:02.000Z | trunk/gtsam/gpstk/PRSolution2.hpp | shaolinbit/PPP-BayesTree | 6f469775277a1a33447bf4c19603c796c2c63c75 | [
"MIT"
] | 31 | 2018-01-10T03:21:28.000Z | 2021-08-06T06:18:35.000Z | #pragma ident "$Id$"
/**
* @file PRSolution2.hpp
* Autonomous pseudorange navigation solution, including RAIM algorithm
*/
#ifndef PRS_POSITION_SOLUTION_NEW_HPP
#define PRS_POSITION_SOLUTION_NEW_HPP
//============================================================================
//
// This file is part of GPSTk, the GPS Toolkit.
//
// The GPSTk is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published
// by the Free Software Foundation; either version 2.1 of the License, or
// any later version.
//
// The GPSTk 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 GPSTk; if not, write to the Free Software Foundation,
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
//
// Copyright 2004, The University of Texas at Austin
//
//============================================================================
#include <vector>
#include <ostream>
#include "GNSSconstants.hpp"
#include "CommonTime.hpp"
#include "SatID.hpp"
#include "Matrix.hpp"
#include "RinexObsHeader.hpp"
#include "XvtStore.hpp"
#include "TropModel.hpp"
namespace gpstk
{
/** @defgroup GPSsolutions GPS solution algorithms and Tropospheric models */
//@{
/** This class defines an interface to routines which compute a position
* and time solution from pseudorange data, with a data editing algorithm
* based on Receiver Autonomous Integrity Monitoring (RAIM) concepts.
* RAIM ref. "A Baseline GPS RAIM Scheme and a Note on the Equivalence of
* Three RAIM Methods," by R. Grover Brown, Journal of the Institute of
* Navigation, Vol. 39, No. 3, Fall 1992, pg 301.
*/
class PRSolution2
{
public:
/// Constructor
PRSolution2() throw() :
RMSLimit(6.5), SlopeLimit(1000.), Algebraic(false),
ResidualCriterion(true), ReturnAtOnce(false), NSatsReject(-1),
Debug(false), pDebugStream(&std::cout), MaxNIterations(10),
ConvergenceLimit(3.e-7), Valid(false)
{};
/** Compute a position/time solution, given satellite PRNs and pseudoranges
* using a RAIM algorithm.
* @param Tr Measured time of reception of the data.
* @param Satellite std::vector<SatID> of satellites; on successful
* return, satellites that were excluded by the algorithm
* are marked by a negative 'prn' member.
* @param Pseudorange std::vector<double> of raw pseudoranges (parallel to
* Satellite), in meters.
* @param Eph gpstk::EphemerisStore to be used in the algorithm.
*
* @return Return values:
* 2 solution is found, but it is not good (RMS residual exceed limits)
* 1 solution is found, but it is suspect (slope is large)
* 0 ok
* -1 algorithm failed to converge
* -2 singular problem, no solution is possible
* -3 not enough good data (> 4) to form a (RAIM) solution
* (the 4 satellite solution might be returned - check isValid())
* -4 ephemeris is not found for one or more satellites
*/
int RAIMCompute(const CommonTime& Tr,
std::vector<SatID>& Satellite,
const std::vector<double>& Pseudorange,
const XvtStore<SatID>& Eph,
TropModel *pTropModel)
throw(Exception);
/// Return the status of solution
bool isValid()
const throw() { return Valid; }
// input:
/// RMS limit - either residual of fit or distance (see ResidualCriterion).
double RMSLimit;
/// Slope limit.
double SlopeLimit;
/// Use an algebraic (if true) or linearized least squares (if false) algorithm.
bool Algebraic;
/** Use a rejection criterion based on RMS residual of fit (true)
* or RMS distance from an a priori position. If false, member Vector Solution
* must be defined as this a priori position when RAIMCompute() is called.
*/
bool ResidualCriterion;
/** Return as soon as a solution meeting the limit requirements is found
* (this makes it a non-RAIM algorithm).
*/
bool ReturnAtOnce;
/** Maximum number of satellites that may be rejected in the RAIM algorithm;
* if this = -1, as many as possible will be rejected (RAIM requires at least 5
* satellites). A (single) non-RAIM solution can be obtained by setting this
* to 0 before calling RAIMCompute().
*/
int NSatsReject;
/// If true, RAIMCompute() will output solution information to *pDebugStream.
bool Debug;
/// Pointer to an ostream, default &std::cout; if Debug is true, RAIMCompute()
/// will print all preliminary solutions to this stream.
std::ostream *pDebugStream;
// TD optional: measurement covariance matrix
/// Maximum number of iterations allowed in the linearized least squares
/// algorithm.
int MaxNIterations;
/// Convergence limit (m): continue iteration loop while RSS change in
/// solution exceeds this.
double ConvergenceLimit;
// output:
/// flag: output content is valid.
bool Valid;
/** Vector<double> containing the computed position solution (ECEF, meter);
* valid only when isValid() is true.
*/
Vector<double> Solution;
/** 4x4 Matrix<double> containing the computed solution covariance (meter);
* valid only when isValid() is true.
*/
Matrix<double> Covariance;
/** Root mean square residual of fit (except when RMSDistanceFlag is set,
* then RMS distance from apriori 4-position); in meters.
*/
double RMSResidual;
/** Slope computed in the RAIM algorithm (largest of all satellite values)
* for the returned solution, dimensionless ??.
*/
double MaxSlope;
/// the actual number of iterations used (linearized least squares algorithm)
int NIterations;
/// the RSS change in solution at the end of iterations.
double Convergence;
/// the number of good satellites used in the final computation
int Nsvs;
/** Compute the satellite position / corrected range matrix (SVP) which is used
* by AutonomousPRSolution(). SVP is output, dimensioned (N,4) where N is the
* number of satellites and the length of both Satellite and Pseudorange.
* Data is ignored whenever Sats[i].id is < 0. NB caller should verify that the
* number of good entries (Satellite[.] > 0) is > 4 before proceeding.
* @param Tr Measured time of reception of the data.
* @param Sats std::vector<SatID> of satellites; satellites that are
* to be excluded by the algorithm are marked by a
* negative 'prn' member.
* @param Pseudorange std::vector<double> of raw pseudoranges (parallel to
* Satellite), in meters
* @param Eph gpstk::XvtStore<SatID> to be used in the algorithm.
* @param SVP gpstk::Matrix<double> of dimension (N,4), N is the number
* of unmarked satellites in Sats[], on output this
* contains the satellite positions at transmit time, and
* the corrected pseudorange.
* @param pDebug pointer to an ostream for debug output, NULL (the default)
* for no debug output.
* @return Return values:
* 0 ok
* -4 ephemeris not found for all the satellites
*/
static int PrepareAutonomousSolution(const CommonTime& Tr,
std::vector<SatID>& Sats,
const std::vector<double>& Pseudorange,
const XvtStore<SatID>& Eph,
Matrix<double>& SVP,
std::ostream *pDebug=NULL)
throw();
/** Compute a single autonomous pseudorange solution.
* Input only:
* @param Tr Measured time of reception of the data.
* @param Use std::vector<bool> of length N, the number of satellites;
* false means do not include that sat. in the computation.
* @param SVP Matrix<double> of dimension (N,4). This Matrix must have
* been computed by calling PrepareAutonomousPRSolution().
* @param Algebraic bool flag indicating algorithm to use : algebraic (true)
* or linearized least squares (false).
* @param pTropModel pointer to a gpstk::TropModel for use within the algorithm
*
* Weight matrix TD...
*
* Input and output (for least squares only; ignored if Algebraic==true):
* @param n_iterate integer limit on the number of iterations. On output,
* it is the number of iterations actually used.
* @param converge double convergence criterion, = RSS change in solution,
* in meters. On output, it is the the final value.
*
* Output: (these will be resized within the function)
* @param Sol gpstk::Vector<double> solution (ECEF + time components;
* all in meters)
* @param Cov gpstk::Matrix<double> 4X4 covariance matrix (meter*meter)
* @param Resid gpstk::Vector<double> post-fit range residuals for each
* satellite (m), the length of this Vector is the number of
* satellites actually used (see Use).
* @param Slope gpstk::Vector<double> slope value used in RAIM for each
* good satellite, length N
* @param pDebug pointer to an ostream for debug output, NULL (the default)
* for no debug output.
* @return Return values:
* 0 ok
* -1 failed to converge
* -2 singular problem
* -3 not enough good data to form a solution (at least 4 satellites required)
* -4 ephemeris not found for one or more satellites
*/
static int AutonomousPRSolution(const CommonTime& Tr,
const std::vector<bool>& Use,
const Matrix<double> SVP,
TropModel *pTropModel,
const bool Algebraic,
int& n_iterate,
double& converge,
Vector<double>& Sol,
Matrix<double>& Cov,
Vector<double>& Resid,
Vector<double>& Slope,
std::ostream *pDebug=NULL,
Vector<int>* satSystems=NULL)
throw(Exception);
private:
/** Matrix, dimensioned Nx4, where N data are input, containing satellite
* positions at transmit time (0,1,2) and raw pseudorange+clk+relativity (3).
*/
Matrix<double> SVP;
/// Save the input solution (for use in rejection when ResidualCriterion is
/// false).
Vector<double> APrioriSolution;
/** Function used internally to handle the details of the Algebraic solution */
static int AlgebraicSolution(Matrix<double>& A,
Vector<double>& Q,
Vector<double>& X,
Vector<double>& R);
}; // end class PRSolution2
//@}
} // namespace gpstk
#endif
| 43.321555 | 86 | 0.580261 | mfkiwl |
bae8894cb56f6176b4e986035fc0576c6c344218 | 17,458 | cc | C++ | src/i18n_data/locale/lzh_TW.cc | rqb500/fast_io | 672d28065b74eda3969eb2218ff18b3ca89dbca4 | [
"MIT"
] | 157 | 2021-07-12T07:19:15.000Z | 2022-02-16T02:22:45.000Z | src/i18n_data/locale/lzh_TW.cc | rqb500/fast_io | 672d28065b74eda3969eb2218ff18b3ca89dbca4 | [
"MIT"
] | 7 | 2021-08-02T05:06:23.000Z | 2021-12-26T10:32:18.000Z | src/i18n_data/locale/lzh_TW.cc | rqb500/fast_io | 672d28065b74eda3969eb2218ff18b3ca89dbca4 | [
"MIT"
] | 15 | 2021-07-17T19:58:14.000Z | 2021-12-30T15:37:32.000Z | #include"../localedef.h"
namespace fast_io_i18n
{
namespace
{
inline constexpr std::size_t numeric_grouping_storage[]{4};
inline constexpr basic_lc_time_era<char> time_era_storage[]{{.direction=true,.offset=2,.start_date_year=1913,.start_date_month=1,.start_date_day=1,.end_date_special=1,.era_name=tsc("民國"),.era_format=tsc("%EC%Ey年")},{.direction=true,.offset=1,.start_date_year=1912,.start_date_month=1,.start_date_day=1,.end_date_year=1912,.end_date_month=12,.end_date_day=31,.era_name=tsc("民國"),.era_format=tsc("%EC元年")},{.direction=true,.offset=1,.start_date_year=1911,.start_date_month=12,.start_date_day=31,.end_date_special=-1,.era_name=tsc("民前"),.era_format=tsc("%EC%Ey年")}};
inline constexpr basic_io_scatter_t<char> time_alt_digits_storage[]{tsc("〇"),tsc("一"),tsc("二"),tsc("三"),tsc("四"),tsc("五"),tsc("六"),tsc("七"),tsc("八"),tsc("九"),tsc("十"),tsc("十一"),tsc("十二"),tsc("十三"),tsc("十四"),tsc("十五"),tsc("十六"),tsc("十七"),tsc("十八"),tsc("十九"),tsc("廿"),tsc("廿一"),tsc("廿二"),tsc("廿三"),tsc("廿四"),tsc("廿五"),tsc("廿六"),tsc("廿七"),tsc("廿八"),tsc("廿九"),tsc("卅"),tsc("卅一")};
inline constexpr lc_all lc_all_global{.identification={.title=tsc("Literary Chinese locale for the Republic of China"),.source=tsc("fast_io"),.address=tsc("https://gitee.com/qabeowjbtkwb/fast_io"),.contact=tsc("fast_io"),.email=tsc("bug-glibc-locales@gnu.org;euloanty@live.com"),.tel=tsc(""),.fax=tsc(""),.language=tsc("Literary Chinese"),.territory=tsc("Taiwan"),.revision=tsc("0.1"),.date=tsc("2013-06-02")},.monetary={.int_curr_symbol=tsc("TWD "),.currency_symbol=tsc("NT$"),.mon_decimal_point=tsc("."),.mon_thousands_sep=tsc(","),.mon_grouping={numeric_grouping_storage,1},.positive_sign=tsc(""),.negative_sign=tsc("-"),.int_frac_digits=2,.frac_digits=2,.p_cs_precedes=1,.p_sep_by_space=0,.n_cs_precedes=1,.n_sep_by_space=0,.int_p_cs_precedes=1,.int_p_sep_by_space=0,.int_n_cs_precedes=1,.int_n_sep_by_space=0,.p_sign_posn=1,.n_sign_posn=1,.int_p_sign_posn=1,.int_n_sign_posn=1},.numeric={.decimal_point=tsc("."),.thousands_sep=tsc(","),.grouping={numeric_grouping_storage,1}},.time={.abday={tsc("日"),tsc("一"),tsc("二"),tsc("三"),tsc("四"),tsc("五"),tsc("六")},.day={tsc("週日"),tsc("週一"),tsc("週二"),tsc("週三"),tsc("週四"),tsc("週五"),tsc("週六")},.abmon={tsc(" 一 "),tsc(" 二 "),tsc(" 三 "),tsc(" 四 "),tsc(" 五 "),tsc(" 六 "),tsc(" 七 "),tsc(" 八 "),tsc(" 九 "),tsc(" 十 "),tsc("十一"),tsc("十二")},.mon={tsc("一月"),tsc("二月"),tsc("三月"),tsc("四月"),tsc("五月"),tsc("六月"),tsc("七月"),tsc("八月"),tsc("九月"),tsc("十月"),tsc("十一月"),tsc("十二月")},.d_t_fmt=tsc("%OC%Oy年%B%Od日 (%A) %OH時%OM分%OS秒"),.d_fmt=tsc("%OC%Oy年%B%Od日"),.t_fmt=tsc("%OH時%OM分%OS秒"),.t_fmt_ampm=tsc("%p %OI時%OM分%OS秒"),.date_fmt=tsc("公曆 %C%Oy年 %B %Oe日 %A %OH時%OM分%OS秒"),.am_pm={tsc("朝"),tsc("暮")},.era={time_era_storage,3},.alt_digits={time_alt_digits_storage,32},.week={7,19971130,1}},.messages={.yesexpr=tsc("^[+1yYyY是]"),.noexpr=tsc("^[-0nNnN非]")},.paper={.width=210,.height=297},.telephone={.tel_int_fmt=tsc("+%c-%a-%l"),.tel_dom_fmt=tsc("%A-%l"),.int_select=tsc("00"),.int_prefix=tsc("886")},.name={.name_fmt=tsc("%f%d%t%g"),.name_gen=tsc("君"),.name_miss=tsc("女"),.name_mr=tsc("子"),.name_mrs=tsc("氏"),.name_ms=tsc("娘")},.address={.postal_fmt=tsc("%c%N%T%N%s %h %e %r%N%b%N%d%N%f%N%a%N"),.country_name=tsc("中華民國"),.country_post=tsc("TW"),.country_ab2=tsc("TW"),.country_ab3=tsc("TWN"),.country_num=158,.country_car=tsc("RC"),.country_isbn=tsc("957"),.lang_name=tsc("漢語文言"),.lang_term=tsc("lzh"),.lang_lib=tsc("lzh")},.measurement={.measurement=1}};
inline constexpr basic_lc_time_era<wchar_t> wtime_era_storage[]{{.direction=true,.offset=2,.start_date_year=1913,.start_date_month=1,.start_date_day=1,.end_date_special=1,.era_name=tsc(L"民國"),.era_format=tsc(L"%EC%Ey年")},{.direction=true,.offset=1,.start_date_year=1912,.start_date_month=1,.start_date_day=1,.end_date_year=1912,.end_date_month=12,.end_date_day=31,.era_name=tsc(L"民國"),.era_format=tsc(L"%EC元年")},{.direction=true,.offset=1,.start_date_year=1911,.start_date_month=12,.start_date_day=31,.end_date_special=-1,.era_name=tsc(L"民前"),.era_format=tsc(L"%EC%Ey年")}};
inline constexpr basic_io_scatter_t<wchar_t> wtime_alt_digits_storage[]{tsc(L"〇"),tsc(L"一"),tsc(L"二"),tsc(L"三"),tsc(L"四"),tsc(L"五"),tsc(L"六"),tsc(L"七"),tsc(L"八"),tsc(L"九"),tsc(L"十"),tsc(L"十一"),tsc(L"十二"),tsc(L"十三"),tsc(L"十四"),tsc(L"十五"),tsc(L"十六"),tsc(L"十七"),tsc(L"十八"),tsc(L"十九"),tsc(L"廿"),tsc(L"廿一"),tsc(L"廿二"),tsc(L"廿三"),tsc(L"廿四"),tsc(L"廿五"),tsc(L"廿六"),tsc(L"廿七"),tsc(L"廿八"),tsc(L"廿九"),tsc(L"卅"),tsc(L"卅一")};
inline constexpr wlc_all wlc_all_global{.identification={.title=tsc(L"Literary Chinese locale for the Republic of China"),.source=tsc(L"fast_io"),.address=tsc(L"https://gitee.com/qabeowjbtkwb/fast_io"),.contact=tsc(L"fast_io"),.email=tsc(L"bug-glibc-locales@gnu.org;euloanty@live.com"),.tel=tsc(L""),.fax=tsc(L""),.language=tsc(L"Literary Chinese"),.territory=tsc(L"Taiwan"),.revision=tsc(L"0.1"),.date=tsc(L"2013-06-02")},.monetary={.int_curr_symbol=tsc(L"TWD "),.currency_symbol=tsc(L"NT$"),.mon_decimal_point=tsc(L"."),.mon_thousands_sep=tsc(L","),.mon_grouping={numeric_grouping_storage,1},.positive_sign=tsc(L""),.negative_sign=tsc(L"-"),.int_frac_digits=2,.frac_digits=2,.p_cs_precedes=1,.p_sep_by_space=0,.n_cs_precedes=1,.n_sep_by_space=0,.int_p_cs_precedes=1,.int_p_sep_by_space=0,.int_n_cs_precedes=1,.int_n_sep_by_space=0,.p_sign_posn=1,.n_sign_posn=1,.int_p_sign_posn=1,.int_n_sign_posn=1},.numeric={.decimal_point=tsc(L"."),.thousands_sep=tsc(L","),.grouping={numeric_grouping_storage,1}},.time={.abday={tsc(L"日"),tsc(L"一"),tsc(L"二"),tsc(L"三"),tsc(L"四"),tsc(L"五"),tsc(L"六")},.day={tsc(L"週日"),tsc(L"週一"),tsc(L"週二"),tsc(L"週三"),tsc(L"週四"),tsc(L"週五"),tsc(L"週六")},.abmon={tsc(L" 一 "),tsc(L" 二 "),tsc(L" 三 "),tsc(L" 四 "),tsc(L" 五 "),tsc(L" 六 "),tsc(L" 七 "),tsc(L" 八 "),tsc(L" 九 "),tsc(L" 十 "),tsc(L"十一"),tsc(L"十二")},.mon={tsc(L"一月"),tsc(L"二月"),tsc(L"三月"),tsc(L"四月"),tsc(L"五月"),tsc(L"六月"),tsc(L"七月"),tsc(L"八月"),tsc(L"九月"),tsc(L"十月"),tsc(L"十一月"),tsc(L"十二月")},.d_t_fmt=tsc(L"%OC%Oy年%B%Od日 (%A) %OH時%OM分%OS秒"),.d_fmt=tsc(L"%OC%Oy年%B%Od日"),.t_fmt=tsc(L"%OH時%OM分%OS秒"),.t_fmt_ampm=tsc(L"%p %OI時%OM分%OS秒"),.date_fmt=tsc(L"公曆 %C%Oy年 %B %Oe日 %A %OH時%OM分%OS秒"),.am_pm={tsc(L"朝"),tsc(L"暮")},.era={wtime_era_storage,3},.alt_digits={wtime_alt_digits_storage,32},.week={7,19971130,1}},.messages={.yesexpr=tsc(L"^[+1yYyY是]"),.noexpr=tsc(L"^[-0nNnN非]")},.paper={.width=210,.height=297},.telephone={.tel_int_fmt=tsc(L"+%c-%a-%l"),.tel_dom_fmt=tsc(L"%A-%l"),.int_select=tsc(L"00"),.int_prefix=tsc(L"886")},.name={.name_fmt=tsc(L"%f%d%t%g"),.name_gen=tsc(L"君"),.name_miss=tsc(L"女"),.name_mr=tsc(L"子"),.name_mrs=tsc(L"氏"),.name_ms=tsc(L"娘")},.address={.postal_fmt=tsc(L"%c%N%T%N%s %h %e %r%N%b%N%d%N%f%N%a%N"),.country_name=tsc(L"中華民國"),.country_post=tsc(L"TW"),.country_ab2=tsc(L"TW"),.country_ab3=tsc(L"TWN"),.country_num=158,.country_car=tsc(L"RC"),.country_isbn=tsc(L"957"),.lang_name=tsc(L"漢語文言"),.lang_term=tsc(L"lzh"),.lang_lib=tsc(L"lzh")},.measurement={.measurement=1}};
inline constexpr basic_lc_time_era<char8_t> u8time_era_storage[]{{.direction=true,.offset=2,.start_date_year=1913,.start_date_month=1,.start_date_day=1,.end_date_special=1,.era_name=tsc(u8"民國"),.era_format=tsc(u8"%EC%Ey年")},{.direction=true,.offset=1,.start_date_year=1912,.start_date_month=1,.start_date_day=1,.end_date_year=1912,.end_date_month=12,.end_date_day=31,.era_name=tsc(u8"民國"),.era_format=tsc(u8"%EC元年")},{.direction=true,.offset=1,.start_date_year=1911,.start_date_month=12,.start_date_day=31,.end_date_special=-1,.era_name=tsc(u8"民前"),.era_format=tsc(u8"%EC%Ey年")}};
inline constexpr basic_io_scatter_t<char8_t> u8time_alt_digits_storage[]{tsc(u8"〇"),tsc(u8"一"),tsc(u8"二"),tsc(u8"三"),tsc(u8"四"),tsc(u8"五"),tsc(u8"六"),tsc(u8"七"),tsc(u8"八"),tsc(u8"九"),tsc(u8"十"),tsc(u8"十一"),tsc(u8"十二"),tsc(u8"十三"),tsc(u8"十四"),tsc(u8"十五"),tsc(u8"十六"),tsc(u8"十七"),tsc(u8"十八"),tsc(u8"十九"),tsc(u8"廿"),tsc(u8"廿一"),tsc(u8"廿二"),tsc(u8"廿三"),tsc(u8"廿四"),tsc(u8"廿五"),tsc(u8"廿六"),tsc(u8"廿七"),tsc(u8"廿八"),tsc(u8"廿九"),tsc(u8"卅"),tsc(u8"卅一")};
inline constexpr u8lc_all u8lc_all_global{.identification={.title=tsc(u8"Literary Chinese locale for the Republic of China"),.source=tsc(u8"fast_io"),.address=tsc(u8"https://gitee.com/qabeowjbtkwb/fast_io"),.contact=tsc(u8"fast_io"),.email=tsc(u8"bug-glibc-locales@gnu.org;euloanty@live.com"),.tel=tsc(u8""),.fax=tsc(u8""),.language=tsc(u8"Literary Chinese"),.territory=tsc(u8"Taiwan"),.revision=tsc(u8"0.1"),.date=tsc(u8"2013-06-02")},.monetary={.int_curr_symbol=tsc(u8"TWD "),.currency_symbol=tsc(u8"NT$"),.mon_decimal_point=tsc(u8"."),.mon_thousands_sep=tsc(u8","),.mon_grouping={numeric_grouping_storage,1},.positive_sign=tsc(u8""),.negative_sign=tsc(u8"-"),.int_frac_digits=2,.frac_digits=2,.p_cs_precedes=1,.p_sep_by_space=0,.n_cs_precedes=1,.n_sep_by_space=0,.int_p_cs_precedes=1,.int_p_sep_by_space=0,.int_n_cs_precedes=1,.int_n_sep_by_space=0,.p_sign_posn=1,.n_sign_posn=1,.int_p_sign_posn=1,.int_n_sign_posn=1},.numeric={.decimal_point=tsc(u8"."),.thousands_sep=tsc(u8","),.grouping={numeric_grouping_storage,1}},.time={.abday={tsc(u8"日"),tsc(u8"一"),tsc(u8"二"),tsc(u8"三"),tsc(u8"四"),tsc(u8"五"),tsc(u8"六")},.day={tsc(u8"週日"),tsc(u8"週一"),tsc(u8"週二"),tsc(u8"週三"),tsc(u8"週四"),tsc(u8"週五"),tsc(u8"週六")},.abmon={tsc(u8" 一 "),tsc(u8" 二 "),tsc(u8" 三 "),tsc(u8" 四 "),tsc(u8" 五 "),tsc(u8" 六 "),tsc(u8" 七 "),tsc(u8" 八 "),tsc(u8" 九 "),tsc(u8" 十 "),tsc(u8"十一"),tsc(u8"十二")},.mon={tsc(u8"一月"),tsc(u8"二月"),tsc(u8"三月"),tsc(u8"四月"),tsc(u8"五月"),tsc(u8"六月"),tsc(u8"七月"),tsc(u8"八月"),tsc(u8"九月"),tsc(u8"十月"),tsc(u8"十一月"),tsc(u8"十二月")},.d_t_fmt=tsc(u8"%OC%Oy年%B%Od日 (%A) %OH時%OM分%OS秒"),.d_fmt=tsc(u8"%OC%Oy年%B%Od日"),.t_fmt=tsc(u8"%OH時%OM分%OS秒"),.t_fmt_ampm=tsc(u8"%p %OI時%OM分%OS秒"),.date_fmt=tsc(u8"公曆 %C%Oy年 %B %Oe日 %A %OH時%OM分%OS秒"),.am_pm={tsc(u8"朝"),tsc(u8"暮")},.era={u8time_era_storage,3},.alt_digits={u8time_alt_digits_storage,32},.week={7,19971130,1}},.messages={.yesexpr=tsc(u8"^[+1yYyY是]"),.noexpr=tsc(u8"^[-0nNnN非]")},.paper={.width=210,.height=297},.telephone={.tel_int_fmt=tsc(u8"+%c-%a-%l"),.tel_dom_fmt=tsc(u8"%A-%l"),.int_select=tsc(u8"00"),.int_prefix=tsc(u8"886")},.name={.name_fmt=tsc(u8"%f%d%t%g"),.name_gen=tsc(u8"君"),.name_miss=tsc(u8"女"),.name_mr=tsc(u8"子"),.name_mrs=tsc(u8"氏"),.name_ms=tsc(u8"娘")},.address={.postal_fmt=tsc(u8"%c%N%T%N%s %h %e %r%N%b%N%d%N%f%N%a%N"),.country_name=tsc(u8"中華民國"),.country_post=tsc(u8"TW"),.country_ab2=tsc(u8"TW"),.country_ab3=tsc(u8"TWN"),.country_num=158,.country_car=tsc(u8"RC"),.country_isbn=tsc(u8"957"),.lang_name=tsc(u8"漢語文言"),.lang_term=tsc(u8"lzh"),.lang_lib=tsc(u8"lzh")},.measurement={.measurement=1}};
inline constexpr basic_lc_time_era<char16_t> u16time_era_storage[]{{.direction=true,.offset=2,.start_date_year=1913,.start_date_month=1,.start_date_day=1,.end_date_special=1,.era_name=tsc(u"民國"),.era_format=tsc(u"%EC%Ey年")},{.direction=true,.offset=1,.start_date_year=1912,.start_date_month=1,.start_date_day=1,.end_date_year=1912,.end_date_month=12,.end_date_day=31,.era_name=tsc(u"民國"),.era_format=tsc(u"%EC元年")},{.direction=true,.offset=1,.start_date_year=1911,.start_date_month=12,.start_date_day=31,.end_date_special=-1,.era_name=tsc(u"民前"),.era_format=tsc(u"%EC%Ey年")}};
inline constexpr basic_io_scatter_t<char16_t> u16time_alt_digits_storage[]{tsc(u"〇"),tsc(u"一"),tsc(u"二"),tsc(u"三"),tsc(u"四"),tsc(u"五"),tsc(u"六"),tsc(u"七"),tsc(u"八"),tsc(u"九"),tsc(u"十"),tsc(u"十一"),tsc(u"十二"),tsc(u"十三"),tsc(u"十四"),tsc(u"十五"),tsc(u"十六"),tsc(u"十七"),tsc(u"十八"),tsc(u"十九"),tsc(u"廿"),tsc(u"廿一"),tsc(u"廿二"),tsc(u"廿三"),tsc(u"廿四"),tsc(u"廿五"),tsc(u"廿六"),tsc(u"廿七"),tsc(u"廿八"),tsc(u"廿九"),tsc(u"卅"),tsc(u"卅一")};
inline constexpr u16lc_all u16lc_all_global{.identification={.title=tsc(u"Literary Chinese locale for the Republic of China"),.source=tsc(u"fast_io"),.address=tsc(u"https://gitee.com/qabeowjbtkwb/fast_io"),.contact=tsc(u"fast_io"),.email=tsc(u"bug-glibc-locales@gnu.org;euloanty@live.com"),.tel=tsc(u""),.fax=tsc(u""),.language=tsc(u"Literary Chinese"),.territory=tsc(u"Taiwan"),.revision=tsc(u"0.1"),.date=tsc(u"2013-06-02")},.monetary={.int_curr_symbol=tsc(u"TWD "),.currency_symbol=tsc(u"NT$"),.mon_decimal_point=tsc(u"."),.mon_thousands_sep=tsc(u","),.mon_grouping={numeric_grouping_storage,1},.positive_sign=tsc(u""),.negative_sign=tsc(u"-"),.int_frac_digits=2,.frac_digits=2,.p_cs_precedes=1,.p_sep_by_space=0,.n_cs_precedes=1,.n_sep_by_space=0,.int_p_cs_precedes=1,.int_p_sep_by_space=0,.int_n_cs_precedes=1,.int_n_sep_by_space=0,.p_sign_posn=1,.n_sign_posn=1,.int_p_sign_posn=1,.int_n_sign_posn=1},.numeric={.decimal_point=tsc(u"."),.thousands_sep=tsc(u","),.grouping={numeric_grouping_storage,1}},.time={.abday={tsc(u"日"),tsc(u"一"),tsc(u"二"),tsc(u"三"),tsc(u"四"),tsc(u"五"),tsc(u"六")},.day={tsc(u"週日"),tsc(u"週一"),tsc(u"週二"),tsc(u"週三"),tsc(u"週四"),tsc(u"週五"),tsc(u"週六")},.abmon={tsc(u" 一 "),tsc(u" 二 "),tsc(u" 三 "),tsc(u" 四 "),tsc(u" 五 "),tsc(u" 六 "),tsc(u" 七 "),tsc(u" 八 "),tsc(u" 九 "),tsc(u" 十 "),tsc(u"十一"),tsc(u"十二")},.mon={tsc(u"一月"),tsc(u"二月"),tsc(u"三月"),tsc(u"四月"),tsc(u"五月"),tsc(u"六月"),tsc(u"七月"),tsc(u"八月"),tsc(u"九月"),tsc(u"十月"),tsc(u"十一月"),tsc(u"十二月")},.d_t_fmt=tsc(u"%OC%Oy年%B%Od日 (%A) %OH時%OM分%OS秒"),.d_fmt=tsc(u"%OC%Oy年%B%Od日"),.t_fmt=tsc(u"%OH時%OM分%OS秒"),.t_fmt_ampm=tsc(u"%p %OI時%OM分%OS秒"),.date_fmt=tsc(u"公曆 %C%Oy年 %B %Oe日 %A %OH時%OM分%OS秒"),.am_pm={tsc(u"朝"),tsc(u"暮")},.era={u16time_era_storage,3},.alt_digits={u16time_alt_digits_storage,32},.week={7,19971130,1}},.messages={.yesexpr=tsc(u"^[+1yYyY是]"),.noexpr=tsc(u"^[-0nNnN非]")},.paper={.width=210,.height=297},.telephone={.tel_int_fmt=tsc(u"+%c-%a-%l"),.tel_dom_fmt=tsc(u"%A-%l"),.int_select=tsc(u"00"),.int_prefix=tsc(u"886")},.name={.name_fmt=tsc(u"%f%d%t%g"),.name_gen=tsc(u"君"),.name_miss=tsc(u"女"),.name_mr=tsc(u"子"),.name_mrs=tsc(u"氏"),.name_ms=tsc(u"娘")},.address={.postal_fmt=tsc(u"%c%N%T%N%s %h %e %r%N%b%N%d%N%f%N%a%N"),.country_name=tsc(u"中華民國"),.country_post=tsc(u"TW"),.country_ab2=tsc(u"TW"),.country_ab3=tsc(u"TWN"),.country_num=158,.country_car=tsc(u"RC"),.country_isbn=tsc(u"957"),.lang_name=tsc(u"漢語文言"),.lang_term=tsc(u"lzh"),.lang_lib=tsc(u"lzh")},.measurement={.measurement=1}};
inline constexpr basic_lc_time_era<char32_t> u32time_era_storage[]{{.direction=true,.offset=2,.start_date_year=1913,.start_date_month=1,.start_date_day=1,.end_date_special=1,.era_name=tsc(U"民國"),.era_format=tsc(U"%EC%Ey年")},{.direction=true,.offset=1,.start_date_year=1912,.start_date_month=1,.start_date_day=1,.end_date_year=1912,.end_date_month=12,.end_date_day=31,.era_name=tsc(U"民國"),.era_format=tsc(U"%EC元年")},{.direction=true,.offset=1,.start_date_year=1911,.start_date_month=12,.start_date_day=31,.end_date_special=-1,.era_name=tsc(U"民前"),.era_format=tsc(U"%EC%Ey年")}};
inline constexpr basic_io_scatter_t<char32_t> u32time_alt_digits_storage[]{tsc(U"〇"),tsc(U"一"),tsc(U"二"),tsc(U"三"),tsc(U"四"),tsc(U"五"),tsc(U"六"),tsc(U"七"),tsc(U"八"),tsc(U"九"),tsc(U"十"),tsc(U"十一"),tsc(U"十二"),tsc(U"十三"),tsc(U"十四"),tsc(U"十五"),tsc(U"十六"),tsc(U"十七"),tsc(U"十八"),tsc(U"十九"),tsc(U"廿"),tsc(U"廿一"),tsc(U"廿二"),tsc(U"廿三"),tsc(U"廿四"),tsc(U"廿五"),tsc(U"廿六"),tsc(U"廿七"),tsc(U"廿八"),tsc(U"廿九"),tsc(U"卅"),tsc(U"卅一")};
inline constexpr u32lc_all u32lc_all_global{.identification={.title=tsc(U"Literary Chinese locale for the Republic of China"),.source=tsc(U"fast_io"),.address=tsc(U"https://gitee.com/qabeowjbtkwb/fast_io"),.contact=tsc(U"fast_io"),.email=tsc(U"bug-glibc-locales@gnu.org;euloanty@live.com"),.tel=tsc(U""),.fax=tsc(U""),.language=tsc(U"Literary Chinese"),.territory=tsc(U"Taiwan"),.revision=tsc(U"0.1"),.date=tsc(U"2013-06-02")},.monetary={.int_curr_symbol=tsc(U"TWD "),.currency_symbol=tsc(U"NT$"),.mon_decimal_point=tsc(U"."),.mon_thousands_sep=tsc(U","),.mon_grouping={numeric_grouping_storage,1},.positive_sign=tsc(U""),.negative_sign=tsc(U"-"),.int_frac_digits=2,.frac_digits=2,.p_cs_precedes=1,.p_sep_by_space=0,.n_cs_precedes=1,.n_sep_by_space=0,.int_p_cs_precedes=1,.int_p_sep_by_space=0,.int_n_cs_precedes=1,.int_n_sep_by_space=0,.p_sign_posn=1,.n_sign_posn=1,.int_p_sign_posn=1,.int_n_sign_posn=1},.numeric={.decimal_point=tsc(U"."),.thousands_sep=tsc(U","),.grouping={numeric_grouping_storage,1}},.time={.abday={tsc(U"日"),tsc(U"一"),tsc(U"二"),tsc(U"三"),tsc(U"四"),tsc(U"五"),tsc(U"六")},.day={tsc(U"週日"),tsc(U"週一"),tsc(U"週二"),tsc(U"週三"),tsc(U"週四"),tsc(U"週五"),tsc(U"週六")},.abmon={tsc(U" 一 "),tsc(U" 二 "),tsc(U" 三 "),tsc(U" 四 "),tsc(U" 五 "),tsc(U" 六 "),tsc(U" 七 "),tsc(U" 八 "),tsc(U" 九 "),tsc(U" 十 "),tsc(U"十一"),tsc(U"十二")},.mon={tsc(U"一月"),tsc(U"二月"),tsc(U"三月"),tsc(U"四月"),tsc(U"五月"),tsc(U"六月"),tsc(U"七月"),tsc(U"八月"),tsc(U"九月"),tsc(U"十月"),tsc(U"十一月"),tsc(U"十二月")},.d_t_fmt=tsc(U"%OC%Oy年%B%Od日 (%A) %OH時%OM分%OS秒"),.d_fmt=tsc(U"%OC%Oy年%B%Od日"),.t_fmt=tsc(U"%OH時%OM分%OS秒"),.t_fmt_ampm=tsc(U"%p %OI時%OM分%OS秒"),.date_fmt=tsc(U"公曆 %C%Oy年 %B %Oe日 %A %OH時%OM分%OS秒"),.am_pm={tsc(U"朝"),tsc(U"暮")},.era={u32time_era_storage,3},.alt_digits={u32time_alt_digits_storage,32},.week={7,19971130,1}},.messages={.yesexpr=tsc(U"^[+1yYyY是]"),.noexpr=tsc(U"^[-0nNnN非]")},.paper={.width=210,.height=297},.telephone={.tel_int_fmt=tsc(U"+%c-%a-%l"),.tel_dom_fmt=tsc(U"%A-%l"),.int_select=tsc(U"00"),.int_prefix=tsc(U"886")},.name={.name_fmt=tsc(U"%f%d%t%g"),.name_gen=tsc(U"君"),.name_miss=tsc(U"女"),.name_mr=tsc(U"子"),.name_mrs=tsc(U"氏"),.name_ms=tsc(U"娘")},.address={.postal_fmt=tsc(U"%c%N%T%N%s %h %e %r%N%b%N%d%N%f%N%a%N"),.country_name=tsc(U"中華民國"),.country_post=tsc(U"TW"),.country_ab2=tsc(U"TW"),.country_ab3=tsc(U"TWN"),.country_num=158,.country_car=tsc(U"RC"),.country_isbn=tsc(U"957"),.lang_name=tsc(U"漢語文言"),.lang_term=tsc(U"lzh"),.lang_lib=tsc(U"lzh")},.measurement={.measurement=1}};
}
}
#include"../main.h" | 396.772727 | 2,556 | 0.682782 | rqb500 |
baea97d88e0f1d4897bb6ab6d6bb965c3baa0b7e | 14,457 | cpp | C++ | Lib/LLVMJIT/EmitFunction.cpp | PiotrSikora/WAVM | da97d6bcf421ac5d8b40ccccc8d36d4ba01a0356 | [
"BSD-3-Clause"
] | null | null | null | Lib/LLVMJIT/EmitFunction.cpp | PiotrSikora/WAVM | da97d6bcf421ac5d8b40ccccc8d36d4ba01a0356 | [
"BSD-3-Clause"
] | null | null | null | Lib/LLVMJIT/EmitFunction.cpp | PiotrSikora/WAVM | da97d6bcf421ac5d8b40ccccc8d36d4ba01a0356 | [
"BSD-3-Clause"
] | null | null | null | #include <stdint.h>
#include <initializer_list>
#include <memory>
#include <string>
#include <vector>
#include "EmitFunctionContext.h"
#include "EmitModuleContext.h"
#include "LLVMJITPrivate.h"
#include "WAVM/IR/Module.h"
#include "WAVM/IR/OperatorPrinter.h"
#include "WAVM/IR/Operators.h"
#include "WAVM/IR/Types.h"
#include "WAVM/Inline/Assert.h"
#include "WAVM/Inline/BasicTypes.h"
#include "WAVM/Inline/Errors.h"
#include "WAVM/Logging/Logging.h"
PUSH_DISABLE_WARNINGS_FOR_LLVM_HEADERS
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/Twine.h"
#include "llvm/IR/Argument.h"
#include "llvm/IR/BasicBlock.h"
#include "llvm/IR/Constant.h"
#include "llvm/IR/Constants.h"
#include "llvm/IR/DIBuilder.h"
#include "llvm/IR/DebugInfoMetadata.h"
#include "llvm/IR/Function.h"
#include "llvm/IR/GlobalValue.h"
#include "llvm/IR/IRBuilder.h"
#include "llvm/IR/Instructions.h"
#include "llvm/IR/Intrinsics.h"
#include "llvm/IR/Module.h"
#include "llvm/IR/Type.h"
#include "llvm/IR/Value.h"
#include "llvm/Support/raw_ostream.h"
POP_DISABLE_WARNINGS_FOR_LLVM_HEADERS
namespace llvm {
class Metadata;
}
#define ENABLE_LOGGING 0
#define EMIT_ENTER_EXIT_HOOKS 0
using namespace WAVM;
using namespace WAVM::IR;
using namespace WAVM::LLVMJIT;
using namespace WAVM::Runtime;
// Creates a PHI node for the argument of branches to a basic block.
PHIVector EmitFunctionContext::createPHIs(llvm::BasicBlock* basicBlock, IR::TypeTuple type)
{
auto originalBlock = irBuilder.GetInsertBlock();
irBuilder.SetInsertPoint(basicBlock);
PHIVector result;
for(Uptr elementIndex = 0; elementIndex < type.size(); ++elementIndex)
{ result.push_back(irBuilder.CreatePHI(asLLVMType(llvmContext, type[elementIndex]), 2)); }
if(originalBlock) { irBuilder.SetInsertPoint(originalBlock); }
return result;
}
// Bitcasts a LLVM value to a canonical type for the corresponding WebAssembly type. This is
// currently just used to map all the various vector types to a canonical type for the vector width.
llvm::Value* EmitFunctionContext::coerceToCanonicalType(llvm::Value* value)
{
if(value->getType()->isVectorTy())
{
switch(value->getType()->getScalarSizeInBits() * value->getType()->getVectorNumElements())
{
case 128: return irBuilder.CreateBitCast(value, llvmContext.i64x2Type);
default: Errors::unreachable();
};
}
else if(value->getType()->isX86_MMXTy())
{
return irBuilder.CreateBitCast(value, llvmContext.i64x2Type);
}
else
{
return value;
}
}
// Debug logging.
void EmitFunctionContext::logOperator(const std::string& operatorDescription)
{
if(ENABLE_LOGGING)
{
std::string controlStackString;
for(Uptr stackIndex = 0; stackIndex < controlStack.size(); ++stackIndex)
{
if(!controlStack[stackIndex].isReachable) { controlStackString += "("; }
switch(controlStack[stackIndex].type)
{
case ControlContext::Type::function: controlStackString += "F"; break;
case ControlContext::Type::block: controlStackString += "B"; break;
case ControlContext::Type::ifThen: controlStackString += "I"; break;
case ControlContext::Type::ifElse: controlStackString += "E"; break;
case ControlContext::Type::loop: controlStackString += "L"; break;
case ControlContext::Type::try_: controlStackString += "T"; break;
case ControlContext::Type::catch_: controlStackString += "C"; break;
default: Errors::unreachable();
};
if(!controlStack[stackIndex].isReachable) { controlStackString += ")"; }
}
std::string stackString;
const Uptr stackBase = controlStack.size() == 0 ? 0 : controlStack.back().outerStackSize;
for(Uptr stackIndex = 0; stackIndex < stack.size(); ++stackIndex)
{
if(stackIndex == stackBase) { stackString += "| "; }
{
llvm::raw_string_ostream stackTypeStream(stackString);
stack[stackIndex]->getType()->print(stackTypeStream, true);
}
stackString += " ";
}
if(stack.size() == stackBase) { stackString += "|"; }
Log::printf(Log::debug,
"%-50s %-50s %-50s\n",
controlStackString.c_str(),
operatorDescription.c_str(),
stackString.c_str());
}
}
// Traps a divide-by-zero
void EmitFunctionContext::trapDivideByZero(llvm::Value* divisor)
{
emitConditionalTrapIntrinsic(
irBuilder.CreateICmpEQ(divisor, llvm::Constant::getNullValue(divisor->getType())),
"divideByZeroOrIntegerOverflowTrap",
FunctionType(),
{});
}
// Traps on (x / 0) or (INT_MIN / -1).
void EmitFunctionContext::trapDivideByZeroOrIntegerOverflow(ValueType type,
llvm::Value* left,
llvm::Value* right)
{
emitConditionalTrapIntrinsic(
irBuilder.CreateOr(
irBuilder.CreateAnd(
irBuilder.CreateICmpEQ(left,
type == ValueType::i32
? emitLiteral(llvmContext, (U32)INT32_MIN)
: emitLiteral(llvmContext, (U64)INT64_MIN)),
irBuilder.CreateICmpEQ(right,
type == ValueType::i32 ? emitLiteral(llvmContext, (U32)-1)
: emitLiteral(llvmContext, (U64)-1))),
irBuilder.CreateICmpEQ(right, llvmContext.typedZeroConstants[(Uptr)type])),
"divideByZeroOrIntegerOverflowTrap",
FunctionType(),
{});
}
// Emits a call to a WAVM intrinsic function.
ValueVector EmitFunctionContext::emitRuntimeIntrinsic(
const char* intrinsicName,
FunctionType intrinsicType,
const std::initializer_list<llvm::Value*>& args)
{
llvm::Function* intrinsicFunction = moduleContext.llvmModule->getFunction(intrinsicName);
if(!intrinsicFunction)
{
intrinsicFunction = llvm::Function::Create(
asLLVMType(llvmContext, intrinsicType, CallingConvention::intrinsic),
llvm::Function::ExternalLinkage,
intrinsicName,
moduleContext.llvmModule);
intrinsicFunction->setCallingConv(asLLVMCallingConv(CallingConvention::intrinsic));
}
return emitCallOrInvoke(intrinsicFunction,
args,
intrinsicType,
CallingConvention::intrinsic,
getInnermostUnwindToBlock());
}
// A helper function to emit a conditional call to a non-returning intrinsic function.
void EmitFunctionContext::emitConditionalTrapIntrinsic(
llvm::Value* booleanCondition,
const char* intrinsicName,
FunctionType intrinsicType,
const std::initializer_list<llvm::Value*>& args)
{
auto trueBlock
= llvm::BasicBlock::Create(llvmContext, llvm::Twine(intrinsicName) + "Trap", function);
auto endBlock
= llvm::BasicBlock::Create(llvmContext, llvm::Twine(intrinsicName) + "Skip", function);
irBuilder.CreateCondBr(
booleanCondition, trueBlock, endBlock, moduleContext.likelyFalseBranchWeights);
irBuilder.SetInsertPoint(trueBlock);
emitRuntimeIntrinsic(intrinsicName, intrinsicType, args);
irBuilder.CreateUnreachable();
irBuilder.SetInsertPoint(endBlock);
}
//
// Control structure operators
//
void EmitFunctionContext::pushControlStack(ControlContext::Type type,
TypeTuple resultTypes,
llvm::BasicBlock* endBlock,
const PHIVector& endPHIs,
llvm::BasicBlock* elseBlock,
const ValueVector& elseArgs)
{
// The unreachable operator filtering should filter out any opcodes that call pushControlStack.
if(controlStack.size()) { errorUnless(controlStack.back().isReachable); }
controlStack.push_back({type,
endBlock,
endPHIs,
elseBlock,
elseArgs,
resultTypes,
stack.size(),
branchTargetStack.size(),
true});
}
void EmitFunctionContext::pushBranchTarget(TypeTuple branchArgumentType,
llvm::BasicBlock* branchTargetBlock,
const PHIVector& branchTargetPHIs)
{
branchTargetStack.push_back({branchArgumentType, branchTargetBlock, branchTargetPHIs});
}
void EmitFunctionContext::branchToEndOfControlContext()
{
ControlContext& currentContext = controlStack.back();
if(currentContext.isReachable)
{
// If the control context expects a result, take it from the operand stack and add it to the
// control context's end PHI.
for(Iptr resultIndex = Iptr(currentContext.resultTypes.size()) - 1; resultIndex >= 0;
--resultIndex)
{
llvm::Value* result = pop();
currentContext.endPHIs[resultIndex]->addIncoming(coerceToCanonicalType(result),
irBuilder.GetInsertBlock());
}
// Branch to the control context's end.
irBuilder.CreateBr(currentContext.endBlock);
}
wavmAssert(stack.size() == currentContext.outerStackSize);
}
void EmitFunctionContext::enterUnreachable()
{
// Unwind the operand stack to the outer control context.
wavmAssert(controlStack.back().outerStackSize <= stack.size());
stack.resize(controlStack.back().outerStackSize);
// Mark the current control context as unreachable: this will cause the outer loop to stop
// dispatching operators to us until an else/end for the current control context is reached.
controlStack.back().isReachable = false;
}
// A do-nothing visitor used to decode past unreachable operators (but supporting logging, and
// passing the end operator through).
struct UnreachableOpVisitor
{
typedef void Result;
UnreachableOpVisitor(EmitFunctionContext& inContext)
: context(inContext), unreachableControlDepth(0)
{
}
#define VISIT_OP(opcode, name, nameString, Imm, ...) \
void name(Imm imm) {}
ENUM_NONCONTROL_OPERATORS(VISIT_OP)
VISIT_OP(_, unknown, "unknown", Opcode)
#undef VISIT_OP
// Keep track of control structure nesting level in unreachable code, so we know when we reach
// the end of the unreachable code.
void block(ControlStructureImm) { ++unreachableControlDepth; }
void loop(ControlStructureImm) { ++unreachableControlDepth; }
void if_(ControlStructureImm) { ++unreachableControlDepth; }
// If an else or end opcode would signal an end to the unreachable code, then pass it through to
// the IR emitter.
void else_(NoImm imm)
{
if(!unreachableControlDepth) { context.else_(imm); }
}
void end(NoImm imm)
{
if(!unreachableControlDepth) { context.end(imm); }
else
{
--unreachableControlDepth;
}
}
void try_(ControlStructureImm imm) { ++unreachableControlDepth; }
void catch_(ExceptionTypeImm imm)
{
if(!unreachableControlDepth) { context.catch_(imm); }
}
void catch_all(NoImm imm)
{
if(!unreachableControlDepth) { context.catch_all(imm); }
}
private:
EmitFunctionContext& context;
Uptr unreachableControlDepth;
};
void EmitFunctionContext::emit()
{
// Create debug info for the function.
llvm::SmallVector<llvm::Metadata*, 10> diFunctionParameterTypes;
for(auto parameterType : functionType.params())
{ diFunctionParameterTypes.push_back(moduleContext.diValueTypes[(Uptr)parameterType]); }
auto diParamArray = moduleContext.diBuilder.getOrCreateTypeArray(diFunctionParameterTypes);
auto diFunctionType = moduleContext.diBuilder.createSubroutineType(diParamArray);
diFunction = moduleContext.diBuilder.createFunction(moduleContext.diModuleScope,
function->getName(),
function->getName(),
moduleContext.diModuleScope,
0,
diFunctionType,
false,
true,
0);
function->setSubprogram(diFunction);
// Create the return basic block, and push the root control context for the function.
auto returnBlock = llvm::BasicBlock::Create(llvmContext, "return", function);
auto returnPHIs = createPHIs(returnBlock, functionType.results());
pushControlStack(
ControlContext::Type::function, functionType.results(), returnBlock, returnPHIs);
pushBranchTarget(functionType.results(), returnBlock, returnPHIs);
// Create an initial basic block for the function.
auto entryBasicBlock = llvm::BasicBlock::Create(llvmContext, "entry", function);
irBuilder.SetInsertPoint(entryBasicBlock);
// Create and initialize allocas for the memory and table base parameters.
auto llvmArgIt = function->arg_begin();
initContextVariables(&*llvmArgIt++);
// Create and initialize allocas for all the locals and parameters.
for(Uptr localIndex = 0;
localIndex < functionType.params().size() + functionDef.nonParameterLocalTypes.size();
++localIndex)
{
auto localType
= localIndex < functionType.params().size()
? functionType.params()[localIndex]
: functionDef.nonParameterLocalTypes[localIndex - functionType.params().size()];
auto localPointer = irBuilder.CreateAlloca(asLLVMType(llvmContext, localType), nullptr, "");
localPointers.push_back(localPointer);
if(localIndex < functionType.params().size())
{
// Copy the parameter value into the local that stores it.
irBuilder.CreateStore(&*llvmArgIt, localPointer);
++llvmArgIt;
}
else
{
// Initialize non-parameter locals to zero.
irBuilder.CreateStore(llvmContext.typedZeroConstants[(Uptr)localType], localPointer);
}
}
if(EMIT_ENTER_EXIT_HOOKS)
{
emitRuntimeIntrinsic(
"debugEnterFunction",
FunctionType({}, {ValueType::anyfunc}),
{llvm::ConstantExpr::getSub(
llvm::ConstantExpr::getPtrToInt(function, llvmContext.iptrType),
emitLiteral(llvmContext, Uptr(offsetof(Runtime::Function, code))))});
}
// Decode the WebAssembly opcodes and emit LLVM IR for them.
OperatorDecoderStream decoder(functionDef.code);
UnreachableOpVisitor unreachableOpVisitor(*this);
OperatorPrinter operatorPrinter(irModule, functionDef);
Uptr opIndex = 0;
while(decoder && controlStack.size())
{
irBuilder.SetCurrentDebugLocation(
llvm::DILocation::get(llvmContext, (unsigned int)opIndex++, 0, diFunction));
if(ENABLE_LOGGING) { logOperator(decoder.decodeOpWithoutConsume(operatorPrinter)); }
if(controlStack.back().isReachable) { decoder.decodeOp(*this); }
else
{
decoder.decodeOp(unreachableOpVisitor);
}
};
wavmAssert(irBuilder.GetInsertBlock() == returnBlock);
if(EMIT_ENTER_EXIT_HOOKS)
{
emitRuntimeIntrinsic(
"debugExitFunction",
FunctionType({}, {ValueType::anyfunc}),
{llvm::ConstantExpr::getSub(
llvm::ConstantExpr::getPtrToInt(function, llvmContext.iptrType),
emitLiteral(llvmContext, Uptr(offsetof(Runtime::Function, code))))});
}
// Emit the function return.
emitReturn(functionType.results(), stack);
// If a local escape block was created, add a localescape intrinsic to it with the accumulated
// local escape allocas, and insert it before the function's entry block.
if(localEscapeBlock)
{
irBuilder.SetInsertPoint(localEscapeBlock);
callLLVMIntrinsic({}, llvm::Intrinsic::localescape, pendingLocalEscapes);
irBuilder.CreateBr(&function->getEntryBlock());
localEscapeBlock->moveBefore(&function->getEntryBlock());
}
}
| 33.006849 | 100 | 0.733486 | PiotrSikora |
baeae0c881b90096ce336ae250b93fdfaa4745dc | 3,594 | cpp | C++ | opensoap/src/server/IdManager_main.cpp | kbore/pbis-open | a05eb9309269b6402b4d6659bc45961986ea5eab | [
"Apache-2.0"
] | 372 | 2016-10-28T10:50:35.000Z | 2022-03-18T19:54:37.000Z | opensoap/src/server/IdManager_main.cpp | kbore/pbis-open | a05eb9309269b6402b4d6659bc45961986ea5eab | [
"Apache-2.0"
] | 317 | 2016-11-02T17:41:48.000Z | 2021-11-08T20:28:19.000Z | opensoap/src/server/IdManager_main.cpp | kenferrara/pbis-open | 690c325d947b2bf6fb3032f9d660e41b94aea4be | [
"Apache-2.0"
] | 107 | 2016-11-03T19:25:16.000Z | 2022-03-20T21:15:22.000Z | /* -*- mode: c++; -*-
*-----------------------------------------------------------------------------
* $RCSfile: IdManager_main.cpp,v $
*
* See Copyright for the status of this software.
*
* The OpenSOAP Project
* http://opensoap.jp/
*-----------------------------------------------------------------------------
*/
#if HAVE_CONFIG_H
# include "config.h"
#endif
#if defined(WIN32)
#include <windows.h>
#include <io.h>
#include <process.h>
#include <time.h>
#else
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/un.h>
#endif
#include <signal.h>
//#include <cstdio>
#include <iostream>
#include <fstream>
#include <string>
#include "IdManager.h"
#if !defined(NO_LOGGER)
#include "AppLogger.h"
#endif
#include "ServerCommon.h"
#include "IdManager.h"
#include "PIDFactory.h"
#include "SrvConfAttrHandler.h"
#include "ProcessInfo.h"
#include "Exception.h"
#include "SrvErrorCode.h"
using namespace OpenSOAP;
using namespace std;
//for LOG
static const std::string CLASS_SIG = "IdManager";
extern void signal_term(int i){
AppLogger::Write(LOG_NOTICE,"signal:term termination now");
ProcessInfo::SetProcessStatus(PSTAT_WAITTERM);
}
int
main(int argc, char* argv[])
{
int i=0;
ProcessInfo::SetProcessName(argv[0]);
ProcessInfo::SetHostName(NULL);
#if defined(NO_LOGGER)
string logFile;
SrvConfAttrHandler* srvConf = new SrvConfAttrHandler();
vector<string> values;
string query = SERVER_CONF_TAG + "/log/path=?";
if (0 > srvConf->queryXml(query, values)) {
logFile = OPENSOAP_TMP_PATH + "log/idManager";
}
else {
logFile = values[0] + "idManager.log";
}
delete srvConf;
FILE* outfp = fopen(logFile.c_str(), "w");
if (!outfp) {
cerr << "** E **: file open failed.[" << logFile << "]" << endl;
return 1;
}
if (argc <=1) {
fprintf(outfp, "invalid initial argument. argc=(%d)\n", argc);
fprintf(outfp, "exit.\n");
fclose(outfp);
return EXIT_FAILURE;
}
int old;
int olderr;
//backup stdout
old = _dup(1);
//stdout -> outfp
if (-1 == _dup2(_fileno(outfp), 1)) {
fprintf(outfp, "_dup2 to stdout failed.\n");
fprintf(outfp, "exit.\n");
fclose(outfp);
return EXIT_FAILURE;
}
//backup stderr
olderr = _dup(2);
//stderr -> outfp
if (-1 == _dup2(_fileno(outfp), 2)) {
fprintf(outfp, "_dup2 to stderr failed.\n");
fprintf(outfp, "exit.\n");
fclose(outfp);
return EXIT_FAILURE;
}
#else
// set log level
AppLogger logger(NULL,ProcessInfo::GetProcessName().c_str());
AppLogger::Write("IdManager start");
#endif
#if !defined(WIN32)
// make it to daemon & write pid file
// daemon(0, 1);
ProcessInfo::AddThreadInfo();
PIDFactory* pidFactory = new PIDFactory();
if (!pidFactory->makePID(IDMGR_PID_FILE)){
delete pidFactory;
AppLogger::Write(ERR_ERROR, "error !!: process duplication");
return EXIT_FAILURE;
}
#endif
// set signal
signal(SIGTERM,signal_term);
// create instance of IdManager & run
// 3 times retry
AppLogger::Write("IdManager_main wait termination");
for (i=0 ; i<3 && ProcessInfo::GetProcessStatus()!=PSTAT_WAITTERM ; i++){
IdManager idMngr;
try{
idMngr.run();
}
catch(Exception e){
AppLogger::Write(e);
}
catch(...){
AppLogger::Write(ERR_ERROR,"unknown error !!: process down!!");
}
}
#if defined(NO_LOGGER)
fclose(outfp);
_dup2(old, 1);
_dup2(olderr, 2);
#else
//write stop message
AppLogger::Write("IdManager_main stop");
#endif
ProcessInfo::DelThreadInfo();
delete pidFactory;
return EXIT_SUCCESS;
}
| 21.914634 | 79 | 0.6266 | kbore |
baeb948cf089895c7b2d8bb827f0849953180fca | 569 | cpp | C++ | codechef/nov19a/hrdseq.cpp | saranshbht/codes-and-more-codes | 0bd2e46ca613b3b81e1196d393902e86a43aa353 | [
"MIT"
] | null | null | null | codechef/nov19a/hrdseq.cpp | saranshbht/codes-and-more-codes | 0bd2e46ca613b3b81e1196d393902e86a43aa353 | [
"MIT"
] | null | null | null | codechef/nov19a/hrdseq.cpp | saranshbht/codes-and-more-codes | 0bd2e46ca613b3b81e1196d393902e86a43aa353 | [
"MIT"
] | null | null | null | #include<bits/stdc++.h>
using namespace std;
#define endl "\n"
int main() {
ios_base :: sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int arr[128] {0};
for (int i = 2; i < 128; i++) {
int key = arr[i - 1], j;
for (j = i - 2; j >= 0; j--) {
if (arr[j] == key) {
break;
}
}
if (j == -1) {
arr[i] = 0;
} else {
arr[i] = i - 1 - j;
}
}
// for(int i = 0; i < 128; i++)
// cout << arr[i] << " ";
// cout << endl;
int t, n;
cin >> t;
while (t--) {
cin >> n;
cout << count(arr, arr + n, arr[n - 1]) << endl;
}
return 0;
} | 16.257143 | 50 | 0.442882 | saranshbht |
baed86eec61b5a581920d0074b8ed340eeaa01b3 | 5,154 | cpp | C++ | FHE/FFT.cpp | fqliao/MP-SPDZ | 070fca5c52ee225fe681f16f150f5fb1a7b4b3ca | [
"BSD-2-Clause"
] | 1 | 2021-06-29T12:12:18.000Z | 2021-06-29T12:12:18.000Z | FHE/FFT.cpp | fqliao/MP-SPDZ | 070fca5c52ee225fe681f16f150f5fb1a7b4b3ca | [
"BSD-2-Clause"
] | null | null | null | FHE/FFT.cpp | fqliao/MP-SPDZ | 070fca5c52ee225fe681f16f150f5fb1a7b4b3ca | [
"BSD-2-Clause"
] | null | null | null |
#include "FHE/FFT.h"
#include "Math/Zp_Data.h"
#include "Math/modp.hpp"
/* Computes the FFT via Horner's Rule
theta is assumed to be an Nth root of unity
*/
void NaiveFFT(vector<modp>& ans,vector<modp>& a,int N,const modp& theta,const Zp_Data& PrD)
{
int i,j;
modp thetaPow;
assignOne(thetaPow,PrD);
for (i=0; i<N; i++)
{ ans[i]=a[N-1];
for (j=N-2; j>=0; j--)
{ Mul(ans[i],ans[i],thetaPow,PrD);
Add(ans[i],ans[i],a[j],PrD);
}
Mul(thetaPow,thetaPow,theta,PrD);
}
}
void FFT(vector<modp>& a,int N,const modp& theta,const Zp_Data& PrD)
{
if (N==1) { return; }
if (N<5)
{ vector<modp> b(N);
NaiveFFT(b,a,N,theta,PrD);
a=b;
return;
}
vector<modp> a0(N/2),a1(N/2);
int i;
for (i=0; i<N/2; i++)
{ a0[i]=a[2*i];
a1[i]=a[2*i+1];
}
modp theta2,w,t;
Sqr(theta2,theta,PrD);
FFT(a0,N/2,theta2,PrD);
FFT(a1,N/2,theta2,PrD);
assignOne(w,PrD);
for (i=0; i<N/2; i++)
{ Mul(t,w,a1[i],PrD);
Add(a[i],a0[i],t,PrD);
Sub(a[i+N/2],a0[i],t,PrD);
Mul(w,w,theta,PrD);
}
}
/*
* Standard FFT for n a power of two, root a n-th primitive root of unity.
*/
template<class T,class P>
void FFT_Iter(vector<T>& ioput, int n, const T& root, const P& PrD)
{
int i, j, m;
T t;
// Bit-reversal of input
for( i = j = 0; i < n; ++i )
{
if( j >= i )
{
t = ioput[i];
ioput[i] = ioput[j];
ioput[j] = t;
}
m = n / 2;
while( (m >= 1) && (j >= m) )
{
j -= m;
m /= 2;
}
j += m;
}
T u, alpha, alpha2;
m = 0; j = 0; i = 0;
// Do the transform
for (int s = 1; s < n; s = 2*s)
{
m = 2*s;
Power(alpha, root, n/m, PrD);
assignOne(alpha2,PrD);
for (int j = 0; j < m/2; ++j)
{
//root = root_table[j*n/m];
for (int k = j; k < n; k += m)
{
Mul(t, alpha2, ioput[k + m/2], PrD);
u = ioput[k];
Add(ioput[k], u, t, PrD);
Sub(ioput[k + m/2], u, t, PrD);
}
Mul(alpha2, alpha2, alpha, PrD);
}
}
}
/*
* FFT modulo x^n + 1.
*
* n must be a power of two, root a 2n-th primitive root of unity.
*/
void FFT_Iter2(vector<modp>& ioput, int n, const modp& root, const Zp_Data& PrD)
{
int i, j, m;
modp t;
// Bit-reversal of input
for( i = j = 0; i < n; ++i )
{
if( j >= i )
{
t = ioput[i];
ioput[i] = ioput[j];
ioput[j] = t;
}
m = n / 2;
while( (m >= 1) && (j >= m) )
{
j -= m;
m /= 2;
}
j += m;
}
modp u, alpha, alpha2;
m = 0; j = 0; i = 0;
// Do the transform
for (int s = 1; s < n; s = 2*s)
{
m = 2*s;
Power(alpha, root, n/m, PrD);
alpha2 = alpha;
Mul(alpha, alpha, alpha, PrD);
for (int j = 0; j < m/2; ++j)
{
//root = root_table[(2*j+1)*n/m];
for (int k = j; k < n; k += m)
{
Mul(t, alpha2, ioput[k + m/2], PrD);
u = ioput[k];
Add(ioput[k], u, t, PrD);
Sub(ioput[k + m/2], u, t, PrD);
}
Mul(alpha2, alpha2, alpha, PrD);
}
}
}
/* This does FFT for X^N+1,
Input and output is an array of size N (shared)
alpha is assumed to be a generator of the N'th roots of unity mod p
Starts at w=alpha and updates by alpha^2
*/
void FFT2(vector<modp>& a, int N, const modp& alpha, const Zp_Data& PrD)
{
int i;
if (N==1) { return; }
vector<modp> a0(N/2),a1(N/2);
for (i=0; i<N/2; i++)
{ a0[i]=a[2*i];
a1[i]=a[2*i+1];
}
modp w,alpha2,temp;
Sqr(alpha2,alpha,PrD);
FFT2(a0,N/2,alpha2,PrD); FFT2(a1,N/2,alpha2,PrD);
w=alpha;
for (i=0; i<N/2; i++)
{ Mul(temp,w,a1[i],PrD);
Add(a[i],a0[i],temp,PrD);
Sub(a[i+N/2],a0[i],temp,PrD);
Mul(w,w,alpha2,PrD);
}
}
void BFFT(vector<modp>& ans,const vector<modp>& a,const FFT_Data& FFTD,bool forward)
{
int k2=FFTD.twop,n=FFTD.m();
if (k2<0) { k2=-k2; }
int r=0;
if (forward==false) { r=1; }
if (FFTD.twop>0)
{ vector<modp> x(k2);
for (unsigned int i=0; i<a.size(); i++)
{ Mul(x[i],FFTD.powers[r][i],a[i],FFTD.get_prD()); }
for (int i=a.size(); i<k2; i++)
{ assignZero(x[i],FFTD.get_prD()); }
FFT_Iter(x,k2,FFTD.two_root[0],FFTD.get_prD());
for (int i=0; i<k2; i++)
{ Mul(x[i],x[i],FFTD.b[r][i],FFTD.get_prD()); }
FFT_Iter(x,k2,FFTD.two_root[1],FFTD.get_prD());
for (int i=0; i<n; i++)
{ Mul(ans[i],x[i+n-1],FFTD.powers_i[r][i],FFTD.get_prD()); }
}
else
{ throw crash_requested(); }
}
| 23.008929 | 92 | 0.431704 | fqliao |
baf09f99e6e50bd9a1869e067dd782f0de68f36d | 17,240 | hpp | C++ | ld64-409.12/src/ld/parsers/generic_dylib_file.hpp | JunyiXie/ld64 | ffaa615b31ff1baa5d6249e4d9a6a21c2ae603ae | [
"Apache-2.0"
] | null | null | null | ld64-409.12/src/ld/parsers/generic_dylib_file.hpp | JunyiXie/ld64 | ffaa615b31ff1baa5d6249e4d9a6a21c2ae603ae | [
"Apache-2.0"
] | null | null | null | ld64-409.12/src/ld/parsers/generic_dylib_file.hpp | JunyiXie/ld64 | ffaa615b31ff1baa5d6249e4d9a6a21c2ae603ae | [
"Apache-2.0"
] | null | null | null | /* -*- mode: C++; c-basic-offset: 4; tab-width: 4 -*-
*
* Copyright (c) 2015 Apple Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this
* file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
#ifndef __GENERIC_DYLIB_FILE_H__
#define __GENERIC_DYLIB_FILE_H__
#include "ld.hpp"
#include "Options.h"
#include <unordered_map>
#include <unordered_set>
namespace generic {
namespace dylib {
// forward reference
template <typename A> class File;
//
// An ExportAtom has no content. It exists so that the linker can track which
// imported symbols came from which dynamic libraries.
//
template <typename A>
class ExportAtom final : public ld::Atom
{
public:
ExportAtom(const File<A>& f, const char* nm, bool weakDef, bool tlv,
typename A::P::uint_t address)
: ld::Atom(f._importProxySection, ld::Atom::definitionProxy,
(weakDef ? ld::Atom::combineByName : ld::Atom::combineNever),
ld::Atom::scopeLinkageUnit,
(tlv ? ld::Atom::typeTLV : ld::Atom::typeUnclassified),
symbolTableNotIn, false, false, false, ld::Atom::Alignment(0)),
_file(f),
_name(nm),
_address(address)
{}
// overrides of ld::Atom
virtual const ld::File* file() const override final { return &_file; }
virtual const char* name() const override final { return _name; }
virtual uint64_t size() const override final { return 0; }
virtual uint64_t objectAddress() const override final { return _address; }
virtual void copyRawContent(uint8_t buffer[]) const override final { }
virtual void setScope(Scope) { }
private:
using pint_t = typename A::P::uint_t;
virtual ~ExportAtom() {}
const File<A>& _file;
const char* _name;
pint_t _address;
};
//
// An ImportAtom has no content. It exists so that when linking a main executable flat-namespace
// the imports of all flat dylibs are checked
//
template <typename A>
class ImportAtom final : public ld::Atom
{
public:
ImportAtom(File<A>& f, std::vector<const char*>& imports);
// overrides of ld::Atom
virtual ld::File* file() const override final { return &_file; }
virtual const char* name() const override final { return "import-atom"; }
virtual uint64_t size() const override final { return 0; }
virtual uint64_t objectAddress() const override final { return 0; }
virtual ld::Fixup::iterator fixupsBegin() const override final { return &_undefs[0]; }
virtual ld::Fixup::iterator fixupsEnd() const override final { return &_undefs[_undefs.size()]; }
virtual void copyRawContent(uint8_t buffer[]) const override final { }
virtual void setScope(Scope) { }
private:
virtual ~ImportAtom() {}
File<A>& _file;
mutable std::vector<ld::Fixup> _undefs;
};
template <typename A>
ImportAtom<A>::ImportAtom(File<A>& f, std::vector<const char*>& imports)
: ld::Atom(f._flatDummySection, ld::Atom::definitionRegular, ld::Atom::combineNever,
ld::Atom::scopeTranslationUnit, ld::Atom::typeUnclassified, symbolTableNotIn, false,
false, false, ld::Atom::Alignment(0)),
_file(f)
{
for(auto *name : imports)
_undefs.emplace_back(0, ld::Fixup::k1of1, ld::Fixup::kindNone, false, strdup(name));
}
//
// A generic representation for the dynamic library files we support (Mach-O and text-based stubs).
// Common state and functionality is consolidated in this class.
//
template <typename A>
class File : public ld::dylib::File
{
public:
File(const char* path, time_t mTime, ld::File::Ordinal ordinal, const ld::VersionSet& platforms,
bool allowWeakImports, bool linkingFlatNamespace, bool hoistImplicitPublicDylibs,
bool allowSimToMacOSX, bool addVers);
// overrides of ld::File
virtual bool forEachAtom(ld::File::AtomHandler&) const override final;
virtual bool justInTimeforEachAtom(const char* name, ld::File::AtomHandler&) const override final;
virtual uint8_t swiftVersion() const override final { return _swiftVersion; }
virtual ld::Bitcode* getBitcode() const override final { return _bitcode.get(); }
// overrides of ld::dylib::File
virtual void processIndirectLibraries(ld::dylib::File::DylibHandler*, bool addImplicitDylibs) override;
virtual bool providedExportAtom() const override final { return _providedAtom; }
virtual const char* parentUmbrella() const override final { return _parentUmbrella; }
virtual const std::vector<const char*>* allowableClients() const override final { return _allowableClients.empty() ? nullptr : &_allowableClients; }
virtual const std::vector<const char*>& rpaths() const override final { return _rpaths; }
virtual bool hasWeakExternals() const override final { return _hasWeakExports; }
virtual bool deadStrippable() const override final { return _deadStrippable; }
virtual bool hasWeakDefinition(const char* name) const override final;
virtual bool hasPublicInstallName() const override final { return _hasPublicInstallName; }
virtual bool allSymbolsAreWeakImported() const override final;
virtual bool installPathVersionSpecific() const override final { return _installPathOverride; }
virtual bool appExtensionSafe() const override final { return _appExtensionSafe; };
bool wrongOS() const { return _wrongOS; }
private:
using pint_t = typename A::P::uint_t;
friend class ExportAtom<A>;
friend class ImportAtom<A>;
struct CStringHash {
std::size_t operator()(const char* __s) const {
unsigned long __h = 0;
for ( ; *__s; ++__s)
__h = 5 * __h + *__s;
return size_t(__h);
};
};
protected:
struct AtomAndWeak { ld::Atom* atom; bool weakDef; bool tlv; pint_t address; };
struct Dependent {
const char* path;
File<A>* dylib;
bool reExport;
Dependent(const char* path, bool reExport)
: path(path), dylib(nullptr), reExport(reExport) {}
};
struct ReExportChain { ReExportChain* prev; const File* file; };
private:
using NameToAtomMap = std::unordered_map<const char*, AtomAndWeak, ld::CStringHash, ld::CStringEquals>;
using NameSet = std::unordered_set<const char*, CStringHash, ld::CStringEquals>;
std::pair<bool, bool> hasWeakDefinitionImpl(const char* name) const;
bool containsOrReExports(const char* name, bool& weakDef, bool& tlv, pint_t& addr) const;
void assertNoReExportCycles(ReExportChain*) const;
protected:
bool isPublicLocation(const char* path) const;
private:
ld::Section _importProxySection;
ld::Section _flatDummySection;
mutable bool _providedAtom;
bool _indirectDylibsProcessed;
protected:
mutable NameToAtomMap _atoms;
NameSet _ignoreExports;
std::vector<Dependent> _dependentDylibs;
ImportAtom<A>* _importAtom;
std::vector<const char*> _allowableClients;
std::vector<const char*> _rpaths;
const char* _parentUmbrella;
std::unique_ptr<ld::Bitcode> _bitcode;
ld::VersionSet _platforms;
uint8_t _swiftVersion;
bool _wrongOS;
bool _linkingFlat;
bool _noRexports;
bool _explictReExportFound;
bool _implicitlyLinkPublicDylibs;
bool _installPathOverride;
bool _hasWeakExports;
bool _deadStrippable;
bool _hasPublicInstallName;
bool _appExtensionSafe;
const bool _allowWeakImports;
const bool _allowSimToMacOSXLinking;
const bool _addVersionLoadCommand;
static bool _s_logHashtable;
};
template <typename A>
bool File<A>::_s_logHashtable = false;
template <typename A>
File<A>::File(const char* path, time_t mTime, ld::File::Ordinal ord, const ld::VersionSet& platforms,
bool allowWeakImports, bool linkingFlatNamespace,
bool hoistImplicitPublicDylibs,
bool allowSimToMacOSX, bool addVers)
: ld::dylib::File(path, mTime, ord),
_importProxySection("__TEXT", "__import", ld::Section::typeImportProxies, true),
_flatDummySection("__LINKEDIT", "__flat_dummy", ld::Section::typeLinkEdit, true),
_providedAtom(false),
_indirectDylibsProcessed(false),
_importAtom(nullptr),
_parentUmbrella(nullptr),
_platforms(platforms),
_swiftVersion(0),
_wrongOS(false),
_linkingFlat(linkingFlatNamespace),
_noRexports(false),
_explictReExportFound(false),
_implicitlyLinkPublicDylibs(hoistImplicitPublicDylibs),
_installPathOverride(false),
_hasWeakExports(false),
_deadStrippable(false),
_hasPublicInstallName(false),
_appExtensionSafe(false),
_allowWeakImports(allowWeakImports),
_allowSimToMacOSXLinking(allowSimToMacOSX),
_addVersionLoadCommand(addVers)
{
}
template <typename A>
std::pair<bool, bool> File<A>::hasWeakDefinitionImpl(const char* name) const
{
const auto pos = _atoms.find(name);
if ( pos != this->_atoms.end() )
return std::make_pair(true, pos->second.weakDef);
// look in re-exported libraries.
for (const auto &dep : _dependentDylibs) {
if ( dep.reExport ) {
auto ret = dep.dylib->hasWeakDefinitionImpl(name);
if ( ret.first )
return ret;
}
}
return std::make_pair(false, false);
}
template <typename A>
bool File<A>::hasWeakDefinition(const char* name) const
{
// If we are supposed to ignore this export, then pretend we don't have it.
if ( _ignoreExports.count(name) != 0 )
return false;
return hasWeakDefinitionImpl(name).second;
}
template <typename A>
bool File<A>::containsOrReExports(const char* name, bool& weakDef, bool& tlv, pint_t& addr) const
{
if ( _ignoreExports.count(name) != 0 )
return false;
// check myself
const auto pos = _atoms.find(name);
if ( pos != _atoms.end() ) {
weakDef = pos->second.weakDef;
tlv = pos->second.tlv;
addr = pos->second.address;
return true;
}
// check dylibs I re-export
for (const auto& dep : _dependentDylibs) {
if ( dep.reExport && !dep.dylib->implicitlyLinked() ) {
if ( dep.dylib->containsOrReExports(name, weakDef, tlv, addr) )
return true;
}
}
return false;
}
template <typename A>
bool File<A>::forEachAtom(ld::File::AtomHandler& handler) const
{
handler.doFile(*this);
// if doing flatnamespace and need all this dylib's imports resolve
// add atom which references alls undefines in this dylib
if ( _importAtom != nullptr ) {
handler.doAtom(*_importAtom);
return true;
}
return false;
}
template <typename A>
bool File<A>::justInTimeforEachAtom(const char* name, ld::File::AtomHandler& handler) const
{
// If we are supposed to ignore this export, then pretend we don't have it.
if ( _ignoreExports.count(name) != 0 )
return false;
AtomAndWeak bucket;
if ( containsOrReExports(name, bucket.weakDef, bucket.tlv, bucket.address) ) {
bucket.atom = new ExportAtom<A>(*this, name, bucket.weakDef, bucket.tlv, bucket.address);
_atoms[name] = bucket;
_providedAtom = true;
if ( _s_logHashtable )
fprintf(stderr, "getJustInTimeAtomsFor: %s found in %s\n", name, this->path());
// call handler with new export atom
handler.doAtom(*bucket.atom);
return true;
}
return false;
}
template <typename A>
void File<A>::assertNoReExportCycles(ReExportChain* prev) const
{
// recursively check my re-exported dylibs
ReExportChain chain = { prev, this };
for (const auto &dep : _dependentDylibs) {
if ( dep.reExport ) {
auto* child = dep.dylib;
// check child is not already in chain
for (auto* p = prev; p != nullptr; p = p->prev) {
if ( p->file == child ) {
throwf("cycle in dylib re-exports with %s and %s", child->path(), this->path());
}
}
if ( dep.dylib != nullptr )
dep.dylib->assertNoReExportCycles(&chain);
}
}
}
template <typename A>
void File<A>::processIndirectLibraries(ld::dylib::File::DylibHandler* handler, bool addImplicitDylibs)
{
// only do this once
if ( _indirectDylibsProcessed )
return;
const static bool log = false;
if ( log )
fprintf(stderr, "processIndirectLibraries(%s)\n", this->installPath());
if ( _linkingFlat ) {
for (auto &dep : _dependentDylibs)
dep.dylib = (File<A>*)handler->findDylib(dep.path, this, false);
}
else if ( _noRexports ) {
// MH_NO_REEXPORTED_DYLIBS bit set, then nothing to do
}
else {
// two-level, might have re-exports
for (auto &dep : this->_dependentDylibs) {
if ( dep.reExport ) {
if ( log )
fprintf(stderr, "processIndirectLibraries() parent=%s, child=%s\n", this->installPath(), dep.path);
// a LC_REEXPORT_DYLIB, LC_SUB_UMBRELLA or LC_SUB_LIBRARY says we re-export this child
dep.dylib = (File<A>*)handler->findDylib(dep.path, this, this->speculativelyLoaded());
if ( dep.dylib->hasPublicInstallName() && !dep.dylib->wrongOS() ) {
// promote this child to be automatically added as a direct dependent if this already is
if ( (this->explicitlyLinked() || this->implicitlyLinked()) && (strcmp(dep.path, dep.dylib->installPath()) == 0) ) {
if ( log )
fprintf(stderr, "processIndirectLibraries() implicitly linking %s\n", dep.dylib->installPath());
dep.dylib->setImplicitlyLinked();
}
else if ( dep.dylib->explicitlyLinked() || dep.dylib->implicitlyLinked() ) {
if ( log )
fprintf(stderr, "processIndirectLibraries() parent is not directly linked, but child is, so no need to re-export child\n");
}
else {
if ( log )
fprintf(stderr, "processIndirectLibraries() parent is not directly linked, so parent=%s will re-export child=%s\n", this->installPath(), dep.path);
}
}
else {
// add all child's symbols to me
if ( log )
fprintf(stderr, "processIndirectLibraries() child is not public, so parent=%s will re-export child=%s\n", this->installPath(), dep.path);
}
}
else if ( !_explictReExportFound ) {
// see if child contains LC_SUB_FRAMEWORK with my name
dep.dylib = (File<A>*)handler->findDylib(dep.path, this, this->speculativelyLoaded());
const char* parentUmbrellaName = dep.dylib->parentUmbrella();
if ( parentUmbrellaName != nullptr ) {
const char* parentName = this->path();
const char* lastSlash = strrchr(parentName, '/');
if ( (lastSlash != nullptr) && (strcmp(&lastSlash[1], parentUmbrellaName) == 0) ) {
// add all child's symbols to me
dep.reExport = true;
if ( log )
fprintf(stderr, "processIndirectLibraries() umbrella=%s will re-export child=%s\n", this->installPath(), dep.path);
}
}
}
}
}
// check for re-export cycles
ReExportChain chain = { nullptr, this };
this->assertNoReExportCycles(&chain);
_indirectDylibsProcessed = true;
}
template <typename A>
bool File<A>::isPublicLocation(const char* path) const
{
// -no_implicit_dylibs disables this optimization
if ( ! _implicitlyLinkPublicDylibs )
return false;
// /usr/lib is a public location
if ( (strncmp(path, "/usr/lib/", 9) == 0) && (strchr(&path[9], '/') == nullptr) )
return true;
// /System/Library/Frameworks/ is a public location
if ( strncmp(path, "/System/Library/Frameworks/", 27) == 0 ) {
const char* frameworkDot = strchr(&path[27], '.');
// but only top level framework
// /System/Library/Frameworks/Foo.framework/Versions/A/Foo ==> true
// /System/Library/Frameworks/Foo.framework/Resources/libBar.dylib ==> false
// /System/Library/Frameworks/Foo.framework/Frameworks/Bar.framework/Bar ==> false
// /System/Library/Frameworks/Foo.framework/Frameworks/Xfoo.framework/XFoo ==> false
if ( frameworkDot != nullptr ) {
int frameworkNameLen = frameworkDot - &path[27];
if ( strncmp(&path[strlen(path)-frameworkNameLen-1], &path[26], frameworkNameLen+1) == 0 )
return true;
}
}
return false;
}
// <rdar://problem/5529626> If only weak_import symbols are used, linker should use LD_LOAD_WEAK_DYLIB
template <typename A>
bool File<A>::allSymbolsAreWeakImported() const
{
bool foundNonWeakImport = false;
bool foundWeakImport = false;
//fprintf(stderr, "%s:\n", this->path());
for (const auto &it : _atoms) {
auto* atom = it.second.atom;
if ( atom != nullptr ) {
if ( atom->weakImported() )
foundWeakImport = true;
else
foundNonWeakImport = true;
//fprintf(stderr, " weak_import=%d, name=%s\n", atom->weakImported(), it->first);
}
}
// don't automatically weak link dylib with no imports
// so at least one weak import symbol and no non-weak-imported symbols must be found
return foundWeakImport && !foundNonWeakImport;
}
} // end namespace dylib
} // end namespace generic
#endif // __GENERIC_DYLIB_FILE_H__
| 34.549098 | 154 | 0.697796 | JunyiXie |
baf1014d77760b07775d4f86ff03ab435be32341 | 688 | cpp | C++ | components/xtl/tests/stl/alg_set03_2.cpp | untgames/funner | c91614cda55fd00f5631d2bd11c4ab91f53573a3 | [
"MIT"
] | 7 | 2016-03-30T17:00:39.000Z | 2017-03-27T16:04:04.000Z | components/xtl/tests/stl/alg_set03_2.cpp | untgames/Funner | c91614cda55fd00f5631d2bd11c4ab91f53573a3 | [
"MIT"
] | 4 | 2017-11-21T11:25:49.000Z | 2018-09-20T17:59:27.000Z | components/xtl/tests/stl/alg_set03_2.cpp | untgames/Funner | c91614cda55fd00f5631d2bd11c4ab91f53573a3 | [
"MIT"
] | 4 | 2016-11-29T15:18:40.000Z | 2017-03-27T16:04:08.000Z | //Тестирование алгоритма set_intersection (range1,range2,result,less)
#include <stdio.h>
#include <stl/algorithm>
#include <stl/vector>
#include "test.h"
using namespace stl;
int main ()
{
printf ("Results of alg_set03_2:\n");
int A1[] = {1, 3, -5, 7, 9, -11};
int A2[] = {1, -1, 2, -3, 5, -8, 13};
const int N1 = sizeof (A1) / sizeof (int);
const int N2 = sizeof (A2) / sizeof (int);
vector <int> v1 (N1+N2);
print ("A1 =", A1, A1+N1);
print ("A2 =", A2, A2+N2);
vector<int>::iterator new_end = set_intersection (A1, A1 + N1, A2, A2 + N2, v1.begin (), abs_less);
printf ("Intersection of A1 and A2:\n");
print ("v1 =", v1.begin (), new_end);
return 0;
}
| 22.933333 | 101 | 0.600291 | untgames |
baf114b85d6487359c785c1b5b16238b52255f0d | 23,596 | cpp | C++ | lgc/patch/SystemValues.cpp | yjaelex/llpc | 9cdcc2a8494396b10794b6557a5a5a4bded13029 | [
"MIT"
] | null | null | null | lgc/patch/SystemValues.cpp | yjaelex/llpc | 9cdcc2a8494396b10794b6557a5a5a4bded13029 | [
"MIT"
] | null | null | null | lgc/patch/SystemValues.cpp | yjaelex/llpc | 9cdcc2a8494396b10794b6557a5a5a4bded13029 | [
"MIT"
] | null | null | null | /*
***********************************************************************************************************************
*
* Copyright (c) 2018-2020 Advanced Micro Devices, Inc. All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
**********************************************************************************************************************/
/**
***********************************************************************************************************************
* @file SystemValues.cpp
* @brief LLPC source file: per-shader per-pass generating and cache of shader system pointers
***********************************************************************************************************************
*/
#include "SystemValues.h"
#include "lgc/state/PipelineState.h"
#include "lgc/state/TargetInfo.h"
#include "llvm/IR/Constants.h"
#include "llvm/IR/Instructions.h"
#define DEBUG_TYPE "lgc-system-values"
using namespace lgc;
using namespace llvm;
// =====================================================================================================================
// Initialize this ShaderSystemValues if it was previously uninitialized.
//
// @param pipelineState : Pipeline state
// @param entryPoint : Shader entrypoint
void ShaderSystemValues::initialize(PipelineState *pipelineState, Function *entryPoint) {
if (!m_entryPoint) {
m_entryPoint = entryPoint;
m_shaderStage = getShaderStage(entryPoint);
m_context = &entryPoint->getParent()->getContext();
m_pipelineState = pipelineState;
assert(m_shaderStage != ShaderStageInvalid);
assert(m_pipelineState->getShaderInterfaceData(m_shaderStage)->entryArgIdxs.initialized);
}
}
// =====================================================================================================================
// Get ES-GS ring buffer descriptor (for VS/TES output or GS input)
Value *ShaderSystemValues::getEsGsRingBufDesc() {
if (!m_esGsRingBufDesc) {
unsigned tableOffset = 0;
switch (m_shaderStage) {
case ShaderStageVertex:
case ShaderStageTessEval:
tableOffset = SiDrvTableEsRingOutOffs;
break;
case ShaderStageGeometry:
tableOffset = SiDrvTableGsRingInOffs;
break;
default:
llvm_unreachable("Should never be called!");
break;
}
// Ensure we have got the global table pointer first, and insert new code after that.
BuilderBase builder(getInternalGlobalTablePtr()->getNextNode());
m_esGsRingBufDesc = loadDescFromDriverTable(tableOffset, builder);
if (m_shaderStage != ShaderStageGeometry && m_pipelineState->getTargetInfo().getGfxIpVersion().major >= 8) {
// NOTE: For GFX8+, we have to explicitly set DATA_FORMAT for GS-VS ring buffer descriptor for
// VS/TES output.
m_esGsRingBufDesc = setRingBufferDataFormat(m_esGsRingBufDesc, BUF_DATA_FORMAT_32, builder);
}
}
return m_esGsRingBufDesc;
}
// =====================================================================================================================
// Get the descriptor for tessellation factor (TF) buffer (TCS output)
Value *ShaderSystemValues::getTessFactorBufDesc() {
assert(m_shaderStage == ShaderStageTessControl);
if (!m_tfBufDesc) {
// Ensure we have got the global table pointer first, and insert new code after that.
BuilderBase builder(getInternalGlobalTablePtr()->getNextNode());
m_tfBufDesc = loadDescFromDriverTable(SiDrvTableTfBufferOffs, builder);
}
return m_tfBufDesc;
}
// =====================================================================================================================
// Extract value of primitive ID (TCS)
Value *ShaderSystemValues::getPrimitiveId() {
assert(m_shaderStage == ShaderStageTessControl);
if (!m_primitiveId) {
auto intfData = m_pipelineState->getShaderInterfaceData(m_shaderStage);
m_primitiveId = getFunctionArgument(m_entryPoint, intfData->entryArgIdxs.tcs.patchId, "patchId");
}
return m_primitiveId;
}
// =====================================================================================================================
// Get invocation ID (TCS)
Value *ShaderSystemValues::getInvocationId() {
assert(m_shaderStage == ShaderStageTessControl);
if (!m_invocationId) {
auto insertPos = &*m_entryPoint->front().getFirstInsertionPt();
auto intfData = m_pipelineState->getShaderInterfaceData(m_shaderStage);
// invocationId = relPatchId[12:8]
Value *args[] = {getFunctionArgument(m_entryPoint, intfData->entryArgIdxs.tcs.relPatchId, "relPatchId"),
ConstantInt::get(Type::getInt32Ty(*m_context), 8),
ConstantInt::get(Type::getInt32Ty(*m_context), 5)};
m_invocationId =
emitCall("llvm.amdgcn.ubfe.i32", Type::getInt32Ty(*m_context), args, Attribute::ReadNone, insertPos);
}
return m_invocationId;
}
// =====================================================================================================================
// Get relative patchId (TCS)
Value *ShaderSystemValues::getRelativeId() {
assert(m_shaderStage == ShaderStageTessControl);
if (!m_relativeId) {
auto insertPos = &*m_entryPoint->front().getFirstInsertionPt();
auto intfData = m_pipelineState->getShaderInterfaceData(m_shaderStage);
auto relPatchId = getFunctionArgument(m_entryPoint, intfData->entryArgIdxs.tcs.relPatchId, "relPatchId");
// relativeId = relPatchId[7:0]
m_relativeId =
BinaryOperator::CreateAnd(relPatchId, ConstantInt::get(Type::getInt32Ty(*m_context), 0xFF), "", insertPos);
}
return m_relativeId;
}
// =====================================================================================================================
// Get offchip LDS descriptor (TCS and TES)
Value *ShaderSystemValues::getOffChipLdsDesc() {
assert(m_shaderStage == ShaderStageTessControl || m_shaderStage == ShaderStageTessEval);
if (!m_offChipLdsDesc) {
// Ensure we have got the global table pointer first, and insert new code after that.
BuilderBase builder(getInternalGlobalTablePtr()->getNextNode());
m_offChipLdsDesc = loadDescFromDriverTable(SiDrvTableHsBuffeR0Offs, builder);
}
return m_offChipLdsDesc;
}
// =====================================================================================================================
// Get tessellated coordinate (TES)
Value *ShaderSystemValues::getTessCoord() {
assert(m_shaderStage == ShaderStageTessEval);
if (!m_tessCoord) {
auto insertPos = &*m_entryPoint->front().getFirstInsertionPt();
auto intfData = m_pipelineState->getShaderInterfaceData(m_shaderStage);
Value *tessCoordX = getFunctionArgument(m_entryPoint, intfData->entryArgIdxs.tes.tessCoordX, "tessCoordX");
Value *tessCoordY = getFunctionArgument(m_entryPoint, intfData->entryArgIdxs.tes.tessCoordY, "tessCoordY");
Value *tessCoordZ = BinaryOperator::CreateFAdd(tessCoordX, tessCoordY, "", insertPos);
tessCoordZ =
BinaryOperator::CreateFSub(ConstantFP::get(Type::getFloatTy(*m_context), 1.0f), tessCoordZ, "", insertPos);
auto primitiveMode = m_pipelineState->getShaderModes()->getTessellationMode().primitiveMode;
tessCoordZ =
primitiveMode == PrimitiveMode::Triangles ? tessCoordZ : ConstantFP::get(Type::getFloatTy(*m_context), 0.0f);
m_tessCoord = UndefValue::get(FixedVectorType::get(Type::getFloatTy(*m_context), 3));
m_tessCoord = InsertElementInst::Create(m_tessCoord, tessCoordX, ConstantInt::get(Type::getInt32Ty(*m_context), 0),
"", insertPos);
m_tessCoord = InsertElementInst::Create(m_tessCoord, tessCoordY, ConstantInt::get(Type::getInt32Ty(*m_context), 1),
"", insertPos);
m_tessCoord = InsertElementInst::Create(m_tessCoord, tessCoordZ, ConstantInt::get(Type::getInt32Ty(*m_context), 2),
"", insertPos);
}
return m_tessCoord;
}
// =====================================================================================================================
// Get ES -> GS offsets (GS in)
Value *ShaderSystemValues::getEsGsOffsets() {
assert(m_shaderStage == ShaderStageGeometry);
if (!m_esGsOffsets) {
auto insertPos = &*m_entryPoint->front().getFirstInsertionPt();
auto intfData = m_pipelineState->getShaderInterfaceData(m_shaderStage);
m_esGsOffsets = UndefValue::get(FixedVectorType::get(Type::getInt32Ty(*m_context), 6));
for (unsigned i = 0; i < InterfaceData::MaxEsGsOffsetCount; ++i) {
auto esGsOffset =
getFunctionArgument(m_entryPoint, intfData->entryArgIdxs.gs.esGsOffsets[i], Twine("esGsOffset") + Twine(i));
m_esGsOffsets = InsertElementInst::Create(m_esGsOffsets, esGsOffset,
ConstantInt::get(Type::getInt32Ty(*m_context), i), "", insertPos);
}
}
return m_esGsOffsets;
}
// =====================================================================================================================
// Get GS -> VS ring buffer descriptor (GS out and copy shader in)
//
// @param streamId : Stream ID, always 0 for copy shader
Value *ShaderSystemValues::getGsVsRingBufDesc(unsigned streamId) {
assert(m_shaderStage == ShaderStageGeometry || m_shaderStage == ShaderStageCopyShader);
if (m_gsVsRingBufDescs.size() <= streamId)
m_gsVsRingBufDescs.resize(streamId + 1);
if (!m_gsVsRingBufDescs[streamId]) {
// Ensure we have got the global table pointer first, and insert new code after that.
BuilderBase builder(getInternalGlobalTablePtr()->getNextNode());
if (m_shaderStage == ShaderStageGeometry) {
const auto resUsage = m_pipelineState->getShaderResourceUsage(m_shaderStage);
// Geometry shader, using GS-VS ring for output.
Value *desc = loadDescFromDriverTable(SiDrvTableGsRingOuT0Offs + streamId, builder);
unsigned outLocStart = 0;
for (int i = 0; i < streamId; ++i)
outLocStart += resUsage->inOutUsage.gs.outLocCount[i];
// streamSize[streamId] = outLocCount[streamId] * 4 * sizeof(unsigned)
// streamOffset = (streamSize[0] + ... + streamSize[streamId - 1]) * 64 * outputVertices
unsigned baseAddr = outLocStart * m_pipelineState->getShaderModes()->getGeometryShaderMode().outputVertices *
sizeof(unsigned) * 4 * 64;
// Patch GS-VS ring buffer descriptor base address for GS output
Value *gsVsOutRingBufDescElem0 = builder.CreateExtractElement(desc, (uint64_t)0);
gsVsOutRingBufDescElem0 = builder.CreateAdd(gsVsOutRingBufDescElem0, builder.getInt32(baseAddr));
desc = builder.CreateInsertElement(desc, gsVsOutRingBufDescElem0, (uint64_t)0);
// Patch GS-VS ring buffer descriptor stride for GS output
Value *gsVsRingBufDescElem1 = builder.CreateExtractElement(desc, (uint64_t)1);
// Clear stride in SRD dword1
SqBufRsrcWord1 strideClearMask = {};
strideClearMask.u32All = UINT32_MAX;
strideClearMask.bits.stride = 0;
gsVsRingBufDescElem1 = builder.CreateAnd(gsVsRingBufDescElem1, builder.getInt32(strideClearMask.u32All));
// Calculate and set stride in SRD dword1
unsigned gsVsStride = m_pipelineState->getShaderModes()->getGeometryShaderMode().outputVertices *
resUsage->inOutUsage.gs.outLocCount[streamId] * sizeof(unsigned) * 4;
SqBufRsrcWord1 strideSetValue = {};
strideSetValue.bits.stride = gsVsStride;
gsVsRingBufDescElem1 = builder.CreateOr(gsVsRingBufDescElem1, builder.getInt32(strideSetValue.u32All));
desc = builder.CreateInsertElement(desc, gsVsRingBufDescElem1, (uint64_t)1);
if (m_pipelineState->getTargetInfo().getGfxIpVersion().major >= 8) {
// NOTE: For GFX8+, we have to explicitly set DATA_FORMAT for GS-VS ring buffer descriptor.
desc = setRingBufferDataFormat(desc, BUF_DATA_FORMAT_32, builder);
}
m_gsVsRingBufDescs[streamId] = desc;
} else {
// Copy shader, using GS-VS ring for input.
assert(streamId == 0);
m_gsVsRingBufDescs[streamId] = loadDescFromDriverTable(SiDrvTableVsRingInOffs, builder);
}
}
return m_gsVsRingBufDescs[streamId];
}
// =====================================================================================================================
// Get pointers to emit counters (GS)
ArrayRef<Value *> ShaderSystemValues::getEmitCounterPtr() {
assert(m_shaderStage == ShaderStageGeometry);
if (m_emitCounterPtrs.empty()) {
// TODO: We should only insert those offsets required by the specified input primitive.
// Setup GS emit vertex counter
auto &dataLayout = m_entryPoint->getParent()->getDataLayout();
auto insertPos = &*m_entryPoint->front().getFirstInsertionPt();
for (int i = 0; i < MaxGsStreams; ++i) {
auto emitCounterPtr =
new AllocaInst(Type::getInt32Ty(*m_context), dataLayout.getAllocaAddrSpace(), "", insertPos);
new StoreInst(ConstantInt::get(Type::getInt32Ty(*m_context), 0), emitCounterPtr, insertPos);
m_emitCounterPtrs.push_back(emitCounterPtr);
}
}
return m_emitCounterPtrs;
}
// =====================================================================================================================
// Get internal global table pointer as pointer to i8.
Instruction *ShaderSystemValues::getInternalGlobalTablePtr() {
if (!m_internalGlobalTablePtr) {
auto ptrTy = Type::getInt8Ty(*m_context)->getPointerTo(ADDR_SPACE_CONST);
// Global table is always the first function argument
m_internalGlobalTablePtr = makePointer(getFunctionArgument(m_entryPoint, 0, "globalTable"), ptrTy, InvalidValue);
}
return m_internalGlobalTablePtr;
}
// =====================================================================================================================
// Get internal per shader table pointer as pointer to i8.
Value *ShaderSystemValues::getInternalPerShaderTablePtr() {
if (!m_internalPerShaderTablePtr) {
auto ptrTy = Type::getInt8Ty(*m_context)->getPointerTo(ADDR_SPACE_CONST);
// Per shader table is always the second function argument
m_internalPerShaderTablePtr =
makePointer(getFunctionArgument(m_entryPoint, 1, "perShaderTable"), ptrTy, InvalidValue);
}
return m_internalPerShaderTablePtr;
}
// =====================================================================================================================
// Get stream-out buffer descriptor
//
// @param xfbBuffer : Transform feedback buffer ID
Value *ShaderSystemValues::getStreamOutBufDesc(unsigned xfbBuffer) {
if (m_streamOutBufDescs.size() <= xfbBuffer)
m_streamOutBufDescs.resize(xfbBuffer + 1);
if (!m_streamOutBufDescs[xfbBuffer]) {
auto streamOutTablePtr = getStreamOutTablePtr();
auto insertPos = streamOutTablePtr->getNextNode();
Value *idxs[] = {ConstantInt::get(Type::getInt64Ty(*m_context), 0),
ConstantInt::get(Type::getInt64Ty(*m_context), xfbBuffer)};
auto streamOutBufDescPtr = GetElementPtrInst::Create(nullptr, streamOutTablePtr, idxs, "", insertPos);
streamOutBufDescPtr->setMetadata(MetaNameUniform, MDNode::get(streamOutBufDescPtr->getContext(), {}));
auto streamOutBufDescTy = streamOutBufDescPtr->getType()->getPointerElementType();
auto streamOutBufDesc = new LoadInst(streamOutBufDescTy, streamOutBufDescPtr, "", false, Align(16), insertPos);
streamOutBufDesc->setMetadata(LLVMContext::MD_invariant_load, MDNode::get(streamOutBufDesc->getContext(), {}));
m_streamOutBufDescs[xfbBuffer] = streamOutBufDesc;
}
return m_streamOutBufDescs[xfbBuffer];
}
// =====================================================================================================================
// Get stream-out buffer table pointer
Instruction *ShaderSystemValues::getStreamOutTablePtr() {
assert(m_shaderStage == ShaderStageVertex || m_shaderStage == ShaderStageTessEval ||
m_shaderStage == ShaderStageCopyShader);
if (!m_streamOutTablePtr) {
auto intfData = m_pipelineState->getShaderInterfaceData(m_shaderStage);
unsigned entryArgIdx = 0;
// Get the SGPR number of the stream-out table pointer.
switch (m_shaderStage) {
case ShaderStageVertex:
entryArgIdx = intfData->entryArgIdxs.vs.streamOutData.tablePtr;
break;
case ShaderStageTessEval:
entryArgIdx = intfData->entryArgIdxs.tes.streamOutData.tablePtr;
break;
case ShaderStageCopyShader:
entryArgIdx = intfData->userDataUsage.gs.copyShaderStreamOutTable;
break;
default:
llvm_unreachable("Should never be called!");
break;
}
assert(entryArgIdx != 0);
// Get the 64-bit extended node value.
auto streamOutTablePtrLow = getFunctionArgument(m_entryPoint, entryArgIdx, "streamOutTable");
auto streamOutTablePtrTy = PointerType::get(
ArrayType::get(FixedVectorType::get(Type::getInt32Ty(*m_context), 4), MaxTransformFeedbackBuffers),
ADDR_SPACE_CONST);
m_streamOutTablePtr = makePointer(streamOutTablePtrLow, streamOutTablePtrTy, InvalidValue);
}
return m_streamOutTablePtr;
}
// =====================================================================================================================
// Make 64-bit pointer of specified type from 32-bit int, extending with the specified value, or PC if InvalidValue
//
// @param lowValue : 32-bit int value to extend
// @param ptrTy : Type that result pointer needs to be
// @param highValue : Value to use for high part, or InvalidValue to use PC
Instruction *ShaderSystemValues::makePointer(Value *lowValue, Type *ptrTy, unsigned highValue) {
// Insert extending code after pLowValue if it is an instruction.
Instruction *insertPos = nullptr;
auto lowValueInst = dyn_cast<Instruction>(lowValue);
if (lowValueInst)
insertPos = lowValueInst->getNextNode();
else
insertPos = &*m_entryPoint->front().getFirstInsertionPt();
Value *extendedPtrValue = nullptr;
if (highValue == InvalidValue) {
// Use PC.
if (!m_pc || isa<Instruction>(lowValue)) {
// Either
// 1. there is no existing code to s_getpc and cast it, or
// 2. there is existing code, but pLowValue is an instruction, so it is more complex to figure
// out whether it is before or after pLowValue in the code. We generate new s_getpc code anyway
// and rely on subsequent CSE to common it up.
// Insert the s_getpc code at the start of the function, so a later call into here knows it can
// reuse this PC if its pLowValue is an arg rather than an instruction.
auto pcInsertPos = &*m_entryPoint->front().getFirstInsertionPt();
Value *pc = emitCall("llvm.amdgcn.s.getpc", Type::getInt64Ty(*m_context), ArrayRef<Value *>(), {}, pcInsertPos);
m_pc = new BitCastInst(pc, FixedVectorType::get(Type::getInt32Ty(*m_context), 2), "", insertPos);
} else
insertPos = m_pc->getNextNode();
extendedPtrValue = m_pc;
} else {
// Use constant highValue value.
Constant *elements[] = {UndefValue::get(lowValue->getType()), ConstantInt::get(lowValue->getType(), highValue)};
extendedPtrValue = ConstantVector::get(elements);
}
extendedPtrValue = InsertElementInst::Create(extendedPtrValue, lowValue,
ConstantInt::get(Type::getInt32Ty(*m_context), 0), "", insertPos);
extendedPtrValue =
CastInst::Create(Instruction::BitCast, extendedPtrValue, Type::getInt64Ty(*m_context), "", insertPos);
return CastInst::Create(Instruction::IntToPtr, extendedPtrValue, ptrTy, "", insertPos);
}
// =====================================================================================================================
// Load descriptor from driver table.
// If the caller sets builder's insert point to the start of the function, it should ensure that it first calls
// getInternalGlobalTablePtr(). Otherwise there is a danger that code is inserted in the wrong order, giving
// invalid IR.
//
// @param tableOffset : Byte offset in driver table
// @param builder : Builder to use for insertion
Instruction *ShaderSystemValues::loadDescFromDriverTable(unsigned tableOffset, BuilderBase &builder) {
auto globalTable = getInternalGlobalTablePtr();
Type *descTy = FixedVectorType::get(builder.getInt32Ty(), 4);
globalTable = cast<Instruction>(builder.CreateBitCast(globalTable, descTy->getPointerTo(ADDR_SPACE_CONST)));
Value *descPtr = builder.CreateGEP(descTy, globalTable, builder.getInt32(tableOffset));
LoadInst *desc = builder.CreateLoad(descTy, descPtr);
return desc;
}
// =====================================================================================================================
// Explicitly set the DATA_FORMAT of ring buffer descriptor.
//
// @param bufDesc : Buffer Descriptor
// @param dataFormat : Data format
// @param builder : Builder to use for inserting instructions
Value *ShaderSystemValues::setRingBufferDataFormat(Value *bufDesc, unsigned dataFormat, BuilderBase &builder) const {
Value *elem3 = builder.CreateExtractElement(bufDesc, (uint64_t)3);
SqBufRsrcWord3 dataFormatClearMask;
dataFormatClearMask.u32All = UINT32_MAX;
// TODO: This code needs to be fixed for gfx10; buffer format is handled differently.
dataFormatClearMask.gfx6.dataFormat = 0;
elem3 = builder.CreateAnd(elem3, builder.getInt32(dataFormatClearMask.u32All));
SqBufRsrcWord3 dataFormatSetValue = {};
dataFormatSetValue.gfx6.dataFormat = dataFormat;
elem3 = builder.CreateOr(elem3, builder.getInt32(dataFormatSetValue.u32All));
return builder.CreateInsertElement(bufDesc, elem3, (uint64_t)3);
}
// =====================================================================================================================
// Find resource node by descriptor set ID
//
// @param descSet : Descriptor set to find
unsigned ShaderSystemValues::findResourceNodeByDescSet(unsigned descSet) {
auto userDataNodes = m_pipelineState->getUserDataNodes();
for (unsigned i = 0; i < userDataNodes.size(); ++i) {
auto node = &userDataNodes[i];
if (node->type == ResourceNodeType::DescriptorTableVaPtr && node->innerTable[0].set == descSet)
return i;
}
return InvalidValue;
}
// =====================================================================================================================
// Test if shadow descriptor table is enabled
bool ShaderSystemValues::isShadowDescTableEnabled() const {
return m_pipelineState->getOptions().shadowDescriptorTable != ShadowDescriptorTableDisable;
}
| 48.954357 | 120 | 0.638201 | yjaelex |
baf152b3b1e5e183e9ec41271d3a9037faf84ed2 | 8,180 | hpp | C++ | src/storage_manager/http.hpp | publiqnet/publiq.pp | 0865494edaa22ea2e3238aaf01cdb9e457535933 | [
"MIT"
] | 4 | 2019-11-20T17:27:57.000Z | 2021-01-05T09:46:20.000Z | src/storage_manager/http.hpp | publiqnet/publiq.pp | 0865494edaa22ea2e3238aaf01cdb9e457535933 | [
"MIT"
] | null | null | null | src/storage_manager/http.hpp | publiqnet/publiq.pp | 0865494edaa22ea2e3238aaf01cdb9e457535933 | [
"MIT"
] | 2 | 2019-01-10T14:10:26.000Z | 2020-03-01T05:55:05.000Z | #pragma once
#include "storage_manager_message.hpp"
#include <belt.pp/global.hpp>
#include <belt.pp/parser.hpp>
#include <belt.pp/http.hpp>
#include <string>
#include <vector>
#include <utility>
#include <unordered_map>
#include <set>
using std::string;
using std::vector;
using std::pair;
using std::unordered_map;
namespace storage_manager
{
namespace http
{
string check_arguments(unordered_map<string, string>& arguments,
std::set<string> const& all_arguments,
std::set<string> const& ui64_arguments)
{
for (auto const& it : arguments)
if (it.second.empty() ||
all_arguments.find(it.first) == all_arguments.end())
return "invalid argument: " + it.first;
size_t pos;
for (auto const& it : ui64_arguments)
if (arguments.find(it) != arguments.end())
{
beltpp::stoui64(arguments[it], pos);
if (arguments[it].size() != pos)
return "invalid argument: " + it + " " + arguments[it];
}
return string();
}
beltpp::detail::pmsg_all request_failed(string const& message)
{
auto p = ::beltpp::new_void_unique_ptr<ManagerMessage::Failed>();
ManagerMessage::Failed & ref = *reinterpret_cast<ManagerMessage::Failed*>(p.get());
ref.message = message;
return ::beltpp::detail::pmsg_all(ManagerMessage::Failed::rtt,
std::move(p),
&ManagerMessage::Failed::pvoid_saver);
}
inline
string response(beltpp::detail::session_special_data& ssd,
beltpp::packet const& pc)
{
if (pc.type() == ManagerMessage::Failed::rtt)
return beltpp::http::http_not_found(ssd, pc.to_string());
else
return beltpp::http::http_response(ssd, pc.to_string());
}
template <beltpp::detail::pmsg_all (*fallback_message_list_load)(
std::string::const_iterator&,
std::string::const_iterator const&,
beltpp::detail::session_special_data&,
void*)>
beltpp::detail::pmsg_all message_list_load(
std::string::const_iterator& iter_scan_begin,
std::string::const_iterator const& iter_scan_end,
beltpp::detail::session_special_data& ssd,
void* putl)
{
auto it_fallback = iter_scan_begin;
ssd.session_specal_handler = nullptr;
ssd.autoreply.clear();
auto protocol_error = [&iter_scan_begin, &iter_scan_end, &ssd]()
{
ssd.session_specal_handler = nullptr;
ssd.autoreply.clear();
iter_scan_begin = iter_scan_end;
return ::beltpp::detail::pmsg_all(size_t(-2),
::beltpp::void_unique_nullptr(),
nullptr);
};
string posted;
auto result = beltpp::http::protocol(ssd,
iter_scan_begin,
iter_scan_end,
it_fallback,
10 * 1024, // enough length
64 * 1024, // header max size
10 * 1024 * 1024, // content max size
posted);
auto code = result.first;
auto& ss = result.second;
if (code == beltpp::e_three_state_result::error &&
ss.status == beltpp::http::detail::scan_status::clean)
{
return fallback_message_list_load(iter_scan_begin, iter_scan_end, ssd, putl);
}
else if (code == beltpp::e_three_state_result::error)
return protocol_error();
else if (code == beltpp::e_three_state_result::attempt)
{
iter_scan_begin = it_fallback;
return ::beltpp::detail::pmsg_all(size_t(-1),
::beltpp::void_unique_nullptr(),
nullptr);
}
else// if (code == beltpp::e_three_state_result::success)
{
ssd.session_specal_handler = &response;
ssd.autoreply.clear();
if (ss.type == beltpp::http::detail::scan_status::get &&
ss.resource.path.size() == 2 &&
ss.resource.path.front() == "import")
{
auto p = ::beltpp::new_void_unique_ptr<ManagerMessage::ImportStorageRequest>();
ManagerMessage::ImportStorageRequest& ref = *reinterpret_cast<ManagerMessage::ImportStorageRequest*>(p.get());
ref.address = ss.resource.path.back();
return ::beltpp::detail::pmsg_all(ManagerMessage::ImportStorageRequest::rtt,
std::move(p),
&ManagerMessage::ImportStorageRequest::pvoid_saver);
}
if (ss.type == beltpp::http::detail::scan_status::get &&
ss.resource.path.size() == 2 &&
ss.resource.path.front() == "clear")
{
auto p = ::beltpp::new_void_unique_ptr<ManagerMessage::ClearStorageRequest>();
ManagerMessage::ClearStorageRequest& ref = *reinterpret_cast<ManagerMessage::ClearStorageRequest*>(p.get());
ref.address = ss.resource.path.back();
return ::beltpp::detail::pmsg_all(ManagerMessage::ClearStorageRequest::rtt,
std::move(p),
&ManagerMessage::ClearStorageRequest::pvoid_saver);
}
else if (ss.type == beltpp::http::detail::scan_status::get &&
ss.resource.path.size() == 1 &&
ss.resource.path.front() == "head_block")
{
auto p = ::beltpp::new_void_unique_ptr<ManagerMessage::HeadBlockRequest>();
return ::beltpp::detail::pmsg_all(ManagerMessage::HeadBlockRequest::rtt,
std::move(p),
&ManagerMessage::HeadBlockRequest::pvoid_saver);
}
else if (ss.type == beltpp::http::detail::scan_status::get &&
ss.resource.path.size() == 1 &&
ss.resource.path.front() == "storages")
{
auto p = ::beltpp::new_void_unique_ptr<ManagerMessage::StoragesRequest>();
return ::beltpp::detail::pmsg_all(ManagerMessage::StoragesRequest::rtt,
std::move(p),
&ManagerMessage::StoragesRequest::pvoid_saver);
}
else if (ss.type == beltpp::http::detail::scan_status::get &&
ss.resource.path.size() == 1 &&
ss.resource.path.front() == "protocol")
{
ssd.session_specal_handler = nullptr;
ssd.autoreply = beltpp::http::http_response(ssd, ManagerMessage::detail::meta_json_schema());
return ::beltpp::detail::pmsg_all(size_t(-1),
::beltpp::void_unique_nullptr(),
nullptr);
}
else
{
ssd.session_specal_handler = nullptr;
string message("noo! \r\n");
for (auto const& dir : ss.resource.path)
message += "/" + dir;
message += "\r\n";
for (auto const& arg : ss.resource.arguments)
message += (arg.first + ": " + arg.second + "\r\n");
message += "\r\n";
message += "\r\n";
for (auto const& prop : ss.resource.properties)
message += (prop.first + ": " + prop.second + "\r\n");
message += "that's an error! \r\n";
message += "here's the protocol, by the way \r\n";
ssd.autoreply = beltpp::http::http_not_found(ssd,
message +
ManagerMessage::detail::meta_json_schema());
return ::beltpp::detail::pmsg_all(size_t(-1),
::beltpp::void_unique_nullptr(),
nullptr);
}
}
}
}
}
| 39.326923 | 122 | 0.52335 | publiqnet |
baf546b2a628f8a072563078937e6d0832273155 | 1,609 | cpp | C++ | dynamic/wrappers/cell_based/ChemotacticForce2.cppwg.cpp | jmsgrogan/PyChaste | 48a9863d2c941c71e47ecb72e917b477ba5c1413 | [
"FTL"
] | 6 | 2017-02-04T16:10:53.000Z | 2021-07-01T08:03:16.000Z | dynamic/wrappers/cell_based/ChemotacticForce2.cppwg.cpp | jmsgrogan/PyChaste | 48a9863d2c941c71e47ecb72e917b477ba5c1413 | [
"FTL"
] | 6 | 2017-06-22T08:50:41.000Z | 2019-12-15T20:17:29.000Z | dynamic/wrappers/cell_based/ChemotacticForce2.cppwg.cpp | jmsgrogan/PyChaste | 48a9863d2c941c71e47ecb72e917b477ba5c1413 | [
"FTL"
] | 3 | 2017-05-15T21:33:58.000Z | 2019-10-27T21:43:07.000Z | #include <pybind11/pybind11.h>
#include <pybind11/stl.h>
#include <set>
#include <vector>
#include <string>
#include <map>
#include "SmartPointers.hpp"
#include "UblasIncludes.hpp"
#include "ChemotacticForce.hpp"
#include "ChemotacticForce2.cppwg.hpp"
namespace py = pybind11;
typedef ChemotacticForce<2 > ChemotacticForce2;
PYBIND11_DECLARE_HOLDER_TYPE(T, boost::shared_ptr<T>);
class ChemotacticForce2_Overloads : public ChemotacticForce2{
public:
using ChemotacticForce2::ChemotacticForce;
void AddForceContribution(::AbstractCellPopulation<2, 2> & rCellPopulation) override {
PYBIND11_OVERLOAD(
void,
ChemotacticForce2,
AddForceContribution,
rCellPopulation);
}
void OutputForceParameters(::out_stream & rParamsFile) override {
PYBIND11_OVERLOAD(
void,
ChemotacticForce2,
OutputForceParameters,
rParamsFile);
}
};
void register_ChemotacticForce2_class(py::module &m){
py::class_<ChemotacticForce2 , ChemotacticForce2_Overloads , boost::shared_ptr<ChemotacticForce2 > , AbstractForce<2, 2> >(m, "ChemotacticForce2")
.def(py::init< >())
.def(
"AddForceContribution",
(void(ChemotacticForce2::*)(::AbstractCellPopulation<2, 2> &)) &ChemotacticForce2::AddForceContribution,
" " , py::arg("rCellPopulation") )
.def(
"OutputForceParameters",
(void(ChemotacticForce2::*)(::out_stream &)) &ChemotacticForce2::OutputForceParameters,
" " , py::arg("rParamsFile") )
;
}
| 32.836735 | 148 | 0.665009 | jmsgrogan |
baf70d487dec5c8c6102af5beb29d004a60a5428 | 11,458 | cpp | C++ | ChaosDataExport/cde.cpp | fast01/chaosframework | 28194bcca5f976fd5cf61448ca84ce545e94d822 | [
"Apache-2.0"
] | 2 | 2020-04-16T13:20:57.000Z | 2021-06-24T02:05:25.000Z | ChaosDataExport/cde.cpp | fast01/chaosframework | 28194bcca5f976fd5cf61448ca84ce545e94d822 | [
"Apache-2.0"
] | null | null | null | ChaosDataExport/cde.cpp | fast01/chaosframework | 28194bcca5f976fd5cf61448ca84ce545e94d822 | [
"Apache-2.0"
] | null | null | null | /*
* cde.cpp
* !CHOAS
* Created by Bisegni Claudio.
*
* Copyright 2012 INFN, National Institute of Nuclear Physics
*
* 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 <stdio.h>
#include <iostream>
#include <fstream>
#include <unistd.h>
#include <sstream>
#include <chaos/common/bson/util/base64.h>
#include <chaos/common/utility/TimingUtil.h>
#include <chaos/common/network/CNodeNetworkAddress.h>
#include <chaos/ui_toolkit/ChaosUIToolkit.h>
#include <chaos/ui_toolkit/LowLevelApi/LLRpcApi.h>
#include <chaos/ui_toolkit/HighLevelApi/HLDataApi.h>
#include <chaos/common/bson/bson.h>
#include <boost/date_time/posix_time/posix_time.hpp>
#include <boost/date_time/c_local_time_adjustor.hpp>
using namespace std;
using namespace chaos;
using namespace chaos::ui;
using namespace bson;
using namespace boost;
#define OPT_CU_ID "device-id"
#define OPT_TIMEOUT "timeout"
#define OPT_DST_TARGET "dest-target"
#define OPT_DST_FILE "dest-file"
#define OPT_DST_TYPE "dest-type"
#define OPT_START_TIME "start-time"
#define OPT_END_TIME "end-time"
void sendBackOnRow() {
std::cout << "\r" <<std::flush;
}
void sendBackForNPos(int position = 1) {
for(int i = 0; i < position; i++) {
std::cout << "\b";
}
std::cout << std::flush;
}
void printPercendDone(int percend_done) {
std::cout << " " << setfill('0') << setw(3) << percend_done << "% " <<std::flush;
}
void printStat(chaos::common::io::QueryFuture *query_future) {
std::cout << "--------------------------------------------------------------------------" << std::endl;
std::cout << "Total found: " << query_future->getTotalElementFound() <<std::endl;
std::cout << "Last element fetched: " << query_future->getCurrentElementIndex() <<std::endl;
std::cout << "Error code: " << query_future->getError() <<std::endl;
std::cout << "Error message: " << query_future->getErrorMessage() <<std::endl;
std::cout << "--------------------------------------------------------------------------" << std::endl;
}
void printStep() {
std::cout << "." <<std::flush;
}
int computePercent(uint64_t done, uint64_t all) {
int result = ((double)done/(double)all)*100;
return result;
}
chaos::common::data::SerializationBuffer *getCSVDecoding( DeviceController& controller, const std::vector<std::string>& output_element_name, CDataWrapper& data_pack) {
chaos::common::data::SerializationBuffer *result = NULL;
std::stringstream csv_lin;
chaos::common::data::RangeValueInfo attribute_info;
int idx = 0;
for(std::vector<std::string>::const_iterator it = output_element_name.begin();
it < output_element_name.end();
it++){
//fetch the type
controller.getDeviceAttributeRangeValueInfo(*it, attribute_info);
//write the data in csv way
switch(attribute_info.valueType){
case DataType::TYPE_BOOLEAN:{
if(data_pack.hasKey((*it).c_str())){
csv_lin << data_pack.getBoolValue((*it).c_str());
}
break;
}
case DataType::TYPE_BYTEARRAY:{
int len;
std::stringstream binary_field;
const char * base_addr = data_pack.getBinaryValue((*it).c_str(), len);
bson::base64::encode( binary_field , base_addr , len );
csv_lin << binary_field.str();
break;
}
case DataType::TYPE_DOUBLE:
if(data_pack.hasKey((*it).c_str())){
csv_lin << data_pack.getDoubleValue((*it).c_str());
}
break;
case DataType::TYPE_INT32:{
if(data_pack.hasKey((*it).c_str())){
csv_lin << data_pack.getInt32Value((*it).c_str());
}
break;
}
case DataType::TYPE_INT64:{
if(data_pack.hasKey((*it).c_str())){
csv_lin << data_pack.getInt64Value((*it).c_str());
}
break;
}
case DataType::TYPE_STRING:{
if(data_pack.hasKey((*it).c_str())){
csv_lin << data_pack.getStringValue((*it).c_str());
}
break;
}
default:
break;
}
if(++idx < output_element_name.size()) {
csv_lin << ",";
}else{
csv_lin << std::endl;
}
}
std::string line = csv_lin.str();
if(line.size()>0) {
result = new chaos::common::data::SerializationBuffer(line.c_str(), line.size());
}
return result;
}
int main(int argc, char* argv[])
{
char buf[255];
uint32_t timeout;
string device_id;
string dst_file;
unsigned int dest_type;
string start_time;
string end_time;
std::string err_str;
std::ostream *destination_stream = NULL;
std::ofstream destination_file;
uint64_t start_ts = 0;
uint64_t end_ts = 0;
int retry = 0;
uint32_t cicle_number = 0;
CDeviceNetworkAddress deviceNetworkAddress;
try{
std::cout << "\e[?25l";
//! [UIToolkit Attribute Init]
ChaosUIToolkit::getInstance()->getGlobalConfigurationInstance()->addOption<string>(OPT_CU_ID, "The identification string of the device", &device_id);
ChaosUIToolkit::getInstance()->getGlobalConfigurationInstance()->addOption<uint32_t>(OPT_TIMEOUT, "Timeout for wait the answer in milliseconds", 2000, &timeout);
ChaosUIToolkit::getInstance()->getGlobalConfigurationInstance()->addOption<unsigned int>(OPT_DST_TYPE, "Destination date type [binary(0), JSON(1), CSV(2)]", 0, &dest_type);
ChaosUIToolkit::getInstance()->getGlobalConfigurationInstance()->addOption<string>(OPT_DST_FILE, "Destination file for save found datapack", &dst_file);
ChaosUIToolkit::getInstance()->getGlobalConfigurationInstance()->addOption<string>(OPT_START_TIME, "Time for first datapack to find [format from %Y-%m-%dT%H:%M:%S.%f to %Y]", &start_time);
ChaosUIToolkit::getInstance()->getGlobalConfigurationInstance()->addOption<string>(OPT_END_TIME, "Time for last datapack to find [format from %Y-%m-%dT%H:%M:%S.%f to %Y]", &end_time);
//! [UIToolkit Attribute Init]
//! [UIToolkit Init]
ChaosUIToolkit::getInstance()->init(argc, argv);
//! [UIToolkit Init]
if(!ChaosUIToolkit::getInstance()->getGlobalConfigurationInstance()->hasOption(OPT_CU_ID)){
throw CException(-1, "invalid device identification string", "check param");
}
//get the timestamp for query boundary
if(ChaosUIToolkit::getInstance()->getGlobalConfigurationInstance()->hasOption(OPT_START_TIME)){
if(!chaos::TimingUtil::dateWellFormat(start_time)) {
throw CException(-2, "Invalid star date format", "check date");
}
start_ts = chaos::TimingUtil::getTimestampFromString(start_time);
std::cout << "Set start data to"<< start_time << std::endl;
}
if(ChaosUIToolkit::getInstance()->getGlobalConfigurationInstance()->hasOption(OPT_END_TIME)){
if(!chaos::TimingUtil::dateWellFormat(end_time)) {
throw CException(-3, "Invalid end date format", "check date");
}
end_ts = chaos::TimingUtil::getTimestampFromString(end_time);
std::cout << "Set end data to"<< end_time << std::endl;
}
//get the timestamp for query boundary
if(!ChaosUIToolkit::getInstance()->getGlobalConfigurationInstance()->hasOption(OPT_DST_FILE)){
std::cout << "Auto destination file generation" << std::endl;
getcwd(buf, 255);
dst_file.assign(buf, strlen(buf));
dst_file += "/"+device_id;
switch(dest_type) {
case 0:
dst_file.append(".bin");
break;
case 1:
dst_file.append(".json");
break;
case 2:
dst_file.append(".cvs");
break;
}
}
std::basic_ios<char>::openmode dst_file_mode = ios_base::out;
if(dest_type) {
dst_file_mode |= ios_base::binary;
}
destination_file.open(dst_file.c_str(), dst_file_mode);
if(!destination_file.good()) {
err_str = "Error opening destination file ";
err_str.append(buf, strlen(buf));
throw CException(-4, err_str, string("check param"));
}
std::cout << "Destination file -> " << dst_file << std::endl;
destination_stream = &destination_file;
//we can allocate the channel
std::cout << "Acquiring controller" << std::endl;
DeviceController *controller = HLDataApi::getInstance()->getControllerForDeviceID(device_id, timeout);
if(!controller) throw CException(4, "Error allcoating decive controller", "device controller creation");
chaos::common::io::QueryFuture *query_future = NULL;
controller->executeTimeIntervallQuery(start_ts, end_ts, &query_future);
std::vector<std::string> output_element_name;
//fetche the output element of the device
controller->getDeviceDatasetAttributesName(output_element_name, DataType::Output);
//create header
if(dest_type == 2) {
//write header
int idx = 0;
for(std::vector<std::string>::const_iterator it = output_element_name.begin();
it < output_element_name.end();
it++){
(*destination_stream) << *it;
if(++idx < output_element_name.size()) {
(*destination_stream) << ",";
}
}
}
if(query_future) {
query_future->waitForBeginResult();
while(query_future->getState() ==chaos::common::io::QueryFutureStateStartResult ||
query_future->getState() ==chaos::common::io::QueryFutureStateReceivingResult){
auto_ptr<CDataWrapper> q_result(query_future->getDataPack(true, timeout));
if(q_result.get()) {
retry = 0;
auto_ptr<chaos::common::data::SerializationBuffer> ser;
//get serialization buffer by type
switch (dest_type) {
//BSON
case 0:{
ser.reset(q_result->getBSONData());
break;
}
//JSON
case 1:{
ser.reset(q_result->getJSONData());
break;
}
//CSV
case 2:{
ser.reset(getCSVDecoding(*controller, output_element_name, *q_result.get()));
break;
}
}
//write the data
if(ser.get())destination_stream->write(ser->getBufferPtr(), ser->getBufferLen());
} else {
break;
}
cicle_number++;
if(!(cicle_number % 10)) {
std::cout << "Exporting ";
printPercendDone(computePercent(query_future->getCurrentElementIndex(), query_future->getTotalElementFound()));
sendBackOnRow();
}
//print last percent
if(query_future->getState() != chaos::common::io::QueryFutureStateError) {
std::cout << "Exporting ";
printPercendDone(computePercent(query_future->getCurrentElementIndex(), query_future->getTotalElementFound()));
std::cout << std::endl;
}
};
//print the statistic
printStat(query_future);
std::cout << "Releasing query" << std::endl;
//release the query
controller->releaseQuery(query_future);
std::cout << "Releasing controller" << std::endl;
HLDataApi::getInstance()->disposeDeviceControllerPtr(controller);
}
} catch (CException& e) {
std::cerr << e.errorCode << " - "<< e.errorDomain << " - " << e.errorMessage << std::endl;
} catch (...) {
std::cerr << "General error " << std::endl;
}
std::cout << "\e[?25h";
try {
//! [UIToolkit Deinit]
ChaosUIToolkit::getInstance()->deinit();
//! [UIToolkit Deinit]
} catch (CException& e) {
std::cerr << e.errorCode << " - "<< e.errorDomain << " - " << e.errorMessage << std::endl;
}
std::cout << std::endl << "Export done"<< std::endl;
return 0;
}
| 32.551136 | 190 | 0.664863 | fast01 |
baf84171ccd7517f3ad14e35ca46e6e2ff7ba679 | 416 | cpp | C++ | Problems/053. Maximum Subarray/Test.cpp | DanielDFY/LeetCode | 5e39e3168db368617ac2f4509886f32cde5bd000 | [
"MIT"
] | null | null | null | Problems/053. Maximum Subarray/Test.cpp | DanielDFY/LeetCode | 5e39e3168db368617ac2f4509886f32cde5bd000 | [
"MIT"
] | null | null | null | Problems/053. Maximum Subarray/Test.cpp | DanielDFY/LeetCode | 5e39e3168db368617ac2f4509886f32cde5bd000 | [
"MIT"
] | null | null | null | #define CATCH_CONFIG_MAIN
#include "../../Utils/Cacth/single_include/catch2/catch.hpp"
#include "solution.h"
TEST_CASE("Maximum Subarray")
{
Solution s;
SECTION("normal input") {
vector<int> nums{ -2,1,-3,4,-1,2,1,-5,4 };
CHECK(s.maxSubArray(nums) == 6);
}
SECTION("all negative input") {
vector<int> nums{ -2,-3,-1,-5 };
CHECK(s.maxSubArray(nums) == -1);
}
} | 20.8 | 60 | 0.579327 | DanielDFY |
bafc24dd3f7ca071210da26f495db6f07d0cbc2e | 1,596 | cc | C++ | cc/dual_net/fake_dual_net.cc | VonRosenchild/minigo | 18d43c0950d3623ad33b9035ab91952b79f8c89c | [
"Apache-2.0"
] | 1 | 2019-10-10T06:09:32.000Z | 2019-10-10T06:09:32.000Z | cc/dual_net/fake_dual_net.cc | VonRosenchild/minigo | 18d43c0950d3623ad33b9035ab91952b79f8c89c | [
"Apache-2.0"
] | null | null | null | cc/dual_net/fake_dual_net.cc | VonRosenchild/minigo | 18d43c0950d3623ad33b9035ab91952b79f8c89c | [
"Apache-2.0"
] | 1 | 2019-10-10T06:09:19.000Z | 2019-10-10T06:09:19.000Z | // Copyright 2018 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include "cc/dual_net/fake_dual_net.h"
#include "absl/memory/memory.h"
#include "cc/logging.h"
namespace minigo {
FakeDualNet::FakeDualNet(absl::Span<const float> priors, float value)
: Model("fake", FeatureDescriptor::Create<AgzFeatures>(), 1),
value_(value) {
if (!priors.empty()) {
MG_CHECK(priors.size() == kNumMoves);
for (int i = 0; i < kNumMoves; ++i) {
priors_[i] = priors[i];
}
} else {
for (auto& prior : priors_) {
prior = 1.0 / kNumMoves;
}
}
}
void FakeDualNet::RunMany(const std::vector<const ModelInput*>& inputs,
std::vector<ModelOutput*>* outputs,
std::string* model) {
for (auto* output : *outputs) {
output->policy = priors_;
output->value = value_;
}
if (model != nullptr) {
*model = "FakeDualNet";
}
}
std::unique_ptr<Model> FakeDualNetFactory::NewModel(
const std::string& descriptor) {
return absl::make_unique<FakeDualNet>();
}
} // namespace minigo
| 29.018182 | 75 | 0.656642 | VonRosenchild |
bafdc567818c5adac16e10a4dc22a8f9ef5673d2 | 9,470 | cpp | C++ | Code/GraphMol/FragCatalog/test1.cpp | kazuyaujihara/rdkit | 06027dcd05674787b61f27ba46ec0d42a6037540 | [
"BSD-3-Clause"
] | 1,609 | 2015-01-05T02:41:13.000Z | 2022-03-30T21:57:24.000Z | Code/GraphMol/FragCatalog/test1.cpp | kazuyaujihara/rdkit | 06027dcd05674787b61f27ba46ec0d42a6037540 | [
"BSD-3-Clause"
] | 3,412 | 2015-01-06T12:13:33.000Z | 2022-03-31T17:25:41.000Z | Code/GraphMol/FragCatalog/test1.cpp | kazuyaujihara/rdkit | 06027dcd05674787b61f27ba46ec0d42a6037540 | [
"BSD-3-Clause"
] | 811 | 2015-01-11T03:33:48.000Z | 2022-03-28T11:57:49.000Z | // $Id$
//
// Copyright (C) 2003-2006 Rational Discovery LLC
//
// @@ All Rights Reserved @@
// This file is part of the RDKit.
// The contents are covered by the terms of the BSD license
// which is included in the file license.txt, found at the root
// of the RDKit source tree.
//
#include <RDGeneral/test.h>
#include <GraphMol/RDKitBase.h>
#include <GraphMol/RDKitQueries.h>
#include <RDGeneral/RDLog.h>
#include <GraphMol/SmilesParse/SmilesParse.h>
#include <GraphMol/SmilesParse/SmilesWrite.h>
#include "FragCatGenerator.h"
#include "FragCatalogEntry.h"
#include "FragCatParams.h"
#include "FragCatalogUtils.h"
#include "FragFPGenerator.h"
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <GraphMol/Subgraphs/SubgraphUtils.h>
#include <GraphMol/Subgraphs/Subgraphs.h>
#include <GraphMol/FileParsers/MolSupplier.h>
#include <RDGeneral/types.h>
#include <RDGeneral/FileParseException.h>
#include <DataStructs/BitVects.h>
using namespace RDKit;
void testMols(std::vector<std::unique_ptr<ROMol>> &mols, FragFPGenerator &fpGen,
FragCatalog &fcat) {
int nDone = 0;
for (auto &&mi : mols) {
ExplicitBitVect *fp = fpGen.getFPForMol(*mi, fcat);
switch (nDone) {
case 0:
TEST_ASSERT(fp->getNumOnBits() == 3);
TEST_ASSERT((*fp)[0]);
TEST_ASSERT((*fp)[1]);
TEST_ASSERT((*fp)[2]);
break;
case 1:
TEST_ASSERT(fp->getNumOnBits() == 2);
TEST_ASSERT((*fp)[1]);
TEST_ASSERT((*fp)[3]);
break;
case 2:
TEST_ASSERT(fp->getNumOnBits() == 3);
TEST_ASSERT((*fp)[1]);
TEST_ASSERT((*fp)[4]);
TEST_ASSERT((*fp)[5]);
break;
case 3:
TEST_ASSERT(fp->getNumOnBits() == 3);
TEST_ASSERT((*fp)[1]);
TEST_ASSERT((*fp)[6]);
TEST_ASSERT((*fp)[7]);
break;
case 4:
TEST_ASSERT(fp->getNumOnBits() == 2);
TEST_ASSERT((*fp)[0]);
TEST_ASSERT((*fp)[8]);
break;
case 5:
TEST_ASSERT(fp->getNumOnBits() == 3);
TEST_ASSERT((*fp)[0]);
TEST_ASSERT((*fp)[6]);
TEST_ASSERT((*fp)[9]);
break;
case 6:
TEST_ASSERT(fp->getNumOnBits() == 5);
TEST_ASSERT((*fp)[0]);
TEST_ASSERT((*fp)[1]);
TEST_ASSERT((*fp)[2]);
TEST_ASSERT((*fp)[3]);
TEST_ASSERT((*fp)[10]);
break;
}
delete fp;
nDone += 1;
}
}
void test1() {
std::string rdbase = getenv("RDBASE");
std::string fname = rdbase + "/Code/GraphMol/FragCatalog/test_data/mols.smi";
std::string fgrpFile =
rdbase + "/Code/GraphMol/FragCatalog/test_data/funcGroups.txt";
SmilesMolSupplier suppl(fname, " ", 0, 1, false);
auto *fparams = new FragCatParams(1, 6, fgrpFile, 1.0e-8);
TEST_ASSERT(fparams->getNumFuncGroups() == 15);
FragCatalog fcat(fparams);
FragCatGenerator catGen;
std::vector<std::unique_ptr<ROMol>> mols;
unsigned int nDone = 0;
ROMol *m = suppl.next();
while (m) {
mols.push_back(std::unique_ptr<ROMol>(m));
nDone += 1;
catGen.addFragsFromMol(*m, &fcat);
try {
m = suppl.next();
} catch (FileParseException &) {
m = nullptr;
}
}
TEST_ASSERT(mols.size() == 16);
TEST_ASSERT(nDone == 16);
int nents = fcat.getNumEntries();
std::cerr << " " << nents << std::endl;
TEST_ASSERT(nents == 21);
FragFPGenerator fpGen;
BOOST_LOG(rdInfoLog) << "----- Test 1" << std::endl;
testMols(mols, fpGen, fcat);
BOOST_LOG(rdInfoLog) << "---- Done" << std::endl;
//----------------------------------------------------------
// SERIALIZATION TESTS
//----------------------------------------------------------
// make sure we can pickle and unpickle parameter objects:
FragCatParams newParams;
std::string pickle = fparams->Serialize();
newParams.initFromString(pickle);
TEST_ASSERT(newParams.getLowerFragLength() == fparams->getLowerFragLength());
TEST_ASSERT(newParams.getUpperFragLength() == fparams->getUpperFragLength());
TEST_ASSERT(newParams.getTolerance() == fparams->getTolerance());
TEST_ASSERT(newParams.getNumFuncGroups() == fparams->getNumFuncGroups());
// make sure we can pickle and unpickle catalog entries:
const FragCatalogEntry *fpEntry = fcat.getEntryWithIdx(0);
auto *fpEntry2 = new FragCatalogEntry();
fpEntry2->initFromString(fpEntry->Serialize());
TEST_ASSERT(fpEntry->getDescription() == fpEntry2->getDescription());
TEST_ASSERT(fpEntry->getOrder() == fpEntry2->getOrder());
TEST_ASSERT(fpEntry->getBitId() == fpEntry2->getBitId());
TEST_ASSERT(fpEntry2->match(fpEntry, 1e-8));
TEST_ASSERT(fpEntry->match(fpEntry2, 1e-8));
delete fpEntry2;
// test catalogs' initFromString:
FragCatalog fcat2;
fcat2.initFromString(fcat.Serialize());
TEST_ASSERT(fcat2.getNumEntries() == fcat.getNumEntries());
BOOST_LOG(rdInfoLog) << "----- Test 2" << std::endl;
testMols(mols, fpGen, fcat2);
BOOST_LOG(rdInfoLog) << "---- Done" << std::endl;
// and the pickle ctor:
FragCatalog *fcat3 = new FragCatalog(fcat.Serialize());
TEST_ASSERT(fcat3->getNumEntries() == fcat.getNumEntries());
BOOST_LOG(rdInfoLog) << "----- Test 3" << std::endl;
testMols(mols, fpGen, *fcat3);
BOOST_LOG(rdInfoLog) << "---- Done" << std::endl;
//----------------------------------------------------------
// test issue 115
//----------------------------------------------------------
BOOST_LOG(rdInfoLog) << "----- Test Issue 115" << std::endl;
delete fparams;
fparams = new FragCatParams(3, 3, fgrpFile, 1.0e-8);
TEST_ASSERT(fparams->getNumFuncGroups() == 15);
delete fcat3;
fcat3 = new FragCatalog(fparams);
suppl.reset();
nDone = 0;
while (!suppl.atEnd()) {
nDone++;
ROMol *m = suppl.next();
catGen.addFragsFromMol(*m, fcat3);
delete m;
}
TEST_ASSERT(nDone == suppl.length());
TEST_ASSERT(fcat3->getNumEntries() == 21);
TEST_ASSERT(fcat3->getFPLength() == 10);
for (unsigned int i = 0; i < fcat3->getFPLength(); i++) {
TEST_ASSERT(fcat3->getEntryWithBitId(i)->getOrder() == 3);
}
BOOST_LOG(rdInfoLog) << "---- Done" << std::endl;
//----------------------------------------------------------
// test issue 117
//----------------------------------------------------------
BOOST_LOG(rdInfoLog) << "----- Test Issue 117" << std::endl;
delete fparams;
fparams = new FragCatParams(1, 2, fgrpFile, 1.0e-8);
delete fcat3;
fcat3 = new FragCatalog(fparams);
ROMol *tmpMol = SmilesToMol("OC(N)CO");
TEST_ASSERT(tmpMol);
catGen.addFragsFromMol(*tmpMol, fcat3);
TEST_ASSERT(fcat3->getNumEntries() == 1);
// std::cout << fcat3->getEntryWithBitId(0)->getDescription() << std::endl;
TEST_ASSERT(fcat3->getEntryWithBitId(0)->getDescription() ==
"C(<-O>)<-N>C<-O>");
BOOST_LOG(rdInfoLog) << "---- Done" << std::endl;
delete tmpMol;
delete fparams;
delete fcat3;
}
void testIssue294() {
BOOST_LOG(rdInfoLog) << "---- Test Issue294\n Watch memory usage."
<< std::endl;
std::string rdbase = getenv("RDBASE");
std::string fname = rdbase + "/Code/GraphMol/FragCatalog/test_data/mols.smi";
std::string fgrpFile =
rdbase + "/Code/GraphMol/FragCatalog/test_data/funcGroups.txt";
SmilesMolSupplier suppl(fname, " ", 0, 1, false);
auto *fparams = new FragCatParams(1, 6, fgrpFile, 1.0e-8);
FragCatalog fcat(fparams);
FragCatGenerator catGen;
std::vector<std::unique_ptr<ROMol>> mols;
ROMol *m = suppl.next();
while (m) {
mols.push_back(std::unique_ptr<ROMol>(m));
catGen.addFragsFromMol(*m, &fcat);
try {
m = suppl.next();
} catch (FileParseException &) {
m = nullptr;
}
}
int nents = fcat.getNumEntries();
TEST_ASSERT(nents == 21);
FragFPGenerator fpGen;
for (unsigned int i = 0; i < 200; i++) {
for (auto &&mi : mols) {
ExplicitBitVect *fp = fpGen.getFPForMol(*mi, fcat);
delete fp;
}
}
delete fparams;
BOOST_LOG(rdInfoLog) << "---- Done" << std::endl;
}
void testWhiteSpaceInSmarts() {
BOOST_LOG(rdInfoLog) << "----- Test Whitespace in SMARTS Fragment string."
<< std::endl;
std::vector<std::string> data(
{" ", // whitespace only
" \n", // whitespace plus new line
" // initial space plus comment\nfluorine\t[F]\n"});
std::vector<size_t> reference_sizes({0, 0, 1});
auto reference = reference_sizes.cbegin();
for (const auto &smarts : data) {
std::istringstream input(smarts);
auto groups = readFuncGroups(input);
TEST_ASSERT(groups.size() == *reference);
++reference;
}
BOOST_LOG(rdInfoLog) << "---- Done" << std::endl;
}
void testFragmentWithoutSmarts() {
BOOST_LOG(rdInfoLog) << "----- Test Fragment string without SMARTS."
<< std::endl;
std::vector<std::string> data(
{"// Name SMARTS\nnonsense\n",
"// Name SMARTS\nnonsense no new line",
"// Name SMARTS\nnonsense with tab\t\n"});
for (const auto &smarts : data) {
bool ok = false;
std::istringstream input(smarts);
RDKit::MOL_SPTR_VECT groups;
try {
groups = readFuncGroups(input);
} catch (const Invar::Invariant &) {
ok = true;
}
TEST_ASSERT(ok);
TEST_ASSERT(groups.empty());
}
BOOST_LOG(rdInfoLog) << "---- Done" << std::endl;
}
int main() {
RDLog::InitLogs();
test1();
testIssue294();
testWhiteSpaceInSmarts();
testFragmentWithoutSmarts();
return 0;
}
| 31.151316 | 80 | 0.603273 | kazuyaujihara |
bafe0d4b4eb96ffa6962c89e036c4370439179b3 | 17,793 | cpp | C++ | .buildozer/android/platform/build-armeabi-v7a/dists/mydatabase__armeabi-v7a/jni/SDL2_mixer/external/flac-1.3.2/src/test_libFLAC++/encoders.cpp | VPetras/mobile-test-app | 6708dade6873ae2fb1ecb13aa70662f95fb42dc6 | [
"MIT"
] | 252 | 2020-12-16T15:34:43.000Z | 2022-03-31T23:21:37.000Z | .buildozer/android/platform/build-armeabi-v7a/dists/mydatabase__armeabi-v7a/jni/SDL2_mixer/external/flac-1.3.2/src/test_libFLAC++/encoders.cpp | VPetras/mobile-test-app | 6708dade6873ae2fb1ecb13aa70662f95fb42dc6 | [
"MIT"
] | 23 | 2020-12-20T18:02:54.000Z | 2022-03-28T16:58:32.000Z | .buildozer/android/platform/build-armeabi-v7a/dists/mydatabase__armeabi-v7a/jni/SDL2_mixer/external/flac-1.3.2/src/test_libFLAC++/encoders.cpp | VPetras/mobile-test-app | 6708dade6873ae2fb1ecb13aa70662f95fb42dc6 | [
"MIT"
] | 53 | 2016-01-06T23:49:36.000Z | 2022-03-15T15:47:33.000Z | /* test_libFLAC++ - Unit tester for libFLAC++
* Copyright (C) 2002-2009 Josh Coalson
* Copyright (C) 2011-2016 Xiph.Org Foundation
*
* 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.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "encoders.h"
#include "FLAC/assert.h"
#include "FLAC++/encoder.h"
#include "share/grabbag.h"
extern "C" {
#include "test_libs_common/file_utils_flac.h"
#include "test_libs_common/metadata_utils.h"
}
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "share/compat.h"
#ifdef _MSC_VER
// warning C4800: 'int' : forcing to bool 'true' or 'false' (performance warning)
#pragma warning ( disable : 4800 )
#endif
typedef enum {
LAYER_STREAM = 0, /* FLAC__stream_encoder_init_stream() without seeking */
LAYER_SEEKABLE_STREAM, /* FLAC__stream_encoder_init_stream() with seeking */
LAYER_FILE, /* FLAC__stream_encoder_init_FILE() */
LAYER_FILENAME /* FLAC__stream_encoder_init_file() */
} Layer;
static const char * const LayerString[] = {
"Stream",
"Seekable Stream",
"FILE*",
"Filename"
};
static ::FLAC__StreamMetadata streaminfo_, padding_, seektable_, application1_, application2_, vorbiscomment_, cuesheet_, picture_, unknown_;
static ::FLAC__StreamMetadata *metadata_sequence_[] = { &vorbiscomment_, &padding_, &seektable_, &application1_, &application2_, &cuesheet_, &picture_, &unknown_ };
static const unsigned num_metadata_ = sizeof(metadata_sequence_) / sizeof(metadata_sequence_[0]);
static const char *flacfilename(bool is_ogg)
{
return is_ogg? "metadata.oga" : "metadata.flac";
}
static bool die_(const char *msg)
{
printf("ERROR: %s\n", msg);
return false;
}
static bool die_s_(const char *msg, const FLAC::Encoder::Stream *encoder)
{
FLAC::Encoder::Stream::State state = encoder->get_state();
if(msg)
printf("FAILED, %s", msg);
else
printf("FAILED");
printf(", state = %u (%s)\n", (unsigned)((::FLAC__StreamEncoderState)state), state.as_cstring());
if(state == ::FLAC__STREAM_ENCODER_VERIFY_DECODER_ERROR) {
FLAC::Decoder::Stream::State dstate = encoder->get_verify_decoder_state();
printf(" verify decoder state = %u (%s)\n", (unsigned)((::FLAC__StreamDecoderState)dstate), dstate.as_cstring());
}
return false;
}
static void init_metadata_blocks_()
{
mutils__init_metadata_blocks(&streaminfo_, &padding_, &seektable_, &application1_, &application2_, &vorbiscomment_, &cuesheet_, &picture_, &unknown_);
}
static void free_metadata_blocks_()
{
mutils__free_metadata_blocks(&streaminfo_, &padding_, &seektable_, &application1_, &application2_, &vorbiscomment_, &cuesheet_, &picture_, &unknown_);
}
class StreamEncoder : public FLAC::Encoder::Stream {
public:
Layer layer_;
FILE *file_;
StreamEncoder(Layer layer): FLAC::Encoder::Stream(), layer_(layer), file_(0) { }
~StreamEncoder() { }
// from FLAC::Encoder::Stream
::FLAC__StreamEncoderReadStatus read_callback(FLAC__byte buffer[], size_t *bytes);
::FLAC__StreamEncoderWriteStatus write_callback(const FLAC__byte buffer[], size_t bytes, unsigned samples, unsigned current_frame);
::FLAC__StreamEncoderSeekStatus seek_callback(FLAC__uint64 absolute_byte_offset);
::FLAC__StreamEncoderTellStatus tell_callback(FLAC__uint64 *absolute_byte_offset);
void metadata_callback(const ::FLAC__StreamMetadata *metadata);
private:
StreamEncoder(const StreamEncoder&);
StreamEncoder&operator=(const StreamEncoder&);
};
::FLAC__StreamEncoderReadStatus StreamEncoder::read_callback(FLAC__byte buffer[], size_t *bytes)
{
if(*bytes > 0) {
*bytes = fread(buffer, sizeof(FLAC__byte), *bytes, file_);
if(ferror(file_))
return ::FLAC__STREAM_ENCODER_READ_STATUS_ABORT;
else if(*bytes == 0)
return ::FLAC__STREAM_ENCODER_READ_STATUS_END_OF_STREAM;
else
return ::FLAC__STREAM_ENCODER_READ_STATUS_CONTINUE;
}
else
return ::FLAC__STREAM_ENCODER_READ_STATUS_ABORT;
}
::FLAC__StreamEncoderWriteStatus StreamEncoder::write_callback(const FLAC__byte buffer[], size_t bytes, unsigned samples, unsigned current_frame)
{
(void)samples, (void)current_frame;
if(fwrite(buffer, 1, bytes, file_) != bytes)
return ::FLAC__STREAM_ENCODER_WRITE_STATUS_FATAL_ERROR;
else
return ::FLAC__STREAM_ENCODER_WRITE_STATUS_OK;
}
::FLAC__StreamEncoderSeekStatus StreamEncoder::seek_callback(FLAC__uint64 absolute_byte_offset)
{
if(layer_==LAYER_STREAM)
return ::FLAC__STREAM_ENCODER_SEEK_STATUS_UNSUPPORTED;
else if(fseeko(file_, (FLAC__off_t)absolute_byte_offset, SEEK_SET) < 0)
return FLAC__STREAM_ENCODER_SEEK_STATUS_ERROR;
else
return FLAC__STREAM_ENCODER_SEEK_STATUS_OK;
}
::FLAC__StreamEncoderTellStatus StreamEncoder::tell_callback(FLAC__uint64 *absolute_byte_offset)
{
FLAC__off_t pos;
if(layer_==LAYER_STREAM)
return ::FLAC__STREAM_ENCODER_TELL_STATUS_UNSUPPORTED;
else if((pos = ftello(file_)) < 0)
return FLAC__STREAM_ENCODER_TELL_STATUS_ERROR;
else {
*absolute_byte_offset = (FLAC__uint64)pos;
return FLAC__STREAM_ENCODER_TELL_STATUS_OK;
}
}
void StreamEncoder::metadata_callback(const ::FLAC__StreamMetadata *metadata)
{
(void)metadata;
}
class FileEncoder : public FLAC::Encoder::File {
public:
Layer layer_;
FileEncoder(Layer layer): FLAC::Encoder::File(), layer_(layer) { }
~FileEncoder() { }
// from FLAC::Encoder::File
void progress_callback(FLAC__uint64 bytes_written, FLAC__uint64 samples_written, unsigned frames_written, unsigned total_frames_estimate);
};
void FileEncoder::progress_callback(FLAC__uint64 bytes_written, FLAC__uint64 samples_written, unsigned frames_written, unsigned total_frames_estimate)
{
(void)bytes_written, (void)samples_written, (void)frames_written, (void)total_frames_estimate;
}
static FLAC::Encoder::Stream *new_by_layer(Layer layer)
{
if(layer < LAYER_FILE)
return new StreamEncoder(layer);
else
return new FileEncoder(layer);
}
static bool test_stream_encoder(Layer layer, bool is_ogg)
{
FLAC::Encoder::Stream *encoder;
::FLAC__StreamEncoderInitStatus init_status;
FILE *file = 0;
FLAC__int32 samples[1024];
FLAC__int32 *samples_array[1] = { samples };
unsigned i;
printf("\n+++ libFLAC++ unit test: FLAC::Encoder::%s (layer: %s, format: %s)\n\n", layer<LAYER_FILE? "Stream":"File", LayerString[layer], is_ogg? "Ogg FLAC":"FLAC");
printf("allocating encoder instance... ");
encoder = new_by_layer(layer);
if(0 == encoder) {
printf("FAILED, new returned NULL\n");
return false;
}
printf("OK\n");
printf("testing is_valid()... ");
if(!encoder->is_valid()) {
printf("FAILED, returned false\n");
return false;
}
printf("OK\n");
if(is_ogg) {
printf("testing set_ogg_serial_number()... ");
if(!encoder->set_ogg_serial_number(file_utils__ogg_serial_number))
return die_s_("returned false", encoder);
printf("OK\n");
}
printf("testing set_verify()... ");
if(!encoder->set_verify(true))
return die_s_("returned false", encoder);
printf("OK\n");
printf("testing set_streamable_subset()... ");
if(!encoder->set_streamable_subset(true))
return die_s_("returned false", encoder);
printf("OK\n");
printf("testing set_channels()... ");
if(!encoder->set_channels(streaminfo_.data.stream_info.channels))
return die_s_("returned false", encoder);
printf("OK\n");
printf("testing set_bits_per_sample()... ");
if(!encoder->set_bits_per_sample(streaminfo_.data.stream_info.bits_per_sample))
return die_s_("returned false", encoder);
printf("OK\n");
printf("testing set_sample_rate()... ");
if(!encoder->set_sample_rate(streaminfo_.data.stream_info.sample_rate))
return die_s_("returned false", encoder);
printf("OK\n");
printf("testing set_compression_level()... ");
if(!encoder->set_compression_level((unsigned)(-1)))
return die_s_("returned false", encoder);
printf("OK\n");
printf("testing set_blocksize()... ");
if(!encoder->set_blocksize(streaminfo_.data.stream_info.min_blocksize))
return die_s_("returned false", encoder);
printf("OK\n");
printf("testing set_do_mid_side_stereo()... ");
if(!encoder->set_do_mid_side_stereo(false))
return die_s_("returned false", encoder);
printf("OK\n");
printf("testing set_loose_mid_side_stereo()... ");
if(!encoder->set_loose_mid_side_stereo(false))
return die_s_("returned false", encoder);
printf("OK\n");
printf("testing set_max_lpc_order()... ");
if(!encoder->set_max_lpc_order(0))
return die_s_("returned false", encoder);
printf("OK\n");
printf("testing set_qlp_coeff_precision()... ");
if(!encoder->set_qlp_coeff_precision(0))
return die_s_("returned false", encoder);
printf("OK\n");
printf("testing set_do_qlp_coeff_prec_search()... ");
if(!encoder->set_do_qlp_coeff_prec_search(false))
return die_s_("returned false", encoder);
printf("OK\n");
printf("testing set_do_escape_coding()... ");
if(!encoder->set_do_escape_coding(false))
return die_s_("returned false", encoder);
printf("OK\n");
printf("testing set_do_exhaustive_model_search()... ");
if(!encoder->set_do_exhaustive_model_search(false))
return die_s_("returned false", encoder);
printf("OK\n");
printf("testing set_min_residual_partition_order()... ");
if(!encoder->set_min_residual_partition_order(0))
return die_s_("returned false", encoder);
printf("OK\n");
printf("testing set_max_residual_partition_order()... ");
if(!encoder->set_max_residual_partition_order(0))
return die_s_("returned false", encoder);
printf("OK\n");
printf("testing set_rice_parameter_search_dist()... ");
if(!encoder->set_rice_parameter_search_dist(0))
return die_s_("returned false", encoder);
printf("OK\n");
printf("testing set_total_samples_estimate()... ");
if(!encoder->set_total_samples_estimate(streaminfo_.data.stream_info.total_samples))
return die_s_("returned false", encoder);
printf("OK\n");
printf("testing set_metadata()... ");
if(!encoder->set_metadata(metadata_sequence_, num_metadata_))
return die_s_("returned false", encoder);
printf("OK\n");
if(layer < LAYER_FILENAME) {
printf("opening file for FLAC output... ");
file = ::flac_fopen(flacfilename(is_ogg), "w+b");
if(0 == file) {
printf("ERROR (%s)\n", strerror(errno));
return false;
}
printf("OK\n");
if(layer < LAYER_FILE)
dynamic_cast<StreamEncoder*>(encoder)->file_ = file;
}
switch(layer) {
case LAYER_STREAM:
case LAYER_SEEKABLE_STREAM:
printf("testing init%s()... ", is_ogg? "_ogg":"");
init_status = is_ogg? encoder->init_ogg() : encoder->init();
break;
case LAYER_FILE:
printf("testing init%s()... ", is_ogg? "_ogg":"");
init_status = is_ogg?
dynamic_cast<FLAC::Encoder::File*>(encoder)->init_ogg(file) :
dynamic_cast<FLAC::Encoder::File*>(encoder)->init(file);
break;
case LAYER_FILENAME:
printf("testing init%s()... ", is_ogg? "_ogg":"");
init_status = is_ogg?
dynamic_cast<FLAC::Encoder::File*>(encoder)->init_ogg(flacfilename(is_ogg)) :
dynamic_cast<FLAC::Encoder::File*>(encoder)->init(flacfilename(is_ogg));
break;
default:
die_("internal error 001");
return false;
}
if(init_status != ::FLAC__STREAM_ENCODER_INIT_STATUS_OK)
return die_s_(0, encoder);
printf("OK\n");
printf("testing get_state()... ");
FLAC::Encoder::Stream::State state = encoder->get_state();
printf("returned state = %u (%s)... OK\n", (unsigned)((::FLAC__StreamEncoderState)state), state.as_cstring());
printf("testing get_verify_decoder_state()... ");
FLAC::Decoder::Stream::State dstate = encoder->get_verify_decoder_state();
printf("returned state = %u (%s)... OK\n", (unsigned)((::FLAC__StreamDecoderState)dstate), dstate.as_cstring());
{
FLAC__uint64 absolute_sample;
unsigned frame_number;
unsigned channel;
unsigned sample;
FLAC__int32 expected;
FLAC__int32 got;
printf("testing get_verify_decoder_error_stats()... ");
encoder->get_verify_decoder_error_stats(&absolute_sample, &frame_number, &channel, &sample, &expected, &got);
printf("OK\n");
}
printf("testing get_verify()... ");
if(encoder->get_verify() != true) {
printf("FAILED, expected true, got false\n");
return false;
}
printf("OK\n");
printf("testing get_streamable_subset()... ");
if(encoder->get_streamable_subset() != true) {
printf("FAILED, expected true, got false\n");
return false;
}
printf("OK\n");
printf("testing get_do_mid_side_stereo()... ");
if(encoder->get_do_mid_side_stereo() != false) {
printf("FAILED, expected false, got true\n");
return false;
}
printf("OK\n");
printf("testing get_loose_mid_side_stereo()... ");
if(encoder->get_loose_mid_side_stereo() != false) {
printf("FAILED, expected false, got true\n");
return false;
}
printf("OK\n");
printf("testing get_channels()... ");
if(encoder->get_channels() != streaminfo_.data.stream_info.channels) {
printf("FAILED, expected %u, got %u\n", streaminfo_.data.stream_info.channels, encoder->get_channels());
return false;
}
printf("OK\n");
printf("testing get_bits_per_sample()... ");
if(encoder->get_bits_per_sample() != streaminfo_.data.stream_info.bits_per_sample) {
printf("FAILED, expected %u, got %u\n", streaminfo_.data.stream_info.bits_per_sample, encoder->get_bits_per_sample());
return false;
}
printf("OK\n");
printf("testing get_sample_rate()... ");
if(encoder->get_sample_rate() != streaminfo_.data.stream_info.sample_rate) {
printf("FAILED, expected %u, got %u\n", streaminfo_.data.stream_info.sample_rate, encoder->get_sample_rate());
return false;
}
printf("OK\n");
printf("testing get_blocksize()... ");
if(encoder->get_blocksize() != streaminfo_.data.stream_info.min_blocksize) {
printf("FAILED, expected %u, got %u\n", streaminfo_.data.stream_info.min_blocksize, encoder->get_blocksize());
return false;
}
printf("OK\n");
printf("testing get_max_lpc_order()... ");
if(encoder->get_max_lpc_order() != 0) {
printf("FAILED, expected %u, got %u\n", 0, encoder->get_max_lpc_order());
return false;
}
printf("OK\n");
printf("testing get_qlp_coeff_precision()... ");
(void)encoder->get_qlp_coeff_precision();
/* we asked the encoder to auto select this so we accept anything */
printf("OK\n");
printf("testing get_do_qlp_coeff_prec_search()... ");
if(encoder->get_do_qlp_coeff_prec_search() != false) {
printf("FAILED, expected false, got true\n");
return false;
}
printf("OK\n");
printf("testing get_do_escape_coding()... ");
if(encoder->get_do_escape_coding() != false) {
printf("FAILED, expected false, got true\n");
return false;
}
printf("OK\n");
printf("testing get_do_exhaustive_model_search()... ");
if(encoder->get_do_exhaustive_model_search() != false) {
printf("FAILED, expected false, got true\n");
return false;
}
printf("OK\n");
printf("testing get_min_residual_partition_order()... ");
if(encoder->get_min_residual_partition_order() != 0) {
printf("FAILED, expected %u, got %u\n", 0, encoder->get_min_residual_partition_order());
return false;
}
printf("OK\n");
printf("testing get_max_residual_partition_order()... ");
if(encoder->get_max_residual_partition_order() != 0) {
printf("FAILED, expected %u, got %u\n", 0, encoder->get_max_residual_partition_order());
return false;
}
printf("OK\n");
printf("testing get_rice_parameter_search_dist()... ");
if(encoder->get_rice_parameter_search_dist() != 0) {
printf("FAILED, expected %u, got %u\n", 0, encoder->get_rice_parameter_search_dist());
return false;
}
printf("OK\n");
printf("testing get_total_samples_estimate()... ");
if(encoder->get_total_samples_estimate() != streaminfo_.data.stream_info.total_samples) {
printf("FAILED, expected %" PRIu64 ", got %" PRIu64 "\n", streaminfo_.data.stream_info.total_samples, encoder->get_total_samples_estimate());
return false;
}
printf("OK\n");
/* init the dummy sample buffer */
for(i = 0; i < sizeof(samples) / sizeof(FLAC__int32); i++)
samples[i] = i & 7;
printf("testing process()... ");
if(!encoder->process(samples_array, sizeof(samples) / sizeof(FLAC__int32)))
return die_s_("returned false", encoder);
printf("OK\n");
printf("testing process_interleaved()... ");
if(!encoder->process_interleaved(samples, sizeof(samples) / sizeof(FLAC__int32)))
return die_s_("returned false", encoder);
printf("OK\n");
printf("testing finish()... ");
if(!encoder->finish()) {
state = encoder->get_state();
printf("FAILED, returned false, state = %u (%s)\n", (unsigned)((::FLAC__StreamEncoderState)state), state.as_cstring());
return false;
}
printf("OK\n");
if(layer < LAYER_FILE)
::fclose(dynamic_cast<StreamEncoder*>(encoder)->file_);
printf("freeing encoder instance... ");
delete encoder;
printf("OK\n");
printf("\nPASSED!\n");
return true;
}
bool test_encoders()
{
FLAC__bool is_ogg = false;
while(1) {
init_metadata_blocks_();
if(!test_stream_encoder(LAYER_STREAM, is_ogg))
return false;
if(!test_stream_encoder(LAYER_SEEKABLE_STREAM, is_ogg))
return false;
if(!test_stream_encoder(LAYER_FILE, is_ogg))
return false;
if(!test_stream_encoder(LAYER_FILENAME, is_ogg))
return false;
(void) grabbag__file_remove_file(flacfilename(is_ogg));
free_metadata_blocks_();
if(!FLAC_API_SUPPORTS_OGG_FLAC || is_ogg)
break;
is_ogg = true;
}
return true;
}
| 31.547872 | 166 | 0.726297 | VPetras |
baff6c6670fe78fb0bde446d08ffc04eaab5b248 | 2,549 | cpp | C++ | test/keystone_util_test.cpp | Warchant/alt-integration-cpp | 61c1012dd4f4632c1bd288d5bfcb0500a2e4933c | [
"MIT"
] | null | null | null | test/keystone_util_test.cpp | Warchant/alt-integration-cpp | 61c1012dd4f4632c1bd288d5bfcb0500a2e4933c | [
"MIT"
] | 2 | 2020-08-19T11:52:46.000Z | 2020-08-19T12:34:42.000Z | test/keystone_util_test.cpp | Warchant/alt-integration-cpp | 61c1012dd4f4632c1bd288d5bfcb0500a2e4933c | [
"MIT"
] | null | null | null | // Copyright (c) 2019-2020 Xenios SEZC
// https://www.veriblock.org
// Distributed under the MIT software license, see the accompanying
// file LICENSE or http://www.opensource.org/licenses/mit-license.php.
#include <gtest/gtest.h>
#include <veriblock/keystone_util.hpp>
using namespace altintegration;
const static uint32_t VBK_KEYSTONE_INTERVAL = 20;
TEST(KeystoneUtil, testHighestKeystoneAtOrBefore) {
ASSERT_ANY_THROW(highestKeystoneAtOrBefore(-1, VBK_KEYSTONE_INTERVAL));
ASSERT_EQ(highestKeystoneAtOrBefore(0, VBK_KEYSTONE_INTERVAL), 0);
ASSERT_EQ(highestKeystoneAtOrBefore(1, VBK_KEYSTONE_INTERVAL), 0);
ASSERT_EQ(highestKeystoneAtOrBefore(20, VBK_KEYSTONE_INTERVAL), 20);
ASSERT_EQ(highestKeystoneAtOrBefore(21, VBK_KEYSTONE_INTERVAL), 20);
ASSERT_EQ(highestKeystoneAtOrBefore(23, VBK_KEYSTONE_INTERVAL), 20);
ASSERT_EQ(highestKeystoneAtOrBefore(30, VBK_KEYSTONE_INTERVAL), 20);
ASSERT_EQ(highestKeystoneAtOrBefore(39, VBK_KEYSTONE_INTERVAL), 20);
ASSERT_EQ(highestKeystoneAtOrBefore(40, VBK_KEYSTONE_INTERVAL), 40);
ASSERT_EQ(highestKeystoneAtOrBefore(41, VBK_KEYSTONE_INTERVAL), 40);
ASSERT_EQ(highestKeystoneAtOrBefore(50, VBK_KEYSTONE_INTERVAL), 40);
ASSERT_EQ(highestKeystoneAtOrBefore(100, VBK_KEYSTONE_INTERVAL), 100);
ASSERT_EQ(highestKeystoneAtOrBefore(101, VBK_KEYSTONE_INTERVAL), 100);
}
TEST(KeystoneUtil, testIsKeystone) {
ASSERT_ANY_THROW(isKeystone(-1, VBK_KEYSTONE_INTERVAL));
ASSERT_TRUE(isKeystone(0, VBK_KEYSTONE_INTERVAL));
ASSERT_TRUE(isKeystone(20, VBK_KEYSTONE_INTERVAL));
ASSERT_TRUE(isKeystone(40, VBK_KEYSTONE_INTERVAL));
ASSERT_FALSE(isKeystone(1, VBK_KEYSTONE_INTERVAL));
ASSERT_FALSE(isKeystone(21, VBK_KEYSTONE_INTERVAL));
}
TEST(KeystoneUtil, testFirstKeystoneAfter) {
ASSERT_ANY_THROW(firstKeystoneAfter(-1, VBK_KEYSTONE_INTERVAL));
ASSERT_EQ(20, firstKeystoneAfter(0, VBK_KEYSTONE_INTERVAL));
ASSERT_EQ(20, firstKeystoneAfter(1, VBK_KEYSTONE_INTERVAL));
ASSERT_EQ(20, firstKeystoneAfter(19, VBK_KEYSTONE_INTERVAL));
ASSERT_EQ(40, firstKeystoneAfter(20, VBK_KEYSTONE_INTERVAL));
}
TEST(KeystoneUtil, testHighestBlockWhichConnectsKeystoneToPrevious) {
ASSERT_ANY_THROW(
highestBlockWhichConnectsKeystoneToPrevious(-1, VBK_KEYSTONE_INTERVAL));
ASSERT_ANY_THROW(
highestBlockWhichConnectsKeystoneToPrevious(3, VBK_KEYSTONE_INTERVAL));
ASSERT_EQ(
21,
highestBlockWhichConnectsKeystoneToPrevious(0, VBK_KEYSTONE_INTERVAL));
ASSERT_EQ(
41,
highestBlockWhichConnectsKeystoneToPrevious(20, VBK_KEYSTONE_INTERVAL));
}
| 43.20339 | 78 | 0.811691 | Warchant |
240011fbd9bee2c77cbcc4f202d6094825911774 | 4,129 | cpp | C++ | src/3rd_party/apache-log4cxx-0.10.0/src/test/cpp/net/smtpappendertestcase.cpp | russjohnson09/sdl_core | 9de7f1456f1807ae97348f774f7eead0ee92fd6d | [
"BSD-3-Clause"
] | 249 | 2015-01-15T16:50:53.000Z | 2022-03-24T13:23:34.000Z | src/3rd_party/apache-log4cxx-0.10.0/src/test/cpp/net/smtpappendertestcase.cpp | russjohnson09/sdl_core | 9de7f1456f1807ae97348f774f7eead0ee92fd6d | [
"BSD-3-Clause"
] | 2,917 | 2015-01-12T16:17:49.000Z | 2022-03-31T11:57:47.000Z | src/3rd_party/apache-log4cxx-0.10.0/src/test/cpp/net/smtpappendertestcase.cpp | russjohnson09/sdl_core | 9de7f1456f1807ae97348f774f7eead0ee92fd6d | [
"BSD-3-Clause"
] | 306 | 2015-01-12T09:23:20.000Z | 2022-01-28T18:06:30.000Z | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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.
*/
#define LOG4CXX_TEST 1
#include <log4cxx/private/log4cxx_private.h>
#if LOG4CXX_HAVE_SMTP
#include <log4cxx/net/smtpappender.h>
#include "../appenderskeletontestcase.h"
#include <log4cxx/xml/domconfigurator.h>
#include <log4cxx/logmanager.h>
#include <log4cxx/ttcclayout.h>
using namespace log4cxx;
using namespace log4cxx::helpers;
using namespace log4cxx::net;
using namespace log4cxx::xml;
using namespace log4cxx::spi;
namespace log4cxx {
namespace net {
class MockTriggeringEventEvaluator :
public virtual spi::TriggeringEventEvaluator,
public virtual helpers::ObjectImpl
{
public:
DECLARE_LOG4CXX_OBJECT(MockTriggeringEventEvaluator)
BEGIN_LOG4CXX_CAST_MAP()
LOG4CXX_CAST_ENTRY(MockTriggeringEventEvaluator)
LOG4CXX_CAST_ENTRY(spi::TriggeringEventEvaluator)
END_LOG4CXX_CAST_MAP()
MockTriggeringEventEvaluator() {
}
virtual bool isTriggeringEvent(const spi::LoggingEventPtr& event) {
return true;
}
private:
MockTriggeringEventEvaluator(const MockTriggeringEventEvaluator&);
MockTriggeringEventEvaluator& operator=(const MockTriggeringEventEvaluator&);
};
}
}
IMPLEMENT_LOG4CXX_OBJECT(MockTriggeringEventEvaluator)
/**
Unit tests of log4cxx::SocketAppender
*/
class SMTPAppenderTestCase : public AppenderSkeletonTestCase
{
LOGUNIT_TEST_SUITE(SMTPAppenderTestCase);
//
// tests inherited from AppenderSkeletonTestCase
//
LOGUNIT_TEST(testDefaultThreshold);
LOGUNIT_TEST(testSetOptionThreshold);
LOGUNIT_TEST(testTrigger);
LOGUNIT_TEST(testInvalid);
LOGUNIT_TEST_SUITE_END();
public:
AppenderSkeleton* createAppenderSkeleton() const {
return new log4cxx::net::SMTPAppender();
}
void setUp() {
}
void tearDown() {
LogManager::resetConfiguration();
}
/**
* Tests that triggeringPolicy element will set evaluator.
*/
void testTrigger() {
DOMConfigurator::configure("input/xml/smtpAppender1.xml");
SMTPAppenderPtr appender(Logger::getRootLogger()->getAppender(LOG4CXX_STR("A1")));
TriggeringEventEvaluatorPtr evaluator(appender->getEvaluator());
LOGUNIT_ASSERT_EQUAL(true, evaluator->instanceof(MockTriggeringEventEvaluator::getStaticClass()));
}
void testInvalid() {
SMTPAppenderPtr appender(new SMTPAppender());
appender->setSMTPHost(LOG4CXX_STR("smtp.invalid"));
appender->setTo(LOG4CXX_STR("you@example.invalid"));
appender->setFrom(LOG4CXX_STR("me@example.invalid"));
appender->setLayout(new TTCCLayout());
Pool p;
appender->activateOptions(p);
LoggerPtr root(Logger::getRootLogger());
root->addAppender(appender);
LOG4CXX_INFO(root, "Hello, World.");
LOG4CXX_ERROR(root, "Sending Message");
}
};
LOGUNIT_TEST_SUITE_REGISTRATION(SMTPAppenderTestCase);
#endif
| 33.569106 | 104 | 0.654638 | russjohnson09 |
24022fd35c79144bbbc15ef121dc0d4c948a9fd4 | 1,058 | hpp | C++ | pythran/pythonic/include/numpy/bincount.hpp | davidbrochart/pythran | 24b6c8650fe99791a4091cbdc2c24686e86aa67c | [
"BSD-3-Clause"
] | 1,647 | 2015-01-13T01:45:38.000Z | 2022-03-28T01:23:41.000Z | pythran/pythonic/include/numpy/bincount.hpp | davidbrochart/pythran | 24b6c8650fe99791a4091cbdc2c24686e86aa67c | [
"BSD-3-Clause"
] | 1,116 | 2015-01-01T09:52:05.000Z | 2022-03-18T21:06:40.000Z | pythran/pythonic/include/numpy/bincount.hpp | davidbrochart/pythran | 24b6c8650fe99791a4091cbdc2c24686e86aa67c | [
"BSD-3-Clause"
] | 180 | 2015-02-12T02:47:28.000Z | 2022-03-14T10:28:18.000Z | #ifndef PYTHONIC_INCLUDE_NUMPY_BINCOUNT_HPP
#define PYTHONIC_INCLUDE_NUMPY_BINCOUNT_HPP
#include "pythonic/include/numpy/max.hpp"
#include "pythonic/include/utils/numpy_conversion.hpp"
PYTHONIC_NS_BEGIN
namespace numpy
{
template <class T, class pS>
typename std::enable_if<std::tuple_size<pS>::value == 1,
types::ndarray<long, types::pshape<long>>>::type
bincount(types::ndarray<T, pS> const &expr,
types::none_type weights = builtins::None,
types::none<long> minlength = builtins::None);
template <class T, class E, class pS>
typename std::enable_if<
std::tuple_size<pS>::value == 1,
types::ndarray<decltype(std::declval<long>() *
std::declval<typename E::dtype>()),
types::pshape<long>>>::type
bincount(types::ndarray<T, pS> const &expr, E const &weights,
types::none<long> minlength = builtins::None);
NUMPY_EXPR_TO_NDARRAY0_DECL(bincount);
DEFINE_FUNCTOR(pythonic::numpy, bincount);
}
PYTHONIC_NS_END
#endif
| 31.117647 | 74 | 0.663516 | davidbrochart |
2404a07e65bc995a03523fb00126b6e24acaa686 | 730,115 | cpp | C++ | test/normalize_to_nfkc_018.cpp | jan-moeller/text | c61e51c82dfb0ae6e74200c01ce040fa6db730c4 | [
"BSL-1.0"
] | null | null | null | test/normalize_to_nfkc_018.cpp | jan-moeller/text | c61e51c82dfb0ae6e74200c01ce040fa6db730c4 | [
"BSL-1.0"
] | null | null | null | test/normalize_to_nfkc_018.cpp | jan-moeller/text | c61e51c82dfb0ae6e74200c01ce040fa6db730c4 | [
"BSL-1.0"
] | null | null | null | // Warning! This file is autogenerated.
#include <boost/text/normalize_string.hpp>
#include <boost/text/utility.hpp>
#include <boost/text/string_utility.hpp>
#include <gtest/gtest.h>
#include <algorithm>
TEST(normalization, nfkc_018_000)
{
// B0A0;B0A0;1102 1161 11AF;B0A0;1102 1161 11AF;
// (날; 날; 날; 날; 날; ) HANGUL SYLLABLE NAL
{
std::array<uint32_t, 1> const c1 = {{ 0xB0A0 }};
std::array<uint32_t, 1> const c2 = {{ 0xB0A0 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1161, 0x11AF }};
std::array<uint32_t, 1> const c4 = {{ 0xB0A0 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1161, 0x11AF }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_001)
{
// B0A1;B0A1;1102 1161 11B0;B0A1;1102 1161 11B0;
// (낡; 낡; 낡; 낡; 낡; ) HANGUL SYLLABLE NALG
{
std::array<uint32_t, 1> const c1 = {{ 0xB0A1 }};
std::array<uint32_t, 1> const c2 = {{ 0xB0A1 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1161, 0x11B0 }};
std::array<uint32_t, 1> const c4 = {{ 0xB0A1 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1161, 0x11B0 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_002)
{
// B0A2;B0A2;1102 1161 11B1;B0A2;1102 1161 11B1;
// (낢; 낢; 낢; 낢; 낢; ) HANGUL SYLLABLE NALM
{
std::array<uint32_t, 1> const c1 = {{ 0xB0A2 }};
std::array<uint32_t, 1> const c2 = {{ 0xB0A2 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1161, 0x11B1 }};
std::array<uint32_t, 1> const c4 = {{ 0xB0A2 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1161, 0x11B1 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_003)
{
// B0A3;B0A3;1102 1161 11B2;B0A3;1102 1161 11B2;
// (낣; 낣; 낣; 낣; 낣; ) HANGUL SYLLABLE NALB
{
std::array<uint32_t, 1> const c1 = {{ 0xB0A3 }};
std::array<uint32_t, 1> const c2 = {{ 0xB0A3 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1161, 0x11B2 }};
std::array<uint32_t, 1> const c4 = {{ 0xB0A3 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1161, 0x11B2 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_004)
{
// B0A4;B0A4;1102 1161 11B3;B0A4;1102 1161 11B3;
// (낤; 낤; 낤; 낤; 낤; ) HANGUL SYLLABLE NALS
{
std::array<uint32_t, 1> const c1 = {{ 0xB0A4 }};
std::array<uint32_t, 1> const c2 = {{ 0xB0A4 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1161, 0x11B3 }};
std::array<uint32_t, 1> const c4 = {{ 0xB0A4 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1161, 0x11B3 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_005)
{
// B0A5;B0A5;1102 1161 11B4;B0A5;1102 1161 11B4;
// (낥; 낥; 낥; 낥; 낥; ) HANGUL SYLLABLE NALT
{
std::array<uint32_t, 1> const c1 = {{ 0xB0A5 }};
std::array<uint32_t, 1> const c2 = {{ 0xB0A5 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1161, 0x11B4 }};
std::array<uint32_t, 1> const c4 = {{ 0xB0A5 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1161, 0x11B4 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_006)
{
// B0A6;B0A6;1102 1161 11B5;B0A6;1102 1161 11B5;
// (낦; 낦; 낦; 낦; 낦; ) HANGUL SYLLABLE NALP
{
std::array<uint32_t, 1> const c1 = {{ 0xB0A6 }};
std::array<uint32_t, 1> const c2 = {{ 0xB0A6 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1161, 0x11B5 }};
std::array<uint32_t, 1> const c4 = {{ 0xB0A6 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1161, 0x11B5 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_007)
{
// B0A7;B0A7;1102 1161 11B6;B0A7;1102 1161 11B6;
// (낧; 낧; 낧; 낧; 낧; ) HANGUL SYLLABLE NALH
{
std::array<uint32_t, 1> const c1 = {{ 0xB0A7 }};
std::array<uint32_t, 1> const c2 = {{ 0xB0A7 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1161, 0x11B6 }};
std::array<uint32_t, 1> const c4 = {{ 0xB0A7 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1161, 0x11B6 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_008)
{
// B0A8;B0A8;1102 1161 11B7;B0A8;1102 1161 11B7;
// (남; 남; 남; 남; 남; ) HANGUL SYLLABLE NAM
{
std::array<uint32_t, 1> const c1 = {{ 0xB0A8 }};
std::array<uint32_t, 1> const c2 = {{ 0xB0A8 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1161, 0x11B7 }};
std::array<uint32_t, 1> const c4 = {{ 0xB0A8 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1161, 0x11B7 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_009)
{
// B0A9;B0A9;1102 1161 11B8;B0A9;1102 1161 11B8;
// (납; 납; 납; 납; 납; ) HANGUL SYLLABLE NAB
{
std::array<uint32_t, 1> const c1 = {{ 0xB0A9 }};
std::array<uint32_t, 1> const c2 = {{ 0xB0A9 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1161, 0x11B8 }};
std::array<uint32_t, 1> const c4 = {{ 0xB0A9 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1161, 0x11B8 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_010)
{
// B0AA;B0AA;1102 1161 11B9;B0AA;1102 1161 11B9;
// (낪; 낪; 낪; 낪; 낪; ) HANGUL SYLLABLE NABS
{
std::array<uint32_t, 1> const c1 = {{ 0xB0AA }};
std::array<uint32_t, 1> const c2 = {{ 0xB0AA }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1161, 0x11B9 }};
std::array<uint32_t, 1> const c4 = {{ 0xB0AA }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1161, 0x11B9 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_011)
{
// B0AB;B0AB;1102 1161 11BA;B0AB;1102 1161 11BA;
// (낫; 낫; 낫; 낫; 낫; ) HANGUL SYLLABLE NAS
{
std::array<uint32_t, 1> const c1 = {{ 0xB0AB }};
std::array<uint32_t, 1> const c2 = {{ 0xB0AB }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1161, 0x11BA }};
std::array<uint32_t, 1> const c4 = {{ 0xB0AB }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1161, 0x11BA }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_012)
{
// B0AC;B0AC;1102 1161 11BB;B0AC;1102 1161 11BB;
// (났; 났; 났; 났; 났; ) HANGUL SYLLABLE NASS
{
std::array<uint32_t, 1> const c1 = {{ 0xB0AC }};
std::array<uint32_t, 1> const c2 = {{ 0xB0AC }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1161, 0x11BB }};
std::array<uint32_t, 1> const c4 = {{ 0xB0AC }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1161, 0x11BB }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_013)
{
// B0AD;B0AD;1102 1161 11BC;B0AD;1102 1161 11BC;
// (낭; 낭; 낭; 낭; 낭; ) HANGUL SYLLABLE NANG
{
std::array<uint32_t, 1> const c1 = {{ 0xB0AD }};
std::array<uint32_t, 1> const c2 = {{ 0xB0AD }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1161, 0x11BC }};
std::array<uint32_t, 1> const c4 = {{ 0xB0AD }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1161, 0x11BC }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_014)
{
// B0AE;B0AE;1102 1161 11BD;B0AE;1102 1161 11BD;
// (낮; 낮; 낮; 낮; 낮; ) HANGUL SYLLABLE NAJ
{
std::array<uint32_t, 1> const c1 = {{ 0xB0AE }};
std::array<uint32_t, 1> const c2 = {{ 0xB0AE }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1161, 0x11BD }};
std::array<uint32_t, 1> const c4 = {{ 0xB0AE }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1161, 0x11BD }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_015)
{
// B0AF;B0AF;1102 1161 11BE;B0AF;1102 1161 11BE;
// (낯; 낯; 낯; 낯; 낯; ) HANGUL SYLLABLE NAC
{
std::array<uint32_t, 1> const c1 = {{ 0xB0AF }};
std::array<uint32_t, 1> const c2 = {{ 0xB0AF }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1161, 0x11BE }};
std::array<uint32_t, 1> const c4 = {{ 0xB0AF }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1161, 0x11BE }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_016)
{
// B0B0;B0B0;1102 1161 11BF;B0B0;1102 1161 11BF;
// (낰; 낰; 낰; 낰; 낰; ) HANGUL SYLLABLE NAK
{
std::array<uint32_t, 1> const c1 = {{ 0xB0B0 }};
std::array<uint32_t, 1> const c2 = {{ 0xB0B0 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1161, 0x11BF }};
std::array<uint32_t, 1> const c4 = {{ 0xB0B0 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1161, 0x11BF }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_017)
{
// B0B1;B0B1;1102 1161 11C0;B0B1;1102 1161 11C0;
// (낱; 낱; 낱; 낱; 낱; ) HANGUL SYLLABLE NAT
{
std::array<uint32_t, 1> const c1 = {{ 0xB0B1 }};
std::array<uint32_t, 1> const c2 = {{ 0xB0B1 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1161, 0x11C0 }};
std::array<uint32_t, 1> const c4 = {{ 0xB0B1 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1161, 0x11C0 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_018)
{
// B0B2;B0B2;1102 1161 11C1;B0B2;1102 1161 11C1;
// (낲; 낲; 낲; 낲; 낲; ) HANGUL SYLLABLE NAP
{
std::array<uint32_t, 1> const c1 = {{ 0xB0B2 }};
std::array<uint32_t, 1> const c2 = {{ 0xB0B2 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1161, 0x11C1 }};
std::array<uint32_t, 1> const c4 = {{ 0xB0B2 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1161, 0x11C1 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_019)
{
// B0B3;B0B3;1102 1161 11C2;B0B3;1102 1161 11C2;
// (낳; 낳; 낳; 낳; 낳; ) HANGUL SYLLABLE NAH
{
std::array<uint32_t, 1> const c1 = {{ 0xB0B3 }};
std::array<uint32_t, 1> const c2 = {{ 0xB0B3 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1161, 0x11C2 }};
std::array<uint32_t, 1> const c4 = {{ 0xB0B3 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1161, 0x11C2 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_020)
{
// B0B4;B0B4;1102 1162;B0B4;1102 1162;
// (내; 내; 내; 내; 내; ) HANGUL SYLLABLE NAE
{
std::array<uint32_t, 1> const c1 = {{ 0xB0B4 }};
std::array<uint32_t, 1> const c2 = {{ 0xB0B4 }};
std::array<uint32_t, 2> const c3 = {{ 0x1102, 0x1162 }};
std::array<uint32_t, 1> const c4 = {{ 0xB0B4 }};
std::array<uint32_t, 2> const c5 = {{ 0x1102, 0x1162 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_021)
{
// B0B5;B0B5;1102 1162 11A8;B0B5;1102 1162 11A8;
// (낵; 낵; 낵; 낵; 낵; ) HANGUL SYLLABLE NAEG
{
std::array<uint32_t, 1> const c1 = {{ 0xB0B5 }};
std::array<uint32_t, 1> const c2 = {{ 0xB0B5 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1162, 0x11A8 }};
std::array<uint32_t, 1> const c4 = {{ 0xB0B5 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1162, 0x11A8 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_022)
{
// B0B6;B0B6;1102 1162 11A9;B0B6;1102 1162 11A9;
// (낶; 낶; 낶; 낶; 낶; ) HANGUL SYLLABLE NAEGG
{
std::array<uint32_t, 1> const c1 = {{ 0xB0B6 }};
std::array<uint32_t, 1> const c2 = {{ 0xB0B6 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1162, 0x11A9 }};
std::array<uint32_t, 1> const c4 = {{ 0xB0B6 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1162, 0x11A9 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_023)
{
// B0B7;B0B7;1102 1162 11AA;B0B7;1102 1162 11AA;
// (낷; 낷; 낷; 낷; 낷; ) HANGUL SYLLABLE NAEGS
{
std::array<uint32_t, 1> const c1 = {{ 0xB0B7 }};
std::array<uint32_t, 1> const c2 = {{ 0xB0B7 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1162, 0x11AA }};
std::array<uint32_t, 1> const c4 = {{ 0xB0B7 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1162, 0x11AA }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_024)
{
// B0B8;B0B8;1102 1162 11AB;B0B8;1102 1162 11AB;
// (낸; 낸; 낸; 낸; 낸; ) HANGUL SYLLABLE NAEN
{
std::array<uint32_t, 1> const c1 = {{ 0xB0B8 }};
std::array<uint32_t, 1> const c2 = {{ 0xB0B8 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1162, 0x11AB }};
std::array<uint32_t, 1> const c4 = {{ 0xB0B8 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1162, 0x11AB }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_025)
{
// B0B9;B0B9;1102 1162 11AC;B0B9;1102 1162 11AC;
// (낹; 낹; 낹; 낹; 낹; ) HANGUL SYLLABLE NAENJ
{
std::array<uint32_t, 1> const c1 = {{ 0xB0B9 }};
std::array<uint32_t, 1> const c2 = {{ 0xB0B9 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1162, 0x11AC }};
std::array<uint32_t, 1> const c4 = {{ 0xB0B9 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1162, 0x11AC }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_026)
{
// B0BA;B0BA;1102 1162 11AD;B0BA;1102 1162 11AD;
// (낺; 낺; 낺; 낺; 낺; ) HANGUL SYLLABLE NAENH
{
std::array<uint32_t, 1> const c1 = {{ 0xB0BA }};
std::array<uint32_t, 1> const c2 = {{ 0xB0BA }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1162, 0x11AD }};
std::array<uint32_t, 1> const c4 = {{ 0xB0BA }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1162, 0x11AD }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_027)
{
// B0BB;B0BB;1102 1162 11AE;B0BB;1102 1162 11AE;
// (낻; 낻; 낻; 낻; 낻; ) HANGUL SYLLABLE NAED
{
std::array<uint32_t, 1> const c1 = {{ 0xB0BB }};
std::array<uint32_t, 1> const c2 = {{ 0xB0BB }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1162, 0x11AE }};
std::array<uint32_t, 1> const c4 = {{ 0xB0BB }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1162, 0x11AE }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_028)
{
// B0BC;B0BC;1102 1162 11AF;B0BC;1102 1162 11AF;
// (낼; 낼; 낼; 낼; 낼; ) HANGUL SYLLABLE NAEL
{
std::array<uint32_t, 1> const c1 = {{ 0xB0BC }};
std::array<uint32_t, 1> const c2 = {{ 0xB0BC }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1162, 0x11AF }};
std::array<uint32_t, 1> const c4 = {{ 0xB0BC }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1162, 0x11AF }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_029)
{
// B0BD;B0BD;1102 1162 11B0;B0BD;1102 1162 11B0;
// (낽; 낽; 낽; 낽; 낽; ) HANGUL SYLLABLE NAELG
{
std::array<uint32_t, 1> const c1 = {{ 0xB0BD }};
std::array<uint32_t, 1> const c2 = {{ 0xB0BD }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1162, 0x11B0 }};
std::array<uint32_t, 1> const c4 = {{ 0xB0BD }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1162, 0x11B0 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_030)
{
// B0BE;B0BE;1102 1162 11B1;B0BE;1102 1162 11B1;
// (낾; 낾; 낾; 낾; 낾; ) HANGUL SYLLABLE NAELM
{
std::array<uint32_t, 1> const c1 = {{ 0xB0BE }};
std::array<uint32_t, 1> const c2 = {{ 0xB0BE }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1162, 0x11B1 }};
std::array<uint32_t, 1> const c4 = {{ 0xB0BE }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1162, 0x11B1 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_031)
{
// B0BF;B0BF;1102 1162 11B2;B0BF;1102 1162 11B2;
// (낿; 낿; 낿; 낿; 낿; ) HANGUL SYLLABLE NAELB
{
std::array<uint32_t, 1> const c1 = {{ 0xB0BF }};
std::array<uint32_t, 1> const c2 = {{ 0xB0BF }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1162, 0x11B2 }};
std::array<uint32_t, 1> const c4 = {{ 0xB0BF }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1162, 0x11B2 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_032)
{
// B0C0;B0C0;1102 1162 11B3;B0C0;1102 1162 11B3;
// (냀; 냀; 냀; 냀; 냀; ) HANGUL SYLLABLE NAELS
{
std::array<uint32_t, 1> const c1 = {{ 0xB0C0 }};
std::array<uint32_t, 1> const c2 = {{ 0xB0C0 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1162, 0x11B3 }};
std::array<uint32_t, 1> const c4 = {{ 0xB0C0 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1162, 0x11B3 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_033)
{
// B0C1;B0C1;1102 1162 11B4;B0C1;1102 1162 11B4;
// (냁; 냁; 냁; 냁; 냁; ) HANGUL SYLLABLE NAELT
{
std::array<uint32_t, 1> const c1 = {{ 0xB0C1 }};
std::array<uint32_t, 1> const c2 = {{ 0xB0C1 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1162, 0x11B4 }};
std::array<uint32_t, 1> const c4 = {{ 0xB0C1 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1162, 0x11B4 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_034)
{
// B0C2;B0C2;1102 1162 11B5;B0C2;1102 1162 11B5;
// (냂; 냂; 냂; 냂; 냂; ) HANGUL SYLLABLE NAELP
{
std::array<uint32_t, 1> const c1 = {{ 0xB0C2 }};
std::array<uint32_t, 1> const c2 = {{ 0xB0C2 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1162, 0x11B5 }};
std::array<uint32_t, 1> const c4 = {{ 0xB0C2 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1162, 0x11B5 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_035)
{
// B0C3;B0C3;1102 1162 11B6;B0C3;1102 1162 11B6;
// (냃; 냃; 냃; 냃; 냃; ) HANGUL SYLLABLE NAELH
{
std::array<uint32_t, 1> const c1 = {{ 0xB0C3 }};
std::array<uint32_t, 1> const c2 = {{ 0xB0C3 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1162, 0x11B6 }};
std::array<uint32_t, 1> const c4 = {{ 0xB0C3 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1162, 0x11B6 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_036)
{
// B0C4;B0C4;1102 1162 11B7;B0C4;1102 1162 11B7;
// (냄; 냄; 냄; 냄; 냄; ) HANGUL SYLLABLE NAEM
{
std::array<uint32_t, 1> const c1 = {{ 0xB0C4 }};
std::array<uint32_t, 1> const c2 = {{ 0xB0C4 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1162, 0x11B7 }};
std::array<uint32_t, 1> const c4 = {{ 0xB0C4 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1162, 0x11B7 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_037)
{
// B0C5;B0C5;1102 1162 11B8;B0C5;1102 1162 11B8;
// (냅; 냅; 냅; 냅; 냅; ) HANGUL SYLLABLE NAEB
{
std::array<uint32_t, 1> const c1 = {{ 0xB0C5 }};
std::array<uint32_t, 1> const c2 = {{ 0xB0C5 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1162, 0x11B8 }};
std::array<uint32_t, 1> const c4 = {{ 0xB0C5 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1162, 0x11B8 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_038)
{
// B0C6;B0C6;1102 1162 11B9;B0C6;1102 1162 11B9;
// (냆; 냆; 냆; 냆; 냆; ) HANGUL SYLLABLE NAEBS
{
std::array<uint32_t, 1> const c1 = {{ 0xB0C6 }};
std::array<uint32_t, 1> const c2 = {{ 0xB0C6 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1162, 0x11B9 }};
std::array<uint32_t, 1> const c4 = {{ 0xB0C6 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1162, 0x11B9 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_039)
{
// B0C7;B0C7;1102 1162 11BA;B0C7;1102 1162 11BA;
// (냇; 냇; 냇; 냇; 냇; ) HANGUL SYLLABLE NAES
{
std::array<uint32_t, 1> const c1 = {{ 0xB0C7 }};
std::array<uint32_t, 1> const c2 = {{ 0xB0C7 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1162, 0x11BA }};
std::array<uint32_t, 1> const c4 = {{ 0xB0C7 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1162, 0x11BA }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_040)
{
// B0C8;B0C8;1102 1162 11BB;B0C8;1102 1162 11BB;
// (냈; 냈; 냈; 냈; 냈; ) HANGUL SYLLABLE NAESS
{
std::array<uint32_t, 1> const c1 = {{ 0xB0C8 }};
std::array<uint32_t, 1> const c2 = {{ 0xB0C8 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1162, 0x11BB }};
std::array<uint32_t, 1> const c4 = {{ 0xB0C8 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1162, 0x11BB }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_041)
{
// B0C9;B0C9;1102 1162 11BC;B0C9;1102 1162 11BC;
// (냉; 냉; 냉; 냉; 냉; ) HANGUL SYLLABLE NAENG
{
std::array<uint32_t, 1> const c1 = {{ 0xB0C9 }};
std::array<uint32_t, 1> const c2 = {{ 0xB0C9 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1162, 0x11BC }};
std::array<uint32_t, 1> const c4 = {{ 0xB0C9 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1162, 0x11BC }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_042)
{
// B0CA;B0CA;1102 1162 11BD;B0CA;1102 1162 11BD;
// (냊; 냊; 냊; 냊; 냊; ) HANGUL SYLLABLE NAEJ
{
std::array<uint32_t, 1> const c1 = {{ 0xB0CA }};
std::array<uint32_t, 1> const c2 = {{ 0xB0CA }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1162, 0x11BD }};
std::array<uint32_t, 1> const c4 = {{ 0xB0CA }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1162, 0x11BD }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_043)
{
// B0CB;B0CB;1102 1162 11BE;B0CB;1102 1162 11BE;
// (냋; 냋; 냋; 냋; 냋; ) HANGUL SYLLABLE NAEC
{
std::array<uint32_t, 1> const c1 = {{ 0xB0CB }};
std::array<uint32_t, 1> const c2 = {{ 0xB0CB }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1162, 0x11BE }};
std::array<uint32_t, 1> const c4 = {{ 0xB0CB }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1162, 0x11BE }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_044)
{
// B0CC;B0CC;1102 1162 11BF;B0CC;1102 1162 11BF;
// (냌; 냌; 냌; 냌; 냌; ) HANGUL SYLLABLE NAEK
{
std::array<uint32_t, 1> const c1 = {{ 0xB0CC }};
std::array<uint32_t, 1> const c2 = {{ 0xB0CC }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1162, 0x11BF }};
std::array<uint32_t, 1> const c4 = {{ 0xB0CC }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1162, 0x11BF }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_045)
{
// B0CD;B0CD;1102 1162 11C0;B0CD;1102 1162 11C0;
// (냍; 냍; 냍; 냍; 냍; ) HANGUL SYLLABLE NAET
{
std::array<uint32_t, 1> const c1 = {{ 0xB0CD }};
std::array<uint32_t, 1> const c2 = {{ 0xB0CD }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1162, 0x11C0 }};
std::array<uint32_t, 1> const c4 = {{ 0xB0CD }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1162, 0x11C0 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_046)
{
// B0CE;B0CE;1102 1162 11C1;B0CE;1102 1162 11C1;
// (냎; 냎; 냎; 냎; 냎; ) HANGUL SYLLABLE NAEP
{
std::array<uint32_t, 1> const c1 = {{ 0xB0CE }};
std::array<uint32_t, 1> const c2 = {{ 0xB0CE }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1162, 0x11C1 }};
std::array<uint32_t, 1> const c4 = {{ 0xB0CE }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1162, 0x11C1 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_047)
{
// B0CF;B0CF;1102 1162 11C2;B0CF;1102 1162 11C2;
// (냏; 냏; 냏; 냏; 냏; ) HANGUL SYLLABLE NAEH
{
std::array<uint32_t, 1> const c1 = {{ 0xB0CF }};
std::array<uint32_t, 1> const c2 = {{ 0xB0CF }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1162, 0x11C2 }};
std::array<uint32_t, 1> const c4 = {{ 0xB0CF }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1162, 0x11C2 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_048)
{
// B0D0;B0D0;1102 1163;B0D0;1102 1163;
// (냐; 냐; 냐; 냐; 냐; ) HANGUL SYLLABLE NYA
{
std::array<uint32_t, 1> const c1 = {{ 0xB0D0 }};
std::array<uint32_t, 1> const c2 = {{ 0xB0D0 }};
std::array<uint32_t, 2> const c3 = {{ 0x1102, 0x1163 }};
std::array<uint32_t, 1> const c4 = {{ 0xB0D0 }};
std::array<uint32_t, 2> const c5 = {{ 0x1102, 0x1163 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_049)
{
// B0D1;B0D1;1102 1163 11A8;B0D1;1102 1163 11A8;
// (냑; 냑; 냑; 냑; 냑; ) HANGUL SYLLABLE NYAG
{
std::array<uint32_t, 1> const c1 = {{ 0xB0D1 }};
std::array<uint32_t, 1> const c2 = {{ 0xB0D1 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1163, 0x11A8 }};
std::array<uint32_t, 1> const c4 = {{ 0xB0D1 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1163, 0x11A8 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_050)
{
// B0D2;B0D2;1102 1163 11A9;B0D2;1102 1163 11A9;
// (냒; 냒; 냒; 냒; 냒; ) HANGUL SYLLABLE NYAGG
{
std::array<uint32_t, 1> const c1 = {{ 0xB0D2 }};
std::array<uint32_t, 1> const c2 = {{ 0xB0D2 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1163, 0x11A9 }};
std::array<uint32_t, 1> const c4 = {{ 0xB0D2 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1163, 0x11A9 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_051)
{
// B0D3;B0D3;1102 1163 11AA;B0D3;1102 1163 11AA;
// (냓; 냓; 냓; 냓; 냓; ) HANGUL SYLLABLE NYAGS
{
std::array<uint32_t, 1> const c1 = {{ 0xB0D3 }};
std::array<uint32_t, 1> const c2 = {{ 0xB0D3 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1163, 0x11AA }};
std::array<uint32_t, 1> const c4 = {{ 0xB0D3 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1163, 0x11AA }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_052)
{
// B0D4;B0D4;1102 1163 11AB;B0D4;1102 1163 11AB;
// (냔; 냔; 냔; 냔; 냔; ) HANGUL SYLLABLE NYAN
{
std::array<uint32_t, 1> const c1 = {{ 0xB0D4 }};
std::array<uint32_t, 1> const c2 = {{ 0xB0D4 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1163, 0x11AB }};
std::array<uint32_t, 1> const c4 = {{ 0xB0D4 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1163, 0x11AB }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_053)
{
// B0D5;B0D5;1102 1163 11AC;B0D5;1102 1163 11AC;
// (냕; 냕; 냕; 냕; 냕; ) HANGUL SYLLABLE NYANJ
{
std::array<uint32_t, 1> const c1 = {{ 0xB0D5 }};
std::array<uint32_t, 1> const c2 = {{ 0xB0D5 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1163, 0x11AC }};
std::array<uint32_t, 1> const c4 = {{ 0xB0D5 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1163, 0x11AC }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_054)
{
// B0D6;B0D6;1102 1163 11AD;B0D6;1102 1163 11AD;
// (냖; 냖; 냖; 냖; 냖; ) HANGUL SYLLABLE NYANH
{
std::array<uint32_t, 1> const c1 = {{ 0xB0D6 }};
std::array<uint32_t, 1> const c2 = {{ 0xB0D6 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1163, 0x11AD }};
std::array<uint32_t, 1> const c4 = {{ 0xB0D6 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1163, 0x11AD }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_055)
{
// B0D7;B0D7;1102 1163 11AE;B0D7;1102 1163 11AE;
// (냗; 냗; 냗; 냗; 냗; ) HANGUL SYLLABLE NYAD
{
std::array<uint32_t, 1> const c1 = {{ 0xB0D7 }};
std::array<uint32_t, 1> const c2 = {{ 0xB0D7 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1163, 0x11AE }};
std::array<uint32_t, 1> const c4 = {{ 0xB0D7 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1163, 0x11AE }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_056)
{
// B0D8;B0D8;1102 1163 11AF;B0D8;1102 1163 11AF;
// (냘; 냘; 냘; 냘; 냘; ) HANGUL SYLLABLE NYAL
{
std::array<uint32_t, 1> const c1 = {{ 0xB0D8 }};
std::array<uint32_t, 1> const c2 = {{ 0xB0D8 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1163, 0x11AF }};
std::array<uint32_t, 1> const c4 = {{ 0xB0D8 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1163, 0x11AF }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_057)
{
// B0D9;B0D9;1102 1163 11B0;B0D9;1102 1163 11B0;
// (냙; 냙; 냙; 냙; 냙; ) HANGUL SYLLABLE NYALG
{
std::array<uint32_t, 1> const c1 = {{ 0xB0D9 }};
std::array<uint32_t, 1> const c2 = {{ 0xB0D9 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1163, 0x11B0 }};
std::array<uint32_t, 1> const c4 = {{ 0xB0D9 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1163, 0x11B0 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_058)
{
// B0DA;B0DA;1102 1163 11B1;B0DA;1102 1163 11B1;
// (냚; 냚; 냚; 냚; 냚; ) HANGUL SYLLABLE NYALM
{
std::array<uint32_t, 1> const c1 = {{ 0xB0DA }};
std::array<uint32_t, 1> const c2 = {{ 0xB0DA }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1163, 0x11B1 }};
std::array<uint32_t, 1> const c4 = {{ 0xB0DA }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1163, 0x11B1 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_059)
{
// B0DB;B0DB;1102 1163 11B2;B0DB;1102 1163 11B2;
// (냛; 냛; 냛; 냛; 냛; ) HANGUL SYLLABLE NYALB
{
std::array<uint32_t, 1> const c1 = {{ 0xB0DB }};
std::array<uint32_t, 1> const c2 = {{ 0xB0DB }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1163, 0x11B2 }};
std::array<uint32_t, 1> const c4 = {{ 0xB0DB }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1163, 0x11B2 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_060)
{
// B0DC;B0DC;1102 1163 11B3;B0DC;1102 1163 11B3;
// (냜; 냜; 냜; 냜; 냜; ) HANGUL SYLLABLE NYALS
{
std::array<uint32_t, 1> const c1 = {{ 0xB0DC }};
std::array<uint32_t, 1> const c2 = {{ 0xB0DC }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1163, 0x11B3 }};
std::array<uint32_t, 1> const c4 = {{ 0xB0DC }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1163, 0x11B3 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_061)
{
// B0DD;B0DD;1102 1163 11B4;B0DD;1102 1163 11B4;
// (냝; 냝; 냝; 냝; 냝; ) HANGUL SYLLABLE NYALT
{
std::array<uint32_t, 1> const c1 = {{ 0xB0DD }};
std::array<uint32_t, 1> const c2 = {{ 0xB0DD }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1163, 0x11B4 }};
std::array<uint32_t, 1> const c4 = {{ 0xB0DD }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1163, 0x11B4 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_062)
{
// B0DE;B0DE;1102 1163 11B5;B0DE;1102 1163 11B5;
// (냞; 냞; 냞; 냞; 냞; ) HANGUL SYLLABLE NYALP
{
std::array<uint32_t, 1> const c1 = {{ 0xB0DE }};
std::array<uint32_t, 1> const c2 = {{ 0xB0DE }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1163, 0x11B5 }};
std::array<uint32_t, 1> const c4 = {{ 0xB0DE }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1163, 0x11B5 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_063)
{
// B0DF;B0DF;1102 1163 11B6;B0DF;1102 1163 11B6;
// (냟; 냟; 냟; 냟; 냟; ) HANGUL SYLLABLE NYALH
{
std::array<uint32_t, 1> const c1 = {{ 0xB0DF }};
std::array<uint32_t, 1> const c2 = {{ 0xB0DF }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1163, 0x11B6 }};
std::array<uint32_t, 1> const c4 = {{ 0xB0DF }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1163, 0x11B6 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_064)
{
// B0E0;B0E0;1102 1163 11B7;B0E0;1102 1163 11B7;
// (냠; 냠; 냠; 냠; 냠; ) HANGUL SYLLABLE NYAM
{
std::array<uint32_t, 1> const c1 = {{ 0xB0E0 }};
std::array<uint32_t, 1> const c2 = {{ 0xB0E0 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1163, 0x11B7 }};
std::array<uint32_t, 1> const c4 = {{ 0xB0E0 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1163, 0x11B7 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_065)
{
// B0E1;B0E1;1102 1163 11B8;B0E1;1102 1163 11B8;
// (냡; 냡; 냡; 냡; 냡; ) HANGUL SYLLABLE NYAB
{
std::array<uint32_t, 1> const c1 = {{ 0xB0E1 }};
std::array<uint32_t, 1> const c2 = {{ 0xB0E1 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1163, 0x11B8 }};
std::array<uint32_t, 1> const c4 = {{ 0xB0E1 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1163, 0x11B8 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_066)
{
// B0E2;B0E2;1102 1163 11B9;B0E2;1102 1163 11B9;
// (냢; 냢; 냢; 냢; 냢; ) HANGUL SYLLABLE NYABS
{
std::array<uint32_t, 1> const c1 = {{ 0xB0E2 }};
std::array<uint32_t, 1> const c2 = {{ 0xB0E2 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1163, 0x11B9 }};
std::array<uint32_t, 1> const c4 = {{ 0xB0E2 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1163, 0x11B9 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_067)
{
// B0E3;B0E3;1102 1163 11BA;B0E3;1102 1163 11BA;
// (냣; 냣; 냣; 냣; 냣; ) HANGUL SYLLABLE NYAS
{
std::array<uint32_t, 1> const c1 = {{ 0xB0E3 }};
std::array<uint32_t, 1> const c2 = {{ 0xB0E3 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1163, 0x11BA }};
std::array<uint32_t, 1> const c4 = {{ 0xB0E3 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1163, 0x11BA }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_068)
{
// B0E4;B0E4;1102 1163 11BB;B0E4;1102 1163 11BB;
// (냤; 냤; 냤; 냤; 냤; ) HANGUL SYLLABLE NYASS
{
std::array<uint32_t, 1> const c1 = {{ 0xB0E4 }};
std::array<uint32_t, 1> const c2 = {{ 0xB0E4 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1163, 0x11BB }};
std::array<uint32_t, 1> const c4 = {{ 0xB0E4 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1163, 0x11BB }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_069)
{
// B0E5;B0E5;1102 1163 11BC;B0E5;1102 1163 11BC;
// (냥; 냥; 냥; 냥; 냥; ) HANGUL SYLLABLE NYANG
{
std::array<uint32_t, 1> const c1 = {{ 0xB0E5 }};
std::array<uint32_t, 1> const c2 = {{ 0xB0E5 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1163, 0x11BC }};
std::array<uint32_t, 1> const c4 = {{ 0xB0E5 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1163, 0x11BC }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_070)
{
// B0E6;B0E6;1102 1163 11BD;B0E6;1102 1163 11BD;
// (냦; 냦; 냦; 냦; 냦; ) HANGUL SYLLABLE NYAJ
{
std::array<uint32_t, 1> const c1 = {{ 0xB0E6 }};
std::array<uint32_t, 1> const c2 = {{ 0xB0E6 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1163, 0x11BD }};
std::array<uint32_t, 1> const c4 = {{ 0xB0E6 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1163, 0x11BD }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_071)
{
// B0E7;B0E7;1102 1163 11BE;B0E7;1102 1163 11BE;
// (냧; 냧; 냧; 냧; 냧; ) HANGUL SYLLABLE NYAC
{
std::array<uint32_t, 1> const c1 = {{ 0xB0E7 }};
std::array<uint32_t, 1> const c2 = {{ 0xB0E7 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1163, 0x11BE }};
std::array<uint32_t, 1> const c4 = {{ 0xB0E7 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1163, 0x11BE }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_072)
{
// B0E8;B0E8;1102 1163 11BF;B0E8;1102 1163 11BF;
// (냨; 냨; 냨; 냨; 냨; ) HANGUL SYLLABLE NYAK
{
std::array<uint32_t, 1> const c1 = {{ 0xB0E8 }};
std::array<uint32_t, 1> const c2 = {{ 0xB0E8 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1163, 0x11BF }};
std::array<uint32_t, 1> const c4 = {{ 0xB0E8 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1163, 0x11BF }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_073)
{
// B0E9;B0E9;1102 1163 11C0;B0E9;1102 1163 11C0;
// (냩; 냩; 냩; 냩; 냩; ) HANGUL SYLLABLE NYAT
{
std::array<uint32_t, 1> const c1 = {{ 0xB0E9 }};
std::array<uint32_t, 1> const c2 = {{ 0xB0E9 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1163, 0x11C0 }};
std::array<uint32_t, 1> const c4 = {{ 0xB0E9 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1163, 0x11C0 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_074)
{
// B0EA;B0EA;1102 1163 11C1;B0EA;1102 1163 11C1;
// (냪; 냪; 냪; 냪; 냪; ) HANGUL SYLLABLE NYAP
{
std::array<uint32_t, 1> const c1 = {{ 0xB0EA }};
std::array<uint32_t, 1> const c2 = {{ 0xB0EA }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1163, 0x11C1 }};
std::array<uint32_t, 1> const c4 = {{ 0xB0EA }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1163, 0x11C1 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_075)
{
// B0EB;B0EB;1102 1163 11C2;B0EB;1102 1163 11C2;
// (냫; 냫; 냫; 냫; 냫; ) HANGUL SYLLABLE NYAH
{
std::array<uint32_t, 1> const c1 = {{ 0xB0EB }};
std::array<uint32_t, 1> const c2 = {{ 0xB0EB }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1163, 0x11C2 }};
std::array<uint32_t, 1> const c4 = {{ 0xB0EB }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1163, 0x11C2 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_076)
{
// B0EC;B0EC;1102 1164;B0EC;1102 1164;
// (냬; 냬; 냬; 냬; 냬; ) HANGUL SYLLABLE NYAE
{
std::array<uint32_t, 1> const c1 = {{ 0xB0EC }};
std::array<uint32_t, 1> const c2 = {{ 0xB0EC }};
std::array<uint32_t, 2> const c3 = {{ 0x1102, 0x1164 }};
std::array<uint32_t, 1> const c4 = {{ 0xB0EC }};
std::array<uint32_t, 2> const c5 = {{ 0x1102, 0x1164 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_077)
{
// B0ED;B0ED;1102 1164 11A8;B0ED;1102 1164 11A8;
// (냭; 냭; 냭; 냭; 냭; ) HANGUL SYLLABLE NYAEG
{
std::array<uint32_t, 1> const c1 = {{ 0xB0ED }};
std::array<uint32_t, 1> const c2 = {{ 0xB0ED }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1164, 0x11A8 }};
std::array<uint32_t, 1> const c4 = {{ 0xB0ED }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1164, 0x11A8 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_078)
{
// B0EE;B0EE;1102 1164 11A9;B0EE;1102 1164 11A9;
// (냮; 냮; 냮; 냮; 냮; ) HANGUL SYLLABLE NYAEGG
{
std::array<uint32_t, 1> const c1 = {{ 0xB0EE }};
std::array<uint32_t, 1> const c2 = {{ 0xB0EE }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1164, 0x11A9 }};
std::array<uint32_t, 1> const c4 = {{ 0xB0EE }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1164, 0x11A9 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_079)
{
// B0EF;B0EF;1102 1164 11AA;B0EF;1102 1164 11AA;
// (냯; 냯; 냯; 냯; 냯; ) HANGUL SYLLABLE NYAEGS
{
std::array<uint32_t, 1> const c1 = {{ 0xB0EF }};
std::array<uint32_t, 1> const c2 = {{ 0xB0EF }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1164, 0x11AA }};
std::array<uint32_t, 1> const c4 = {{ 0xB0EF }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1164, 0x11AA }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_080)
{
// B0F0;B0F0;1102 1164 11AB;B0F0;1102 1164 11AB;
// (냰; 냰; 냰; 냰; 냰; ) HANGUL SYLLABLE NYAEN
{
std::array<uint32_t, 1> const c1 = {{ 0xB0F0 }};
std::array<uint32_t, 1> const c2 = {{ 0xB0F0 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1164, 0x11AB }};
std::array<uint32_t, 1> const c4 = {{ 0xB0F0 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1164, 0x11AB }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_081)
{
// B0F1;B0F1;1102 1164 11AC;B0F1;1102 1164 11AC;
// (냱; 냱; 냱; 냱; 냱; ) HANGUL SYLLABLE NYAENJ
{
std::array<uint32_t, 1> const c1 = {{ 0xB0F1 }};
std::array<uint32_t, 1> const c2 = {{ 0xB0F1 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1164, 0x11AC }};
std::array<uint32_t, 1> const c4 = {{ 0xB0F1 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1164, 0x11AC }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_082)
{
// B0F2;B0F2;1102 1164 11AD;B0F2;1102 1164 11AD;
// (냲; 냲; 냲; 냲; 냲; ) HANGUL SYLLABLE NYAENH
{
std::array<uint32_t, 1> const c1 = {{ 0xB0F2 }};
std::array<uint32_t, 1> const c2 = {{ 0xB0F2 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1164, 0x11AD }};
std::array<uint32_t, 1> const c4 = {{ 0xB0F2 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1164, 0x11AD }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_083)
{
// B0F3;B0F3;1102 1164 11AE;B0F3;1102 1164 11AE;
// (냳; 냳; 냳; 냳; 냳; ) HANGUL SYLLABLE NYAED
{
std::array<uint32_t, 1> const c1 = {{ 0xB0F3 }};
std::array<uint32_t, 1> const c2 = {{ 0xB0F3 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1164, 0x11AE }};
std::array<uint32_t, 1> const c4 = {{ 0xB0F3 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1164, 0x11AE }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_084)
{
// B0F4;B0F4;1102 1164 11AF;B0F4;1102 1164 11AF;
// (냴; 냴; 냴; 냴; 냴; ) HANGUL SYLLABLE NYAEL
{
std::array<uint32_t, 1> const c1 = {{ 0xB0F4 }};
std::array<uint32_t, 1> const c2 = {{ 0xB0F4 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1164, 0x11AF }};
std::array<uint32_t, 1> const c4 = {{ 0xB0F4 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1164, 0x11AF }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_085)
{
// B0F5;B0F5;1102 1164 11B0;B0F5;1102 1164 11B0;
// (냵; 냵; 냵; 냵; 냵; ) HANGUL SYLLABLE NYAELG
{
std::array<uint32_t, 1> const c1 = {{ 0xB0F5 }};
std::array<uint32_t, 1> const c2 = {{ 0xB0F5 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1164, 0x11B0 }};
std::array<uint32_t, 1> const c4 = {{ 0xB0F5 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1164, 0x11B0 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_086)
{
// B0F6;B0F6;1102 1164 11B1;B0F6;1102 1164 11B1;
// (냶; 냶; 냶; 냶; 냶; ) HANGUL SYLLABLE NYAELM
{
std::array<uint32_t, 1> const c1 = {{ 0xB0F6 }};
std::array<uint32_t, 1> const c2 = {{ 0xB0F6 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1164, 0x11B1 }};
std::array<uint32_t, 1> const c4 = {{ 0xB0F6 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1164, 0x11B1 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_087)
{
// B0F7;B0F7;1102 1164 11B2;B0F7;1102 1164 11B2;
// (냷; 냷; 냷; 냷; 냷; ) HANGUL SYLLABLE NYAELB
{
std::array<uint32_t, 1> const c1 = {{ 0xB0F7 }};
std::array<uint32_t, 1> const c2 = {{ 0xB0F7 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1164, 0x11B2 }};
std::array<uint32_t, 1> const c4 = {{ 0xB0F7 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1164, 0x11B2 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_088)
{
// B0F8;B0F8;1102 1164 11B3;B0F8;1102 1164 11B3;
// (냸; 냸; 냸; 냸; 냸; ) HANGUL SYLLABLE NYAELS
{
std::array<uint32_t, 1> const c1 = {{ 0xB0F8 }};
std::array<uint32_t, 1> const c2 = {{ 0xB0F8 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1164, 0x11B3 }};
std::array<uint32_t, 1> const c4 = {{ 0xB0F8 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1164, 0x11B3 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_089)
{
// B0F9;B0F9;1102 1164 11B4;B0F9;1102 1164 11B4;
// (냹; 냹; 냹; 냹; 냹; ) HANGUL SYLLABLE NYAELT
{
std::array<uint32_t, 1> const c1 = {{ 0xB0F9 }};
std::array<uint32_t, 1> const c2 = {{ 0xB0F9 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1164, 0x11B4 }};
std::array<uint32_t, 1> const c4 = {{ 0xB0F9 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1164, 0x11B4 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_090)
{
// B0FA;B0FA;1102 1164 11B5;B0FA;1102 1164 11B5;
// (냺; 냺; 냺; 냺; 냺; ) HANGUL SYLLABLE NYAELP
{
std::array<uint32_t, 1> const c1 = {{ 0xB0FA }};
std::array<uint32_t, 1> const c2 = {{ 0xB0FA }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1164, 0x11B5 }};
std::array<uint32_t, 1> const c4 = {{ 0xB0FA }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1164, 0x11B5 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_091)
{
// B0FB;B0FB;1102 1164 11B6;B0FB;1102 1164 11B6;
// (냻; 냻; 냻; 냻; 냻; ) HANGUL SYLLABLE NYAELH
{
std::array<uint32_t, 1> const c1 = {{ 0xB0FB }};
std::array<uint32_t, 1> const c2 = {{ 0xB0FB }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1164, 0x11B6 }};
std::array<uint32_t, 1> const c4 = {{ 0xB0FB }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1164, 0x11B6 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_092)
{
// B0FC;B0FC;1102 1164 11B7;B0FC;1102 1164 11B7;
// (냼; 냼; 냼; 냼; 냼; ) HANGUL SYLLABLE NYAEM
{
std::array<uint32_t, 1> const c1 = {{ 0xB0FC }};
std::array<uint32_t, 1> const c2 = {{ 0xB0FC }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1164, 0x11B7 }};
std::array<uint32_t, 1> const c4 = {{ 0xB0FC }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1164, 0x11B7 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_093)
{
// B0FD;B0FD;1102 1164 11B8;B0FD;1102 1164 11B8;
// (냽; 냽; 냽; 냽; 냽; ) HANGUL SYLLABLE NYAEB
{
std::array<uint32_t, 1> const c1 = {{ 0xB0FD }};
std::array<uint32_t, 1> const c2 = {{ 0xB0FD }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1164, 0x11B8 }};
std::array<uint32_t, 1> const c4 = {{ 0xB0FD }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1164, 0x11B8 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_094)
{
// B0FE;B0FE;1102 1164 11B9;B0FE;1102 1164 11B9;
// (냾; 냾; 냾; 냾; 냾; ) HANGUL SYLLABLE NYAEBS
{
std::array<uint32_t, 1> const c1 = {{ 0xB0FE }};
std::array<uint32_t, 1> const c2 = {{ 0xB0FE }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1164, 0x11B9 }};
std::array<uint32_t, 1> const c4 = {{ 0xB0FE }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1164, 0x11B9 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_095)
{
// B0FF;B0FF;1102 1164 11BA;B0FF;1102 1164 11BA;
// (냿; 냿; 냿; 냿; 냿; ) HANGUL SYLLABLE NYAES
{
std::array<uint32_t, 1> const c1 = {{ 0xB0FF }};
std::array<uint32_t, 1> const c2 = {{ 0xB0FF }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1164, 0x11BA }};
std::array<uint32_t, 1> const c4 = {{ 0xB0FF }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1164, 0x11BA }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_096)
{
// B100;B100;1102 1164 11BB;B100;1102 1164 11BB;
// (넀; 넀; 넀; 넀; 넀; ) HANGUL SYLLABLE NYAESS
{
std::array<uint32_t, 1> const c1 = {{ 0xB100 }};
std::array<uint32_t, 1> const c2 = {{ 0xB100 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1164, 0x11BB }};
std::array<uint32_t, 1> const c4 = {{ 0xB100 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1164, 0x11BB }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_097)
{
// B101;B101;1102 1164 11BC;B101;1102 1164 11BC;
// (넁; 넁; 넁; 넁; 넁; ) HANGUL SYLLABLE NYAENG
{
std::array<uint32_t, 1> const c1 = {{ 0xB101 }};
std::array<uint32_t, 1> const c2 = {{ 0xB101 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1164, 0x11BC }};
std::array<uint32_t, 1> const c4 = {{ 0xB101 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1164, 0x11BC }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_098)
{
// B102;B102;1102 1164 11BD;B102;1102 1164 11BD;
// (넂; 넂; 넂; 넂; 넂; ) HANGUL SYLLABLE NYAEJ
{
std::array<uint32_t, 1> const c1 = {{ 0xB102 }};
std::array<uint32_t, 1> const c2 = {{ 0xB102 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1164, 0x11BD }};
std::array<uint32_t, 1> const c4 = {{ 0xB102 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1164, 0x11BD }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_099)
{
// B103;B103;1102 1164 11BE;B103;1102 1164 11BE;
// (넃; 넃; 넃; 넃; 넃; ) HANGUL SYLLABLE NYAEC
{
std::array<uint32_t, 1> const c1 = {{ 0xB103 }};
std::array<uint32_t, 1> const c2 = {{ 0xB103 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1164, 0x11BE }};
std::array<uint32_t, 1> const c4 = {{ 0xB103 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1164, 0x11BE }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_100)
{
// B104;B104;1102 1164 11BF;B104;1102 1164 11BF;
// (넄; 넄; 넄; 넄; 넄; ) HANGUL SYLLABLE NYAEK
{
std::array<uint32_t, 1> const c1 = {{ 0xB104 }};
std::array<uint32_t, 1> const c2 = {{ 0xB104 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1164, 0x11BF }};
std::array<uint32_t, 1> const c4 = {{ 0xB104 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1164, 0x11BF }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_101)
{
// B105;B105;1102 1164 11C0;B105;1102 1164 11C0;
// (넅; 넅; 넅; 넅; 넅; ) HANGUL SYLLABLE NYAET
{
std::array<uint32_t, 1> const c1 = {{ 0xB105 }};
std::array<uint32_t, 1> const c2 = {{ 0xB105 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1164, 0x11C0 }};
std::array<uint32_t, 1> const c4 = {{ 0xB105 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1164, 0x11C0 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_102)
{
// B106;B106;1102 1164 11C1;B106;1102 1164 11C1;
// (넆; 넆; 넆; 넆; 넆; ) HANGUL SYLLABLE NYAEP
{
std::array<uint32_t, 1> const c1 = {{ 0xB106 }};
std::array<uint32_t, 1> const c2 = {{ 0xB106 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1164, 0x11C1 }};
std::array<uint32_t, 1> const c4 = {{ 0xB106 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1164, 0x11C1 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_103)
{
// B107;B107;1102 1164 11C2;B107;1102 1164 11C2;
// (넇; 넇; 넇; 넇; 넇; ) HANGUL SYLLABLE NYAEH
{
std::array<uint32_t, 1> const c1 = {{ 0xB107 }};
std::array<uint32_t, 1> const c2 = {{ 0xB107 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1164, 0x11C2 }};
std::array<uint32_t, 1> const c4 = {{ 0xB107 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1164, 0x11C2 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_104)
{
// B108;B108;1102 1165;B108;1102 1165;
// (너; 너; 너; 너; 너; ) HANGUL SYLLABLE NEO
{
std::array<uint32_t, 1> const c1 = {{ 0xB108 }};
std::array<uint32_t, 1> const c2 = {{ 0xB108 }};
std::array<uint32_t, 2> const c3 = {{ 0x1102, 0x1165 }};
std::array<uint32_t, 1> const c4 = {{ 0xB108 }};
std::array<uint32_t, 2> const c5 = {{ 0x1102, 0x1165 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_105)
{
// B109;B109;1102 1165 11A8;B109;1102 1165 11A8;
// (넉; 넉; 넉; 넉; 넉; ) HANGUL SYLLABLE NEOG
{
std::array<uint32_t, 1> const c1 = {{ 0xB109 }};
std::array<uint32_t, 1> const c2 = {{ 0xB109 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1165, 0x11A8 }};
std::array<uint32_t, 1> const c4 = {{ 0xB109 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1165, 0x11A8 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_106)
{
// B10A;B10A;1102 1165 11A9;B10A;1102 1165 11A9;
// (넊; 넊; 넊; 넊; 넊; ) HANGUL SYLLABLE NEOGG
{
std::array<uint32_t, 1> const c1 = {{ 0xB10A }};
std::array<uint32_t, 1> const c2 = {{ 0xB10A }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1165, 0x11A9 }};
std::array<uint32_t, 1> const c4 = {{ 0xB10A }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1165, 0x11A9 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_107)
{
// B10B;B10B;1102 1165 11AA;B10B;1102 1165 11AA;
// (넋; 넋; 넋; 넋; 넋; ) HANGUL SYLLABLE NEOGS
{
std::array<uint32_t, 1> const c1 = {{ 0xB10B }};
std::array<uint32_t, 1> const c2 = {{ 0xB10B }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1165, 0x11AA }};
std::array<uint32_t, 1> const c4 = {{ 0xB10B }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1165, 0x11AA }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_108)
{
// B10C;B10C;1102 1165 11AB;B10C;1102 1165 11AB;
// (넌; 넌; 넌; 넌; 넌; ) HANGUL SYLLABLE NEON
{
std::array<uint32_t, 1> const c1 = {{ 0xB10C }};
std::array<uint32_t, 1> const c2 = {{ 0xB10C }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1165, 0x11AB }};
std::array<uint32_t, 1> const c4 = {{ 0xB10C }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1165, 0x11AB }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_109)
{
// B10D;B10D;1102 1165 11AC;B10D;1102 1165 11AC;
// (넍; 넍; 넍; 넍; 넍; ) HANGUL SYLLABLE NEONJ
{
std::array<uint32_t, 1> const c1 = {{ 0xB10D }};
std::array<uint32_t, 1> const c2 = {{ 0xB10D }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1165, 0x11AC }};
std::array<uint32_t, 1> const c4 = {{ 0xB10D }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1165, 0x11AC }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_110)
{
// B10E;B10E;1102 1165 11AD;B10E;1102 1165 11AD;
// (넎; 넎; 넎; 넎; 넎; ) HANGUL SYLLABLE NEONH
{
std::array<uint32_t, 1> const c1 = {{ 0xB10E }};
std::array<uint32_t, 1> const c2 = {{ 0xB10E }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1165, 0x11AD }};
std::array<uint32_t, 1> const c4 = {{ 0xB10E }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1165, 0x11AD }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_111)
{
// B10F;B10F;1102 1165 11AE;B10F;1102 1165 11AE;
// (넏; 넏; 넏; 넏; 넏; ) HANGUL SYLLABLE NEOD
{
std::array<uint32_t, 1> const c1 = {{ 0xB10F }};
std::array<uint32_t, 1> const c2 = {{ 0xB10F }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1165, 0x11AE }};
std::array<uint32_t, 1> const c4 = {{ 0xB10F }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1165, 0x11AE }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_112)
{
// B110;B110;1102 1165 11AF;B110;1102 1165 11AF;
// (널; 널; 널; 널; 널; ) HANGUL SYLLABLE NEOL
{
std::array<uint32_t, 1> const c1 = {{ 0xB110 }};
std::array<uint32_t, 1> const c2 = {{ 0xB110 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1165, 0x11AF }};
std::array<uint32_t, 1> const c4 = {{ 0xB110 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1165, 0x11AF }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_113)
{
// B111;B111;1102 1165 11B0;B111;1102 1165 11B0;
// (넑; 넑; 넑; 넑; 넑; ) HANGUL SYLLABLE NEOLG
{
std::array<uint32_t, 1> const c1 = {{ 0xB111 }};
std::array<uint32_t, 1> const c2 = {{ 0xB111 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1165, 0x11B0 }};
std::array<uint32_t, 1> const c4 = {{ 0xB111 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1165, 0x11B0 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_114)
{
// B112;B112;1102 1165 11B1;B112;1102 1165 11B1;
// (넒; 넒; 넒; 넒; 넒; ) HANGUL SYLLABLE NEOLM
{
std::array<uint32_t, 1> const c1 = {{ 0xB112 }};
std::array<uint32_t, 1> const c2 = {{ 0xB112 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1165, 0x11B1 }};
std::array<uint32_t, 1> const c4 = {{ 0xB112 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1165, 0x11B1 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_115)
{
// B113;B113;1102 1165 11B2;B113;1102 1165 11B2;
// (넓; 넓; 넓; 넓; 넓; ) HANGUL SYLLABLE NEOLB
{
std::array<uint32_t, 1> const c1 = {{ 0xB113 }};
std::array<uint32_t, 1> const c2 = {{ 0xB113 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1165, 0x11B2 }};
std::array<uint32_t, 1> const c4 = {{ 0xB113 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1165, 0x11B2 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_116)
{
// B114;B114;1102 1165 11B3;B114;1102 1165 11B3;
// (넔; 넔; 넔; 넔; 넔; ) HANGUL SYLLABLE NEOLS
{
std::array<uint32_t, 1> const c1 = {{ 0xB114 }};
std::array<uint32_t, 1> const c2 = {{ 0xB114 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1165, 0x11B3 }};
std::array<uint32_t, 1> const c4 = {{ 0xB114 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1165, 0x11B3 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_117)
{
// B115;B115;1102 1165 11B4;B115;1102 1165 11B4;
// (넕; 넕; 넕; 넕; 넕; ) HANGUL SYLLABLE NEOLT
{
std::array<uint32_t, 1> const c1 = {{ 0xB115 }};
std::array<uint32_t, 1> const c2 = {{ 0xB115 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1165, 0x11B4 }};
std::array<uint32_t, 1> const c4 = {{ 0xB115 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1165, 0x11B4 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_118)
{
// B116;B116;1102 1165 11B5;B116;1102 1165 11B5;
// (넖; 넖; 넖; 넖; 넖; ) HANGUL SYLLABLE NEOLP
{
std::array<uint32_t, 1> const c1 = {{ 0xB116 }};
std::array<uint32_t, 1> const c2 = {{ 0xB116 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1165, 0x11B5 }};
std::array<uint32_t, 1> const c4 = {{ 0xB116 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1165, 0x11B5 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_119)
{
// B117;B117;1102 1165 11B6;B117;1102 1165 11B6;
// (넗; 넗; 넗; 넗; 넗; ) HANGUL SYLLABLE NEOLH
{
std::array<uint32_t, 1> const c1 = {{ 0xB117 }};
std::array<uint32_t, 1> const c2 = {{ 0xB117 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1165, 0x11B6 }};
std::array<uint32_t, 1> const c4 = {{ 0xB117 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1165, 0x11B6 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_120)
{
// B118;B118;1102 1165 11B7;B118;1102 1165 11B7;
// (넘; 넘; 넘; 넘; 넘; ) HANGUL SYLLABLE NEOM
{
std::array<uint32_t, 1> const c1 = {{ 0xB118 }};
std::array<uint32_t, 1> const c2 = {{ 0xB118 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1165, 0x11B7 }};
std::array<uint32_t, 1> const c4 = {{ 0xB118 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1165, 0x11B7 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_121)
{
// B119;B119;1102 1165 11B8;B119;1102 1165 11B8;
// (넙; 넙; 넙; 넙; 넙; ) HANGUL SYLLABLE NEOB
{
std::array<uint32_t, 1> const c1 = {{ 0xB119 }};
std::array<uint32_t, 1> const c2 = {{ 0xB119 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1165, 0x11B8 }};
std::array<uint32_t, 1> const c4 = {{ 0xB119 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1165, 0x11B8 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_122)
{
// B11A;B11A;1102 1165 11B9;B11A;1102 1165 11B9;
// (넚; 넚; 넚; 넚; 넚; ) HANGUL SYLLABLE NEOBS
{
std::array<uint32_t, 1> const c1 = {{ 0xB11A }};
std::array<uint32_t, 1> const c2 = {{ 0xB11A }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1165, 0x11B9 }};
std::array<uint32_t, 1> const c4 = {{ 0xB11A }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1165, 0x11B9 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_123)
{
// B11B;B11B;1102 1165 11BA;B11B;1102 1165 11BA;
// (넛; 넛; 넛; 넛; 넛; ) HANGUL SYLLABLE NEOS
{
std::array<uint32_t, 1> const c1 = {{ 0xB11B }};
std::array<uint32_t, 1> const c2 = {{ 0xB11B }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1165, 0x11BA }};
std::array<uint32_t, 1> const c4 = {{ 0xB11B }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1165, 0x11BA }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_124)
{
// B11C;B11C;1102 1165 11BB;B11C;1102 1165 11BB;
// (넜; 넜; 넜; 넜; 넜; ) HANGUL SYLLABLE NEOSS
{
std::array<uint32_t, 1> const c1 = {{ 0xB11C }};
std::array<uint32_t, 1> const c2 = {{ 0xB11C }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1165, 0x11BB }};
std::array<uint32_t, 1> const c4 = {{ 0xB11C }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1165, 0x11BB }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_125)
{
// B11D;B11D;1102 1165 11BC;B11D;1102 1165 11BC;
// (넝; 넝; 넝; 넝; 넝; ) HANGUL SYLLABLE NEONG
{
std::array<uint32_t, 1> const c1 = {{ 0xB11D }};
std::array<uint32_t, 1> const c2 = {{ 0xB11D }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1165, 0x11BC }};
std::array<uint32_t, 1> const c4 = {{ 0xB11D }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1165, 0x11BC }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_126)
{
// B11E;B11E;1102 1165 11BD;B11E;1102 1165 11BD;
// (넞; 넞; 넞; 넞; 넞; ) HANGUL SYLLABLE NEOJ
{
std::array<uint32_t, 1> const c1 = {{ 0xB11E }};
std::array<uint32_t, 1> const c2 = {{ 0xB11E }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1165, 0x11BD }};
std::array<uint32_t, 1> const c4 = {{ 0xB11E }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1165, 0x11BD }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_127)
{
// B11F;B11F;1102 1165 11BE;B11F;1102 1165 11BE;
// (넟; 넟; 넟; 넟; 넟; ) HANGUL SYLLABLE NEOC
{
std::array<uint32_t, 1> const c1 = {{ 0xB11F }};
std::array<uint32_t, 1> const c2 = {{ 0xB11F }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1165, 0x11BE }};
std::array<uint32_t, 1> const c4 = {{ 0xB11F }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1165, 0x11BE }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_128)
{
// B120;B120;1102 1165 11BF;B120;1102 1165 11BF;
// (넠; 넠; 넠; 넠; 넠; ) HANGUL SYLLABLE NEOK
{
std::array<uint32_t, 1> const c1 = {{ 0xB120 }};
std::array<uint32_t, 1> const c2 = {{ 0xB120 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1165, 0x11BF }};
std::array<uint32_t, 1> const c4 = {{ 0xB120 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1165, 0x11BF }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_129)
{
// B121;B121;1102 1165 11C0;B121;1102 1165 11C0;
// (넡; 넡; 넡; 넡; 넡; ) HANGUL SYLLABLE NEOT
{
std::array<uint32_t, 1> const c1 = {{ 0xB121 }};
std::array<uint32_t, 1> const c2 = {{ 0xB121 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1165, 0x11C0 }};
std::array<uint32_t, 1> const c4 = {{ 0xB121 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1165, 0x11C0 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_130)
{
// B122;B122;1102 1165 11C1;B122;1102 1165 11C1;
// (넢; 넢; 넢; 넢; 넢; ) HANGUL SYLLABLE NEOP
{
std::array<uint32_t, 1> const c1 = {{ 0xB122 }};
std::array<uint32_t, 1> const c2 = {{ 0xB122 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1165, 0x11C1 }};
std::array<uint32_t, 1> const c4 = {{ 0xB122 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1165, 0x11C1 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_131)
{
// B123;B123;1102 1165 11C2;B123;1102 1165 11C2;
// (넣; 넣; 넣; 넣; 넣; ) HANGUL SYLLABLE NEOH
{
std::array<uint32_t, 1> const c1 = {{ 0xB123 }};
std::array<uint32_t, 1> const c2 = {{ 0xB123 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1165, 0x11C2 }};
std::array<uint32_t, 1> const c4 = {{ 0xB123 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1165, 0x11C2 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_132)
{
// B124;B124;1102 1166;B124;1102 1166;
// (네; 네; 네; 네; 네; ) HANGUL SYLLABLE NE
{
std::array<uint32_t, 1> const c1 = {{ 0xB124 }};
std::array<uint32_t, 1> const c2 = {{ 0xB124 }};
std::array<uint32_t, 2> const c3 = {{ 0x1102, 0x1166 }};
std::array<uint32_t, 1> const c4 = {{ 0xB124 }};
std::array<uint32_t, 2> const c5 = {{ 0x1102, 0x1166 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_133)
{
// B125;B125;1102 1166 11A8;B125;1102 1166 11A8;
// (넥; 넥; 넥; 넥; 넥; ) HANGUL SYLLABLE NEG
{
std::array<uint32_t, 1> const c1 = {{ 0xB125 }};
std::array<uint32_t, 1> const c2 = {{ 0xB125 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1166, 0x11A8 }};
std::array<uint32_t, 1> const c4 = {{ 0xB125 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1166, 0x11A8 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_134)
{
// B126;B126;1102 1166 11A9;B126;1102 1166 11A9;
// (넦; 넦; 넦; 넦; 넦; ) HANGUL SYLLABLE NEGG
{
std::array<uint32_t, 1> const c1 = {{ 0xB126 }};
std::array<uint32_t, 1> const c2 = {{ 0xB126 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1166, 0x11A9 }};
std::array<uint32_t, 1> const c4 = {{ 0xB126 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1166, 0x11A9 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_135)
{
// B127;B127;1102 1166 11AA;B127;1102 1166 11AA;
// (넧; 넧; 넧; 넧; 넧; ) HANGUL SYLLABLE NEGS
{
std::array<uint32_t, 1> const c1 = {{ 0xB127 }};
std::array<uint32_t, 1> const c2 = {{ 0xB127 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1166, 0x11AA }};
std::array<uint32_t, 1> const c4 = {{ 0xB127 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1166, 0x11AA }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_136)
{
// B128;B128;1102 1166 11AB;B128;1102 1166 11AB;
// (넨; 넨; 넨; 넨; 넨; ) HANGUL SYLLABLE NEN
{
std::array<uint32_t, 1> const c1 = {{ 0xB128 }};
std::array<uint32_t, 1> const c2 = {{ 0xB128 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1166, 0x11AB }};
std::array<uint32_t, 1> const c4 = {{ 0xB128 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1166, 0x11AB }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_137)
{
// B129;B129;1102 1166 11AC;B129;1102 1166 11AC;
// (넩; 넩; 넩; 넩; 넩; ) HANGUL SYLLABLE NENJ
{
std::array<uint32_t, 1> const c1 = {{ 0xB129 }};
std::array<uint32_t, 1> const c2 = {{ 0xB129 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1166, 0x11AC }};
std::array<uint32_t, 1> const c4 = {{ 0xB129 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1166, 0x11AC }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_138)
{
// B12A;B12A;1102 1166 11AD;B12A;1102 1166 11AD;
// (넪; 넪; 넪; 넪; 넪; ) HANGUL SYLLABLE NENH
{
std::array<uint32_t, 1> const c1 = {{ 0xB12A }};
std::array<uint32_t, 1> const c2 = {{ 0xB12A }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1166, 0x11AD }};
std::array<uint32_t, 1> const c4 = {{ 0xB12A }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1166, 0x11AD }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_139)
{
// B12B;B12B;1102 1166 11AE;B12B;1102 1166 11AE;
// (넫; 넫; 넫; 넫; 넫; ) HANGUL SYLLABLE NED
{
std::array<uint32_t, 1> const c1 = {{ 0xB12B }};
std::array<uint32_t, 1> const c2 = {{ 0xB12B }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1166, 0x11AE }};
std::array<uint32_t, 1> const c4 = {{ 0xB12B }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1166, 0x11AE }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_140)
{
// B12C;B12C;1102 1166 11AF;B12C;1102 1166 11AF;
// (넬; 넬; 넬; 넬; 넬; ) HANGUL SYLLABLE NEL
{
std::array<uint32_t, 1> const c1 = {{ 0xB12C }};
std::array<uint32_t, 1> const c2 = {{ 0xB12C }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1166, 0x11AF }};
std::array<uint32_t, 1> const c4 = {{ 0xB12C }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1166, 0x11AF }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_141)
{
// B12D;B12D;1102 1166 11B0;B12D;1102 1166 11B0;
// (넭; 넭; 넭; 넭; 넭; ) HANGUL SYLLABLE NELG
{
std::array<uint32_t, 1> const c1 = {{ 0xB12D }};
std::array<uint32_t, 1> const c2 = {{ 0xB12D }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1166, 0x11B0 }};
std::array<uint32_t, 1> const c4 = {{ 0xB12D }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1166, 0x11B0 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_142)
{
// B12E;B12E;1102 1166 11B1;B12E;1102 1166 11B1;
// (넮; 넮; 넮; 넮; 넮; ) HANGUL SYLLABLE NELM
{
std::array<uint32_t, 1> const c1 = {{ 0xB12E }};
std::array<uint32_t, 1> const c2 = {{ 0xB12E }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1166, 0x11B1 }};
std::array<uint32_t, 1> const c4 = {{ 0xB12E }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1166, 0x11B1 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_143)
{
// B12F;B12F;1102 1166 11B2;B12F;1102 1166 11B2;
// (넯; 넯; 넯; 넯; 넯; ) HANGUL SYLLABLE NELB
{
std::array<uint32_t, 1> const c1 = {{ 0xB12F }};
std::array<uint32_t, 1> const c2 = {{ 0xB12F }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1166, 0x11B2 }};
std::array<uint32_t, 1> const c4 = {{ 0xB12F }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1166, 0x11B2 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_144)
{
// B130;B130;1102 1166 11B3;B130;1102 1166 11B3;
// (넰; 넰; 넰; 넰; 넰; ) HANGUL SYLLABLE NELS
{
std::array<uint32_t, 1> const c1 = {{ 0xB130 }};
std::array<uint32_t, 1> const c2 = {{ 0xB130 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1166, 0x11B3 }};
std::array<uint32_t, 1> const c4 = {{ 0xB130 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1166, 0x11B3 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_145)
{
// B131;B131;1102 1166 11B4;B131;1102 1166 11B4;
// (넱; 넱; 넱; 넱; 넱; ) HANGUL SYLLABLE NELT
{
std::array<uint32_t, 1> const c1 = {{ 0xB131 }};
std::array<uint32_t, 1> const c2 = {{ 0xB131 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1166, 0x11B4 }};
std::array<uint32_t, 1> const c4 = {{ 0xB131 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1166, 0x11B4 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_146)
{
// B132;B132;1102 1166 11B5;B132;1102 1166 11B5;
// (넲; 넲; 넲; 넲; 넲; ) HANGUL SYLLABLE NELP
{
std::array<uint32_t, 1> const c1 = {{ 0xB132 }};
std::array<uint32_t, 1> const c2 = {{ 0xB132 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1166, 0x11B5 }};
std::array<uint32_t, 1> const c4 = {{ 0xB132 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1166, 0x11B5 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_147)
{
// B133;B133;1102 1166 11B6;B133;1102 1166 11B6;
// (넳; 넳; 넳; 넳; 넳; ) HANGUL SYLLABLE NELH
{
std::array<uint32_t, 1> const c1 = {{ 0xB133 }};
std::array<uint32_t, 1> const c2 = {{ 0xB133 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1166, 0x11B6 }};
std::array<uint32_t, 1> const c4 = {{ 0xB133 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1166, 0x11B6 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_148)
{
// B134;B134;1102 1166 11B7;B134;1102 1166 11B7;
// (넴; 넴; 넴; 넴; 넴; ) HANGUL SYLLABLE NEM
{
std::array<uint32_t, 1> const c1 = {{ 0xB134 }};
std::array<uint32_t, 1> const c2 = {{ 0xB134 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1166, 0x11B7 }};
std::array<uint32_t, 1> const c4 = {{ 0xB134 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1166, 0x11B7 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_149)
{
// B135;B135;1102 1166 11B8;B135;1102 1166 11B8;
// (넵; 넵; 넵; 넵; 넵; ) HANGUL SYLLABLE NEB
{
std::array<uint32_t, 1> const c1 = {{ 0xB135 }};
std::array<uint32_t, 1> const c2 = {{ 0xB135 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1166, 0x11B8 }};
std::array<uint32_t, 1> const c4 = {{ 0xB135 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1166, 0x11B8 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_150)
{
// B136;B136;1102 1166 11B9;B136;1102 1166 11B9;
// (넶; 넶; 넶; 넶; 넶; ) HANGUL SYLLABLE NEBS
{
std::array<uint32_t, 1> const c1 = {{ 0xB136 }};
std::array<uint32_t, 1> const c2 = {{ 0xB136 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1166, 0x11B9 }};
std::array<uint32_t, 1> const c4 = {{ 0xB136 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1166, 0x11B9 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_151)
{
// B137;B137;1102 1166 11BA;B137;1102 1166 11BA;
// (넷; 넷; 넷; 넷; 넷; ) HANGUL SYLLABLE NES
{
std::array<uint32_t, 1> const c1 = {{ 0xB137 }};
std::array<uint32_t, 1> const c2 = {{ 0xB137 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1166, 0x11BA }};
std::array<uint32_t, 1> const c4 = {{ 0xB137 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1166, 0x11BA }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_152)
{
// B138;B138;1102 1166 11BB;B138;1102 1166 11BB;
// (넸; 넸; 넸; 넸; 넸; ) HANGUL SYLLABLE NESS
{
std::array<uint32_t, 1> const c1 = {{ 0xB138 }};
std::array<uint32_t, 1> const c2 = {{ 0xB138 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1166, 0x11BB }};
std::array<uint32_t, 1> const c4 = {{ 0xB138 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1166, 0x11BB }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_153)
{
// B139;B139;1102 1166 11BC;B139;1102 1166 11BC;
// (넹; 넹; 넹; 넹; 넹; ) HANGUL SYLLABLE NENG
{
std::array<uint32_t, 1> const c1 = {{ 0xB139 }};
std::array<uint32_t, 1> const c2 = {{ 0xB139 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1166, 0x11BC }};
std::array<uint32_t, 1> const c4 = {{ 0xB139 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1166, 0x11BC }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_154)
{
// B13A;B13A;1102 1166 11BD;B13A;1102 1166 11BD;
// (넺; 넺; 넺; 넺; 넺; ) HANGUL SYLLABLE NEJ
{
std::array<uint32_t, 1> const c1 = {{ 0xB13A }};
std::array<uint32_t, 1> const c2 = {{ 0xB13A }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1166, 0x11BD }};
std::array<uint32_t, 1> const c4 = {{ 0xB13A }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1166, 0x11BD }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_155)
{
// B13B;B13B;1102 1166 11BE;B13B;1102 1166 11BE;
// (넻; 넻; 넻; 넻; 넻; ) HANGUL SYLLABLE NEC
{
std::array<uint32_t, 1> const c1 = {{ 0xB13B }};
std::array<uint32_t, 1> const c2 = {{ 0xB13B }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1166, 0x11BE }};
std::array<uint32_t, 1> const c4 = {{ 0xB13B }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1166, 0x11BE }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_156)
{
// B13C;B13C;1102 1166 11BF;B13C;1102 1166 11BF;
// (넼; 넼; 넼; 넼; 넼; ) HANGUL SYLLABLE NEK
{
std::array<uint32_t, 1> const c1 = {{ 0xB13C }};
std::array<uint32_t, 1> const c2 = {{ 0xB13C }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1166, 0x11BF }};
std::array<uint32_t, 1> const c4 = {{ 0xB13C }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1166, 0x11BF }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_157)
{
// B13D;B13D;1102 1166 11C0;B13D;1102 1166 11C0;
// (넽; 넽; 넽; 넽; 넽; ) HANGUL SYLLABLE NET
{
std::array<uint32_t, 1> const c1 = {{ 0xB13D }};
std::array<uint32_t, 1> const c2 = {{ 0xB13D }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1166, 0x11C0 }};
std::array<uint32_t, 1> const c4 = {{ 0xB13D }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1166, 0x11C0 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_158)
{
// B13E;B13E;1102 1166 11C1;B13E;1102 1166 11C1;
// (넾; 넾; 넾; 넾; 넾; ) HANGUL SYLLABLE NEP
{
std::array<uint32_t, 1> const c1 = {{ 0xB13E }};
std::array<uint32_t, 1> const c2 = {{ 0xB13E }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1166, 0x11C1 }};
std::array<uint32_t, 1> const c4 = {{ 0xB13E }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1166, 0x11C1 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_159)
{
// B13F;B13F;1102 1166 11C2;B13F;1102 1166 11C2;
// (넿; 넿; 넿; 넿; 넿; ) HANGUL SYLLABLE NEH
{
std::array<uint32_t, 1> const c1 = {{ 0xB13F }};
std::array<uint32_t, 1> const c2 = {{ 0xB13F }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1166, 0x11C2 }};
std::array<uint32_t, 1> const c4 = {{ 0xB13F }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1166, 0x11C2 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_160)
{
// B140;B140;1102 1167;B140;1102 1167;
// (녀; 녀; 녀; 녀; 녀; ) HANGUL SYLLABLE NYEO
{
std::array<uint32_t, 1> const c1 = {{ 0xB140 }};
std::array<uint32_t, 1> const c2 = {{ 0xB140 }};
std::array<uint32_t, 2> const c3 = {{ 0x1102, 0x1167 }};
std::array<uint32_t, 1> const c4 = {{ 0xB140 }};
std::array<uint32_t, 2> const c5 = {{ 0x1102, 0x1167 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_161)
{
// B141;B141;1102 1167 11A8;B141;1102 1167 11A8;
// (녁; 녁; 녁; 녁; 녁; ) HANGUL SYLLABLE NYEOG
{
std::array<uint32_t, 1> const c1 = {{ 0xB141 }};
std::array<uint32_t, 1> const c2 = {{ 0xB141 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1167, 0x11A8 }};
std::array<uint32_t, 1> const c4 = {{ 0xB141 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1167, 0x11A8 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_162)
{
// B142;B142;1102 1167 11A9;B142;1102 1167 11A9;
// (녂; 녂; 녂; 녂; 녂; ) HANGUL SYLLABLE NYEOGG
{
std::array<uint32_t, 1> const c1 = {{ 0xB142 }};
std::array<uint32_t, 1> const c2 = {{ 0xB142 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1167, 0x11A9 }};
std::array<uint32_t, 1> const c4 = {{ 0xB142 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1167, 0x11A9 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_163)
{
// B143;B143;1102 1167 11AA;B143;1102 1167 11AA;
// (녃; 녃; 녃; 녃; 녃; ) HANGUL SYLLABLE NYEOGS
{
std::array<uint32_t, 1> const c1 = {{ 0xB143 }};
std::array<uint32_t, 1> const c2 = {{ 0xB143 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1167, 0x11AA }};
std::array<uint32_t, 1> const c4 = {{ 0xB143 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1167, 0x11AA }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_164)
{
// B144;B144;1102 1167 11AB;B144;1102 1167 11AB;
// (년; 년; 년; 년; 년; ) HANGUL SYLLABLE NYEON
{
std::array<uint32_t, 1> const c1 = {{ 0xB144 }};
std::array<uint32_t, 1> const c2 = {{ 0xB144 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1167, 0x11AB }};
std::array<uint32_t, 1> const c4 = {{ 0xB144 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1167, 0x11AB }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_165)
{
// B145;B145;1102 1167 11AC;B145;1102 1167 11AC;
// (녅; 녅; 녅; 녅; 녅; ) HANGUL SYLLABLE NYEONJ
{
std::array<uint32_t, 1> const c1 = {{ 0xB145 }};
std::array<uint32_t, 1> const c2 = {{ 0xB145 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1167, 0x11AC }};
std::array<uint32_t, 1> const c4 = {{ 0xB145 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1167, 0x11AC }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_166)
{
// B146;B146;1102 1167 11AD;B146;1102 1167 11AD;
// (녆; 녆; 녆; 녆; 녆; ) HANGUL SYLLABLE NYEONH
{
std::array<uint32_t, 1> const c1 = {{ 0xB146 }};
std::array<uint32_t, 1> const c2 = {{ 0xB146 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1167, 0x11AD }};
std::array<uint32_t, 1> const c4 = {{ 0xB146 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1167, 0x11AD }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_167)
{
// B147;B147;1102 1167 11AE;B147;1102 1167 11AE;
// (녇; 녇; 녇; 녇; 녇; ) HANGUL SYLLABLE NYEOD
{
std::array<uint32_t, 1> const c1 = {{ 0xB147 }};
std::array<uint32_t, 1> const c2 = {{ 0xB147 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1167, 0x11AE }};
std::array<uint32_t, 1> const c4 = {{ 0xB147 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1167, 0x11AE }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_168)
{
// B148;B148;1102 1167 11AF;B148;1102 1167 11AF;
// (녈; 녈; 녈; 녈; 녈; ) HANGUL SYLLABLE NYEOL
{
std::array<uint32_t, 1> const c1 = {{ 0xB148 }};
std::array<uint32_t, 1> const c2 = {{ 0xB148 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1167, 0x11AF }};
std::array<uint32_t, 1> const c4 = {{ 0xB148 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1167, 0x11AF }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_169)
{
// B149;B149;1102 1167 11B0;B149;1102 1167 11B0;
// (녉; 녉; 녉; 녉; 녉; ) HANGUL SYLLABLE NYEOLG
{
std::array<uint32_t, 1> const c1 = {{ 0xB149 }};
std::array<uint32_t, 1> const c2 = {{ 0xB149 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1167, 0x11B0 }};
std::array<uint32_t, 1> const c4 = {{ 0xB149 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1167, 0x11B0 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_170)
{
// B14A;B14A;1102 1167 11B1;B14A;1102 1167 11B1;
// (녊; 녊; 녊; 녊; 녊; ) HANGUL SYLLABLE NYEOLM
{
std::array<uint32_t, 1> const c1 = {{ 0xB14A }};
std::array<uint32_t, 1> const c2 = {{ 0xB14A }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1167, 0x11B1 }};
std::array<uint32_t, 1> const c4 = {{ 0xB14A }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1167, 0x11B1 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_171)
{
// B14B;B14B;1102 1167 11B2;B14B;1102 1167 11B2;
// (녋; 녋; 녋; 녋; 녋; ) HANGUL SYLLABLE NYEOLB
{
std::array<uint32_t, 1> const c1 = {{ 0xB14B }};
std::array<uint32_t, 1> const c2 = {{ 0xB14B }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1167, 0x11B2 }};
std::array<uint32_t, 1> const c4 = {{ 0xB14B }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1167, 0x11B2 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_172)
{
// B14C;B14C;1102 1167 11B3;B14C;1102 1167 11B3;
// (녌; 녌; 녌; 녌; 녌; ) HANGUL SYLLABLE NYEOLS
{
std::array<uint32_t, 1> const c1 = {{ 0xB14C }};
std::array<uint32_t, 1> const c2 = {{ 0xB14C }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1167, 0x11B3 }};
std::array<uint32_t, 1> const c4 = {{ 0xB14C }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1167, 0x11B3 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_173)
{
// B14D;B14D;1102 1167 11B4;B14D;1102 1167 11B4;
// (녍; 녍; 녍; 녍; 녍; ) HANGUL SYLLABLE NYEOLT
{
std::array<uint32_t, 1> const c1 = {{ 0xB14D }};
std::array<uint32_t, 1> const c2 = {{ 0xB14D }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1167, 0x11B4 }};
std::array<uint32_t, 1> const c4 = {{ 0xB14D }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1167, 0x11B4 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_174)
{
// B14E;B14E;1102 1167 11B5;B14E;1102 1167 11B5;
// (녎; 녎; 녎; 녎; 녎; ) HANGUL SYLLABLE NYEOLP
{
std::array<uint32_t, 1> const c1 = {{ 0xB14E }};
std::array<uint32_t, 1> const c2 = {{ 0xB14E }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1167, 0x11B5 }};
std::array<uint32_t, 1> const c4 = {{ 0xB14E }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1167, 0x11B5 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_175)
{
// B14F;B14F;1102 1167 11B6;B14F;1102 1167 11B6;
// (녏; 녏; 녏; 녏; 녏; ) HANGUL SYLLABLE NYEOLH
{
std::array<uint32_t, 1> const c1 = {{ 0xB14F }};
std::array<uint32_t, 1> const c2 = {{ 0xB14F }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1167, 0x11B6 }};
std::array<uint32_t, 1> const c4 = {{ 0xB14F }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1167, 0x11B6 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_176)
{
// B150;B150;1102 1167 11B7;B150;1102 1167 11B7;
// (념; 념; 념; 념; 념; ) HANGUL SYLLABLE NYEOM
{
std::array<uint32_t, 1> const c1 = {{ 0xB150 }};
std::array<uint32_t, 1> const c2 = {{ 0xB150 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1167, 0x11B7 }};
std::array<uint32_t, 1> const c4 = {{ 0xB150 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1167, 0x11B7 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_177)
{
// B151;B151;1102 1167 11B8;B151;1102 1167 11B8;
// (녑; 녑; 녑; 녑; 녑; ) HANGUL SYLLABLE NYEOB
{
std::array<uint32_t, 1> const c1 = {{ 0xB151 }};
std::array<uint32_t, 1> const c2 = {{ 0xB151 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1167, 0x11B8 }};
std::array<uint32_t, 1> const c4 = {{ 0xB151 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1167, 0x11B8 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_178)
{
// B152;B152;1102 1167 11B9;B152;1102 1167 11B9;
// (녒; 녒; 녒; 녒; 녒; ) HANGUL SYLLABLE NYEOBS
{
std::array<uint32_t, 1> const c1 = {{ 0xB152 }};
std::array<uint32_t, 1> const c2 = {{ 0xB152 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1167, 0x11B9 }};
std::array<uint32_t, 1> const c4 = {{ 0xB152 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1167, 0x11B9 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_179)
{
// B153;B153;1102 1167 11BA;B153;1102 1167 11BA;
// (녓; 녓; 녓; 녓; 녓; ) HANGUL SYLLABLE NYEOS
{
std::array<uint32_t, 1> const c1 = {{ 0xB153 }};
std::array<uint32_t, 1> const c2 = {{ 0xB153 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1167, 0x11BA }};
std::array<uint32_t, 1> const c4 = {{ 0xB153 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1167, 0x11BA }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_180)
{
// B154;B154;1102 1167 11BB;B154;1102 1167 11BB;
// (녔; 녔; 녔; 녔; 녔; ) HANGUL SYLLABLE NYEOSS
{
std::array<uint32_t, 1> const c1 = {{ 0xB154 }};
std::array<uint32_t, 1> const c2 = {{ 0xB154 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1167, 0x11BB }};
std::array<uint32_t, 1> const c4 = {{ 0xB154 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1167, 0x11BB }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_181)
{
// B155;B155;1102 1167 11BC;B155;1102 1167 11BC;
// (녕; 녕; 녕; 녕; 녕; ) HANGUL SYLLABLE NYEONG
{
std::array<uint32_t, 1> const c1 = {{ 0xB155 }};
std::array<uint32_t, 1> const c2 = {{ 0xB155 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1167, 0x11BC }};
std::array<uint32_t, 1> const c4 = {{ 0xB155 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1167, 0x11BC }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_182)
{
// B156;B156;1102 1167 11BD;B156;1102 1167 11BD;
// (녖; 녖; 녖; 녖; 녖; ) HANGUL SYLLABLE NYEOJ
{
std::array<uint32_t, 1> const c1 = {{ 0xB156 }};
std::array<uint32_t, 1> const c2 = {{ 0xB156 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1167, 0x11BD }};
std::array<uint32_t, 1> const c4 = {{ 0xB156 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1167, 0x11BD }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_183)
{
// B157;B157;1102 1167 11BE;B157;1102 1167 11BE;
// (녗; 녗; 녗; 녗; 녗; ) HANGUL SYLLABLE NYEOC
{
std::array<uint32_t, 1> const c1 = {{ 0xB157 }};
std::array<uint32_t, 1> const c2 = {{ 0xB157 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1167, 0x11BE }};
std::array<uint32_t, 1> const c4 = {{ 0xB157 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1167, 0x11BE }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_184)
{
// B158;B158;1102 1167 11BF;B158;1102 1167 11BF;
// (녘; 녘; 녘; 녘; 녘; ) HANGUL SYLLABLE NYEOK
{
std::array<uint32_t, 1> const c1 = {{ 0xB158 }};
std::array<uint32_t, 1> const c2 = {{ 0xB158 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1167, 0x11BF }};
std::array<uint32_t, 1> const c4 = {{ 0xB158 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1167, 0x11BF }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_185)
{
// B159;B159;1102 1167 11C0;B159;1102 1167 11C0;
// (녙; 녙; 녙; 녙; 녙; ) HANGUL SYLLABLE NYEOT
{
std::array<uint32_t, 1> const c1 = {{ 0xB159 }};
std::array<uint32_t, 1> const c2 = {{ 0xB159 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1167, 0x11C0 }};
std::array<uint32_t, 1> const c4 = {{ 0xB159 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1167, 0x11C0 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_186)
{
// B15A;B15A;1102 1167 11C1;B15A;1102 1167 11C1;
// (녚; 녚; 녚; 녚; 녚; ) HANGUL SYLLABLE NYEOP
{
std::array<uint32_t, 1> const c1 = {{ 0xB15A }};
std::array<uint32_t, 1> const c2 = {{ 0xB15A }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1167, 0x11C1 }};
std::array<uint32_t, 1> const c4 = {{ 0xB15A }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1167, 0x11C1 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_187)
{
// B15B;B15B;1102 1167 11C2;B15B;1102 1167 11C2;
// (녛; 녛; 녛; 녛; 녛; ) HANGUL SYLLABLE NYEOH
{
std::array<uint32_t, 1> const c1 = {{ 0xB15B }};
std::array<uint32_t, 1> const c2 = {{ 0xB15B }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1167, 0x11C2 }};
std::array<uint32_t, 1> const c4 = {{ 0xB15B }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1167, 0x11C2 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_188)
{
// B15C;B15C;1102 1168;B15C;1102 1168;
// (녜; 녜; 녜; 녜; 녜; ) HANGUL SYLLABLE NYE
{
std::array<uint32_t, 1> const c1 = {{ 0xB15C }};
std::array<uint32_t, 1> const c2 = {{ 0xB15C }};
std::array<uint32_t, 2> const c3 = {{ 0x1102, 0x1168 }};
std::array<uint32_t, 1> const c4 = {{ 0xB15C }};
std::array<uint32_t, 2> const c5 = {{ 0x1102, 0x1168 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_189)
{
// B15D;B15D;1102 1168 11A8;B15D;1102 1168 11A8;
// (녝; 녝; 녝; 녝; 녝; ) HANGUL SYLLABLE NYEG
{
std::array<uint32_t, 1> const c1 = {{ 0xB15D }};
std::array<uint32_t, 1> const c2 = {{ 0xB15D }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1168, 0x11A8 }};
std::array<uint32_t, 1> const c4 = {{ 0xB15D }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1168, 0x11A8 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_190)
{
// B15E;B15E;1102 1168 11A9;B15E;1102 1168 11A9;
// (녞; 녞; 녞; 녞; 녞; ) HANGUL SYLLABLE NYEGG
{
std::array<uint32_t, 1> const c1 = {{ 0xB15E }};
std::array<uint32_t, 1> const c2 = {{ 0xB15E }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1168, 0x11A9 }};
std::array<uint32_t, 1> const c4 = {{ 0xB15E }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1168, 0x11A9 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_191)
{
// B15F;B15F;1102 1168 11AA;B15F;1102 1168 11AA;
// (녟; 녟; 녟; 녟; 녟; ) HANGUL SYLLABLE NYEGS
{
std::array<uint32_t, 1> const c1 = {{ 0xB15F }};
std::array<uint32_t, 1> const c2 = {{ 0xB15F }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1168, 0x11AA }};
std::array<uint32_t, 1> const c4 = {{ 0xB15F }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1168, 0x11AA }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_192)
{
// B160;B160;1102 1168 11AB;B160;1102 1168 11AB;
// (녠; 녠; 녠; 녠; 녠; ) HANGUL SYLLABLE NYEN
{
std::array<uint32_t, 1> const c1 = {{ 0xB160 }};
std::array<uint32_t, 1> const c2 = {{ 0xB160 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1168, 0x11AB }};
std::array<uint32_t, 1> const c4 = {{ 0xB160 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1168, 0x11AB }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_193)
{
// B161;B161;1102 1168 11AC;B161;1102 1168 11AC;
// (녡; 녡; 녡; 녡; 녡; ) HANGUL SYLLABLE NYENJ
{
std::array<uint32_t, 1> const c1 = {{ 0xB161 }};
std::array<uint32_t, 1> const c2 = {{ 0xB161 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1168, 0x11AC }};
std::array<uint32_t, 1> const c4 = {{ 0xB161 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1168, 0x11AC }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_194)
{
// B162;B162;1102 1168 11AD;B162;1102 1168 11AD;
// (녢; 녢; 녢; 녢; 녢; ) HANGUL SYLLABLE NYENH
{
std::array<uint32_t, 1> const c1 = {{ 0xB162 }};
std::array<uint32_t, 1> const c2 = {{ 0xB162 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1168, 0x11AD }};
std::array<uint32_t, 1> const c4 = {{ 0xB162 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1168, 0x11AD }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_195)
{
// B163;B163;1102 1168 11AE;B163;1102 1168 11AE;
// (녣; 녣; 녣; 녣; 녣; ) HANGUL SYLLABLE NYED
{
std::array<uint32_t, 1> const c1 = {{ 0xB163 }};
std::array<uint32_t, 1> const c2 = {{ 0xB163 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1168, 0x11AE }};
std::array<uint32_t, 1> const c4 = {{ 0xB163 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1168, 0x11AE }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_196)
{
// B164;B164;1102 1168 11AF;B164;1102 1168 11AF;
// (녤; 녤; 녤; 녤; 녤; ) HANGUL SYLLABLE NYEL
{
std::array<uint32_t, 1> const c1 = {{ 0xB164 }};
std::array<uint32_t, 1> const c2 = {{ 0xB164 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1168, 0x11AF }};
std::array<uint32_t, 1> const c4 = {{ 0xB164 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1168, 0x11AF }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_197)
{
// B165;B165;1102 1168 11B0;B165;1102 1168 11B0;
// (녥; 녥; 녥; 녥; 녥; ) HANGUL SYLLABLE NYELG
{
std::array<uint32_t, 1> const c1 = {{ 0xB165 }};
std::array<uint32_t, 1> const c2 = {{ 0xB165 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1168, 0x11B0 }};
std::array<uint32_t, 1> const c4 = {{ 0xB165 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1168, 0x11B0 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_198)
{
// B166;B166;1102 1168 11B1;B166;1102 1168 11B1;
// (녦; 녦; 녦; 녦; 녦; ) HANGUL SYLLABLE NYELM
{
std::array<uint32_t, 1> const c1 = {{ 0xB166 }};
std::array<uint32_t, 1> const c2 = {{ 0xB166 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1168, 0x11B1 }};
std::array<uint32_t, 1> const c4 = {{ 0xB166 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1168, 0x11B1 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_199)
{
// B167;B167;1102 1168 11B2;B167;1102 1168 11B2;
// (녧; 녧; 녧; 녧; 녧; ) HANGUL SYLLABLE NYELB
{
std::array<uint32_t, 1> const c1 = {{ 0xB167 }};
std::array<uint32_t, 1> const c2 = {{ 0xB167 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1168, 0x11B2 }};
std::array<uint32_t, 1> const c4 = {{ 0xB167 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1168, 0x11B2 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
| 36.85216 | 88 | 0.500888 | jan-moeller |
240801f7d228a5b63f027555fe651fb67be580cf | 7,466 | cpp | C++ | ql/experimental/math/convolvedstudentt.cpp | mshojatalab/QuantLib | 7801a0fb3226bc1b001e310bacdd35ddb2e51661 | [
"BSD-3-Clause"
] | null | null | null | ql/experimental/math/convolvedstudentt.cpp | mshojatalab/QuantLib | 7801a0fb3226bc1b001e310bacdd35ddb2e51661 | [
"BSD-3-Clause"
] | 1 | 2022-02-24T02:22:30.000Z | 2022-02-24T02:22:30.000Z | ql/experimental/math/convolvedstudentt.cpp | sweemer/QuantLib | 1341223e3d839dd77bb7231d0913809f01437740 | [
"BSD-3-Clause"
] | null | null | null | /* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
Copyright (C) 2014 Jose Aparicio
This file is part of QuantLib, a free-software/open-source library
for financial quantitative analysts and developers - http://quantlib.org/
QuantLib is free software: you can redistribute it and/or modify it
under the terms of the QuantLib license. You should have received a
copy of the license along with this program; if not, please email
<quantlib-dev@lists.sf.net>. The license is also available online at
<http://quantlib.org/license.shtml>.
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 license for more details.
*/
#include <ql/experimental/math/convolvedstudentt.hpp>
#include <ql/errors.hpp>
#include <ql/math/factorial.hpp>
#include <ql/math/distributions/normaldistribution.hpp>
#include <ql/math/solvers1d/brent.hpp>
#include <ql/math/functional.hpp>
#if defined(__GNUC__) && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 8)) || (__GNUC__ > 4))
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-local-typedefs"
#endif
#include <boost/math/distributions/students_t.hpp>
#if defined(__GNUC__) && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 8)) || (__GNUC__ > 4))
#pragma GCC diagnostic pop
#endif
namespace QuantLib {
CumulativeBehrensFisher::CumulativeBehrensFisher(const std::vector<Integer>& degreesFreedom,
const std::vector<Real>& factors)
: degreesFreedom_(degreesFreedom), factors_(factors), polyConvolved_(std::vector<Real>(1, 1.))
{
QL_REQUIRE(degreesFreedom.size() == factors.size(),
"Incompatible sizes in convolution.");
for (int i : degreesFreedom) {
QL_REQUIRE(i % 2 != 0, "Even degree of freedom not allowed");
QL_REQUIRE(i >= 0, "Negative degree of freedom not allowed");
}
for(Size i=0; i<degreesFreedom_.size(); i++)
polynCharFnc_.push_back(polynCharactT((degreesFreedom[i]-1)/2));
// adjust the polynomial coefficients by the factors in the linear
// combination:
for(Size i=0; i<degreesFreedom_.size(); i++) {
Real multiplier = 1.;
for(Size k=1; k<polynCharFnc_[i].size(); k++) {
multiplier *= std::abs(factors_[i]);
polynCharFnc_[i][k] *= multiplier;
}
}
//convolution, here it is a product of polynomials and exponentials
for (auto& i : polynCharFnc_)
polyConvolved_ = convolveVectorPolynomials(polyConvolved_, i);
// trim possible zeros that might have arised:
auto it = polyConvolved_.rbegin();
while (it != polyConvolved_.rend()) {
if (*it == 0.) {
polyConvolved_.pop_back();
it = polyConvolved_.rbegin();
}else{
break;
}
}
// cache 'a' value (the exponent)
for(Size i=0; i<degreesFreedom_.size(); i++)
a_ += std::sqrt(static_cast<Real>(degreesFreedom_[i]))
* std::abs(factors_[i]);
a2_ = a_ * a_;
}
std::vector<Real> CumulativeBehrensFisher::polynCharactT(Natural n) const {
Natural nu = 2 * n +1;
std::vector<Real> low(1,1.), high(1,1.);
high.push_back(std::sqrt(static_cast<Real>(nu)));
if(n==0) return low;
if(n==1) return high;
for(Size k=1; k<n; k++) {
std::vector<Real> recursionFactor(1,0.); // 0 coef
recursionFactor.push_back(0.); // 1 coef
recursionFactor.push_back(nu/((2.*k+1.)*(2.*k-1.))); // 2 coef
std::vector<Real> lowUp =
convolveVectorPolynomials(recursionFactor, low);
//add them up:
for(Size i=0; i<high.size(); i++)
lowUp[i] += high[i];
low = high;
high = lowUp;
}
return high;
}
std::vector<Real> CumulativeBehrensFisher::convolveVectorPolynomials(
const std::vector<Real>& v1,
const std::vector<Real>& v2) const {
#if defined(QL_EXTRA_SAFETY_CHECKS)
QL_REQUIRE(!v1.empty() && !v2.empty(),
"Incorrect vectors in polynomial.");
#endif
const std::vector<Real>& shorter = v1.size() < v2.size() ? v1 : v2;
const std::vector<Real>& longer = (v1 == shorter) ? v2 : v1;
Size newDegree = v1.size()+v2.size()-2;
std::vector<Real> resultB(newDegree+1, 0.);
for(Size polyOrdr=0; polyOrdr<resultB.size(); polyOrdr++) {
for(Size i=std::max<Integer>(0, polyOrdr-longer.size()+1);
i<=std::min(polyOrdr, shorter.size()-1); i++)
resultB[polyOrdr] += shorter[i]*longer[polyOrdr-i];
}
return resultB;
}
Probability CumulativeBehrensFisher::operator()(const Real x) const {
// 1st & 0th terms with the table integration
Real integral = polyConvolved_[0] * std::atan(x/a_);
Real squared = a2_ + x*x;
Real rootsqr = std::sqrt(squared);
Real atan2xa = std::atan2(-x,a_);
if(polyConvolved_.size()>1)
integral += polyConvolved_[1] * x/squared;
for(Size exponent = 2; exponent <polyConvolved_.size(); exponent++) {
integral -= polyConvolved_[exponent] *
Factorial::get(exponent-1) * std::sin((exponent)*atan2xa)
/std::pow(rootsqr, static_cast<Real>(exponent));
}
return .5 + integral / M_PI;
}
Probability
CumulativeBehrensFisher::density(const Real x) const {
Real squared = a2_ + x*x;
Real integral = polyConvolved_[0] * a_ / squared;
Real rootsqr = std::sqrt(squared);
Real atan2xa = std::atan2(-x,a_);
for(Size exponent=1; exponent <polyConvolved_.size(); exponent++) {
integral += polyConvolved_[exponent] *
Factorial::get(exponent) * std::cos((exponent+1)*atan2xa)
/std::pow(rootsqr, static_cast<Real>(exponent+1) );
}
return integral / M_PI;
}
InverseCumulativeBehrensFisher::InverseCumulativeBehrensFisher(
const std::vector<Integer>& degreesFreedom,
const std::vector<Real>& factors,
Real accuracy)
: normSqr_(std::inner_product(factors.begin(), factors.end(),
factors.begin(), 0.)),
accuracy_(accuracy), distrib_(degreesFreedom, factors) { }
Real InverseCumulativeBehrensFisher::operator()(const Probability q) const {
Probability effectiveq;
Real sign;
// since the distrib is symmetric solve only on the right side:
if(q==0.5) {
return 0.;
}else if(q < 0.5) {
sign = -1.;
effectiveq = 1.-q;
}else{
sign = 1.;
effectiveq = q;
}
Real xMin =
InverseCumulativeNormal::standard_value(effectiveq) * normSqr_;
// inversion will fail at the Brent's bounds-check if this is not enough
// (q is very close to 1.), in a bad combination fails around 1.-1.e-7
Real xMax = 1.e6;
return sign *
Brent().solve([&](Real x){ return distrib_(x) - effectiveq; },
accuracy_, (xMin+xMax)/2., xMin, xMax);
}
}
| 39.712766 | 98 | 0.590008 | mshojatalab |
240855b8125bfd1a65e1502559e838cc81b2c289 | 3,948 | cpp | C++ | thirdparty/GeometricTools/WildMagic5/LibMathematics/Distance/Wm5DistLine2Line2.cpp | SoMa-Project/vision | ea8199d98edc363b2be79baa7c691da3a5a6cc86 | [
"BSD-2-Clause-FreeBSD"
] | 1 | 2020-07-24T23:40:01.000Z | 2020-07-24T23:40:01.000Z | thirdparty/GeometricTools/WildMagic5/LibMathematics/Distance/Wm5DistLine2Line2.cpp | SoMa-Project/vision | ea8199d98edc363b2be79baa7c691da3a5a6cc86 | [
"BSD-2-Clause-FreeBSD"
] | 4 | 2020-05-19T18:14:33.000Z | 2021-03-19T15:53:43.000Z | thirdparty/GeometricTools/WildMagic5/LibMathematics/Distance/Wm5DistLine2Line2.cpp | SoMa-Project/vision | ea8199d98edc363b2be79baa7c691da3a5a6cc86 | [
"BSD-2-Clause-FreeBSD"
] | null | null | null | // Geometric Tools, LLC
// Copyright (c) 1998-2014
// Distributed under the Boost Software License, Version 1.0.
// http://www.boost.org/LICENSE_1_0.txt
// http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt
//
// File Version: 5.0.1 (2010/10/01)
#include "Wm5MathematicsPCH.h"
#include "Wm5DistLine2Line2.h"
namespace Wm5
{
//----------------------------------------------------------------------------
template <typename Real>
DistLine2Line2<Real>::DistLine2Line2 (const Line2<Real>& rkLine0,
const Line2<Real>& rkLine1)
:
mLine0(&rkLine0),
mLine1(&rkLine1)
{
}
//----------------------------------------------------------------------------
template <typename Real>
const Line2<Real>& DistLine2Line2<Real>::GetLine0 () const
{
return *mLine0;
}
//----------------------------------------------------------------------------
template <typename Real>
const Line2<Real>& DistLine2Line2<Real>::GetLine1 () const
{
return *mLine1;
}
//----------------------------------------------------------------------------
template <typename Real>
Real DistLine2Line2<Real>::Get ()
{
Real sqrDist = GetSquared();
return Math<Real>::Sqrt(sqrDist);
}
//----------------------------------------------------------------------------
template <typename Real>
Real DistLine2Line2<Real>::GetSquared ()
{
Vector2<Real> diff = mLine0->Origin - mLine1->Origin;
Real a01 = -mLine0->Direction.Dot(mLine1->Direction);
Real b0 = diff.Dot(mLine0->Direction);
Real c = diff.SquaredLength();
Real det = Math<Real>::FAbs((Real)1 - a01*a01);
Real b1, s0, s1, sqrDist;
if (det >= Math<Real>::ZERO_TOLERANCE)
{
// Lines are not parallel.
b1 = -diff.Dot(mLine1->Direction);
Real invDet = ((Real)1)/det;
s0 = (a01*b1 - b0)*invDet;
s1 = (a01*b0 - b1)*invDet;
sqrDist = (Real)0;
}
else
{
// Lines are parallel, select any closest pair of points.
s0 = -b0;
s1 = (Real)0;
sqrDist = b0*s0 + c;
// Account for numerical round-off errors.
if (sqrDist < (Real)0)
{
sqrDist = (Real)0;
}
}
mClosestPoint0 = mLine0->Origin + s0*mLine0->Direction;
mClosestPoint1 = mLine1->Origin + s1*mLine1->Direction;
return sqrDist;
}
//----------------------------------------------------------------------------
template <typename Real>
Real DistLine2Line2<Real>::Get (Real t, const Vector2<Real>& velocity0,
const Vector2<Real>& velocity1)
{
Vector2<Real> movedOrigin0 = mLine0->Origin + t*velocity0;
Vector2<Real> movedOrigin1 = mLine1->Origin + t*velocity1;
Line2<Real> movedLine0(movedOrigin0, mLine0->Direction);
Line2<Real> movedLine1(movedOrigin1, mLine1->Direction);
return DistLine2Line2<Real>(movedLine0, movedLine1).Get();
}
//----------------------------------------------------------------------------
template <typename Real>
Real DistLine2Line2<Real>::GetSquared (Real t,
const Vector2<Real>& velocity0, const Vector2<Real>& velocity1)
{
Vector2<Real> movedOrigin0 = mLine0->Origin + t*velocity0;
Vector2<Real> movedOrigin1 = mLine1->Origin + t*velocity1;
Line2<Real> movedLine0(movedOrigin0, mLine0->Direction);
Line2<Real> movedLine1(movedOrigin1, mLine1->Direction);
return DistLine2Line2<Real>(movedLine0, movedLine1).GetSquared();
}
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
// Explicit instantiation.
//----------------------------------------------------------------------------
template WM5_MATHEMATICS_ITEM
class DistLine2Line2<float>;
template WM5_MATHEMATICS_ITEM
class DistLine2Line2<double>;
//----------------------------------------------------------------------------
}
| 34.631579 | 79 | 0.505572 | SoMa-Project |
24098da66848085bd93b0932879a148d792798be | 1,169 | cpp | C++ | samples/snippets/cpp/VS_Snippets_CLR/Thread.GetSetTrySetApartmentState/cpp/source.cpp | hamarb123/dotnet-api-docs | 6aeb55784944a2f1f5e773b657791cbd73a92dd4 | [
"CC-BY-4.0",
"MIT"
] | 421 | 2018-04-01T01:57:50.000Z | 2022-03-28T15:24:42.000Z | samples/snippets/cpp/VS_Snippets_CLR/Thread.GetSetTrySetApartmentState/cpp/source.cpp | hamarb123/dotnet-api-docs | 6aeb55784944a2f1f5e773b657791cbd73a92dd4 | [
"CC-BY-4.0",
"MIT"
] | 5,797 | 2018-04-02T21:12:23.000Z | 2022-03-31T23:54:38.000Z | samples/snippets/cpp/VS_Snippets_CLR/Thread.GetSetTrySetApartmentState/cpp/source.cpp | hamarb123/dotnet-api-docs | 6aeb55784944a2f1f5e773b657791cbd73a92dd4 | [
"CC-BY-4.0",
"MIT"
] | 1,482 | 2018-03-31T11:26:20.000Z | 2022-03-30T22:36:45.000Z | //<Snippet1>
using namespace System;
using namespace System::Threading;
void ThreadProc()
{
Thread::Sleep(2000);
};
void main()
{
Thread^ t = gcnew Thread(gcnew ThreadStart(ThreadProc));
Console::WriteLine("Before setting apartment state: {0}",
t->GetApartmentState());
t->SetApartmentState(ApartmentState::STA);
Console::WriteLine("After setting apartment state: {0}",
t->GetApartmentState());
bool result = t->TrySetApartmentState(ApartmentState::MTA);
Console::WriteLine("Try to change state: {0}", result);
t->Start();
Thread::Sleep(500);
try
{
t->TrySetApartmentState(ApartmentState::STA);
}
catch (ThreadStateException^)
{
Console::WriteLine("ThreadStateException occurs " +
"if apartment state is set after starting thread.");
}
t->Join();
}
/* This code example produces the following output:
Before setting apartment state: Unknown
After setting apartment state: STA
Try to change state: False
ThreadStateException occurs if apartment state is set after starting thread.
*/
//</Snippet1>
| 24.354167 | 77 | 0.645851 | hamarb123 |
240d0bd98074ecfc35e23fee72c00e6de7406f84 | 19,435 | hpp | C++ | domain/include/cstone/tree/octree_internal.hpp | lks1248/SPH-EXA | af6d2307f022a1892606008e290ab9cba6f683f7 | [
"MIT"
] | 16 | 2022-01-17T19:50:38.000Z | 2022-03-28T08:09:58.000Z | domain/include/cstone/tree/octree_internal.hpp | sguera/SPH-EXA_mini-app | 0cac399d43118bda1ed2a5e42b593eb18ca55c30 | [
"MIT"
] | 33 | 2021-12-06T12:42:41.000Z | 2022-03-31T10:56:49.000Z | domain/include/cstone/tree/octree_internal.hpp | sguera/SPH-EXA_mini-app | 0cac399d43118bda1ed2a5e42b593eb18ca55c30 | [
"MIT"
] | 13 | 2021-12-06T09:12:52.000Z | 2022-03-28T08:07:38.000Z | /*
* MIT License
*
* Copyright (c) 2021 CSCS, ETH Zurich
* 2021 University of Basel
*
* 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
* @brief Compute the internal part of a cornerstone octree
*
* @author Sebastian Keller <sebastian.f.keller@gmail.com>
*
* General algorithm:
* cornerstone octree (leaves) -> internal binary radix tree -> internal octree
*
* Like the cornerstone octree, the internal octree is stored in a linear memory layout
* with tree nodes placed next to each other in a single buffer. Construction
* is fully parallel and non-recursive and non-iterative. Traversal is possible non-recursively
* in an iterative fashion with a local stack.
*/
#pragma once
#include <iterator>
#include <vector>
#include "cstone/cuda/annotation.hpp"
#include "cstone/primitives/gather.hpp"
#include "cstone/sfc/sfc.hpp"
#include "cstone/tree/octree.hpp"
#include "cstone/util/gsl-lite.hpp"
namespace cstone
{
/*! @brief map a binary node index to an octree node index
*
* @tparam KeyType 32- or 64-bit unsigned integer
* @param key a cornerstone leaf cell key
* @param level the subdivision level of @p key
* @return the index offset
*
* if
* - cstree is a cornerstone leaf array
* - l = commonPrefix(cstree[j], cstree[j+1]), l % 3 == 0
* - k = cstree[j]
*
* then i = (j + binaryKeyWeight(k, l) / 7 equals the index of the internal octree node with key k,
* see unit test of this function for an illustration
*/
template<class KeyType>
HOST_DEVICE_FUN constexpr TreeNodeIndex binaryKeyWeight(KeyType key, unsigned level)
{
TreeNodeIndex ret = 0;
for (unsigned l = 1; l <= level + 1; ++l)
{
unsigned digit = octalDigit(key, l);
ret += digitWeight(digit);
}
return ret;
}
/*! @brief combine internal and leaf tree parts into a single array with the nodeKey prefixes
*
* @tparam KeyType unsigned 32- or 64-bit integer
* @param[in] leaves cornerstone SFC keys, length numLeafNodes + 1
* @param[in] numInternalNodes number of internal octree nodes
* @param[in] numLeafNodes total number of nodes
* @param[in] binaryToOct translation map from binary to octree nodes
* @param[out] prefixes output octree SFC keys, length @p numInternalNodes + numLeafNodes
* NOTE: keys are prefixed with Warren-Salmon placeholder bits!
* @param[out] internalToLeaf iota 0,1,2,3,... sequence for later use, length same as @p prefixes
*/
template<class KeyType>
void createUnsortedLayoutCpu(const KeyType* leaves,
TreeNodeIndex numInternalNodes,
TreeNodeIndex numLeafNodes,
KeyType* prefixes,
TreeNodeIndex* internalToLeaf)
{
#pragma omp parallel for schedule(static)
for (TreeNodeIndex tid = 0; tid < numLeafNodes; ++tid)
{
KeyType key = leaves[tid];
unsigned level = treeLevel(leaves[tid + 1] - key);
prefixes[tid + numInternalNodes] = encodePlaceholderBit(key, 3 * level);
internalToLeaf[tid + numInternalNodes] = tid + numInternalNodes;
unsigned prefixLength = commonPrefix(key, leaves[tid + 1]);
if (prefixLength % 3 == 0 && tid < numLeafNodes - 1)
{
TreeNodeIndex octIndex = (tid + binaryKeyWeight(key, prefixLength / 3)) / 7;
prefixes[octIndex] = encodePlaceholderBit(key, prefixLength);
internalToLeaf[octIndex] = octIndex;
}
}
}
/*! @brief extract parent/child relationships from binary tree and translate to sorted order
*
* @tparam KeyType unsigned 32- or 64-bit integer
* @param[in] prefixes octree node prefixes in Warren-Salmon format
* @param[in] numInternalNodes number of internal octree nodes
* @param[in] leafToInternal translation map from unsorted layout to level/SFC sorted octree layout
* length is total number of octree nodes, internal + leaves
* @param[in] levelRange indices of the first node at each level
* @param[out] childOffsets octree node index of first child for each node, length is total number of nodes
* @param[out] parents parent index of for each node which is the first of 8 siblings
* i.e. the parent of node i is stored at parents[(i - 1)/8]
*/
template<class KeyType>
void linkTreeCpu(const KeyType* prefixes,
TreeNodeIndex numInternalNodes,
const TreeNodeIndex* leafToInternal,
const TreeNodeIndex* levelRange,
TreeNodeIndex* childOffsets,
TreeNodeIndex* parents)
{
#pragma omp parallel for schedule(static)
for (TreeNodeIndex i = 0; i < numInternalNodes; ++i)
{
TreeNodeIndex idxA = leafToInternal[i];
KeyType prefix = prefixes[idxA];
KeyType nodeKey = decodePlaceholderBit(prefix);
unsigned prefixLength = decodePrefixLength(prefix);
unsigned level = prefixLength / 3;
assert(level < maxTreeLevel<KeyType>{});
KeyType childPrefix = encodePlaceholderBit(nodeKey, prefixLength + 3);
TreeNodeIndex leafSearchStart = levelRange[level + 1];
TreeNodeIndex leafSearchEnd = levelRange[level + 2];
TreeNodeIndex childIdx =
stl::lower_bound(prefixes + leafSearchStart, prefixes + leafSearchEnd, childPrefix) - prefixes;
if (childIdx != leafSearchEnd && childPrefix == prefixes[childIdx])
{
childOffsets[idxA] = childIdx;
// We only store the parent once for every group of 8 siblings.
// This works as long as each node always has 8 siblings.
// Subtract one because the root has no siblings.
parents[(childIdx - 1) / 8] = idxA;
}
}
}
//! @brief determine the octree subdivision level boundaries
template<class KeyType>
void getLevelRangeCpu(const KeyType* nodeKeys, TreeNodeIndex numNodes, TreeNodeIndex* levelRange)
{
for (unsigned level = 0; level <= maxTreeLevel<KeyType>{}; ++level)
{
auto it = std::lower_bound(nodeKeys, nodeKeys + numNodes, encodePlaceholderBit(KeyType(0), 3 * level));
levelRange[level] = TreeNodeIndex(it - nodeKeys);
}
levelRange[maxTreeLevel<KeyType>{} + 1] = numNodes;
}
/*! @brief construct the internal octree part of a given octree leaf cell array on the GPU
*
* @tparam KeyType unsigned 32- or 64-bit integer
* @param[in] cstoneTree GPU buffer with the SFC leaf cell keys
*/
template<class KeyType>
void buildInternalOctreeCpu(const KeyType* cstoneTree,
TreeNodeIndex numLeafNodes,
TreeNodeIndex numInternalNodes,
KeyType* prefixes,
TreeNodeIndex* childOffsets,
TreeNodeIndex* parents,
TreeNodeIndex* levelRange,
TreeNodeIndex* internalToLeaf,
TreeNodeIndex* leafToInternal)
{
TreeNodeIndex numNodes = numInternalNodes + numLeafNodes;
createUnsortedLayoutCpu(cstoneTree, numInternalNodes, numLeafNodes, prefixes, internalToLeaf);
sort_by_key(prefixes, prefixes + numNodes, internalToLeaf);
#pragma omp parallel for schedule(static)
for (TreeNodeIndex i = 0; i < numNodes; ++i)
{
leafToInternal[internalToLeaf[i]] = i;
}
#pragma omp parallel for schedule(static)
for (TreeNodeIndex i = 0; i < numNodes; ++i)
{
internalToLeaf[i] -= numInternalNodes;
}
getLevelRangeCpu(prefixes, numNodes, levelRange);
std::fill(childOffsets, childOffsets + numNodes, 0);
linkTreeCpu(prefixes, numInternalNodes, leafToInternal, levelRange, childOffsets, parents);
}
template<class K>
class FocusedOctreeCore;
template<class KeyType>
class Octree
{
public:
Octree() = default;
//! @brief update tree, copying from externally provided leaf keys
void update(const KeyType* leaves, TreeNodeIndex numLeafNodes)
{
cstoneTree_.resize(numLeafNodes + 1);
omp_copy(leaves, leaves + numLeafNodes + 1, cstoneTree_.data());
updateInternalTree();
}
//! @brief regenerates the internal tree, assuming cstoneTree_ has been changed from the outside
void updateInternalTree()
{
resize(nNodes(cstoneTree_));
buildInternalOctreeCpu(cstoneTree_.data(), numLeafNodes_, numInternalNodes_, prefixes_.data(),
childOffsets_.data(), parents_.data(), levelRange_.data(), internalToLeaf_.data(),
leafToInternal_.data());
}
//! @brief rebalance based on leaf counts only, optimized version that avoids unnecessary allocations
bool rebalance(unsigned bucketSize, gsl::span<const unsigned> counts)
{
assert(childOffsets_.size() >= cstoneTree_.size());
bool converged =
rebalanceDecision(cstoneTree_.data(), counts.data(), numLeafNodes_, bucketSize, childOffsets_.data());
rebalanceTree(cstoneTree_, prefixes_, childOffsets_.data());
swap(cstoneTree_, prefixes_);
updateInternalTree();
return converged;
}
//! @brief return a const view of the cstone leaf array
gsl::span<const KeyType> treeLeaves() const { return cstoneTree_; }
//! @brief return const pointer to node(cell) SFC keys
gsl::span<const KeyType> nodeKeys() const { return prefixes_; }
//! @brief return const pointer to child offsets array
gsl::span<const TreeNodeIndex> childOffsets() const { return childOffsets_; }
//! @brief return const pointer to the cell parents array
gsl::span<const TreeNodeIndex> parents() const { return parents_; }
//! @brief stores the first internal node index of each tree subdivision level
gsl::span<const TreeNodeIndex> levelRange() const { return levelRange_; }
//! @brief converts a cornerstone index into an internal index
gsl::span<const TreeNodeIndex> internalOrder() const
{
return {leafToInternal_.data() + numInternalNodes_, size_t(numLeafNodes_)};
}
//! @brief converts an internal index into a cornerstone index
gsl::span<const TreeNodeIndex> toLeafOrder() const { return {internalToLeaf_.data(), size_t(numTreeNodes())}; }
//! @brief total number of nodes in the tree
inline TreeNodeIndex numTreeNodes() const { return levelRange_.back(); }
//! @brief return number of nodes per tree level
inline TreeNodeIndex numTreeNodes(unsigned level) const { return levelRange_[level + 1] - levelRange_[level]; }
//! @brief number of leaf nodes in the tree
inline TreeNodeIndex numLeafNodes() const { return numLeafNodes_; }
//! @brief number of internal nodes in the tree, equal to (numLeafNodes()-1) / 7
inline TreeNodeIndex numInternalNodes() const { return numInternalNodes_; }
/*! @brief check whether node is a leaf
*
* @param[in] node node index, range [0:numTreeNodes()]
* @return true or false
*/
inline bool isLeaf(TreeNodeIndex node) const { return childOffsets_[node] == 0; }
//! @brief check if node is the root node
inline bool isRoot(TreeNodeIndex node) const { return node == levelRange_[0]; }
/*! @brief return child node index
*
* @param[in] node node index, range [0:numInternalNodes()]
* @param[in] octant octant index, range [0:8]
* @return child node index, range [0:nNodes()]
*
* If @p node is not internal, behavior is undefined.
* Query with isLeaf(node) before calling this function.
*/
inline TreeNodeIndex child(TreeNodeIndex node, int octant) const
{
assert(node < TreeNodeIndex(childOffsets_.size()));
return childOffsets_[node] + octant;
}
//! @brief Index of parent node. Note: the root node is its own parent
inline TreeNodeIndex parent(TreeNodeIndex node) const { return node ? parents_[(node - 1) / 8] : 0; }
//! @brief lowest SFC key contained int the geometrical box of @p node
inline KeyType codeStart(TreeNodeIndex node) const { return decodePlaceholderBit(prefixes_[node]); }
//! @brief highest SFC key contained in the geometrical box of @p node
inline KeyType codeEnd(TreeNodeIndex node) const
{
KeyType prefix = prefixes_[node];
assert(decodePrefixLength(prefix) % 3 == 0);
return decodePlaceholderBit(prefix) + (1ul << (3 * maxTreeLevel<KeyType>{} - decodePrefixLength(prefix)));
}
/*! @brief octree subdivision level for @p node
*
* Returns 0 for the root node. Highest value is maxTreeLevel<KeyType>{}.
*/
inline unsigned level(TreeNodeIndex node) const { return decodePrefixLength(prefixes_[node]) / 3; }
//! @brief return the index of the first node at subdivision level @p level
inline TreeNodeIndex levelOffset(unsigned level) const { return levelRange_[level]; }
/*! @brief convert a leaf index (indexed from first leaf starting from 0) to 0-indexed from root
*
* @param[in] node leaf node index, range [0:numLeafNodes()]
* @return octree index, relative to the root node
*/
[[nodiscard]] inline TreeNodeIndex toInternal(TreeNodeIndex node) const
{
assert(size_t(node + numInternalNodes()) < leafToInternal_.size());
return leafToInternal_[node + numInternalNodes()];
}
/*! @brief returns index of @p node in the cornerstone tree used for construction
*
* @param node node in [0:numTreeNodes()]
* @return the index in the cornerstone tree used for construction if @p node is a leaf
* such that this->codeStart(node) == cstoneTree[this->cstoneIndex(node)]
* If node is not a leaf, the return value is negative.
*/
[[nodiscard]] inline TreeNodeIndex cstoneIndex(TreeNodeIndex node) const
{
assert(size_t(node) < internalToLeaf_.size());
return internalToLeaf_[node];
}
/*! @brief finds the index of the node with SFC key range [startKey:endKey]
*
* @param startKey lower SFC key
* @param endKey upper SFC key
* @return The index i of the node that satisfies codeStart(i) == startKey
* and codeEnd(i) == endKey, or numTreeNodes() if no such node exists.
*/
TreeNodeIndex locate(KeyType startKey, KeyType endKey) const
{
//! prefixLength is 3 * treeLevel(endKey - startKey)
unsigned prefixLength = countLeadingZeros(endKey - startKey - 1) - unusedBits<KeyType>{};
return locate(encodePlaceholderBit(startKey, prefixLength));
}
TreeNodeIndex locate(KeyType nodeKey) const
{
unsigned level = decodePrefixLength(nodeKey) / 3;
auto it = std::lower_bound(prefixes_.begin() + levelRange_[level], prefixes_.begin() + levelRange_[level + 1],
nodeKey);
if (it != prefixes_.end() && *it == nodeKey) { return it - prefixes_.begin(); }
else { return numTreeNodes(); }
}
private:
friend class FocusedOctreeCore<KeyType>;
void resize(TreeNodeIndex numCsLeafNodes)
{
numLeafNodes_ = numCsLeafNodes;
numInternalNodes_ = (numLeafNodes_ - 1) / 7;
TreeNodeIndex numNodes = numLeafNodes_ + numInternalNodes_;
prefixes_.resize(numNodes);
// +1 to accommodate nodeOffsets in FocusedOctreeCore::update when numNodes == 1
childOffsets_.resize(numNodes + 1);
parents_.resize((numNodes - 1) / 8);
/*! Apart from the root at level 0, there are maxTreeLevel<KeyType>{} non-trivial levels.
* For convenience, we also store the root offset, even though the root is always a single node
* at offset 0. So in total there are maxTreeLevel<KeyType>{}+1 levels and we need
* another +1 to store the last upper bound which is equal to the total number of nodes in the tree.
*/
levelRange_.resize(maxTreeLevel<KeyType>{} + 2);
internalToLeaf_.resize(numNodes);
leafToInternal_.resize(numNodes);
}
TreeNodeIndex numLeafNodes_{0};
TreeNodeIndex numInternalNodes_{0};
using Alloc = util::DefaultInitAdaptor<TreeNodeIndex>;
//! @brief the SFC key and level of each node (Warren-Salmon placeholder-bit), length = numNodes
std::vector<KeyType> prefixes_;
//! @brief the index of the first child of each node, a value of 0 indicates a leaf, length = numNodes
std::vector<TreeNodeIndex, Alloc> childOffsets_;
//! @brief stores the parent index for every group of 8 sibling nodes, length the (numNodes - 1) / 8
std::vector<TreeNodeIndex, Alloc> parents_;
//! @brief store the first node index of every tree level, length = maxTreeLevel + 2
std::vector<TreeNodeIndex, Alloc> levelRange_;
//! @brief maps between the (level-key) sorted layout B and the unsorted intermediate binary layout A
std::vector<TreeNodeIndex, Alloc> internalToLeaf_;
std::vector<TreeNodeIndex, Alloc> leafToInternal_;
//! @brief the cornerstone leaf SFC key array
std::vector<KeyType> cstoneTree_;
};
template<class T, class CombinationFunction>
void upsweep(gsl::span<const TreeNodeIndex> levelOffset,
gsl::span<const TreeNodeIndex> childOffsets,
T* quantities,
CombinationFunction&& combinationFunction)
{
int currentLevel = levelOffset.size() - 2;
for (; currentLevel >= 0; --currentLevel)
{
TreeNodeIndex start = levelOffset[currentLevel];
TreeNodeIndex end = levelOffset[currentLevel + 1];
#pragma omp parallel for schedule(static)
for (TreeNodeIndex i = start; i < end; ++i)
{
cstone::TreeNodeIndex firstChild = childOffsets[i];
if (firstChild) { quantities[i] = combinationFunction(i, firstChild, quantities); }
}
}
}
template<class T>
struct SumCombination
{
T operator()(TreeNodeIndex /*nodeIdx*/, TreeNodeIndex c, const T* Q)
{
return Q[c] + Q[c + 1] + Q[c + 2] + Q[c + 3] + Q[c + 4] + Q[c + 5] + Q[c + 6] + Q[c + 7];
}
};
} // namespace cstone
| 42.80837 | 118 | 0.65912 | lks1248 |
240f3d2ca00b20b83544b93e0e815914c0ac5a94 | 16,996 | cc | C++ | media/cdm/ppapi/cdm_file_io_impl.cc | metux/chromium-deb | 3c08e9b89a1b6f95f103a61ff4f528dbcd57fc42 | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | null | null | null | media/cdm/ppapi/cdm_file_io_impl.cc | metux/chromium-deb | 3c08e9b89a1b6f95f103a61ff4f528dbcd57fc42 | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | null | null | null | media/cdm/ppapi/cdm_file_io_impl.cc | metux/chromium-deb | 3c08e9b89a1b6f95f103a61ff4f528dbcd57fc42 | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | null | null | null | // 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 "media/cdm/ppapi/cdm_file_io_impl.h"
#include <sstream>
#include "media/cdm/ppapi/cdm_logging.h"
#include "ppapi/c/pp_errors.h"
#include "ppapi/cpp/dev/url_util_dev.h"
namespace media {
// Arbitrary choice based on the following heuristic ideas:
// - not too big to avoid unnecessarily large memory allocation;
// - not too small to avoid breaking most reads into multiple read operations.
const int kReadSize = 8 * 1024;
// Call func_call and check the result. If the result is not
// PP_OK_COMPLETIONPENDING, print out logs, call OnError() and return.
#define CHECK_PP_OK_COMPLETIONPENDING(func_call, error_type) \
do { \
int32_t result = func_call; \
PP_DCHECK(result != PP_OK); \
if (result != PP_OK_COMPLETIONPENDING) { \
CDM_DLOG() << #func_call << " failed with result: " << result; \
state_ = STATE_ERROR; \
OnError(error_type); \
return; \
} \
} while (0)
#if !defined(NDEBUG)
// PPAPI calls should only be made on the main thread. In this file, main thread
// checking is only performed in public APIs and the completion callbacks. This
// ensures all functions are running on the main thread since internal methods
// are called either by the public APIs or by the completion callbacks.
static bool IsMainThread() {
return pp::Module::Get()->core()->IsMainThread();
}
#endif // !defined(NDEBUG)
// Posts a task to run |cb| on the main thread. The task is posted even if the
// current thread is the main thread.
static void PostOnMain(pp::CompletionCallback cb) {
pp::Module::Get()->core()->CallOnMainThread(0, cb, PP_OK);
}
CdmFileIOImpl::FileLockMap* CdmFileIOImpl::file_lock_map_ = NULL;
CdmFileIOImpl::ResourceTracker::ResourceTracker() {
// Do nothing here since we lazy-initialize CdmFileIOImpl::file_lock_map_
// in CdmFileIOImpl::AcquireFileLock().
}
CdmFileIOImpl::ResourceTracker::~ResourceTracker() {
delete CdmFileIOImpl::file_lock_map_;
}
CdmFileIOImpl::CdmFileIOImpl(
cdm::FileIOClient* client,
PP_Instance pp_instance,
const pp::CompletionCallback& first_file_read_cb)
: state_(STATE_UNOPENED),
client_(client),
pp_instance_handle_(pp_instance),
io_offset_(0),
first_file_read_reported_(false),
first_file_read_cb_(first_file_read_cb),
callback_factory_(this) {
PP_DCHECK(IsMainThread());
PP_DCHECK(pp_instance); // 0 indicates a "NULL handle".
}
CdmFileIOImpl::~CdmFileIOImpl() {
// The destructor is private. |this| can only be destructed through Close().
PP_DCHECK(state_ == STATE_CLOSED);
}
// Call sequence: Open() -> OpenFileSystem() -> STATE_FILE_SYSTEM_OPENED.
// Note: This only stores file name and opens the file system. The real file
// open is deferred to when Read() or Write() is called.
void CdmFileIOImpl::Open(const char* file_name, uint32_t file_name_size) {
CDM_DLOG() << __func__ << " " << std::string(file_name, file_name_size);
PP_DCHECK(IsMainThread());
if (state_ != STATE_UNOPENED) {
CDM_DLOG() << "Open() called in an invalid state.";
OnError(OPEN_ERROR);
return;
}
// File name should not (1) be empty, (2) start with '_', or (3) contain any
// path separators.
std::string file_name_str(file_name, file_name_size);
if (file_name_str.empty() ||
file_name_str[0] == '_' ||
file_name_str.find('/') != std::string::npos ||
file_name_str.find('\\') != std::string::npos) {
CDM_DLOG() << "Invalid file name.";
state_ = STATE_ERROR;
OnError(OPEN_ERROR);
return;
}
// pp::FileRef only accepts path that begins with a '/' character.
file_name_ = '/' + file_name_str;
if (!AcquireFileLock()) {
CDM_DLOG() << "File is in use by other cdm::FileIO objects.";
OnError(OPEN_WHILE_IN_USE);
return;
}
state_ = STATE_OPENING_FILE_SYSTEM;
OpenFileSystem();
}
// Call sequence:
// Read() -> OpenFileForRead() -> ReadFile() -> Done.
void CdmFileIOImpl::Read() {
CDM_DLOG() << __func__;
PP_DCHECK(IsMainThread());
if (state_ == STATE_READING || state_ == STATE_WRITING) {
CDM_DLOG() << "Read() called during pending read/write.";
OnError(READ_WHILE_IN_USE);
return;
}
if (state_ != STATE_FILE_SYSTEM_OPENED) {
CDM_DLOG() << "Read() called in an invalid state.";
OnError(READ_ERROR);
return;
}
PP_DCHECK(io_offset_ == 0);
PP_DCHECK(io_buffer_.empty());
PP_DCHECK(cumulative_read_buffer_.empty());
io_buffer_.resize(kReadSize);
io_offset_ = 0;
state_ = STATE_READING;
OpenFileForRead();
}
// Call sequence:
// Write() -> OpenTempFileForWrite() -> WriteTempFile() -> RenameTempFile().
// The file name of the temporary file is /_<requested_file_name>.
void CdmFileIOImpl::Write(const uint8_t* data, uint32_t data_size) {
CDM_DLOG() << __func__ << ": size = " << data_size;
PP_DCHECK(IsMainThread());
if (state_ == STATE_READING || state_ == STATE_WRITING) {
CDM_DLOG() << "Write() called during pending read/write.";
OnError(WRITE_WHILE_IN_USE);
return;
}
if (state_ != STATE_FILE_SYSTEM_OPENED) {
CDM_DLOG() << "Write() called in an invalid state.";
OnError(WRITE_ERROR);
return;
}
PP_DCHECK(io_offset_ == 0);
PP_DCHECK(io_buffer_.empty());
if (data_size > 0)
io_buffer_.assign(data, data + data_size);
else
PP_DCHECK(!data);
state_ = STATE_WRITING;
OpenTempFileForWrite();
}
void CdmFileIOImpl::Close() {
CDM_DLOG() << __func__;
PP_DCHECK(IsMainThread());
PP_DCHECK(state_ != STATE_CLOSED);
Reset();
state_ = STATE_CLOSED;
ReleaseFileLock();
// All pending callbacks are canceled since |callback_factory_| is destroyed.
delete this;
}
bool CdmFileIOImpl::SetFileID() {
PP_DCHECK(file_id_.empty());
PP_DCHECK(!file_name_.empty() && file_name_[0] == '/');
// Not taking ownership of |url_util_dev| (which is a singleton).
const pp::URLUtil_Dev* url_util_dev = pp::URLUtil_Dev::Get();
PP_URLComponents_Dev components;
pp::Var url_var =
url_util_dev->GetDocumentURL(pp_instance_handle_, &components);
if (!url_var.is_string())
return false;
std::string url = url_var.AsString();
file_id_.append(url, components.scheme.begin, components.scheme.len);
file_id_ += ':';
file_id_.append(url, components.host.begin, components.host.len);
file_id_ += ':';
file_id_.append(url, components.port.begin, components.port.len);
file_id_ += file_name_;
return true;
}
bool CdmFileIOImpl::AcquireFileLock() {
PP_DCHECK(IsMainThread());
if (file_id_.empty() && !SetFileID())
return false;
if (!file_lock_map_) {
file_lock_map_ = new FileLockMap();
} else {
FileLockMap::iterator found = file_lock_map_->find(file_id_);
if (found != file_lock_map_->end() && found->second)
return false;
}
(*file_lock_map_)[file_id_] = true;
return true;
}
void CdmFileIOImpl::ReleaseFileLock() {
PP_DCHECK(IsMainThread());
if (!file_lock_map_)
return;
FileLockMap::iterator found = file_lock_map_->find(file_id_);
if (found != file_lock_map_->end() && found->second)
found->second = false;
}
void CdmFileIOImpl::OpenFileSystem() {
PP_DCHECK(state_ == STATE_OPENING_FILE_SYSTEM);
pp::CompletionCallbackWithOutput<pp::FileSystem> cb =
callback_factory_.NewCallbackWithOutput(
&CdmFileIOImpl::OnFileSystemOpened);
isolated_file_system_ = pp::IsolatedFileSystemPrivate(
pp_instance_handle_, PP_ISOLATEDFILESYSTEMTYPE_PRIVATE_PLUGINPRIVATE);
CHECK_PP_OK_COMPLETIONPENDING(isolated_file_system_.Open(cb), OPEN_ERROR);
}
void CdmFileIOImpl::OnFileSystemOpened(int32_t result,
pp::FileSystem file_system) {
PP_DCHECK(IsMainThread());
PP_DCHECK(state_ == STATE_OPENING_FILE_SYSTEM);
if (result != PP_OK) {
CDM_DLOG() << "File system open failed asynchronously.";
ReleaseFileLock();
state_ = STATE_ERROR;
OnError(OPEN_ERROR);
return;
}
file_system_ = file_system;
state_ = STATE_FILE_SYSTEM_OPENED;
client_->OnOpenComplete(cdm::FileIOClient::kSuccess);
}
void CdmFileIOImpl::OpenFileForRead() {
PP_DCHECK(state_ == STATE_READING);
PP_DCHECK(file_io_.is_null());
PP_DCHECK(file_ref_.is_null());
file_io_ = pp::FileIO(pp_instance_handle_);
file_ref_ = pp::FileRef(file_system_, file_name_.c_str());
// Open file for read. If file doesn't exist, PP_ERROR_FILENOTFOUND will be
// returned.
int32_t file_open_flag = PP_FILEOPENFLAG_READ;
pp::CompletionCallback cb =
callback_factory_.NewCallback(&CdmFileIOImpl::OnFileOpenedForRead);
CHECK_PP_OK_COMPLETIONPENDING(file_io_.Open(file_ref_, file_open_flag, cb),
READ_ERROR);
}
void CdmFileIOImpl::OnFileOpenedForRead(int32_t result) {
CDM_DLOG() << __func__ << ": result = " << result;
PP_DCHECK(IsMainThread());
PP_DCHECK(state_ == STATE_READING);
if (result != PP_OK && result != PP_ERROR_FILENOTFOUND) {
CDM_DLOG() << "File open failed.";
state_ = STATE_ERROR;
OnError(OPEN_ERROR);
return;
}
// File doesn't exist.
if (result == PP_ERROR_FILENOTFOUND) {
Reset();
state_ = STATE_FILE_SYSTEM_OPENED;
client_->OnReadComplete(cdm::FileIOClient::kSuccess, NULL, 0);
return;
}
ReadFile();
}
// Call sequence:
// fully read
// ReadFile() ---> OnFileRead() ------------> Done.
// ^ |
// | partially read |
// |----------------|
void CdmFileIOImpl::ReadFile() {
PP_DCHECK(state_ == STATE_READING);
PP_DCHECK(!io_buffer_.empty());
pp::CompletionCallback cb =
callback_factory_.NewCallback(&CdmFileIOImpl::OnFileRead);
CHECK_PP_OK_COMPLETIONPENDING(
file_io_.Read(io_offset_, &io_buffer_[0], io_buffer_.size(), cb),
READ_ERROR);
}
void CdmFileIOImpl::OnFileRead(int32_t bytes_read) {
CDM_DLOG() << __func__ << ": bytes_read = " << bytes_read;
PP_DCHECK(IsMainThread());
PP_DCHECK(state_ == STATE_READING);
// 0 |bytes_read| indicates end-of-file reached.
if (bytes_read < PP_OK) {
CDM_DLOG() << "Read file failed.";
state_ = STATE_ERROR;
OnError(READ_ERROR);
return;
}
PP_DCHECK(static_cast<size_t>(bytes_read) <= io_buffer_.size());
// Append |bytes_read| in |io_buffer_| to |cumulative_read_buffer_|.
cumulative_read_buffer_.insert(cumulative_read_buffer_.end(),
io_buffer_.begin(),
io_buffer_.begin() + bytes_read);
io_offset_ += bytes_read;
// Not received end-of-file yet. Keep reading.
if (bytes_read > 0) {
ReadFile();
return;
}
// We hit end-of-file. Return read data to the client.
// Clear |cumulative_read_buffer_| in case OnReadComplete() calls Read() or
// Write().
std::vector<char> local_buffer;
std::swap(cumulative_read_buffer_, local_buffer);
const uint8_t* data = local_buffer.empty() ?
NULL : reinterpret_cast<const uint8_t*>(&local_buffer[0]);
// Call this before OnReadComplete() so that we always have the latest file
// size before CDM fires errors.
if (!first_file_read_reported_) {
first_file_read_cb_.Run(local_buffer.size());
first_file_read_reported_ = true;
}
Reset();
state_ = STATE_FILE_SYSTEM_OPENED;
client_->OnReadComplete(
cdm::FileIOClient::kSuccess, data, local_buffer.size());
}
void CdmFileIOImpl::OpenTempFileForWrite() {
PP_DCHECK(state_ == STATE_WRITING);
PP_DCHECK(file_name_.size() > 1 && file_name_[0] == '/');
// Temporary file name format: /_<requested_file_name>
std::string temp_file_name = "/_" + file_name_.substr(1);
PP_DCHECK(file_io_.is_null());
PP_DCHECK(file_ref_.is_null());
file_io_ = pp::FileIO(pp_instance_handle_);
file_ref_ = pp::FileRef(file_system_, temp_file_name.c_str());
// Create the file if it doesn't exist. Truncate the file to length 0 if it
// exists.
// TODO(xhwang): Find a good way to report to UMA cases where the temporary
// file already exists (due to previous interruption or failure).
int32_t file_open_flag = PP_FILEOPENFLAG_WRITE |
PP_FILEOPENFLAG_TRUNCATE |
PP_FILEOPENFLAG_CREATE;
pp::CompletionCallback cb =
callback_factory_.NewCallback(&CdmFileIOImpl::OnTempFileOpenedForWrite);
CHECK_PP_OK_COMPLETIONPENDING(
file_io_.Open(file_ref_, file_open_flag, cb), WRITE_ERROR);
}
void CdmFileIOImpl::OnTempFileOpenedForWrite(int32_t result) {
CDM_DLOG() << __func__ << ": result = " << result;
PP_DCHECK(IsMainThread());
PP_DCHECK(state_ == STATE_WRITING);
if (result != PP_OK) {
CDM_DLOG() << "Open temporary file failed.";
state_ = STATE_ERROR;
OnError(WRITE_ERROR);
return;
}
// We were told to write 0 bytes (to clear the file). In this case, there's
// no need to write anything.
if (io_buffer_.empty()) {
RenameTempFile();
return;
}
PP_DCHECK(io_offset_ == 0);
io_offset_ = 0;
WriteTempFile();
}
// Call sequence:
// fully written
// WriteTempFile() -> OnTempFileWritten() ---------------> RenameTempFile().
// ^ |
// | partially written |
// |---------------------|
void CdmFileIOImpl::WriteTempFile() {
PP_DCHECK(state_ == STATE_WRITING);
PP_DCHECK(io_offset_ < io_buffer_.size());
pp::CompletionCallback cb =
callback_factory_.NewCallback(&CdmFileIOImpl::OnTempFileWritten);
CHECK_PP_OK_COMPLETIONPENDING(file_io_.Write(io_offset_,
&io_buffer_[io_offset_],
io_buffer_.size() - io_offset_,
cb),
WRITE_ERROR);
}
void CdmFileIOImpl::OnTempFileWritten(int32_t bytes_written) {
CDM_DLOG() << __func__ << ": bytes_written = " << bytes_written;
PP_DCHECK(IsMainThread());
PP_DCHECK(state_ == STATE_WRITING);
if (bytes_written <= PP_OK) {
CDM_DLOG() << "Write temporary file failed.";
state_ = STATE_ERROR;
OnError(WRITE_ERROR);
return;
}
io_offset_ += bytes_written;
PP_DCHECK(io_offset_ <= io_buffer_.size());
if (io_offset_ < io_buffer_.size()) {
WriteTempFile();
return;
}
// All data written. Now rename the temporary file to the real file.
RenameTempFile();
}
void CdmFileIOImpl::RenameTempFile() {
PP_DCHECK(state_ == STATE_WRITING);
pp::CompletionCallback cb =
callback_factory_.NewCallback(&CdmFileIOImpl::OnTempFileRenamed);
CHECK_PP_OK_COMPLETIONPENDING(
file_ref_.Rename(pp::FileRef(file_system_, file_name_.c_str()), cb),
WRITE_ERROR);
}
void CdmFileIOImpl::OnTempFileRenamed(int32_t result) {
CDM_DLOG() << __func__ << ": result = " << result;
PP_DCHECK(IsMainThread());
PP_DCHECK(state_ == STATE_WRITING);
if (result != PP_OK) {
CDM_DLOG() << "Rename temporary file failed.";
state_ = STATE_ERROR;
OnError(WRITE_ERROR);
return;
}
Reset();
state_ = STATE_FILE_SYSTEM_OPENED;
client_->OnWriteComplete(cdm::FileIOClient::kSuccess);
}
void CdmFileIOImpl::Reset() {
PP_DCHECK(IsMainThread());
io_buffer_.clear();
io_offset_ = 0;
cumulative_read_buffer_.clear();
file_io_.Close();
file_io_ = pp::FileIO();
file_ref_ = pp::FileRef();
}
void CdmFileIOImpl::OnError(ErrorType error_type) {
// For *_WHILE_IN_USE errors, do not reset these values. Otherwise, the
// existing read/write operation will fail.
if (error_type == READ_ERROR || error_type == WRITE_ERROR)
Reset();
PostOnMain(callback_factory_.NewCallback(&CdmFileIOImpl::NotifyClientOfError,
error_type));
}
void CdmFileIOImpl::NotifyClientOfError(int32_t result,
ErrorType error_type) {
PP_DCHECK(result == PP_OK);
switch (error_type) {
case OPEN_ERROR:
client_->OnOpenComplete(cdm::FileIOClient::kError);
break;
case READ_ERROR:
client_->OnReadComplete(cdm::FileIOClient::kError, NULL, 0);
break;
case WRITE_ERROR:
client_->OnWriteComplete(cdm::FileIOClient::kError);
break;
case OPEN_WHILE_IN_USE:
client_->OnOpenComplete(cdm::FileIOClient::kInUse);
break;
case READ_WHILE_IN_USE:
client_->OnReadComplete(cdm::FileIOClient::kInUse, NULL, 0);
break;
case WRITE_WHILE_IN_USE:
client_->OnWriteComplete(cdm::FileIOClient::kInUse);
break;
}
}
} // namespace media
| 31.071298 | 80 | 0.659214 | metux |
240fe05ae04d8a9487c4e0d10f1aa6fd4826d31e | 446 | cpp | C++ | nucleo-l433/blink/src/main.cpp | Paolo-Maffei/stm32x | 790aa03a365952c8a3cf8fd334ae307c2130fedb | [
"Unlicense"
] | 2 | 2021-03-11T10:33:37.000Z | 2022-02-12T19:35:55.000Z | nucleo-l433/blink/src/main.cpp | Paolo-Maffei/stm32x | 790aa03a365952c8a3cf8fd334ae307c2130fedb | [
"Unlicense"
] | null | null | null | nucleo-l433/blink/src/main.cpp | Paolo-Maffei/stm32x | 790aa03a365952c8a3cf8fd334ae307c2130fedb | [
"Unlicense"
] | null | null | null | #include <jee.h>
UartBufDev< PinA<2>, PinA<3> > console;
int printf(const char* fmt, ...) {
va_list ap; va_start(ap, fmt); veprintf(console.putc, fmt, ap); va_end(ap);
return 0;
}
PinB<13> led;
int main() {
console.init();
console.baud(115200, fullSpeedClock());
led.mode(Pinmode::out);
while (1) {
printf("%d\n", ticks);
led = 1;
wait_ms(100);
led = 0;
wait_ms(400);
}
}
| 17.153846 | 79 | 0.542601 | Paolo-Maffei |
24111838746ac1e44a0599ad4044e59541da5c76 | 992 | cpp | C++ | openr/tests/benchmark/OpenrBenchmarkBase.cpp | willoughbyrm/openr | f32e4bf0037ea1e56286aa14eef016534ac1b6f3 | [
"MIT"
] | 1 | 2021-08-24T02:12:41.000Z | 2021-08-24T02:12:41.000Z | openr/tests/benchmark/OpenrBenchmarkBase.cpp | willoughbyrm/openr | f32e4bf0037ea1e56286aa14eef016534ac1b6f3 | [
"MIT"
] | null | null | null | openr/tests/benchmark/OpenrBenchmarkBase.cpp | willoughbyrm/openr | f32e4bf0037ea1e56286aa14eef016534ac1b6f3 | [
"MIT"
] | null | null | null | /*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
#include <openr/tests/benchmark/OpenrBenchmarkBase.h>
namespace openr {
OpenrBenchmarkBase::OpenrBenchmarkBase() {}
OpenrBenchmarkBase::~OpenrBenchmarkBase() {}
thrift::Value
OpenrBenchmarkBase::createAdjValue(
const std::string& node,
int64_t version,
const std::vector<thrift::Adjacency>& adjs,
bool overloaded,
int32_t nodeId,
int64_t ttlVersion,
int64_t hashValue) noexcept {
auto adjDB = createAdjDb(node, adjs, nodeId);
adjDB.isOverloaded_ref() = overloaded;
thrift::Value val;
val.value_ref() = writeThriftObjStr(adjDB, serializer_);
val.version_ref() = version;
val.originatorId_ref() = "originator-1";
val.ttl_ref() = Constants::kTtlInfinity;
val.ttlVersion_ref() = ttlVersion;
val.hash_ref() = hashValue;
return val;
}
} // namespace openr
| 26.105263 | 66 | 0.722782 | willoughbyrm |
24128b28629146d03e39f378236104401a51c8e3 | 7,931 | cpp | C++ | src/RageUtil/Sound/RageSoundReader_ChannelSplit.cpp | thenerdie/etterna | 341b7c506c785e3a15e7af18814791aefff5c958 | [
"MIT"
] | null | null | null | src/RageUtil/Sound/RageSoundReader_ChannelSplit.cpp | thenerdie/etterna | 341b7c506c785e3a15e7af18814791aefff5c958 | [
"MIT"
] | null | null | null | src/RageUtil/Sound/RageSoundReader_ChannelSplit.cpp | thenerdie/etterna | 341b7c506c785e3a15e7af18814791aefff5c958 | [
"MIT"
] | null | null | null | /*
* Output a sound from the channels of another sound.
*
* This is intended for splitting a FileReader, and assumes the
* GetStreamToSourceRatio of the source is 1.0.
*
* If multiple readers are created, they should be read in parallel. If their
* source position drifts apart, the data between will be buffered to prevent
* seeking the source.
*
* The resulting sounds have as many channels as the largest destination channel
* specified; multiple sounds on the same channel are mixed together; empty
* channels are silent.
*
* Create two mono sounds from one stereo sound, one playing the left channel
* and one playing the right: RageSoundSplitter split(pSource);
* RageSoundReader_Split *pLeft = split.CreateSound();
* pLeft->AddSourceChannelToSound( 0, 0 );
* RageSoundReader_Split *pRight = split.CreateSound();
* pRight->AddSourceChannelToSound( 1, 0 );
*
* Convert a stereo sound to mono:
* RageSoundSplitter split(pSource);
* RageSoundReader_Split *pMono = split.CreateSound();
* pMono->AddSourceChannelToSound( 0, 0 );
* pMono->AddSourceChannelToSound( 1, 0 );
*
* Convert a mono sound to stereo (RageSoundReader_Pan will do this faster):
* RageSoundSplitter split(pSource);
* RageSoundReader_Split *pStereo = split.CreateSound();
* pStereo->AddSourceChannelToSound( 0, 0 );
* pStereo->AddSourceChannelToSound( 0, 1 );
*/
#include "Etterna/Globals/global.h"
#include "Etterna/Models/Misc/Foreach.h"
#include "RageSoundMixBuffer.h"
#include "RageSoundReader_ChannelSplit.h"
#include "RageUtil/Utils/RageUtil.h"
#include <climits>
#include <set>
class RageSoundReader_Split;
/* This class is refcounted, freed when all RageSoundReader_Split and
* RageSoundSplitter classes release it. */
class RageSoundSplitterImpl
{
public:
explicit RageSoundSplitterImpl(RageSoundReader* pSource)
{
m_iRefCount = 1;
m_pSource = pSource;
m_iBufferPositionFrames = 0;
}
~RageSoundSplitterImpl() { delete m_pSource; }
static void Release(RageSoundSplitterImpl* pImpl)
{
--pImpl->m_iRefCount;
if (pImpl->m_iRefCount == 0)
delete pImpl;
}
/* Request that m_sBuffer contain frames [iStartFrame,iStartFrame+iFrames).
*/
int ReadBuffer();
int m_iRefCount;
RageSoundReader* m_pSource;
set<RageSoundReader_Split*> m_apSounds;
/* m_sBuffer[0] corresponds to frame number m_iBufferPositionFrames. */
int m_iBufferPositionFrames;
vector<float> m_sBuffer;
};
int
RageSoundReader_Split::GetLength() const
{
return m_pImpl->m_pSource->GetLength();
}
int
RageSoundReader_Split::GetLength_Fast() const
{
return m_pImpl->m_pSource->GetLength_Fast();
}
int
RageSoundReader_Split::GetSampleRate() const
{
return m_pImpl->m_pSource->GetSampleRate();
}
unsigned
RageSoundReader_Split::GetNumChannels() const
{
return m_iNumOutputChannels;
}
int
RageSoundReader_Split::GetNextSourceFrame() const
{
return m_iPositionFrame;
}
float
RageSoundReader_Split::GetStreamToSourceRatio() const
{
return 1.0f;
}
RString
RageSoundReader_Split::GetError() const
{
return m_pImpl->m_pSource->GetError();
}
RageSoundReader_Split::RageSoundReader_Split(RageSoundSplitterImpl* pImpl)
{
m_pImpl = pImpl;
++m_pImpl->m_iRefCount;
m_pImpl->m_apSounds.insert(this);
m_iNumOutputChannels = 0;
m_iPositionFrame = 0;
m_iRequestFrames = 0;
}
RageSoundReader_Split::RageSoundReader_Split(const RageSoundReader_Split& cpy)
: RageSoundReader(cpy)
{
m_pImpl = cpy.m_pImpl;
++m_pImpl->m_iRefCount;
m_pImpl->m_apSounds.insert(this);
m_aChannels = cpy.m_aChannels;
m_iNumOutputChannels = cpy.m_iNumOutputChannels;
m_iPositionFrame = cpy.m_iPositionFrame;
m_iRequestFrames = cpy.m_iRequestFrames;
}
RageSoundReader_Split::~RageSoundReader_Split()
{
m_pImpl->m_apSounds.erase(this);
RageSoundSplitterImpl::Release(m_pImpl);
}
int
RageSoundReader_Split::SetPosition(int iFrame)
{
m_iPositionFrame = iFrame;
/* We can't tell whether we're past EOF. We can't ReadBuffer here, because
* the other sounds using this same source probably haven't seeked yet, so
* seeking to the beginning of the file would buffer between there and the
* position of those sounds. Just return success, and we'll return EOF in
* Read if needed. */
return 1;
}
bool
RageSoundReader_Split::SetProperty(const RString& sProperty, float fValue)
{
return m_pImpl->m_pSource->SetProperty(sProperty, fValue);
}
int
RageSoundReader_Split::Read(float* pBuf, int iFrames)
{
m_iRequestFrames = iFrames;
int iRet = m_pImpl->ReadBuffer();
int iSamplesAvailable = m_pImpl->m_sBuffer.size();
const float* pSrc = &m_pImpl->m_sBuffer[0];
if (m_pImpl->m_iBufferPositionFrames < m_iPositionFrame) {
int iSkipFrames = m_iPositionFrame - m_pImpl->m_iBufferPositionFrames;
int iSkipSamples = iSkipFrames * m_pImpl->m_pSource->GetNumChannels();
pSrc += iSkipSamples;
iSamplesAvailable -= iSkipSamples;
}
int iFramesWanted = iFrames;
int iFramesAvailable =
iSamplesAvailable / (m_pImpl->m_pSource->GetNumChannels());
/* Report any errors from Read() if we don't have any data buffered to
* return. If we do have data, finish returning it first. */
if (iFramesAvailable == 0 && iRet < 0)
return iRet;
iFramesAvailable = min(iFramesAvailable, iFramesWanted);
{
RageSoundMixBuffer mix;
for (int i = 0; i < (int)m_aChannels.size(); ++i) {
const ChannelMap& chan = m_aChannels[i];
mix.SetWriteOffset(chan.m_iToChannel);
mix.write(pSrc + chan.m_iFromChannel,
iFramesAvailable,
m_pImpl->m_pSource->GetNumChannels(),
m_iNumOutputChannels);
}
mix.read(pBuf);
}
m_iPositionFrame += iFramesAvailable;
/* We no longer need the data we requested. Clear our request, so the
* memory can be freed. */
m_iRequestFrames = 0;
m_pImpl->ReadBuffer();
return iFramesAvailable;
}
int
RageSoundSplitterImpl::ReadBuffer()
{
/* Discard any bytes that are no longer requested by any sound. */
int iMinFrameRequested = INT_MAX;
int iMaxFrameRequested = INT_MIN;
FOREACHS(RageSoundReader_Split*, m_apSounds, snd)
{
iMinFrameRequested = min(iMinFrameRequested, (*snd)->m_iPositionFrame);
iMaxFrameRequested =
max(iMaxFrameRequested,
(*snd)->m_iPositionFrame + (*snd)->m_iRequestFrames);
}
if (iMinFrameRequested > m_iBufferPositionFrames) {
int iEraseFrames = iMinFrameRequested - m_iBufferPositionFrames;
iEraseFrames = min(iEraseFrames, (int)m_sBuffer.size());
m_sBuffer.erase(m_sBuffer.begin(),
m_sBuffer.begin() +
iEraseFrames * m_pSource->GetNumChannels());
m_iBufferPositionFrames += iEraseFrames;
}
if (iMinFrameRequested != m_iBufferPositionFrames) {
m_pSource->SetPosition(iMinFrameRequested);
m_iBufferPositionFrames = iMinFrameRequested;
m_sBuffer.clear();
}
int iFramesBuffered = m_sBuffer.size() / m_pSource->GetNumChannels();
int iFramesToRead =
iMaxFrameRequested - (m_iBufferPositionFrames + iFramesBuffered);
if (iFramesToRead <= 0)
return 1; // requested data already buffered
int iSamplesToRead = iFramesToRead * m_pSource->GetNumChannels();
int iOldSizeSamples = m_sBuffer.size();
m_sBuffer.resize(iOldSizeSamples + iSamplesToRead);
int iGotFrames =
m_pSource->Read(&m_sBuffer[0] + iOldSizeSamples, iFramesToRead);
if (iGotFrames < 0) {
m_sBuffer.resize(iOldSizeSamples);
return iGotFrames;
}
int iGotSamples = iGotFrames * m_pSource->GetNumChannels();
m_sBuffer.resize(iOldSizeSamples + iGotSamples);
return 1;
}
void
RageSoundReader_Split::AddSourceChannelToSound(int iFromChannel, int iToChannel)
{
m_aChannels.push_back(ChannelMap(iFromChannel, iToChannel));
m_iNumOutputChannels = max(m_iNumOutputChannels, iToChannel + 1);
}
RageSoundSplitter::RageSoundSplitter(RageSoundReader* pSource)
{
m_pImpl = new RageSoundSplitterImpl(pSource);
}
RageSoundSplitter::~RageSoundSplitter()
{
RageSoundSplitterImpl::Release(m_pImpl);
}
RageSoundReader_Split*
RageSoundSplitter::CreateSound()
{
return new RageSoundReader_Split(m_pImpl);
}
| 27.730769 | 80 | 0.756147 | thenerdie |
24141cd68a03022af0af7dc1abf9c81d2e68802f | 1,581 | cc | C++ | win/win_util_unittest.cc | chinmaygarde/flutter_base | 40e46434df6711b5c219823d3a01ffa1f2fb10d6 | [
"BSD-3-Clause"
] | 20 | 2015-08-26T06:46:00.000Z | 2019-02-27T09:05:58.000Z | win/win_util_unittest.cc | chinmaygarde/flutter_base | 40e46434df6711b5c219823d3a01ffa1f2fb10d6 | [
"BSD-3-Clause"
] | 1 | 2021-05-05T11:11:31.000Z | 2021-05-05T11:11:31.000Z | win/win_util_unittest.cc | chinmaygarde/flutter_base | 40e46434df6711b5c219823d3a01ffa1f2fb10d6 | [
"BSD-3-Clause"
] | 7 | 2016-02-09T09:28:14.000Z | 2020-07-25T19:03:36.000Z | // Copyright (c) 2010 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 <windows.h>
#include "base/basictypes.h"
#include "base/strings/string_util.h"
#include "base/win/win_util.h"
#include "base/win/windows_version.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace base {
namespace win {
namespace {
// Saves the current thread's locale ID when initialized, and restores it when
// the instance is going out of scope.
class ThreadLocaleSaver {
public:
ThreadLocaleSaver() : original_locale_id_(GetThreadLocale()) {}
~ThreadLocaleSaver() { SetThreadLocale(original_locale_id_); }
private:
LCID original_locale_id_;
DISALLOW_COPY_AND_ASSIGN(ThreadLocaleSaver);
};
} // namespace
// The test is somewhat silly, because the Vista bots some have UAC enabled
// and some have it disabled. At least we check that it does not crash.
TEST(BaseWinUtilTest, TestIsUACEnabled) {
if (GetVersion() >= base::win::VERSION_VISTA) {
UserAccountControlIsEnabled();
} else {
EXPECT_TRUE(UserAccountControlIsEnabled());
}
}
TEST(BaseWinUtilTest, TestGetUserSidString) {
std::wstring user_sid;
EXPECT_TRUE(GetUserSidString(&user_sid));
EXPECT_TRUE(!user_sid.empty());
}
TEST(BaseWinUtilTest, TestGetNonClientMetrics) {
NONCLIENTMETRICS_XP metrics = {0};
GetNonClientMetrics(&metrics);
EXPECT_GT(metrics.cbSize, 0u);
EXPECT_GT(metrics.iScrollWidth, 0);
EXPECT_GT(metrics.iScrollHeight, 0);
}
} // namespace win
} // namespace base
| 26.79661 | 78 | 0.748893 | chinmaygarde |
241565c84aac230e8a008b23d03b2e5b6d76fe0f | 2,184 | cpp | C++ | test/ofp/message_unittest.cpp | byllyfish/oftr | ac1e4ef09388376ea6fa7b460b6abe2ab3471624 | [
"MIT"
] | 1 | 2019-06-14T13:57:28.000Z | 2019-06-14T13:57:28.000Z | test/ofp/message_unittest.cpp | byllyfish/oftr | ac1e4ef09388376ea6fa7b460b6abe2ab3471624 | [
"MIT"
] | 20 | 2017-02-20T04:49:10.000Z | 2019-07-09T05:32:54.000Z | test/ofp/message_unittest.cpp | byllyfish/oftr | ac1e4ef09388376ea6fa7b460b6abe2ab3471624 | [
"MIT"
] | 1 | 2019-07-16T00:21:42.000Z | 2019-07-16T00:21:42.000Z | // Copyright (c) 2015-2018 William W. Fisher (at gmail dot com)
// This file is distributed under the MIT License.
#include "ofp/message.h"
#include "ofp/flowmod.h"
#include "ofp/unittest.h"
using namespace ofp;
TEST(message, constructor) {
Message message{nullptr};
EXPECT_EQ(8, message.size());
}
TEST(message, normalize) {
const char *hexBefore =
"010E 0048 0000 002C 0010 001F 0000 0000 0000 0000 0000 0000 0000 0000 "
"0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 "
"0003 0000 0000 8000 FFFF FFFF FFFF 0000";
auto s = HexToRawData(hexBefore);
Message msg{nullptr};
std::memcpy(msg.mutableDataResized(s.length()), s.data(), s.length());
EXPECT_EQ(0x48, msg.size());
EXPECT_HEX(hexBefore, msg.data(), msg.size());
msg.normalize();
const char *hexAfter =
"010E00880000002C0000000000000000FFFFFFFFFFFFFFFF0003000000008000FFFFFFFF"
"FFFFFFFF000000000000000000000058000000000000030F000000000000000000000000"
"000000000000000000000000000000000000000000000000FFFFFFFF00000000FFFFFFFF"
"00000000000000000000000000000000000000000000000000000000";
EXPECT_EQ(0x088, msg.size());
EXPECT_HEX(hexAfter, msg.data(), msg.size());
}
TEST(message, normalize_flow_mod) {
const char *hexBefore =
"010E 0048 0000 0060 0010 001F 0000 0000 0000 0000 "
"0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 "
"0000 0000 0000 0000 0000 0000 0000 0000 0003 0000 "
"0000 8000 FFFF FFFF FFFF 0000";
auto s = HexToRawData(hexBefore);
Message message{nullptr};
std::memcpy(message.mutableDataResized(s.length()), s.data(), s.length());
message.normalize();
const FlowMod *msg = FlowMod::cast(&message);
EXPECT_TRUE(msg);
if (msg) {
EXPECT_EQ(0, msg->cookie());
EXPECT_EQ(0xFFFFFFFFFFFFFFFFUL, msg->cookieMask());
EXPECT_EQ(0, msg->tableId());
EXPECT_EQ(3, msg->command());
EXPECT_EQ(0, msg->idleTimeout());
EXPECT_EQ(0, msg->hardTimeout());
EXPECT_EQ(0x8000, msg->priority());
EXPECT_EQ(0xFFFFFFFFU, msg->bufferId());
EXPECT_EQ(0xFFFFFFFFU, msg->outPort());
EXPECT_EQ(0, msg->outGroup());
EXPECT_EQ(0, msg->flags());
}
}
| 30.760563 | 80 | 0.702839 | byllyfish |
2415f1317e5f29e7055d22b53be96449b8ae3569 | 51,453 | cpp | C++ | Source/General/Driver/Filter/ASTC/Core/astcenc_ideal_endpoints_and_weights.cpp | paintdream/paintsnow | 3a1cbc9e571eaa2e62a3a2d60f75817b45f0c781 | [
"MIT"
] | 15 | 2016-09-17T16:29:42.000Z | 2021-11-24T06:21:27.000Z | Source/General/Driver/Filter/ASTC/Core/astcenc_ideal_endpoints_and_weights.cpp | paintdream/paintsnow | 3a1cbc9e571eaa2e62a3a2d60f75817b45f0c781 | [
"MIT"
] | null | null | null | Source/General/Driver/Filter/ASTC/Core/astcenc_ideal_endpoints_and_weights.cpp | paintdream/paintsnow | 3a1cbc9e571eaa2e62a3a2d60f75817b45f0c781 | [
"MIT"
] | 3 | 2017-04-07T13:33:57.000Z | 2021-03-31T02:04:48.000Z | // SPDX-License-Identifier: Apache-2.0
// ----------------------------------------------------------------------------
// Copyright 2011-2021 Arm Limited
//
// 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.
// ----------------------------------------------------------------------------
#if !defined(ASTCENC_DECOMPRESS_ONLY)
/**
* @brief Functions for computing color endpoints and texel weights.
*/
#include <cassert>
#include "astcenc_internal.h"
#include "astcenc_vecmathlib.h"
static void compute_endpoints_and_ideal_weights_1_comp(
const block_size_descriptor* bsd,
const partition_info* pt,
const imageblock* blk,
const error_weight_block* ewb,
endpoints_and_weights* ei,
unsigned int component
) {
int partition_count = pt->partition_count;
ei->ep.partition_count = partition_count;
promise(partition_count > 0);
int texel_count = bsd->texel_count;
promise(texel_count > 0);
float lowvalues[4] { 1e10f, 1e10f, 1e10f, 1e10f };
float highvalues[4] { -1e10f, -1e10f, -1e10f, -1e10f };
float partition_error_scale[4];
float linelengths_rcp[4];
const float *error_weights = nullptr;
const float* data_vr = nullptr;
assert(component < 4);
switch (component)
{
case 0:
error_weights = ewb->texel_weight_r;
data_vr = blk->data_r;
break;
case 1:
error_weights = ewb->texel_weight_g;
data_vr = blk->data_g;
break;
case 2:
error_weights = ewb->texel_weight_b;
data_vr = blk->data_b;
break;
default:
error_weights = ewb->texel_weight_a;
data_vr = blk->data_a;
break;
}
for (int i = 0; i < texel_count; i++)
{
if (error_weights[i] > 1e-10f)
{
float value = data_vr[i];
int partition = pt->partition_of_texel[i];
lowvalues[partition] = astc::min(value, lowvalues[partition]);
highvalues[partition] = astc::max(value, highvalues[partition]);
}
}
vmask4 sep_mask = vint4::lane_id() == vint4(component);
for (int i = 0; i < partition_count; i++)
{
float diff = highvalues[i] - lowvalues[i];
if (diff < 0)
{
lowvalues[i] = 0.0f;
highvalues[i] = 0.0f;
}
diff = astc::max(diff, 1e-7f);
partition_error_scale[i] = diff * diff;
linelengths_rcp[i] = 1.0f / diff;
ei->ep.endpt0[i] = select(blk->data_min, vfloat4(lowvalues[i]), sep_mask);
ei->ep.endpt1[i] = select(blk->data_max, vfloat4(highvalues[i]), sep_mask);
}
bool is_constant_wes = true;
float constant_wes = partition_error_scale[pt->partition_of_texel[0]] * error_weights[0];
for (int i = 0; i < texel_count; i++)
{
float value = data_vr[i];
int partition = pt->partition_of_texel[i];
value -= lowvalues[partition];
value *= linelengths_rcp[partition];
value = astc::clamp1f(value);
ei->weights[i] = value;
ei->weight_error_scale[i] = partition_error_scale[partition] * error_weights[i];
assert(!astc::isnan(ei->weight_error_scale[i]));
is_constant_wes = is_constant_wes && ei->weight_error_scale[i] == constant_wes;
}
ei->is_constant_weight_error_scale = is_constant_wes;
}
static void compute_endpoints_and_ideal_weights_2_comp(
const block_size_descriptor* bsd,
const partition_info* pt,
const imageblock* blk,
const error_weight_block * ewb,
endpoints_and_weights* ei,
int component1,
int component2
) {
int partition_count = pt->partition_count;
ei->ep.partition_count = partition_count;
promise(partition_count > 0);
int texel_count = bsd->texel_count;
promise(texel_count > 0);
partition_metrics pms[4];
const float *error_weights;
const float* data_vr = nullptr;
const float* data_vg = nullptr;
if (component1 == 0 && component2 == 1)
{
error_weights = ewb->texel_weight_rg;
data_vr = blk->data_r;
data_vg = blk->data_g;
}
else if (component1 == 0 && component2 == 2)
{
error_weights = ewb->texel_weight_rb;
data_vr = blk->data_r;
data_vg = blk->data_b;
}
else // (component1 == 1 && component2 == 2)
{
error_weights = ewb->texel_weight_gb;
data_vr = blk->data_g;
data_vg = blk->data_b;
}
float lowparam[4] { 1e10f, 1e10f, 1e10f, 1e10f };
float highparam[4] { -1e10f, -1e10f, -1e10f, -1e10f };
line2 lines[4];
float scale[4];
float length_squared[4];
compute_avgs_and_dirs_2_comp(pt, blk, ewb, component1, component2, pms);
for (int i = 0; i < partition_count; i++)
{
float2 dir = pms[i].dir.swz<0, 1>();
if (dir.r + dir.g < 0.0f)
{
dir = float2(0.0f) - dir;
}
lines[i].a = pms[i].avg.swz<0, 1>();
if (dot(dir, dir) == 0.0f)
{
lines[i].b = normalize(float2(1.0f));
}
else
{
lines[i].b = normalize(dir);
}
}
for (int i = 0; i < texel_count; i++)
{
if (error_weights[i] > 1e-10f)
{
int partition = pt->partition_of_texel[i];
float2 point = float2(data_vr[i], data_vg[i]) * float2(pms[partition].color_scale.lane<0>(), pms[partition].color_scale.lane<0>());
line2 l = lines[partition];
float param = dot(point - l.a, l.b);
ei->weights[i] = param;
lowparam[partition] = astc::min(param, lowparam[partition]);
highparam[partition] = astc::max(param, highparam[partition]);
}
else
{
ei->weights[i] = -1e38f;
}
}
float2 lowvalues[4];
float2 highvalues[4];
for (int i = 0; i < partition_count; i++)
{
float length = highparam[i] - lowparam[i];
if (length < 0.0f) // case for when none of the texels had any weight
{
lowparam[i] = 0.0f;
highparam[i] = 1e-7f;
}
// it is possible for a uniform-color partition to produce length=0; this
// causes NaN-production and NaN-propagation later on. Set length to
// a small value to avoid this problem.
length = astc::max(length, 1e-7f);
length_squared[i] = length * length;
scale[i] = 1.0f / length;
float2 ep0 = lines[i].a + lines[i].b * lowparam[i];
float2 ep1 = lines[i].a + lines[i].b * highparam[i];
ep0.r /= pms[i].color_scale.lane<0>();
ep0.g /= pms[i].color_scale.lane<1>();
ep1.r /= pms[i].color_scale.lane<0>();
ep1.g /= pms[i].color_scale.lane<1>();
lowvalues[i] = ep0;
highvalues[i] = ep1;
}
vmask4 comp1_mask = vint4::lane_id() == vint4(component1);
vmask4 comp2_mask = vint4::lane_id() == vint4(component2);
for (int i = 0; i < partition_count; i++)
{
vfloat4 ep0 = select(blk->data_min, vfloat4(lowvalues[i].r), comp1_mask);
vfloat4 ep1 = select(blk->data_max, vfloat4(highvalues[i].r), comp1_mask);
ei->ep.endpt0[i] = select(ep0, vfloat4(lowvalues[i].g), comp2_mask);
ei->ep.endpt1[i] = select(ep1, vfloat4(highvalues[i].g), comp2_mask);
}
bool is_constant_wes = true;
float constant_wes = length_squared[pt->partition_of_texel[0]] * error_weights[0];
for (int i = 0; i < texel_count; i++)
{
int partition = pt->partition_of_texel[i];
float idx = (ei->weights[i] - lowparam[partition]) * scale[partition];
idx = astc::clamp1f(idx);
ei->weights[i] = idx;
ei->weight_error_scale[i] = length_squared[partition] * error_weights[i];
assert(!astc::isnan(ei->weight_error_scale[i]));
is_constant_wes = is_constant_wes && ei->weight_error_scale[i] == constant_wes;
}
ei->is_constant_weight_error_scale = is_constant_wes;
}
static void compute_endpoints_and_ideal_weights_3_comp(
const block_size_descriptor* bsd,
const partition_info* pt,
const imageblock* blk,
const error_weight_block* ewb,
endpoints_and_weights* ei,
int omitted_component
) {
int partition_count = pt->partition_count;
ei->ep.partition_count = partition_count;
promise(partition_count > 0);
int texel_count= bsd->texel_count;
promise(texel_count > 0);
partition_metrics pms[4];
const float *error_weights;
const float* data_vr = nullptr;
const float* data_vg = nullptr;
const float* data_vb = nullptr;
if (omitted_component == 0)
{
error_weights = ewb->texel_weight_gba;
data_vr = blk->data_g;
data_vg = blk->data_b;
data_vb = blk->data_a;
}
else if (omitted_component == 1)
{
error_weights = ewb->texel_weight_rba;
data_vr = blk->data_r;
data_vg = blk->data_b;
data_vb = blk->data_a;
}
else if (omitted_component == 2)
{
error_weights = ewb->texel_weight_rga;
data_vr = blk->data_r;
data_vg = blk->data_g;
data_vb = blk->data_a;
}
else
{
error_weights = ewb->texel_weight_rgb;
data_vr = blk->data_r;
data_vg = blk->data_g;
data_vb = blk->data_b;
}
float lowparam[4] { 1e10f, 1e10f, 1e10f, 1e10f };
float highparam[4] { -1e10f, -1e10f, -1e10f, -1e10f };
line3 lines[4];
float scale[4];
float length_squared[4];
compute_avgs_and_dirs_3_comp(pt, blk, ewb, omitted_component, pms);
for (int i = 0; i < partition_count; i++)
{
vfloat4 dir = pms[i].dir;
if (hadd_rgb_s(dir) < 0.0f)
{
dir = vfloat4(0.0f) - dir;
}
lines[i].a = pms[i].avg;
lines[i].b = normalize_safe(dir, unit3());
}
for (int i = 0; i < texel_count; i++)
{
if (error_weights[i] > 1e-10f)
{
int partition = pt->partition_of_texel[i];
vfloat4 point = vfloat4(data_vr[i], data_vg[i], data_vb[i], 0.0f) * pms[partition].color_scale;
line3 l = lines[partition];
float param = dot3_s(point - l.a, l.b);
ei->weights[i] = param;
lowparam[partition] = astc::min(param, lowparam[partition]);
highparam[partition] = astc::max(param, highparam[partition]);
}
else
{
ei->weights[i] = -1e38f;
}
}
for (int i = 0; i < partition_count; i++)
{
float length = highparam[i] - lowparam[i];
if (length < 0) // case for when none of the texels had any weight
{
lowparam[i] = 0.0f;
highparam[i] = 1e-7f;
}
// it is possible for a uniform-color partition to produce length=0; this
// causes NaN-production and NaN-propagation later on. Set length to
// a small value to avoid this problem.
length = astc::max(length, 1e-7f);
length_squared[i] = length * length;
scale[i] = 1.0f / length;
vfloat4 ep0 = lines[i].a + lines[i].b * lowparam[i];
vfloat4 ep1 = lines[i].a + lines[i].b * highparam[i];
ep0 = ep0 / pms[i].color_scale;
ep1 = ep1 / pms[i].color_scale;
vfloat4 bmin = blk->data_min;
vfloat4 bmax = blk->data_max;
// TODO: Probably a programmatic vector permute we can do here ...
assert(omitted_component < 4);
switch (omitted_component)
{
case 0:
ei->ep.endpt0[i] = vfloat4(bmin.lane<0>(), ep0.lane<0>(), ep0.lane<1>(), ep0.lane<2>());
ei->ep.endpt1[i] = vfloat4(bmax.lane<0>(), ep1.lane<0>(), ep1.lane<1>(), ep1.lane<2>());
break;
case 1:
ei->ep.endpt0[i] = vfloat4(ep0.lane<0>(), bmin.lane<1>(), ep0.lane<1>(), ep0.lane<2>());
ei->ep.endpt1[i] = vfloat4(ep1.lane<0>(), bmax.lane<1>(), ep1.lane<1>(), ep1.lane<2>());
break;
case 2:
ei->ep.endpt0[i] = vfloat4(ep0.lane<0>(), ep0.lane<1>(), bmin.lane<2>(), ep0.lane<2>());
ei->ep.endpt1[i] = vfloat4(ep1.lane<0>(), ep1.lane<1>(), bmax.lane<2>(), ep1.lane<2>());
break;
default:
ei->ep.endpt0[i] = vfloat4(ep0.lane<0>(), ep0.lane<1>(), ep0.lane<2>(), bmin.lane<3>());
ei->ep.endpt1[i] = vfloat4(ep1.lane<0>(), ep1.lane<1>(), ep1.lane<2>(), bmax.lane<3>());
break;
}
}
bool is_constant_wes = true;
float constant_wes = length_squared[pt->partition_of_texel[0]] * error_weights[0];
for (int i = 0; i < texel_count; i++)
{
int partition = pt->partition_of_texel[i];
float idx = (ei->weights[i] - lowparam[partition]) * scale[partition];
idx = astc::clamp1f(idx);
ei->weights[i] = idx;
ei->weight_error_scale[i] = length_squared[partition] * error_weights[i];
assert(!astc::isnan(ei->weight_error_scale[i]));
is_constant_wes = is_constant_wes && ei->weight_error_scale[i] == constant_wes;
}
ei->is_constant_weight_error_scale = is_constant_wes;
}
static void compute_endpoints_and_ideal_weights_4_comp(
const block_size_descriptor* bsd,
const partition_info* pt,
const imageblock* blk,
const error_weight_block* ewb,
endpoints_and_weights* ei
) {
const float *error_weights = ewb->texel_weight;
int partition_count = pt->partition_count;
int texel_count= bsd->texel_count;
promise(texel_count > 0);
promise(partition_count > 0);
float lowparam[4] { 1e10, 1e10, 1e10, 1e10 };
float highparam[4] { -1e10, -1e10, -1e10, -1e10 };
line4 lines[4];
float scale[4];
float length_squared[4];
partition_metrics pms[4];
compute_avgs_and_dirs_4_comp(pt, blk, ewb, pms);
// if the direction-vector ends up pointing from light to dark, FLIP IT!
// this will make the first endpoint the darkest one.
for (int i = 0; i < partition_count; i++)
{
vfloat4 dir = pms[i].dir;
if (hadd_rgb_s(dir) < 0.0f)
{
dir = vfloat4::zero() - dir;
}
lines[i].a = pms[i].avg;
if (dot_s(dir, dir) == 0.0f)
{
lines[i].b = normalize(vfloat4(1.0f));
}
else
{
lines[i].b = normalize(dir);
}
}
for (int i = 0; i < texel_count; i++)
{
if (error_weights[i] > 1e-10f)
{
int partition = pt->partition_of_texel[i];
vfloat4 point = blk->texel(i) * pms[partition].color_scale;
line4 l = lines[partition];
float param = dot_s(point - l.a, l.b);
ei->weights[i] = param;
lowparam[partition] = astc::min(param, lowparam[partition]);
highparam[partition] = astc::max(param, highparam[partition]);
}
else
{
ei->weights[i] = -1e38f;
}
}
for (int i = 0; i < partition_count; i++)
{
float length = highparam[i] - lowparam[i];
if (length < 0)
{
lowparam[i] = 0.0f;
highparam[i] = 1e-7f;
}
// it is possible for a uniform-color partition to produce length=0; this
// causes NaN-production and NaN-propagation later on. Set length to
// a small value to avoid this problem.
length = astc::max(length, 1e-7f);
length_squared[i] = length * length;
scale[i] = 1.0f / length;
vfloat4 ep0 = lines[i].a + lines[i].b * lowparam[i];
vfloat4 ep1 = lines[i].a + lines[i].b * highparam[i];
ei->ep.endpt0[i] = ep0 / pms[i].color_scale;
ei->ep.endpt1[i] = ep1 / pms[i].color_scale;
}
bool is_constant_wes = true;
float constant_wes = length_squared[pt->partition_of_texel[0]] * error_weights[0];
for (int i = 0; i < texel_count; i++)
{
int partition = pt->partition_of_texel[i];
float idx = (ei->weights[i] - lowparam[partition]) * scale[partition];
idx = astc::clamp1f(idx);
ei->weights[i] = idx;
ei->weight_error_scale[i] = error_weights[i] * length_squared[partition];
assert(!astc::isnan(ei->weight_error_scale[i]));
is_constant_wes = is_constant_wes && ei->weight_error_scale[i] == constant_wes;
}
ei->is_constant_weight_error_scale = is_constant_wes;
}
/*
For a given partitioning, compute: for each partition, the ideal endpoint colors;
these define a color line for the partition. for each pixel, the ideal position of the pixel on the partition's
color line. for each pixel, the length of the color line.
These data allow us to assess the error introduced by removing and quantizing the per-pixel weights.
*/
void compute_endpoints_and_ideal_weights_1plane(
const block_size_descriptor* bsd,
const partition_info* pt,
const imageblock* blk,
const error_weight_block* ewb,
endpoints_and_weights* ei
) {
int uses_alpha = imageblock_uses_alpha(blk);
if (uses_alpha)
{
compute_endpoints_and_ideal_weights_4_comp(bsd, pt, blk, ewb, ei);
}
else
{
compute_endpoints_and_ideal_weights_3_comp(bsd, pt, blk, ewb, ei, 3);
}
}
void compute_endpoints_and_ideal_weights_2planes(
const block_size_descriptor* bsd,
const partition_info* pt,
const imageblock* blk,
const error_weight_block* ewb,
int plane2_component,
endpoints_and_weights* ei1,
endpoints_and_weights* ei2
) {
int uses_alpha = imageblock_uses_alpha(blk);
assert(plane2_component < 4);
switch (plane2_component)
{
case 0: // separate weights for red
if (uses_alpha)
{
compute_endpoints_and_ideal_weights_3_comp(bsd, pt, blk, ewb, ei1, 0);
}
else
{
compute_endpoints_and_ideal_weights_2_comp(bsd, pt, blk, ewb, ei1, 1, 2);
}
compute_endpoints_and_ideal_weights_1_comp(bsd, pt, blk, ewb, ei2, 0);
break;
case 1: // separate weights for green
if (uses_alpha)
{
compute_endpoints_and_ideal_weights_3_comp(bsd, pt, blk, ewb, ei1, 1);
}
else
{
compute_endpoints_and_ideal_weights_2_comp(bsd, pt, blk, ewb, ei1, 0, 2);
}
compute_endpoints_and_ideal_weights_1_comp(bsd, pt, blk, ewb, ei2, 1);
break;
case 2: // separate weights for blue
if (uses_alpha)
{
compute_endpoints_and_ideal_weights_3_comp(bsd, pt, blk, ewb, ei1, 2);
}
else
{
compute_endpoints_and_ideal_weights_2_comp(bsd, pt, blk, ewb, ei1, 0, 1);
}
compute_endpoints_and_ideal_weights_1_comp(bsd, pt, blk, ewb, ei2, 2);
break;
default: // separate weights for alpha
assert(uses_alpha);
compute_endpoints_and_ideal_weights_3_comp(bsd, pt, blk, ewb, ei1, 3);
compute_endpoints_and_ideal_weights_1_comp(bsd, pt, blk, ewb, ei2, 3);
break;
}
}
/*
After having computed ideal weights for the case where a weight exists for
every texel, we want to compute the ideal weights for the case where weights
exist only for some texels.
We do this with a steepest-descent grid solver; this works as follows:
* First, for each actual weight, perform a weighted averaging based on the
texels affected by the weight.
* Then, set step size to <some initial value>
* Then, repeat:
1: First, compute for each weight how much the error will change
if we change the weight by an infinitesimal amount.
2: This produces a vector that points the direction we should step in.
Normalize this vector.
3: Perform a step
4: Check if the step actually improved the error. If it did, perform
another step in the same direction; repeat until error no longer
improves. If the *first* step did not improve error, then we halve
the step size.
5: If the step size dropped down below <some threshold value>,
then we quit, else we go back to #1.
Subroutines: one routine to apply a step and compute the step's effect on
the error one routine to compute the error change of an infinitesimal
weight change
Data structures needed:
For every decimation pattern, we need:
* For each weight, a list of <texel, weight> tuples that tell which texels
the weight influences.
* For each texel, a list of <texel, weight> tuples that tell which weights
go into a given texel.
*/
float compute_error_of_weight_set_1plane(
const endpoints_and_weights* eai,
const decimation_table* dt,
const float* weights
) {
vfloat4 error_summav = vfloat4::zero();
float error_summa = 0.0f;
int texel_count = dt->texel_count;
int i = 0;
// Process SIMD-width texel coordinates at at time while we can
int clipped_texel_count = round_down_to_simd_multiple_vla(texel_count);
for (/* */; i < clipped_texel_count; i += ASTCENC_SIMD_WIDTH)
{
// Compute the bilinear interpolation of the decimated weight grid
vfloat current_values = bilinear_infill_vla(*dt, weights, i);
// Compute the error between the computed value and the ideal weight
vfloat actual_values = loada(&(eai->weights[i]));
vfloat diff = current_values - actual_values;
vfloat significance = loada(&(eai->weight_error_scale[i]));
vfloat error = diff * diff * significance;
haccumulate(error_summav, error);
}
// Loop tail
// Error is buffered and accumulated in blocks of 4 to ensure that
// the partial sums added to the accumulator are invariant with the
// vector implementation, irrespective of vector size ...
#if CMAKE_ANDROID
__attribute__((aligned(16))) float errorsum_tmp[4] { 0 };
#else
alignas(16) float errorsum_tmp[4] { 0 };
#endif
for (/* */; i < texel_count; i++)
{
float current_value = bilinear_infill(*dt, weights, i);
float valuedif = current_value - eai->weights[i];
float error = valuedif * valuedif * eai->weight_error_scale[i];
// Accumulate error sum in the temporary array
int error_index = i & 0x3;
errorsum_tmp[error_index] = error;
#if ASTCENC_SIMD_WIDTH == 8
// Zero the temporary staging buffer every 4 items unless last. Note
// that this block can only trigger for 6x5 blocks, all other partials
// tails are shorter than 4 ...
if ((i & 0x7) == 0x03)
{
haccumulate(error_summav, vfloat4::loada(errorsum_tmp));
storea(vfloat4::zero(), errorsum_tmp);
}
#endif
}
// Accumulate the loop tail using the vfloat4 swizzle
haccumulate(error_summav, vfloat4::loada(errorsum_tmp));
// Resolve the final scalar accumulator sum
haccumulate(error_summa, error_summav);
return error_summa;
}
float compute_error_of_weight_set_2planes(
const endpoints_and_weights* eai1,
const endpoints_and_weights* eai2,
const decimation_table* dt,
const float* weights1,
const float* weights2
) {
float error_summa = 0.0f;
int texel_count = dt->texel_count;
int i = 0;
vfloat4 error_summav = vfloat4::zero();
// Process SIMD-width texel coordinates at at time while we can
int clipped_texel_count = round_down_to_simd_multiple_vla(texel_count);
for (/* */; i < clipped_texel_count; i += ASTCENC_SIMD_WIDTH)
{
// Plane 1
// Compute the bilinear interpolation of the decimated weight grid
vfloat current_values1 = bilinear_infill_vla(*dt, weights1, i);
// Compute the error between the computed value and the ideal weight
vfloat actual_values1 = loada(&(eai1->weights[i]));
vfloat diff = current_values1 - actual_values1;
vfloat error1 = diff * diff * loada(&(eai1->weight_error_scale[i]));
// Plane 2
// Compute the bilinear interpolation of the decimated weight grid
vfloat current_values2 = bilinear_infill_vla(*dt, weights2, i);
// Compute the error between the computed value and the ideal weight
vfloat actual_values2 = loada(&(eai2->weights[i]));
diff = current_values2 - actual_values2;
vfloat error2 = diff * diff * loada(&(eai2->weight_error_scale[i]));
haccumulate(error_summav, error1 + error2);
}
// Loop tail
// Error is buffered and accumulated in blocks of 4 to ensure that
// the partial sums added to the accumulator are invariant with the
// vector implementation, irrespective of vector size ...
#if CMAKE_ANDROID
__attribute__((aligned(16))) float errorsum_tmp[4]{ 0 };
#else
alignas(16) float errorsum_tmp[4]{ 0 };
#endif
for (/* */; i < texel_count; i++)
{
// Plane 1
float current_value1 = bilinear_infill(*dt, weights1, i);
float valuedif1 = current_value1 - eai1->weights[i];
float error1 = valuedif1 * valuedif1 * eai1->weight_error_scale[i];
// Plane 2
float current_value2 = bilinear_infill(*dt, weights2, i);
float valuedif2 = current_value2 - eai2->weights[i];
float error2 = valuedif2 * valuedif2 * eai2->weight_error_scale[i];
// Accumulate error sum in the temporary array
int error_index = i & 0x3;
errorsum_tmp[error_index] = error1 + error2;
#if ASTCENC_SIMD_WIDTH == 8
// Zero the temporary staging buffer every 4 items unless last. Note
// that this block can only trigger for 6x5 blocks, all other partials
// tails are shorter than 4 ...
if ((i & 0x7) == 0x03)
{
haccumulate(error_summav, vfloat4::loada(errorsum_tmp));
storea(vfloat4::zero(), errorsum_tmp);
}
#endif
}
// Accumulate the loop tail using the vfloat4 swizzle
haccumulate(error_summav, vfloat4::loada(errorsum_tmp));
// Resolve the final scalar accumulator sum
haccumulate(error_summa, error_summav);
return error_summa;
}
/* See header for documentation. */
// Note: This function is vectorized, but needs to use gathers to access the
// decimation table structures so vectorization is currently only enabled for
// AVX2. The implementation loops over decimated weights, and then texels for
// each weight. We know the backing memory is "large enough" we can can
// overshoot the weight count to always use full vectors without a loop tail.
// The inner loop operates on 8 weights, each of which may have a different
// number of texels referenced by it. We iterate over the max reference count,
// and then use lane masks to disable lanes that are no longer in scope.
void compute_ideal_weights_for_decimation_table(
const endpoints_and_weights& eai_in,
endpoints_and_weights& eai_out,
const decimation_table& dt,
float* RESTRICT weight_set,
float* RESTRICT weights
) {
int texel_count = dt.texel_count;
int weight_count = dt.weight_count;
promise(texel_count > 0);
promise(weight_count > 0);
// This function includes a copy of the epw from eai_in to eai_out. We do it
// here because we want to load the data anyway, so we can avoid loading it
// from memory twice.
eai_out.ep = eai_in.ep;
eai_out.is_constant_weight_error_scale = eai_in.is_constant_weight_error_scale;
// Ensure that the end of the output arrays that are used for SIMD paths later are filled so we
// can safely run SIMD elsewhere without a loop tail. Note that this is always safe as weight
// arrays always contain space for 64 elements
int simd_weight_count = round_up_to_simd_multiple_vla(weight_count);
for (int i = weight_count; i < simd_weight_count; i++)
{
weight_set[i] = 0.0f;
}
// If we have a 1:1 mapping just shortcut the computation - clone the
// weights into both the weight set and the output epw copy.
if (texel_count == weight_count)
{
for (int i = 0; i < texel_count; i++)
{
assert(i == dt.weight_texel[0][i]);
weight_set[i] = eai_in.weights[i];
weights[i] = eai_in.weight_error_scale[i];
eai_out.weights[i] = eai_in.weights[i];
eai_out.weight_error_scale[i] = eai_in.weight_error_scale[i];
}
return;
}
// If we don't have a 1:1 mapping just clone the weights into the output
// epw copy and then do the full algorithm to decimate weights.
else
{
for (int i = 0; i < texel_count; i++)
{
eai_out.weights[i] = eai_in.weights[i];
eai_out.weight_error_scale[i] = eai_in.weight_error_scale[i];
}
}
// Otherwise compute an estimate and perform single refinement iteration
#if CMAKE_ANDROID
__attribute__((aligned(ASTCENC_VECALIGN))) float infilled_weights[MAX_TEXELS_PER_BLOCK];
#else
alignas(ASTCENC_VECALIGN) float infilled_weights[MAX_TEXELS_PER_BLOCK];
#endif
// Compute an initial average for each decimated weight
bool constant_wes = eai_in.is_constant_weight_error_scale;
vfloat weight_error_scale(eai_in.weight_error_scale[0]);
// This overshoots - this is OK as we initialize the array tails in the
// decimation table structures to safe values ...
for (int i = 0; i < weight_count; i += ASTCENC_SIMD_WIDTH)
{
// Accumulate error weighting of all the texels using this weight
vint weight_texel_count(dt.weight_texel_count + i);
// Start with a small value to avoid div-by-zero later
vfloat weight_weight(1e-10f);
vfloat initial_weight = vfloat::zero();
int b = std::max(weight_texel_count.m[0], weight_texel_count.m[1]);
int c = std::max(weight_texel_count.m[2], weight_texel_count.m[3]);
int max_texel_count = std::max(b, c);
promise(max_texel_count > 0);
for (int j = 0; j < max_texel_count; j++)
{
// Not all lanes may actually use j texels, so mask out if idle
vmask active = weight_texel_count > vint(j);
vint texel(dt.weight_texel[j] + i);
texel = select(vint::zero(), texel, active);
vfloat weight = loada(dt.weights_flt[j] + i);
weight = select(vfloat::zero(), weight, active);
if (!constant_wes)
{
weight_error_scale = gatherf(eai_in.weight_error_scale, texel);
}
vfloat contrib_weight = weight * weight_error_scale;
weight_weight += contrib_weight;
initial_weight += gatherf(eai_in.weights, texel) * contrib_weight;
}
storea(weight_weight, weights + i);
storea(initial_weight / weight_weight, weight_set + i);
}
// Populate the interpolated weight grid based on the initital average
// Process SIMD-width texel coordinates at at time while we can
int is = 0;
int clipped_texel_count = round_down_to_simd_multiple_vla(texel_count);
for (/* */; is < clipped_texel_count; is += ASTCENC_SIMD_WIDTH)
{
vfloat weight = bilinear_infill_vla(dt, weight_set, is);
storea(weight, infilled_weights + is);
}
// Loop tail
for (/* */; is < texel_count; is++)
{
infilled_weights[is] = bilinear_infill(dt, weight_set, is);
}
// Perform a single iteration of refinement
constexpr float stepsize = 0.25f;
constexpr float chd_scale = -TEXEL_WEIGHT_SUM;
for (int i = 0; i < weight_count; i += ASTCENC_SIMD_WIDTH)
{
// Start with a small value to avoid div-by-zero later
vfloat weight_val = loada(weight_set + i);
// Accumulate error weighting of all the texels using this weight
vfloat error_change0(1e-10f);
vfloat error_change1(0.0f);
// Accumulate error weighting of all the texels using this weight
vint weight_texel_count(dt.weight_texel_count + i);
int b = std::max(weight_texel_count.m[0], weight_texel_count.m[1]);
int c = std::max(weight_texel_count.m[2], weight_texel_count.m[3]);
int max_texel_count = std::max(b, c);
promise(max_texel_count > 0);
for (int j = 0; j < max_texel_count; j++)
{
// Not all lanes may actually use j texels, so mask out if idle
vmask active = weight_texel_count > vint(j);
vint texel(dt.weight_texel[j] + i);
texel = select(vint::zero(), texel, active);
vfloat contrib_weight = loada(dt.weights_flt[j] + i);
contrib_weight = select(vfloat::zero(), contrib_weight, active);
if (!constant_wes)
{
weight_error_scale = gatherf((const float*)eai_in.weight_error_scale, texel);
}
vfloat scale = weight_error_scale * contrib_weight;
vfloat old_weight = gatherf(infilled_weights, texel);
vfloat ideal_weight = gatherf(eai_in.weights, texel);
error_change0 = error_change0 + contrib_weight * scale;
error_change1 = error_change1 + (old_weight - ideal_weight) * scale;
}
vfloat step = (error_change1 * chd_scale) / error_change0;
step = clamp(-stepsize, stepsize, step);
// update the weight
storea(weight_val + step, weight_set + i);
}
}
/*
For a decimation table, try to compute an optimal weight set, assuming
that the weights are quantized and subject to a transfer function.
We do this as follows:
First, we take the initial weights and quantize them. This is our initial estimate.
Then, go through the weights one by one; try to perturb then up and down one weight at a
time; apply any perturbations that improve overall error
Repeat until we have made a complete processing pass over all weights without
triggering any perturbations *OR* we have run 4 full passes.
*/
void compute_quantized_weights_for_decimation_table(
const decimation_table* dt,
float low_bound,
float high_bound,
const float* weight_set_in,
float* weight_set_out,
uint8_t* quantized_weight_set,
int quant_level
) {
int weight_count = dt->weight_count;
promise(weight_count > 0);
const quantization_and_transfer_table *qat = &(quant_and_xfer_tables[quant_level]);
static const int quant_levels[12] { 2,3,4,5,6,8,10,12,16,20,24,32 };
float quant_level_m1 = (float)(quant_levels[quant_level] - 1);
// Quantize the weight set using both the specified low/high bounds
// and the standard 0..1 weight bounds.
assert(high_bound > low_bound);
float rscale = high_bound - low_bound;
float scale = 1.0f / rscale;
float scaled_low_bound = low_bound * scale;
rscale *= 1.0f / 64.0f;
vfloat scalev(scale);
vfloat scaled_low_boundv(scaled_low_bound);
vfloat quant_level_m1v(quant_level_m1);
vfloat rscalev(rscale);
vfloat low_boundv(low_bound);
// This runs to the rounded-up SIMD size, which is safe as the loop tail is filled with known
// safe data in compute_ideal_weights_for_decimation_table and arrays are always 64 elements
for (int i = 0; i < weight_count; i += ASTCENC_SIMD_WIDTH)
{
vfloat ix = loada(&weight_set_in[i]) * scalev - scaled_low_boundv;
ix = clampzo(ix);
// Look up the two closest indexes and return the one that was closest
vfloat ix1 = ix * quant_level_m1v;
vint weightl = float_to_int(ix1);
vint weighth = weightl + vint(1);
vfloat ixl = gatherf(qat->unquantized_value_unsc, weightl);
vfloat ixh = gatherf(qat->unquantized_value_unsc, weighth);
vmask mask = (ixl + ixh) < (vfloat(128.0f) * ix);
vint weight = select(weightl, weighth, mask);
ixl = select(ixl, ixh, mask);
// Invert the weight-scaling that was done initially
storea(ixl * rscalev + low_boundv, &weight_set_out[i]);
vint scm = gatheri(qat->scramble_map, weight);
vint scn = pack_low_bytes(scm);
store_nbytes(scn, &quantized_weight_set[i]);
}
}
static inline vfloat4 compute_rgbovec(
vfloat4 rgba_weight_sum,
vfloat4 weight_weight_sum,
vfloat4 rgbq_sum,
float psum
) {
// Compute the rgb+offset for HDR endpoint mode #7. Since the matrix needed
// has a regular structure, we can simplify the inverse calculation. This
// gives us ~24 multiplications, down from 96 for a generic inverse
// mat[0] = vfloat4(rgba_ws.x, 0.0f, 0.0f, wght_ws.x);
// mat[1] = vfloat4( 0.0f, rgba_ws.y, 0.0f, wght_ws.y);
// mat[2] = vfloat4( 0.0f, 0.0f, rgba_ws.z, wght_ws.z);
// mat[3] = vfloat4(wght_ws.x, wght_ws.y, wght_ws.z, psum);
// mat = invert(mat);
float X = rgba_weight_sum.lane<0>();
float Y = rgba_weight_sum.lane<1>();
float Z = rgba_weight_sum.lane<2>();
float P = weight_weight_sum.lane<0>();
float Q = weight_weight_sum.lane<1>();
float R = weight_weight_sum.lane<2>();
float S = psum;
float PP = P * P;
float QQ = Q * Q;
float RR = R * R;
float SZmRR = S * Z - RR;
float DT = SZmRR * Y - Z * QQ;
float YP = Y * P;
float QX = Q * X;
float YX = Y * X;
float mZYP = -Z * YP;
float mZQX = -Z * QX;
float mRYX = -R * YX;
float ZQP = Z * Q * P;
float RYP = R * YP;
float RQX = R * QX;
// Compute the reciprocal of matrix determinant.
float rdet = 1.0f / (DT * X + mZYP * P);
// Actually compute the adjugate matrix, not the inverse, and apply the
// multiplication by 1/det to the vector separately.
vfloat4 mat0(DT, ZQP, RYP, mZYP);
vfloat4 mat1(ZQP, SZmRR * X - Z * PP, RQX, mZQX);
vfloat4 mat2(RYP, RQX, (S * Y - QQ) * X - Y * PP, mRYX);
vfloat4 mat3(mZYP, mZQX, mRYX, Z * YX);
vfloat4 vect = rgbq_sum * rdet;
return vfloat4(dot_s(mat0, vect),
dot_s(mat1, vect),
dot_s(mat2, vect),
dot_s(mat3, vect));
}
/* for a given weight set, we wish to recompute the colors so that they are optimal for a particular weight set. */
void recompute_ideal_colors_2planes(
int weight_quant_mode,
endpoints* ep, // contains the endpoints we wish to update
vfloat4* rgbs_vectors, // used to return RGBS-vectors for endpoint mode #6
vfloat4* rgbo_vectors, // used to return RGBO-vectors for endpoint mode #7
const uint8_t* weight_set8_plane1, // Plane 1 weight set
const uint8_t* weight_set8_plane2, // Plane 2 weight set
int plane2_component, // Color component for 2nd plane of weights
const partition_info* pt,
const decimation_table* dt,
const imageblock* blk, // picture-block containing the actual data.
const error_weight_block* ewb
) {
int weight_count = dt->weight_count;
int partition_count = pt->partition_count;
promise(weight_count > 0);
promise(partition_count > 0);
const quantization_and_transfer_table *qat = &(quant_and_xfer_tables[weight_quant_mode]);
float weight_set[MAX_WEIGHTS_PER_BLOCK];
float plane2_weight_set[MAX_WEIGHTS_PER_BLOCK];
for (int i = 0; i < weight_count; i++)
{
weight_set[i] = qat->unquantized_value[weight_set8_plane1[i]] * (1.0f / 64.0f);
plane2_weight_set[i] = qat->unquantized_value[weight_set8_plane2[i]] * (1.0f / 64.0f);
}
for (int i = 0; i < partition_count; i++)
{
vfloat4 rgba_sum(1e-17f);
vfloat4 rgba_weight_sum(1e-17f);
int texel_count = pt->partition_texel_count[i];
const uint8_t *texel_indexes = pt->texels_of_partition[i];
for (int j = 0; j < texel_count; j++)
{
int tix = texel_indexes[j];
vfloat4 rgba = blk->texel(tix);
vfloat4 error_weight = ewb->error_weights[tix];
rgba_sum += rgba * error_weight;
rgba_weight_sum += error_weight;
}
vfloat4 scale_direction = normalize((rgba_sum * (1.0f / rgba_weight_sum)).swz<0, 1, 2>());
float scale_max = 0.0f;
float scale_min = 1e10f;
float wmin1 = 1.0f;
float wmax1 = 0.0f;
float wmin2 = 1.0f;
float wmax2 = 0.0f;
vfloat4 left_sum = vfloat4::zero();
vfloat4 middle_sum = vfloat4::zero();
vfloat4 right_sum = vfloat4::zero();
vfloat4 left2_sum = vfloat4::zero();
vfloat4 middle2_sum = vfloat4::zero();
vfloat4 right2_sum = vfloat4::zero();
vfloat4 lmrs_sum = vfloat4::zero();
vfloat4 color_vec_x = vfloat4::zero();
vfloat4 color_vec_y = vfloat4::zero();
float2 scale_vec = float2(0.0f);
vfloat4 weight_weight_sum = vfloat4(1e-17f);
float psum = 1e-17f;
// FIXME: the loop below has too many responsibilities, making it inefficient.
for (int j = 0; j < texel_count; j++)
{
int tix = texel_indexes[j];
vfloat4 rgba = blk->texel(tix);
vfloat4 color_weight = ewb->error_weights[tix];
// FIXME: move this calculation out to the color block.
float ls_weight = hadd_rgb_s(color_weight);
float idx0 = bilinear_infill(*dt, weight_set, tix);
float om_idx0 = 1.0f - idx0;
wmin1 = astc::min(idx0, wmin1);
wmax1 = astc::max(idx0, wmax1);
float scale = dot3_s(scale_direction, rgba);
scale_min = astc::min(scale, scale_min);
scale_max = astc::max(scale, scale_max);
vfloat4 left = color_weight * (om_idx0 * om_idx0);
vfloat4 middle = color_weight * (om_idx0 * idx0);
vfloat4 right = color_weight * (idx0 * idx0);
vfloat4 lmrs = vfloat4(om_idx0 * om_idx0,
om_idx0 * idx0,
idx0 * idx0,
0.0f) * ls_weight;
left_sum += left;
middle_sum += middle;
right_sum += right;
lmrs_sum += lmrs;
float idx1 = 0.0f;
float om_idx1 = 0.0f;
idx1 = bilinear_infill(*dt, plane2_weight_set, tix);
om_idx1 = 1.0f - idx1;
wmin2 = astc::min(idx1, wmin2);
wmax2 = astc::max(idx1, wmax2);
vfloat4 left2 = color_weight * (om_idx1 * om_idx1);
vfloat4 middle2 = color_weight * (om_idx1 * idx1);
vfloat4 right2 = color_weight * (idx1 * idx1);
left2_sum += left2;
middle2_sum += middle2;
right2_sum += right2;
vmask4 p2_mask = vint4::lane_id() == vint4(plane2_component);
vfloat4 color_idx = select(vfloat4(idx0), vfloat4(idx1), p2_mask);
vfloat4 cwprod = color_weight * rgba;
vfloat4 cwiprod = cwprod * color_idx;
color_vec_y += cwiprod;
color_vec_x += cwprod - cwiprod;
scale_vec += float2(om_idx0, idx0) * (ls_weight * scale);
weight_weight_sum += (color_weight * color_idx);
psum += dot3_s(color_weight * color_idx, color_idx);
}
// calculations specific to mode #7, the HDR RGB-scale mode.
// FIXME: Can we skip this for LDR textures?
vfloat4 rgbq_sum = color_vec_x + color_vec_y;
rgbq_sum.set_lane<3>(hadd_rgb_s(color_vec_y));
vfloat4 rgbovec = compute_rgbovec(rgba_weight_sum, weight_weight_sum,
rgbq_sum, psum);
rgbo_vectors[i] = rgbovec;
// We will occasionally get a failure due to the use of a singular
// (non-invertible) matrix. Record whether such a failure has taken
// place; if it did, compute rgbo_vectors[] with a different method
// later on.
float chkval = dot_s(rgbovec, rgbovec);
int rgbo_fail = chkval != chkval;
// Initialize the luminance and scale vectors with a reasonable
// default, just in case the subsequent calculation blows up.
float scalediv = scale_min * (1.0f / astc::max(scale_max, 1e-10f));
scalediv = astc::clamp1f(scalediv);
vfloat4 sds = scale_direction * scale_max;
rgbs_vectors[i] = vfloat4(sds.lane<0>(), sds.lane<1>(), sds.lane<2>(), scalediv);
if (wmin1 >= wmax1 * 0.999f)
{
// if all weights in the partition were equal, then just take average
// of all colors in the partition and use that as both endpoint colors.
vfloat4 avg = (color_vec_x + color_vec_y) * (1.0f / rgba_weight_sum);
vmask4 p1_mask = vint4::lane_id() != vint4(plane2_component);
vmask4 notnan_mask = avg == avg;
vmask4 full_mask = p1_mask & notnan_mask;
ep->endpt0[i] = select(ep->endpt0[i], avg, full_mask);
ep->endpt1[i] = select(ep->endpt1[i], avg, full_mask);
rgbs_vectors[i] = vfloat4(sds.lane<0>(), sds.lane<1>(), sds.lane<2>(), 1.0f);
}
else
{
// otherwise, complete the analytic calculation of ideal-endpoint-values
// for the given set of texel weights and pixel colors.
vfloat4 color_det1 = (left_sum * right_sum) - (middle_sum * middle_sum);
vfloat4 color_rdet1 = 1.0f / color_det1;
float ls_det1 = (lmrs_sum.lane<0>() * lmrs_sum.lane<2>()) - (lmrs_sum.lane<1>() * lmrs_sum.lane<1>());
float ls_rdet1 = 1.0f / ls_det1;
vfloat4 color_mss1 = (left_sum * left_sum)
+ (2.0f * middle_sum * middle_sum)
+ (right_sum * right_sum);
float ls_mss1 = (lmrs_sum.lane<0>() * lmrs_sum.lane<0>())
+ (2.0f * lmrs_sum.lane<1>() * lmrs_sum.lane<1>())
+ (lmrs_sum.lane<2>() * lmrs_sum.lane<2>());
vfloat4 ep0 = (right_sum * color_vec_x - middle_sum * color_vec_y) * color_rdet1;
vfloat4 ep1 = (left_sum * color_vec_y - middle_sum * color_vec_x) * color_rdet1;
float scale_ep0 = (lmrs_sum.lane<2>() * scale_vec.r - lmrs_sum.lane<1>() * scale_vec.g) * ls_rdet1;
float scale_ep1 = (lmrs_sum.lane<0>() * scale_vec.g - lmrs_sum.lane<1>() * scale_vec.r) * ls_rdet1;
vmask4 p1_mask = vint4::lane_id() != vint4(plane2_component);
vmask4 det_mask = abs(color_det1) > (color_mss1 * 1e-4f);
vmask4 notnan_mask = (ep0 == ep0) & (ep1 == ep1);
vmask4 full_mask = p1_mask & det_mask & notnan_mask;
ep->endpt0[i] = select(ep->endpt0[i], ep0, full_mask);
ep->endpt1[i] = select(ep->endpt1[i], ep1, full_mask);
if (fabsf(ls_det1) > (ls_mss1 * 1e-4f) && scale_ep0 == scale_ep0 && scale_ep1 == scale_ep1 && scale_ep0 < scale_ep1)
{
float scalediv2 = scale_ep0 * (1.0f / scale_ep1);
vfloat4 sdsm = scale_direction * scale_ep1;
rgbs_vectors[i] = vfloat4(sdsm.lane<0>(), sdsm.lane<1>(), sdsm.lane<2>(), scalediv2);
}
}
if (wmin2 >= wmax2 * 0.999f)
{
// if all weights in the partition were equal, then just take average
// of all colors in the partition and use that as both endpoint colors.
vfloat4 avg = (color_vec_x + color_vec_y) * (1.0f / rgba_weight_sum);
vmask4 p2_mask = vint4::lane_id() == vint4(plane2_component);
vmask4 notnan_mask = avg == avg;
vmask4 full_mask = p2_mask & notnan_mask;
ep->endpt0[i] = select(ep->endpt0[i], avg, full_mask);
ep->endpt1[i] = select(ep->endpt1[i], avg, full_mask);
}
else
{
// otherwise, complete the analytic calculation of ideal-endpoint-values
// for the given set of texel weights and pixel colors.
vfloat4 color_det2 = (left2_sum * right2_sum) - (middle2_sum * middle2_sum);
vfloat4 color_rdet2 = 1.0f / color_det2;
vfloat4 color_mss2 = (left2_sum * left2_sum)
+ (2.0f * middle2_sum * middle2_sum)
+ (right2_sum * right2_sum);
vfloat4 ep0 = (right2_sum * color_vec_x - middle2_sum * color_vec_y) * color_rdet2;
vfloat4 ep1 = (left2_sum * color_vec_y - middle2_sum * color_vec_x) * color_rdet2;
vmask4 p2_mask = vint4::lane_id() == vint4(plane2_component);
vmask4 det_mask = abs(color_det2) > (color_mss2 * 1e-4f);
vmask4 notnan_mask = (ep0 == ep0) & (ep1 == ep1);
vmask4 full_mask = p2_mask & det_mask & notnan_mask;
ep->endpt0[i] = select(ep->endpt0[i], ep0, full_mask);
ep->endpt1[i] = select(ep->endpt1[i], ep1, full_mask);
}
// if the calculation of an RGB-offset vector failed, try to compute
// a somewhat-sensible value anyway
if (rgbo_fail)
{
vfloat4 v0 = ep->endpt0[i];
vfloat4 v1 = ep->endpt1[i];
float avgdif = hadd_rgb_s(v1 - v0) * (1.0f / 3.0f);
avgdif = astc::max(avgdif, 0.0f);
vfloat4 avg = (v0 + v1) * 0.5f;
vfloat4 ep0 = avg - vfloat4(avgdif) * 0.5f;
rgbo_vectors[i] = vfloat4(ep0.lane<0>(), ep0.lane<1>(), ep0.lane<2>(), avgdif);
}
}
}
/* for a given weight set, we wish to recompute the colors so that they are optimal for a particular weight set. */
void recompute_ideal_colors_1plane(
int weight_quant_mode,
endpoints* ep, // contains the endpoints we wish to update
vfloat4* rgbs_vectors, // used to return RGBS-vectors for endpoint mode #6
vfloat4* rgbo_vectors, // used to return RGBO-vectors for endpoint mode #7
const uint8_t* weight_set8, // the current set of weight values
const partition_info* pt,
const decimation_table* dt,
const imageblock* blk, // picture-block containing the actual data.
const error_weight_block* ewb
) {
int weight_count = dt->weight_count;
int partition_count = pt->partition_count;
promise(weight_count > 0);
promise(partition_count > 0);
const quantization_and_transfer_table *qat = &(quant_and_xfer_tables[weight_quant_mode]);
float weight_set[MAX_WEIGHTS_PER_BLOCK];
for (int i = 0; i < weight_count; i++)
{
weight_set[i] = qat->unquantized_value[weight_set8[i]] * (1.0f / 64.0f);
}
for (int i = 0; i < partition_count; i++)
{
vfloat4 rgba_sum(1e-17f);
vfloat4 rgba_weight_sum(1e-17f);
int texel_count = pt->partition_texel_count[i];
const uint8_t *texel_indexes = pt->texels_of_partition[i];
promise(texel_count > 0);
for (int j = 0; j < texel_count; j++)
{
int tix = texel_indexes[j];
vfloat4 rgba = blk->texel(tix);
vfloat4 error_weight = ewb->error_weights[tix];
rgba_sum += rgba * error_weight;
rgba_weight_sum += error_weight;
}
vfloat4 scale_direction = normalize((rgba_sum * (1.0f / rgba_weight_sum)).swz<0, 1, 2>());
float scale_max = 0.0f;
float scale_min = 1e10f;
float wmin1 = 1.0f;
float wmax1 = 0.0f;
vfloat4 left_sum = vfloat4::zero();
vfloat4 middle_sum = vfloat4::zero();
vfloat4 right_sum = vfloat4::zero();
vfloat4 lmrs_sum = vfloat4::zero();
vfloat4 color_vec_x = vfloat4::zero();
vfloat4 color_vec_y = vfloat4::zero();
float2 scale_vec = float2(0.0f);
vfloat4 weight_weight_sum = vfloat4(1e-17f);
float psum = 1e-17f;
// FIXME: the loop below has too many responsibilities, making it inefficient.
for (int j = 0; j < texel_count; j++)
{
int tix = texel_indexes[j];
vfloat4 rgba = blk->texel(tix);
vfloat4 color_weight = ewb->error_weights[tix];
// FIXME: move this calculation out to the color block.
float ls_weight = hadd_rgb_s(color_weight);
float idx0 = bilinear_infill(*dt, weight_set, tix);
float om_idx0 = 1.0f - idx0;
wmin1 = astc::min(idx0, wmin1);
wmax1 = astc::max(idx0, wmax1);
float scale = dot3_s(scale_direction, rgba);
scale_min = astc::min(scale, scale_min);
scale_max = astc::max(scale, scale_max);
vfloat4 left = color_weight * (om_idx0 * om_idx0);
vfloat4 middle = color_weight * (om_idx0 * idx0);
vfloat4 right = color_weight * (idx0 * idx0);
vfloat4 lmrs = vfloat4(om_idx0 * om_idx0,
om_idx0 * idx0,
idx0 * idx0,
0.0f) * ls_weight;
left_sum += left;
middle_sum += middle;
right_sum += right;
lmrs_sum += lmrs;
vfloat4 color_idx(idx0);
vfloat4 cwprod = color_weight * rgba;
vfloat4 cwiprod = cwprod * color_idx;
color_vec_y += cwiprod;
color_vec_x += cwprod - cwiprod;
scale_vec += (float2(om_idx0, idx0) * (ls_weight * scale));
weight_weight_sum += color_weight * color_idx;
psum += dot3_s(color_weight * color_idx, color_idx);
}
// calculations specific to mode #7, the HDR RGB-scale mode.
// FIXME: Can we skip this for LDR textures?
vfloat4 rgbq_sum = color_vec_x + color_vec_y;
rgbq_sum.set_lane<3>(hadd_rgb_s(color_vec_y));
vfloat4 rgbovec = compute_rgbovec(rgba_weight_sum, weight_weight_sum,
rgbq_sum, psum);
rgbo_vectors[i] = rgbovec;
// We will occasionally get a failure due to the use of a singular
// (non-invertible) matrix. Record whether such a failure has taken
// place; if it did, compute rgbo_vectors[] with a different method
// later on.
float chkval = dot_s(rgbovec, rgbovec);
int rgbo_fail = chkval != chkval;
// Initialize the luminance and scale vectors with a reasonable
// default, just in case the subsequent calculation blows up.
float scalediv = scale_min * (1.0f / astc::max(scale_max, 1e-10f));
scalediv = astc::clamp1f(scalediv);
vfloat4 sds = scale_direction * scale_max;
rgbs_vectors[i] = vfloat4(sds.lane<0>(), sds.lane<1>(), sds.lane<2>(), scalediv);
if (wmin1 >= wmax1 * 0.999f)
{
// if all weights in the partition were equal, then just take average
// of all colors in the partition and use that as both endpoint colors.
vfloat4 avg = (color_vec_x + color_vec_y) * (1.0f / rgba_weight_sum);
vmask4 notnan_mask = avg == avg;
ep->endpt0[i] = select(ep->endpt0[i], avg, notnan_mask);
ep->endpt1[i] = select(ep->endpt1[i], avg, notnan_mask);
rgbs_vectors[i] = vfloat4(sds.lane<0>(), sds.lane<1>(), sds.lane<2>(), 1.0f);
}
else
{
// otherwise, complete the analytic calculation of ideal-endpoint-values
// for the given set of texel weights and pixel colors.
vfloat4 color_det1 = (left_sum * right_sum) - (middle_sum * middle_sum);
vfloat4 color_rdet1 = 1.0f / color_det1;
float ls_det1 = (lmrs_sum.lane<0>() * lmrs_sum.lane<2>()) - (lmrs_sum.lane<1>() * lmrs_sum.lane<1>());
float ls_rdet1 = 1.0f / ls_det1;
vfloat4 color_mss1 = (left_sum * left_sum)
+ (2.0f * middle_sum * middle_sum)
+ (right_sum * right_sum);
float ls_mss1 = (lmrs_sum.lane<0>() * lmrs_sum.lane<0>())
+ (2.0f * lmrs_sum.lane<1>() * lmrs_sum.lane<1>())
+ (lmrs_sum.lane<2>() * lmrs_sum.lane<2>());
vfloat4 ep0 = (right_sum * color_vec_x - middle_sum * color_vec_y) * color_rdet1;
vfloat4 ep1 = (left_sum * color_vec_y - middle_sum * color_vec_x) * color_rdet1;
vmask4 det_mask = abs(color_det1) > (color_mss1 * 1e-4f);
vmask4 notnan_mask = (ep0 == ep0) & (ep1 == ep1);
vmask4 full_mask = det_mask & notnan_mask;
ep->endpt0[i] = select(ep->endpt0[i], ep0, full_mask);
ep->endpt1[i] = select(ep->endpt1[i], ep1, full_mask);
float scale_ep0 = (lmrs_sum.lane<2>() * scale_vec.r - lmrs_sum.lane<1>() * scale_vec.g) * ls_rdet1;
float scale_ep1 = (lmrs_sum.lane<0>() * scale_vec.g - lmrs_sum.lane<1>() * scale_vec.r) * ls_rdet1;
if (fabsf(ls_det1) > (ls_mss1 * 1e-4f) && scale_ep0 == scale_ep0 && scale_ep1 == scale_ep1 && scale_ep0 < scale_ep1)
{
float scalediv2 = scale_ep0 * (1.0f / scale_ep1);
vfloat4 sdsm = scale_direction * scale_ep1;
rgbs_vectors[i] = vfloat4(sdsm.lane<0>(), sdsm.lane<1>(), sdsm.lane<2>(), scalediv2);
}
}
// if the calculation of an RGB-offset vector failed, try to compute
// a somewhat-sensible value anyway
if (rgbo_fail)
{
vfloat4 v0 = ep->endpt0[i];
vfloat4 v1 = ep->endpt1[i];
float avgdif = hadd_rgb_s(v1 - v0) * (1.0f / 3.0f);
avgdif = astc::max(avgdif, 0.0f);
vfloat4 avg = (v0 + v1) * 0.5f;
vfloat4 ep0 = avg - vfloat4(avgdif) * 0.5f;
rgbo_vectors[i] = vfloat4(ep0.lane<0>(), ep0.lane<1>(), ep0.lane<2>(), avgdif);
}
}
}
#endif
| 31.938547 | 134 | 0.68478 | paintdream |
24162d68791ad302d220367b919a7c2ca053bf91 | 18,445 | cc | C++ | Models/LocaleMessage.pb.cc | wpscott/AcFunDanmaku-C- | c1b834dbb7133fd9d3908a8e0840747b759bdb0f | [
"MIT"
] | null | null | null | Models/LocaleMessage.pb.cc | wpscott/AcFunDanmaku-C- | c1b834dbb7133fd9d3908a8e0840747b759bdb0f | [
"MIT"
] | null | null | null | Models/LocaleMessage.pb.cc | wpscott/AcFunDanmaku-C- | c1b834dbb7133fd9d3908a8e0840747b759bdb0f | [
"MIT"
] | null | null | null | // Generated by the protocol buffer compiler. DO NOT EDIT!
// source: LocaleMessage.proto
#include "LocaleMessage.pb.h"
#include <algorithm>
#include <google/protobuf/io/coded_stream.h>
#include <google/protobuf/extension_set.h>
#include <google/protobuf/wire_format_lite.h>
#include <google/protobuf/descriptor.h>
#include <google/protobuf/generated_message_reflection.h>
#include <google/protobuf/reflection_ops.h>
#include <google/protobuf/wire_format.h>
// @@protoc_insertion_point(includes)
#include <google/protobuf/port_def.inc>
extern PROTOBUF_INTERNAL_EXPORT_LocaleMessage_2eproto ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<0> scc_info_LocaleMessage_ErrorMessageEntry_DoNotUse_LocaleMessage_2eproto;
namespace AcFunDanmu {
class LocaleMessage_ErrorMessageEntry_DoNotUseDefaultTypeInternal {
public:
::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed<LocaleMessage_ErrorMessageEntry_DoNotUse> _instance;
} _LocaleMessage_ErrorMessageEntry_DoNotUse_default_instance_;
class LocaleMessageDefaultTypeInternal {
public:
::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed<LocaleMessage> _instance;
} _LocaleMessage_default_instance_;
} // namespace AcFunDanmu
static void InitDefaultsscc_info_LocaleMessage_LocaleMessage_2eproto() {
GOOGLE_PROTOBUF_VERIFY_VERSION;
{
void* ptr = &::AcFunDanmu::_LocaleMessage_default_instance_;
new (ptr) ::AcFunDanmu::LocaleMessage();
::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr);
}
}
::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<1> scc_info_LocaleMessage_LocaleMessage_2eproto =
{{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 1, 0, InitDefaultsscc_info_LocaleMessage_LocaleMessage_2eproto}, {
&scc_info_LocaleMessage_ErrorMessageEntry_DoNotUse_LocaleMessage_2eproto.base,}};
static void InitDefaultsscc_info_LocaleMessage_ErrorMessageEntry_DoNotUse_LocaleMessage_2eproto() {
GOOGLE_PROTOBUF_VERIFY_VERSION;
{
void* ptr = &::AcFunDanmu::_LocaleMessage_ErrorMessageEntry_DoNotUse_default_instance_;
new (ptr) ::AcFunDanmu::LocaleMessage_ErrorMessageEntry_DoNotUse();
}
}
::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<0> scc_info_LocaleMessage_ErrorMessageEntry_DoNotUse_LocaleMessage_2eproto =
{{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 0, 0, InitDefaultsscc_info_LocaleMessage_ErrorMessageEntry_DoNotUse_LocaleMessage_2eproto}, {}};
static ::PROTOBUF_NAMESPACE_ID::Metadata file_level_metadata_LocaleMessage_2eproto[2];
static constexpr ::PROTOBUF_NAMESPACE_ID::EnumDescriptor const** file_level_enum_descriptors_LocaleMessage_2eproto = nullptr;
static constexpr ::PROTOBUF_NAMESPACE_ID::ServiceDescriptor const** file_level_service_descriptors_LocaleMessage_2eproto = nullptr;
const ::PROTOBUF_NAMESPACE_ID::uint32 TableStruct_LocaleMessage_2eproto::offsets[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = {
PROTOBUF_FIELD_OFFSET(::AcFunDanmu::LocaleMessage_ErrorMessageEntry_DoNotUse, _has_bits_),
PROTOBUF_FIELD_OFFSET(::AcFunDanmu::LocaleMessage_ErrorMessageEntry_DoNotUse, _internal_metadata_),
~0u, // no _extensions_
~0u, // no _oneof_case_
~0u, // no _weak_field_map_
PROTOBUF_FIELD_OFFSET(::AcFunDanmu::LocaleMessage_ErrorMessageEntry_DoNotUse, key_),
PROTOBUF_FIELD_OFFSET(::AcFunDanmu::LocaleMessage_ErrorMessageEntry_DoNotUse, value_),
0,
1,
~0u, // no _has_bits_
PROTOBUF_FIELD_OFFSET(::AcFunDanmu::LocaleMessage, _internal_metadata_),
~0u, // no _extensions_
~0u, // no _oneof_case_
~0u, // no _weak_field_map_
PROTOBUF_FIELD_OFFSET(::AcFunDanmu::LocaleMessage, locale_),
PROTOBUF_FIELD_OFFSET(::AcFunDanmu::LocaleMessage, errormessage_),
};
static const ::PROTOBUF_NAMESPACE_ID::internal::MigrationSchema schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = {
{ 0, 7, sizeof(::AcFunDanmu::LocaleMessage_ErrorMessageEntry_DoNotUse)},
{ 9, -1, sizeof(::AcFunDanmu::LocaleMessage)},
};
static ::PROTOBUF_NAMESPACE_ID::Message const * const file_default_instances[] = {
reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&::AcFunDanmu::_LocaleMessage_ErrorMessageEntry_DoNotUse_default_instance_),
reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&::AcFunDanmu::_LocaleMessage_default_instance_),
};
const char descriptor_table_protodef_LocaleMessage_2eproto[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) =
"\n\023LocaleMessage.proto\022\nAcFunDanmu\"\227\001\n\rLo"
"caleMessage\022\016\n\006locale\030\001 \001(\t\022A\n\014errorMess"
"age\030\002 \003(\0132+.AcFunDanmu.LocaleMessage.Err"
"orMessageEntry\0323\n\021ErrorMessageEntry\022\013\n\003k"
"ey\030\001 \001(\005\022\r\n\005value\030\002 \001(\t:\0028\001b\006proto3"
;
static const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable*const descriptor_table_LocaleMessage_2eproto_deps[1] = {
};
static ::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase*const descriptor_table_LocaleMessage_2eproto_sccs[2] = {
&scc_info_LocaleMessage_LocaleMessage_2eproto.base,
&scc_info_LocaleMessage_ErrorMessageEntry_DoNotUse_LocaleMessage_2eproto.base,
};
static ::PROTOBUF_NAMESPACE_ID::internal::once_flag descriptor_table_LocaleMessage_2eproto_once;
const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_LocaleMessage_2eproto = {
false, false, descriptor_table_protodef_LocaleMessage_2eproto, "LocaleMessage.proto", 195,
&descriptor_table_LocaleMessage_2eproto_once, descriptor_table_LocaleMessage_2eproto_sccs, descriptor_table_LocaleMessage_2eproto_deps, 2, 0,
schemas, file_default_instances, TableStruct_LocaleMessage_2eproto::offsets,
file_level_metadata_LocaleMessage_2eproto, 2, file_level_enum_descriptors_LocaleMessage_2eproto, file_level_service_descriptors_LocaleMessage_2eproto,
};
// Force running AddDescriptors() at dynamic initialization time.
static bool dynamic_init_dummy_LocaleMessage_2eproto = (static_cast<void>(::PROTOBUF_NAMESPACE_ID::internal::AddDescriptors(&descriptor_table_LocaleMessage_2eproto)), true);
namespace AcFunDanmu {
// ===================================================================
LocaleMessage_ErrorMessageEntry_DoNotUse::LocaleMessage_ErrorMessageEntry_DoNotUse() {}
LocaleMessage_ErrorMessageEntry_DoNotUse::LocaleMessage_ErrorMessageEntry_DoNotUse(::PROTOBUF_NAMESPACE_ID::Arena* arena)
: SuperType(arena) {}
void LocaleMessage_ErrorMessageEntry_DoNotUse::MergeFrom(const LocaleMessage_ErrorMessageEntry_DoNotUse& other) {
MergeFromInternal(other);
}
::PROTOBUF_NAMESPACE_ID::Metadata LocaleMessage_ErrorMessageEntry_DoNotUse::GetMetadata() const {
return GetMetadataStatic();
}
void LocaleMessage_ErrorMessageEntry_DoNotUse::MergeFrom(
const ::PROTOBUF_NAMESPACE_ID::Message& other) {
::PROTOBUF_NAMESPACE_ID::Message::MergeFrom(other);
}
// ===================================================================
class LocaleMessage::_Internal {
public:
};
LocaleMessage::LocaleMessage(::PROTOBUF_NAMESPACE_ID::Arena* arena)
: ::PROTOBUF_NAMESPACE_ID::Message(arena),
errormessage_(arena) {
SharedCtor();
RegisterArenaDtor(arena);
// @@protoc_insertion_point(arena_constructor:AcFunDanmu.LocaleMessage)
}
LocaleMessage::LocaleMessage(const LocaleMessage& from)
: ::PROTOBUF_NAMESPACE_ID::Message() {
_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
errormessage_.MergeFrom(from.errormessage_);
locale_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
if (!from._internal_locale().empty()) {
locale_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_locale(),
GetArena());
}
// @@protoc_insertion_point(copy_constructor:AcFunDanmu.LocaleMessage)
}
void LocaleMessage::SharedCtor() {
::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&scc_info_LocaleMessage_LocaleMessage_2eproto.base);
locale_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
}
LocaleMessage::~LocaleMessage() {
// @@protoc_insertion_point(destructor:AcFunDanmu.LocaleMessage)
SharedDtor();
_internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}
void LocaleMessage::SharedDtor() {
GOOGLE_DCHECK(GetArena() == nullptr);
locale_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
}
void LocaleMessage::ArenaDtor(void* object) {
LocaleMessage* _this = reinterpret_cast< LocaleMessage* >(object);
(void)_this;
}
void LocaleMessage::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) {
}
void LocaleMessage::SetCachedSize(int size) const {
_cached_size_.Set(size);
}
const LocaleMessage& LocaleMessage::default_instance() {
::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&::scc_info_LocaleMessage_LocaleMessage_2eproto.base);
return *internal_default_instance();
}
void LocaleMessage::Clear() {
// @@protoc_insertion_point(message_clear_start:AcFunDanmu.LocaleMessage)
::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
errormessage_.Clear();
locale_.ClearToEmpty();
_internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}
const char* LocaleMessage::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) {
#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
while (!ctx->Done(&ptr)) {
::PROTOBUF_NAMESPACE_ID::uint32 tag;
ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag);
CHK_(ptr);
switch (tag >> 3) {
// string locale = 1;
case 1:
if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 10)) {
auto str = _internal_mutable_locale();
ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx);
CHK_(::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, "AcFunDanmu.LocaleMessage.locale"));
CHK_(ptr);
} else goto handle_unusual;
continue;
// map<int32, string> errorMessage = 2;
case 2:
if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 18)) {
ptr -= 1;
do {
ptr += 1;
ptr = ctx->ParseMessage(&errormessage_, ptr);
CHK_(ptr);
if (!ctx->DataAvailable(ptr)) break;
} while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<18>(ptr));
} else goto handle_unusual;
continue;
default: {
handle_unusual:
if ((tag & 7) == 4 || tag == 0) {
ctx->SetLastTag(tag);
goto success;
}
ptr = UnknownFieldParse(tag,
_internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(),
ptr, ctx);
CHK_(ptr != nullptr);
continue;
}
} // switch
} // while
success:
return ptr;
failure:
ptr = nullptr;
goto success;
#undef CHK_
}
::PROTOBUF_NAMESPACE_ID::uint8* LocaleMessage::_InternalSerialize(
::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
// @@protoc_insertion_point(serialize_to_array_start:AcFunDanmu.LocaleMessage)
::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
(void) cached_has_bits;
// string locale = 1;
if (this->locale().size() > 0) {
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String(
this->_internal_locale().data(), static_cast<int>(this->_internal_locale().length()),
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE,
"AcFunDanmu.LocaleMessage.locale");
target = stream->WriteStringMaybeAliased(
1, this->_internal_locale(), target);
}
// map<int32, string> errorMessage = 2;
if (!this->_internal_errormessage().empty()) {
typedef ::PROTOBUF_NAMESPACE_ID::Map< ::PROTOBUF_NAMESPACE_ID::int32, std::string >::const_pointer
ConstPtr;
typedef ::PROTOBUF_NAMESPACE_ID::internal::SortItem< ::PROTOBUF_NAMESPACE_ID::int32, ConstPtr > SortItem;
typedef ::PROTOBUF_NAMESPACE_ID::internal::CompareByFirstField<SortItem> Less;
struct Utf8Check {
static void Check(ConstPtr p) {
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String(
p->second.data(), static_cast<int>(p->second.length()),
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE,
"AcFunDanmu.LocaleMessage.ErrorMessageEntry.value");
}
};
if (stream->IsSerializationDeterministic() &&
this->_internal_errormessage().size() > 1) {
::std::unique_ptr<SortItem[]> items(
new SortItem[this->_internal_errormessage().size()]);
typedef ::PROTOBUF_NAMESPACE_ID::Map< ::PROTOBUF_NAMESPACE_ID::int32, std::string >::size_type size_type;
size_type n = 0;
for (::PROTOBUF_NAMESPACE_ID::Map< ::PROTOBUF_NAMESPACE_ID::int32, std::string >::const_iterator
it = this->_internal_errormessage().begin();
it != this->_internal_errormessage().end(); ++it, ++n) {
items[static_cast<ptrdiff_t>(n)] = SortItem(&*it);
}
::std::sort(&items[0], &items[static_cast<ptrdiff_t>(n)], Less());
for (size_type i = 0; i < n; i++) {
target = LocaleMessage_ErrorMessageEntry_DoNotUse::Funcs::InternalSerialize(2, items[static_cast<ptrdiff_t>(i)].second->first, items[static_cast<ptrdiff_t>(i)].second->second, target, stream);
Utf8Check::Check(&(*items[static_cast<ptrdiff_t>(i)].second));
}
} else {
for (::PROTOBUF_NAMESPACE_ID::Map< ::PROTOBUF_NAMESPACE_ID::int32, std::string >::const_iterator
it = this->_internal_errormessage().begin();
it != this->_internal_errormessage().end(); ++it) {
target = LocaleMessage_ErrorMessageEntry_DoNotUse::Funcs::InternalSerialize(2, it->first, it->second, target, stream);
Utf8Check::Check(&(*it));
}
}
}
if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray(
_internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream);
}
// @@protoc_insertion_point(serialize_to_array_end:AcFunDanmu.LocaleMessage)
return target;
}
size_t LocaleMessage::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:AcFunDanmu.LocaleMessage)
size_t total_size = 0;
::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
// map<int32, string> errorMessage = 2;
total_size += 1 *
::PROTOBUF_NAMESPACE_ID::internal::FromIntSize(this->_internal_errormessage_size());
for (::PROTOBUF_NAMESPACE_ID::Map< ::PROTOBUF_NAMESPACE_ID::int32, std::string >::const_iterator
it = this->_internal_errormessage().begin();
it != this->_internal_errormessage().end(); ++it) {
total_size += LocaleMessage_ErrorMessageEntry_DoNotUse::Funcs::ByteSizeLong(it->first, it->second);
}
// string locale = 1;
if (this->locale().size() > 0) {
total_size += 1 +
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
this->_internal_locale());
}
if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
return ::PROTOBUF_NAMESPACE_ID::internal::ComputeUnknownFieldsSize(
_internal_metadata_, total_size, &_cached_size_);
}
int cached_size = ::PROTOBUF_NAMESPACE_ID::internal::ToCachedSize(total_size);
SetCachedSize(cached_size);
return total_size;
}
void LocaleMessage::MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) {
// @@protoc_insertion_point(generalized_merge_from_start:AcFunDanmu.LocaleMessage)
GOOGLE_DCHECK_NE(&from, this);
const LocaleMessage* source =
::PROTOBUF_NAMESPACE_ID::DynamicCastToGenerated<LocaleMessage>(
&from);
if (source == nullptr) {
// @@protoc_insertion_point(generalized_merge_from_cast_fail:AcFunDanmu.LocaleMessage)
::PROTOBUF_NAMESPACE_ID::internal::ReflectionOps::Merge(from, this);
} else {
// @@protoc_insertion_point(generalized_merge_from_cast_success:AcFunDanmu.LocaleMessage)
MergeFrom(*source);
}
}
void LocaleMessage::MergeFrom(const LocaleMessage& from) {
// @@protoc_insertion_point(class_specific_merge_from_start:AcFunDanmu.LocaleMessage)
GOOGLE_DCHECK_NE(&from, this);
_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
(void) cached_has_bits;
errormessage_.MergeFrom(from.errormessage_);
if (from.locale().size() > 0) {
_internal_set_locale(from._internal_locale());
}
}
void LocaleMessage::CopyFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) {
// @@protoc_insertion_point(generalized_copy_from_start:AcFunDanmu.LocaleMessage)
if (&from == this) return;
Clear();
MergeFrom(from);
}
void LocaleMessage::CopyFrom(const LocaleMessage& from) {
// @@protoc_insertion_point(class_specific_copy_from_start:AcFunDanmu.LocaleMessage)
if (&from == this) return;
Clear();
MergeFrom(from);
}
bool LocaleMessage::IsInitialized() const {
return true;
}
void LocaleMessage::InternalSwap(LocaleMessage* other) {
using std::swap;
_internal_metadata_.Swap<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(&other->_internal_metadata_);
errormessage_.Swap(&other->errormessage_);
locale_.Swap(&other->locale_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena());
}
::PROTOBUF_NAMESPACE_ID::Metadata LocaleMessage::GetMetadata() const {
return GetMetadataStatic();
}
// @@protoc_insertion_point(namespace_scope)
} // namespace AcFunDanmu
PROTOBUF_NAMESPACE_OPEN
template<> PROTOBUF_NOINLINE ::AcFunDanmu::LocaleMessage_ErrorMessageEntry_DoNotUse* Arena::CreateMaybeMessage< ::AcFunDanmu::LocaleMessage_ErrorMessageEntry_DoNotUse >(Arena* arena) {
return Arena::CreateMessageInternal< ::AcFunDanmu::LocaleMessage_ErrorMessageEntry_DoNotUse >(arena);
}
template<> PROTOBUF_NOINLINE ::AcFunDanmu::LocaleMessage* Arena::CreateMaybeMessage< ::AcFunDanmu::LocaleMessage >(Arena* arena) {
return Arena::CreateMessageInternal< ::AcFunDanmu::LocaleMessage >(arena);
}
PROTOBUF_NAMESPACE_CLOSE
// @@protoc_insertion_point(global_scope)
#include <google/protobuf/port_undef.inc>
| 44.55314 | 200 | 0.758254 | wpscott |
241639cc3f2214a8c5df38f579bfe756df9d631f | 2,166 | cpp | C++ | at2021b/past202104v/13.cpp | akouryy/competitive-programming-2021 | b5c65f5d6337d67e2e68c7c9c4d5832f661d571c | [
"MIT"
] | null | null | null | at2021b/past202104v/13.cpp | akouryy/competitive-programming-2021 | b5c65f5d6337d67e2e68c7c9c4d5832f661d571c | [
"MIT"
] | null | null | null | at2021b/past202104v/13.cpp | akouryy/competitive-programming-2021 | b5c65f5d6337d67e2e68c7c9c4d5832f661d571c | [
"MIT"
] | null | null | null | #include "base.hpp"
//#include "consts.hpp"
/* include禁止(コピペする) */
/*! http://codeforces.com/blog/entry/1256 http://codeforces.com/blog/entry/18051 */
constexpr int N = 262144; /*- たぶん2^xじゃなくても大丈夫 */
int same[N*2]; /*- 1, 2 3, 4 5 6 7, 8 9 10 11 12 13 14 15 */
int val[N*2]; /*- 1, 2 3, 4 5 6 7, 8 9 10 11 12 13 14 15 */
struct SegTree {
map<int, int> count;
int nPair;
SegTree(const VI& A) {
nPair = 0;
times(N, i) {
if(i < size(A)) {
val[i + N] = A[i];
nPair += count[A[i]]++;
} else {
val[i + N] = -1;
}
same[i] = false;
same[i + N] = true;
}
}
/** [l, r) 0-based **/
void update(int a, int b, int v) {
update(a, b, v, 1, 0, N);
}
void update(int a, int b, int v, int k, int l, int r) {
if(r <= a || b <= l) return;
dd a; b; v; k; l; r; a <= l && r <= b; same[k]; val[k];
if(a <= l && r <= b) {
if(same[k]) {
int xx = r - l;
dd count[val[k]]; count[v]; nPair; xx;
nPair -= count[val[k]] * (count[val[k]] - 1) / 2;
count[val[k]] -= xx;
nPair += count[val[k]] * (count[val[k]] - 1) / 2;
nPair -= count[v] * (count[v] - 1) / 2;
count[v] += xx;
nPair += count[v] * (count[v] - 1) / 2;
dd count[val[k]]; count[v]; nPair;
} else {
update(a, b, v, k * 2, l, (l + r) / 2);
update(a, b, v, k * 2 + 1, (l + r) / 2, r);
}
same[k] = true;
val[k] = v;
} else {
if(same[k]) {
same[k * 2] = same[k * 2 + 1] = true;
val[k * 2] = val[k * 2 + 1] = val[k];
}
update(a, b, v, k * 2, l, (l + r) / 2);
update(a, b, v, k * 2 + 1, (l + r) / 2, r);
if(same[k * 2] && same[k * 2 + 1] && val[k * 2] == val[k * 2 + 1]) {
same[k] = true;
val[k] = val[k * 2];
} else {
same[k] = false;
}
}
}
};
void solve() {
/* wt.ten
N NA Q Q(L- R X)
*/
int N,Q;cin>>N;VI A(N);times(N,i0){cin>>A[i0];}cin>>Q;VI L(Q),R(Q),X(Q);times(Q,i0){cin>>L[i0]>>R[i0]>>X[i0];
--L[i0];}
SegTree st(A);
times(Q, i) {
dd i;
st.update(L[i], R[i], X[i]);
cout << st.nPair ln;
}
}
| 25.482353 | 111 | 0.420591 | akouryy |
241887b579b10b9adafd612d00d96e1f9d7fb52e | 24,810 | cpp | C++ | Experiment_Test/ThirdGL/ThirdGL/Src/Chapter15/Block/Block.cpp | HelloWorld115/My_Test | c32524c7b8b970627200a767b86d1e4080b94a14 | [
"Apache-2.0"
] | null | null | null | Experiment_Test/ThirdGL/ThirdGL/Src/Chapter15/Block/Block.cpp | HelloWorld115/My_Test | c32524c7b8b970627200a767b86d1e4080b94a14 | [
"Apache-2.0"
] | null | null | null | Experiment_Test/ThirdGL/ThirdGL/Src/Chapter15/Block/Block.cpp | HelloWorld115/My_Test | c32524c7b8b970627200a767b86d1e4080b94a14 | [
"Apache-2.0"
] | null | null | null | // Block.cpp
// OpenGL SuperBible, Chapter 1
// Demonstrates an assortment of basic 3D concepts
// Program by Richard S. Wright Jr.
#include <glew.h>
#include <glxew.h>
#include <GLTools.h> // OpenGL toolkit
#include <GLMatrixStack.h>
#include <GLFrame.h>
#include <GLFrustum.h>
#include <GLBatch.h>
#include <GLGeometryTransform.h>
#include <math.h>
#ifdef linux
#include <cstdlib>
#endif
/////////////////////////////////////////////////////////////////////////////////
// An assortment of needed classes
GLShaderManager shaderManager;
GLMatrixStack modelViewMatrix;
GLMatrixStack projectionMatrix;
GLFrame cameraFrame;
GLFrustum viewFrustum;
GLBatch cubeBatch;
GLBatch floorBatch;
GLBatch topBlock;
GLBatch frontBlock;
GLBatch leftBlock;
GLGeometryTransform transformPipeline;
M3DMatrix44f shadowMatrix;
// Keep track of effects step
int nStep = 0;
// Lighting data
GLfloat lightAmbient[] = { 0.2f, 0.2f, 0.2f, 1.0f };
GLfloat lightDiffuse[] = { 0.7f, 0.7f, 0.7f, 1.0f };
GLfloat lightSpecular[] = { 0.9f, 0.9f, 0.9f };
GLfloat vLightPos[] = { -8.0f, 20.0f, 100.0f, 1.0f };
GLuint textures[4];
void EarlyInitGLXfnPointers()
{
glGenVertexArraysAPPLE = (void(*)(GLsizei, const GLuint*))glXGetProcAddressARB((GLubyte*)"glGenVertexArrays");
glBindVertexArrayAPPLE = (void(*)(const GLuint))glXGetProcAddressARB((GLubyte*)"glBindVertexArray");
glDeleteVertexArraysAPPLE = (void(*)(GLsizei, const GLuint*))glXGetProcAddressARB((GLubyte*)"glGenVertexArrays");
glXCreateContextAttribsARB = (GLXContext(*)(Display* dpy, GLXFBConfig config, GLXContext share_context, Bool direct, const int *attrib_list))glXGetProcAddressARB((GLubyte*)"glXCreateContextAttribsARB");
glXChooseFBConfig = (GLXFBConfig*(*)(Display *dpy, int screen, const int *attrib_list, int *nelements))glXGetProcAddressARB((GLubyte*)"glXChooseFBConfig");
glXGetVisualFromFBConfig = (XVisualInfo*(*)(Display *dpy, GLXFBConfig config))glXGetProcAddressARB((GLubyte*)"glXGetVisualFromFBConfig");
}
///////////////////////////////////////////////////////////////////////////////
// Make a cube out of a batch of triangles. Texture coordinates and normals
// are also provided.
void MakeCube(GLBatch& cubeBatch)
{
cubeBatch.Begin(GL_TRIANGLES, 36, 1);
/////////////////////////////////////////////
// Top of cube
cubeBatch.Normal3f(0.0f, 1.0f, 0.0f);
cubeBatch.MultiTexCoord2f(0, 1.0f, 1.0f);
cubeBatch.Vertex3f(1.0f, 1.0f, 1.0f);
cubeBatch.Normal3f(0.0f, 1.0f, 0.0f);
cubeBatch.MultiTexCoord2f(0, 1.0f, 0.0f);
cubeBatch.Vertex3f(1.0f, 1.0f, -1.0f);
cubeBatch.Normal3f(0.0f, 1.0f, 0.0f);
cubeBatch.MultiTexCoord2f(0, 0.0f, 0.0f);
cubeBatch.Vertex3f(-1.0f, 1.0f, -1.0f);
cubeBatch.Normal3f(0.0f, 1.0f, 0.0f);
cubeBatch.MultiTexCoord2f(0, 1.0f, 1.0f);
cubeBatch.Vertex3f(1.0f, 1.0f, 1.0f);
cubeBatch.Normal3f(0.0f, 1.0f, 0.0f);
cubeBatch.MultiTexCoord2f(0, 0.0f, 0.0f);
cubeBatch.Vertex3f(-1.0f, 1.0f, -1.0f);
cubeBatch.Normal3f(0.0f, 1.0f, 0.0f);
cubeBatch.MultiTexCoord2f(0, 0.0f, 1.0f);
cubeBatch.Vertex3f(-1.0f, 1.0f, 1.0f);
////////////////////////////////////////////
// Bottom of cube
cubeBatch.Normal3f(0.0f, -1.0f, 0.0f);
cubeBatch.MultiTexCoord2f(0, 0.0f, 0.0f);
cubeBatch.Vertex3f(-1.0f, -1.0f, -1.0f);
cubeBatch.Normal3f(0.0f, -1.0f, 0.0f);
cubeBatch.MultiTexCoord2f(0, 1.0f, 0.0f);
cubeBatch.Vertex3f(1.0f, -1.0f, -1.0f);
cubeBatch.Normal3f(0.0f, -1.0f, 0.0f);
cubeBatch.MultiTexCoord2f(0, 1.0f, 1.0f);
cubeBatch.Vertex3f(1.0f, -1.0f, 1.0f);
cubeBatch.Normal3f(0.0f, -1.0f, 0.0f);
cubeBatch.MultiTexCoord2f(0, 0.0f, 1.0f);
cubeBatch.Vertex3f(-1.0f, -1.0f, 1.0f);
cubeBatch.Normal3f(0.0f, -1.0f, 0.0f);
cubeBatch.MultiTexCoord2f(0, 0.0f, 0.0f);
cubeBatch.Vertex3f(-1.0f, -1.0f, -1.0f);
cubeBatch.Normal3f(0.0f, -1.0f, 0.0f);
cubeBatch.MultiTexCoord2f(0, 1.0f, 1.0f);
cubeBatch.Vertex3f(1.0f, -1.0f, 1.0f);
///////////////////////////////////////////
// Left side of cube
cubeBatch.Normal3f(-1.0f, 0.0f, 0.0f);
cubeBatch.MultiTexCoord2f(0, 1.0f, 1.0f);
cubeBatch.Vertex3f(-1.0f, 1.0f, 1.0f);
cubeBatch.Normal3f(-1.0f, 0.0f, 0.0f);
cubeBatch.MultiTexCoord2f(0, 1.0f, 0.0f);
cubeBatch.Vertex3f(-1.0f, 1.0f, -1.0f);
cubeBatch.Normal3f(-1.0f, 0.0f, 0.0f);
cubeBatch.MultiTexCoord2f(0, 0.0f, 0.0f);
cubeBatch.Vertex3f(-1.0f, -1.0f, -1.0f);
cubeBatch.Normal3f(-1.0f, 0.0f, 0.0f);
cubeBatch.MultiTexCoord2f(0, 1.0f, 1.0f);
cubeBatch.Vertex3f(-1.0f, 1.0f, 1.0f);
cubeBatch.Normal3f(-1.0f, 0.0f, 0.0f);
cubeBatch.MultiTexCoord2f(0, 0.0f, 0.0f);
cubeBatch.Vertex3f(-1.0f, -1.0f, -1.0f);
cubeBatch.Normal3f(-1.0f, 0.0f, 0.0f);
cubeBatch.MultiTexCoord2f(0, 0.0f, 1.0f);
cubeBatch.Vertex3f(-1.0f, -1.0f, 1.0f);
// Right side of cube
cubeBatch.Normal3f(1.0f, 0.0f, 0.0f);
cubeBatch.MultiTexCoord2f(0, 0.0f, 0.0f);
cubeBatch.Vertex3f(1.0f, -1.0f, -1.0f);
cubeBatch.Normal3f(1.0f, 0.0f, 0.0f);
cubeBatch.MultiTexCoord2f(0, 1.0f, 0.0f);
cubeBatch.Vertex3f(1.0f, 1.0f, -1.0f);
cubeBatch.Normal3f(1.0f, 0.0f, 0.0f);
cubeBatch.MultiTexCoord2f(0, 1.0f, 1.0f);
cubeBatch.Vertex3f(1.0f, 1.0f, 1.0f);
cubeBatch.Normal3f(1.0f, 0.0f, 0.0f);
cubeBatch.MultiTexCoord2f(0, 1.0f, 1.0f);
cubeBatch.Vertex3f(1.0f, 1.0f, 1.0f);
cubeBatch.Normal3f(1.0f, 0.0f, 0.0f);
cubeBatch.MultiTexCoord2f(0, 0.0f, 1.0f);
cubeBatch.Vertex3f(1.0f, -1.0f, 1.0f);
cubeBatch.Normal3f(1.0f, 0.0f, 0.0f);
cubeBatch.MultiTexCoord2f(0, 0.0f, 0.0f);
cubeBatch.Vertex3f(1.0f, -1.0f, -1.0f);
// Front and Back
// Front
cubeBatch.Normal3f(0.0f, 0.0f, 1.0f);
cubeBatch.MultiTexCoord2f(0, 1.0f, 0.0f);
cubeBatch.Vertex3f(1.0f, -1.0f, 1.0f);
cubeBatch.Normal3f(0.0f, 0.0f, 1.0f);
cubeBatch.MultiTexCoord2f(0, 1.0f, 1.0f);
cubeBatch.Vertex3f(1.0f, 1.0f, 1.0f);
cubeBatch.Normal3f(0.0f, 0.0f, 1.0f);
cubeBatch.MultiTexCoord2f(0, 0.0f, 1.0f);
cubeBatch.Vertex3f(-1.0f, 1.0f, 1.0f);
cubeBatch.Normal3f(0.0f, 0.0f, 1.0f);
cubeBatch.MultiTexCoord2f(0, 0.0f, 1.0f);
cubeBatch.Vertex3f(-1.0f, 1.0f, 1.0f);
cubeBatch.Normal3f(0.0f, 0.0f, 1.0f);
cubeBatch.MultiTexCoord2f(0, 0.0f, 0.0f);
cubeBatch.Vertex3f(-1.0f, -1.0f, 1.0f);
cubeBatch.Normal3f(0.0f, 0.0f, 1.0f);
cubeBatch.MultiTexCoord2f(0, 1.0f, 0.0f);
cubeBatch.Vertex3f(1.0f, -1.0f, 1.0f);
// Back
cubeBatch.Normal3f(0.0f, 0.0f, -1.0f);
cubeBatch.MultiTexCoord2f(0, 1.0f, 0.0f);
cubeBatch.Vertex3f(1.0f, -1.0f, -1.0f);
cubeBatch.Normal3f(0.0f, 0.0f, -1.0f);
cubeBatch.MultiTexCoord2f(0, 0.0f, 0.0f);
cubeBatch.Vertex3f(-1.0f, -1.0f, -1.0f);
cubeBatch.Normal3f(0.0f, 0.0f, -1.0f);
cubeBatch.MultiTexCoord2f(0, 0.0f, 1.0f);
cubeBatch.Vertex3f(-1.0f, 1.0f, -1.0f);
cubeBatch.Normal3f(0.0f, 0.0f, -1.0f);
cubeBatch.MultiTexCoord2f(0, 0.0f, 1.0f);
cubeBatch.Vertex3f(-1.0f, 1.0f, -1.0f);
cubeBatch.Normal3f(0.0f, 0.0f, -1.0f);
cubeBatch.MultiTexCoord2f(0, 1.0f, 1.0f);
cubeBatch.Vertex3f(1.0f, 1.0f, -1.0f);
cubeBatch.Normal3f(0.0f, 0.0f, -1.0f);
cubeBatch.MultiTexCoord2f(0, 1.0f, 0.0f);
cubeBatch.Vertex3f(1.0f, -1.0f, -1.0f);
cubeBatch.End();
}
/////////////////////////////////////////////////////////////////////////////
// Make the floor, just the verts and texture coordinates, no normals
void MakeFloor(GLBatch& floorBatch)
{
GLfloat x = 5.0f;
GLfloat y = -1.0f;
floorBatch.Begin(GL_TRIANGLE_FAN, 4, 1);
floorBatch.MultiTexCoord2f(0, 0.0f, 0.0f);
floorBatch.Vertex3f(-x, y, x);
floorBatch.MultiTexCoord2f(0, 1.0f, 0.0f);
floorBatch.Vertex3f(x, y, x);
floorBatch.MultiTexCoord2f(0, 1.0f, 1.0f);
floorBatch.Vertex3f(x, y, -x);
floorBatch.MultiTexCoord2f(0, 0.0f, 1.0f);
floorBatch.Vertex3f(-x, y, -x);
floorBatch.End();
}
typedef struct RenderContextRec
{
GLXContext ctx;
Display *dpy;
Window win;
int nWinWidth;
int nWinHeight;
} RenderContext;
void CreateWindow(RenderContext *rcx)
{
XSetWindowAttributes winAttribs;
GLint winmask;
GLint nMajorVer = 0;
GLint nMinorVer = 0;
XVisualInfo *visualInfo;
GLXFBConfig *fbConfigs;
int numConfigs = 0;
static int fbAttribs[] = {
GLX_RENDER_TYPE, GLX_RGBA_BIT,
GLX_X_RENDERABLE, True,
GLX_DRAWABLE_TYPE, GLX_WINDOW_BIT,
GLX_DOUBLEBUFFER, True,
GLX_RED_SIZE, 8,
GLX_BLUE_SIZE, 8,
GLX_GREEN_SIZE, 8,
0 };
// Tell X we are going to use the display
rcx->dpy = XOpenDisplay(NULL);
// Get Version info
glXQueryVersion(rcx->dpy, &nMajorVer, &nMinorVer);
printf("Supported GLX version - %d.%d\n", nMajorVer, nMinorVer);
if(nMajorVer == 1 && nMinorVer < 2)
{
printf("ERROR: GLX 1.2 or greater is necessary\n");
XCloseDisplay(rcx->dpy);
exit(0);
}
// Get a new fb config that meets our attrib requirements
fbConfigs = glXChooseFBConfig(rcx->dpy, DefaultScreen(rcx->dpy), fbAttribs, &numConfigs);
visualInfo = glXGetVisualFromFBConfig(rcx->dpy, fbConfigs[0]);
// Now create an X window
winAttribs.event_mask = ExposureMask | VisibilityChangeMask |
KeyPressMask | PointerMotionMask |
StructureNotifyMask ;
winAttribs.border_pixel = 0;
winAttribs.bit_gravity = StaticGravity;
winAttribs.colormap = XCreateColormap(rcx->dpy,
RootWindow(rcx->dpy, visualInfo->screen),
visualInfo->visual, AllocNone);
winmask = CWBorderPixel | CWBitGravity | CWEventMask| CWColormap;
rcx->win = XCreateWindow(rcx->dpy, DefaultRootWindow(rcx->dpy), 20, 20,
rcx->nWinWidth, rcx->nWinHeight, 0,
visualInfo->depth, InputOutput,
visualInfo->visual, winmask, &winAttribs);
XMapWindow(rcx->dpy, rcx->win);
// Also create a new GL context for rendering
GLint attribs[] = {
GLX_CONTEXT_MAJOR_VERSION_ARB, 3,
GLX_CONTEXT_MINOR_VERSION_ARB, 2,
0 };
rcx->ctx = glXCreateContextAttribsARB(rcx->dpy, fbConfigs[0], 0, True, attribs);
glXMakeCurrent(rcx->dpy, rcx->win, rcx->ctx);
GLenum err = glewInit();
if (GLEW_OK != err)
{
/* Problem: glewInit failed, something is seriously wrong. */
fprintf(stderr, "Error: %s\n", glewGetErrorString(err));
}
}
///////////////////////////////////////////////////////////////////////////////
// This function does any needed initialization on the rendering context.
// This is the first opportunity to do any OpenGL related tasks.
void SetupRC(RenderContext *rcx)
{
GLbyte *pBytes;
GLint nWidth, nHeight, nComponents;
GLenum format;
shaderManager.InitializeStockShaders();
// Black background
glClearColor(0.0f, 0.0f, 0.0f, 1.0f );
glEnable(GL_DEPTH_TEST);
glLineWidth(2.5f);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);
transformPipeline.SetMatrixStacks(modelViewMatrix, projectionMatrix);
cameraFrame.MoveForward(-15.0f);
cameraFrame.MoveUp(6.0f);
cameraFrame.RotateLocalX(float(m3dDegToRad(20.0f)));
MakeCube(cubeBatch);
MakeFloor(floorBatch);
// Make top
topBlock.Begin(GL_TRIANGLE_FAN, 4, 1);
topBlock.Normal3f(0.0f, 1.0f, 0.0f);
topBlock.MultiTexCoord2f(0, 0.0f, 0.0f);
topBlock.Vertex3f(-1.0f, 1.0f, 1.0f);
topBlock.Normal3f(0.0f, 1.0f, 0.0f);
topBlock.MultiTexCoord2f(0, 1.0f, 0.0f);
topBlock.Vertex3f(1.0f, 1.0f, 1.0f);
topBlock.Normal3f(0.0f, 1.0f, 0.0f);
topBlock.MultiTexCoord2f(0, 1.0f, 1.0f);
topBlock.Vertex3f(1.0f, 1.0f, -1.0f);
topBlock.Normal3f(0.0f, 1.0f, 0.0f);
topBlock.MultiTexCoord2f(0, 0.0f, 1.0f);
topBlock.Vertex3f(-1.0f, 1.0f, -1.0f);
topBlock.End();
// Make Front
frontBlock.Begin(GL_TRIANGLE_FAN, 4, 1);
frontBlock.Normal3f(0.0f, 0.0f, 1.0f);
frontBlock.MultiTexCoord2f(0, 0.0f, 0.0f);
frontBlock.Vertex3f(-1.0f, -1.0f, 1.0f);
frontBlock.Normal3f(0.0f, 0.0f, 1.0f);
frontBlock.MultiTexCoord2f(0, 1.0f, 0.0f);
frontBlock.Vertex3f(1.0f, -1.0f, 1.0f);
frontBlock.Normal3f(0.0f, 0.0f, 1.0f);
frontBlock.MultiTexCoord2f(0, 1.0f, 1.0f);
frontBlock.Vertex3f(1.0f, 1.0f, 1.0f);
frontBlock.Normal3f(0.0f, 0.0f, 1.0f);
frontBlock.MultiTexCoord2f(0, 0.0f, 1.0f);
frontBlock.Vertex3f(-1.0f, 1.0f, 1.0f);
frontBlock.End();
// Make left
leftBlock.Begin(GL_TRIANGLE_FAN, 4, 1);
leftBlock.Normal3f(-1.0f, 0.0f, 0.0f);
leftBlock.MultiTexCoord2f(0, 0.0f, 0.0f);
leftBlock.Vertex3f(-1.0f, -1.0f, -1.0f);
leftBlock.Normal3f(-1.0f, 0.0f, 0.0f);
leftBlock.MultiTexCoord2f(0, 1.0f, 0.0f);
leftBlock.Vertex3f(-1.0f, -1.0f, 1.0f);
leftBlock.Normal3f(-1.0f, 0.0f, 0.0f);
leftBlock.MultiTexCoord2f(0, 1.0f, 1.0f);
leftBlock.Vertex3f(-1.0f, 1.0f, 1.0f);
leftBlock.Normal3f(-1.0f, 0.0f, 0.0f);
leftBlock.MultiTexCoord2f(0, 0.0f, 1.0f);
leftBlock.Vertex3f(-1.0f, 1.0f, -1.0f);
leftBlock.End();
// Create shadow projection matrix
GLfloat floorPlane[] = { 0.0f, 1.0f, 0.0f, 1.0f};
m3dMakePlanarShadowMatrix(shadowMatrix, floorPlane, vLightPos);
// Load up four textures
glGenTextures(4, textures);
// Wood floor
pBytes = gltReadTGABits("floor.tga", &nWidth, &nHeight, &nComponents, &format);
glBindTexture(GL_TEXTURE_2D, textures[0]);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexImage2D(GL_TEXTURE_2D,0,nComponents,nWidth, nHeight, 0,
format, GL_UNSIGNED_BYTE, pBytes);
free(pBytes);
// One of the block faces
pBytes = gltReadTGABits("Block4.tga", &nWidth, &nHeight, &nComponents, &format);
glBindTexture(GL_TEXTURE_2D, textures[1]);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexImage2D(GL_TEXTURE_2D,0,nComponents,nWidth, nHeight, 0,
format, GL_UNSIGNED_BYTE, pBytes);
free(pBytes);
// Another block face
pBytes = gltReadTGABits("Block5.tga", &nWidth, &nHeight, &nComponents, &format);
glBindTexture(GL_TEXTURE_2D, textures[2]);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexImage2D(GL_TEXTURE_2D,0,nComponents,nWidth, nHeight, 0,
format, GL_UNSIGNED_BYTE, pBytes);
free(pBytes);
// Yet another block face
pBytes = gltReadTGABits("Block6.tga", &nWidth, &nHeight, &nComponents, &format);
glBindTexture(GL_TEXTURE_2D, textures[3]);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexImage2D(GL_TEXTURE_2D,0,nComponents,nWidth, nHeight, 0,
format, GL_UNSIGNED_BYTE, pBytes);
free(pBytes);
}
///////////////////////////////////////////////////////////////////////////////
// Render the block
void RenderBlock(void)
{
GLfloat vRed[] = { 1.0f, 0.0f, 0.0f, 1.0f};
GLfloat vWhite[] = { 1.0f, 1.0f, 1.0f, 1.0f };
switch(nStep)
{
// Wire frame
case 0:
glEnable(GL_BLEND);
glEnable(GL_LINE_SMOOTH);
shaderManager.UseStockShader(GLT_SHADER_FLAT, transformPipeline.GetModelViewProjectionMatrix(), vRed);
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
glDisable(GL_CULL_FACE);
// Draw the cube
cubeBatch.Draw();
break;
// Wire frame, but not the back side... we also want the block to be in the stencil buffer
case 1:
shaderManager.UseStockShader(GLT_SHADER_FLAT, transformPipeline.GetModelViewProjectionMatrix(), vRed);
// Draw (back side) solid block in stencil buffer
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
glEnable(GL_STENCIL_TEST);
glStencilFunc(GL_NEVER, 0, 0);
glStencilOp(GL_INCR, GL_INCR, GL_INCR);
glFrontFace(GL_CW);
cubeBatch.Draw();
glFrontFace(GL_CCW);
glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);
glDisable(GL_STENCIL_TEST);
glEnable(GL_BLEND);
glEnable(GL_LINE_SMOOTH);
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
// Draw the front side cube
cubeBatch.Draw();
break;
// Solid
case 2:
shaderManager.UseStockShader(GLT_SHADER_FLAT, transformPipeline.GetModelViewProjectionMatrix(), vRed);
// Draw the cube
cubeBatch.Draw();
break;
// Lit
case 3:
shaderManager.UseStockShader(GLT_SHADER_POINT_LIGHT_DIFF, modelViewMatrix.GetMatrix(),
projectionMatrix.GetMatrix(), vLightPos, vRed);
// Draw the cube
cubeBatch.Draw();
break;
// Textured & Lit
case 4:
case 5:
default:
glBindTexture(GL_TEXTURE_2D, textures[2]);
shaderManager.UseStockShader(GLT_SHADER_TEXTURE_POINT_LIGHT_DIFF, modelViewMatrix.GetMatrix(),
projectionMatrix.GetMatrix(), vLightPos, vWhite, 0);
glBindTexture(GL_TEXTURE_2D, textures[1]);
topBlock.Draw();
glBindTexture(GL_TEXTURE_2D, textures[2]);
frontBlock.Draw();
glBindTexture(GL_TEXTURE_2D, textures[3]);
leftBlock.Draw();
break;
}
// Put everything back
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
glEnable(GL_CULL_FACE);
glDisable(GL_BLEND);
glDisable(GL_LINE_SMOOTH);
glDisable(GL_STENCIL_TEST);
}
///////////////////////////////////////////////////////////////////////////////
// Render the floor
void RenderFloor(void)
{
GLfloat vBrown [] = { 0.55f, 0.292f, 0.09f, 1.0f};
GLfloat vFloor[] = { 1.0f, 1.0f, 1.0f, 0.6f };
switch(nStep)
{
// Wire frame
case 0:
glEnable(GL_BLEND);
glEnable(GL_LINE_SMOOTH);
shaderManager.UseStockShader(GLT_SHADER_FLAT, transformPipeline.GetModelViewProjectionMatrix(), vBrown);
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
glDisable(GL_CULL_FACE);
break;
// Wire frame, but not the back side.. and only where stencil == 0
case 1:
glEnable(GL_BLEND);
glEnable(GL_LINE_SMOOTH);
glEnable(GL_STENCIL_TEST);
glStencilFunc(GL_EQUAL, 0, 0xff);
shaderManager.UseStockShader(GLT_SHADER_FLAT, transformPipeline.GetModelViewProjectionMatrix(), vBrown);
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
break;
// Solid
case 2:
case 3:
shaderManager.UseStockShader(GLT_SHADER_FLAT, transformPipeline.GetModelViewProjectionMatrix(), vBrown);
break;
// Textured
case 4:
case 5:
default:
glBindTexture(GL_TEXTURE_2D, textures[0]);
shaderManager.UseStockShader(GLT_SHADER_TEXTURE_MODULATE, transformPipeline.GetModelViewProjectionMatrix(), vFloor, 0);
break;
}
// Draw the floor
floorBatch.Draw();
// Put everything back
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
glEnable(GL_CULL_FACE);
glDisable(GL_BLEND);
glDisable(GL_LINE_SMOOTH);
glDisable(GL_STENCIL_TEST);
}
///////////////////////////////////////////////////////////////////////////////
// Called to draw scene
void RenderScene(RenderContext *rcx)
{
// Clear the window with current clearing color
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
modelViewMatrix.PushMatrix();
M3DMatrix44f mCamera;
cameraFrame.GetCameraMatrix(mCamera);
modelViewMatrix.MultMatrix(mCamera);
// Reflection step... draw cube upside down, the floor
// blended on top of it
if(nStep == 5)
{
glDisable(GL_CULL_FACE);
modelViewMatrix.PushMatrix();
modelViewMatrix.Scale(1.0f, -1.0f, 1.0f);
modelViewMatrix.Translate(0.0f, 2.0f, 0.0f);
modelViewMatrix.Rotate(35.0f, 0.0f, 1.0f, 0.0f);
RenderBlock();
modelViewMatrix.PopMatrix();
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
RenderFloor();
glDisable(GL_BLEND);
}
modelViewMatrix.PushMatrix();
// Draw normally
modelViewMatrix.Rotate(35.0f, 0.0f, 1.0f, 0.0f);
RenderBlock();
modelViewMatrix.PopMatrix();
// If not the reflection pass, draw floor last
if(nStep != 5)
RenderFloor();
modelViewMatrix.PopMatrix();
// Flush drawing commands
glXSwapBuffers(rcx->dpy, rcx->win);
}
///////////////////////////////////////////////////////////////////////////////
// A normal ASCII key has been pressed.
// In this case, advance the scene when the space bar is pressed
void KeyPressFunc(unsigned char key)
{
if(key == 65)
{
nStep++;
if(nStep > 5)
nStep = 0;
}
}
///////////////////////////////////////////////////////////////////////////////
// Window has changed size, or has just been created. In either case, we need
// to use the window dimensions to set the viewport and the projection matrix.
void ChangeSize(int w, int h)
{
glViewport(0, 0, w, h);
viewFrustum.SetPerspective(35.0f, float(w) / float(h), 1.0f, 500.0f);
projectionMatrix.LoadMatrix(viewFrustum.GetProjectionMatrix());
modelViewMatrix.LoadIdentity();
}
void Cleanup(RenderContext *rcx)
{
glDeleteTextures(4,textures);
// Unbind the context before deleting
glXMakeCurrent(rcx->dpy, None, NULL);
glXDestroyContext(rcx->dpy, rcx->ctx);
rcx->ctx = NULL;
XDestroyWindow(rcx->dpy, rcx->win);
rcx->win = (Window)NULL;
XCloseDisplay(rcx->dpy);
rcx->dpy = 0;
}
///////////////////////////////////////////////////////////////////////////////
// Main entry point
int main(int argc, char* argv[])
{
Bool bWinMapped = False;
RenderContext rcx;
gltSetWorkingDirectory(argv[0]);
GLuint vertexArrayObject;
EarlyInitGLXfnPointers();
// Set initial window size
rcx.nWinWidth = 800;
rcx.nWinHeight = 600;
// Setup X window and GLX context
CreateWindow(&rcx);
SetupRC(&rcx);
ChangeSize(rcx.nWinWidth, rcx.nWinHeight);
// Draw the first frame before checking for messages
RenderScene(&rcx);
// Execute loop the whole time the app runs
for(;;)
{
XEvent newEvent;
XWindowAttributes winData;
// Watch for new X events
XNextEvent(rcx.dpy, &newEvent);
switch(newEvent.type)
{
case UnmapNotify:
bWinMapped = False;
break;
case MapNotify :
bWinMapped = True;
case ConfigureNotify:
XGetWindowAttributes(rcx.dpy, rcx.win, &winData);
rcx.nWinHeight = winData.height;
rcx.nWinWidth = winData.width;
ChangeSize(rcx.nWinWidth, rcx.nWinHeight);
break;
case KeyPress:
KeyPressFunc(newEvent.xkey.keycode);
break;
case DestroyNotify:
Cleanup(&rcx);
exit(0);
break;
}
if(bWinMapped)
{
RenderScene(&rcx);
}
}
Cleanup(&rcx);
return 0;
}
| 32.012903 | 203 | 0.608222 | HelloWorld115 |
2419d4c7b56e4b7732264e7de20a7e83c192c18e | 8,265 | cpp | C++ | core/blockchain/impl/key_value_block_storage.cpp | lamafab/kagome | 988bc6d93314ca58b320a9d83dcbc4cd3b87b7bb | [
"Apache-2.0"
] | null | null | null | core/blockchain/impl/key_value_block_storage.cpp | lamafab/kagome | 988bc6d93314ca58b320a9d83dcbc4cd3b87b7bb | [
"Apache-2.0"
] | null | null | null | core/blockchain/impl/key_value_block_storage.cpp | lamafab/kagome | 988bc6d93314ca58b320a9d83dcbc4cd3b87b7bb | [
"Apache-2.0"
] | null | null | null | /**
* Copyright Soramitsu Co., Ltd. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
*/
#include "blockchain/impl/key_value_block_storage.hpp"
#include "blockchain/impl/storage_util.hpp"
#include "scale/scale.hpp"
OUTCOME_CPP_DEFINE_CATEGORY(kagome::blockchain,
KeyValueBlockStorage::Error,
e) {
using E = kagome::blockchain::KeyValueBlockStorage::Error;
switch (e) {
case E::BLOCK_EXISTS:
return "Block already exists on the chain";
case E::BODY_DOES_NOT_EXIST:
return "Block body was not found";
case E::JUSTIFICATION_DOES_NOT_EXIST:
return "Justification was not found";
}
return "Unknown error";
}
namespace kagome::blockchain {
using primitives::Block;
using primitives::BlockId;
using storage::face::MapCursor;
using storage::face::WriteBatch;
using Buffer = common::Buffer;
using Prefix = prefix::Prefix;
KeyValueBlockStorage::KeyValueBlockStorage(
std::shared_ptr<storage::BufferStorage> storage,
std::shared_ptr<crypto::Hasher> hasher)
: storage_{std::move(storage)},
hasher_{std::move(hasher)},
logger_{common::createLogger("Block Storage:")} {}
outcome::result<std::shared_ptr<KeyValueBlockStorage>>
KeyValueBlockStorage::createWithGenesis(
common::Buffer state_root,
const std::shared_ptr<storage::BufferStorage> &storage,
std::shared_ptr<crypto::Hasher> hasher,
const GenesisHandler &on_genesis_created) {
KeyValueBlockStorage block_storage(storage, std::move(hasher));
// TODO(Harrm) check that storage is actually empty
// state root type is Hash256, however for consistency with spec root hash
// returns buffer. So we need this conversion
OUTCOME_TRY(state_root_blob,
common::Hash256::fromSpan(state_root.toVector()));
auto extrinsics_root_buf = trieRoot({});
// same reason for conversion as few lines above
OUTCOME_TRY(extrinsics_root,
common::Hash256::fromSpan(extrinsics_root_buf.toVector()));
// genesis block initialization
primitives::Block genesis_block;
genesis_block.header.number = 0;
genesis_block.header.extrinsics_root = extrinsics_root;
genesis_block.header.state_root = state_root_blob;
// the rest of the fields have default value
OUTCOME_TRY(block_storage.putBlock(genesis_block));
on_genesis_created(genesis_block);
return std::make_shared<KeyValueBlockStorage>(block_storage);
}
outcome::result<primitives::BlockHeader> KeyValueBlockStorage::getBlockHeader(
const primitives::BlockId &id) const {
OUTCOME_TRY(encoded_header, getWithPrefix(*storage_, Prefix::HEADER, id));
OUTCOME_TRY(header, scale::decode<primitives::BlockHeader>(encoded_header));
return std::move(header);
}
outcome::result<primitives::BlockBody> KeyValueBlockStorage::getBlockBody(
const primitives::BlockId &id) const {
OUTCOME_TRY(block_data, getBlockData(id));
if (block_data.body) {
return block_data.body.value();
}
return Error::BODY_DOES_NOT_EXIST;
}
outcome::result<primitives::BlockData> KeyValueBlockStorage::getBlockData(
const primitives::BlockId &id) const {
OUTCOME_TRY(encoded_block_data,
getWithPrefix(*storage_, Prefix::BLOCK_DATA, id));
OUTCOME_TRY(block_data,
scale::decode<primitives::BlockData>(encoded_block_data));
return std::move(block_data);
}
outcome::result<primitives::Justification>
KeyValueBlockStorage::getJustification(
const primitives::BlockId &block) const {
OUTCOME_TRY(block_data, getBlockData(block));
if (block_data.justification) {
return block_data.justification.value();
}
return Error::JUSTIFICATION_DOES_NOT_EXIST;
}
outcome::result<primitives::BlockHash> KeyValueBlockStorage::putBlockHeader(
const primitives::BlockHeader &header) {
OUTCOME_TRY(encoded_header, scale::encode(header));
auto block_hash = hasher_->blake2b_256(encoded_header);
OUTCOME_TRY(putWithPrefix(*storage_,
Prefix::HEADER,
header.number,
block_hash,
Buffer{std::move(encoded_header)}));
return block_hash;
}
outcome::result<void> KeyValueBlockStorage::putBlockData(
primitives::BlockNumber block_number,
const primitives::BlockData &block_data) {
primitives::BlockData to_insert;
// if block data does not exist, put a new one. Otherwise get the old one
// and merge with the new one. During the merge new block data fields have
// higher priority over the old ones (old ones should be rewritten)
auto existing_block_data_res = getBlockData(block_data.hash);
if (not existing_block_data_res) {
to_insert = block_data;
} else {
auto existing_data = existing_block_data_res.value();
// add all the fields from the new block_data
to_insert.header =
block_data.header ? block_data.header : existing_data.header;
to_insert.body = block_data.body ? block_data.body : existing_data.body;
to_insert.justification = block_data.justification
? block_data.justification
: existing_data.justification;
to_insert.message_queue = block_data.message_queue
? block_data.message_queue
: existing_data.message_queue;
to_insert.receipt =
block_data.receipt ? block_data.receipt : existing_data.receipt;
}
OUTCOME_TRY(encoded_block_data, scale::encode(to_insert));
OUTCOME_TRY(putWithPrefix(*storage_,
Prefix::BLOCK_DATA,
block_number,
block_data.hash,
Buffer{encoded_block_data}));
return outcome::success();
}
outcome::result<primitives::BlockHash> KeyValueBlockStorage::putBlock(
const primitives::Block &block) {
auto block_in_storage =
getWithPrefix(*storage_, Prefix::HEADER, block.header.number);
if (block_in_storage.has_value()) {
return Error::BLOCK_EXISTS;
}
if (block_in_storage.error() != blockchain::Error::BLOCK_NOT_FOUND) {
return block_in_storage.error();
}
// insert our block's parts into the database-
OUTCOME_TRY(block_hash, putBlockHeader(block.header));
primitives::BlockData block_data;
block_data.hash = block_hash;
block_data.header = block.header;
block_data.body = block.body;
OUTCOME_TRY(putBlockData(block.header.number, block_data));
logger_->info("Added block. Number: {}. Hash: {}. State root: {}",
block.header.number,
block_hash.toHex(),
block.header.state_root.toHex());
return block_hash;
}
outcome::result<void> KeyValueBlockStorage::putJustification(
const primitives::Justification &j,
const primitives::BlockHash &hash,
const primitives::BlockNumber &block_number) {
// insert justification into the database as a part of BlockData
primitives::BlockData block_data{.hash = hash, .justification = j};
OUTCOME_TRY(putBlockData(block_number, block_data));
return outcome::success();
}
outcome::result<void> KeyValueBlockStorage::removeBlock(
const primitives::BlockHash &hash,
const primitives::BlockNumber &number) {
auto block_lookup_key = numberAndHashToLookupKey(number, hash);
auto header_lookup_key = prependPrefix(block_lookup_key, Prefix::HEADER);
if (auto rm_res = storage_->remove(header_lookup_key); !rm_res) {
logger_->error("could not remove header from the storage: {}",
rm_res.error().message());
return rm_res;
}
auto body_lookup_key = prependPrefix(block_lookup_key, Prefix::BLOCK_DATA);
if (auto rm_res = storage_->remove(body_lookup_key); !rm_res) {
logger_->error("could not remove body from the storage: {}",
rm_res.error().message());
return rm_res;
}
return outcome::success();
}
} // namespace kagome::blockchain
| 38.621495 | 80 | 0.67441 | lamafab |
241bcc8e1235101d63e6a2af2164737d99ba7e83 | 32,070 | cc | C++ | cc/lispmds-import.cc | acorg/acmacs-chart-2 | 0e95cf11ee71d9c383a0ef5cc619edc8afbeda76 | [
"MIT"
] | null | null | null | cc/lispmds-import.cc | acorg/acmacs-chart-2 | 0e95cf11ee71d9c383a0ef5cc619edc8afbeda76 | [
"MIT"
] | null | null | null | cc/lispmds-import.cc | acorg/acmacs-chart-2 | 0e95cf11ee71d9c383a0ef5cc619edc8afbeda76 | [
"MIT"
] | null | null | null | #include <set>
#include <vector>
#include <limits>
#include <regex>
#include <cmath>
#include "acmacs-base/string.hh"
#include "acmacs-base/enumerate.hh"
#include "acmacs-base/fmt.hh"
#include "acmacs-chart-2/lispmds-import.hh"
#include "acmacs-chart-2/lispmds-encode.hh"
using namespace acmacs::chart;
// ----------------------------------------------------------------------
static std::vector<double> native_column_bases(const acmacs::lispmds::value& aData);
static std::vector<double> column_bases(const acmacs::lispmds::value& aData, size_t aProjectionNo);
static std::pair<std::shared_ptr<acmacs::chart::ColumnBases>, acmacs::chart::MinimumColumnBasis> forced_column_bases(const acmacs::lispmds::value& aData, size_t aProjectionNo);
// ----------------------------------------------------------------------
static inline size_t number_of_antigens(const acmacs::lispmds::value& aData)
{
return acmacs::lispmds::size(aData, 0, 1);
} // number_of_antigens
static inline size_t number_of_sera(const acmacs::lispmds::value& aData)
{
return acmacs::lispmds::size(aData, 0, 2);
} // number_of_sera
static inline const acmacs::lispmds::value& projection_data(const acmacs::lispmds::value& aData, size_t aProjectionNo)
{
if (acmacs::lispmds::empty(aData, ":STARTING-COORDSS"))
return acmacs::lispmds::get(aData, ":BATCH-RUNS", aProjectionNo);
else if (aProjectionNo == 0)
return acmacs::lispmds::get(aData, ":STARTING-COORDSS");
else
return acmacs::lispmds::get(aData, ":BATCH-RUNS", aProjectionNo - 1);
} // LispmdsProjection::data
static inline const acmacs::lispmds::value& projection_layout(const acmacs::lispmds::value& aData, size_t aProjectionNo)
{
if (acmacs::lispmds::empty(aData, ":STARTING-COORDSS"))
return acmacs::lispmds::get(aData, ":BATCH-RUNS", aProjectionNo, 0);
else if (aProjectionNo == 0)
return acmacs::lispmds::get(aData, ":STARTING-COORDSS");
else
return acmacs::lispmds::get(aData, ":BATCH-RUNS", aProjectionNo - 1, 0);
} // LispmdsProjection::data
// ----------------------------------------------------------------------
std::vector<double> native_column_bases(const acmacs::lispmds::value& aData)
{
std::vector<double> cb(number_of_sera(aData), 0);
for (const auto& row : std::get<acmacs::lispmds::list>(acmacs::lispmds::get(aData, 0, 3))) {
for (auto [sr_no, titer_v] : acmacs::enumerate(std::get<acmacs::lispmds::list>(row))) {
std::visit(
[&cb, sr_no = sr_no](auto&& titer) {
using T = std::decay_t<decltype(titer)>;
if constexpr (std::is_same_v<T, acmacs::lispmds::symbol>) {
double titer_d;
switch (titer[0]) {
case '<':
titer_d = std::stod(titer->substr(1));
if (titer_d > cb[sr_no])
cb[sr_no] = titer_d;
break;
case '>':
titer_d = std::stod(titer->substr(1)) + 1;
if (titer_d > cb[sr_no])
cb[sr_no] = titer_d;
break;
default:
break;
}
}
else if constexpr (std::is_same_v<T, acmacs::lispmds::number>) {
const double titer_d = titer;
if (titer_d > cb[sr_no])
cb[sr_no] = titer_d;
}
else
throw acmacs::lispmds::type_mismatch{fmt::format("Unexpected titer type: {}", typeid(T).name())};
},
titer_v);
}
}
return cb;
} // native_column_bases
// ----------------------------------------------------------------------
std::vector<double> column_bases(const acmacs::lispmds::value& aData, size_t aProjectionNo)
{
const auto num_antigens = number_of_antigens(aData);
const auto num_sera = number_of_sera(aData);
const auto number_of_points = num_antigens + num_sera;
const auto& cb = std::get<acmacs::lispmds::list>(acmacs::lispmds::get(projection_layout(aData, aProjectionNo), number_of_points, 0, 1));
std::vector<double> result(num_sera);
using diff_t = decltype(cb.end() - cb.begin());
std::transform(cb.begin() + static_cast<diff_t>(num_antigens), cb.begin() + static_cast<diff_t>(number_of_points), result.begin(), [](const auto& val) -> double { return std::get<acmacs::lispmds::number>(val); });
return result;
} // column_bases
// ----------------------------------------------------------------------
std::pair<std::shared_ptr<acmacs::chart::ColumnBases>, acmacs::chart::MinimumColumnBasis> forced_column_bases(const acmacs::lispmds::value& aData, size_t aProjectionNo)
{
try {
const auto native_cb = native_column_bases(aData);
const auto cb = column_bases(aData, aProjectionNo);
if (native_cb == cb) {
return {nullptr, acmacs::chart::MinimumColumnBasis()};
}
else {
const double min_forced = *std::min_element(cb.begin(), cb.end());
std::decay_t<decltype(native_cb)> native_upgraded(native_cb.size());
std::transform(native_cb.begin(), native_cb.end(), native_upgraded.begin(), [min_forced](double b) -> double { return std::max(b, min_forced); });
// std::cerr << "INFO: native: " << native_cb << '\n';
// std::cerr << "INFO: forced: " << cb << '\n';
// std::cerr << "INFO: upgrad: " << native_upgraded << '\n';
if (native_upgraded == cb)
return {nullptr, acmacs::chart::MinimumColumnBasis(min_forced)};
else
return {std::make_shared<LispmdsColumnBases>(cb), acmacs::chart::MinimumColumnBasis()};
}
}
catch (acmacs::lispmds::keyword_no_found&) {
return {nullptr, acmacs::chart::MinimumColumnBasis()};
}
catch (acmacs::lispmds::error& err) {
fmt::print(stderr, "WARNING: broken save: {}\n", err);
return {nullptr, acmacs::chart::MinimumColumnBasis()};
}
} // forced_column_bases
// ----------------------------------------------------------------------
ChartP acmacs::chart::lispmds_import(std::string_view aData, Verify aVerify)
{
try {
auto chart = std::make_shared<LispmdsChart>(acmacs::lispmds::parse_string(aData));
chart->verify_data(aVerify);
return chart;
}
catch (std::exception& err) {
fmt::print(stderr, "ERROR: lispmds_import: {}\n", err);
throw;
}
} // acmacs::chart::lispmds_import
// ----------------------------------------------------------------------
void LispmdsChart::verify_data(Verify) const
{
try {
if (number_of_antigens() == 0)
throw import_error("no antigens");
if (number_of_sera() == 0)
throw import_error("no sera (genetic tables are not supported)");
}
catch (std::exception& err) {
throw import_error{fmt::format("[lispmds]: structure verification failed: {}", err)};
}
} // LispmdsChart::verify_data
// ----------------------------------------------------------------------
InfoP LispmdsChart::info() const
{
return std::make_shared<LispmdsInfo>(mData);
} // LispmdsChart::info
// ----------------------------------------------------------------------
AntigensP LispmdsChart::antigens() const
{
return std::make_shared<LispmdsAntigens>(mData);
} // LispmdsChart::antigens
// ----------------------------------------------------------------------
SeraP LispmdsChart::sera() const
{
return std::make_shared<LispmdsSera>(mData);
} // LispmdsChart::sera
// ----------------------------------------------------------------------
TitersP LispmdsChart::titers() const
{
return std::make_shared<LispmdsTiters>(mData);
} // LispmdsChart::titers
// ----------------------------------------------------------------------
ColumnBasesP LispmdsChart::forced_column_bases(MinimumColumnBasis /*aMinimumColumnBasis*/) const
{
return ::forced_column_bases(mData, 0).first;
} // LispmdsChart::forced_column_bases
// ----------------------------------------------------------------------
ProjectionsP LispmdsChart::projections() const
{
if (!projections_)
projections_ = std::make_shared<LispmdsProjections>(*this, mData);
return projections_;
} // LispmdsChart::projections
// ----------------------------------------------------------------------
PlotSpecP LispmdsChart::plot_spec() const
{
return std::make_shared<LispmdsPlotSpec>(mData);
} // LispmdsChart::plot_spec
// ----------------------------------------------------------------------
size_t LispmdsChart::number_of_antigens() const
{
return ::number_of_antigens(mData);
} // LispmdsChart::number_of_antigens
// ----------------------------------------------------------------------
size_t LispmdsChart::number_of_sera() const
{
return ::number_of_sera(mData);
} // LispmdsChart::number_of_sera
// ----------------------------------------------------------------------
std::string LispmdsInfo::name(Compute) const
{
if (acmacs::lispmds::size(mData, 0) >= 5)
return lispmds_decode(std::get<acmacs::lispmds::symbol>(acmacs::lispmds::get(mData, 0, 4)));
else
return {};
} // LispmdsInfo::name
// ----------------------------------------------------------------------
static inline std::string antigen_name(const acmacs::lispmds::value& aData, size_t aIndex)
{
return *std::get<acmacs::lispmds::symbol>(acmacs::lispmds::get(aData, 0, 1, aIndex));
}
// ----------------------------------------------------------------------
acmacs::virus::name_t LispmdsAntigen::name() const
{
acmacs::virus::name_t name;
acmacs::virus::Reassortant reassortant;
acmacs::virus::Passage passage;
Annotations annotations;
lispmds_antigen_name_decode(antigen_name(mData, mIndex), name, reassortant, passage, annotations);
return name;
} // LispmdsAntigen::name
// ----------------------------------------------------------------------
acmacs::virus::Passage LispmdsAntigen::passage() const
{
acmacs::virus::name_t name;
acmacs::virus::Reassortant reassortant;
acmacs::virus::Passage passage;
Annotations annotations;
lispmds_antigen_name_decode(antigen_name(mData, mIndex), name, reassortant, passage, annotations);
return passage;
} // LispmdsAntigen::passage
// ----------------------------------------------------------------------
acmacs::virus::Reassortant LispmdsAntigen::reassortant() const
{
acmacs::virus::name_t name;
acmacs::virus::Reassortant reassortant;
acmacs::virus::Passage passage;
Annotations annotations;
lispmds_antigen_name_decode(antigen_name(mData, mIndex), name, reassortant, passage, annotations);
return reassortant;
} // LispmdsAntigen::reassortant
// ----------------------------------------------------------------------
Annotations LispmdsAntigen::annotations() const
{
acmacs::virus::name_t name;
acmacs::virus::Reassortant reassortant;
acmacs::virus::Passage passage;
Annotations annotations;
lispmds_antigen_name_decode(antigen_name(mData, mIndex), name, reassortant, passage, annotations);
return annotations;
} // LispmdsAntigen::annotations
// ----------------------------------------------------------------------
bool LispmdsAntigen::reference() const
{
try {
const auto& val = acmacs::lispmds::get(mData, ":REFERENCE-ANTIGENS");
if (acmacs::lispmds::empty(val))
return false;
const auto name = antigen_name(mData, mIndex);
const auto& val_l = std::get<acmacs::lispmds::list>(val);
return std::find_if(val_l.begin(), val_l.end(), [&name](const auto& ev) -> bool { return std::get<acmacs::lispmds::symbol>(ev) == acmacs::lispmds::symbol{name}; }) != val_l.end();
}
catch (acmacs::lispmds::keyword_no_found&) {
return false;
}
} // LispmdsAntigen::reference
// ----------------------------------------------------------------------
static inline std::string serum_name(const acmacs::lispmds::value& aData, size_t aIndex)
{
return *std::get<acmacs::lispmds::symbol>(acmacs::lispmds::get(aData, 0, 2, aIndex));
}
// ----------------------------------------------------------------------
acmacs::virus::name_t LispmdsSerum::name() const
{
acmacs::virus::name_t name;
acmacs::virus::Reassortant reassortant;
SerumId serum_id;
Annotations annotations;
lispmds_serum_name_decode(serum_name(mData, mIndex), name, reassortant, annotations, serum_id);
return name;
} // LispmdsSerum::name
// ----------------------------------------------------------------------
acmacs::virus::Reassortant LispmdsSerum::reassortant() const
{
acmacs::virus::name_t name;
acmacs::virus::Reassortant reassortant;
SerumId serum_id;
Annotations annotations;
lispmds_serum_name_decode(serum_name(mData, mIndex), name, reassortant, annotations, serum_id);
return reassortant;
} // LispmdsSerum::reassortant
// ----------------------------------------------------------------------
Annotations LispmdsSerum::annotations() const
{
acmacs::virus::name_t name;
acmacs::virus::Reassortant reassortant;
SerumId serum_id;
Annotations annotations;
lispmds_serum_name_decode(serum_name(mData, mIndex), name, reassortant, annotations, serum_id);
return annotations;
} // LispmdsSerum::annotations
// ----------------------------------------------------------------------
SerumId LispmdsSerum::serum_id() const
{
acmacs::virus::name_t name;
acmacs::virus::Reassortant reassortant;
SerumId serum_id;
Annotations annotations;
lispmds_serum_name_decode(serum_name(mData, mIndex), name, reassortant, annotations, serum_id);
return serum_id;
} // LispmdsSerum::serum_id
// ----------------------------------------------------------------------
size_t LispmdsAntigens::size() const
{
return number_of_antigens(mData);
} // LispmdsAntigens::size
// ----------------------------------------------------------------------
AntigenP LispmdsAntigens::operator[](size_t aIndex) const
{
return std::make_shared<LispmdsAntigen>(mData, aIndex);
} // LispmdsAntigens::operator[]
// ----------------------------------------------------------------------
size_t LispmdsSera::size() const
{
return number_of_sera(mData);
} // LispmdsSera::size
// ----------------------------------------------------------------------
SerumP LispmdsSera::operator[](size_t aIndex) const
{
return std::make_shared<LispmdsSerum>(mData, aIndex);
} // LispmdsSera::operator[]
// ----------------------------------------------------------------------
Titer LispmdsTiters::titer(size_t aAntigenNo, size_t aSerumNo) const
{
return std::visit(
[](auto&& titer_x) -> Titer {
using T = std::decay_t<decltype(titer_x)>;
if constexpr (std::is_same_v<T, acmacs::lispmds::symbol>) {
if (titer_x[0] == '*')
return Titer{std::string(1, titer_x[0])};
return Titer{fmt::format("{}{}", titer_x[0], std::lround(std::exp2(std::stod(titer_x->substr(1))) * 10))};
}
else if constexpr (std::is_same_v<T, acmacs::lispmds::number>) {
return Titer{fmt::format("{}", std::lround(std::exp2(static_cast<double>(titer_x)) * 10))};
}
else
throw acmacs::lispmds::type_mismatch{fmt::format("Unexpected titer type: {}", typeid(T).name())};
},
acmacs::lispmds::get(mData, 0, 3, aAntigenNo, aSerumNo));
} // LispmdsTiters::titer
// ----------------------------------------------------------------------
size_t LispmdsTiters::number_of_antigens() const
{
return acmacs::lispmds::size(mData, 0, 3);
} // LispmdsTiters::number_of_antigens
// ----------------------------------------------------------------------
size_t LispmdsTiters::number_of_sera() const
{
return acmacs::lispmds::size(mData, 0, 3, 0);
} // LispmdsTiters::number_of_sera
// ----------------------------------------------------------------------
inline bool is_dontcare(const acmacs::lispmds::value& titer)
{
return std::visit(
[](auto&& arg) -> bool {
using T = std::decay_t<decltype(arg)>;
if constexpr (std::is_same_v<T, acmacs::lispmds::symbol>)
return arg[0] == '*';
else if constexpr (std::is_same_v<T, acmacs::lispmds::number>)
return false;
else
throw acmacs::lispmds::type_mismatch{fmt::format("Unexpected titer type: {}", typeid(T).name())};
},
titer);
}
// ----------------------------------------------------------------------
size_t LispmdsTiters::number_of_non_dont_cares() const
{
size_t result = 0;
for (const auto& row : std::get<acmacs::lispmds::list>(acmacs::lispmds::get(mData, 0, 3))) {
for (const auto& titer : std::get<acmacs::lispmds::list>(row)) {
if (!is_dontcare(titer))
++result;
}
}
return result;
} // LispmdsTiters::number_of_non_dont_cares
// ----------------------------------------------------------------------
size_t LispmdsTiters::titrations_for_antigen(size_t antigen_no) const
{
size_t result = 0;
const auto& row = std::get<acmacs::lispmds::list>(acmacs::lispmds::get(mData, 0, 3))[antigen_no];
for (const auto& titer : std::get<acmacs::lispmds::list>(row)) {
if (!is_dontcare(titer))
++result;
}
return result;
} // LispmdsTiters::titrations_for_antigen
// ----------------------------------------------------------------------
size_t LispmdsTiters::titrations_for_serum(size_t serum_no) const
{
size_t result = 0;
for (const auto& row : std::get<acmacs::lispmds::list>(acmacs::lispmds::get(mData, 0, 3))) {
if (!is_dontcare(std::get<acmacs::lispmds::list>(row)[serum_no]))
++result;
}
return result;
} // LispmdsTiters::titrations_for_serum
// ----------------------------------------------------------------------
void LispmdsProjection::check() const
{
try {
if (auto nd = layout()->number_of_dimensions(); *nd > 5)
throw import_error{fmt::format("[lispmds] projection {} has unsupported number of dimensions: {}", projection_no(), nd)};
}
catch (std::exception& err) {
throw import_error{fmt::format("[lispmds] projection {} reading error: {}", projection_no(), err)};
}
} // LispmdsProjection::check
// ----------------------------------------------------------------------
std::optional<double> LispmdsProjection::stored_stress() const
{
return std::visit(
[](auto&& arg) -> std::optional<double> {
using T = std::decay_t<decltype(arg)>;
if constexpr (std::is_same_v<T, acmacs::lispmds::number>)
return static_cast<double>(arg);
else
return {};
},
acmacs::lispmds::get(projection_data(mData, projection_no()), 1));
} // LispmdsProjection::stress
// ----------------------------------------------------------------------
class LispmdsLayout : public acmacs::Layout
{
public:
LispmdsLayout(const acmacs::lispmds::value& aData, size_t aNumberOfAntigens, size_t aNumberOfSera)
: acmacs::Layout(aNumberOfAntigens + aNumberOfSera, acmacs::number_of_dimensions_t{acmacs::lispmds::size(aData, 0)})
{
auto target = Vec::begin();
for (size_t p_no = 0; p_no < number_of_points(); ++p_no) {
const auto& point = acmacs::lispmds::get(aData, p_no);
if (const auto ps = acmacs::lispmds::size(point); ps == *number_of_dimensions()) {
for (auto dim : acmacs::range(ps))
*target++ = std::get<acmacs::lispmds::number>(acmacs::lispmds::get(point, dim));
}
else if (ps > 0)
throw invalid_data(fmt::format("LispmdsLayout: point has invalid number of coordinates: {}, expected 0 or {}", ps, number_of_dimensions()));
else
target += static_cast<decltype(target)::difference_type>(*number_of_dimensions());
}
}
}; // class LispmdsLayout
// ----------------------------------------------------------------------
std::shared_ptr<acmacs::Layout> LispmdsProjection::layout() const
{
// std::cerr << "antigens: " << mNumberOfAntigens << " sera: " << mNumberOfSera << " points: " << (mNumberOfAntigens + mNumberOfSera) << '\n';
if (!layout_)
layout_ = std::make_shared<LispmdsLayout>(projection_layout(mData, projection_no()), mNumberOfAntigens, mNumberOfSera);
return layout_;
} // LispmdsProjection::layout
// ----------------------------------------------------------------------
acmacs::number_of_dimensions_t LispmdsProjection::number_of_dimensions() const
{
return acmacs::number_of_dimensions_t{acmacs::lispmds::size(projection_layout(mData, projection_no()), 0)};
} // LispmdsProjection::number_of_dimensions
// ----------------------------------------------------------------------
ColumnBasesP LispmdsProjection::forced_column_bases() const
{
return ::forced_column_bases(mData, projection_no()).first;
} // LispmdsProjection::forced_column_bases
// ----------------------------------------------------------------------
acmacs::chart::MinimumColumnBasis LispmdsProjection::minimum_column_basis() const
{
return ::forced_column_bases(mData, projection_no()).second;
} // LispmdsProjection::minimum_column_basis
// ----------------------------------------------------------------------
acmacs::Transformation LispmdsProjection::transformation() const
{
acmacs::Transformation result;
try {
if (const auto& coord_tr = acmacs::lispmds::get(mData, ":CANVAS-COORD-TRANSFORMATIONS"); !acmacs::lispmds::empty(coord_tr)) {
try {
if (const auto& v0 = acmacs::lispmds::get(coord_tr, ":CANVAS-BASIS-VECTOR-0"); !acmacs::lispmds::empty(v0)) {
result.a() = std::get<acmacs::lispmds::number>(acmacs::lispmds::get(v0, 0));
result.c() = std::get<acmacs::lispmds::number>(acmacs::lispmds::get(v0, 1));
}
}
catch (std::exception&) {
}
try {
if (const auto& v1 = acmacs::lispmds::get(coord_tr, ":CANVAS-BASIS-VECTOR-1"); !acmacs::lispmds::empty(v1)) {
result.b() = std::get<acmacs::lispmds::number>(acmacs::lispmds::get(v1, 0));
result.d() = std::get<acmacs::lispmds::number>(acmacs::lispmds::get(v1, 1));
}
}
catch (std::exception&) {
}
try {
if (static_cast<double>(std::get<acmacs::lispmds::number>(acmacs::lispmds::get(coord_tr, ":CANVAS-X-COORD-SCALE"))) < 0) {
result.a() = - result.a();
result.c() = - result.c();
}
}
catch (std::exception&) {
}
try {
if (static_cast<double>(std::get<acmacs::lispmds::number>(acmacs::lispmds::get(coord_tr, ":CANVAS-Y-COORD-SCALE"))) < 0) {
result.b() = - result.b();
result.d() = - result.d();
}
}
catch (std::exception&) {
}
}
}
catch (acmacs::lispmds::keyword_no_found&) {
}
return result;
} // LispmdsProjection::transformation
// ----------------------------------------------------------------------
UnmovablePoints LispmdsProjection::unmovable() const
{
// :UNMOVEABLE-COORDS '(87 86 85 83 82 80 81)
try {
const auto& val = std::get<acmacs::lispmds::list>(acmacs::lispmds::get(mData, ":UNMOVEABLE-COORDS"));
return {val.begin(), val.end(), [](const auto& v) -> size_t { return std::get<acmacs::lispmds::number>(v); }};
}
catch (std::exception&) {
return {};
}
} // LispmdsProjection::unmovable
// ----------------------------------------------------------------------
DisconnectedPoints LispmdsProjection::disconnected() const
{
// std::cerr << "WARNING: LispmdsProjection::disconnected not implemented\n";
return {};
} // LispmdsProjection::disconnected
// ----------------------------------------------------------------------
AvidityAdjusts LispmdsProjection::avidity_adjusts() const
{
try {
const auto num_points = layout()->number_of_points();
const acmacs::lispmds::list& cb = std::get<acmacs::lispmds::list>(acmacs::lispmds::get(projection_layout(mData, projection_no()), num_points, 0, 1));
AvidityAdjusts result(num_points);
for (size_t i = 0; i < num_points; ++i)
result[i] = std::exp2(static_cast<double>(std::get<acmacs::lispmds::number>(cb[num_points + i])));
return result;
}
catch (acmacs::lispmds::error& err) {
fmt::print(stderr, "ERROR: [lispmds avidity_adjusts] broken save: {}\n", err);
return {};
}
catch (std::exception& err) {
fmt::print(stderr, "ERROR: [lispmds avidity_adjusts]: {}\n", err);
throw;
}
} // LispmdsProjection::avidity_adjusts
// ----------------------------------------------------------------------
bool LispmdsProjections::empty() const
{
return acmacs::lispmds::empty(mData, ":STARTING-COORDSS") && acmacs::lispmds::empty(mData, ":BATCH-RUNS");
} // LispmdsProjections::empty
// ----------------------------------------------------------------------
size_t LispmdsProjections::size() const
{
size_t result = 0;
if (!acmacs::lispmds::empty(mData, ":STARTING-COORDSS"))
++result;
try {
result += acmacs::lispmds::size(mData, ":BATCH-RUNS");
}
catch (acmacs::lispmds::error&) {
}
return result;
} // LispmdsProjections::size
// ----------------------------------------------------------------------
ProjectionP LispmdsProjections::operator[](size_t aIndex) const
{
if (!projections_[aIndex])
projections_[aIndex] = std::make_shared<LispmdsProjection>(chart(), mData, aIndex, number_of_antigens(mData), number_of_sera(mData));
return projections_[aIndex];
} // LispmdsProjections::operator[]
// ----------------------------------------------------------------------
bool LispmdsPlotSpec::empty() const
{
try {
return acmacs::lispmds::empty(mData, ":PLOT-SPEC");
}
catch (std::exception&) {
return true;
}
} // LispmdsPlotSpec::empty
// ----------------------------------------------------------------------
DrawingOrder LispmdsPlotSpec::drawing_order() const
{
// :RAISE-POINTS 'NIL
// :LOWER-POINTS 'NIL
// don't know how drawing order is stored
return {};
} // LispmdsPlotSpec::drawing_order
// ----------------------------------------------------------------------
Color LispmdsPlotSpec::error_line_positive_color() const
{
return RED;
} // LispmdsPlotSpec::error_line_positive_color
// ----------------------------------------------------------------------
Color LispmdsPlotSpec::error_line_negative_color() const
{
return BLUE;
} // LispmdsPlotSpec::error_line_negative_color
// ----------------------------------------------------------------------
acmacs::PointStyle LispmdsPlotSpec::style(size_t aPointNo) const
{
acmacs::PointStyle result;
extract_style(result, aPointNo);
return result;
} // LispmdsPlotSpec::style
// ----------------------------------------------------------------------
std::vector<acmacs::PointStyle> LispmdsPlotSpec::all_styles() const
{
try {
const auto number_of_points = acmacs::lispmds::size(mData, 0, 1) + acmacs::lispmds::size(mData, 0, 2);
std::vector<acmacs::PointStyle> result(number_of_points);
for (size_t point_no = 0; point_no < number_of_points; ++point_no) {
extract_style(result[point_no], point_no);
}
return result;
}
catch (std::exception& err) {
AD_WARNING("[lispmds]: cannot get point styles: {}", err);
}
return {};
} // LispmdsPlotSpec::all_styles
// ----------------------------------------------------------------------
size_t LispmdsPlotSpec::number_of_points() const
{
try {
return acmacs::lispmds::size(mData, 0, 1) + acmacs::lispmds::size(mData, 0, 2);
}
catch (std::exception& err) {
AD_WARNING("[lispmds]: cannot get point styles: {}", err);
return 0;
}
} // LispmdsPlotSpec::number_of_points
// ----------------------------------------------------------------------
void LispmdsPlotSpec::extract_style(acmacs::PointStyle& aTarget, size_t aPointNo) const
{
std::string name = aPointNo < number_of_antigens(mData)
? static_cast<std::string>(std::get<acmacs::lispmds::symbol>(acmacs::lispmds::get(mData, 0, 1, aPointNo))) + "-AG"
: static_cast<std::string>(std::get<acmacs::lispmds::symbol>(acmacs::lispmds::get(mData, 0, 2, aPointNo - number_of_antigens(mData)))) + "-SR";
const auto& plot_spec = std::get<acmacs::lispmds::list>(acmacs::lispmds::get(mData, ":PLOT-SPEC"));
for (const auto& pstyle : plot_spec) {
if (std::get<acmacs::lispmds::symbol>(acmacs::lispmds::get(pstyle, 0)) == acmacs::lispmds::symbol{name}) {
extract_style(aTarget, std::get<acmacs::lispmds::list>(pstyle));
break;
}
}
} // LispmdsPlotSpec::extract_style
// ----------------------------------------------------------------------
void LispmdsPlotSpec::extract_style(acmacs::PointStyle& aTarget, const acmacs::lispmds::list& aSource) const
{
try {
aTarget.size(Pixels{static_cast<double>(std::get<acmacs::lispmds::number>(aSource[":DS"])) / acmacs::lispmds::DS_SCALE});
// if antigen also divide size by 2 ?
}
catch (std::exception&) {
}
try {
aTarget.label_text(*std::get<acmacs::lispmds::string>(aSource[":WN"]));
aTarget.label().shown = !aTarget.label_text().empty();
}
catch (std::exception&) {
}
try {
aTarget.shape(PointShape{*std::get<acmacs::lispmds::string>(aSource[":SH"])});
}
catch (std::exception&) {
}
try {
aTarget.label().size = Pixels{static_cast<double>(std::get<acmacs::lispmds::number>(aSource[":NS"])) / acmacs::lispmds::NS_SCALE};
}
catch (std::exception&) {
}
try {
if (const auto label_color = std::get<acmacs::lispmds::string>(aSource[":NC"]); label_color != acmacs::lispmds::string{"{}"})
aTarget.label().color = acmacs::color::Modifier{Color(*label_color)};
}
catch (std::exception&) {
}
try {
if (const auto fill_color = std::get<acmacs::lispmds::string>(aSource[":CO"]); fill_color != acmacs::lispmds::string{"{}"})
aTarget.fill(Color(*fill_color));
else
aTarget.fill(TRANSPARENT);
}
catch (std::exception&) {
}
try {
if (const auto outline_color = std::get<acmacs::lispmds::string>(aSource[":OC"]); outline_color != acmacs::lispmds::string{"{}"})
aTarget.outline(Color(*outline_color));
else
aTarget.outline(TRANSPARENT);
}
catch (std::exception&) {
}
try {
aTarget.fill(acmacs::color::Modifier{acmacs::color::Modifier::transparency_set{static_cast<double>(std::get<acmacs::lispmds::number>(aSource[":TR"]))}});
}
catch (std::exception&) {
}
} // LispmdsPlotSpec::extract_style
// ----------------------------------------------------------------------
/// Local Variables:
/// eval: (if (fboundp 'eu-rename-buffer) (eu-rename-buffer))
/// End:
| 35.125958 | 217 | 0.536296 | acorg |
241cd8fda7f5c03f59f7136ca1325baf92064849 | 3,123 | hpp | C++ | src/stan/math/prim/mat/prob/multi_normal_prec_rng.hpp | alashworth/stan-monorepo | 75596bc1f860ededd7b3e9ae9002aea97ee1cd46 | [
"BSD-3-Clause"
] | 1 | 2019-09-06T15:53:17.000Z | 2019-09-06T15:53:17.000Z | src/stan/math/prim/mat/prob/multi_normal_prec_rng.hpp | alashworth/stan-monorepo | 75596bc1f860ededd7b3e9ae9002aea97ee1cd46 | [
"BSD-3-Clause"
] | 8 | 2019-01-17T18:51:16.000Z | 2019-01-17T18:51:39.000Z | src/stan/math/prim/mat/prob/multi_normal_prec_rng.hpp | alashworth/stan-monorepo | 75596bc1f860ededd7b3e9ae9002aea97ee1cd46 | [
"BSD-3-Clause"
] | null | null | null | #ifndef STAN_MATH_PRIM_MAT_PROB_MULTI_NORMAL_PREC_RNG_HPP
#define STAN_MATH_PRIM_MAT_PROB_MULTI_NORMAL_PREC_RNG_HPP
#include <stan/math/prim/meta.hpp>
#include <stan/math/prim/mat/err/check_pos_definite.hpp>
#include <stan/math/prim/mat/err/check_symmetric.hpp>
#include <stan/math/prim/mat/fun/Eigen.hpp>
#include <stan/math/prim/scal/err/check_finite.hpp>
#include <stan/math/prim/scal/err/check_positive.hpp>
#include <boost/random/normal_distribution.hpp>
#include <boost/random/variate_generator.hpp>
namespace stan {
namespace math {
/**
* Return a multivariate normal random variate with the given location
* and precision using the specified random number generator.
*
* mu can be either an Eigen::VectorXd, an Eigen::RowVectorXd, or a
* std::vector of either of those types.
*
* @tparam T_loc Type of location paramater
* @tparam RNG Type of pseudo-random number generator
* @param mu (Sequence of) location parameter(s)
* @param S Precision matrix
* @param rng random number generator
* @throw std::domain_error if S is not positive definite, or
* std::invalid_argument if the length of (each) mu is not equal to
* the number of rows and columns in S
*/
template <typename T_loc, class RNG>
inline typename StdVectorBuilder<true, Eigen::VectorXd, T_loc>::type
multi_normal_prec_rng(const T_loc &mu, const Eigen::MatrixXd &S, RNG &rng) {
using boost::normal_distribution;
using boost::variate_generator;
static const char *function = "multi_normal_prec_rng";
check_positive(function, "Precision matrix rows", S.rows());
check_finite(function, "Precision matrix", S);
check_symmetric(function, "Precision matrix", S);
Eigen::LLT<Eigen::MatrixXd> llt_of_S = S.llt();
check_pos_definite(function, "precision matrix argument", llt_of_S);
vector_seq_view<T_loc> mu_vec(mu);
check_positive(function, "number of location parameter vectors",
mu_vec.size());
size_t size_mu = mu_vec[0].size();
size_t N = mu_vec.size();
for (size_t i = 1; i < N; i++) {
int size_mu_new = mu_vec[i].size();
check_size_match(function,
"Size of one of the vectors of "
"the location variable",
size_mu_new,
"Size of another vector of the "
"location variable",
size_mu);
}
for (size_t i = 0; i < N; i++) {
check_finite(function, "Location parameter", mu_vec[i]);
}
check_size_match(function, "Rows of location parameter", size_mu, "Rows of S",
S.rows());
StdVectorBuilder<true, Eigen::VectorXd, T_loc> output(N);
variate_generator<RNG &, normal_distribution<>> std_normal_rng(
rng, normal_distribution<>(0, 1));
for (size_t n = 0; n < N; ++n) {
Eigen::VectorXd z(S.cols());
for (int i = 0; i < S.cols(); i++)
z(i) = std_normal_rng();
output[n] = Eigen::VectorXd(mu_vec[n]) + llt_of_S.matrixU().solve(z);
}
return output.data();
}
} // namespace math
} // namespace stan
#endif
| 34.318681 | 81 | 0.663465 | alashworth |
241da46294ca59fa72f34e7c7b3c4ef8a3f5fbf7 | 739 | cpp | C++ | src/tests/testutil.cpp | sbu-fsl/Lintel | b9e603aaec630c8d3fae2f21fc156582d11d84c9 | [
"BSD-3-Clause"
] | null | null | null | src/tests/testutil.cpp | sbu-fsl/Lintel | b9e603aaec630c8d3fae2f21fc156582d11d84c9 | [
"BSD-3-Clause"
] | 1 | 2020-10-05T21:20:36.000Z | 2020-10-05T21:56:51.000Z | src/tests/testutil.cpp | sbu-fsl/Lintel | b9e603aaec630c8d3fae2f21fc156582d11d84c9 | [
"BSD-3-Clause"
] | null | null | null | /* -*-C++-*- */
/*
(c) Copyright 2008, Hewlett-Packard Development Company, LP
See the file named COPYING for license details
*/
/** @file
Tests for TestUtil
*/
#include <Lintel/TestUtil.hpp>
int main(int, char **) {
INVARIANT(true, "...");
TEST_INVARIANTMSG(FATAL_ERROR("die now"), "die now");
TEST_INVARIANTMSG(INVARIANT(false, boost::format("foo %s") % "bar"), "foo bar");
TEST_INVARIANTMSG(SINVARIANT(false), "No additional details provided");
TEST_INVARIANTMSG(FATAL_ERROR(boost::format("%1% %d")),
"Exception evaluating boost::format(\"%1% %d\")");
TEST_INVARIANTMSG(INVARIANT(1 == 0, "expected to fail"), "wrong test msg");
FATAL_ERROR("should not get here");
return 0;
}
| 28.423077 | 84 | 0.641407 | sbu-fsl |
241dd3108e9fd07f8e6ab5591a1775f9154f943c | 10,320 | cpp | C++ | graph/L3/src/op_wcc.cpp | Geekdude/Vitis_Libraries | bca52cee88c07e9ccbec90c00e6df98f4b450ec1 | [
"Apache-2.0"
] | 1 | 2021-04-19T20:40:02.000Z | 2021-04-19T20:40:02.000Z | graph/L3/src/op_wcc.cpp | Geekdude/Vitis_Libraries | bca52cee88c07e9ccbec90c00e6df98f4b450ec1 | [
"Apache-2.0"
] | null | null | null | graph/L3/src/op_wcc.cpp | Geekdude/Vitis_Libraries | bca52cee88c07e9ccbec90c00e6df98f4b450ec1 | [
"Apache-2.0"
] | 1 | 2021-04-28T05:58:38.000Z | 2021-04-28T05:58:38.000Z | /*
* Copyright 2020 Xilinx, 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
#ifndef _XF_GRAPH_L3_OP_WCC_CPP_
#define _XF_GRAPH_L3_OP_WCC_CPP_
#include "op_wcc.hpp"
namespace xf {
namespace graph {
namespace L3 {
void createHandleWCC(clHandle& handle, const char* kernelName, const char* pXclbin, int32_t IDDevice) {
// Platform related operations
std::vector<cl::Device> devices = xcl::get_xil_devices();
handle.device = devices[IDDevice];
handle.context = cl::Context(handle.device);
handle.q = cl::CommandQueue(handle.context, handle.device,
CL_QUEUE_PROFILING_ENABLE | CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE);
std::string devName = handle.device.getInfo<CL_DEVICE_NAME>();
printf("INFO: Found Device=%s\n", devName.c_str());
handle.xclBins = xcl::import_binary_file(pXclbin);
std::vector<cl::Device> devices2;
devices2.push_back(handle.device);
handle.program = cl::Program(handle.context, devices2, handle.xclBins);
}
uint32_t opWCC::cuPerBoardWCC;
uint32_t opWCC::dupNmWCC;
void opWCC::setHWInfo(uint32_t numDev, uint32_t CUmax) {
maxCU = CUmax;
deviceNm = numDev;
cuPerBoardWCC = maxCU / deviceNm;
handles = new clHandle[CUmax];
};
void opWCC::freeWCC() {
for (int i = 0; i < maxCU; ++i) {
delete[] handles[i].buffer;
}
delete[] handles;
};
void opWCC::cuRelease(xrmContext* ctx, xrmCuResource* resR) {
while (!xrmCuRelease(ctx, resR)) {
};
free(resR);
};
void opWCC::init(char* kernelName, char* xclbinFile, uint32_t* deviceIDs, uint32_t* cuIDs, unsigned int requestLoad) {
dupNmWCC = 100 / requestLoad;
cuPerBoardWCC /= dupNmWCC;
uint32_t bufferNm = 8;
unsigned int cnt = 0;
unsigned int cntCU = 0;
unsigned int* handleID = new unsigned int[maxCU];
handleID[0] = cnt;
handles[0].deviceID = deviceIDs[0];
handles[0].cuID = cuIDs[0];
handles[0].dupID = 0;
std::thread th[maxCU];
// th[0] = std::thread(&createHandleWCC, std::ref(handles[cnt]), kernelName, xclbinFile, deviceIDs[cnt]);
createHandleWCC(handles[cnt], kernelName, xclbinFile, deviceIDs[cnt]);
handles[cnt].buffer = new cl::Buffer[bufferNm];
unsigned int prev = deviceIDs[0];
unsigned int prevCU = cuIDs[0];
deviceOffset.push_back(0);
for (int i = 1; i < maxCU; ++i) {
handles[i].deviceID = deviceIDs[i];
handles[i].cuID = cuIDs[i];
handles[i].dupID = i % dupNmWCC;
// th[i] = std::thread(&createHandleWCC, std::ref(handles[i]), kernelName, xclbinFile, deviceIDs[i]);
createHandleWCC(handles[i], kernelName, xclbinFile, deviceIDs[i]);
handles[i].buffer = new cl::Buffer[bufferNm];
if (deviceIDs[i] != prev) {
prev = deviceIDs[i];
deviceOffset.push_back(i);
}
}
delete[] handleID;
}
void opWCC::migrateMemObj(clHandle* hds,
bool type,
unsigned int num_runs,
std::vector<cl::Memory>& ob,
std::vector<cl::Event>* evIn,
cl::Event* evOut) {
for (int i = 0; i < num_runs; ++i) {
hds[0].q.enqueueMigrateMemObjects(ob, type, evIn, evOut); // 0 : migrate from host to dev
}
};
void opWCC::bufferInit(clHandle* hds,
std::string instanceName0,
xf::graph::Graph<uint32_t, uint32_t> g,
uint32_t* offsetsG2,
uint32_t* indicesG2,
uint32_t* offsetsTmp1,
uint32_t* offsetsTmp2,
uint32_t* queue,
uint32_t* result,
cl::Kernel& kernel0,
std::vector<cl::Memory>& ob_in,
std::vector<cl::Memory>& ob_out) {
cl::Device device = hds[0].device;
const char* instanceName = instanceName0.c_str();
// Creating Context and Command Queue for selected Device
cl::Context context = hds[0].context;
cl::CommandQueue q = hds[0].q;
std::string devName = device.getInfo<CL_DEVICE_NAME>();
printf("INFO: Found Device=%s\n", devName.c_str());
std::vector<cl::Device> devices;
devices.push_back(hds[0].device);
cl::Program program = hds[0].program;
kernel0 = cl::Kernel(program, instanceName);
std::cout << "INFO: Kernel has been created" << std::endl;
std::vector<cl_mem_ext_ptr_t> mext_in = std::vector<cl_mem_ext_ptr_t>(8);
mext_in[0] = {(unsigned int)(3) | XCL_MEM_TOPOLOGY, g.offsetsCSR, kernel0()};
mext_in[1] = {(unsigned int)(2) | XCL_MEM_TOPOLOGY, g.indicesCSR, kernel0()};
mext_in[2] = {(unsigned int)(6) | XCL_MEM_TOPOLOGY, offsetsG2, kernel0()};
mext_in[3] = {(unsigned int)(5) | XCL_MEM_TOPOLOGY, indicesG2, kernel0()};
mext_in[4] = {(unsigned int)(7) | XCL_MEM_TOPOLOGY, offsetsTmp1, kernel0()};
mext_in[5] = {(unsigned int)(8) | XCL_MEM_TOPOLOGY, offsetsTmp2, kernel0()};
mext_in[6] = {(unsigned int)(10) | XCL_MEM_TOPOLOGY, queue, kernel0()};
mext_in[7] = {(unsigned int)(12) | XCL_MEM_TOPOLOGY, result, kernel0()};
uint32_t numVertices = g.nodeNum;
uint32_t numEdges = g.edgeNum;
// create device buffer and map dev buf to host buf
hds[0].buffer[1] = cl::Buffer(context, CL_MEM_EXT_PTR_XILINX | CL_MEM_USE_HOST_PTR | CL_MEM_READ_WRITE,
sizeof(uint32_t) * numEdges, &mext_in[1]);
hds[0].buffer[0] = cl::Buffer(context, CL_MEM_EXT_PTR_XILINX | CL_MEM_USE_HOST_PTR | CL_MEM_READ_WRITE,
sizeof(uint32_t) * (numVertices + 1), &mext_in[0]);
hds[0].buffer[3] = cl::Buffer(context, CL_MEM_EXT_PTR_XILINX | CL_MEM_USE_HOST_PTR | CL_MEM_READ_WRITE,
sizeof(uint32_t) * numEdges, &mext_in[3]);
hds[0].buffer[2] = cl::Buffer(context, CL_MEM_EXT_PTR_XILINX | CL_MEM_USE_HOST_PTR | CL_MEM_READ_WRITE,
sizeof(uint32_t) * (numVertices + 1), &mext_in[2]);
hds[0].buffer[4] = cl::Buffer(context, CL_MEM_EXT_PTR_XILINX | CL_MEM_USE_HOST_PTR | CL_MEM_READ_WRITE,
sizeof(uint32_t) * (numVertices + 1), &mext_in[4]);
hds[0].buffer[5] = cl::Buffer(context, CL_MEM_EXT_PTR_XILINX | CL_MEM_USE_HOST_PTR | CL_MEM_READ_WRITE,
sizeof(uint32_t) * (numVertices + 1), &mext_in[5]);
hds[0].buffer[6] = cl::Buffer(context, CL_MEM_EXT_PTR_XILINX | CL_MEM_USE_HOST_PTR | CL_MEM_READ_WRITE,
sizeof(uint32_t) * numVertices, &mext_in[6]);
hds[0].buffer[7] = cl::Buffer(context, CL_MEM_EXT_PTR_XILINX | CL_MEM_USE_HOST_PTR | CL_MEM_READ_WRITE,
sizeof(uint32_t) * numVertices, &mext_in[7]);
ob_in.push_back(hds[0].buffer[0]);
ob_in.push_back(hds[0].buffer[1]);
ob_out.push_back(hds[0].buffer[7]);
kernel0.setArg(0, g.edgeNum); // edge number
kernel0.setArg(1, g.nodeNum); // node number
kernel0.setArg(2, hds[0].buffer[1]); // indicee
kernel0.setArg(3, hds[0].buffer[0]); // offsets
kernel0.setArg(4, hds[0].buffer[3]); // indices G2
kernel0.setArg(5, hds[0].buffer[3]); // indices G2
kernel0.setArg(6, hds[0].buffer[2]); // offsets G2
kernel0.setArg(7, hds[0].buffer[4]); // offsetsTmp1
kernel0.setArg(8, hds[0].buffer[5]); // offsetsTmp2
kernel0.setArg(9, hds[0].buffer[6]); // queue
kernel0.setArg(10, hds[0].buffer[6]); // queue
kernel0.setArg(11, hds[0].buffer[7]); // result
kernel0.setArg(12, hds[0].buffer[7]); // result
};
int opWCC::cuExecute(
clHandle* hds, cl::Kernel& kernel0, unsigned int num_runs, std::vector<cl::Event>* evIn, cl::Event* evOut) {
for (int i = 0; i < num_runs; ++i) {
hds[0].q.enqueueTask(kernel0, evIn, evOut);
}
return 0;
}
int opWCC::compute(unsigned int deviceID,
unsigned int cuID,
unsigned int channelID,
xrmContext* ctx,
xrmCuResource* resR,
std::string instanceName,
clHandle* handles,
xf::graph::Graph<uint32_t, uint32_t> g,
uint32_t* result) {
clHandle* hds = &handles[channelID + cuID * dupNmWCC + deviceID * dupNmWCC * cuPerBoardWCC];
cl::Kernel kernel0;
std::vector<cl::Memory> ob_in;
std::vector<cl::Memory> ob_out;
unsigned int num_runs = 1;
uint32_t numVertices = g.nodeNum;
uint32_t numEdges = g.edgeNum;
uint32_t* indicesG2 = aligned_alloc<uint32_t>(numEdges);
uint32_t* offsetsG2 = aligned_alloc<uint32_t>(numVertices + 1);
uint32_t* offsetsTmp1 = aligned_alloc<uint32_t>(numVertices + 1);
uint32_t* offsetsTmp2 = aligned_alloc<uint32_t>(numVertices + 1);
uint32_t* queue = aligned_alloc<uint32_t>(numVertices);
std::vector<cl::Event> events_write(1);
std::vector<cl::Event> events_kernel(num_runs);
std::vector<cl::Event> events_read(1);
bufferInit(hds, instanceName, g, offsetsG2, indicesG2, offsetsTmp1, offsetsTmp2, queue, result, kernel0, ob_in,
ob_out);
migrateMemObj(hds, 0, num_runs, ob_in, nullptr, &events_write[0]);
int ret = cuExecute(hds, kernel0, num_runs, &events_write, &events_kernel[0]);
migrateMemObj(hds, 1, num_runs, ob_out, &events_kernel, &events_read[0]);
events_read[0].wait();
cuRelease(ctx, resR);
free(indicesG2);
free(offsetsG2);
free(offsetsTmp1);
free(offsetsTmp2);
free(queue);
return ret;
};
event<int> opWCC::addwork(xf::graph::Graph<uint32_t, uint32_t> g, uint32_t* result) {
return createL3(task_queue[0], &(compute), handles, g, result);
};
} // L3
} // graph
} // xf
#endif
| 40 | 118 | 0.624419 | Geekdude |
241df5f22dec7e44a0926c15f67f537cd3d26184 | 60 | cpp | C++ | src/cpp/NgxString.cpp | Nov11/nginx_with_cpp | 7a8524f4685753cd7e315c181aa587b3f74fc3c9 | [
"BSD-2-Clause"
] | 1 | 2019-01-25T07:01:03.000Z | 2019-01-25T07:01:03.000Z | src/cpp/NgxString.cpp | Nov11/nginx_with_cpp | 7a8524f4685753cd7e315c181aa587b3f74fc3c9 | [
"BSD-2-Clause"
] | null | null | null | src/cpp/NgxString.cpp | Nov11/nginx_with_cpp | 7a8524f4685753cd7e315c181aa587b3f74fc3c9 | [
"BSD-2-Clause"
] | null | null | null | //
// Created by c6s on 18-1-13.
//
#include "NgxString.h"
| 10 | 29 | 0.6 | Nov11 |
241e569744509577c8c1fa11fd748abb32899cfa | 525 | cpp | C++ | targets/android/jni/EMBEDDED_LINK_TEST.cpp | additionsec/as_mobileawareness | 8fbd3a4debc75639518045698f54416cd3ab047a | [
"Apache-2.0"
] | 4 | 2019-05-07T02:29:48.000Z | 2019-07-22T22:11:57.000Z | targets/android/jni/EMBEDDED_LINK_TEST.cpp | additionsec/as_mobileawareness | 8fbd3a4debc75639518045698f54416cd3ab047a | [
"Apache-2.0"
] | null | null | null | targets/android/jni/EMBEDDED_LINK_TEST.cpp | additionsec/as_mobileawareness | 8fbd3a4debc75639518045698f54416cd3ab047a | [
"Apache-2.0"
] | 3 | 2019-03-21T06:47:01.000Z | 2019-12-04T07:32:09.000Z | #include <jni.h>
#include <stdint.h>
#include "as_mobileawareness.h"
extern "C" {
JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved)
{
// one of everything, for linking purposes
jint ret = AS_JNI_OnLoad(vm, reserved);
uint8_t uuid[32];
ret = AS_UUID_Default_Serial(uuid);
ret = AS_Initialize( NULL, uuid, NULL, 0, NULL );
ret = AS_Register_Identity("");
ret = AS_Send_Message(2,"");
long lret = AS_Heartbeat(42);
AS_Login_Status(1);
AS_Network_Reachability();
uint32_t v = AS_Version();
}
}
| 21 | 61 | 0.700952 | additionsec |
241f4f92829d38940c6b9d78a7b4361262134f77 | 16,173 | cpp | C++ | src/lib/asn1/ASN1Writer.cpp | rgoliver/connectedhomeip | 1bbbed11464a4895a4c50c519c67e81b490ac06d | [
"Apache-2.0"
] | 2 | 2021-03-30T00:47:43.000Z | 2021-05-14T08:54:59.000Z | src/lib/asn1/ASN1Writer.cpp | rgoliver/connectedhomeip | 1bbbed11464a4895a4c50c519c67e81b490ac06d | [
"Apache-2.0"
] | null | null | null | src/lib/asn1/ASN1Writer.cpp | rgoliver/connectedhomeip | 1bbbed11464a4895a4c50c519c67e81b490ac06d | [
"Apache-2.0"
] | null | null | null | /*
*
* Copyright (c) 2020-2021 Project CHIP Authors
* Copyright (c) 2013-2017 Nest Labs, 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.
*/
/**
* @file
* This file implements an object for writing Abstract Syntax
* Notation One (ASN.1) encoded data.
*
*/
#ifndef __STDC_LIMIT_MACROS
#define __STDC_LIMIT_MACROS
#endif
#include <ctype.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <asn1/ASN1.h>
#include <core/CHIPCore.h>
#include <core/CHIPEncoding.h>
#include <core/CHIPTLV.h>
#include <support/CodeUtils.h>
namespace chip {
namespace ASN1 {
using namespace chip::Encoding;
enum
{
kLengthFieldReserveSize = 5,
kMaxElementLength = INT32_MAX,
kUnkownLength = -1,
kUnknownLengthMarker = 0xFF
};
void ASN1Writer::Init(uint8_t * buf, uint32_t maxLen)
{
mBuf = buf;
mWritePoint = buf;
mBufEnd = buf + maxLen;
mBufEnd = reinterpret_cast<uint8_t *>(reinterpret_cast<uintptr_t>(mBufEnd) & ~3); // align on 32bit boundary
mDeferredLengthList = reinterpret_cast<uint8_t **>(mBufEnd);
}
void ASN1Writer::InitNullWriter(void)
{
mBuf = nullptr;
mWritePoint = nullptr;
mBufEnd = nullptr;
mDeferredLengthList = nullptr;
}
ASN1_ERROR ASN1Writer::Finalize()
{
if (mBuf != nullptr)
{
uint8_t * compactPoint = mBuf;
uint8_t * spanStart = mBuf;
for (uint8_t ** listEntry = reinterpret_cast<uint8_t **>(mBufEnd); listEntry > mDeferredLengthList;)
{
uint8_t * lenField = *--listEntry;
uint8_t lenFieldFirstByte = *lenField;
if (lenFieldFirstByte == kUnknownLengthMarker)
return ASN1_ERROR_INVALID_STATE;
uint8_t lenOfLen = (lenFieldFirstByte < 128) ? 1 : (lenFieldFirstByte & 0x7f) + 1;
uint8_t * spanEnd = lenField + lenOfLen;
if (spanStart == compactPoint)
compactPoint = spanEnd;
else
{
uint32_t spanLen = spanEnd - spanStart;
memmove(compactPoint, spanStart, spanLen);
compactPoint += spanLen;
}
spanStart = lenField + kLengthFieldReserveSize;
}
if (spanStart > compactPoint)
{
uint32_t spanLen = mWritePoint - spanStart;
memmove(compactPoint, spanStart, spanLen);
compactPoint += spanLen;
}
mWritePoint = compactPoint;
}
return ASN1_NO_ERROR;
}
uint16_t ASN1Writer::GetLengthWritten() const
{
return (mBuf != nullptr) ? mWritePoint - mBuf : 0;
}
ASN1_ERROR ASN1Writer::PutInteger(int64_t val)
{
uint8_t encodedVal[8];
uint8_t valStart, valLen;
BigEndian::Put64(encodedVal, static_cast<uint64_t>(val));
for (valStart = 0; valStart < 7; valStart++)
{
if (encodedVal[valStart] == 0x00 && (encodedVal[valStart + 1] & 0x80) == 0)
continue;
if (encodedVal[valStart] == 0xFF && (encodedVal[valStart + 1] & 0x80) == 0x80)
continue;
break;
}
valLen = 8 - valStart;
return PutValue(kASN1TagClass_Universal, kASN1UniversalTag_Integer, false, encodedVal + valStart, valLen);
}
ASN1_ERROR ASN1Writer::PutBoolean(bool val)
{
// Do nothing for a null writer.
VerifyOrReturnError(mBuf != nullptr, ASN1_NO_ERROR);
ReturnErrorOnFailure(EncodeHead(kASN1TagClass_Universal, kASN1UniversalTag_Boolean, false, 1));
*mWritePoint++ = (val) ? 0xFF : 0;
return ASN1_NO_ERROR;
}
ASN1_ERROR ASN1Writer::PutObjectId(const uint8_t * val, uint16_t valLen)
{
return PutValue(kASN1TagClass_Universal, kASN1UniversalTag_ObjectId, false, val, valLen);
}
ASN1_ERROR ASN1Writer::PutString(uint32_t tag, const char * val, uint16_t valLen)
{
return PutValue(kASN1TagClass_Universal, tag, false, (const uint8_t *) val, valLen);
}
ASN1_ERROR ASN1Writer::PutOctetString(const uint8_t * val, uint16_t valLen)
{
return PutValue(kASN1TagClass_Universal, kASN1UniversalTag_OctetString, false, val, valLen);
}
ASN1_ERROR ASN1Writer::PutOctetString(uint8_t cls, uint32_t tag, const uint8_t * val, uint16_t valLen)
{
return PutValue(cls, tag, false, val, valLen);
}
ASN1_ERROR ASN1Writer::PutOctetString(uint8_t cls, uint32_t tag, chip::TLV::TLVReader & val)
{
return PutValue(cls, tag, false, val);
}
static uint8_t ReverseBits(uint8_t v)
{
// swap adjacent bits
v = ((v >> 1) & 0x55) | ((v & 0x55) << 1);
// swap adjacent bit pairs
v = ((v >> 2) & 0x33) | ((v & 0x33) << 2);
// swap nibbles
v = (v >> 4) | (v << 4);
return v;
}
static uint8_t HighestBit(uint32_t v)
{
uint32_t highestBit = 0;
if (v > 0xFFFF)
{
highestBit = 16;
v >>= 16;
}
if (v > 0xFF)
{
highestBit |= 8;
v >>= 8;
}
if (v > 0xF)
{
highestBit |= 4;
v >>= 4;
}
if (v > 0x3)
{
highestBit |= 2;
v >>= 2;
}
highestBit |= (v >> 1);
return highestBit;
}
ASN1_ERROR ASN1Writer::PutBitString(uint32_t val)
{
uint8_t len;
// Do nothing for a null writer.
VerifyOrReturnError(mBuf != nullptr, ASN1_NO_ERROR);
if (val == 0)
len = 1;
else if (val < 256)
len = 2;
else if (val < 65536)
len = 3;
else if (val < (1 << 24))
len = 4;
else
len = 5;
ReturnErrorOnFailure(EncodeHead(kASN1TagClass_Universal, kASN1UniversalTag_BitString, false, len));
if (val == 0)
mWritePoint[0] = 0;
else
{
mWritePoint[1] = ReverseBits(static_cast<uint8_t>(val));
if (len >= 3)
{
val >>= 8;
mWritePoint[2] = ReverseBits(static_cast<uint8_t>(val));
if (len >= 4)
{
val >>= 8;
mWritePoint[3] = ReverseBits(static_cast<uint8_t>(val));
if (len == 5)
{
val >>= 8;
mWritePoint[4] = ReverseBits(static_cast<uint8_t>(val));
}
}
}
mWritePoint[0] = 7 - HighestBit(val);
}
mWritePoint += len;
return ASN1_NO_ERROR;
}
ASN1_ERROR ASN1Writer::PutBitString(uint8_t unusedBitCount, const uint8_t * encodedBits, uint16_t encodedBitsLen)
{
// Do nothing for a null writer.
VerifyOrReturnError(mBuf != nullptr, ASN1_NO_ERROR);
ReturnErrorOnFailure(EncodeHead(kASN1TagClass_Universal, kASN1UniversalTag_BitString, false, encodedBitsLen + 1));
*mWritePoint++ = unusedBitCount;
memcpy(mWritePoint, encodedBits, encodedBitsLen);
mWritePoint += encodedBitsLen;
return ASN1_NO_ERROR;
}
ASN1_ERROR ASN1Writer::PutBitString(uint8_t unusedBitCount, chip::TLV::TLVReader & encodedBits)
{
uint32_t encodedBitsLen;
// Do nothing for a null writer.
VerifyOrReturnError(mBuf != nullptr, ASN1_NO_ERROR);
encodedBitsLen = encodedBits.GetLength();
ReturnErrorOnFailure(EncodeHead(kASN1TagClass_Universal, kASN1UniversalTag_BitString, false, encodedBitsLen + 1));
*mWritePoint++ = unusedBitCount;
encodedBits.GetBytes(mWritePoint, encodedBitsLen);
mWritePoint += encodedBitsLen;
return ASN1_NO_ERROR;
}
static void itoa2(uint32_t val, uint8_t * buf)
{
buf[1] = '0' + (val % 10);
val /= 10;
buf[0] = '0' + (val % 10);
}
ASN1_ERROR ASN1Writer::PutTime(const ASN1UniversalTime & val)
{
uint8_t buf[15];
itoa2(val.Year / 100, buf);
itoa2(val.Year, buf + 2);
itoa2(val.Month, buf + 4);
itoa2(val.Day, buf + 6);
itoa2(val.Hour, buf + 8);
itoa2(val.Minute, buf + 10);
itoa2(val.Second, buf + 12);
buf[14] = 'Z';
// X.509/RFC5280 mandates that times before 2050 UTC must be encoded as ASN.1 UTCTime values, while
// times equal or greater than 2050 must be encoded as GeneralizedTime values. The only difference
// (in the context of X.509 DER) is that GeneralizedTimes are encoded with a 4 digit year, while
// UTCTimes are encoded with a two-digit year.
//
if (val.Year >= 2050)
return PutValue(kASN1TagClass_Universal, kASN1UniversalTag_GeneralizedTime, false, buf, 15);
else
return PutValue(kASN1TagClass_Universal, kASN1UniversalTag_UTCTime, false, buf + 2, 13);
}
ASN1_ERROR ASN1Writer::PutNull()
{
return EncodeHead(kASN1TagClass_Universal, kASN1UniversalTag_Null, false, 0);
}
ASN1_ERROR ASN1Writer::StartConstructedType(uint8_t cls, uint32_t tag)
{
return EncodeHead(cls, tag, true, kUnkownLength);
}
ASN1_ERROR ASN1Writer::EndConstructedType()
{
return WriteDeferredLength();
}
ASN1_ERROR ASN1Writer::StartEncapsulatedType(uint8_t cls, uint32_t tag, bool bitStringEncoding)
{
// Do nothing for a null writer.
VerifyOrReturnError(mBuf != nullptr, ASN1_NO_ERROR);
ReturnErrorOnFailure(EncodeHead(cls, tag, false, kUnkownLength));
// If the encapsulating type is BIT STRING, encode the unused bit count field. Since the BIT
// STRING contains an ASN.1 DER encoding, and ASN.1 DER encodings are always multiples of 8 bits,
// the unused bit count is always 0.
if (bitStringEncoding)
{
if (mWritePoint == reinterpret_cast<uint8_t *>(mDeferredLengthList))
return ASN1_ERROR_OVERFLOW;
*mWritePoint++ = 0;
}
return ASN1_NO_ERROR;
}
ASN1_ERROR ASN1Writer::EndEncapsulatedType()
{
return WriteDeferredLength();
}
ASN1_ERROR ASN1Writer::PutValue(uint8_t cls, uint32_t tag, bool isConstructed, const uint8_t * val, uint16_t valLen)
{
// Do nothing for a null writer.
VerifyOrReturnError(mBuf != nullptr, ASN1_NO_ERROR);
ReturnErrorOnFailure(EncodeHead(cls, tag, isConstructed, valLen));
memcpy(mWritePoint, val, valLen);
mWritePoint += valLen;
return ASN1_NO_ERROR;
}
ASN1_ERROR ASN1Writer::PutValue(uint8_t cls, uint32_t tag, bool isConstructed, chip::TLV::TLVReader & val)
{
uint32_t valLen;
// Do nothing for a null writer.
VerifyOrReturnError(mBuf != nullptr, ASN1_NO_ERROR);
valLen = val.GetLength();
ReturnErrorOnFailure(EncodeHead(cls, tag, isConstructed, valLen));
val.GetBytes(mWritePoint, valLen);
mWritePoint += valLen;
return ASN1_NO_ERROR;
}
ASN1_ERROR ASN1Writer::EncodeHead(uint8_t cls, uint32_t tag, bool isConstructed, int32_t len)
{
uint8_t bytesForLen;
uint32_t totalLen;
// Do nothing for a null writer.
VerifyOrReturnError(mBuf != nullptr, ASN1_NO_ERROR);
// Only tags <= 31 supported. The implication of this is that encoded tags are exactly 1 byte long.
VerifyOrReturnError(tag <= 0x1F, ASN1_ERROR_UNSUPPORTED_ENCODING);
// Only positive and kUnkownLength values are supported for len input.
VerifyOrReturnError(len >= 0 || len == kUnkownLength, ASN1_ERROR_UNSUPPORTED_ENCODING);
// Compute the number of bytes required to encode the length.
bytesForLen = BytesForLength(len);
// If the element length is unknown, allocate a new entry in the deferred-length list.
//
// The deferred-length list is a list of "pointers" (represented as offsets into mBuf)
// to length fields for which the length of the element was unknown at the time the element
// head was written. Examples include constructed types such as SEQUENCE and SET, as well
// non-constructed types that encapsulate other ASN.1 types (e.g. OCTET STRINGS that contain
// BER/DER encodings). The final lengths are filled in later, at the time the encoding is
// complete (e.g. when EndConstructed() is called).
//
if (len == kUnkownLength)
mDeferredLengthList--;
// Make sure there's enough space to encode the entire value without bumping into the deferred length
// list at the end of the buffer.
totalLen = 1 + bytesForLen + (len != kUnkownLength ? len : 0);
VerifyOrReturnError((mWritePoint + totalLen) <= reinterpret_cast<uint8_t *>(mDeferredLengthList), ASN1_ERROR_OVERFLOW);
// Write the tag byte.
*mWritePoint++ = cls | (isConstructed ? 0x20 : 0) | tag;
// Encode the length if it is known.
if (len != kUnkownLength)
EncodeLength(mWritePoint, bytesForLen, len);
// ... otherwise place a marker in the first byte of the length to indicate that the length is unknown
// and save a pointer to the length field in the deferred-length list.
else
{
*mWritePoint = kUnknownLengthMarker;
*mDeferredLengthList = mWritePoint;
}
mWritePoint += bytesForLen;
return ASN1_NO_ERROR;
}
ASN1_ERROR ASN1Writer::WriteDeferredLength()
{
uint8_t ** listEntry;
uint32_t lenAdj;
// Do nothing for a null writer.
VerifyOrReturnError(mBuf != nullptr, ASN1_NO_ERROR);
lenAdj = kLengthFieldReserveSize;
// Scan the deferred-length list in reverse order looking for the most recent entry where
// the length is still unknown. This entry represents the "container" element whose encoding
// is now complete.
for (listEntry = mDeferredLengthList; listEntry < reinterpret_cast<uint8_t **>(mBufEnd); listEntry++)
{
// Get a pointer to the deferred-length field.
uint8_t * lenField = *listEntry;
// Get the first byte of the length field.
uint8_t lenFieldFirstByte = *lenField;
// If the length is marked as unknown...
if (lenFieldFirstByte == kUnknownLengthMarker)
{
// Compute the final length of the element's value (3 = bytes reserved for length).
uint32_t elemLen = (mWritePoint - lenField) - lenAdj;
// Return an error if the length exceeds the maximum value that can be encoded in the
// space reserved for the length.
VerifyOrReturnError(elemLen <= kMaxElementLength, ASN1_ERROR_LENGTH_OVERFLOW);
// Encode the final length of the element, overwriting the unknown length marker
// in the process. Note that the number of bytes consumed by the final length field
// may be smaller than the space that was reserved for the field. This will be fixed
// up when the Finalize() method is called.
uint8_t bytesForLen = BytesForLength(static_cast<int32_t>(elemLen));
EncodeLength(lenField, bytesForLen, elemLen);
return ASN1_NO_ERROR;
}
else
{
uint8_t bytesForLen = (lenFieldFirstByte < 128) ? 1 : (lenFieldFirstByte & 0x7f) + 1;
lenAdj += (kLengthFieldReserveSize - bytesForLen);
}
}
return ASN1_ERROR_INVALID_STATE;
}
/**
* Returns the number of bytes required to encode the length value.
*
* @param[in] len Parameter, which encoding length to be calculated.
*
* @return number of bytes required to encode the length value.
*/
uint8_t ASN1Writer::BytesForLength(int32_t len)
{
if (len == kUnkownLength)
return kLengthFieldReserveSize;
if (len < 128)
return 1;
if (len < 256)
return 2;
if (len < 65536)
return 3;
if (len < (1 << 24))
return 4;
return 5;
}
void ASN1Writer::EncodeLength(uint8_t * buf, uint8_t bytesForLen, int32_t lenToEncode)
{
if (bytesForLen == 1)
buf[0] = static_cast<uint8_t>(lenToEncode);
else
{
--bytesForLen;
buf[0] = 0x80 | bytesForLen;
do
{
buf[bytesForLen] = static_cast<uint8_t>(lenToEncode);
lenToEncode >>= 8;
} while (--bytesForLen);
}
}
} // namespace ASN1
} // namespace chip
| 29.675229 | 124 | 0.649292 | rgoliver |
2423c80c29f267f39159a8b40e1dc41ac11b59e1 | 12,247 | cpp | C++ | PhysX_3.4/Source/LowLevel/common/src/pipeline/PxcContactCache.cpp | RyanTorant/simple-physx | a065a9c734c134074c63c80a9109a398b22d040c | [
"Unlicense"
] | 1 | 2019-12-09T16:03:55.000Z | 2019-12-09T16:03:55.000Z | PhysX_3.4/Source/LowLevel/common/src/pipeline/PxcContactCache.cpp | RyanTorant/simple-physx | a065a9c734c134074c63c80a9109a398b22d040c | [
"Unlicense"
] | null | null | null | PhysX_3.4/Source/LowLevel/common/src/pipeline/PxcContactCache.cpp | RyanTorant/simple-physx | a065a9c734c134074c63c80a9109a398b22d040c | [
"Unlicense"
] | null | null | null | // This code contains NVIDIA Confidential Information and is disclosed to you
// under a form of NVIDIA software license agreement provided separately to you.
//
// Notice
// NVIDIA Corporation and its licensors retain all intellectual property and
// proprietary rights in and to this software and related documentation and
// any modifications thereto. Any use, reproduction, disclosure, or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA Corporation is strictly prohibited.
//
// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
//
// Information and code furnished is believed to be accurate and reliable.
// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
// information or for any infringement of patents or other rights of third parties that may
// result from its use. No license is granted by implication or otherwise under any patent
// or patent rights of NVIDIA Corporation. Details are subject to change without notice.
// This code supersedes and replaces all information previously supplied.
// NVIDIA Corporation products are not authorized for use as critical
// components in life support devices or systems without express written approval of
// NVIDIA Corporation.
//
// Copyright (c) 2008-2018 NVIDIA Corporation. All rights reserved.
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
#include "PxcContactCache.h"
#include "PxsContactManager.h"
#include "PsUtilities.h"
#include "PxcNpCache.h"
using namespace physx;
using namespace Gu;
//#define ENABLE_CONTACT_CACHE_STATS
#ifdef ENABLE_CONTACT_CACHE_STATS
static PxU32 gNbCalls;
static PxU32 gNbHits;
#endif
void PxcClearContactCacheStats()
{
#ifdef ENABLE_CONTACT_CACHE_STATS
gNbCalls = 0;
gNbHits = 0;
#endif
}
void PxcDisplayContactCacheStats()
{
#ifdef ENABLE_CONTACT_CACHE_STATS
pxPrintf("%d|%d (%f)\n", gNbHits, gNbCalls, gNbCalls ? float(gNbHits)/float(gNbCalls) : 0.0f);
#endif
}
namespace physx
{
const bool g_CanUseContactCache[][PxGeometryType::eGEOMETRY_COUNT] =
{
//PxGeometryType::eSPHERE
{
false, //PxcContactSphereSphere
false, //PxcContactSpherePlane
true, //PxcContactSphereCapsule
false, //PxcContactSphereBox
true, //PxcContactSphereConvex
true, //PxcContactSphereMesh
true, //PxcContactSphereHeightField
},
//PxGeometryType::ePLANE
{
false, //-
false, //PxcInvalidContactPair
true, //PxcContactPlaneCapsule
true, //PxcContactPlaneBox
true, //PxcContactPlaneConvex
false, //PxcInvalidContactPair
false, //PxcInvalidContactPair
},
//PxGeometryType::eCAPSULE
{
false, //-
false, //-
true, //PxcContactCapsuleCapsule
true, //PxcContactCapsuleBox
true, //PxcContactCapsuleConvex
true, //PxcContactCapsuleMesh
true, //PxcContactCapsuleHeightField
},
//PxGeometryType::eBOX
{
false, //-
false, //-
false, //-
true, //PxcContactBoxBox
true, //PxcContactBoxConvex
true, //PxcContactBoxMesh
true, //PxcContactBoxHeightField
},
//PxGeometryType::eCONVEXMESH
{
false, //-
false, //-
false, //-
false, //-
true, //PxcContactConvexConvex
true, //PxcContactConvexMesh2
true, //PxcContactConvexHeightField
},
//PxGeometryType::eTRIANGLEMESH
{
false, //-
false, //-
false, //-
false, //-
false, //-
false, //PxcInvalidContactPair
false, //PxcInvalidContactPair
},
//PxGeometryType::eHEIGHTFIELD
{
false, //-
false, //-
false, //-
false, //-
false, //-
false, //-
false, //PxcInvalidContactPair
},
};
}
static PX_FORCE_INLINE void updateContact( Gu::ContactPoint& dst, const PxcLocalContactsCache& contactsData,
const Cm::Matrix34& world0, const Cm::Matrix34& world1,
const PxVec3& point, const PxVec3& normal, float separation)
{
const PxVec3 tmp0 = contactsData.mTransform0.transformInv(point);
const PxVec3 worldpt0 = world0.transform(tmp0);
const PxVec3 tmp1 = contactsData.mTransform1.transformInv(point);
const PxVec3 worldpt1 = world1.transform(tmp1);
const PxVec3 motion = worldpt0 - worldpt1;
dst.normal = normal;
dst.point = (worldpt0 + worldpt1)*0.5f;
//dst.point = point;
dst.separation = separation + motion.dot(normal);
}
static PX_FORCE_INLINE void prefetchData128(PxU8* PX_RESTRICT ptr, PxU32 size)
{
// PT: always prefetch the cache line containing our address (which unfortunately won't be aligned to 128 most of the time)
Ps::prefetchLine(ptr, 0);
// PT: compute start offset of our data within its cache line
const PxU32 startOffset = PxU32(size_t(ptr)&127);
// PT: prefetch next cache line if needed
if(startOffset+size>128)
Ps::prefetchLine(ptr+128, 0);
}
static PX_FORCE_INLINE PxU8* outputToCache(PxU8* PX_RESTRICT bytes, const PxVec3& v)
{
*reinterpret_cast<PxVec3*>(bytes) = v;
return bytes + sizeof(PxVec3);
}
static PX_FORCE_INLINE PxU8* outputToCache(PxU8* PX_RESTRICT bytes, PxReal v)
{
*reinterpret_cast<PxReal*>(bytes) = v;
return bytes + sizeof(PxReal);
}
static PX_FORCE_INLINE PxU8* outputToCache(PxU8* PX_RESTRICT bytes, PxU32 v)
{
*reinterpret_cast<PxU32*>(bytes) = v;
return bytes + sizeof(PxU32);
}
//PxU32 gContactCache_NbCalls = 0;
//PxU32 gContactCache_NbHits = 0;
static PX_FORCE_INLINE PxReal maxComponentDeltaPos(const PxTransform& t0, const PxTransform& t1)
{
PxReal delta = PxAbs(t0.p.x - t1.p.x);
delta = PxMax(delta, PxAbs(t0.p.y - t1.p.y));
delta = PxMax(delta, PxAbs(t0.p.z - t1.p.z));
return delta;
}
static PX_FORCE_INLINE PxReal maxComponentDeltaRot(const PxTransform& t0, const PxTransform& t1)
{
PxReal delta = PxAbs(t0.q.x - t1.q.x);
delta = PxMax(delta, PxAbs(t0.q.y - t1.q.y));
delta = PxMax(delta, PxAbs(t0.q.z - t1.q.z));
delta = PxMax(delta, PxAbs(t0.q.w - t1.q.w));
return delta;
}
bool physx::PxcCacheLocalContacts( PxcNpThreadContext& context, Gu::Cache& pairContactCache,
const PxTransform& tm0, const PxTransform& tm1,
const PxcContactMethod conMethod,
const Gu::GeometryUnion& shape0, const Gu::GeometryUnion& shape1)
{
const Gu::NarrowPhaseParams& params = context.mNarrowPhaseParams;
// gContactCache_NbCalls++;
if(pairContactCache.mCachedData)
prefetchData128(pairContactCache.mCachedData, pairContactCache.mCachedSize);
ContactBuffer& contactBuffer = context.mContactBuffer;
contactBuffer.reset();
PxcLocalContactsCache contactsData;
PxU32 nbCachedBytes;
const PxU8* cachedBytes = PxcNpCacheRead2(pairContactCache, contactsData, nbCachedBytes);
pairContactCache.mCachedData = NULL;
pairContactCache.mCachedSize = 0;
#ifdef ENABLE_CONTACT_CACHE_STATS
gNbCalls++;
#endif
const PxU32 payloadSize = (sizeof(PxcLocalContactsCache)+3)&~3;
if(cachedBytes)
{
// PT: we used to store the relative TM but it's better to save memory and recompute it
const PxTransform t0to1 = tm1.transformInv(tm0);
const PxTransform relTM = contactsData.mTransform1.transformInv(contactsData.mTransform0);
const PxReal epsilon = 0.01f;
if( maxComponentDeltaPos(t0to1, relTM)<epsilon*params.mToleranceLength
&& maxComponentDeltaRot(t0to1, relTM)<epsilon)
{
// gContactCache_NbHits++;
const PxU32 nbContacts = contactsData.mNbCachedContacts;
PxU8* ls = PxcNpCacheWriteInitiate(context.mNpCacheStreamPair, pairContactCache, contactsData, nbCachedBytes);
prefetchData128(ls, (payloadSize + 4 + nbCachedBytes + 0xF)&~0xF);
contactBuffer.count = nbContacts;
if(nbContacts)
{
Gu::ContactPoint* PX_RESTRICT dst = contactBuffer.contacts;
const Cm::Matrix34 world1(tm1);
const Cm::Matrix34 world0(tm0);
const bool sameNormal = contactsData.mSameNormal;
const PxU8* contacts = reinterpret_cast<const PxU8*>(cachedBytes);
const PxVec3* normal0 = NULL;
for(PxU32 i=0;i<nbContacts;i++)
{
if(i!=nbContacts-1)
Ps::prefetchLine(contacts, 128);
const PxVec3* cachedNormal;
if(!i || !sameNormal)
{
cachedNormal = reinterpret_cast<const PxVec3*>(contacts); contacts += sizeof(PxVec3);
normal0 = cachedNormal;
}
else
{
cachedNormal = normal0;
}
const PxVec3* cachedPoint = reinterpret_cast<const PxVec3*>(contacts); contacts += sizeof(PxVec3);
const PxReal* cachedPD = reinterpret_cast<const PxReal*>(contacts); contacts += sizeof(PxReal);
updateContact(*dst, contactsData, world0, world1, *cachedPoint, *cachedNormal, *cachedPD);
if(contactsData.mUseFaceIndices)
{
const PxU32* cachedIndex1 = reinterpret_cast<const PxU32*>(contacts); contacts += sizeof(PxU32);
dst->internalFaceIndex1 = *cachedIndex1;
}
else
{
dst->internalFaceIndex1 = PXC_CONTACT_NO_FACE_INDEX;
}
dst++;
}
}
if(ls)
PxcNpCacheWriteFinalize(ls, contactsData, nbCachedBytes, cachedBytes);
#ifdef ENABLE_CONTACT_CACHE_STATS
gNbHits++;
#endif
return true;
}
else
{
// PT: if we reach this point we cached the contacts but we couldn't use them next frame
// => waste of time and memory
}
}
conMethod(shape0, shape1, tm0, tm1, params, pairContactCache, context.mContactBuffer, &context.mRenderOutput);
//if(contactBuffer.count)
{
contactsData.mTransform0 = tm0;
contactsData.mTransform1 = tm1;
PxU32 nbBytes = 0;
const PxU8* bytes = NULL;
const PxU32 count = contactBuffer.count;
if(count)
{
const bool useFaceIndices = contactBuffer.contacts[0].internalFaceIndex1!=PXC_CONTACT_NO_FACE_INDEX;
contactsData.mNbCachedContacts = Ps::to16(count);
contactsData.mUseFaceIndices = useFaceIndices;
const Gu::ContactPoint* PX_RESTRICT srcContacts = contactBuffer.contacts;
// PT: this loop should not be here. We should output the contacts directly compressed, as we used to.
bool sameNormal = true;
{
const PxVec3 normal0 = srcContacts->normal;
for(PxU32 i=1;i<count;i++)
{
if(srcContacts[i].normal!=normal0)
{
sameNormal = false;
break;
}
}
}
contactsData.mSameNormal = sameNormal;
if(!sameNormal)
{
const PxU32 sizeof_CachedContactPoint = sizeof(PxVec3) + sizeof(PxVec3) + sizeof(PxReal);
const PxU32 sizeof_CachedContactPointAndFaceIndices = sizeof_CachedContactPoint + sizeof(PxU32);
const PxU32 sizeOfItem = useFaceIndices ? sizeof_CachedContactPointAndFaceIndices : sizeof_CachedContactPoint;
nbBytes = count * sizeOfItem;
}
else
{
const PxU32 sizeof_CachedContactPoint = sizeof(PxVec3) + sizeof(PxReal);
const PxU32 sizeof_CachedContactPointAndFaceIndices = sizeof_CachedContactPoint + sizeof(PxU32);
const PxU32 sizeOfItem = useFaceIndices ? sizeof_CachedContactPointAndFaceIndices : sizeof_CachedContactPoint;
nbBytes = sizeof(PxVec3) + count * sizeOfItem;
}
PxU8* ls = PxcNpCacheWriteInitiate(context.mNpCacheStreamPair, pairContactCache, contactsData, nbBytes);
if(ls)
{
*reinterpret_cast<PxcLocalContactsCache*>(ls) = contactsData;
*reinterpret_cast<PxU32*>(ls+payloadSize) = nbBytes;
bytes = ls+payloadSize+sizeof(PxU32);
PxU8* dest = const_cast<PxU8*>(bytes);
for(PxU32 i=0;i<count;i++)
{
if(!i || !sameNormal)
dest = outputToCache(dest, srcContacts[i].normal);
dest = outputToCache(dest, srcContacts[i].point);
dest = outputToCache(dest, srcContacts[i].separation);
if(useFaceIndices)
{
dest = outputToCache(dest, srcContacts[i].internalFaceIndex1);
}
}
PX_ASSERT(size_t(dest) - size_t(bytes)==nbBytes);
}
else
{
contactsData.mNbCachedContacts = 0;
PxcNpCacheWrite(context.mNpCacheStreamPair, pairContactCache, contactsData, 0, bytes);
}
}
else
{
contactsData.mNbCachedContacts = 0;
contactsData.mUseFaceIndices = false;
PxcNpCacheWrite(context.mNpCacheStreamPair, pairContactCache, contactsData, nbBytes, bytes);
}
}
return false;
}
| 31.083756 | 124 | 0.721646 | RyanTorant |
24247782aea7b1609fa3b43e05307b5200a823d4 | 551 | cpp | C++ | src/MySqlWrapper.cpp | yangboz/MySQLWrapper | 9b76ce95bf74edbbec7109c39916a15c4818686e | [
"MIT"
] | null | null | null | src/MySqlWrapper.cpp | yangboz/MySQLWrapper | 9b76ce95bf74edbbec7109c39916a15c4818686e | [
"MIT"
] | null | null | null | src/MySqlWrapper.cpp | yangboz/MySQLWrapper | 9b76ce95bf74edbbec7109c39916a15c4818686e | [
"MIT"
] | null | null | null | //============================================================================
// Name : MySqlWrapper.cpp
// Author : youngwelle@gmail.com
// Version :
// Copyright : Copyright GODPAPER
// Description : Hello World in C++, Ansi-style
//============================================================================
#include <iostream>
using namespace std;
#include "MySqlCpp.h"
int main() {
cout << "!!!Hello,MySqlWrapper!!!" << endl; // prints !!!Hello,MySqlWrapper!!!
MySqlCpp mySqlCpp;
mySqlCpp.simpleSqlQuery();
return 0;
}
| 27.55 | 79 | 0.466425 | yangboz |
24273ed7f7eafa6d5a842952903ad128d49625a9 | 1,022 | cpp | C++ | volume1/1024_19Nov2006_1408090.cpp | andriybuday/timus | a5cdc03f3ca8e7878220b8e0a0c72343f98ee1eb | [
"MIT"
] | null | null | null | volume1/1024_19Nov2006_1408090.cpp | andriybuday/timus | a5cdc03f3ca8e7878220b8e0a0c72343f98ee1eb | [
"MIT"
] | null | null | null | volume1/1024_19Nov2006_1408090.cpp | andriybuday/timus | a5cdc03f3ca8e7878220b8e0a0c72343f98ee1eb | [
"MIT"
] | null | null | null | #include <stdio.h>
void quickSortR(int* a, long N)
{
long i = 0, j = N;
int temp, p;
p = a[ N>>1 ];
do
{
while ( a[i] < p ) i++;
while ( a[j] > p ) j--;
if (i <= j) {
temp = a[i]; a[i] = a[j]; a[j] = temp;
i++; j--;
}
} while ( i<=j );
if ( j > 0 ) quickSortR(a, j);
if ( N > i ) quickSortR(a+i, N-i);
}
int NSD(int min, int max)
{
int temp = 1;
while(temp!=0)
{
if(min != 0)temp = max%min;
if(min == 0)continue;
max = min;
min = temp;
if(temp == 0)continue;
}
return max;
}
inline int NSK(int x, int y)
{
return x / NSD(x, y) * y;
}
int a[1002];
int k[1002];
int main()
{
int n, i, x;
scanf("%d", &n);
for(i = 1; i <= n; i++)
{
scanf("%d", &a[i]);
}
for(i = 1; i <= n; i++)
{
int j = i;
int count = 1;
while(a[j] != i)
{
j = a[j];
count++;
}
k[i] = count;
}
quickSortR(k, n);
int curr_NSK = k[1];
for(i = 1; i <= n; i++)
{
curr_NSK = NSK(curr_NSK, k[i]);
}
printf("%d", curr_NSK);
return 0;
}
| 11.483146 | 44 | 0.438356 | andriybuday |
242903ca6638e1a4100204828a3aab5ff794e4ab | 4,714 | cpp | C++ | Source/Constraint/imstkcpdPointTriangleCollisionConstraint.cpp | quantingxie/vibe | 965a79089ac3ec821ad65c45ac50e69bf32dc92f | [
"Apache-2.0"
] | 2 | 2020-08-14T07:21:30.000Z | 2021-08-30T09:39:09.000Z | Source/Constraint/imstkcpdPointTriangleCollisionConstraint.cpp | quantingxie/vibe | 965a79089ac3ec821ad65c45ac50e69bf32dc92f | [
"Apache-2.0"
] | null | null | null | Source/Constraint/imstkcpdPointTriangleCollisionConstraint.cpp | quantingxie/vibe | 965a79089ac3ec821ad65c45ac50e69bf32dc92f | [
"Apache-2.0"
] | 1 | 2020-08-14T07:00:31.000Z | 2020-08-14T07:00:31.000Z | #include "imstkcpdPointTriangleCollisionConstraint.h"
namespace cpd
{
void PointTriangleCollisionConstraint::initConstraint(ParticleObjectPtr p_object1, const size_t p_idx1, ParticleObjectPtr p_object2, const size_t p_idx2, const size_t p_idx3, const size_t p_idx4, double p_stiffness)
{
m_object = p_object1;
m_objectOther = p_object2;
m_stiffness = p_stiffness;
m_elasticityMatrix(0,0) = 0;
m_particleIDs[0] = p_idx1;
m_particleIDs[1] = p_idx2;
m_particleIDs[2] = p_idx3;
m_particleIDs[3] = p_idx4;
for (unsigned i = 0; i < 4; i++)
{
if (i < m_sizeCol[0])
m_invMass[i] = m_object->getInvMass(m_particleIDs[i]);
else
m_invMass[i] = m_objectOther->getInvMass(m_particleIDs[i]);
m_deltaDisplacement[i].setZero();
if (m_invMass[i] > EPS)
m_movable[i] = true;
else
m_movable[i] = false;
}
m_volume = m_object->getParticleProximity() + m_objectOther->getParticleProximity();
m_elasticityMatrix[0] = 0.0;
m_deno[0] = 0.0;
clearLamda();
computeDerivative();
}
void PointTriangleCollisionConstraint::updateConstraint()
{
m_delta[0] = m_delta[0] + m_deltaDisplacement[0] - m_deltaDisplacement[1];
m_delta[1] = m_delta[1] + m_deltaDisplacement[2] - m_deltaDisplacement[1];
m_delta[2] = m_delta[2] + m_deltaDisplacement[3] - m_deltaDisplacement[1];
//m_delta[1] = m_delta[1] + m_deltaDisplacement[3] - m_deltaDisplacement[1];
//m_delta[2] = m_delta[2] + m_deltaDisplacement[2] - m_deltaDisplacement[1];
m_Constraint[0] = m_delta[0].dot((m_delta[1].cross(m_delta[2])).normalized()) - m_volume;
}
void PointTriangleCollisionConstraint::computeDerivative()
{
m_delta[0] = m_object->getTemporaryPosition(m_particleIDs[0]) - m_objectOther->getTemporaryPosition(m_particleIDs[1]);
m_delta[1] = m_objectOther->getTemporaryPosition(m_particleIDs[2]) - m_objectOther->getTemporaryPosition(m_particleIDs[1]);
m_delta[2] = m_objectOther->getTemporaryPosition(m_particleIDs[3]) - m_objectOther->getTemporaryPosition(m_particleIDs[1]);
//m_delta[1] = m_objectOther->getTemporaryPosition(m_particleIDs[3]) - m_objectOther->getTemporaryPosition(m_particleIDs[1]);
//m_delta[2] = m_objectOther->getTemporaryPosition(m_particleIDs[2]) - m_objectOther->getTemporaryPosition(m_particleIDs[1]);
for (unsigned i = 0; i < 4; i++)
{
m_derivatives[i].fill(0.0);
}
}
bool PointTriangleCollisionConstraint::updateDenominator()
{
//std::cout << "C" << m_Constraint[0] << ", eps = " << EPS << std::endl;
if (m_Constraint[0] > EPS)
return false;
double coeff[4];
Vec3d n = m_delta[1].cross(m_delta[2]);
coeff[1] = n.dot(m_delta[1].cross(m_delta[0])) / (n.dot(n));
coeff[2] = n.dot(m_delta[0].cross(m_delta[2])) / (n.dot(n));
coeff[3] = (1.0 - coeff[1] - coeff[2]);
//coeff[1] = -n.dot(m_delta[1].cross(m_delta[0])) / (n.dot(n));
//coeff[2] = -n.dot(m_delta[0].cross(m_delta[2])) / (n.dot(n));
//coeff[3] = -(1.0 - coeff[1] - coeff[2]);
coeff[0] = 1.0;
if (coeff[1] < 0 || coeff[2] < 0 || coeff[3] < 0)
{
//if (coeff[1] > 0 || coeff[2] > 0 || coeff[3] > 0)
//{
return false;
}
for (unsigned i = 0; i < 4; i++)
{
//m_object->setParticleCollided(m_particleIDs[i]);
if (i < m_sizeCol[0])
m_object->setParticleCollided(m_particleIDs[i]);
else
m_objectOther->setParticleCollided(m_particleIDs[i]);
}
n.normalize();
for (unsigned i = 0; i < 4; i++)
{
for (unsigned j = 0; j < 3; j++)
{
m_derivatives[i][j] = coeff[i] * n[j];
}
}
double cmc = 0;
for (unsigned i = 0; i < 4; i++)
{
cmc += m_invMass[i] * coeff[i] * coeff[i];
}
if (abs(cmc) > EPS)
m_deno[0] = 1.0 / cmc;
else
m_deno[0] = 0.0;
return true;
}
void PointTriangleCollisionConstraint::computeForce()
{
Vec3d force;
double coeff;
for (unsigned i = 0; i < 4; i++)
{
coeff = m_lamdaList[0] * 0.5;
for (unsigned j = 0; j < 3; j++)
{
force[j] = coeff * m_derivatives[i][j];
}
}
#pragma omp critical
for (unsigned i = 0; i < 4; i++)
{
//m_object->addToConstraintForce(m_particleIDs[i], m_invMass[i] * force);
if (i < m_sizeCol[0])
m_object->addToConstraintForce(m_particleIDs[i], m_ID, m_invMass[i] * force);
else
m_objectOther->addToConstraintForce(m_particleIDs[i], m_ID, m_invMass[i] * force);
}
}
void PointTriangleCollisionConstraint::integrate(bool p_all)
{
}
void PointTriangleCollisionConstraint::initShapeFunction()
{
}
}
| 31.218543 | 217 | 0.622613 | quantingxie |
242a48a9c2f9af3f003c95dc58a386f2c5695554 | 6,376 | cpp | C++ | test/unit/alphabet/nucleotide/sam_dna16_test.cpp | qPCR4vir/seqan3 | 67ebf427dc1d49fb55e684acc108ed75d224f5d4 | [
"CC-BY-4.0",
"CC0-1.0"
] | null | null | null | test/unit/alphabet/nucleotide/sam_dna16_test.cpp | qPCR4vir/seqan3 | 67ebf427dc1d49fb55e684acc108ed75d224f5d4 | [
"CC-BY-4.0",
"CC0-1.0"
] | null | null | null | test/unit/alphabet/nucleotide/sam_dna16_test.cpp | qPCR4vir/seqan3 | 67ebf427dc1d49fb55e684acc108ed75d224f5d4 | [
"CC-BY-4.0",
"CC0-1.0"
] | null | null | null | // -----------------------------------------------------------------------------------------------------
// Copyright (c) 2006-2020, Knut Reinert & Freie Universität Berlin
// Copyright (c) 2016-2020, Knut Reinert & MPI für molekulare Genetik
// This file may be used, modified and/or redistributed under the terms of the 3-clause BSD-License
// shipped with this file and also available at: https://github.com/seqan/seqan3/blob/master/LICENSE.md
// -----------------------------------------------------------------------------------------------------
#include <seqan3/alphabet/nucleotide/sam_dna16.hpp>
#include <seqan3/core/detail/debug_stream_range.hpp>
#include <seqan3/utility/char_operations/predicate.hpp>
#include "../alphabet_constexpr_test_template.hpp"
#include "../alphabet_test_template.hpp"
#include "../semi_alphabet_constexpr_test_template.hpp"
#include "../semi_alphabet_test_template.hpp"
using seqan3::operator""_sam_dna16;
// ------------------------------------------------------------------
// sam_dna16 alphabet
// ------------------------------------------------------------------
INSTANTIATE_TYPED_TEST_SUITE_P(sam_dna16, alphabet, seqan3::sam_dna16, );
INSTANTIATE_TYPED_TEST_SUITE_P(sam_dna16, semi_alphabet_test, seqan3::sam_dna16, );
INSTANTIATE_TYPED_TEST_SUITE_P(sam_dna16, alphabet_constexpr, seqan3::sam_dna16, );
INSTANTIATE_TYPED_TEST_SUITE_P(sam_dna16, semi_alphabet_constexpr, seqan3::sam_dna16, );
// nucleotide test: (because the complement is not bijective for sam_dna16 we need to test it manually)
TEST(sam_dna16, nucleotide)
{
EXPECT_TRUE(seqan3::nucleotide_alphabet<seqan3::sam_dna16>);
EXPECT_TRUE(seqan3::nucleotide_alphabet<seqan3::sam_dna16 &>);
EXPECT_EQ(seqan3::complement('='_sam_dna16), 'N'_sam_dna16);
EXPECT_EQ(seqan3::complement('A'_sam_dna16), 'T'_sam_dna16);
EXPECT_EQ(seqan3::complement('C'_sam_dna16), 'G'_sam_dna16);
EXPECT_EQ(seqan3::complement('M'_sam_dna16), 'K'_sam_dna16);
EXPECT_EQ(seqan3::complement('G'_sam_dna16), 'C'_sam_dna16);
EXPECT_EQ(seqan3::complement('R'_sam_dna16), 'Y'_sam_dna16);
EXPECT_EQ(seqan3::complement('S'_sam_dna16), 'S'_sam_dna16);
EXPECT_EQ(seqan3::complement('V'_sam_dna16), 'B'_sam_dna16);
EXPECT_EQ(seqan3::complement('T'_sam_dna16), 'A'_sam_dna16);
EXPECT_EQ(seqan3::complement('W'_sam_dna16), 'W'_sam_dna16);
EXPECT_EQ(seqan3::complement('Y'_sam_dna16), 'R'_sam_dna16);
EXPECT_EQ(seqan3::complement('H'_sam_dna16), 'D'_sam_dna16);
EXPECT_EQ(seqan3::complement('K'_sam_dna16), 'M'_sam_dna16);
EXPECT_EQ(seqan3::complement('D'_sam_dna16), 'H'_sam_dna16);
EXPECT_EQ(seqan3::complement('B'_sam_dna16), 'V'_sam_dna16);
EXPECT_EQ(seqan3::complement('N'_sam_dna16), 'N'_sam_dna16);
}
TEST(sam_dna16, to_char_assign_char)
{
using rank_t = seqan3::alphabet_rank_t<seqan3::sam_dna16>;
for (rank_t rank = 0; rank < seqan3::alphabet_size<seqan3::sam_dna16>; ++rank)
{
char chr = seqan3::to_char(seqan3::assign_rank_to(rank, seqan3::sam_dna16{}));
EXPECT_EQ(seqan3::to_char(seqan3::sam_dna16{}.assign_char(chr)), chr);
}
EXPECT_EQ(seqan3::to_char(seqan3::sam_dna16{}.assign_char('a')), 'A');
EXPECT_EQ(seqan3::to_char(seqan3::sam_dna16{}.assign_char('c')), 'C');
EXPECT_EQ(seqan3::to_char(seqan3::sam_dna16{}.assign_char('g')), 'G');
EXPECT_EQ(seqan3::to_char(seqan3::sam_dna16{}.assign_char('t')), 'T');
EXPECT_EQ(seqan3::to_char(seqan3::sam_dna16{}.assign_char('U')), 'T');
EXPECT_EQ(seqan3::to_char(seqan3::sam_dna16{}.assign_char('!')), 'N');
}
TEST(sam_dna16, char_literal)
{
EXPECT_EQ(seqan3::to_char('A'_sam_dna16), 'A');
EXPECT_EQ(seqan3::to_char('C'_sam_dna16), 'C');
EXPECT_EQ(seqan3::to_char('G'_sam_dna16), 'G');
EXPECT_EQ(seqan3::to_char('U'_sam_dna16), 'T');
EXPECT_EQ(seqan3::to_char('T'_sam_dna16), 'T');
EXPECT_EQ(seqan3::to_char('R'_sam_dna16), 'R');
EXPECT_EQ(seqan3::to_char('Y'_sam_dna16), 'Y');
EXPECT_EQ(seqan3::to_char('S'_sam_dna16), 'S');
EXPECT_EQ(seqan3::to_char('W'_sam_dna16), 'W');
EXPECT_EQ(seqan3::to_char('K'_sam_dna16), 'K');
EXPECT_EQ(seqan3::to_char('M'_sam_dna16), 'M');
EXPECT_EQ(seqan3::to_char('B'_sam_dna16), 'B');
EXPECT_EQ(seqan3::to_char('D'_sam_dna16), 'D');
EXPECT_EQ(seqan3::to_char('H'_sam_dna16), 'H');
EXPECT_EQ(seqan3::to_char('V'_sam_dna16), 'V');
EXPECT_EQ(seqan3::to_char('='_sam_dna16), '=');
EXPECT_EQ(seqan3::to_char('N'_sam_dna16), 'N');
EXPECT_EQ(seqan3::to_char('!'_sam_dna16), 'N');
}
TEST(sam_dna16, string_literal)
{
seqan3::sam_dna16_vector v;
v.resize(5, 'A'_sam_dna16);
EXPECT_EQ(v, "AAAAA"_sam_dna16);
std::vector<seqan3::sam_dna16> w{'A'_sam_dna16,
'='_sam_dna16,
'G'_sam_dna16,
'T'_sam_dna16,
'U'_sam_dna16,
'N'_sam_dna16};
EXPECT_EQ(w, "A=GTTN"_sam_dna16);
}
TEST(sam_dna16, char_is_valid)
{
constexpr auto validator = seqan3::is_char<'A'> || seqan3::is_char<'C'> || seqan3::is_char<'G'> ||
seqan3::is_char<'T'> || seqan3::is_char<'U'> || seqan3::is_char<'a'> ||
seqan3::is_char<'c'> || seqan3::is_char<'g'> || seqan3::is_char<'t'> ||
seqan3::is_char<'u'> || seqan3::is_char<'N'> || seqan3::is_char<'n'> ||
seqan3::is_char<'R'> || seqan3::is_char<'Y'> || seqan3::is_char<'S'> ||
seqan3::is_char<'W'> || seqan3::is_char<'K'> || seqan3::is_char<'M'> ||
seqan3::is_char<'B'> || seqan3::is_char<'D'> || seqan3::is_char<'H'> ||
seqan3::is_char<'V'> || seqan3::is_char<'r'> || seqan3::is_char<'y'> ||
seqan3::is_char<'s'> || seqan3::is_char<'w'> || seqan3::is_char<'k'> ||
seqan3::is_char<'m'> || seqan3::is_char<'b'> || seqan3::is_char<'d'> ||
seqan3::is_char<'h'> || seqan3::is_char<'v'> || seqan3::is_char<'='>;
for (char c : std::views::iota(std::numeric_limits<char>::min(), std::numeric_limits<char>::max()))
EXPECT_EQ(seqan3::sam_dna16::char_is_valid(c), validator(c));
}
| 49.8125 | 104 | 0.604768 | qPCR4vir |
242b97cef7b5f19e6a0fc3f0344973e206157a3e | 17,164 | cpp | C++ | src/bredala/transport/mpi/redist_mpi.cpp | tpeterka/decaf | ad6ad823070793bfd7fc8d9384d5475f7cf20848 | [
"BSD-3-Clause"
] | 1 | 2019-05-10T02:50:50.000Z | 2019-05-10T02:50:50.000Z | src/bredala/transport/mpi/redist_mpi.cpp | tpeterka/decaf | ad6ad823070793bfd7fc8d9384d5475f7cf20848 | [
"BSD-3-Clause"
] | 2 | 2020-10-28T03:44:51.000Z | 2021-01-18T19:49:33.000Z | src/bredala/transport/mpi/redist_mpi.cpp | tpeterka/decaf | ad6ad823070793bfd7fc8d9384d5475f7cf20848 | [
"BSD-3-Clause"
] | 2 | 2018-08-31T14:02:47.000Z | 2020-04-17T16:01:54.000Z | //---------------------------------------------------------------------------
//
// redistribute base class
//
// Matthieu Dreher
// Argonne National Laboratory
// 9700 S. Cass Ave.
// Argonne, IL 60439
// mdreher@anl.gov
//
//--------------------------------------------------------------------------
#include <iostream>
#include <assert.h>
#include <string.h>
#include <sys/time.h>
#include <bredala/transport/mpi/redist_mpi.h>
// create communicators for contiguous process assignment
// ranks within source and destination must be contiguous, but
// destination ranks need not be higher numbered than source ranks
decaf::
RedistMPI::RedistMPI(int rankSource,
int nbSources,
int rankDest,
int nbDests,
CommHandle world_comm, RedistCommMethod commMethod, MergeMethod mergeMethod) :
RedistComp(rankSource, nbSources, rankDest, nbDests, commMethod, mergeMethod),
communicator_(MPI_COMM_NULL),
commSources_(MPI_COMM_NULL),
commDests_(MPI_COMM_NULL),
sum_(NULL),
destBuffer_(NULL)
{
MPI_Group group, groupRedist, groupSource, groupDest;
MPI_Comm_group(world_comm, &group);
// group covering both the sources and destinations
// destination ranks need not be higher than source ranks
// Testing if sources and receivers are disjoints
if(rankDest >= rankSource + nbSources || rankSource >= rankDest + nbDests)
{
int range_both[2][3];
if(rankDest < rankSource) //Separation to preserve the order of the ranks
{
range_both[0][0] = rankDest;
range_both[0][1] = rankDest + nbDests - 1;
range_both[0][2] = 1;
range_both[1][0] = rankSource;
range_both[1][1] = rankSource + nbSources - 1;
range_both[1][2] = 1;
local_source_rank_ = nbDests;
local_dest_rank_ = 0;
}
else
{
range_both[0][0] = rankSource;
range_both[0][1] = rankSource + nbSources - 1;
range_both[0][2] = 1;
range_both[1][0] = rankDest;
range_both[1][1] = rankDest + nbDests - 1;
range_both[1][2] = 1;
local_source_rank_ = 0;
local_dest_rank_ = nbSources;
}
MPI_Group_range_incl(group, 2, range_both, &groupRedist);
}
else //Sources and Receivers are overlapping
{
int range[3];
range[0] = std::min(rankSource, rankDest);
range[1] = std::max(rankSource + nbSources - 1, rankDest + nbDests - 1);
range[2] = 1;
MPI_Group_range_incl(group, 1, &range, &groupRedist);
if(rankDest < rankSource) //Separation to preserve the order of the ranks
{
local_source_rank_ = rankSource - rankDest;
local_dest_rank_ = 0;
}
else
{
local_source_rank_ = 0;
local_dest_rank_ = rankDest - rankSource;
}
}
MPI_Comm_create_group(world_comm, groupRedist, 0, &communicator_);
MPI_Group_free(&groupRedist);
MPI_Comm_rank(communicator_, &rank_);
MPI_Comm_size(communicator_, &size_);
// group with all the sources
if(isSource())
{
int range_src[3];
range_src[0] = rankSource;
range_src[1] = rankSource + nbSources - 1;
range_src[2] = 1;
MPI_Group_range_incl(group, 1, &range_src, &groupSource);
MPI_Comm_create_group(world_comm, groupSource, 0, &commSources_);
MPI_Group_free(&groupSource);
int source_rank;
MPI_Comm_rank(commSources_, &source_rank);
// Create the array which represents where the current source will emit toward
// the destinations rank. 0 is no send to that rank, 1 is send
// Used only with commMethod = DECAF_REDIST_COLLECTIVE
summerizeDest_ = new int[ nbDests_];
}
// group with all the destinations
if(isDest())
{
int range_dest[3];
range_dest[0] = rankDest;
range_dest[1] = rankDest + nbDests - 1;
range_dest[2] = 1;
MPI_Group_range_incl(group, 1, &range_dest, &groupDest);
MPI_Comm_create_group(world_comm, groupDest, 0, &commDests_);
MPI_Group_free(&groupDest);
int dest_rank;
MPI_Comm_rank(commDests_, &dest_rank);
}
MPI_Group_free(&group);
destBuffer_ = new int[nbDests_];
sum_ = new int[nbDests_];
transit = pConstructData(false);
}
decaf::
RedistMPI::~RedistMPI()
{
if (communicator_ != MPI_COMM_NULL)
MPI_Comm_free(&communicator_);
if (commSources_ != MPI_COMM_NULL)
MPI_Comm_free(&commSources_);
if (commDests_ != MPI_COMM_NULL)
MPI_Comm_free(&commDests_);
delete[] destBuffer_;
delete[] sum_;
}
void
decaf::
RedistMPI::splitSystemData(pConstructData& data, RedistRole role)
{
if(role == DECAF_REDIST_SOURCE)
{
// Create the array which represents where the current source will emit toward
// the destinations rank. 0 is no send to that rank, 1 is send
if( summerizeDest_) delete [] summerizeDest_;
summerizeDest_ = new int[ nbDests_];
bzero( summerizeDest_, nbDests_ * sizeof(int)); // First we don't send anything
// For this case we simply duplicate the message for each destination
for(unsigned int i = 0; i < nbDests_; i++)
{
//Creating the ranges for the split function
splitChunks_.push_back(data);
//We send data to everyone except to self
if(i + local_dest_rank_ != rank_)
summerizeDest_[i] = 1;
// rankDest_ - rankSource_ is the rank of the first destination in the
// component communicator (communicator_)
destList_.push_back(i + local_dest_rank_);
}
// All the data chunks are the same pointer
// We just need to serialize one chunk
if(!splitChunks_[0]->serialize())
std::cout<<"ERROR : unable to serialize one object"<<std::endl;
}
}
// redistribution protocol
void
decaf::
RedistMPI::redistribute(pConstructData& data, RedistRole role)
{
switch(commMethod_)
{
case DECAF_REDIST_COLLECTIVE:
{
redistributeCollective(data, role);
break;
}
case DECAF_REDIST_P2P:
{
redistributeP2P(data, role);
break;
}
default:
{
std::cout<<"WARNING : Unknown redistribution strategy used ("<<commMethod_<<"). Using collective by default."<<std::endl;
redistributeCollective(data, role);
break;
}
}
}
// collective redistribution protocol
void
decaf::
RedistMPI::redistributeCollective(pConstructData& data, RedistRole role)
{
// debug
int rank;
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
// producer root collects the number of messages for each source destination
if (role == DECAF_REDIST_SOURCE)
{
//for(int i = 0; i < nbDests_; i++)
// std::cout<<summerizeDest_[i]<<" ";
//std::cout<<std::endl;
MPI_Reduce(summerizeDest_, sum_, nbDests_, MPI_INT, MPI_SUM,
0, commSources_); // 0 Because we are in the source comm
//local_source_rank_, commSources_);
}
// overlapping source and destination
if (rank_ == local_source_rank_ && rank_ == local_dest_rank_)
memcpy(destBuffer_, sum_, nbDests_ * sizeof(int));
// disjoint source and destination
else
{
// Sending to the rank 0 of the destinations
if(role == DECAF_REDIST_SOURCE && rank_ == local_source_rank_)
{
MPI_Request req;
reqs.push_back(req);
MPI_Isend(sum_, nbDests_, MPI_INT, local_dest_rank_, MPI_METADATA_TAG,
communicator_,&reqs.back());
}
// Getting the accumulated buffer on the destination side
if(role == DECAF_REDIST_DEST && rank_ == local_dest_rank_) //Root of destination
{
MPI_Status status;
MPI_Probe(MPI_ANY_SOURCE, MPI_METADATA_TAG, communicator_, &status);
if (status.MPI_TAG == MPI_METADATA_TAG) // normal, non-null get
{
MPI_Recv(destBuffer_, nbDests_, MPI_INT, local_source_rank_,
MPI_METADATA_TAG, communicator_, MPI_STATUS_IGNORE);
}
}
/* // producer root sends the number of messages to root of consumer
if (role == DECAF_REDIST_SOURCE && rank_ == local_source_rank_)
MPI_Send(sum_, nbDests_, MPI_INT, local_dest_rank_, MPI_METADATA_TAG,
communicator_);
// consumer root receives the number of messages
if (role == DECAF_REDIST_DEST && rank_ == local_dest_rank_)
MPI_Recv(destBuffer_, nbDests_, MPI_INT, local_source_rank_, MPI_METADATA_TAG,
communicator_, MPI_STATUS_IGNORE);*/
}
// producer ranks send data payload
if (role == DECAF_REDIST_SOURCE)
{
for (unsigned int i = 0; i < destList_.size(); i++)
{
// sending to self, we store the data from the out to in
if (destList_.at(i) == rank_)
transit = splitChunks_.at(i);
else if (destList_.at(i) != -1)
{
MPI_Request req;
reqs.push_back(req);
// nonblocking send in case payload is too big send in immediate mode
MPI_Isend(splitChunks_.at(i)->getOutSerialBuffer(),
splitChunks_.at(i)->getOutSerialBufferSize(),
MPI_BYTE, destList_.at(i), send_data_tag, communicator_, &reqs.back());
}
}
send_data_tag = (send_data_tag == INT_MAX ? MPI_DATA_TAG : send_data_tag + 1);
}
// check if we have something in transit to/from self
if (role == DECAF_REDIST_DEST && !transit.empty())
{
if(mergeMethod_ == DECAF_REDIST_MERGE_STEP)
data->merge(transit->getOutSerialBuffer(), transit->getOutSerialBufferSize());
else if (mergeMethod_ == DECAF_REDIST_MERGE_ONCE)
data->unserializeAndStore(transit->getOutSerialBuffer(), transit->getOutSerialBufferSize());
transit.reset(); // we don't need it anymore, clean for the next iteration
//return;
}
// only consumer ranks are left
if (role == DECAF_REDIST_DEST)
{
// scatter the number of messages to receive at each rank
int nbRecep;
MPI_Scatter(destBuffer_, 1, MPI_INT, &nbRecep, 1, MPI_INT, 0, commDests_);
// receive the payload (blocking)
// recv_data_tag forces messages from different ranks in the same workflow link
// (grouped by communicator) and in the same iteration to stay together
// because the tag is incremented with each iteration
for (int i = 0; i < nbRecep; i++)
{
MPI_Status status;
MPI_Probe(MPI_ANY_SOURCE, recv_data_tag, communicator_, &status);
int nbytes; // number of bytes in the message
MPI_Get_count(&status, MPI_BYTE, &nbytes);
data->allocate_serial_buffer(nbytes); // allocate necessary space
MPI_Recv(data->getInSerialBuffer(), nbytes, MPI_BYTE, status.MPI_SOURCE,
recv_data_tag, communicator_, &status);
// The dynamic type of merge is given by the user
// NOTE: examine if it's not more efficient to receive everything
// and then merge. Memory footprint more important but allows to
// aggregate the allocations etc
if(mergeMethod_ == DECAF_REDIST_MERGE_STEP)
data->merge();
else if(mergeMethod_ == DECAF_REDIST_MERGE_ONCE)
//data->unserializeAndStore();
data->unserializeAndStore(data->getInSerialBuffer(), nbytes);
else
{
std::cout<<"ERROR : merge method not specified. Abording."<<std::endl;
MPI_Abort(MPI_COMM_WORLD, 0);
}
}
recv_data_tag = (recv_data_tag == INT_MAX ? MPI_DATA_TAG : recv_data_tag + 1);
if(mergeMethod_ == DECAF_REDIST_MERGE_ONCE)
data->mergeStoredData();
}
}
// point to point redistribution protocol
void
decaf::
RedistMPI::redistributeP2P(pConstructData& data, RedistRole role)
{
//Processing the data exchange
if(role == DECAF_REDIST_SOURCE)
{
for(unsigned int i = 0; i < destList_.size(); i++)
{
//Sending to self, we simply copy the string from the out to in
if(destList_[i] == rank_)
{
transit = splitChunks_[i];
}
else if(destList_[i] != -1)
{
//fprintf(stderr, "Sending a message size: %i\n", splitChunks_[i]->getOutSerialBufferSize());
MPI_Request req;
reqs.push_back(req);
MPI_Isend( splitChunks_[i]->getOutSerialBuffer(),
splitChunks_[i]->getOutSerialBufferSize(),
MPI_BYTE, destList_[i], send_data_tag, communicator_, &reqs.back());
}
else
{
MPI_Request req;
reqs.push_back(req);
MPI_Isend( NULL,
0,
MPI_BYTE, i + local_dest_rank_, send_data_tag, communicator_, &reqs.back());
}
}
send_data_tag = (send_data_tag == INT_MAX ? MPI_DATA_TAG : send_data_tag + 1);
}
if(role == DECAF_REDIST_DEST)
{
int nbRecep;
if(isSource()) //Overlapping case
nbRecep = nbSources_-1;
else
nbRecep = nbSources_;
for(int i = 0; i < nbRecep; i++)
{
MPI_Status status;
MPI_Probe(MPI_ANY_SOURCE, recv_data_tag, communicator_, &status);
if (status.MPI_TAG == recv_data_tag) // normal, non-null get
{
int nitems; // number of items (of type dtype) in the message
MPI_Get_count(&status, MPI_BYTE, &nitems);
if(nitems > 0)
{
//Allocating the space necessary
data->allocate_serial_buffer(nitems);
MPI_Recv(data->getInSerialBuffer(), nitems, MPI_BYTE, status.MPI_SOURCE,
status.MPI_TAG, communicator_, &status);
// The dynamic type of merge is given by the user
// NOTE : examin if it's not more efficient to receive everything
// and then merge. Memory footprint more important but allows to
// aggregate the allocations etc
if(mergeMethod_ == DECAF_REDIST_MERGE_STEP)
data->merge();
else if(mergeMethod_ == DECAF_REDIST_MERGE_ONCE)
//data->unserializeAndStore();
data->unserializeAndStore(data->getInSerialBuffer(), nitems);
else
{
std::cout<<"ERROR : merge method not specified. Abording."<<std::endl;
MPI_Abort(MPI_COMM_WORLD, 0);
}
}
else
{
MPI_Recv(NULL, 0, MPI_BYTE,status.MPI_SOURCE,
status.MPI_TAG, communicator_, &status);
}
}
}
// Checking if we have something in transit
if(!transit.empty())
{
if(mergeMethod_ == DECAF_REDIST_MERGE_STEP)
data->merge(transit->getOutSerialBuffer(), transit->getOutSerialBufferSize());
else if (mergeMethod_ == DECAF_REDIST_MERGE_ONCE)
data->unserializeAndStore(transit->getOutSerialBuffer(), transit->getOutSerialBufferSize());
//We don't need it anymore. Cleaning for the next iteration
transit.reset();
}
if(mergeMethod_ == DECAF_REDIST_MERGE_ONCE)
data->mergeStoredData();
recv_data_tag = (recv_data_tag == INT_MAX ? MPI_DATA_TAG : recv_data_tag + 1);
}
}
void
decaf::
RedistMPI::flush()
{
if (reqs.size())
MPI_Waitall(reqs.size(), &reqs[0], MPI_STATUSES_IGNORE);
reqs.clear();
// data have been received, we can clean it now
// Cleaning the data here because synchronous send.
// TODO: move to flush when switching to asynchronous send
splitChunks_.clear();
destList_.clear();
}
void
decaf::
RedistMPI::shutdown()
{
for (size_t i = 0; i < reqs.size(); i++)
MPI_Request_free(&reqs[i]);
reqs.clear();
// data have been received, we can clean it now
// Cleaning the data here because synchronous send.
// TODO: move to flush when switching to asynchronous send
splitChunks_.clear();
destList_.clear();
}
void
decaf::
RedistMPI::clearBuffers()
{
splitBuffer_.clear();
}
| 34.744939 | 133 | 0.582265 | tpeterka |
242baf542b904488327e53dd9fa04928a68d698e | 8,556 | cc | C++ | Alignment/MuonAlignment/plugins/MuonGeometryDBConverter.cc | pasmuss/cmssw | 566f40c323beef46134485a45ea53349f59ae534 | [
"Apache-2.0"
] | null | null | null | Alignment/MuonAlignment/plugins/MuonGeometryDBConverter.cc | pasmuss/cmssw | 566f40c323beef46134485a45ea53349f59ae534 | [
"Apache-2.0"
] | null | null | null | Alignment/MuonAlignment/plugins/MuonGeometryDBConverter.cc | pasmuss/cmssw | 566f40c323beef46134485a45ea53349f59ae534 | [
"Apache-2.0"
] | null | null | null | // -*- C++ -*-
//
// Package: MuonGeometryDBConverter
// Class: MuonGeometryDBConverter
//
/**\class MuonGeometryDBConverter MuonGeometryDBConverter.cc Alignment/MuonAlignment/plugins/MuonGeometryDBConverter.cc
Description: <one line class summary>
Implementation:
<Notes on implementation>
*/
//
// Original Author: Jim Pivarski
// Created: Sat Feb 16 00:04:55 CST 2008
// $Id: MuonGeometryDBConverter.cc,v 1.15 2011/09/15 09:12:01 mussgill Exp $
//
//
// system include files
#include "FWCore/Framework/interface/Frameworkfwd.h"
#include "FWCore/Framework/interface/one/EDAnalyzer.h"
#include "FWCore/Framework/interface/EventSetup.h"
#include "FWCore/Framework/interface/ESHandle.h"
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/MakerMacros.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"
// user include files
#include "Alignment/MuonAlignment/interface/MuonAlignment.h"
#include "Alignment/MuonAlignment/interface/MuonAlignmentInputMethod.h"
#include "Alignment/MuonAlignment/interface/MuonAlignmentInputDB.h"
#include "Alignment/MuonAlignment/interface/MuonAlignmentInputSurveyDB.h"
#include "Alignment/MuonAlignment/interface/MuonAlignmentInputXML.h"
#include "Alignment/MuonAlignment/interface/MuonScenarioBuilder.h"
//
// class decleration
//
class MuonGeometryDBConverter : public edm::one::EDAnalyzer<> {
public:
explicit MuonGeometryDBConverter(const edm::ParameterSet&);
~MuonGeometryDBConverter();
static void fillDescriptions(edm::ConfigurationDescriptions&);
void beginJob() override {};
void endJob() override {};
private:
virtual void analyze(const edm::Event&, const edm::EventSetup&) override;
bool m_done;
std::string m_input, m_output;
std::string m_dtLabel, m_cscLabel;
double m_shiftErr, m_angleErr;
std::string m_fileName;
bool m_getAPEs;
edm::ParameterSet m_misalignmentScenario;
edm::ParameterSet m_outputXML;
};
//
// constants, enums and typedefs
//
//
// static data member definitions
//
//
// constructors and destructor
//
MuonGeometryDBConverter::MuonGeometryDBConverter(const edm::ParameterSet &iConfig)
: m_done(false)
, m_input(iConfig.getParameter<std::string>("input"))
, m_output(iConfig.getParameter<std::string>("output"))
, m_shiftErr(0.)
, m_angleErr(0.)
, m_getAPEs(false)
{
////////////////////////////////////////////////////////////////////
// Version V02-03-02 and earlier of this module had support for //
// "cfg" as an input/output format. It turns out that reading //
// thousands of parameters from a configuration file takes a very //
// long time, so "cfg" wasn't very practical. When I reorganized //
// the code, I didn't bother to port it. //
////////////////////////////////////////////////////////////////////
if (m_input == std::string("ideal")) {}
else if (m_input == std::string("db")) {
m_dtLabel = iConfig.getParameter<std::string>("dtLabel");
m_cscLabel = iConfig.getParameter<std::string>("cscLabel");
m_shiftErr = iConfig.getParameter<double>("shiftErr");
m_angleErr = iConfig.getParameter<double>("angleErr");
m_getAPEs = iConfig.getParameter<bool>("getAPEs");
}
else if (m_input == std::string("surveydb")) {
m_dtLabel = iConfig.getParameter<std::string>("dtLabel");
m_cscLabel = iConfig.getParameter<std::string>("cscLabel");
}
else if (m_input == std::string("scenario")) {
m_misalignmentScenario = iConfig.getParameter<edm::ParameterSet>("MisalignmentScenario");
m_shiftErr = iConfig.getParameter<double>("shiftErr");
m_angleErr = iConfig.getParameter<double>("angleErr");
}
else if (m_input == std::string("xml")) {
m_fileName = iConfig.getParameter<std::string>("fileName");
m_shiftErr = iConfig.getParameter<double>("shiftErr");
m_angleErr = iConfig.getParameter<double>("angleErr");
}
else {
throw cms::Exception("BadConfig") << "input must be \"ideal\", \"db\", \"surveydb\", or \"xml\"." << std::endl;
}
if (m_output == std::string("none")) {}
else if (m_output == std::string("db")) {}
else if (m_output == std::string("surveydb")) {}
else if (m_output == std::string("xml")) {
m_outputXML = iConfig.getParameter<edm::ParameterSet>("outputXML");
}
else {
throw cms::Exception("BadConfig") << "output must be \"none\", \"db\", or \"surveydb\"." << std::endl;
}
}
MuonGeometryDBConverter::~MuonGeometryDBConverter() { }
// ------------ method called to for each event ------------
void
MuonGeometryDBConverter::analyze(const edm::Event &iEvent, const edm::EventSetup &iSetup) {
if (!m_done) {
MuonAlignment *muonAlignment = NULL;
if (m_input == std::string("ideal")) {
MuonAlignmentInputMethod inputMethod;
muonAlignment = new MuonAlignment(iSetup, inputMethod);
muonAlignment->fillGapsInSurvey(0., 0.);
}
else if (m_input == std::string("db")) {
MuonAlignmentInputDB inputMethod(m_dtLabel, m_cscLabel, m_getAPEs);
muonAlignment = new MuonAlignment(iSetup, inputMethod);
if (m_getAPEs) {
muonAlignment->copyAlignmentToSurvey(m_shiftErr, m_angleErr);
}
}
else if (m_input == std::string("surveydb")) {
MuonAlignmentInputSurveyDB inputMethod(m_dtLabel, m_cscLabel);
muonAlignment = new MuonAlignment(iSetup, inputMethod);
muonAlignment->copySurveyToAlignment();
}
else if (m_input == std::string("scenario")) {
MuonAlignmentInputMethod inputMethod;
muonAlignment = new MuonAlignment(iSetup, inputMethod);
MuonScenarioBuilder muonScenarioBuilder(muonAlignment->getAlignableMuon());
muonScenarioBuilder.applyScenario(m_misalignmentScenario);
muonAlignment->copyAlignmentToSurvey(m_shiftErr, m_angleErr);
}
else if (m_input == std::string("xml")) {
MuonAlignmentInputXML inputMethod(m_fileName);
muonAlignment = new MuonAlignment(iSetup, inputMethod);
muonAlignment->fillGapsInSurvey(m_shiftErr, m_angleErr);
}
/////////////
if (muonAlignment) {
if (m_output == std::string("none")) {}
else if (m_output == std::string("db")) {
muonAlignment->saveToDB();
}
else if (m_output == std::string("surveydb")) {
muonAlignment->saveSurveyToDB();
}
else if (m_output == std::string("xml")) {
muonAlignment->writeXML(m_outputXML, iSetup);
}
delete muonAlignment;
}
m_done = true;
} // end if not done
else {
throw cms::Exception("BadConfig") << "Set maxEvents.input to 1. (Your output is okay.)" << std::endl;
}
}
// ------------ method fills 'descriptions' with the allowed parameters for the module ------------
void
MuonGeometryDBConverter::fillDescriptions(edm::ConfigurationDescriptions& descriptions)
{
edm::ParameterSetDescription desc;
desc.setComment("Converts muon geometry between various formats.");
desc.add<std::string>("input", "ideal");
desc.add<std::string>("dtLabel", "");
desc.add<std::string>("cscLabel", "");
desc.add<double>("shiftErr", 1000.0);
desc.add<double>("angleErr", 6.28);
desc.add<bool>("getAPEs", true);
desc.add<std::string>("output", "xml");
desc.add<std::string>("fileName", "REPLACEME.xml");
edm::ParameterSetDescription outputXML;
outputXML.add<std::string>("fileName", "REPLACEME.xml");
outputXML.add<std::string>("relativeto", "ideal");
outputXML.add<bool>("survey", false);
outputXML.add<bool>("rawIds", false);
outputXML.add<bool>("eulerAngles", false);
outputXML.add<int>("precision", 10);
outputXML.addUntracked<bool>("suppressDTBarrel", true);
outputXML.addUntracked<bool>("suppressDTWheels", true);
outputXML.addUntracked<bool>("suppressDTStations", true);
outputXML.addUntracked<bool>("suppressDTChambers", false);
outputXML.addUntracked<bool>("suppressDTSuperLayers", false);
outputXML.addUntracked<bool>("suppressDTLayers", false);
outputXML.addUntracked<bool>("suppressCSCEndcaps", true);
outputXML.addUntracked<bool>("suppressCSCStations", true);
outputXML.addUntracked<bool>("suppressCSCRings", true);
outputXML.addUntracked<bool>("suppressCSCChambers", false);
outputXML.addUntracked<bool>("suppressCSCLayers", false);
desc.add("outputXML", outputXML);
descriptions.add("muonGeometryDBConverter", desc);
}
//define this as a plug-in
DEFINE_FWK_MODULE(MuonGeometryDBConverter);
| 34.224 | 119 | 0.682211 | pasmuss |
242bdced4724b98c665df7ffdfce9bd5370b762c | 42,111 | cpp | C++ | src/QMCHamiltonians/DensityMatrices1B.cpp | bwvdg/qmcpack | cd09fc54b36de2579c9802f5e64b7ec15506f3c3 | [
"NCSA"
] | null | null | null | src/QMCHamiltonians/DensityMatrices1B.cpp | bwvdg/qmcpack | cd09fc54b36de2579c9802f5e64b7ec15506f3c3 | [
"NCSA"
] | 1 | 2020-04-10T15:33:28.000Z | 2020-04-10T15:35:59.000Z | src/QMCHamiltonians/DensityMatrices1B.cpp | bwvdg/qmcpack | cd09fc54b36de2579c9802f5e64b7ec15506f3c3 | [
"NCSA"
] | 1 | 2019-07-23T17:44:39.000Z | 2019-07-23T17:44:39.000Z | //////////////////////////////////////////////////////////////////////////////////////
// This file is distributed under the University of Illinois/NCSA Open Source License.
// See LICENSE file in top directory for details.
//
// Copyright (c) 2016 Jeongnim Kim and QMCPACK developers.
//
// File developed by: Jaron T. Krogel, krogeljt@ornl.gov, Oak Ridge National Laboratory
// Mark A. Berrill, berrillma@ornl.gov, Oak Ridge National Laboratory
//
// File created by: Jaron T. Krogel, krogeljt@ornl.gov, Oak Ridge National Laboratory
//////////////////////////////////////////////////////////////////////////////////////
#include <QMCHamiltonians/DensityMatrices1B.h>
#include <OhmmsData/AttributeSet.h>
#include <QMCWaveFunctions/TrialWaveFunction.h>
#include <Numerics/MatrixOperators.h>
#include <Utilities/IteratorUtility.h>
#include <Utilities/string_utils.h>
#include <QMCWaveFunctions/SPOSetBuilderFactory.h>
namespace qmcplusplus
{
using MatrixOperators::product;
using MatrixOperators::product_AtB;
using MatrixOperators::diag_product;
DensityMatrices1B::DensityMatrices1B(ParticleSet& P, TrialWaveFunction& psi, ParticleSet* Pcl)
: Lattice(P.Lattice),Pq(P),Psi(psi),Pc(Pcl)
{
reset();
}
DensityMatrices1B::DensityMatrices1B(DensityMatrices1B& master, ParticleSet& P, TrialWaveFunction& psi)
: QMCHamiltonianBase(master), Lattice(P.Lattice),Pq(P),Psi(psi),Pc(master.Pc)
{
app_log()<<"dm1b deepcopy"<< std::endl;
reset();
set_state(master);
basis_functions.clone_from(master.basis_functions);
initialize();
app_log()<<"dm1b end deepcopy"<< std::endl;
}
DensityMatrices1B::~DensityMatrices1B()
{
if(initialized)
finalize();
}
QMCHamiltonianBase* DensityMatrices1B::makeClone(ParticleSet& P, TrialWaveFunction& psi)
{
return new DensityMatrices1B(*this,P,psi);
}
void DensityMatrices1B::reset()
{
// uninitialized data
w_trace = NULL;
T_trace = NULL;
Vq_trace = NULL;
Vc_trace = NULL;
Vqq_trace = NULL;
Vqc_trace = NULL;
Vcc_trace = NULL;
basis_size = -1;
nindex = -1;
eindex = -1;
uniform_random = NULL;
// basic HamiltonianBase info
UpdateMode.set(COLLECTABLE,1);
// default values
energy_mat = false;
integrator = uniform_grid;
evaluator = loop;
sampling = volume_based;
scale = 1.0;
center = 0.0;
points = 10;
samples = 10;
warmup = 30;
timestep = .5;
use_drift = false;
warmed_up = false;
metric = 1.0;
write_acceptance_ratio = false;
write_rstats = false;
normalized = false;
check_overlap = false;
check_derivatives = false;
// trace data is required
request.request_scalar("weight");
request.request_array("Kinetic_complex");
request.request_array("Vq");
request.request_array("Vc");
request.request_array("Vqq");
request.request_array("Vqc");
request.request_array("Vcc");
// has not been initialized
initialized = false;
}
bool DensityMatrices1B::put(xmlNodePtr cur)
{
app_log()<<"dm1b put"<< std::endl;
// read in parameters from the input xml
set_state(cur);
// resize local data and perform warmup sampling, if necessary
initialize();
// write a report to the log
report();
if(check_overlap)
test_overlap();
app_log()<<"dm1b end put"<< std::endl;
return true;
}
void DensityMatrices1B::set_state(xmlNodePtr cur)
{
app_log()<<"dm1b set_state"<< std::endl;
bool center_defined=false;
std::string emstr="no";
std::string igstr="uniform_grid";
std::string evstr="loop";
std::string costr="no";
std::string cdstr="no";
std::string arstr="no";
std::string udstr="no";
std::string wrstr="no";
std::string nmstr="no";
std::vector<std::string> sposets;
xmlNodePtr element = cur->xmlChildrenNode;
while(element!=NULL)
{
std::string ename((const char*)element->name);
if(ename=="parameter")
{
std::string name((const char*)(xmlGetProp(element,(const xmlChar*)"name")));
if(name== "basis")
putContent(sposets,element);
else if(name=="energy_matrix")
putContent(emstr,element);
else if(name=="integrator")
putContent(igstr,element);
else if(name=="evaluator")
putContent(evstr,element);
else if(name=="scale")
putContent(scale,element);
else if(name=="center")
{
putContent(center,element);
center_defined = true;
}
else if(name=="points")
putContent(points,element);
else if(name=="samples")
putContent(samples,element);
else if(name=="warmup")
putContent(warmup,element);
else if(name=="timestep")
putContent(timestep,element);
else if(name=="use_drift")
putContent(udstr,element);
else if(name=="check_overlap")
putContent(costr,element);
else if(name=="check_derivatives")
putContent(cdstr,element);
else if(name=="acceptance_ratio")
putContent(arstr,element);
else if(name=="rstats")
putContent(wrstr,element);
else if(name=="normalized")
putContent(nmstr,element);
}
element = element->next;
}
if(scale>1.0+1e-10){
APP_ABORT("DensityMatrices1B::put scale must be less than one");
}else if(scale<0.0-1e-10)
APP_ABORT("DensityMatrices1B::put scale must be greater than zero");
// get volume and cell information
Lattice.reset();
if(!center_defined)
center = Lattice.Center;
volume = Lattice.Volume*std::exp(DIM*std::log(scale));
periodic = Lattice.SuperCellEnum!=SUPERCELL_OPEN;
rcorner = center - scale*Lattice.Center;
energy_mat = emstr=="yes";
if(igstr=="uniform_grid")
{
integrator = uniform_grid;
sampling = volume_based;
samples = pow(points,DIM);
metric = volume/samples;
ind_dims[0] = pow(points,DIM-1);
for(int d=1;d<DIM;++d)
ind_dims[d] = ind_dims[d-1]/points;
}
else if(igstr=="uniform")
{
integrator = uniform;
sampling = volume_based;
metric = volume/samples;
}
else if(igstr=="density")
{
integrator = density;
sampling = metropolis;
metric = 1.0/samples;
}
else
APP_ABORT("DensityMatrices1B::set_state invalid integrator\n valid options are: uniform_grid, uniform, density");
if(evstr=="loop")
evaluator=loop;
else if(evstr=="matrix")
evaluator=matrix;
else
APP_ABORT("DensityMatrices1B::set_state invalid evaluator\n valid options are: loop, matrix");
normalized = nmstr=="yes";
use_drift = udstr=="yes";
check_overlap = costr=="yes";
check_derivatives = cdstr=="yes";
write_rstats = wrstr=="yes";
write_acceptance_ratio = arstr=="yes";
// get the sposets that form the basis
if(sposets.size()==0)
APP_ABORT("DensityMatrices1B::put basis must have at least one sposet");
for(int i=0;i<sposets.size();++i)
{
app_log()<<" sposets requested "<<sposets.size()<<" "<<i<<" "<<sposets[i]<< std::endl;
app_log()<<" size before "<<basis_functions.size()<< std::endl;
basis_functions.add(get_sposet(sposets[i]));
app_log()<<" size after "<<basis_functions.size()<< std::endl;
}
basis_size = basis_functions.size();
if(basis_size<1)
APP_ABORT("DensityMatrices1B::put basis_size must be greater than one");
app_log()<<"dm1b end set_state"<< std::endl;
}
void DensityMatrices1B::set_state(DensityMatrices1B& master)
{
app_log()<<"dm1b set_state master"<< std::endl;
basis_size = master.basis_size;
energy_mat = master.energy_mat;
integrator = master.integrator;
evaluator = master.evaluator;
sampling = master.sampling;
scale = master.scale;
points = master.points;
samples = master.samples;
warmup = master.warmup;
timestep = master.timestep;
use_drift = master.use_drift;
volume = master.volume;
periodic = master.periodic;
metric = master.metric;
rcorner = master.rcorner;
normalized = master.normalized;
for(int d=0;d<DIM;++d)
ind_dims[d] = master.ind_dims[d];
app_log()<<"dm1b end set_state master"<< std::endl;
}
void DensityMatrices1B::initialize()
{
app_log()<<"dm1b initialize"<< std::endl;
// get particle information
SpeciesSet& species = Pq.getSpeciesSet();
nparticles = Pq.getTotalNum();
nspecies = species.size();
int natt = species.numAttributes();
int isize = species.addAttribute("membersize");
if(isize==natt)
APP_ABORT("DensityMatrices1B::set_state Species set does not have the required attribute 'membersize'");
for(int s=0;s<nspecies;++s)
species_size.push_back(species(isize,s));
for(int s=0;s<nspecies;++s)
species_name.push_back(species.speciesName[s]);
// allocate space
basis_values.resize(basis_size);
integrated_values.resize(basis_size);
basis_norms.resize(basis_size);
for(int i=0;i<basis_size;++i)
basis_norms[i] = 1.0;
rsamples.resize(samples);
sample_weights.resize(samples);
if(evaluator==matrix)
{
Phi_MB.resize(samples,basis_size);
for(int s=0;s<nspecies;++s)
{
int specs_size = species_size[s];
Phi_NB.push_back( new Matrix_t(specs_size,basis_size));
Psi_NM.push_back( new Matrix_t(specs_size,samples ));
Phi_Psi_NB.push_back(new Matrix_t(specs_size,basis_size));
N_BB.push_back( new Matrix_t(basis_size,basis_size));
if(energy_mat)
{
E_N.push_back( new Vector_t(specs_size));
E_BB.push_back(new Matrix_t(basis_size,basis_size));
}
}
#ifdef DMCHECK
Phi_MBtmp.resize(samples,basis_size);
for(int s=0;s<nspecies;++s)
{
int specs_size = species_size[s];
Phi_NBtmp.push_back( new Matrix_t(specs_size,basis_size));
Psi_NMtmp.push_back( new Matrix_t(specs_size,samples ));
Phi_Psi_NBtmp.push_back(new Matrix_t(specs_size,basis_size));
N_BBtmp.push_back( new Matrix_t(basis_size,basis_size));
if(energy_mat)
{
E_Ntmp.push_back( new Vector_t(specs_size));
E_BBtmp.push_back(new Matrix_t(basis_size,basis_size));
}
}
#endif
}
if(sampling==metropolis)
{
basis_gradients.resize(basis_size);
basis_laplacians.resize(basis_size);
}
if(!normalized)
normalize();
initialized = true;
app_log()<<"dm1b end initialize"<< std::endl;
}
void DensityMatrices1B::finalize()
{
delete_iter( Phi_NB.begin(), Phi_NB.end() );
delete_iter( Psi_NM.begin(), Psi_NM.end() );
delete_iter( Phi_Psi_NB.begin(), Phi_Psi_NB.end() );
delete_iter( N_BB.begin(), N_BB.end() );
if(energy_mat)
{
delete_iter( E_N.begin(), E_N.end() );
delete_iter( E_BB.begin(), E_BB.end() );
}
#ifdef DMCHECK
delete_iter( Phi_NBtmp.begin(), Phi_NBtmp.end() );
delete_iter( Psi_NMtmp.begin(), Psi_NMtmp.end() );
delete_iter( Phi_Psi_NBtmp.begin(), Phi_Psi_NBtmp.end() );
delete_iter( N_BBtmp.begin(), N_BBtmp.end() );
if(energy_mat)
{
delete_iter( E_Ntmp.begin(), E_Ntmp.end() );
delete_iter( E_BBtmp.begin(), E_BBtmp.end() );
}
#endif
}
void DensityMatrices1B::report(const std::string& pad)
{
std::vector<std::string> integrator_list;
integrator_list.push_back("uniform_grid");
integrator_list.push_back("uniform");
integrator_list.push_back("density");
integrator_list.push_back("no_integrator");
std::vector<std::string> evaluator_list;
evaluator_list.push_back("loop");
evaluator_list.push_back("matrix");
evaluator_list.push_back("no_evaluator");
std::vector<std::string> sampling_list;
sampling_list.push_back("volume_based");
sampling_list.push_back("metropolis");
sampling_list.push_back("no_sampling");
//ostream& out = app_log();
std::ostream& out = std::cout;
out<<pad<<"DensityMatrices1B"<< std::endl;
out<<pad<<" integrator = "<< integrator_list[(int)integrator] << std::endl;
out<<pad<<" sampling = "<< sampling_list[ (int)sampling ] << std::endl;
out<<pad<<" evaluator = "<< evaluator_list[ (int)evaluator ] << std::endl;
out<<pad<<" periodic = "<< periodic << std::endl;
if(sampling==volume_based)
{
PosType rmax = rcorner + 2*scale*Lattice.Center;
out<<pad<<" points = "<< points << std::endl;
out<<pad<<" scale = "<< scale << std::endl;
out<<pad<<" center = "<< center << std::endl;
out<<pad<<" rmin = "<< rcorner << std::endl;
out<<pad<<" rmax = "<< rmax << std::endl;
out<<pad<<" volume = "<< volume << std::endl;
}
else if(sampling==metropolis)
{
out<<pad<<" warmup = "<< warmup << std::endl;
out<<pad<<" timestep = "<< timestep << std::endl;
}
out<<pad<<" metric = "<< metric << std::endl;
out<<pad<<" nparticles = "<< nparticles << std::endl;
out<<pad<<" nspecies = "<< nspecies << std::endl;
for(int s=0;s<nspecies;++s)
out<<pad<<" species "<<s<<" = "<< species_size[s] << std::endl;
out<<pad<<" basis_size = "<< basis_size << std::endl;
out<<pad<<" samples = "<< samples << std::endl;
out<<pad<<" energy_mat = "<< energy_mat << std::endl;
out<<pad<<" initialized = "<< initialized << std::endl;
out<<pad<<" rsamples : "<< rsamples.size()<< std::endl;
if(evaluator==matrix)
{
out<<pad<<" Phi_MB : "<< Phi_MB.rows()<<" "<<Phi_MB.cols()<< std::endl;
for(int s=0;s<nspecies;++s)
{
out<<pad<<" matrices/vectors for species "<<s<< std::endl;
if(energy_mat)
out<<pad<<" E_N : "<< E_N[s]->size()<< std::endl;
out<<pad<<" Phi_NB : "<< Phi_NB[s]->rows()<<" "<<Phi_NB[s]->cols()<< std::endl;
out<<pad<<" Psi_NM : "<< Psi_NM[s]->rows()<<" "<<Psi_NM[s]->cols()<< std::endl;
out<<pad<<" Phi_Psi_NB : "<< Phi_Psi_NB[s]->rows()<<" "<<Phi_Psi_NB[s]->cols()<< std::endl;
out<<pad<<" N_BB : "<< N_BB[s]->rows()<<" "<<N_BB[s]->cols()<< std::endl;
if(energy_mat)
out<<pad<<" E_BB : "<< E_BB[s]->rows()<<" "<<E_BB[s]->cols()<< std::endl;
}
}
out<<pad<<" basis_norms"<< std::endl;
for(int i=0;i<basis_size;++i)
out<<pad<<" "<<i<<" "<<basis_norms[i]<< std::endl;
out<<pad<<"end DensityMatrices1B"<< std::endl;
}
void DensityMatrices1B::get_required_traces(TraceManager& tm)
{
app_log()<<"dm1b get_required_traces"<< std::endl;
w_trace = tm.get_real_trace("weight");
if(energy_mat)
{
T_trace = tm.get_complex_trace(Pq,"Kinetic_complex");
Vq_trace = tm.get_real_combined_trace(Pq,"Vq");
Vqq_trace = tm.get_real_combined_trace(Pq,"Vqq");
Vqc_trace = tm.get_real_combined_trace(Pq,"Vqc");
if(Pc)
{
Vc_trace = tm.get_real_combined_trace(*Pc,"Vc");
Vcc_trace = tm.get_real_combined_trace(*Pc,"Vcc");
}
E_samp.resize(nparticles);
}
have_required_traces = true;
app_log()<<"dm1b end get_required_traces"<< std::endl;
}
void DensityMatrices1B::setRandomGenerator(RandomGenerator_t* rng)
{
app_log()<<"dm1b setRandomGenerator"<< std::endl;
uniform_random = rng;
app_log()<<"dm1b end setRandomGenerator"<< std::endl;
}
void DensityMatrices1B::addObservables(PropertySetType& plist,BufferType& collectables)
{
app_log()<<"dm1b addObservables"<< std::endl;
#if defined(QMC_COMPLEX)
int nentries = 2*basis_size*basis_size*nspecies;
#else
int nentries = basis_size*basis_size*nspecies;
#endif
myIndex=collectables.current();
nindex=myIndex;
std::vector<RealType> ntmp(nentries);
collectables.add(ntmp.begin(),ntmp.end());
if(energy_mat)
{
eindex = nindex+nentries;
std::vector<RealType> etmp(nentries);
collectables.add(etmp.begin(),etmp.end());
}
app_log()<<"dm1b end addObservables"<< std::endl;
}
void DensityMatrices1B::registerCollectables(std::vector<observable_helper*>& h5desc, hid_t gid) const
{
app_log()<<"dm1b registerCollectables"<< std::endl;
#if defined(QMC_COMPLEX)
std::vector<int> ng(3);
ng[0] = basis_size;
ng[1] = basis_size;
ng[2] = 2;
int nentries = ng[0]*ng[1]*ng[2];
#else
std::vector<int> ng(2);
ng[0] = basis_size;
ng[1] = basis_size;
int nentries = ng[0]*ng[1];
#endif
std::string dname = myName;
hid_t dgid=H5Gcreate(gid,dname.c_str(),0);
std::string nname = "number_matrix";
hid_t ngid=H5Gcreate(dgid,nname.c_str(),0);
for(int s=0;s<nspecies;++s)
{
observable_helper* oh;
oh = new observable_helper(species_name[s]);
oh->set_dimensions(ng,nindex+s*nentries);
oh->open(ngid);
h5desc.push_back(oh);
}
if(energy_mat)
{
std::string ename = "energy_matrix";
hid_t egid=H5Gcreate(dgid,ename.c_str(),0);
for(int s=0;s<nspecies;++s)
{
observable_helper* oh;
oh = new observable_helper(species_name[s]);
oh->set_dimensions(ng,eindex+s*nentries);
oh->open(egid);
h5desc.push_back(oh);
}
}
app_log()<<"dm1b end registerCollectables"<< std::endl;
}
void DensityMatrices1B::warmup_sampling()
{
if(sampling==metropolis)
{
if(!warmed_up)
{
diffusion(std::sqrt(timestep),rpcur);
rpcur += center;
if(integrator==density)
density_drift(rpcur,rhocur,dpcur);
else
APP_ABORT("DensityMatrices1B::warmup_sampling invalid integrator");
}
generate_samples(1.0,warmup);
warmed_up = true;
}
}
DensityMatrices1B::Return_t DensityMatrices1B::evaluate(ParticleSet& P)
{
if(have_required_traces || !energy_mat)
{
if(check_derivatives)
test_derivatives();
if(evaluator==loop)
evaluate_loop(P);
else if(evaluator==matrix)
evaluate_matrix(P);
else
APP_ABORT("DensityMatrices1B::evaluate invalid evaluator");
}
return 0.0;
}
DensityMatrices1B::Return_t DensityMatrices1B::evaluate_matrix(ParticleSet& P)
{
//perform warmup sampling the first time
if(!warmed_up)
warmup_sampling();
// get weight and single particle energy trace data
RealType weight;
if(energy_mat)
weight=w_trace->sample[0]*metric;
else
weight=tWalker->Weight*metric;
if(energy_mat)
get_energies(E_N); // energies : particles x 1
// compute sample positions (monte carlo or deterministic)
generate_samples(weight);
// compute basis and wavefunction ratio values in matrix form
generate_sample_basis(Phi_MB); // basis : samples x basis_size
generate_sample_ratios(Psi_NM); // qmcplusplus::conj(Psi ratio) : particles x samples
generate_particle_basis(P,Phi_NB); // qmcplusplus::conj(basis) : particles x basis_size
// perform integration via matrix products
for(int s=0;s<nspecies;++s)
{
Matrix_t& Psi_nm = *Psi_NM[s];
Matrix_t& Phi_Psi_nb = *Phi_Psi_NB[s];
Matrix_t& Phi_nb = *Phi_NB[s];
diag_product(Psi_nm,sample_weights,Psi_nm);
product(Psi_nm,Phi_MB,Phi_Psi_nb); // ratio*basis : particles x basis_size
product_AtB(Phi_nb,Phi_Psi_nb,*N_BB[s]); // qmcplusplus::conj(basis)^T*ratio*basis : basis_size^2
if(energy_mat)
{
Vector_t& E = *E_N[s];
diag_product(E,Phi_nb,Phi_nb); // diag(energies)*qmcplusplus::conj(basis)
product_AtB(Phi_nb,Phi_Psi_nb,*E_BB[s]);// (energies*qmcplusplus::conj(basis))^T*ratio*basis
}
}
// accumulate data into collectables
const int basis_size2 = basis_size*basis_size;
int ij=nindex;
for(int s=0;s<nspecies;++s)
{
//int ij=nindex; // for testing
const Matrix_t& NDM = *N_BB[s];
for(int n=0;n<basis_size2;++n)
{
Value_t val = NDM(n);
P.Collectables[ij] += real(val);
ij++;
#if defined(QMC_COMPLEX)
P.Collectables[ij] += imag(val);
ij++;
#endif
}
}
if(energy_mat)
{
int ij=eindex;
for(int s=0;s<nspecies;++s)
{
//int ij=eindex; // for testing
const Matrix_t& EDM = *E_BB[s];
for(int n=0;n<basis_size2;++n)
{
Value_t val = EDM(n);
P.Collectables[ij] += real(val);
ij++;
#if defined(QMC_COMPLEX)
P.Collectables[ij] += imag(val);
ij++;
#endif
}
}
}
// jtk come back to this
// why are matrices so similar across species?
// O atom, einspline, points=20, blocks=1, steps=1
//
//app_log()<<" ntraces = ";
//for(int s=0;s<nspecies;++s)
//{
// const Matrix_t& NDM = *N_BB[s];
// Value_t ntrace = 0.0;
// for(int i=0;i<basis_size;++i)
// ntrace+=NDM(i,i);
// app_log()<<ntrace<<" ";
//}
//app_log()<< std::endl;
//
//app_log()<<"nmatrices"<< std::endl;
//for(int s=0;s<nspecies;++s)
//{
// app_log()<<" species "<<s<< std::endl;
// const Matrix_t& NDM = *N_BB[s];
// for(int i=0;i<basis_size;++i)
// {
// for(int j=0;j<basis_size;++j)
// app_log()<<" "<<real(NDM(i,j));
// app_log()<< std::endl;
// }
//}
//
//app_log()<<"positions"<< std::endl;
//int p=0;
//for(int s=0;s<nspecies;++s)
//{
// app_log()<<" species "<<s<< std::endl;
// for(int ps=0;ps<species_size[s];++ps,++p)
// app_log()<<" "<<p<<" "<<P.R[p]-P.Lattice.Center<< std::endl;
//}
//
////app_log()<<"basis_values"<< std::endl;
////int p=0;
////for(int s=0;s<nspecies;++s)
////{
//// app_log()<<" species "<<s<< std::endl;
//// for(int ps=0;ps<species_size[s];++ps,++p)
//// app_log()<<" "<<p<<" "<<P.R[p]<< std::endl;
////}
#ifdef DMCHECK
report();
app_log()<<"DM Check"<< std::endl;
evaluate_check(P);
compare(" Phi_MB",Phi_MB,Phi_MBtmp);
for(int s=0;s<nspecies;++s)
{
app_log()<<" species "<<s<< std::endl;
compare(" E_N ", *E_N[s] , *E_Ntmp[s]);
compare(" Phi_NB ", *Phi_NB[s] , *Phi_NBtmp[s]);
compare(" Psi_NM ", *Psi_NM[s] , *Psi_NMtmp[s]);
compare(" Phi_Psi_NB", *Phi_Psi_NB[s], *Phi_Psi_NBtmp[s],true);
compare(" N_BB ", *N_BB[s] , *N_BBtmp[s],true);
compare(" E_BB ", *E_BB[s] , *E_BBtmp[s],true);
}
app_log()<<"end DM Check"<< std::endl;
APP_ABORT("DM Check");
#endif
return 0.0;
}
DensityMatrices1B::Return_t DensityMatrices1B::evaluate_check(ParticleSet& P)
{
#ifdef DMCHECK
APP_ABORT("DensityMatrices1B::evaluate_check use of E_trace in this function needs to be replaces with get_energies() and E_samp");
int n=0;
for(int s=0;s<nspecies;++s)
{
Matrix_t& Phi_mb = Phi_MBtmp;
Matrix_t& Psi_nm = *Psi_NMtmp[s];
Matrix_t& Phi_Psi_nb = *Phi_Psi_NBtmp[s];
Matrix_t& Phi_nb = *Phi_NBtmp[s];
Vector_t& E_n = *E_Ntmp[s];
Matrix_t& N_bb = *N_BBtmp[s];
Matrix_t& E_bb = *E_BBtmp[s];
for(int ij=0;ij<basis_size*basis_size;++ij)
N_bb(ij) = 0.0;
for(int ij=0;ij<basis_size*basis_size;++ij)
E_bb(ij) = 0.0;
for(int ns=0;ns<species_size[s];++ns,++n)
{
std::fill(integrated_values.begin(),integrated_values.end(),0.0);
for(int m=0;m<samples;++m)
{
PosType& rsamp = rsamples[m];
update_basis(rsamp);
PosType dr = rsamp-P.R[n];
P.makeMove(n,dr);
Value_t ratio = sample_weights[m]*qmcplusplus::conj(Psi.full_ratio(P,n));
P.rejectMove(n);
for(int i=0;i<basis_size;++i)
{
integrated_values[i]+=ratio*basis_values[i];
Phi_mb(m,i) = basis_values[i];
}
Psi_nm(ns,m) = ratio;
}
update_basis(P.R[n]);
for(int i=0;i<basis_size;++i)
Phi_Psi_nb(ns,i) = integrated_values[i];
for(int i=0;i<basis_size;++i)
Phi_nb(ns,i) = qmcplusplus::conj(basis_values[i]);
for(int i=0;i<basis_size;++i)
{
Value_t phi_i = qmcplusplus::conj(basis_values[i]);
for(int j=0;j<basis_size;++j)
{
Value_t val = phi_i*integrated_values[j];
N_bb(i,j) += val;
}
}
if(energy_mat)
{
RealType e_n = E_trace->sample[n]; //replace this with traces access later
E_n[ns] = e_n;
for(int i=0;i<basis_size;++i)
{
Value_t ephi_i = e_n*qmcplusplus::conj(basis_values[i]);
Phi_nb(ns,i) = ephi_i;
for(int j=0;j<basis_size;++j)
{
Value_t val = ephi_i*integrated_values[j];
E_bb(i,j) += val;
}
}
}
}
}
#endif
return 0.0;
}
DensityMatrices1B::Return_t DensityMatrices1B::evaluate_loop(ParticleSet& P)
{
const int basis_size2 = basis_size*basis_size;
if(!warmed_up)
warmup_sampling();
RealType weight;
if(energy_mat)
weight=w_trace->sample[0]*metric;
else
weight=tWalker->Weight*metric;
int nparticles = P.getTotalNum();
generate_samples(weight);
int n=0;
for(int s=0;s<nspecies;++s)
{
for(int ns=0;ns<species_size[s];++ns,++n)
{
integrate(P,n);
update_basis(P.R[n]);
int ij = nindex + s*basis_size2;
for(int i=0;i<basis_size;++i)
{
Value_t phi_i = qmcplusplus::conj(basis_values[i]);
for(int j=0;j<basis_size;++j)
{
Value_t val = phi_i*integrated_values[j];
P.Collectables[ij] += real(val);
ij++;
#if defined(QMC_COMPLEX)
P.Collectables[ij] += imag(val);
ij++;
#endif
}
}
if(energy_mat)
{
RealType e_n = E_trace->sample[n]; //replace this with traces access later
int ij = eindex + s*basis_size2;
for(int i=0;i<basis_size;++i)
{
Value_t ephi_i = e_n*qmcplusplus::conj(basis_values[i]);
for(int j=0;j<basis_size;++j)
{
Value_t val = ephi_i*integrated_values[j];
P.Collectables[ij] += real(val);
ij++;
#if defined(QMC_COMPLEX)
P.Collectables[ij] += imag(val);
ij++;
#endif
}
}
}
}
}
return 0.0;
}
inline void DensityMatrices1B::generate_samples(RealType weight,int steps)
{
RandomGenerator_t& rng = *uniform_random;
bool save = false;
if(steps==0)
{
save = true;
steps = samples;
}
if(integrator==uniform_grid)
generate_uniform_grid(rng);
else if(integrator==uniform)
generate_uniform_samples(rng);
else if(integrator==density)
generate_density_samples(save,steps,rng);
if(save)
{
if(sampling==metropolis)
{
sample_weights*=weight;
}
else
{
std::fill(sample_weights.begin(),sample_weights.end(),weight);
}
}
// temporary check
if(write_rstats && omp_get_thread_num()==0)
{
PosType rmin = std::numeric_limits<RealType>::max();
PosType rmax = -std::numeric_limits<RealType>::max();
PosType rmean = 0.0;
PosType rstd = 0.0;
for(int s=0;s<rsamples.size();++s)
for(int d=0;d<DIM;++d)
{
RealType rd = rsamples[s][d];
rmin[d] = std::min(rmin[d],rd);
rmax[d] = std::max(rmax[d],rd);
rmean[d] += rd;
rstd[d] += rd*rd;
}
rmean/=rsamples.size();
rstd/=rsamples.size();
for(int d=0;d<DIM;++d)
rstd[d] = std::sqrt(rstd[d]-rmean[d]*rmean[d]);
app_log()<<"\nrsamples properties:"<< std::endl;
app_log()<<" rmin = "<<rmin<< std::endl;
app_log()<<" rmax = "<<rmax<< std::endl;
app_log()<<" rmean = "<<rmean<< std::endl;
app_log()<<" rstd = "<<rstd<< std::endl;
}
}
inline void DensityMatrices1B::generate_uniform_grid(RandomGenerator_t& rng)
{
PosType rp;
PosType ushift = 0.0;
RealType du = scale/points;
for(int d=0;d<DIM;++d)
ushift[d] += rng()*du;
for(int s=0;s<samples;++s)
{
int nrem = s;
for(int d=0;d<DIM-1;++d)
{
int ind = nrem/ind_dims[d];
rp[d] = ind*du + ushift[d];
nrem-=ind*ind_dims[d];
}
rp[DIM-1] = nrem*du + ushift[DIM-1];
rsamples[s] = Lattice.toCart(rp) + rcorner;
}
}
inline void DensityMatrices1B::generate_uniform_samples(RandomGenerator_t& rng)
{
PosType rp;
for(int s=0;s<samples;++s)
{
for(int d=0;d<DIM;++d)
rp[d] = scale*rng();
rsamples[s] = Lattice.toCart(rp) + rcorner;
}
}
inline void DensityMatrices1B::generate_density_samples(bool save,int steps,RandomGenerator_t& rng)
{
RealType sqt = std::sqrt(timestep);
RealType ot = 1.0/timestep;
PosType r = rpcur; //current position
PosType d = dpcur; //current drift
RealType rho = rhocur; //current density
for(int s=0;s<steps;++s)
{
nmoves++;
PosType n,rp,dp,ds; //diffusion, trial pos/drift, drift sum
RealType rhop,ratio,Pacc; //trial density, dens ratio, acc prob
diffusion(sqt,n); //get diffusion
if(use_drift)
{
rp = r + n + d; //update trial position
density_drift(rp,rhop,dp); //get trial drift and density
ratio = rhop/rho; //density ratio
ds = dp+d; //drift sum
Pacc = ratio*std::exp(-ot*(dot(n,ds)+.5*dot(ds,ds))); //acceptance probability
}
else
{
rp = r + n; //update trial position
density_only(rp,rhop); //get trial density
ratio = rhop/rho; //density ratio
Pacc = ratio; //acceptance probability
}
if(rng()<Pacc)
{//accept move
r = rp;
d = dp;
rho = rhop;
naccepted++;
}
if(save)
{
rsamples[s] = r;
sample_weights[s] = 1.0/rho;
}
}
acceptance_ratio = RealType(naccepted)/nmoves;
if(write_acceptance_ratio && omp_get_thread_num()==0)
app_log()<<"dm1b acceptance_ratio = "<<acceptance_ratio<< std::endl;
rpcur = r;
dpcur = d;
rhocur = rho;
}
inline void DensityMatrices1B::diffusion(RealType sqt,PosType& diff)
{
assignGaussRand(&diff[0],DIM,*uniform_random);
diff *= sqt;
}
inline void DensityMatrices1B::density_only(const PosType& r,RealType& dens)
{
update_basis(r);
dens=0.0;
for(int i=0;i<basis_size;++i)
{
Value_t b = basis_values[i];
dens += std::abs(qmcplusplus::conj(b)*b);
}
dens /= basis_size;
}
inline void DensityMatrices1B::density_drift(const PosType& r,RealType& dens,PosType& drift)
{
update_basis_d012(r);
dens=0.0;
drift=0.0;
for(int i=0;i<basis_size;++i)
{
const Grad_t& bg = basis_gradients[i];
Value_t b = basis_values[i];
Value_t bc = qmcplusplus::conj(b);
dens += std::abs(bc*b);
for(int d=0;d<DIM;++d)
drift[d] += prod_real(bc,bg[d]);
}
drift *= timestep/dens;
dens /= basis_size;
}
typedef DensityMatrices1B::RealType RealType;
typedef DensityMatrices1B::Value_t Value_t;
inline RealType accum_constant(CombinedTraceSample<TraceReal>* etrace,RealType weight=1.0)
{
RealType E=0.0;
if(etrace)
{
etrace->combine();
for(int p=0;p<etrace->sample.size();++p)
E += etrace->sample[p];
}
return weight*E;
}
template<typename T>
inline void accum_sample(std::vector<Value_t>& E_samp,CombinedTraceSample<T>* etrace,RealType weight=1.0)
{
if(etrace)
{
etrace->combine();
for(int p=0;p<etrace->sample.size();++p)
E_samp[p] += weight*etrace->sample[p];
}
}
template<typename T>
inline void accum_sample(std::vector<Value_t>& E_samp,TraceSample<T>* etrace,RealType weight=1.0)
{
#ifdef QMC_COMPLEX
if(etrace)
for(int p=0;p<etrace->sample.size();++p)
E_samp[p] += weight*etrace->sample[p];
#else
if(etrace)
for(int p=0;p<etrace->sample.size();++p)
E_samp[p] += weight*real(etrace->sample[p]);
#endif
}
void DensityMatrices1B::get_energies(std::vector<Vector_t*>& E_n)
{
Value_t Vc = 0;
Vc += accum_constant(Vc_trace);
Vc += accum_constant(Vcc_trace);
Vc /= nparticles;
std::fill(E_samp.begin(),E_samp.end(),Vc);
accum_sample(E_samp,T_trace);
accum_sample(E_samp,Vq_trace);
accum_sample(E_samp,Vqq_trace);
accum_sample(E_samp,Vqc_trace,2.0);
int p=0;
for(int s=0;s<nspecies;++s)
{
Vector_t& E = *E_n[s];
for(int ps=0;ps<E.size();++ps,++p)
E[ps] = E_samp[p];
}
//E_trace->combine();
//RealType E = 0.0;
//for(int p=0;p<nparticles;++p)
// E += E_samp[p];
//app_log()<<" E = "<<E<<" "<<E_trace->sample[0]<< std::endl;
//APP_ABORT("dm1b::get_energies check sp traces");
}
void DensityMatrices1B::generate_sample_basis(Matrix_t& Phi_mb)
{
int mb=0;
for(int m=0;m<samples;++m)
{
update_basis(rsamples[m]);
for(int b=0;b<basis_size;++b,++mb)
Phi_mb(mb) = basis_values[b];
}
}
void DensityMatrices1B::generate_sample_ratios(std::vector<Matrix_t*> Psi_nm)
{
int p=0;
for(int s=0;s<nspecies;++s)
{
int nm=0;
Matrix_t& P_nm = *Psi_nm[s];
for(int n=0;n<species_size[s];++n,++p)
{
PosType& Rp = Pq.R[p];
for(int m=0;m<samples;++m,++nm)
{
Pq.makeMove(p,rsamples[m]-Rp);
P_nm(nm) = qmcplusplus::conj(Psi.full_ratio(Pq,p));
Pq.rejectMove(p);
}
}
}
}
void DensityMatrices1B::generate_particle_basis(ParticleSet& P,std::vector<Matrix_t*>& Phi_nb)
{
int p=0;
for(int s=0;s<nspecies;++s)
{
int nb=0;
Matrix_t& P_nb = *Phi_nb[s];
for(int n=0;n<species_size[s];++n,++p)
{
update_basis(P.R[p]);
for(int b=0;b<basis_size;++b,++nb)
P_nb(nb) = qmcplusplus::conj(basis_values[b]);
}
}
}
inline void DensityMatrices1B::integrate(ParticleSet& P,int n)
{
std::fill(integrated_values.begin(),integrated_values.end(),0.0);
for(int s=0;s<samples;++s)
{
PosType& rsamp = rsamples[s];
update_basis(rsamp);
P.makeMove(n,rsamp-P.R[n]);
Value_t ratio = sample_weights[s]*qmcplusplus::conj(Psi.full_ratio(P,n));
P.rejectMove(n);
for(int i=0;i<basis_size;++i)
integrated_values[i]+=ratio*basis_values[i];
}
}
inline void DensityMatrices1B::update_basis(const PosType& r)
{
Pq.makeMove(0,r-Pq.R[0]);
basis_functions.evaluate(Pq,0,basis_values);
Pq.rejectMove(0);
for(int i=0;i<basis_size;++i)
basis_values[i]*=basis_norms[i];
}
inline void DensityMatrices1B::update_basis_d012(const PosType& r)
{
Pq.makeMove(0,r-Pq.R[0]);
basis_functions.evaluate(Pq,0,basis_values,basis_gradients,basis_laplacians);
Pq.rejectMove(0);
for(int i=0;i<basis_size;++i)
basis_values[i]*=basis_norms[i];
for(int i=0;i<basis_size;++i)
basis_gradients[i]*=basis_norms[i];
for(int i=0;i<basis_size;++i)
basis_laplacians[i]*=basis_norms[i];
}
inline void DensityMatrices1B::normalize()
{
int ngrid = std::max(200,points);
int ngtot = pow(ngrid,DIM);
RealType du = scale/ngrid;
RealType dV = volume/ngtot;
PosType rp;
ValueVector_t bnorms;
int gdims[DIM];
gdims[0] = pow(ngrid,DIM-1);
for(int d=1;d<DIM;++d)
gdims[d] = gdims[d-1]/ngrid;
bnorms.resize(basis_size);
for(int i=0;i<basis_size;++i)
bnorms[i] = 0.0;
std::fill(basis_norms.begin(),basis_norms.end(),1.0);
for(int p=0;p<ngtot;++p)
{
int nrem = p;
for(int d=0;d<DIM-1;++d)
{
int ind = nrem/gdims[d];
rp[d] = ind*du+du/2;
nrem-=ind*gdims[d];
}
rp[DIM-1] = nrem*du+du/2;
rp = Lattice.toCart(rp) + rcorner;
update_basis(rp);
for(int i=0;i<basis_size;++i)
bnorms[i] += qmcplusplus::conj(basis_values[i])*basis_values[i]*dV;
}
for(int i=0;i<basis_size;++i)
basis_norms[i] = 1.0/std::sqrt(real(bnorms[i]));
normalized = true;
}
inline void DensityMatrices1B::test_overlap()
{
int ngrid = std::max(200,points);
int ngtot = pow(ngrid,DIM);
PosType rp;
RealType du = scale/ngrid;
RealType dV = volume/ngtot;
PosType rmin = std::numeric_limits<RealType>::max();
PosType rmax = -std::numeric_limits<RealType>::max();
int gdims[DIM];
gdims[0] = pow(ngrid,DIM-1);
for(int d=1;d<DIM;++d)
gdims[d] = gdims[d-1]/ngrid;
Array<Value_t,2> omat;
omat.resize(basis_size,basis_size);
for(int i=0;i<basis_size;++i)
for(int j=0;j<basis_size;++j)
omat(i,j) = 0.0;
for(int p=0;p<ngtot;++p)
{
int nrem = p;
for(int d=0;d<DIM-1;++d)
{
int ind = nrem/gdims[d];
rp[d] = ind*du+du/2;
nrem-=ind*gdims[d];
}
rp[DIM-1] = nrem*du+du/2;
rp = Lattice.toCart(rp) + rcorner;
update_basis(rp);
for(int i=0;i<basis_size;++i)
for(int j=0;j<basis_size;++j)
omat(i,j) += qmcplusplus::conj(basis_values[i])*basis_values[j]*dV;
for(int d=0;d<DIM;++d)
{
rmin[d] = std::min(rmin[d],rp[d]);
rmax[d] = std::max(rmax[d],rp[d]);
}
}
app_log()<<"DensityMatrices1B::test_overlap checking overlap matrix"<< std::endl;
app_log()<<" rmin = "<<rmin<< std::endl;
app_log()<<" rmax = "<<rmax<< std::endl;
app_log()<<" overlap scale "<<std::abs(omat(0,0))<< std::endl;
app_log()<<" overlap matrix:"<< std::endl;
for(int i=0;i<basis_size;++i){
app_log()<< std::endl;
for(int j=0;j<basis_size;++j)
app_log()<<std::abs(omat(i,j))/std::abs(omat(0,0))<<" ";
}
app_log()<< std::endl;
APP_ABORT("DensityMatrices1B::test_overlap");
}
void DensityMatrices1B::test_derivatives()
{
app_log()<<"DensityMatrices1B::test_derivatives checking drift"<< std::endl;
PosType r,rtmp;
RealType delta = 1e-5;
RealType dens,densp,densm;
PosType drift,driftn,drifttmp;
app_log()<<" warming up"<< std::endl;
warmup_sampling();
app_log()<<" generating samples"<< std::endl;
generate_samples(1.0);
app_log()<<" testing derivatives at sample points"<< std::endl;
for(int s=0;s<rsamples.size();++s)
{
r = rsamples[s];
density_drift(r,dens,drift);
for(int d=0;d<DIM;++d)
{
rtmp = r;
rtmp[d] = r[d]+delta;
density_drift(rtmp,densp,drifttmp);
rtmp[d] = r[d]-delta;
density_drift(rtmp,densm,drifttmp);
driftn[d] = (densp-densm)/(2*delta);
}
driftn *= .5*timestep/dens;
app_log()<<s<< std::endl;
app_log()<<" "<<driftn<< std::endl;
app_log()<<" "<<drift<< std::endl;
}
APP_ABORT("DensityMatrices1B::test_derivatives");
}
bool DensityMatrices1B::match(Value_t e1, Value_t e2, RealType tol)
{
return std::abs(e1-e2) < tol;
//return std::abs(2*(e1-e2)/(e1+e2)) < tol;
}
bool DensityMatrices1B::same(Vector_t& v1, Vector_t& v2, RealType tol)
{
if(v1.size()!=v2.size())
APP_ABORT("DensityMatrices1B::same(vector) vectors differ in size");
bool sm = true;
for(int i=0;i<v1.size();++i)
sm &= match(v1[i],v2[i]);
return sm;
}
bool DensityMatrices1B::same(Matrix_t& m1, Matrix_t& m2, RealType tol)
{
if(m1.rows()!=m2.rows() || m1.cols()!=m2.cols())
APP_ABORT("DensityMatrices1B::same(matrix) matrices differ in size");
bool sm = true;
int n = m1.rows()*m1.cols();
for(int i=0;i<n;++i)
sm &= match(m1(i),m2(i));
return sm;
}
void DensityMatrices1B::compare(const std::string& name, Vector_t& v1, Vector_t& v2,bool write,bool diff_only)
{
bool sm = same(v1,v2);
std::string result="differ";
if(sm)
result = "agree";
app_log()<<name<<" "<<result<< std::endl;
if(write && !sm)
for(int i=0;i<v1.size();++i)
app_log()<<" "<<i<<" "<<real(v1[i])<<" "<<real(v2[i])
<<" "<<real(v1[i]/v2[i])<<" "<<real(v2[i]/v1[i])<< std::endl;
}
void DensityMatrices1B::compare(const std::string& name, Matrix_t& m1, Matrix_t& m2,bool write,bool diff_only)
{
bool sm = same(m1,m2);
std::string result="differ";
if(sm)
result = "agree";
app_log()<<name<<" "<<result<< std::endl;
if(write && !sm)
for(int i=0;i<m1.rows();++i)
for(int j=0;j<m1.cols();++j)
if(!diff_only || !match(m1(i,j),m2(i,j)) )
app_log()<<" "<<i<<" "<<j<<" "<<real(m1(i,j))<<" "<<real(m2(i,j))
<<" "<<real(m1(i,j)/m2(i,j))<< std::endl;
}
}
| 29.24375 | 136 | 0.573294 | bwvdg |
242facc4a20ac970c47acb13727499fb142e07fd | 3,634 | cpp | C++ | Source/MetaImg.cpp | AceyT/GBImg | f799cd7cb9aa7175e6ded79e1dc616e6fcb0cf1a | [
"MIT"
] | 1 | 2018-03-19T22:36:14.000Z | 2018-03-19T22:36:14.000Z | Source/MetaImg.cpp | AceyT/GBImg | f799cd7cb9aa7175e6ded79e1dc616e6fcb0cf1a | [
"MIT"
] | null | null | null | Source/MetaImg.cpp | AceyT/GBImg | f799cd7cb9aa7175e6ded79e1dc616e6fcb0cf1a | [
"MIT"
] | null | null | null | #include "MetaImg.hpp"
#include <cstring>
IndexedImage::~IndexedImage()
{
freeBuffer();
}
IndexedImage::IndexedImage(uint32_t _width, uint32_t _height) :
width(_width),
height(_height),
framesLowerBits(0),
framesUpperBits(0),
frameLoop(0),
transparentColor(0xFF),
colorMode((uint8_t)ColorMode::INDEXED),
imgData(nullptr),
size(0)
{
allocateBuffer();
}
IndexedImage::IndexedImage(const IndexedImage& other) :
width(other.width),
height(other.height),
framesLowerBits(other.framesLowerBits),
framesUpperBits(other.framesUpperBits),
frameLoop(other.frameLoop),
transparentColor(other.transparentColor),
colorMode(other.colorMode),
imgData(nullptr),
size(0)
{
allocateBuffer();
std::memcpy(imgData, other.imgData, size);
}
IndexedImage& IndexedImage::operator=(const IndexedImage& other)
{
if (&other != this)
{
freeBuffer();
width = other.width;
height = other.height;
framesLowerBits = other.framesLowerBits;
framesUpperBits = other.framesUpperBits;
frameLoop = other.frameLoop;
transparentColor = other.transparentColor;
colorMode = other.colorMode;
allocateBuffer();
if (other.imgData != nullptr)
std::memcpy(imgData, other.imgData, size);
}
return (*this);
}
void IndexedImage::allocateBuffer()
{
if (width > 0 && height > 0)
{
size = height * ((width+1) / 2);
imgData = new uint8_t[size];
std::memset(imgData, 0, size);
}
}
void IndexedImage::freeBuffer()
{
if (*this)
{
delete[] imgData;
imgData = nullptr;
size = 0;
}
}
uint8_t IndexedImage::getIdxByte(uint8_t x, uint8_t y) const
{
if (*this)
{
uint16_t offset = (y * ((width+1)/2) + x/2);
uint8_t value = imgData[offset];
if (x%2 == 0)
return (value >> 4 & 0x0F);
else
return (value & 0x0F);
}
return(0x00);
}
void IndexedImage::setIdxByte(uint8_t x, uint8_t y, uint8_t val)
{
if (*this)
{
uint16_t offset = (y * ((width+1)/2) + x/2);
uint8_t old = imgData[offset];
if (x%2 == 0)
imgData[offset] = ((val << 4) & 0xF0) + (old & 0x0F);
else
imgData[offset] = (old & 0xF0) + (val & 0x0F);
}
}
MetaImage::~MetaImage()
{
freeBuffer();
}
MetaImage::MetaImage(uint32_t _width, uint32_t _height) :
width(_width),
height(_height),
frames(0),
frameLoop(0),
transparentColor(0xFFFF),
colorMode((uint8_t)ColorMode::RGB_565),
imgData(nullptr),
size(0)
{
allocateBuffer();
}
MetaImage::MetaImage(const MetaImage& other) :
width(other.width),
height(other.height),
frames(other.frames),
frameLoop(other.frameLoop),
transparentColor(other.transparentColor),
colorMode(other.colorMode),
imgData(nullptr),
size(0)
{
allocateBuffer();
std::memcpy(imgData, other.imgData, size);
}
MetaImage& MetaImage::operator=(const MetaImage& other)
{
if (&other != this)
{
freeBuffer();
width = other.width;
height = other.height;
frames = other.frames;
frameLoop = other.frameLoop;
transparentColor = other.transparentColor;
colorMode = other.colorMode;
allocateBuffer();
if (other.imgData != nullptr)
std::memcpy(imgData, other.imgData, size);
}
return (*this);
}
void MetaImage::allocateBuffer()
{
if (width > 0 && height > 0)
{
size = height * width;
imgData = new uint16_t[size];
std::memset(imgData, 0, size);
}
}
void MetaImage::freeBuffer()
{
if (*this)
{
delete[] imgData;
imgData = nullptr;
size = 0;
}
}
RGB565 MetaImage::getColor(uint16_t x, uint16_t y) const
{
if (*this)
{
uint32_t offset = y * width + x;
return (imgData[offset]);
}
return(0x0000);
}
void MetaImage::setColor(uint16_t x, uint16_t y, RGB565 val)
{
if (*this)
{
uint32_t offset = y * width + x;
imgData[offset] = val;
}
}
| 18.446701 | 65 | 0.67749 | AceyT |
24316af1a7c54cf6fb8825727c98eb0ac574cd60 | 1,365 | cpp | C++ | ch13_ubuntu/src/frame.cpp | Little-Potato-1990/slambook2 | 9309c29ed2d2d7efe2fe7c35713faade91309efc | [
"MIT"
] | null | null | null | ch13_ubuntu/src/frame.cpp | Little-Potato-1990/slambook2 | 9309c29ed2d2d7efe2fe7c35713faade91309efc | [
"MIT"
] | null | null | null | ch13_ubuntu/src/frame.cpp | Little-Potato-1990/slambook2 | 9309c29ed2d2d7efe2fe7c35713faade91309efc | [
"MIT"
] | null | null | null | /*
* <one line to give the program's name and a brief idea of what it does.>
* Copyright (C) 2016 <copyright holder> <email>
*
* 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 <http://www.gnu.org/licenses/>.
*
*/
#include "myslam/frame.h"
namespace myslam {
Frame::Frame(long id, double time_stamp, const SE3 &pose, const Mat &left,
const Mat &right)
: id_(id),
time_stamp_(time_stamp),
pose_(pose),
left_img_(left),
right_img_(right) {}
Frame::Ptr Frame::CreateFrame() {
static long factory_id = 0;
Frame::Ptr new_frame(new Frame);
new_frame->id_ = factory_id++;
return new_frame;
}
void Frame::SetKeyFrame() {
static long keyframe_factory_id = 0;
is_keyframe_ = true;
keyframe_id_ = keyframe_factory_id++;
}
} // namespace myslam
| 29.673913 | 74 | 0.701832 | Little-Potato-1990 |
24324a1ffde62b60851d6b01ac2a8b9ce366852c | 6,093 | cxx | C++ | Modules/Segmentation/LabelVoting/test/itkLabelVotingImageFilterTest.cxx | rmukh/ITK | 0fcfaf1288928a76c3ef2b3fcc8b6e53246bfbba | [
"Apache-2.0"
] | null | null | null | Modules/Segmentation/LabelVoting/test/itkLabelVotingImageFilterTest.cxx | rmukh/ITK | 0fcfaf1288928a76c3ef2b3fcc8b6e53246bfbba | [
"Apache-2.0"
] | null | null | null | Modules/Segmentation/LabelVoting/test/itkLabelVotingImageFilterTest.cxx | rmukh/ITK | 0fcfaf1288928a76c3ef2b3fcc8b6e53246bfbba | [
"Apache-2.0"
] | null | null | null | /*=========================================================================
*
* Copyright NumFOCUS
*
* 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
*
* https://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 "itkLabelVotingImageFilter.h"
#include "itkTestingMacros.h"
int
itkLabelVotingImageFilterTest(int, char *[])
{
// Define the dimension of the images
constexpr unsigned int Dimension = 3;
// Declare the pixel types of the images
using PixelType = unsigned int;
// Declare the types of the images
using ImageType = itk::Image<PixelType, Dimension>;
// Input data arrays for test images
const unsigned int dataImageA[8] = { 0, 1, 3, 3, 4, 6, 6, 0 };
const unsigned int dataImageB[8] = { 1, 1, 2, 4, 4, 5, 7, 1 };
const unsigned int dataImageC[8] = { 0, 2, 2, 3, 5, 5, 6, 8 };
// Correct combinations of input images
const unsigned int combinationABC[8] = { 0, 1, 2, 3, 4, 5, 6, 9 };
const unsigned int combinationAB[8] = { 8, 1, 8, 8, 4, 8, 8, 8 };
const unsigned int combinationABundecided255[8] = { 255, 1, 255, 255, 4, 255, 255, 255 };
// Declare the type of the index to access images
using IndexType = itk::Index<Dimension>;
// Declare the type of the size
using SizeType = itk::Size<Dimension>;
// Declare the type of the Region
using RegionType = itk::ImageRegion<Dimension>;
// Declare appropriate Iterator type for the images
using IteratorType = itk::ImageRegionIterator<ImageType>;
// Declare the type for the filter
using LabelVotingImageFilterType = itk::LabelVotingImageFilter<ImageType>;
// Create the input images
auto inputImageA = ImageType::New();
auto inputImageB = ImageType::New();
auto inputImageC = ImageType::New();
// Define their size, and start index
SizeType size;
size[0] = 2;
size[1] = 2;
size[2] = 2;
IndexType start;
start[0] = 0;
start[1] = 0;
start[2] = 0;
RegionType region;
region.SetIndex(start);
region.SetSize(size);
// Initialize Image A
inputImageA->SetLargestPossibleRegion(region);
inputImageA->SetBufferedRegion(region);
inputImageA->SetRequestedRegion(region);
inputImageA->Allocate();
IteratorType it = IteratorType(inputImageA, inputImageA->GetBufferedRegion());
for (int i = 0; i < 8; ++i, ++it)
{
it.Set(dataImageA[i]);
}
// Initialize Image B
inputImageB->SetLargestPossibleRegion(region);
inputImageB->SetBufferedRegion(region);
inputImageB->SetRequestedRegion(region);
inputImageB->Allocate();
it = IteratorType(inputImageB, inputImageB->GetBufferedRegion());
for (int i = 0; i < 8; ++i, ++it)
{
it.Set(dataImageB[i]);
}
// Initialize Image C
inputImageC->SetLargestPossibleRegion(region);
inputImageC->SetBufferedRegion(region);
inputImageC->SetRequestedRegion(region);
inputImageC->Allocate();
it = IteratorType(inputImageC, inputImageC->GetBufferedRegion());
for (int i = 0; i < 8; ++i, ++it)
{
it.Set(dataImageC[i]);
}
// Create the LabelVoting Filter
auto labelVotingFilter = LabelVotingImageFilterType::New();
ITK_EXERCISE_BASIC_OBJECT_METHODS(labelVotingFilter, LabelVotingImageFilter, ImageToImageFilter);
// Test with first two input images with undecided label set to 255
//
// Set the first two input images
labelVotingFilter->SetInput(0, inputImageA);
labelVotingFilter->SetInput(1, inputImageB);
// Set label for undecided pixels
labelVotingFilter->SetLabelForUndecidedPixels(255);
// Execute the filter
labelVotingFilter->Update();
// Get the filter output
ImageType::Pointer outputImage = labelVotingFilter->GetOutput();
// Compare to correct results
it = IteratorType(outputImage, outputImage->GetBufferedRegion());
for (unsigned int i = 0; i < 8; ++i, ++it)
{
if (combinationABundecided255[i] != it.Get())
{
std::cout << "Incorrect result using images A,B and undecided=255: "
<< "i = " << i << ", Expected = " << combinationABundecided255[i] << ", Received = " << it.Get()
<< "\n";
return EXIT_FAILURE;
}
}
// Test with first two input images
//
// unset undecided pixel label; reinstate automatic selection
labelVotingFilter->UnsetLabelForUndecidedPixels();
// Execute the filter
labelVotingFilter->Update();
// Get the filter output
outputImage = labelVotingFilter->GetOutput();
// Compare to correct results
it = IteratorType(outputImage, outputImage->GetBufferedRegion());
for (unsigned int i = 0; i < 8; ++i, ++it)
{
if (combinationAB[i] != it.Get())
{
std::cout << "Incorrect result using images A,B: i = " << i << ", Expected = " << combinationAB[i]
<< ", Received = " << it.Get() << "\n";
return EXIT_FAILURE;
}
}
// Test with all three input images
//
// Set the third input image
labelVotingFilter->SetInput(2, inputImageC);
// Execute the filter
labelVotingFilter->Update();
// Get the filter output
outputImage = labelVotingFilter->GetOutput();
// Compare to correct results
it = IteratorType(outputImage, outputImage->GetBufferedRegion());
for (unsigned int i = 0; i < 8; ++i, ++it)
{
if (combinationABC[i] != it.Get())
{
std::cout << "Incorrect result using images A,B,C: i = " << i << ", Expected = " << combinationABC[i]
<< ", Received = " << it.Get() << "\n";
return EXIT_FAILURE;
}
}
std::cout << "Test succeeded." << std::endl;
// All objects should be automatically destroyed at this point
return EXIT_SUCCESS;
}
| 29.293269 | 112 | 0.653701 | rmukh |
2432878eff17a8322490a9d621032ff8103350d2 | 1,949 | hpp | C++ | src/mlnn/cost_function/SoftmaxTests.hpp | kant/mi-neural-nets | 82aa18fddc1fac9b72d8cd3ddcc61c02569f9e20 | [
"Apache-2.0"
] | null | null | null | src/mlnn/cost_function/SoftmaxTests.hpp | kant/mi-neural-nets | 82aa18fddc1fac9b72d8cd3ddcc61c02569f9e20 | [
"Apache-2.0"
] | 2 | 2019-01-26T21:32:50.000Z | 2019-01-28T19:39:37.000Z | src/mlnn/cost_function/SoftmaxTests.hpp | kant/mi-neural-nets | 82aa18fddc1fac9b72d8cd3ddcc61c02569f9e20 | [
"Apache-2.0"
] | 4 | 2019-01-02T21:38:04.000Z | 2020-06-29T14:28:52.000Z | /*!
* Copyright (C) tkornuta, IBM Corporation 2015-2019
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*!
* @file: SoftmaxTests.hpp
* @Author: Tomasz Kornuta <tkornut@us.ibm.com>
* @Date: Apr 12, 2017
*
* Copyright (c) 2017, Tomasz Kornuta, IBM Corporation. All rights reserved.
*
*/
#ifndef SOFTMAXTESTS_HPP_
#define SOFTMAXTESTS_HPP_
#include <gtest/gtest.h>
// Redefine word "public" so every class field/method will be accessible for tests.
#define private public
#define protected public
#include <mlnn/cost_function/Softmax.hpp>
#include <loss/SquaredErrorLoss.hpp>
/*!
* \brief Test Fixture - 4x1 softmax layer.
* \author tkornuta
*/
class Softmax4x1Float : public ::testing::Test {
public:
// Constructor. Sets layer size.
Softmax4x1Float () : layer(4) {
input_x = MAKE_MATRIX_PTR(float, 4, 1);
output_y = MAKE_MATRIX_PTR(float, 4, 1);
target_y = MAKE_MATRIX_PTR(float, 4, 1);
}
protected:
// Sets test values.
virtual void SetUp() {
(*input_x) << 1, -1, -5, 0.5;
(*output_y) << 0.573281, 0.0775852, 0.00142102, 0.347713;
(*target_y) << 0.5, 0.25, 0.15, 0.10;
}
private:
// Object to be tested.
mic::mlnn::cost_function::Softmax<float> layer;
// Test input x - used in forward pass.
mic::types::MatrixPtr<float> input_x;
// Output y values.
mic::types::MatrixPtr<float> output_y;
// Target y values.
mic::types::MatrixPtr<float> target_y;
};
#endif /* SOFTMAXTESTS_HPP_ */
| 26.337838 | 83 | 0.701898 | kant |
2432c37b3ea4111b8920eddabf064274c4cd559f | 4,554 | cpp | C++ | examples/hello/bpReader/helloBPReaderHeatMap2D.cpp | yunai2384/ADIOS2 | c88fd748720dfdfb0d7f8a529d7838ea86ecfa65 | [
"ECL-2.0",
"Apache-2.0"
] | 2 | 2019-07-12T11:57:03.000Z | 2020-05-14T09:40:01.000Z | examples/hello/bpReader/helloBPReaderHeatMap2D.cpp | yunai2384/ADIOS2 | c88fd748720dfdfb0d7f8a529d7838ea86ecfa65 | [
"ECL-2.0",
"Apache-2.0"
] | null | null | null | examples/hello/bpReader/helloBPReaderHeatMap2D.cpp | yunai2384/ADIOS2 | c88fd748720dfdfb0d7f8a529d7838ea86ecfa65 | [
"ECL-2.0",
"Apache-2.0"
] | 1 | 2019-08-07T21:33:40.000Z | 2019-08-07T21:33:40.000Z | /*
* Distributed under the OSI-approved Apache License, Version 2.0. See
* accompanying file Copyright.txt for details.
*
* helloBPReaderHeatMap.cpp : Writes a heat map in a regular 2D mesh,
* values grow from 0 in increments of 1
*
* temperature[gNx, Ny]
* where: gNx = MPI_size_x * Nx
*
* 0 1 2 ... Ny-1
* Ny Ny+1 Ny+2 ... 2*Ny-1
* ...
* ...
* (gNx-1)*Ny ... gNx*Ny-1
*
*
* Created on: Nov 1, 2017
* Author: William F Godoy godoywf@ornl.gov
*/
#include <algorithm>
#include <ios> //std::ios_base::failure
#include <iostream> //std::cout
#include <mpi.h>
#include <stdexcept> //std::invalid_argument std::exception
#include <vector>
#include <adios2.h>
int main(int argc, char *argv[])
{
MPI_Init(&argc, &argv);
int rank, size;
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
MPI_Comm_size(MPI_COMM_WORLD, &size);
/** Application variable dimensions */
constexpr std::size_t Nx = 10;
constexpr std::size_t Ny = 10;
const adios2::Dims count{Nx, Ny};
const adios2::Dims start{rank * Nx, 0};
const adios2::Dims shape{size * Nx, Ny};
// populate local temperature values
std::vector<unsigned int> temperatures(Nx * Ny);
for (unsigned int i = 0; i < Nx; ++i)
{
const unsigned int iGlobal = static_cast<unsigned int>(start[0] + i);
for (unsigned int j = 0; j < Ny; ++j)
{
const unsigned int value =
static_cast<unsigned int>(iGlobal * shape[1] + j);
temperatures[i * Ny + j] = value;
}
}
try
{
/** ADIOS class factory of IO class objects, Debug is ON by default */
adios2::ADIOS adios(MPI_COMM_WORLD);
// ************************** WRITE
/*** IO class object: settings and factory of Settings: Variables,
* Parameters, Transports, and Execution: Engines */
adios2::IO putHeatMap = adios.DeclareIO("HeatMapWriter");
adios2::Variable<unsigned int> outTemperature =
putHeatMap.DefineVariable<unsigned int>(
"temperature", shape, start, count, adios2::ConstantDims);
/** Will create HeatMap.bp */
adios2::Engine bpWriter =
putHeatMap.Open("HeatMap2D.bp", adios2::Mode::Write);
bpWriter.Put(outTemperature, temperatures.data());
bpWriter.Close();
// ************************** READ
if (rank == 0)
{
adios2::IO getHeatMap = adios.DeclareIO("HeatMapReader");
adios2::Engine bpReader = getHeatMap.Open(
"HeatMap2D.bp", adios2::Mode::Read, MPI_COMM_SELF);
// this just discovers in the metadata file that the variable exists
adios2::Variable<unsigned int> inTemperature =
getHeatMap.InquireVariable<unsigned int>("temperature");
// now read the variable
if (inTemperature)
{
inTemperature.SetSelection({{2, 2}, {6, 1}});
size_t elementsSize = inTemperature.SelectionSize();
std::vector<unsigned int> inTemperatures(elementsSize);
std::cout << "Pre-allocated " << elementsSize << " elements, "
<< elementsSize * sizeof(unsigned int) << " bytes\n";
bpReader.Get(inTemperature, inTemperatures.data(),
adios2::Mode::Sync);
std::cout << "Incoming temperature map:\n";
for (auto i = 0; i < inTemperatures.size(); ++i)
{
std::cout << inTemperatures[i] << " ";
if ((i + 1) % inTemperature.Count().back() == 0)
{
std::cout << "\n";
}
}
std::cout << "\n";
}
bpReader.Close();
}
}
catch (std::invalid_argument &e)
{
std::cout << "Invalid argument exception, STOPPING PROGRAM from rank "
<< rank << "\n";
std::cout << e.what() << "\n";
}
catch (std::ios_base::failure &e)
{
std::cout << "IO System base failure exception, STOPPING PROGRAM "
"from rank "
<< rank << "\n";
std::cout << e.what() << "\n";
}
catch (std::exception &e)
{
std::cout << "Exception, STOPPING PROGRAM from rank " << rank << "\n";
std::cout << e.what() << "\n";
}
MPI_Finalize();
return 0;
}
| 32.070423 | 80 | 0.525692 | yunai2384 |
2434304dceb9fd76f54cffca7e929b8caabbab80 | 1,930 | cpp | C++ | CuriosityEngine/texturepack.cpp | GondalfGery/Entrophy-simulator | 2534a0c64e32bf3e492c98db1e87cef23d81cd59 | [
"MIT"
] | null | null | null | CuriosityEngine/texturepack.cpp | GondalfGery/Entrophy-simulator | 2534a0c64e32bf3e492c98db1e87cef23d81cd59 | [
"MIT"
] | null | null | null | CuriosityEngine/texturepack.cpp | GondalfGery/Entrophy-simulator | 2534a0c64e32bf3e492c98db1e87cef23d81cd59 | [
"MIT"
] | null | null | null | #include "texturepack.h"
void TexturePack::Bind()
{
//*****BACKGROUND******
glActiveTexture(GL_TEXTURE0 + 0);
glBindTexture(GL_TEXTURE_2D, m_backgroundTexture->GetTexture());
glActiveTexture(GL_TEXTURE0 + 1);
glBindTexture(GL_TEXTURE_2D, m_backgroundTexture->GetTexture()+sizeof(m_backgroundTexture->GetTexture()));
glActiveTexture(GL_TEXTURE0 + 2);
glBindTexture(GL_TEXTURE_2D, m_backgroundTexture->GetTexture()+sizeof(m_backgroundTexture->GetTexture())+sizeof(m_backgroundTexture->GetTexture()));
//*****R TEXTURE******
glActiveTexture(GL_TEXTURE0 + 3);
glBindTexture(GL_TEXTURE_2D, m_rTexture->GetTexture());
glActiveTexture(GL_TEXTURE0 + 4);
glBindTexture(GL_TEXTURE_2D, m_rTexture->GetTexture()+sizeof(m_rTexture->GetTexture()));
glActiveTexture(GL_TEXTURE0 + 5);
glBindTexture(GL_TEXTURE_2D, m_rTexture->GetTexture()+sizeof(m_rTexture->GetTexture())+sizeof(m_rTexture->GetTexture()));
//*****G TEXTURE******
glActiveTexture(GL_TEXTURE0 + 6);
glBindTexture(GL_TEXTURE_2D, m_gTexture->GetTexture());
glActiveTexture(GL_TEXTURE0 + 7);
glBindTexture(GL_TEXTURE_2D, m_gTexture->GetTexture()+sizeof(m_gTexture->GetTexture()));
glActiveTexture(GL_TEXTURE0 + 8);
glBindTexture(GL_TEXTURE_2D, m_gTexture->GetTexture()+sizeof(m_gTexture->GetTexture())+sizeof(m_gTexture->GetTexture()));
//*****B TEXTURE******
glActiveTexture(GL_TEXTURE0 + 9);
glBindTexture(GL_TEXTURE_2D, m_bTexture->GetTexture());
glActiveTexture(GL_TEXTURE0 + 10);
glBindTexture(GL_TEXTURE_2D, m_bTexture->GetTexture()+sizeof(m_bTexture->GetTexture()));
glActiveTexture(GL_TEXTURE0 + 11);
glBindTexture(GL_TEXTURE_2D, m_bTexture->GetTexture()+sizeof(m_bTexture->GetTexture())+sizeof(m_bTexture->GetTexture()));
//*****BLEND MAP******
glActiveTexture(GL_TEXTURE0 + 12);
glBindTexture(GL_TEXTURE_2D, m_blendMap->GetTexture());
}
| 39.387755 | 152 | 0.724352 | GondalfGery |
243478f49cc5166171e9c266e83f1a6d46ff2283 | 14,145 | cc | C++ | runtime/vm/compiler/frontend/constant_reader.cc | wennyyustalim/sdk | e6ffc0b285fb393ba04c4afa35f9a7eae0e05793 | [
"BSD-3-Clause"
] | 2 | 2021-05-09T01:55:36.000Z | 2021-09-06T03:32:17.000Z | runtime/vm/compiler/frontend/constant_reader.cc | wennyyustalim/sdk | e6ffc0b285fb393ba04c4afa35f9a7eae0e05793 | [
"BSD-3-Clause"
] | null | null | null | runtime/vm/compiler/frontend/constant_reader.cc | wennyyustalim/sdk | e6ffc0b285fb393ba04c4afa35f9a7eae0e05793 | [
"BSD-3-Clause"
] | 1 | 2021-06-05T07:28:45.000Z | 2021-06-05T07:28:45.000Z | // Copyright (c) 2018, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
#include "vm/compiler/frontend/constant_reader.h"
namespace dart {
namespace kernel {
#define Z (zone_)
#define H (translation_helper_)
ConstantReader::ConstantReader(KernelReaderHelper* helper,
ActiveClass* active_class)
: helper_(helper),
zone_(helper->zone_),
translation_helper_(helper->translation_helper_),
active_class_(active_class),
script_(helper->script()),
result_(Instance::Handle(zone_)) {}
InstancePtr ConstantReader::ReadConstantExpression() {
Tag tag = helper_->ReadTag(); // read tag.
switch (tag) {
case kConstantExpression:
helper_->ReadPosition();
helper_->SkipDartType();
result_ = ReadConstant(helper_->ReadUInt());
break;
case kInvalidExpression: {
helper_->ReadPosition(); // Skip position.
const String& message = H.DartString(helper_->ReadStringReference());
// Invalid expression message has pointer to the source code, no need to
// report it twice.
H.ReportError(helper_->script(), TokenPosition::kNoSource, "%s",
message.ToCString());
break;
}
default:
H.ReportError(script_, TokenPosition::kNoSource,
"Not a constant expression: unexpected kernel tag %s (%d)",
Reader::TagName(tag), tag);
}
return result_.raw();
}
ObjectPtr ConstantReader::ReadAnnotations() {
intptr_t list_length = helper_->ReadListLength(); // read list length.
const Array& metadata_values =
Array::Handle(Z, Array::New(list_length, H.allocation_space()));
Instance& value = Instance::Handle(Z);
for (intptr_t i = 0; i < list_length; ++i) {
// This will read the expression.
value = ReadConstantExpression();
metadata_values.SetAt(i, value);
}
return metadata_values.raw();
}
InstancePtr ConstantReader::ReadConstant(intptr_t constant_offset) {
ASSERT(!H.constants().IsNull());
ASSERT(!H.constants_table().IsNull()); // raw bytes
// For kernel-level cache (in contrast with script-level caching),
// we need to access the raw constants array inside the shared
// KernelProgramInfo directly, so that all scripts will see the
// results after new insertions. These accesses at kernel-level
// must be locked since mutator and background compiler can
// access the array at the same time.
{
SafepointMutexLocker ml(H.thread()->isolate()->kernel_constants_mutex());
KernelConstantsMap constant_map(H.info().constants());
result_ ^= constant_map.GetOrNull(constant_offset);
ASSERT(constant_map.Release().raw() == H.info().constants());
}
// On miss, evaluate, and insert value.
if (result_.IsNull()) {
result_ = ReadConstantInternal(constant_offset);
SafepointMutexLocker ml(H.thread()->isolate()->kernel_constants_mutex());
KernelConstantsMap constant_map(H.info().constants());
auto insert = constant_map.InsertNewOrGetValue(constant_offset, result_);
ASSERT(insert == result_.raw());
H.info().set_constants(constant_map.Release()); // update!
}
return result_.raw();
}
bool ConstantReader::IsInstanceConstant(intptr_t constant_offset,
const Class& clazz) {
// Get reader directly into raw bytes of constant table.
KernelReaderHelper reader(Z, &H, script_, H.constants_table(), 0);
reader.ReadUInt(); // skip variable-sized int for adjusted constant offset
reader.SetOffset(reader.ReaderOffset() + constant_offset);
// Peek for an instance of the given clazz.
if (reader.ReadByte() == kInstanceConstant) {
const NameIndex index = reader.ReadCanonicalNameReference();
return H.LookupClassByKernelClass(index) == clazz.raw();
}
return false;
}
InstancePtr ConstantReader::ReadConstantInternal(intptr_t constant_offset) {
// Get reader directly into raw bytes of constant table.
bool null_safety = H.thread()->isolate()->null_safety();
KernelReaderHelper reader(Z, &H, script_, H.constants_table(), 0);
reader.ReadUInt(); // skip variable-sized int for adjusted constant offset
reader.SetOffset(reader.ReaderOffset() + constant_offset);
// Construct constant from raw bytes.
Instance& instance = Instance::Handle(Z);
const intptr_t constant_tag = reader.ReadByte();
switch (constant_tag) {
case kNullConstant:
instance = Instance::null();
break;
case kBoolConstant:
instance = reader.ReadByte() == 1 ? Object::bool_true().raw()
: Object::bool_false().raw();
break;
case kIntConstant: {
uint8_t payload = 0;
Tag integer_tag = reader.ReadTag(&payload); // read tag.
switch (integer_tag) {
case kBigIntLiteral: {
const String& value = H.DartString(reader.ReadStringReference());
instance = Integer::New(value, Heap::kOld);
break;
}
case kSpecializedIntLiteral: {
const int64_t value =
static_cast<int32_t>(payload) - SpecializedIntLiteralBias;
instance = Integer::New(value, Heap::kOld);
break;
}
case kNegativeIntLiteral: {
const int64_t value = -static_cast<int64_t>(reader.ReadUInt());
instance = Integer::New(value, Heap::kOld);
break;
}
case kPositiveIntLiteral: {
const int64_t value = reader.ReadUInt();
instance = Integer::New(value, Heap::kOld);
break;
}
default:
H.ReportError(
script_, TokenPosition::kNoSource,
"Cannot lazily read integer: unexpected kernel tag %s (%d)",
Reader::TagName(integer_tag), integer_tag);
}
break;
}
case kDoubleConstant:
instance = Double::New(reader.ReadDouble(), Heap::kOld);
break;
case kStringConstant:
instance = H.DartSymbolPlain(reader.ReadStringReference()).raw();
break;
case kSymbolConstant: {
Library& library = Library::Handle(Z);
library = Library::InternalLibrary();
const auto& symbol_class =
Class::Handle(Z, library.LookupClass(Symbols::Symbol()));
const auto& symbol_name_field = Field::Handle(
Z, symbol_class.LookupInstanceFieldAllowPrivate(Symbols::_name()));
ASSERT(!symbol_name_field.IsNull());
const NameIndex index = reader.ReadCanonicalNameReference();
if (index == -1) {
library = Library::null();
} else {
library = H.LookupLibraryByKernelLibrary(index);
}
const String& symbol =
H.DartIdentifier(library, reader.ReadStringReference());
instance = Instance::New(symbol_class, Heap::kOld);
instance.SetField(symbol_name_field, symbol);
break;
}
case kListConstant: {
const auto& corelib = Library::Handle(Z, Library::CoreLibrary());
const auto& list_class =
Class::Handle(Z, corelib.LookupClassAllowPrivate(Symbols::_List()));
// Build type from the raw bytes (needs temporary translator).
TypeTranslator type_translator(
&reader, this, active_class_, true,
active_class_->RequireLegacyErasure(null_safety));
auto& type_arguments =
TypeArguments::Handle(Z, TypeArguments::New(1, Heap::kOld));
AbstractType& type = type_translator.BuildType();
type_arguments.SetTypeAt(0, type);
// Instantiate class.
type = Type::New(list_class, type_arguments, TokenPosition::kNoSource);
type = ClassFinalizer::FinalizeType(*active_class_->klass, type,
ClassFinalizer::kCanonicalize);
type_arguments = type.arguments();
// Fill array with constant elements.
const intptr_t length = reader.ReadUInt();
const Array& array =
Array::Handle(Z, ImmutableArray::New(length, Heap::kOld));
array.SetTypeArguments(type_arguments);
Instance& constant = Instance::Handle(Z);
for (intptr_t j = 0; j < length; ++j) {
// Recurse into lazily evaluating all "sub" constants
// needed to evaluate the current constant.
const intptr_t entry_offset = reader.ReadUInt();
ASSERT(entry_offset < constant_offset); // DAG!
constant = ReadConstant(entry_offset);
array.SetAt(j, constant);
}
instance = array.raw();
break;
}
case kInstanceConstant: {
const NameIndex index = reader.ReadCanonicalNameReference();
const auto& klass = Class::Handle(Z, H.LookupClassByKernelClass(index));
if (!klass.is_declaration_loaded() && !klass.is_declared_in_bytecode()) {
FATAL1(
"Trying to evaluate an instance constant whose references class "
"%s is not loaded yet.",
klass.ToCString());
}
const auto& obj = Object::Handle(Z, klass.EnsureIsFinalized(H.thread()));
ASSERT(obj.IsNull());
ASSERT(klass.is_enum_class() || klass.is_const());
instance = Instance::New(klass, Heap::kOld);
// Build type from the raw bytes (needs temporary translator).
TypeTranslator type_translator(
&reader, this, active_class_, true,
active_class_->RequireLegacyErasure(null_safety));
const intptr_t number_of_type_arguments = reader.ReadUInt();
if (klass.NumTypeArguments() > 0) {
auto& type_arguments = TypeArguments::Handle(
Z, TypeArguments::New(number_of_type_arguments, Heap::kOld));
for (intptr_t j = 0; j < number_of_type_arguments; ++j) {
type_arguments.SetTypeAt(j, type_translator.BuildType());
}
// Instantiate class.
auto& type = AbstractType::Handle(
Z, Type::New(klass, type_arguments, TokenPosition::kNoSource));
type = ClassFinalizer::FinalizeType(*active_class_->klass, type,
ClassFinalizer::kCanonicalize);
type_arguments = type.arguments();
instance.SetTypeArguments(type_arguments);
} else {
ASSERT(number_of_type_arguments == 0);
}
// Set the fields.
const intptr_t number_of_fields = reader.ReadUInt();
Field& field = Field::Handle(Z);
Instance& constant = Instance::Handle(Z);
for (intptr_t j = 0; j < number_of_fields; ++j) {
field = H.LookupFieldByKernelField(reader.ReadCanonicalNameReference());
// Recurse into lazily evaluating all "sub" constants
// needed to evaluate the current constant.
const intptr_t entry_offset = reader.ReadUInt();
ASSERT(entry_offset < constant_offset); // DAG!
constant = ReadConstant(entry_offset);
instance.SetField(field, constant);
}
break;
}
case kPartialInstantiationConstant: {
// Recurse into lazily evaluating the "sub" constant
// needed to evaluate the current constant.
const intptr_t entry_offset = reader.ReadUInt();
ASSERT(entry_offset < constant_offset); // DAG!
const auto& constant = Instance::Handle(Z, ReadConstant(entry_offset));
ASSERT(!constant.IsNull());
// Build type from the raw bytes (needs temporary translator).
TypeTranslator type_translator(
&reader, this, active_class_, true,
active_class_->RequireLegacyErasure(null_safety));
const intptr_t number_of_type_arguments = reader.ReadUInt();
ASSERT(number_of_type_arguments > 0);
auto& type_arguments = TypeArguments::Handle(
Z, TypeArguments::New(number_of_type_arguments, Heap::kOld));
for (intptr_t j = 0; j < number_of_type_arguments; ++j) {
type_arguments.SetTypeAt(j, type_translator.BuildType());
}
type_arguments = type_arguments.Canonicalize();
// Make a copy of the old closure, and set delayed type arguments.
Closure& closure = Closure::Handle(Z, Closure::RawCast(constant.raw()));
Function& function = Function::Handle(Z, closure.function());
const auto& type_arguments2 =
TypeArguments::Handle(Z, closure.instantiator_type_arguments());
// The function type arguments are used for type parameters from enclosing
// closures. Though inner closures cannot be constants. We should
// therefore see `null here.
ASSERT(closure.function_type_arguments() == TypeArguments::null());
Context& context = Context::Handle(Z, closure.context());
instance = Closure::New(type_arguments2, Object::null_type_arguments(),
type_arguments, function, context, Heap::kOld);
break;
}
case kTearOffConstant: {
const NameIndex index = reader.ReadCanonicalNameReference();
Function& function =
Function::Handle(Z, H.LookupStaticMethodByKernelProcedure(index));
function = function.ImplicitClosureFunction();
instance = function.ImplicitStaticClosure();
break;
}
case kTypeLiteralConstant: {
// Build type from the raw bytes (needs temporary translator).
// Legacy erasure is not applied to type literals. See issue #42262.
TypeTranslator type_translator(&reader, this, active_class_, true);
instance = type_translator.BuildType().raw();
break;
}
default:
// Set literals (kSetConstant) are currently desugared in the frontend
// and will not reach the VM. See http://dartbug.com/35124 for some
// discussion. Map constants (kMapConstant ) are already lowered to
// InstanceConstant or ListConstant. We should never see unevaluated
// constants (kUnevaluatedConstant) in the constant table, they should
// have been fully evaluated before we get them.
H.ReportError(script_, TokenPosition::kNoSource,
"Cannot lazily read constant: unexpected kernel tag (%" Pd
")",
constant_tag);
}
return H.Canonicalize(instance);
}
} // namespace kernel
} // namespace dart
| 43.125 | 80 | 0.65684 | wennyyustalim |
0f83d6480cb305953c9ecda7e84c08da56318083 | 235 | hpp | C++ | src/cxx_stubs/SFView_stub.hpp | reykjalin/ocaml-sfml | 50beb0b2ad77ecd0f1d6b5fd0723d33e2cd586c6 | [
"Zlib"
] | 16 | 2015-02-05T18:14:29.000Z | 2022-03-12T20:42:13.000Z | src/cxx_stubs/SFView_stub.hpp | reykjalin/ocaml-sfml | 50beb0b2ad77ecd0f1d6b5fd0723d33e2cd586c6 | [
"Zlib"
] | 4 | 2019-12-22T13:20:51.000Z | 2020-10-11T12:06:39.000Z | src/cxx_stubs/SFView_stub.hpp | reykjalin/ocaml-sfml | 50beb0b2ad77ecd0f1d6b5fd0723d33e2cd586c6 | [
"Zlib"
] | 5 | 2016-12-12T05:57:35.000Z | 2020-10-08T03:14:20.000Z | #ifndef _SF_VIEW_INC
#define _SF_VIEW_INC
#include <SFML/Graphics/View.hpp>
value Val_sfView(const sf::View *view, value origin = Val_unit);
#define SfView_val(view) (*(sf::View **)(Data_custom_val(view)))
#endif // _SF_VIEW_INC
| 18.076923 | 64 | 0.73617 | reykjalin |
0f8601e64b86a038ffccb51a6c9634fc46b89686 | 1,431 | cpp | C++ | src/lib/storage/fixed_size_attribute_vector.cpp | tjjordan/DYOD_SoSe21 | 9cf7af43f10caccbfa2b0583a43e991f24cd336c | [
"MIT"
] | 1 | 2022-01-25T09:03:56.000Z | 2022-01-25T09:03:56.000Z | src/lib/storage/fixed_size_attribute_vector.cpp | tjjordan/DYOD_SoSe21 | 9cf7af43f10caccbfa2b0583a43e991f24cd336c | [
"MIT"
] | 2 | 2022-02-10T14:25:25.000Z | 2022-03-12T20:19:12.000Z | src/lib/storage/fixed_size_attribute_vector.cpp | tjjordan/DYOD_SoSe21 | 9cf7af43f10caccbfa2b0583a43e991f24cd336c | [
"MIT"
] | null | null | null | #include "fixed_size_attribute_vector.hpp"
#include <limits>
#include <memory>
#include <sstream>
#include <string>
#include <utility>
#include <vector>
#include "type_cast.hpp"
#include "utils/assert.hpp"
namespace opossum {
template <typename uintX_t>
FixedSizeAttributeVector<uintX_t>::FixedSizeAttributeVector(const size_t size)
: _attribute_vector(std::vector<uintX_t>(size)) {}
// returns the value id at a given position
template <typename uintX_t>
ValueID FixedSizeAttributeVector<uintX_t>::get(const size_t index) const {
DebugAssert(index < size(), "Index out of bounds.");
return ValueID(_attribute_vector[index]);
}
// sets the value id at a given position
template <typename uintX_t>
void FixedSizeAttributeVector<uintX_t>::set(const size_t index, const ValueID value_id) {
DebugAssert(index < size(), "Index out of bounds.");
_attribute_vector[index] = static_cast<uintX_t>(value_id);
}
// returns the number of values
template <typename uintX_t>
size_t FixedSizeAttributeVector<uintX_t>::size() const {
return _attribute_vector.size();
}
// returns the width of biggest value id in bytes
template <typename uintX_t>
AttributeVectorWidth FixedSizeAttributeVector<uintX_t>::width() const {
return sizeof(uintX_t);
}
template class FixedSizeAttributeVector<uint8_t>;
template class FixedSizeAttributeVector<uint16_t>;
template class FixedSizeAttributeVector<uint32_t>;
} // namespace opossum
| 28.62 | 89 | 0.778477 | tjjordan |
0f8762925ee672238b2c1471d9090559cb7e1b9c | 13,464 | cc | C++ | src/libxtp/threecenter_gwbse.cc | fossabot/xtp | e82cc53f23e213d09da15da80ada6e32ac031a07 | [
"Apache-2.0"
] | null | null | null | src/libxtp/threecenter_gwbse.cc | fossabot/xtp | e82cc53f23e213d09da15da80ada6e32ac031a07 | [
"Apache-2.0"
] | null | null | null | src/libxtp/threecenter_gwbse.cc | fossabot/xtp | e82cc53f23e213d09da15da80ada6e32ac031a07 | [
"Apache-2.0"
] | null | null | null | /*
* Copyright 2009-2020 The VOTCA Development Team
* (http://www.votca.org)
*
* 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.
*
*/
// Local VOTCA includes
#include "votca/xtp/aomatrix.h"
#include "votca/xtp/logger.h"
#include "votca/xtp/threecenter.h"
using std::flush;
namespace votca {
namespace xtp {
void TCMatrix_gwbse::Initialize(Index basissize, Index mmin, Index mmax,
Index nmin, Index nmax) {
// here as storage indices starting from zero
_nmin = nmin;
_nmax = nmax;
_ntotal = nmax - nmin + 1;
_mmin = mmin;
_mmax = mmax;
_mtotal = mmax - mmin + 1;
_auxbasissize = basissize;
// vector has mtotal elements
_matrix = std::vector<Eigen::MatrixXd>(
_mtotal, Eigen::MatrixXd::Zero(_ntotal, _auxbasissize));
}
/*
* Modify 3-center matrix elements consistent with use of symmetrized
* Coulomb interaction using either CUDA or Openmp
*/
void TCMatrix_gwbse::MultiplyRightWithAuxMatrix(const Eigen::MatrixXd& matrix) {
// Try to run the operation in a Nvidia GPU, otherwise is the default Openmp
// implementation
#if defined(USE_CUDA)
if (count_available_gpus() > 0) {
MultiplyRightWithAuxMatrixCuda(matrix);
} else {
MultiplyRightWithAuxMatrixOpenMP(matrix);
}
#else
MultiplyRightWithAuxMatrixOpenMP(matrix);
#endif
return;
}
/*
* Fill the 3-center object by looping over shells of GW basis set and
* calling FillBlock, which calculates all 3-center overlap integrals
* associated to a particular shell, convoluted with the DFT orbital
* coefficients
*/
void TCMatrix_gwbse::Fill(const AOBasis& gwbasis, const AOBasis& dftbasis,
const Eigen::MatrixXd& dft_orbitals) {
// needed for Rebuild())
_auxbasis = &gwbasis;
_dftbasis = &dftbasis;
_dft_orbitals = &dft_orbitals;
// If cuda is enabled the dft orbitals are sent first to the cuda gpu
// and memory in the cuda gpu is allocated for the intermediate matrices
#if defined(USE_CUDA)
if (count_available_gpus() > 0) {
FillAllBlocksCuda(gwbasis, dftbasis, dft_orbitals);
} else {
FillAllBlocksOpenMP(gwbasis, dftbasis, dft_orbitals);
}
#else
FillAllBlocksOpenMP(gwbasis, dftbasis, dft_orbitals);
#endif
AOOverlap auxoverlap;
auxoverlap.Fill(gwbasis);
AOCoulomb auxcoulomb;
auxcoulomb.Fill(gwbasis);
Eigen::MatrixXd inv_sqrt = auxcoulomb.Pseudo_InvSqrt_GWBSE(auxoverlap, 5e-7);
_removedfunctions = auxcoulomb.Removedfunctions();
MultiplyRightWithAuxMatrix(inv_sqrt);
return;
}
/*
* Determines the 3-center integrals for a given shell in the GW basis
* by calculating the 3-center overlap integral of the functions in the
* GW shell with ALL functions in the DFT basis set (FillThreeCenterOLBlock)
*/
std::vector<Eigen::MatrixXd> TCMatrix_gwbse::ComputeSymmStorage(
const AOShell& auxshell, const AOBasis& dftbasis) const {
std::vector<Eigen::MatrixXd> symmstorage = std::vector<Eigen::MatrixXd>(
auxshell.getNumFunc(),
Eigen::MatrixXd::Zero(dftbasis.AOBasisSize(), dftbasis.AOBasisSize()));
// alpha-loop over the "left" DFT basis function
for (Index row = 0; row < dftbasis.getNumofShells(); row++) {
const AOShell& shell_row = dftbasis.getShell(row);
const Index row_start = shell_row.getStartIndex();
// ThreecMatrix is symmetric, restrict explicit calculation to triangular
// matrix
for (Index col = 0; col <= row; col++) {
const AOShell& shell_col = dftbasis.getShell(col);
const Index col_start = shell_col.getStartIndex();
Eigen::Tensor<double, 3> threec_block(auxshell.getNumFunc(),
shell_row.getNumFunc(),
shell_col.getNumFunc());
threec_block.setZero();
bool nonzero =
FillThreeCenterRepBlock(threec_block, auxshell, shell_row, shell_col);
if (nonzero) {
for (Index aux_c = 0; aux_c < auxshell.getNumFunc(); aux_c++) {
for (Index row_c = 0; row_c < shell_row.getNumFunc(); row_c++) {
for (Index col_c = 0; col_c < shell_col.getNumFunc(); col_c++) {
// symmetry
if ((col_start + col_c) > (row_start + row_c)) {
break;
}
symmstorage[aux_c](row_start + row_c, col_start + col_c) =
threec_block(aux_c, row_c, col_c);
} // ROW copy
} // COL copy
} // AUX copy
}
} // gamma-loop
} // alpha-loop
return symmstorage;
}
/*
* Convolution of the GW shell with ALL functions with the DFT orbital
* coefficients
*/
std::vector<Eigen::MatrixXd> TCMatrix_gwbse::FillBlock(
const std::vector<Eigen::MatrixXd>& symmstorage,
const Eigen::MatrixXd& dft_orbitals) const {
std::vector<Eigen::MatrixXd> block = std::vector<Eigen::MatrixXd>(
_mtotal, Eigen::MatrixXd::Zero(_ntotal, symmstorage.size()));
const Eigen::MatrixXd dftm =
dft_orbitals.block(0, _mmin, dft_orbitals.rows(), _mtotal);
const Eigen::MatrixXd dftn =
dft_orbitals.block(0, _nmin, dft_orbitals.rows(), _ntotal);
Index dim = static_cast<Index>(symmstorage.size());
for (Index k = 0; k < dim; ++k) {
const Eigen::MatrixXd& matrix = symmstorage[k];
Eigen::MatrixXd threec_inMo =
dftn.transpose() * matrix.selfadjointView<Eigen::Lower>() * dftm;
for (Index i = 0; i < threec_inMo.cols(); ++i) {
block[i].col(k) = threec_inMo.col(i);
}
}
return block;
}
/*
* Modify 3-center matrix elements consistent with use of symmetrized
* Coulomb interaction using OPENMP parallelization
*/
void TCMatrix_gwbse::MultiplyRightWithAuxMatrixOpenMP(
const Eigen::MatrixXd& matrix) {
XTP_LOG(Log::info, _log)
<< TimeStamp() << " Using Default OpenMP for tensor matrix multiplication"
<< flush;
#pragma omp parallel for
for (Index i_occ = 0; i_occ < _mtotal; i_occ++) {
_matrix[i_occ] *= matrix;
}
return;
}
void TCMatrix_gwbse::FillAllBlocksOpenMP(const AOBasis& gwbasis,
const AOBasis& dftbasis,
const Eigen::MatrixXd& dft_orbitals) {
#pragma omp parallel for schedule(guided) // private(_block)
for (Index is = 0; is < gwbasis.getNumofShells(); is++) {
const AOShell& shell = gwbasis.getShell(is);
// Fill block for this shell (3-center overlap with _dft_basis +
// multiplication with _dft_orbitals )
std::vector<Eigen::MatrixXd> symmstorage =
ComputeSymmStorage(shell, dftbasis);
std::vector<Eigen::MatrixXd> block = FillBlock(symmstorage, dft_orbitals);
// put into correct position
for (Index m_level = 0; m_level < _mtotal; m_level++) {
_matrix[m_level].block(0, shell.getStartIndex(), _ntotal,
shell.getNumFunc()) = block[m_level];
} // m-th DFT orbital
} // shells of GW basis set
}
#if defined(USE_CUDA)
/*
* The Cuda device behaves like a server that is receiving matrix-matrix
* multiplications from a single stream (an Nvidia queue) and handle them
* in an asynchronous way. It performs the following operations when recieving a
* request:
* 1. Check that there is enough space for the arrays
* 2. Allocate memory for each matrix
* 3. Copy the matrix to the allocated space
* 4. Perform the matrix multiplication
* 5. Return the result matrix
* The Cuda device knows to which memory address it needs to copy back the
* result. see: https://docs.nvidia.com/cuda/cublas/index.html#thread-safety2
*/
/*
* Modify 3-center matrix elements consistent with use of symmetrized
* Coulomb interaction using OPENMP/CUDA parallelization
*/
void TCMatrix_gwbse::MultiplyRightWithAuxMatrixCuda(
const Eigen::MatrixXd& matrix) {
XTP_LOG(Log::info, _log)
<< TimeStamp() << " Using CUDA/OpenMP for tensor matrix multiplication"
<< flush;
CudaPipeline cuda_pip;
const Eigen::MatrixXd& head = _matrix.front();
const cudaStream_t& stream = cuda_pip.get_stream();
CudaMatrix cuma_A{head.rows(), head.cols(), stream};
CudaMatrix cuma_B{matrix, stream};
CudaMatrix cuma_C{head.rows(), matrix.cols(), stream};
#pragma omp parallel for schedule(dynamic)
for (Index i_occ = 0; i_occ < _mtotal; i_occ++) {
// All the GPU communication happens through a single thread that reuses all
// memory allocated in the GPU and it's dynamically load-balanced by OpenMP.
// The rest of the threads use the default CPU matrix multiplication
if (OPENMP::getThreadId() == 0) {
cuma_A.copy_to_gpu(_matrix[i_occ]);
cuda_pip.gemm(cuma_A, cuma_B, cuma_C);
_matrix[i_occ] = cuma_C;
} else {
_matrix[i_occ] *= matrix;
}
}
}
/*
* Convolution of the GW shell with the DFT orbital coefficients using an Nvidia
* GPU
*/
void TCMatrix_gwbse::FillAllBlocksCuda(const AOBasis& gwbasis,
const AOBasis& dftbasis,
const Eigen::MatrixXd& dft_orbitals) {
CudaPipeline cuda_pip;
std::array<CudaMatrix, 2> cuda_matrices =
SendDFTMatricesToGPU(dft_orbitals, cuda_pip);
std::array<CudaMatrix, 3> cuda_inter_matrices =
CreateIntermediateCudaMatrices(dft_orbitals.rows(), cuda_pip);
// loop over all shells in the GW basis and get _Mmn for that shell
#pragma omp parallel for schedule(dynamic) // private(_block)
for (Index is = 0; is < gwbasis.getNumofShells(); is++) {
const AOShell& shell = gwbasis.getShell(is);
// Fill block for this shell (3-center overlap with _dft_basis +
// multiplication with _dft_orbitals )
std::vector<Eigen::MatrixXd> symmstorage =
ComputeSymmStorage(shell, dftbasis);
// If cuda is enable all the GPU communication happens through a single
// thread that reuses all memory allocated in the GPU and it's dynamically
// load-balanced by OpenMP. The remaining threads will perform the
// convolution using the default CPU method.
std::vector<Eigen::MatrixXd> block;
if (OPENMP::getThreadId() == 0) {
block = FillBlockCUDA(symmstorage, cuda_matrices, cuda_inter_matrices,
cuda_pip);
} else {
block = FillBlock(symmstorage, dft_orbitals);
}
// // Otherwise the convolution is performed by Eigen
// block = FillBlock(symmstorage, dft_orbitals);
// put into correct position
for (Index m_level = 0; m_level < _mtotal; m_level++) {
_matrix[m_level].block(0, shell.getStartIndex(), _ntotal,
shell.getNumFunc()) = block[m_level];
} // m-th DFT orbital
} // shells of GW basis set
}
std::vector<Eigen::MatrixXd> TCMatrix_gwbse::FillBlockCUDA(
const std::vector<Eigen::MatrixXd>& symmstorage,
const std::array<CudaMatrix, 2>& cuda_matrices,
std::array<CudaMatrix, 3>& cuda_inter_matrices,
const CudaPipeline& cuda_pip) const {
std::vector<Eigen::MatrixXd> block = std::vector<Eigen::MatrixXd>(
_mtotal, Eigen::MatrixXd::Zero(_ntotal, symmstorage.size()));
try {
const CudaMatrix& cuma_A = cuda_matrices[0];
const CudaMatrix& cuma_C = cuda_matrices[1];
CudaMatrix& cuma_B = cuda_inter_matrices[0];
CudaMatrix& cuma_X = cuda_inter_matrices[1];
CudaMatrix& cuma_Y = cuda_inter_matrices[2];
Index dim = static_cast<Index>(symmstorage.size());
for (Index k = 0; k < dim; ++k) {
const Eigen::MatrixXd& matrix = symmstorage[k];
cuma_B.copy_to_gpu(matrix.selfadjointView<Eigen::Lower>());
cuda_pip.gemm(cuma_A, cuma_B, cuma_X);
cuda_pip.gemm(cuma_X, cuma_C, cuma_Y);
Eigen::MatrixXd threec_inMo = cuma_Y;
for (Index i = 0; i < threec_inMo.cols(); ++i) {
block[i].col(k) = threec_inMo.col(i);
}
}
} catch (const std::runtime_error& error) {
XTP_LOG(Log::error, _log)
<< TimeStamp() << " FillBlockCUDA failed due to: " << error.what()
<< flush;
throw;
}
return block;
}
std::array<CudaMatrix, 2> TCMatrix_gwbse::SendDFTMatricesToGPU(
const Eigen::MatrixXd& dft_orbitals, const CudaPipeline& cuda_pip) const {
const Eigen::MatrixXd dftm =
dft_orbitals.block(0, _mmin, dft_orbitals.rows(), _mtotal);
const Eigen::MatrixXd dftn =
dft_orbitals.block(0, _nmin, dft_orbitals.rows(), _ntotal);
// Smart Pointers to the cuda arrays
const cudaStream_t& stream = cuda_pip.get_stream();
return {CudaMatrix{dftn.transpose(), stream}, CudaMatrix{dftm, stream}};
}
std::array<CudaMatrix, 3> TCMatrix_gwbse::CreateIntermediateCudaMatrices(
Index basissize, const CudaPipeline& cuda_pip) const {
Index mcols = _mtotal - _mmin;
Index ncols = _ntotal - _nmin;
const cudaStream_t& stream = cuda_pip.get_stream();
return {CudaMatrix{basissize, basissize, stream},
CudaMatrix{ncols, basissize, stream},
CudaMatrix{ncols, mcols, stream}};
}
#endif
} // namespace xtp
} // namespace votca
| 36.389189 | 80 | 0.673351 | fossabot |
0f89d006d43a422d3f2827a2b022dbfaec920aa4 | 2,082 | cpp | C++ | compiler/AST/PartialCopyData.cpp | vasslitvinov/chapel | 53feadfc838e7f36ef863b1cd8cd5200d2d92ec8 | [
"ECL-2.0",
"Apache-2.0"
] | null | null | null | compiler/AST/PartialCopyData.cpp | vasslitvinov/chapel | 53feadfc838e7f36ef863b1cd8cd5200d2d92ec8 | [
"ECL-2.0",
"Apache-2.0"
] | null | null | null | compiler/AST/PartialCopyData.cpp | vasslitvinov/chapel | 53feadfc838e7f36ef863b1cd8cd5200d2d92ec8 | [
"ECL-2.0",
"Apache-2.0"
] | null | null | null | /*
* Copyright 2004-2017 Cray Inc.
* Other additional copyright holders may be indicated within.
*
* The entirety of this work 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 "PartialCopyData.h"
#include "symbol.h"
#include <map>
static std::map<int, PartialCopyData> sFnMap;
PartialCopyData::PartialCopyData() {
partialCopySource = NULL;
varargOldFormal = NULL;
}
PartialCopyData::~PartialCopyData() {
partialCopyMap.clear();
varargNewFormals.clear();
}
// Return the entry for 'fn' in partialCopyFnMap or NULL if it does not exist.
PartialCopyData* getPartialCopyData(FnSymbol* fn) {
std::map<int, PartialCopyData>::iterator it = sFnMap.find(fn->id);
PartialCopyData* retval = NULL;
if (it != sFnMap.end()) {
retval = &(it->second);
}
return retval;
}
// Add 'fn' to partialCopyFnMap; remove the corresponding entry.
PartialCopyData& addPartialCopyData(FnSymbol* fn) {
INT_ASSERT(sFnMap.count(fn->id) == 0);
return sFnMap[fn->id];
}
// Remove 'fn' from partialCopyFnMap.
void clearPartialCopyData(FnSymbol* fn) {
size_t cnt = sFnMap.erase(fn->id);
INT_ASSERT(cnt == 1); // Convention: clear only what was added before.
}
void clearPartialCopyDataFnMap() {
sFnMap.clear();
}
// Since FnSymbols can get removed at pass boundaries, leaving them
// in here may result in useless entries.
// As of this writing, PartialCopyData is used only within resolution.
void checkEmptyPartialCopyDataFnMap() {
if (sFnMap.size()) {
INT_FATAL("partialCopyFnMap is not empty");
}
}
| 27.038961 | 78 | 0.713256 | vasslitvinov |
0f8ddb3596bd6ca35b8bed8bbdf227b131caf340 | 570 | hpp | C++ | src/gui/guiutils.hpp | henryiii/spatial-model-editor | 2138d03ae4c7cc353b40324dfd1a3e763d7085d9 | [
"MIT"
] | 4 | 2019-07-18T15:05:09.000Z | 2020-03-14T09:50:07.000Z | src/gui/guiutils.hpp | henryiii/spatial-model-editor | 2138d03ae4c7cc353b40324dfd1a3e763d7085d9 | [
"MIT"
] | 418 | 2020-10-08T07:42:27.000Z | 2022-03-08T12:10:52.000Z | src/gui/guiutils.hpp | henryiii/spatial-model-editor | 2138d03ae4c7cc353b40324dfd1a3e763d7085d9 | [
"MIT"
] | 2 | 2021-09-02T11:20:38.000Z | 2021-10-13T14:05:32.000Z | #pragma once
#include <QImage>
#include <QString>
class QWidget;
class QMessageBox;
class QListWidget;
class QTreeWidget;
class QScrollArea;
void selectMatchingOrFirstItem(QListWidget *list, const QString &text = {});
void selectFirstChild(QTreeWidget *tree);
void selectMatchingOrFirstChild(QTreeWidget *list, const QString &text = {});
QImage getImageFromUser(QWidget *parent = nullptr,
const QString &title = "Import image");
void zoomScrollArea(QScrollArea *scrollArea, int zoomFactor,
const QPointF &relativePos);
| 24.782609 | 77 | 0.726316 | henryiii |
0f91437b0d93434ede56b44655c963401ba14feb | 1,317 | hpp | C++ | modules/boost/simd/sdk/include/boost/simd/sdk/meta/iterate.hpp | pbrunet/nt2 | 2aeca0f6a315725b335efd5d9dc95d72e10a7fb7 | [
"BSL-1.0"
] | 2 | 2016-09-14T00:23:53.000Z | 2018-01-14T12:51:18.000Z | modules/boost/simd/sdk/include/boost/simd/sdk/meta/iterate.hpp | pbrunet/nt2 | 2aeca0f6a315725b335efd5d9dc95d72e10a7fb7 | [
"BSL-1.0"
] | null | null | null | modules/boost/simd/sdk/include/boost/simd/sdk/meta/iterate.hpp | pbrunet/nt2 | 2aeca0f6a315725b335efd5d9dc95d72e10a7fb7 | [
"BSL-1.0"
] | null | null | null | //==============================================================================
// Copyright 2003 - 2011 LASMEA UMR 6602 CNRS/Univ. Clermont II
// Copyright 2009 - 2011 LRI UMR 8623 CNRS/Univ Paris Sud XI
//
// Distributed under the Boost Software License, Version 1.0.
// See accompanying file LICENSE.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt
//==============================================================================
#ifndef BOOST_SIMD_SDK_META_ITERATE_HPP_INCLUDED
#define BOOST_SIMD_SDK_META_ITERATE_HPP_INCLUDED
#include <boost/dispatch/attributes.hpp>
namespace boost { namespace simd { namespace details
{
template<int N, class F>
struct iterate
{
BOOST_FORCEINLINE static void call(F& f)
{
#ifdef BOOST_MSVC
f.operator()<N-1>();
#else
f.template operator()<N-1>();
#endif
iterate<N-1, F>::call(f);
}
};
template<class F>
struct iterate<0, F>
{
BOOST_FORCEINLINE static void call(F&)
{
}
};
}
namespace meta
{
template<int N, class F>
BOOST_FORCEINLINE void iterate(F const& f)
{
details::iterate<N, F const>::call(f);
}
template<int N, class F>
BOOST_FORCEINLINE void iterate(F& f)
{
details::iterate<N, F>::call(f);
}
} } }
#endif
| 23.945455 | 80 | 0.558087 | pbrunet |
0f92a603808ebcde405ef673ae39d18a277470da | 1,332 | cpp | C++ | src/error.cpp | 1c0e/Abacus | 167b826aeef966014f185e3b5d376f39111c9e9e | [
"Apache-2.0"
] | 11 | 2021-01-12T00:45:49.000Z | 2022-01-17T06:22:17.000Z | src/error.cpp | 1c0e/Abacus | 167b826aeef966014f185e3b5d376f39111c9e9e | [
"Apache-2.0"
] | 3 | 2021-03-16T08:37:52.000Z | 2022-03-29T14:56:55.000Z | src/error.cpp | s3team/Abacus | 31bb80f7ce2b5cf52590c2627cf37e99e7b6a17b | [
"MIT"
] | 3 | 2021-05-09T06:57:42.000Z | 2021-11-23T13:06:17.000Z |
#include "error.hpp"
#include <iostream>
#include <map>
#include <string>
namespace tana {
void default_error_handler(const char *file, int line, const char *message) {
if (log_class == LOG_TYPE::MUTE) {
return;
}
std::string file_name(file);
std::string error_message(message);
std::cerr << "\n********************************" << std::endl;
std::cerr << "Error at :" << line << "\n";
std::cerr << "File name: " << file_name << "\n";
std::cerr << "Message: " << error_message << "\n";
std::cerr << "********************************\n" << std::endl;
// exit(0);
}
void default_warn_handler(const char *file, int line, const char *message) {
if (log_class == LOG_TYPE::INFO || log_class == LOG_TYPE::MUTE) {
return;
}
std::string file_name(file);
std::string error_message(message);
std::cerr << "\n********************************" << std::endl;
std::cerr << "Error at :" << line << "\n";
std::cerr << "File name: " << file_name << "\n";
std::cerr << "Message: " << error_message << "\n";
std::cerr << "********************************\n" << std::endl;
}
void debug_map(const std::map<int, uint32_t> &value_map) {
for (auto const &x : value_map) {
std::cout << x.first << ':' << std::hex << x.second << std::dec << " ";
}
std::cout << std::endl;
}
} // namespace tana | 28.956522 | 77 | 0.527027 | 1c0e |
0f95907c8b154151436608481386d73cd660c22f | 1,212 | cpp | C++ | source/gamethread.cpp | MaxReimann/Troen | aeabab35da15fe69f89b163f3762dccb9947e93c | [
"MIT"
] | null | null | null | source/gamethread.cpp | MaxReimann/Troen | aeabab35da15fe69f89b163f3762dccb9947e93c | [
"MIT"
] | 6 | 2016-08-15T01:56:11.000Z | 2016-08-15T01:56:40.000Z | source/gamethread.cpp | MaxReimann/Troen | aeabab35da15fe69f89b163f3762dccb9947e93c | [
"MIT"
] | null | null | null | #include "gamethread.h"
#include "omegascene.h"
#include "troengame.h"
#include <assert.h>
#include <osgDB/Registry>
using namespace troen;
GameThread* GameThread::instance;
GameThread::GameThread(QThread* thread) : m_gameThread(thread), m_storedLibPaths("")
{
if (m_gameThread == NULL) {
m_gameThread = new QThread(this);
}
moveToThread(m_gameThread);
m_gameThread->start(QThread::HighestPriority);
GameThread::instance = this;
m_troenGame = std::make_shared<TroenGame>();
}
void GameThread::prepareAndStartGame(const GameConfig& config,const CArguments& arguments){
m_omegaApp = std::make_shared<omega::Application<TroenOmegaScene> >("Troen");
for (auto libPath : osgDB::Registry::instance()->getLibraryFilePathList ())
{
m_storedLibPaths += libPath + ":";
}
omega::DataManager* dataManager = omega::SystemManager::instance()->getDataManager();
std::cout << OMEGALIB_BIN_DIR << std::endl;
dataManager->addSource(new omega::FilesystemDataSource(OMEGALIB_BIN_DIR));
m_gameConfig = new GameConfig(config);
// char* a[] = {"Troen","--log","v"};
omain(*(m_omegaApp.get()), arguments.argc, arguments.argv);
}
| 25.787234 | 91 | 0.686469 | MaxReimann |
0f987f73e690143084573beeff644f4a25ebfabc | 11,405 | cc | C++ | chromeos/services/secure_channel/device_to_device_operations_unittest.cc | sarang-apps/darshan_browser | 173649bb8a7c656dc60784d19e7bb73e07c20daa | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | null | null | null | chromeos/services/secure_channel/device_to_device_operations_unittest.cc | sarang-apps/darshan_browser | 173649bb8a7c656dc60784d19e7bb73e07c20daa | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | null | null | null | chromeos/services/secure_channel/device_to_device_operations_unittest.cc | sarang-apps/darshan_browser | 173649bb8a7c656dc60784d19e7bb73e07c20daa | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | 2 | 2021-01-05T23:43:46.000Z | 2021-01-07T23:36:34.000Z | // Copyright 2015 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 <memory>
#include "base/base64url.h"
#include "base/bind.h"
#include "base/macros.h"
#include "chromeos/components/multidevice/fake_secure_message_delegate.h"
#include "chromeos/services/secure_channel/device_to_device_initiator_helper.h"
#include "chromeos/services/secure_channel/device_to_device_responder_operations.h"
#include "chromeos/services/secure_channel/session_keys.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace chromeos {
namespace secure_channel {
namespace {
// The initiator's session public key in base64url form. Note that this is
// actually a serialized proto.
const char kInitiatorSessionPublicKeyBase64[] =
"CAESRQogOlH8DgPMQu7eAt-b6yoTXcazG8mAl6SPC5Ds-LTULIcSIQDZDMqsoYRO4tNMej1FB"
"El1sTiTiVDqrcGq-CkYCzDThw==";
// The responder's session public key in base64url form. Note that this is
// actually a serialized proto.
const char kResponderSessionPublicKeyBase64[] =
"CAESRgohAN9QYU5HySO14Gi9PDIClacBnC0C8wqPwXsNHUNG_vXlEiEAggzU80ZOd9DWuCBdp"
"6bzpGcC-oj1yrwdVCHGg_yeaAQ=";
// The long-term public key possessed by the responder device.
const char kResponderPersistentPublicKey[] = "responder persistent public key";
// Used as a callback for message creation operations to save |message| into
// |out_message|.
void SaveMessageResult(std::string* out_message, const std::string& message) {
*out_message = message;
}
// Used as a callback for validation operations to save |success| and into
// |out_success|.
void SaveValidationResult(bool* out_success, bool success) {
*out_success = success;
}
// Used as a callback for the ValidateResponderAuthMessage and
// ValidateHelloMessage operations, saving both the outcome and the returned
// key.
void SaveValidationResultWithKey(bool* out_success,
std::string* out_key,
bool success,
const std::string& key) {
*out_success = success;
*out_key = key;
}
void SaveValidationResultWithSessionKeys(bool* out_success,
SessionKeys* out_keys,
bool success,
const SessionKeys& keys) {
*out_success = success;
*out_keys = keys;
}
} // namespace
class SecureChannelDeviceToDeviceOperationsTest : public testing::Test {
protected:
SecureChannelDeviceToDeviceOperationsTest() {}
~SecureChannelDeviceToDeviceOperationsTest() override {}
void SetUp() override {
ASSERT_TRUE(
base::Base64UrlDecode(kInitiatorSessionPublicKeyBase64,
base::Base64UrlDecodePolicy::REQUIRE_PADDING,
&local_session_public_key_));
local_session_private_key_ =
secure_message_delegate_.GetPrivateKeyForPublicKey(
local_session_public_key_);
ASSERT_TRUE(
base::Base64UrlDecode(kResponderSessionPublicKeyBase64,
base::Base64UrlDecodePolicy::REQUIRE_PADDING,
&remote_session_public_key_));
remote_session_private_key_ =
secure_message_delegate_.GetPrivateKeyForPublicKey(
remote_session_public_key_);
// Note: FakeSecureMessageDelegate functions are synchronous.
secure_message_delegate_.DeriveKey(
local_session_private_key_, remote_session_public_key_,
base::Bind(&SaveMessageResult, &session_symmetric_key_));
session_keys_ = SessionKeys(session_symmetric_key_);
persistent_symmetric_key_ = "persistent symmetric key";
helper_ = std::make_unique<DeviceToDeviceInitiatorHelper>();
}
// Creates the initator's [Hello] message.
std::string CreateHelloMessage() {
std::string hello_message;
helper_->CreateHelloMessage(local_session_public_key_,
persistent_symmetric_key_,
&secure_message_delegate_,
base::Bind(&SaveMessageResult, &hello_message));
EXPECT_FALSE(hello_message.empty());
return hello_message;
}
// Creates the responder's [Remote Auth] message.
std::string CreateResponderAuthMessage(const std::string& hello_message) {
std::string persistent_responder_private_key =
secure_message_delegate_.GetPrivateKeyForPublicKey(
kResponderPersistentPublicKey);
std::string remote_auth_message;
DeviceToDeviceResponderOperations::CreateResponderAuthMessage(
hello_message, remote_session_public_key_, remote_session_private_key_,
persistent_responder_private_key, persistent_symmetric_key_,
&secure_message_delegate_,
base::Bind(&SaveMessageResult, &remote_auth_message));
EXPECT_FALSE(remote_auth_message.empty());
return remote_auth_message;
}
// Creates the initiator's [Initiator Auth] message.
std::string CreateInitiatorAuthMessage(
const std::string& remote_auth_message) {
std::string local_auth_message;
helper_->CreateInitiatorAuthMessage(
session_keys_, persistent_symmetric_key_, remote_auth_message,
&secure_message_delegate_,
base::Bind(&SaveMessageResult, &local_auth_message));
EXPECT_FALSE(local_auth_message.empty());
return local_auth_message;
}
multidevice::FakeSecureMessageDelegate secure_message_delegate_;
std::string persistent_symmetric_key_;
std::string local_session_public_key_;
std::string local_session_private_key_;
std::string remote_session_public_key_;
std::string remote_session_private_key_;
std::string session_symmetric_key_;
SessionKeys session_keys_;
std::unique_ptr<DeviceToDeviceInitiatorHelper> helper_;
DISALLOW_COPY_AND_ASSIGN(SecureChannelDeviceToDeviceOperationsTest);
};
TEST_F(SecureChannelDeviceToDeviceOperationsTest,
ValidateHelloMessage_Success) {
bool validation_success = false;
std::string hello_public_key;
DeviceToDeviceResponderOperations::ValidateHelloMessage(
CreateHelloMessage(), persistent_symmetric_key_,
&secure_message_delegate_,
base::Bind(&SaveValidationResultWithKey, &validation_success,
&hello_public_key));
EXPECT_TRUE(validation_success);
EXPECT_EQ(local_session_public_key_, hello_public_key);
}
TEST_F(SecureChannelDeviceToDeviceOperationsTest,
ValidateHelloMessage_Failure) {
bool validation_success = true;
std::string hello_public_key = "non-empty string";
DeviceToDeviceResponderOperations::ValidateHelloMessage(
"some random string", persistent_symmetric_key_,
&secure_message_delegate_,
base::Bind(&SaveValidationResultWithKey, &validation_success,
&hello_public_key));
EXPECT_FALSE(validation_success);
EXPECT_TRUE(hello_public_key.empty());
}
TEST_F(SecureChannelDeviceToDeviceOperationsTest,
ValidateResponderAuthMessage_Success) {
std::string hello_message = CreateHelloMessage();
std::string remote_auth_message = CreateResponderAuthMessage(hello_message);
bool validation_success = false;
SessionKeys session_keys;
helper_->ValidateResponderAuthMessage(
remote_auth_message, kResponderPersistentPublicKey,
persistent_symmetric_key_, local_session_private_key_, hello_message,
&secure_message_delegate_,
base::Bind(&SaveValidationResultWithSessionKeys, &validation_success,
&session_keys));
EXPECT_TRUE(validation_success);
EXPECT_EQ(session_keys_.initiator_encode_key(),
session_keys.initiator_encode_key());
EXPECT_EQ(session_keys_.responder_encode_key(),
session_keys.responder_encode_key());
}
TEST_F(SecureChannelDeviceToDeviceOperationsTest,
ValidateResponderAuthMessage_InvalidHelloMessage) {
std::string hello_message = CreateHelloMessage();
std::string remote_auth_message = CreateResponderAuthMessage(hello_message);
bool validation_success = true;
SessionKeys session_keys("non empty");
helper_->ValidateResponderAuthMessage(
remote_auth_message, kResponderPersistentPublicKey,
persistent_symmetric_key_, local_session_private_key_,
"invalid hello message", &secure_message_delegate_,
base::Bind(&SaveValidationResultWithSessionKeys, &validation_success,
&session_keys));
EXPECT_FALSE(validation_success);
EXPECT_TRUE(session_keys.initiator_encode_key().empty());
EXPECT_TRUE(session_keys.responder_encode_key().empty());
}
TEST_F(SecureChannelDeviceToDeviceOperationsTest,
ValidateResponderAuthMessage_InvalidPSK) {
std::string hello_message = CreateHelloMessage();
std::string remote_auth_message = CreateResponderAuthMessage(hello_message);
bool validation_success = true;
SessionKeys session_keys("non empty");
helper_->ValidateResponderAuthMessage(
remote_auth_message, kResponderPersistentPublicKey,
"invalid persistent symmetric key", local_session_private_key_,
hello_message, &secure_message_delegate_,
base::Bind(&SaveValidationResultWithSessionKeys, &validation_success,
&session_keys));
EXPECT_FALSE(validation_success);
EXPECT_TRUE(session_keys.initiator_encode_key().empty());
EXPECT_TRUE(session_keys.responder_encode_key().empty());
}
TEST_F(SecureChannelDeviceToDeviceOperationsTest,
ValidateInitiatorAuthMessage_Success) {
std::string hello_message = CreateHelloMessage();
std::string remote_auth_message = CreateResponderAuthMessage(hello_message);
std::string local_auth_message =
CreateInitiatorAuthMessage(remote_auth_message);
bool validation_success = false;
DeviceToDeviceResponderOperations::ValidateInitiatorAuthMessage(
local_auth_message, session_keys_, persistent_symmetric_key_,
remote_auth_message, &secure_message_delegate_,
base::Bind(&SaveValidationResult, &validation_success));
EXPECT_TRUE(validation_success);
}
TEST_F(SecureChannelDeviceToDeviceOperationsTest,
ValidateInitiatorAuthMessage_InvalidRemoteAuth) {
std::string hello_message = CreateHelloMessage();
std::string remote_auth_message = CreateResponderAuthMessage(hello_message);
std::string local_auth_message =
CreateInitiatorAuthMessage(remote_auth_message);
bool validation_success = true;
DeviceToDeviceResponderOperations::ValidateInitiatorAuthMessage(
local_auth_message, session_keys_, persistent_symmetric_key_,
"invalid remote auth", &secure_message_delegate_,
base::Bind(&SaveValidationResult, &validation_success));
EXPECT_FALSE(validation_success);
}
TEST_F(SecureChannelDeviceToDeviceOperationsTest,
ValidateInitiatorAuthMessage_InvalidPSK) {
std::string hello_message = CreateHelloMessage();
std::string remote_auth_message = CreateResponderAuthMessage(hello_message);
std::string local_auth_message =
CreateInitiatorAuthMessage(remote_auth_message);
bool validation_success = true;
DeviceToDeviceResponderOperations::ValidateInitiatorAuthMessage(
local_auth_message, session_keys_, "invalid persistent symmetric key",
remote_auth_message, &secure_message_delegate_,
base::Bind(&SaveValidationResult, &validation_success));
EXPECT_FALSE(validation_success);
}
} // namespace secure_channel
} // namespace chromeos
| 38.661017 | 83 | 0.756949 | sarang-apps |
0f9da20933837499f3b3387fa1a0b6da7397a92e | 4,401 | cpp | C++ | Source/SystemQOR/MSWindows/WinQL/System/Devices/Enumerator/WinQLRootDeviceEnumerator.cpp | mfaithfull/QOR | 0fa51789344da482e8c2726309265d56e7271971 | [
"BSL-1.0"
] | 9 | 2016-05-27T01:00:39.000Z | 2021-04-01T08:54:46.000Z | Source/SystemQOR/MSWindows/WinQL/System/Devices/Enumerator/WinQLRootDeviceEnumerator.cpp | mfaithfull/QOR | 0fa51789344da482e8c2726309265d56e7271971 | [
"BSL-1.0"
] | 1 | 2016-03-03T22:54:08.000Z | 2016-03-03T22:54:08.000Z | Source/SystemQOR/MSWindows/WinQL/System/Devices/Enumerator/WinQLRootDeviceEnumerator.cpp | mfaithfull/QOR | 0fa51789344da482e8c2726309265d56e7271971 | [
"BSL-1.0"
] | 4 | 2016-05-27T01:00:43.000Z | 2018-08-19T08:47:49.000Z | //WinQLRootDeviceEnumerator.cpp
// Copyright Querysoft Limited 2013, 2015, 2017
//
// Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following:
//
// The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by
// a source language processor.
//
// 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, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
#include "SystemQOR/System.h"
#include "WinQL/CodeServices/WinQLPolicy.h"
#include "WinQL/Application/Threading/WinQLCriticalSection.h"
#include "WinQL/Application/ErrorSystem/WinQLError.h"
#include "WinQL/CodeServices/Text/WinString.h"
#include "WinQL/System/WinQLSystem.h"
#include "WinQL/System/Devices/Enumerator/WinQLRootDeviceEnumerator.h"
#include "WinQAPI/SetupAPI.h"
//--------------------------------------------------------------------------------
namespace nsWin32
{
using namespace nsWinQAPI;
//--------------------------------------------------------------------------------
__QOR_IMPLEMENT_OCLASS_LUID( CRootDeviceEnumerator );
//--------------------------------------------------------------------------------
CRootDeviceEnumerator::CRootDeviceEnumerator() : m_Library( CSetupAPI::Instance() )
{
_WINQ_FCONTEXT( "CRootDeviceEnumerator::CRootDeviceEnumerator" );
Enumerate();
}
//--------------------------------------------------------------------------------
unsigned int CRootDeviceEnumerator::Enumerate( void )
{
unsigned long ulEnumIndex = 0;
CTString strEnumerator( _TXT( "ROOT" ) );
unsigned long ulInitLength = 256;
unsigned long ulResult = 0;
CDeviceEnumerator::ref_type pEnumerator = new_shared_ref< CDeviceEnumerator >( strEnumerator );
TheSystem().As< nsWin32::CSystem >()->Devices( QOR_PP_SHARED_OBJECT_ACCESS )().RegisterEnumerator( strEnumerator, pEnumerator );
do
{
unsigned long ulLength = ulInitLength;
ulResult = m_Library.CM_Enumerate_Enumerators( ulEnumIndex, strEnumerator.GetBufferSetLength( static_cast< unsigned short >( ulLength ) ), &ulLength, 0 );
if( ulResult == CR_BUFFER_SMALL )
{
ulInitLength = ulLength + 1;
}
else
{
if( ulResult == CR_SUCCESS )
{
strEnumerator.ValidateBuffer( static_cast< unsigned short >( ulLength ) );
pEnumerator = new_shared_ref<CDeviceEnumerator>( strEnumerator );
TheSystem().As< nsWin32::CSystem >()->Devices( QOR_PP_SHARED_OBJECT_ACCESS )().RegisterEnumerator( strEnumerator, pEnumerator );
}
else
{
//TODO: Handle weirdness
}
ulEnumIndex++;
}
}while( ulResult != CR_NO_SUCH_VALUE );
return ulEnumIndex;
}
//--------------------------------------------------------------------------------
CRootDeviceEnumerator::CRootDeviceEnumerator( const CRootDeviceEnumerator& src ) : m_Library( CSetupAPI::Instance() )
{
_WINQ_FCONTEXT( "CRootDeviceEnumerator::CRootDeviceEnumerator" );
*this = src;
}
//--------------------------------------------------------------------------------
CRootDeviceEnumerator& CRootDeviceEnumerator::operator = ( const CRootDeviceEnumerator& src )
{
_WINQ_FCONTEXT( "CRootDeviceEnumerator::operator =" );
return *this;
}
//--------------------------------------------------------------------------------
CRootDeviceEnumerator::~CRootDeviceEnumerator()
{
_WINQ_FCONTEXT( "CRootDeviceEnumerator::~CRootDeviceEnumerator" );
}
}//nsWin32
| 41.130841 | 157 | 0.65417 | mfaithfull |
0f9f777ef3b011bbe225a7a50e6536d985bcef55 | 3,786 | cc | C++ | source/src/http/protocol/HttpProtocolDecoder.cc | ciscoruiz/wepa | e6d922157543c91b6804f11073424a0a9c6e8f51 | [
"MIT"
] | 2 | 2018-02-03T06:56:29.000Z | 2021-04-20T10:28:32.000Z | source/src/http/protocol/HttpProtocolDecoder.cc | ciscoruiz/wepa | e6d922157543c91b6804f11073424a0a9c6e8f51 | [
"MIT"
] | 8 | 2018-02-18T21:00:07.000Z | 2018-02-20T15:31:24.000Z | source/src/http/protocol/HttpProtocolDecoder.cc | ciscoruiz/wepa | e6d922157543c91b6804f11073424a0a9c6e8f51 | [
"MIT"
] | 1 | 2018-02-09T07:09:26.000Z | 2018-02-09T07:09:26.000Z | // MIT License
//
// Copyright (c) 2018 Francisco Ruiz (francisco.ruiz.rayo@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.
//
#include <coffee/http/protocol/HttpProtocolDecoder.hpp>
#include <coffee/http/protocol/defines.hpp>
#include <coffee/http/protocol/state/HttpProtocolState.hpp>
#include <coffee/http/protocol/state/HttpProtocolWaitingMessage.hpp>
#include <coffee/http/protocol/state/HttpProtocolWaitingContentLength.hpp>
#include <coffee/http/protocol/state/HttpProtocolWaitingBody.hpp>
#include <coffee/http/protocol/state/HttpProtocolReadBody.hpp>
using namespace coffee;
static http::protocol::state::HttpProtocolWaitingMessage stateWaitingMessage;
static http::protocol::state::HttpProtocolWaitingContentLength stateWaitingContentLength;
static http::protocol::state::HttpProtocolWaitingBody stateWaitingBody;
static http::protocol::state::HttpProtocolReadBody stateReadBody;
std::shared_ptr<http::HttpMessage> http::protocol::HttpProtocolDecoder::apply(const basis::DataBlock& dataBlock)
throw(basis::RuntimeException)
{
Token token;
setState(State::WaitingMessage);
m_result.reset();
m_bodyExpectedSize = 0;
while (readToken(dataBlock, token)) {
if (m_state->process(*this, token) == state::HttpProtocolState::ProcessResult::Completed) {
break;
}
}
if (!m_result) {
COFFEE_THROW_EXCEPTION("Unable to allocate an HTTP message");
}
return m_result;
}
bool http::protocol::HttpProtocolDecoder::readToken(const basis::DataBlock& dataBlock, protocol::Token& token)
throw(basis::RuntimeException)
{
static const int nchars = coffee_strlen(http::protocol::newLineCharacters);
if (token.currentPosition == dataBlock.size()) {
return false;
}
auto endToken = dataBlock.find(protocol::newLineCharacters, token.currentPosition);
if (endToken == std::string::npos) {
// Copy from the current position to the end
token.value = basis::DataBlock(dataBlock.data() + token.currentPosition, dataBlock.size() - token.currentPosition);
token.currentPosition = dataBlock.size();
return true;
}
if (endToken == token.currentPosition) {
// Empty token
token.value.clear();
token.currentPosition += nchars;
}
else {
token.value = basis::DataBlock(dataBlock.data() + token.currentPosition, endToken - token.currentPosition);
token.currentPosition = endToken + nchars;
}
return true;
}
void http::protocol::HttpProtocolDecoder::setState(const State::_v state)
noexcept
{
static const state::HttpProtocolState* states[] = { &stateWaitingMessage, &stateWaitingContentLength, &stateWaitingBody, &stateReadBody };
if (m_state != states[state]) {
m_state = states[state];
}
}
| 37.485149 | 141 | 0.744585 | ciscoruiz |
0f9fe4a1bbdeb5d743f53d6d37385f481f645142 | 2,379 | cc | C++ | tc/core/cpu/cpu_tc_executor.cc | dchichkov/TensorComprehensions | e27d427adb532987f07db9450902475c0d807b77 | [
"Apache-2.0"
] | null | null | null | tc/core/cpu/cpu_tc_executor.cc | dchichkov/TensorComprehensions | e27d427adb532987f07db9450902475c0d807b77 | [
"Apache-2.0"
] | null | null | null | tc/core/cpu/cpu_tc_executor.cc | dchichkov/TensorComprehensions | e27d427adb532987f07db9450902475c0d807b77 | [
"Apache-2.0"
] | null | null | null | /**
* Copyright (c) 2017-present, Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "tc/core/cpu/cpu_tc_executor.h"
#include "tc/core/cpu/cpu_mapping_options.h"
#include "tc/core/cpu/cpu_mapping_options_cpp_printer.h"
#include "tc/core/halide_utils.h"
#include "tc/core/tc2halide.h"
#include "tc/core/tensor.h"
#include "tc/lang/parser.h"
#include "tc/lang/sema.h"
#include "version.h"
namespace tc {
CpuTcExecutor::CpuTcExecutor(
const std::vector<TensorInfo>& inputsInfo,
const std::vector<TensorInfo>& outputsInfo,
const tc2halide::HalideComponents& halideComponents,
const typename CpuBackend::CompilationResultType& compilationResult)
: TcExecutor<CpuBackend>(
inputsInfo,
outputsInfo,
halideComponents,
compilationResult) {
LOG(ERROR) << "NYI: CpuTcExecutor::CpuTcExecutor setup RTC";
}
CpuCompilationResult CpuBackend::compileWithTcMapper(
const std::string& tcName,
tc2halide::HalideComponents halideComponents,
const std::vector<const DLConstTensor*>& inputs,
/* TODO: in the future also pass outputs for stride and alignment info */
const CpuMappingOptions& options) {
LOG(ERROR) << "NYI: CpuBackend::compileWithTcMapper";
return CpuCompilationResult{std::string("source"),
std::string("specializedName"),
std::vector<long>()};
}
void CpuTcExecutor::uncheckedRun(
const std::vector<const void*>& inputs,
const std::vector<void*>& outputs) const {
LOG(ERROR) << "NYI: CpuTcExecutor::uncheckedRun";
}
ProfilingInfo CpuTcExecutor::profileUnchecked(
const std::vector<const void*>& inputs,
const std::vector<void*>& outputs) const {
LOG(ERROR) << "NYI: CpuTcExecutor::profileUnchecked";
return ProfilingInfo{Duration::max(), Duration::max()};
}
} // namespace tc
| 36.045455 | 77 | 0.708281 | dchichkov |
0fa03d7a5105acbccf51a2a319de4fdfe23a7b1f | 1,725 | cpp | C++ | Week 8/Lab/Week_8_Sample_Programs/Pr11-9.cpp | sugamkarki/NAMI-Year-II-Term-I-Software_Engineering | 39182816b670dcb75ec322e24b346a4cfeb80be0 | [
"Apache-2.0"
] | 3 | 2019-10-28T01:12:46.000Z | 2021-10-16T09:16:31.000Z | Week 8/Lab/Week_8_Sample_Programs/Pr11-9.cpp | sugamkarki/NAMI-Year-II-Term-I-Software_Engineering | 39182816b670dcb75ec322e24b346a4cfeb80be0 | [
"Apache-2.0"
] | null | null | null | Week 8/Lab/Week_8_Sample_Programs/Pr11-9.cpp | sugamkarki/NAMI-Year-II-Term-I-Software_Engineering | 39182816b670dcb75ec322e24b346a4cfeb80be0 | [
"Apache-2.0"
] | 4 | 2020-04-10T17:22:17.000Z | 2021-11-04T14:34:00.000Z | // This program demonstrates a union.
#include <iostream>
#include <iomanip>
using namespace std;
union PaySource
{
int hours; // Hours worked
float sales; // Amount of sales
};
int main()
{
PaySource employee1; // Define a union variable
char payType; // To hold the pay type
float payRate; // Hourly pay rate
float grossPay; // Gross pay
cout << fixed << showpoint << setprecision(2);
cout << "This program calculates either hourly wages or\n";
cout << "sales commission.\n";
// Get the pay type, hourly or commission.
cout << "Enter H for hourly wages or C for commission: ";
cin >> payType;
// Determine the gross pay, depending on the pay type.
if (payType == 'H' || payType == 'h')
{
// This is an hourly paid employee. Get the
// pay rate and hours worked.
cout << "What is the hourly pay rate? ";
cin >> payRate;
cout << "How many hours were worked? ";
cin >> employee1.hours;
// Calculate and display the gross pay.
grossPay = employee1.hours * payRate;
cout << "Gross pay: $" << grossPay << endl;
}
else if (payType == 'C' || payType == 'c')
{
// This is a commission-paid employee. Get the
// amount of sales.
cout << "What are the total sales for this employee? ";
cin >> employee1.sales;
// Calculate and display the gross pay.
grossPay = employee1.sales * 0.10;
cout << "Gross pay: $" << grossPay << endl;
}
else
{
// The user made an invalid selection.
cout << payType << " is not a valid selection.\n";
}
return 0;
} | 29.741379 | 63 | 0.566377 | sugamkarki |
0fa166751d178f1fb7e7f18be4914aa599ad222a | 546 | cpp | C++ | SDDD/changecode.cpp | hux8/SDD-Project | 1d589f88655f5a565f0c2efb5d60a3dd8ccc5c06 | [
"MIT"
] | null | null | null | SDDD/changecode.cpp | hux8/SDD-Project | 1d589f88655f5a565f0c2efb5d60a3dd8ccc5c06 | [
"MIT"
] | 1 | 2019-03-15T01:59:20.000Z | 2019-03-15T17:36:01.000Z | SDDD/changecode.cpp | hux8/SDD-Project | 1d589f88655f5a565f0c2efb5d60a3dd8ccc5c06 | [
"MIT"
] | 5 | 2018-10-25T23:14:30.000Z | 2018-11-05T18:43:46.000Z | #include "changecode.h"
#include "ui_changecode.h"
ChangeCode::ChangeCode(QWidget *parent) :
QDialog(parent),
ui(new Ui::ChangeCode)
{
ui->setupUi(this);
ui->error->setVisible(false);
}
ChangeCode::~ChangeCode()
{
delete ui;
}
void ChangeCode::accept()
{
//check if the code is new
if(ui->first->text()==ui->second->text())
emit changeCode(ui->first->text());
//update the code
else
{
ui->error->setVisible(true);
ui->first->setText("");
ui->second->setText("");
}
}
| 18.2 | 45 | 0.587912 | hux8 |
0fa1ac940aeae54547c38c9988d6b694a667e064 | 58,821 | cxx | C++ | Pando/src/SciTEBuffers.cxx | jjzhang166/Pando | ab9b37eeaefdd6ee06b38b590e1fa60912e7aca9 | [
"FSFAP"
] | null | null | null | Pando/src/SciTEBuffers.cxx | jjzhang166/Pando | ab9b37eeaefdd6ee06b38b590e1fa60912e7aca9 | [
"FSFAP"
] | null | null | null | Pando/src/SciTEBuffers.cxx | jjzhang166/Pando | ab9b37eeaefdd6ee06b38b590e1fa60912e7aca9 | [
"FSFAP"
] | null | null | null | // SciTE - Scintilla based Text Editor
/** @file SciTEBuffers.cxx
** Buffers and jobs management.
**/
// Copyright 1998-2010 by Neil Hodgson <neilh@scintilla.org>
// The License.txt file describes the conditions under which this software may be distributed.
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <stdio.h>
#include <stddef.h>
#include <time.h>
#include <assert.h>
#include <string>
#include <vector>
#include <set>
#include <map>
#include "Scintilla.h"
#include "SciLexer.h"
#include "ILexer.h"
#include "GUI.h"
#include "SString.h"
#include "StringList.h"
#include "StringHelpers.h"
#include "FilePath.h"
#include "StyleDefinition.h"
#include "PropSetFile.h"
#include "StyleWriter.h"
#include "Extender.h"
#include "SciTE.h"
#include "Mutex.h"
#include "JobQueue.h"
#include "Cookie.h"
#include "Worker.h"
#include "FileWorker.h"
#include "MatchMarker.h"
#include "SciTEBase.h"
const GUI::gui_char defaultSessionFileName[] = GUI_TEXT("SciTE.session");
void Buffer::DocumentModified() {
documentModTime = time(0);
}
bool Buffer::NeedsSave(int delayBeforeSave) const {
time_t now = time(0);
return now && documentModTime && isDirty && !pFileWorker && (now-documentModTime > delayBeforeSave) && !IsUntitled() && !failedSave;
}
void Buffer::CompleteLoading() {
lifeState = open;
if (pFileWorker && pFileWorker->IsLoading()) {
delete pFileWorker;
pFileWorker = 0;
}
}
void Buffer::CompleteStoring() {
if (pFileWorker && !pFileWorker->IsLoading()) {
delete pFileWorker;
pFileWorker = 0;
}
SetTimeFromFile();
}
void Buffer::AbandonAutomaticSave() {
if (pFileWorker && !pFileWorker->IsLoading()) {
FileStorer *pFileStorer = static_cast<FileStorer *>(pFileWorker);
if (!pFileStorer->visibleProgress) {
pFileWorker->Cancel();
// File is in partially saved state so may be better to remove
}
}
}
void Buffer::CancelLoad() {
// Complete any background loading
if (pFileWorker && pFileWorker->IsLoading()) {
pFileWorker->Cancel();
CompleteLoading();
lifeState = empty;
}
}
BufferList::BufferList() : current(0), stackcurrent(0), stack(0), buffers(0), size(0), length(0), lengthVisible(0), initialised(false) {}
BufferList::~BufferList() {
delete []buffers;
delete []stack;
}
void BufferList::Allocate(int maxSize) {
length = 1;
lengthVisible = 1;
current = 0;
size = maxSize;
buffers = new Buffer[size];
stack = new int[size];
stack[0] = 0;
}
int BufferList::Add() {
if (length < size) {
length++;
}
buffers[length - 1].Init();
stack[length - 1] = length - 1;
MoveToStackTop(length - 1);
SetVisible(length-1, true);
return lengthVisible - 1;
}
int BufferList::GetDocumentByWorker(FileWorker *pFileWorker) const {
for (int i = 0;i < length;i++) {
if (buffers[i].pFileWorker == pFileWorker) {
return i;
}
}
return -1;
}
int BufferList::GetDocumentByName(FilePath filename, bool excludeCurrent) {
if (!filename.IsSet()) {
return -1;
}
for (int i = 0;i < length;i++) {
if ((!excludeCurrent || i != current) && buffers[i].SameNameAs(filename)) {
return i;
}
}
return -1;
}
void BufferList::RemoveInvisible(int index) {
assert(!GetVisible(index));
if (index == current) {
RemoveCurrent();
} else {
if (index < length-1) {
// Swap with last visible
Swap(index, length-1);
}
length--;
}
}
void BufferList::RemoveCurrent() {
// Delete and move up to fill gap but ensure doc pointer is saved.
sptr_t currentDoc = buffers[current].doc;
buffers[current].CompleteLoading();
for (int i = current;i < length - 1;i++) {
buffers[i] = buffers[i + 1];
}
buffers[length - 1].doc = currentDoc;
if (length > 1) {
CommitStackSelection();
PopStack();
length--;
lengthVisible--;
buffers[length].Init();
if (current >= lengthVisible) {
SetCurrent(lengthVisible - 1);
}
if (current < 0) {
SetCurrent(0);
}
} else {
buffers[current].Init();
}
MoveToStackTop(current);
}
int BufferList::Current() const {
return current;
}
Buffer *BufferList::CurrentBuffer() {
return &buffers[Current()];
}
void BufferList::SetCurrent(int index) {
current = index;
}
void BufferList::PopStack() {
for (int i = 0; i < length - 1; ++i) {
int index = stack[i + 1];
// adjust the index for items that will move in buffers[]
if (index > current)
--index;
stack[i] = index;
}
}
int BufferList::StackNext() {
if (++stackcurrent >= length)
stackcurrent = 0;
return stack[stackcurrent];
}
int BufferList::StackPrev() {
if (--stackcurrent < 0)
stackcurrent = length - 1;
return stack[stackcurrent];
}
void BufferList::MoveToStackTop(int index) {
// shift top chunk of stack down into the slot that index occupies
bool move = false;
for (int i = length - 1; i > 0; --i) {
if (stack[i] == index)
move = true;
if (move)
stack[i] = stack[i-1];
}
stack[0] = index;
}
void BufferList::CommitStackSelection() {
// called only when ctrl key is released when ctrl-tabbing
// or when a document is closed (in case of Ctrl+F4 during ctrl-tabbing)
MoveToStackTop(stack[stackcurrent]);
stackcurrent = 0;
}
void BufferList::ShiftTo(int indexFrom, int indexTo) {
// shift buffer to new place in buffers array
if (indexFrom == indexTo ||
indexFrom < 0 || indexFrom >= length ||
indexTo < 0 || indexTo >= length) return;
int step = (indexFrom > indexTo) ? -1 : 1;
Buffer tmp = buffers[indexFrom];
int i;
for (i = indexFrom; i != indexTo; i += step) {
buffers[i] = buffers[i+step];
}
buffers[indexTo] = tmp;
// update stack indexes
for (i = 0; i < length; i++) {
if (stack[i] == indexFrom) {
stack[i] = indexTo;
} else if (step == 1) {
if (indexFrom < stack[i] && stack[i] <= indexTo) stack[i] -= step;
} else {
if (indexFrom > stack[i] && stack[i] >= indexTo) stack[i] -= step;
}
}
}
void BufferList::Swap(int indexA, int indexB) {
// shift buffer to new place in buffers array
if (indexA == indexB ||
indexA < 0 || indexA >= length ||
indexB < 0 || indexB >= length) return;
Buffer tmp = buffers[indexA];
buffers[indexA] = buffers[indexB];
buffers[indexB] = tmp;
// update stack indexes
for (int i = 0; i < length; i++) {
if (stack[i] == indexA) {
stack[i] = indexB;
} else if (stack[i] == indexB) {
stack[i] = indexA;
}
}
}
bool BufferList::SingleBuffer() const {
return size == 1;
}
BackgroundActivities BufferList::CountBackgroundActivities() const {
BackgroundActivities bg;
bg.loaders = 0;
bg.storers = 0;
bg.totalWork = 0;
bg.totalProgress = 0;
for (int i = 0;i < length;i++) {
if (buffers[i].pFileWorker) {
if (!buffers[i].pFileWorker->FinishedJob()) {
if (!buffers[i].pFileWorker->IsLoading()) {
FileStorer *fstorer = static_cast<FileStorer*>(buffers[i].pFileWorker);
if (!fstorer->visibleProgress)
continue;
}
if (buffers[i].pFileWorker->IsLoading())
bg.loaders++;
else
bg.storers++;
bg.fileNameLast = buffers[i].AsInternal();
bg.totalWork += buffers[i].pFileWorker->SizeJob();
bg.totalProgress += buffers[i].pFileWorker->ProgressMade();
}
}
}
return bg;
}
bool BufferList::SavingInBackground() const {
for (int i = 0; i<length; i++) {
if (buffers[i].pFileWorker && !buffers[i].pFileWorker->IsLoading() && !buffers[i].pFileWorker->FinishedJob()) {
return true;
}
}
return false;
}
bool BufferList::GetVisible(int index) const {
return index < lengthVisible;
}
void BufferList::SetVisible(int index, bool visible) {
if (visible != GetVisible(index)) {
if (visible) {
if (index > lengthVisible) {
// Swap with first invisible
Swap(index, lengthVisible);
}
lengthVisible++;
} else {
if (index < lengthVisible-1) {
// Swap with last visible
Swap(index, lengthVisible-1);
}
lengthVisible--;
if (current >= lengthVisible && lengthVisible > 0)
SetCurrent(lengthVisible-1);
}
}
}
void BufferList::AddFuture(int index, Buffer::FutureDo fd) {
if (index >= 0 || index < length) {
buffers[index].futureDo = static_cast<Buffer::FutureDo>(buffers[index].futureDo | fd);
}
}
void BufferList::FinishedFuture(int index, Buffer::FutureDo fd) {
if (index >= 0 || index < length) {
buffers[index].futureDo = static_cast<Buffer::FutureDo>(buffers[index].futureDo & ~(fd));
}
}
sptr_t SciTEBase::GetDocumentAt(int index) {
if (index < 0 || index >= buffers.size) {
return 0;
}
if (buffers.buffers[index].doc == 0) {
// Create a new document buffer
buffers.buffers[index].doc = wEditor.CallReturnPointer(SCI_CREATEDOCUMENT, 0, 0);
}
return buffers.buffers[index].doc;
}
void SciTEBase::SwitchDocumentAt(int index, sptr_t pdoc) {
if (index < 0 || index >= buffers.size) {
return;
}
sptr_t pdocOld = buffers.buffers[index].doc;
buffers.buffers[index].doc = pdoc;
if (pdocOld) {
wEditor.Call(SCI_RELEASEDOCUMENT, 0, pdocOld);
}
if (index == buffers.Current()) {
wEditor.Call(SCI_SETDOCPOINTER, 0, buffers.buffers[index].doc);
}
}
void SciTEBase::SetDocumentAt(int index, bool updateStack) {
int currentbuf = buffers.Current();
if ( index < 0 ||
index >= buffers.length ||
index == currentbuf ||
currentbuf < 0 ||
currentbuf >= buffers.length) {
return;
}
UpdateBuffersCurrent();
buffers.SetCurrent(index);
if (updateStack) {
buffers.MoveToStackTop(index);
}
if (extender) {
if (buffers.size > 1)
extender->ActivateBuffer(index);
else
extender->InitBuffer(0);
}
Buffer bufferNext = buffers.buffers[buffers.Current()];
SetFileName(bufferNext);
propsDiscovered = bufferNext.props;
propsDiscovered.superPS = &propsLocal;
wEditor.Call(SCI_SETDOCPOINTER, 0, GetDocumentAt(buffers.Current()));
bool restoreBookmarks = bufferNext.lifeState == Buffer::readAll;
PerformDeferredTasks();
if (bufferNext.lifeState == Buffer::readAll) {
CompleteOpen(ocCompleteSwitch);
if (extender)
extender->OnOpen(filePath.AsUTF8().c_str());
}
RestoreState(bufferNext, restoreBookmarks);
TabSelect(index);
if (lineNumbers && lineNumbersExpand)
SetLineNumberWidth();
DisplayAround(bufferNext);
if (restoreBookmarks) {
// Restoring a session does not restore the scroll position
// so make the selection visible.
wEditor.Call(SCI_SCROLLCARET);
}
SetBuffersMenu();
CheckMenus();
UpdateStatusBar(true);
if (extender) {
extender->OnSwitchFile(filePath.AsUTF8().c_str());
}
}
void SciTEBase::UpdateBuffersCurrent() {
int currentbuf = buffers.Current();
if ((buffers.length > 0) && (currentbuf >= 0) && (buffers.GetVisible(currentbuf))) {
Buffer &bufferCurrent = buffers.buffers[currentbuf];
bufferCurrent.Set(filePath);
if (bufferCurrent.lifeState != Buffer::reading && bufferCurrent.lifeState != Buffer::readAll) {
bufferCurrent.selection.position = wEditor.Call(SCI_GETCURRENTPOS);
bufferCurrent.selection.anchor = wEditor.Call(SCI_GETANCHOR);
bufferCurrent.scrollPosition = GetCurrentScrollPosition();
// Retrieve fold state and store in buffer state info
std::vector<int> *f = &bufferCurrent.foldState;
f->clear();
if (props.GetInt("fold")) {
for (int line = 0; ; line++) {
int lineNext = wEditor.Call(SCI_CONTRACTEDFOLDNEXT, line);
if ((line < 0) || (lineNext < line))
break;
line = lineNext;
f->push_back(line);
}
}
if (props.GetInt("session.bookmarks")) {
buffers.buffers[buffers.Current()].bookmarks.clear();
int lineBookmark = -1;
while ((lineBookmark = wEditor.Call(SCI_MARKERNEXT, lineBookmark + 1, 1 << markerBookmark)) >= 0) {
bufferCurrent.bookmarks.push_back(lineBookmark);
}
}
}
}
}
bool SciTEBase::IsBufferAvailable() const {
return buffers.size > 1 && buffers.length < buffers.size;
}
bool SciTEBase::CanMakeRoom(bool maySaveIfDirty) {
if (IsBufferAvailable()) {
return true;
} else if (maySaveIfDirty) {
// All available buffers are taken, try and close the current one
if (SaveIfUnsure(true, static_cast<SaveFlags>(sfProgressVisible | sfSynchronous)) != saveCancelled) {
// The file isn't dirty, or the user agreed to close the current one
return true;
}
} else {
return true; // Told not to save so must be OK.
}
return false;
}
void SciTEBase::ClearDocument() {
wEditor.Call(SCI_SETREADONLY, 0);
wEditor.Call(SCI_SETUNDOCOLLECTION, 0);
wEditor.Call(SCI_CLEARALL);
wEditor.Call(SCI_EMPTYUNDOBUFFER);
wEditor.Call(SCI_SETUNDOCOLLECTION, 1);
wEditor.Call(SCI_SETSAVEPOINT);
wEditor.Call(SCI_SETREADONLY, CurrentBuffer()->isReadOnly);
}
void SciTEBase::CreateBuffers() {
int buffersWanted = props.GetInt("buffers");
if (buffersWanted > bufferMax) {
buffersWanted = bufferMax;
}
if (buffersWanted < 1) {
buffersWanted = 1;
}
buffers.Allocate(buffersWanted);
}
void SciTEBase::InitialiseBuffers() {
if (!buffers.initialised) {
buffers.initialised = true;
// First document is the default from creation of control
buffers.buffers[0].doc = wEditor.CallReturnPointer(SCI_GETDOCPOINTER, 0, 0);
wEditor.Call(SCI_ADDREFDOCUMENT, 0, buffers.buffers[0].doc); // We own this reference
if (buffers.size == 1) {
// Single buffer mode, delete the Buffers main menu entry
DestroyMenuItem(menuBuffers, 0);
// Destroy command "View Tab Bar" in the menu "View"
DestroyMenuItem(menuView, IDM_VIEWTABBAR);
// Make previous change visible.
RedrawMenu();
}
}
}
FilePath SciTEBase::UserFilePath(const GUI::gui_char *name) {
GUI::gui_string nameWithVisibility(configFileVisibilityString);
nameWithVisibility += name;
return FilePath(GetSciteUserHome(), nameWithVisibility.c_str());
}
static std::string IndexPropKey(const char *bufPrefix, int bufIndex, const char *bufAppendix) {
std::string pKey = bufPrefix;
pKey += '.';
pKey += StdStringFromInteger(bufIndex + 1);
if (bufAppendix != NULL) {
pKey += ".";
pKey += bufAppendix;
}
return pKey;
}
void SciTEBase::LoadSessionFile(const GUI::gui_char *sessionName) {
FilePath sessionPathName;
if (sessionName[0] == '\0') {
sessionPathName = UserFilePath(defaultSessionFileName);
} else {
sessionPathName.Set(sessionName);
}
propsSession.Clear();
propsSession.Read(sessionPathName, sessionPathName.Directory(), filter, NULL, 0);
FilePath sessionFilePath = FilePath(sessionPathName).AbsolutePath();
// Add/update SessionPath environment variable
props.Set("SessionPath", sessionFilePath.AsUTF8().c_str());
}
void SciTEBase::RestoreRecentMenu() {
SelectedRange sr(0,0);
DeleteFileStackMenu();
for (int i = 0; i < fileStackMax; i++) {
std::string propKey = IndexPropKey("mru", i, "path");
std::string propStr = propsSession.GetString(propKey.c_str());
if (propStr == "")
continue;
AddFileToStack(GUI::StringFromUTF8(propStr.c_str()), sr, 0);
}
}
static std::vector<int> LinesFromString(const std::string &s) {
std::vector<int> result;
if (s.length()) {
size_t start = 0;
for (;;) {
const int line = atoi(s.c_str() + start) - 1;
result.push_back(line);
const size_t posComma = s.find(',', start);
if (posComma == std::string::npos)
break;
start = posComma + 1;
}
}
return result;
}
void SciTEBase::RestoreFromSession(const Session &session) {
for (std::vector<BufferState>::const_iterator bs=session.buffers.begin(); bs != session.buffers.end(); ++bs)
AddFileToBuffer(*bs);
int iBuffer = buffers.GetDocumentByName(session.pathActive);
if (iBuffer >= 0)
SetDocumentAt(iBuffer);
}
void SciTEBase::RestoreSession() {
if (props.GetInt("save.find") != 0) {
for (int i = 0;; i++) {
std::string propKey = IndexPropKey("search", i, "findwhat");
std::string propStr = propsSession.GetString(propKey.c_str());
if (propStr == "")
break;
memFinds.AppendList(propStr.c_str());
}
for (int i = 0;; i++) {
std::string propKey = IndexPropKey("search", i, "replacewith");
std::string propStr = propsSession.GetString(propKey.c_str());
if (propStr == "")
break;
memReplaces.AppendList(propStr.c_str());
}
}
// Comment next line if you don't want to close all buffers before restoring session
CloseAllBuffers(true);
Session session;
for (int i = 0; i < bufferMax; i++) {
std::string propKey = IndexPropKey("buffer", i, "path");
std::string propStr = propsSession.GetString(propKey.c_str());
if (propStr == "")
continue;
BufferState bufferState;
bufferState.Set(GUI::StringFromUTF8(propStr.c_str()));
propKey = IndexPropKey("buffer", i, "current");
if (propsSession.GetInt(propKey.c_str()))
session.pathActive = bufferState;
propKey = IndexPropKey("buffer", i, "scroll");
int scroll = propsSession.GetInt(propKey.c_str());
bufferState.scrollPosition = scroll;
propKey = IndexPropKey("buffer", i, "position");
int pos = propsSession.GetInt(propKey.c_str());
bufferState.selection.anchor = pos - 1;
bufferState.selection.position = bufferState.selection.anchor;
if (props.GetInt("session.bookmarks")) {
propKey = IndexPropKey("buffer", i, "bookmarks");
propStr = propsSession.GetString(propKey.c_str());
bufferState.bookmarks = LinesFromString(propStr);
}
if (props.GetInt("fold") && !props.GetInt("fold.on.open") &&
props.GetInt("session.folds")) {
propKey = IndexPropKey("buffer", i, "folds");
propStr = propsSession.GetString(propKey.c_str());
bufferState.foldState = LinesFromString(propStr);
}
session.buffers.push_back(bufferState);
}
RestoreFromSession(session);
}
void SciTEBase::SaveSessionFile(const GUI::gui_char *sessionName) {
UpdateBuffersCurrent();
bool defaultSession;
FilePath sessionPathName;
if (sessionName[0] == '\0') {
sessionPathName = UserFilePath(defaultSessionFileName);
defaultSession = true;
} else {
sessionPathName.Set(sessionName);
defaultSession = false;
}
FILE *sessionFile = sessionPathName.Open(fileWrite);
if (!sessionFile)
return;
fprintf(sessionFile, "# SciTE session file\n");
if (defaultSession && props.GetInt("save.position")) {
int top, left, width, height, maximize;
GetWindowPosition(&left, &top, &width, &height, &maximize);
fprintf(sessionFile, "\n");
fprintf(sessionFile, "position.left=%d\n", left);
fprintf(sessionFile, "position.top=%d\n", top);
fprintf(sessionFile, "position.width=%d\n", width);
fprintf(sessionFile, "position.height=%d\n", height);
fprintf(sessionFile, "position.maximize=%d\n", maximize);
}
if (defaultSession && props.GetInt("save.recent")) {
std::string propKey;
int j = 0;
fprintf(sessionFile, "\n");
// Save recent files list
for (int i = fileStackMax - 1; i >= 0; i--) {
if (recentFileStack[i].IsSet()) {
propKey = IndexPropKey("mru", j++, "path");
fprintf(sessionFile, "%s=%s\n", propKey.c_str(), recentFileStack[i].AsUTF8().c_str());
}
}
}
if (defaultSession && props.GetInt("save.find")) {
std::string propKey;
std::vector<std::string>::iterator it;
std::vector<std::string> mem = memFinds.AsVector();
if (!mem.empty()) {
fprintf(sessionFile, "\n");
it = mem.begin();
for (int i = 0; it != mem.end(); i++, ++it) {
propKey = IndexPropKey("search", i, "findwhat");
fprintf(sessionFile, "%s=%s\n", propKey.c_str(), (*it).c_str());
}
}
mem = memReplaces.AsVector();
if (!mem.empty()) {
fprintf(sessionFile, "\n");
mem = memReplaces.AsVector();
it = mem.begin();
for (int i = 0; it != mem.end(); i++, ++it) {
propKey = IndexPropKey("search", i, "replacewith");
fprintf(sessionFile, "%s=%s\n", propKey.c_str(), (*it).c_str());
}
}
}
if (props.GetInt("buffers") && (!defaultSession || props.GetInt("save.session"))) {
int curr = buffers.Current();
for (int i = 0; i < buffers.lengthVisible; i++) {
if (buffers.buffers[i].IsSet() && !buffers.buffers[i].IsUntitled()) {
Buffer &buff = buffers.buffers[i];
std::string propKey = IndexPropKey("buffer", i, "path");
fprintf(sessionFile, "\n%s=%s\n", propKey.c_str(), buff.AsUTF8().c_str());
int pos = buff.selection.position + 1;
propKey = IndexPropKey("buffer", i, "position");
fprintf(sessionFile, "%s=%d\n", propKey.c_str(), pos);
int scroll = buff.scrollPosition;
propKey = IndexPropKey("buffer", i, "scroll");
fprintf(sessionFile, "%s=%d\n", propKey.c_str(), scroll);
if (i == curr) {
propKey = IndexPropKey("buffer", i, "current");
fprintf(sessionFile, "%s=1\n", propKey.c_str());
}
if (props.GetInt("session.bookmarks")) {
bool found = false;
for (std::vector<int>::iterator itBM=buff.bookmarks.begin();
itBM != buff.bookmarks.end(); ++itBM) {
if (!found) {
propKey = IndexPropKey("buffer", i, "bookmarks");
fprintf(sessionFile, "%s=%d", propKey.c_str(), *itBM + 1);
found = true;
} else {
fprintf(sessionFile, ",%d", *itBM + 1);
}
}
if (found)
fprintf(sessionFile, "\n");
}
if (props.GetInt("fold") && props.GetInt("session.folds")) {
bool found = false;
for (std::vector<int>::iterator itF=buff.foldState.begin();
itF != buff.foldState.end(); ++itF) {
if (!found) {
propKey = IndexPropKey("buffer", i, "folds");
fprintf(sessionFile, "%s=%d", propKey.c_str(), *itF + 1);
found = true;
} else {
fprintf(sessionFile, ",%d", *itF + 1);
}
}
if (found)
fprintf(sessionFile, "\n");
}
}
}
}
fclose(sessionFile);
FilePath sessionFilePath = FilePath(sessionPathName).AbsolutePath();
// Add/update SessionPath environment variable
props.Set("SessionPath", sessionFilePath.AsUTF8().c_str());
}
void SciTEBase::SetIndentSettings() {
// Get default values
int useTabs = props.GetInt("use.tabs", 1);
int tabSize = props.GetInt("tabsize");
int indentSize = props.GetInt("indent.size");
// Either set the settings related to the extension or the default ones
SString fileNameForExtension = ExtensionFileName();
SString useTabsChars = props.GetNewExpand("use.tabs.",
fileNameForExtension.c_str());
if (useTabsChars.length() != 0) {
wEditor.Call(SCI_SETUSETABS, useTabsChars.value());
} else {
wEditor.Call(SCI_SETUSETABS, useTabs);
}
SString tabSizeForExt = props.GetNewExpand("tab.size.",
fileNameForExtension.c_str());
if (tabSizeForExt.length() != 0) {
wEditor.Call(SCI_SETTABWIDTH, tabSizeForExt.value());
} else if (tabSize != 0) {
wEditor.Call(SCI_SETTABWIDTH, tabSize);
}
SString indentSizeForExt = props.GetNewExpand("indent.size.",
fileNameForExtension.c_str());
if (indentSizeForExt.length() != 0) {
wEditor.Call(SCI_SETINDENT, indentSizeForExt.value());
} else {
wEditor.Call(SCI_SETINDENT, indentSize);
}
}
void SciTEBase::SetEol() {
SString eol_mode = props.Get("eol.mode");
if (eol_mode == "LF") {
wEditor.Call(SCI_SETEOLMODE, SC_EOL_LF);
} else if (eol_mode == "CR") {
wEditor.Call(SCI_SETEOLMODE, SC_EOL_CR);
} else if (eol_mode == "CRLF") {
wEditor.Call(SCI_SETEOLMODE, SC_EOL_CRLF);
}
}
void SciTEBase::New() {
InitialiseBuffers();
UpdateBuffersCurrent();
propsDiscovered.Clear();
if ((buffers.size == 1) && (!buffers.buffers[0].IsUntitled())) {
AddFileToStack(buffers.buffers[0],
buffers.buffers[0].selection,
buffers.buffers[0].scrollPosition);
}
// If the current buffer is the initial untitled, clean buffer then overwrite it,
// otherwise add a new buffer.
if ((buffers.length > 1) ||
(buffers.Current() != 0) ||
(buffers.buffers[0].isDirty) ||
(!buffers.buffers[0].IsUntitled())) {
if (buffers.size == buffers.length) {
Close(false, false, true);
}
buffers.SetCurrent(buffers.Add());
}
sptr_t doc = GetDocumentAt(buffers.Current());
wEditor.Call(SCI_SETDOCPOINTER, 0, doc);
FilePath curDirectory(filePath.Directory());
filePath.Set(curDirectory, GUI_TEXT(""));
SetFileName(filePath);
UpdateBuffersCurrent();
SetBuffersMenu();
CurrentBuffer()->isDirty = false;
CurrentBuffer()->failedSave = false;
CurrentBuffer()->lifeState = Buffer::open;
jobQueue.isBuilding = false;
jobQueue.isBuilt = false;
CurrentBuffer()->isReadOnly = false; // No sense to create an empty, read-only buffer...
ClearDocument();
DeleteFileStackMenu();
SetFileStackMenu();
if (extender)
extender->InitBuffer(buffers.Current());
}
void SciTEBase::RestoreState(const Buffer &buffer, bool restoreBookmarks) {
SetWindowName();
ReadProperties();
if (CurrentBuffer()->unicodeMode != uni8Bit) {
// Override the code page if Unicode
codePage = SC_CP_UTF8;
wEditor.Call(SCI_SETCODEPAGE, codePage);
}
// check to see whether there is saved fold state, restore
if (!buffer.foldState.empty()) {
wEditor.Call(SCI_COLOURISE, 0, -1);
for (std::vector<int>::const_iterator fold=buffer.foldState.begin(); fold != buffer.foldState.end(); ++fold) {
wEditor.Call(SCI_TOGGLEFOLD, *fold);
}
}
if (restoreBookmarks) {
for (std::vector<int>::const_iterator mark=buffer.bookmarks.begin(); mark != buffer.bookmarks.end(); ++mark) {
wEditor.Call(SCI_MARKERADD, *mark, markerBookmark);
}
}
}
void SciTEBase::Close(bool updateUI, bool loadingSession, bool makingRoomForNew) {
bool closingLast = false;
int index = buffers.Current();
if (index >= 0) {
buffers.buffers[index].CancelLoad();
}
if (extender) {
extender->OnClose(filePath.AsUTF8().c_str());
}
if (buffers.size == 1) {
// With no buffer list, Close means close from MRU
closingLast = !(recentFileStack[0].IsSet());
buffers.buffers[0].Init();
filePath.Set(GUI_TEXT(""));
ClearDocument(); //avoid double are-you-sure
if (!makingRoomForNew)
StackMenu(0); // calls New, or Open, which calls InitBuffer
} else if (buffers.size > 1) {
if (buffers.Current() >= 0 && buffers.Current() < buffers.length) {
UpdateBuffersCurrent();
Buffer buff = buffers.buffers[buffers.Current()];
AddFileToStack(buff, buff.selection, buff.scrollPosition);
}
closingLast = (buffers.lengthVisible == 1) && !buffers.buffers[0].pFileWorker;
if (closingLast) {
buffers.buffers[0].Init();
buffers.buffers[0].lifeState = Buffer::open;
if (extender)
extender->InitBuffer(0);
} else {
if (extender)
extender->RemoveBuffer(buffers.Current());
if (buffers.buffers[buffers.Current()].pFileWorker) {
buffers.SetVisible(buffers.Current(), false);
if (buffers.lengthVisible == 0)
New();
} else {
wEditor.Call(SCI_SETREADONLY, 0);
ClearDocument();
buffers.RemoveCurrent();
}
if (extender && !makingRoomForNew)
extender->ActivateBuffer(buffers.Current());
}
Buffer bufferNext = buffers.buffers[buffers.Current()];
if (updateUI)
SetFileName(bufferNext);
else
filePath = bufferNext;
propsDiscovered = bufferNext.props;
propsDiscovered.superPS = &propsLocal;
wEditor.Call(SCI_SETDOCPOINTER, 0, GetDocumentAt(buffers.Current()));
PerformDeferredTasks();
if (bufferNext.lifeState == Buffer::readAll) {
//restoreBookmarks = true;
CompleteOpen(ocCompleteSwitch);
if (extender)
extender->OnOpen(filePath.AsUTF8().c_str());
}
if (closingLast) {
wEditor.Call(SCI_SETREADONLY, 0);
ClearDocument();
}
if (updateUI)
CheckReload();
if (updateUI) {
RestoreState(bufferNext, false);
DisplayAround(bufferNext);
}
}
if (updateUI) {
BuffersMenu();
UpdateStatusBar(true);
}
if (extender && !closingLast && !makingRoomForNew) {
extender->OnSwitchFile(filePath.AsUTF8().c_str());
}
if (closingLast && props.GetInt("quit.on.close.last") && !loadingSession) {
QuitProgram();
}
}
void SciTEBase::CloseTab(int tab) {
int tabCurrent = buffers.Current();
if (tab == tabCurrent) {
if (SaveIfUnsure() != saveCancelled) {
Close();
WindowSetFocus(wEditor);
}
} else {
FilePath fpCurrent = buffers.buffers[tabCurrent].AbsolutePath();
SetDocumentAt(tab);
if (SaveIfUnsure() != saveCancelled) {
Close();
WindowSetFocus(wEditor);
// Return to the previous buffer
SetDocumentAt(buffers.GetDocumentByName(fpCurrent));
}
}
}
void SciTEBase::CloseAllBuffers(bool loadingSession) {
if (SaveAllBuffers(false) != saveCancelled) {
while (buffers.lengthVisible > 1)
Close(false, loadingSession);
Close(true, loadingSession);
}
}
SciTEBase::SaveResult SciTEBase::SaveAllBuffers(bool alwaysYes) {
SaveResult choice = saveCompleted;
UpdateBuffersCurrent();
int currentBuffer = buffers.Current();
for (int i = 0; (i < buffers.lengthVisible) && (choice != saveCancelled); i++) {
if (buffers.buffers[i].isDirty) {
SetDocumentAt(i);
if (alwaysYes) {
if (!Save()) {
choice = saveCancelled;
}
} else {
choice = SaveIfUnsure(false);
}
}
}
SetDocumentAt(currentBuffer);
return choice;
}
void SciTEBase::SaveTitledBuffers() {
UpdateBuffersCurrent();
int currentBuffer = buffers.Current();
for (int i = 0; i < buffers.lengthVisible; i++) {
if (buffers.buffers[i].isDirty && !buffers.buffers[i].IsUntitled()) {
SetDocumentAt(i);
Save();
}
}
SetDocumentAt(currentBuffer);
}
void SciTEBase::Next() {
int next = buffers.Current();
if (++next >= buffers.lengthVisible)
next = 0;
SetDocumentAt(next);
CheckReload();
}
void SciTEBase::Prev() {
int prev = buffers.Current();
if (--prev < 0)
prev = buffers.lengthVisible - 1;
SetDocumentAt(prev);
CheckReload();
}
void SciTEBase::ShiftTab(int indexFrom, int indexTo) {
buffers.ShiftTo(indexFrom, indexTo);
buffers.SetCurrent(indexTo);
BuffersMenu();
TabSelect(indexTo);
DisplayAround(buffers.buffers[buffers.Current()]);
}
void SciTEBase::MoveTabRight() {
if (buffers.lengthVisible < 2) return;
int indexFrom = buffers.Current();
int indexTo = indexFrom + 1;
if (indexTo >= buffers.lengthVisible) indexTo = 0;
ShiftTab(indexFrom, indexTo);
}
void SciTEBase::MoveTabLeft() {
if (buffers.lengthVisible < 2) return;
int indexFrom = buffers.Current();
int indexTo = indexFrom - 1;
if (indexTo < 0) indexTo = buffers.lengthVisible - 1;
ShiftTab(indexFrom, indexTo);
}
void SciTEBase::NextInStack() {
SetDocumentAt(buffers.StackNext(), false);
CheckReload();
}
void SciTEBase::PrevInStack() {
SetDocumentAt(buffers.StackPrev(), false);
CheckReload();
}
void SciTEBase::EndStackedTabbing() {
buffers.CommitStackSelection();
}
static void EscapeFilePathsForMenu(GUI::gui_string &path) {
// Escape '&' characters in path, since they are interpreted in
// menues.
Substitute(path, GUI_TEXT("&"), GUI_TEXT("&&"));
#if defined(GTK)
GUI::gui_string homeDirectory = getenv("HOME");
if (StartsWith(path, homeDirectory)) {
path.replace(static_cast<size_t>(0), homeDirectory.size(), GUI_TEXT("~"));
}
#endif
}
void SciTEBase::SetBuffersMenu() {
if (buffers.size <= 1) {
DestroyMenuItem(menuBuffers, IDM_BUFFERSEP);
}
RemoveAllTabs();
int pos;
for (pos = buffers.lengthVisible; pos < bufferMax; pos++) {
DestroyMenuItem(menuBuffers, IDM_BUFFER + pos);
}
if (buffers.size > 1) {
int menuStart = 4;
SetMenuItem(menuBuffers, menuStart, IDM_BUFFERSEP, GUI_TEXT(""));
for (pos = 0; pos < buffers.lengthVisible; pos++) {
int itemID = bufferCmdID + pos;
GUI::gui_string entry;
GUI::gui_string titleTab;
#if defined(_WIN32) || defined(GTK)
if (pos < 10) {
GUI::gui_string sPos = GUI::StringFromInteger((pos + 1) % 10);
GUI::gui_string sHotKey = GUI_TEXT("&") + sPos + GUI_TEXT(" ");
entry = sHotKey; // hotkey 1..0
#if defined(_WIN32)
titleTab = sHotKey; // add hotkey to the tabbar
#elif defined(GTK)
titleTab = sPos + GUI_TEXT(" ");
#endif
}
#endif
if (buffers.buffers[pos].IsUntitled()) {
GUI::gui_string untitled = localiser.Text("Untitled");
entry += untitled;
titleTab += untitled;
} else {
GUI::gui_string path = buffers.buffers[pos].AsInternal();
GUI::gui_string filename = buffers.buffers[pos].Name().AsInternal();
EscapeFilePathsForMenu(path);
#if defined(_WIN32)
// On Windows, '&' are also interpreted in tab names, so we need
// the escaped filename
EscapeFilePathsForMenu(filename);
#endif
entry += path;
titleTab += filename;
}
// For short file names:
//char *cpDirEnd = strrchr(buffers.buffers[pos]->fileName, pathSepChar);
//strcat(entry, cpDirEnd + 1);
if (buffers.buffers[pos].isDirty) {
entry += GUI_TEXT(" *");
titleTab += GUI_TEXT(" *");
}
SetMenuItem(menuBuffers, menuStart + pos + 1, itemID, entry.c_str());
TabInsert(pos, titleTab.c_str());
}
}
CheckMenus();
#if !defined(GTK)
if (tabVisible)
SizeSubWindows();
#endif
#if defined(GTK)
ShowTabBar();
#endif
}
void SciTEBase::BuffersMenu() {
UpdateBuffersCurrent();
SetBuffersMenu();
}
void SciTEBase::DeleteFileStackMenu() {
for (int stackPos = 0; stackPos < fileStackMax; stackPos++) {
DestroyMenuItem(menuFile, fileStackCmdID + stackPos);
}
DestroyMenuItem(menuFile, IDM_MRU_SEP);
}
void SciTEBase::SetFileStackMenu() {
if (recentFileStack[0].IsSet()) {
SetMenuItem(menuFile, MRU_START, IDM_MRU_SEP, GUI_TEXT(""));
for (int stackPos = 0; stackPos < fileStackMax; stackPos++) {
int itemID = fileStackCmdID + stackPos;
if (recentFileStack[stackPos].IsSet()) {
GUI::gui_string sEntry;
#if defined(_WIN32) || defined(GTK)
GUI::gui_string sPos = GUI::StringFromInteger((stackPos + 1) % 10);
GUI::gui_string sHotKey = GUI_TEXT("&") + sPos + GUI_TEXT(" ");
sEntry = sHotKey;
#endif
GUI::gui_string path = recentFileStack[stackPos].AsInternal();
EscapeFilePathsForMenu(path);
sEntry += path;
SetMenuItem(menuFile, MRU_START + stackPos + 1, itemID, sEntry.c_str());
}
}
}
}
bool SciTEBase::AddFileToBuffer(const BufferState &bufferState) {
// Return whether file loads successfully
bool opened = false;
if (bufferState.Exists()) {
opened = Open(bufferState, static_cast<OpenFlags>(ofForceLoad));
// If forced synchronous should set up position, foldState and bookmarks
if (opened) {
int iBuffer = buffers.GetDocumentByName(bufferState, false);
if (iBuffer >= 0) {
buffers.buffers[iBuffer].scrollPosition = bufferState.scrollPosition;
buffers.buffers[iBuffer].selection = bufferState.selection;
buffers.buffers[iBuffer].foldState = bufferState.foldState;
buffers.buffers[iBuffer].bookmarks = bufferState.bookmarks;
if (buffers.buffers[iBuffer].lifeState == Buffer::open) {
// File was opened synchronously
RestoreState(buffers.buffers[iBuffer], true);
DisplayAround(buffers.buffers[iBuffer]);
wEditor.Call(SCI_SCROLLCARET);
}
}
}
}
return opened;
}
void SciTEBase::AddFileToStack(FilePath file, SelectedRange selection, int scrollPos) {
if (!file.IsSet())
return;
DeleteFileStackMenu();
// Only stack non-empty names
if (file.IsSet() && !file.IsUntitled()) {
int stackPos;
int eqPos = fileStackMax - 1;
for (stackPos = 0; stackPos < fileStackMax; stackPos++)
if (recentFileStack[stackPos].SameNameAs(file))
eqPos = stackPos;
for (stackPos = eqPos; stackPos > 0; stackPos--)
recentFileStack[stackPos] = recentFileStack[stackPos - 1];
recentFileStack[0].Set(file);
recentFileStack[0].selection = selection;
recentFileStack[0].scrollPosition = scrollPos;
}
SetFileStackMenu();
}
void SciTEBase::RemoveFileFromStack(FilePath file) {
if (!file.IsSet())
return;
DeleteFileStackMenu();
int stackPos;
for (stackPos = 0; stackPos < fileStackMax; stackPos++) {
if (recentFileStack[stackPos].SameNameAs(file)) {
for (int movePos = stackPos; movePos < fileStackMax - 1; movePos++)
recentFileStack[movePos] = recentFileStack[movePos + 1];
recentFileStack[fileStackMax - 1].Init();
break;
}
}
SetFileStackMenu();
}
RecentFile SciTEBase::GetFilePosition() {
RecentFile rf;
rf.selection = GetSelectedRange();
rf.scrollPosition = GetCurrentScrollPosition();
return rf;
}
void SciTEBase::DisplayAround(const RecentFile &rf) {
if ((rf.selection.position != INVALID_POSITION) && (rf.selection.anchor != INVALID_POSITION)) {
SetSelection(rf.selection.anchor, rf.selection.position);
int curTop = wEditor.Call(SCI_GETFIRSTVISIBLELINE);
int lineTop = wEditor.Call(SCI_VISIBLEFROMDOCLINE, rf.scrollPosition);
wEditor.Call(SCI_LINESCROLL, 0, lineTop - curTop);
wEditor.Call(SCI_CHOOSECARETX, 0, 0);
}
}
// Next and Prev file comments.
// Decided that "Prev" file should mean the file you had opened last
// This means "Next" file means the file you opened longest ago.
void SciTEBase::StackMenuNext() {
DeleteFileStackMenu();
for (int stackPos = fileStackMax - 1; stackPos >= 0;stackPos--) {
if (recentFileStack[stackPos].IsSet()) {
SetFileStackMenu();
StackMenu(stackPos);
return;
}
}
SetFileStackMenu();
}
void SciTEBase::StackMenuPrev() {
if (recentFileStack[0].IsSet()) {
// May need to restore last entry if removed by StackMenu
RecentFile rfLast = recentFileStack[fileStackMax - 1];
StackMenu(0); // Swap current with top of stack
for (int checkPos = 0; checkPos < fileStackMax; checkPos++) {
if (rfLast.SameNameAs(recentFileStack[checkPos])) {
rfLast.Init();
}
}
// And rotate the MRU
RecentFile rfCurrent = recentFileStack[0];
// Move them up
for (int stackPos = 0; stackPos < fileStackMax - 1; stackPos++) {
recentFileStack[stackPos] = recentFileStack[stackPos + 1];
}
recentFileStack[fileStackMax - 1].Init();
// Copy current file into first empty
for (int emptyPos = 0; emptyPos < fileStackMax; emptyPos++) {
if (!recentFileStack[emptyPos].IsSet()) {
if (rfLast.IsSet()) {
recentFileStack[emptyPos] = rfLast;
rfLast.Init();
} else {
recentFileStack[emptyPos] = rfCurrent;
break;
}
}
}
DeleteFileStackMenu();
SetFileStackMenu();
}
}
void SciTEBase::StackMenu(int pos) {
if (CanMakeRoom(true)) {
if (pos >= 0) {
if ((pos == 0) && (!recentFileStack[pos].IsSet())) { // Empty
New();
SetWindowName();
ReadProperties();
SetIndentSettings();
SetEol();
} else if (recentFileStack[pos].IsSet()) {
RecentFile rf = recentFileStack[pos];
// Already asked user so don't allow Open to ask again.
Open(rf, ofNoSaveIfDirty);
CurrentBuffer()->scrollPosition = rf.scrollPosition;
CurrentBuffer()->selection = rf.selection;
DisplayAround(rf);
}
}
}
}
void SciTEBase::RemoveToolsMenu() {
for (int pos = 0; pos < toolMax; pos++) {
DestroyMenuItem(menuTools, IDM_TOOLS + pos);
}
}
void SciTEBase::SetMenuItemLocalised(int menuNumber, int position, int itemID,
const char *text, const char *mnemonic) {
GUI::gui_string localised = localiser.Text(text);
SetMenuItem(menuNumber, position, itemID, localised.c_str(), GUI::StringFromUTF8(mnemonic).c_str());
}
bool SciTEBase::ToolIsImmediate(int item) {
SString itemSuffix = item;
itemSuffix += '.';
SString propName = "command.";
propName += itemSuffix;
std::string command = props.GetWild(propName.c_str(), FileNameExt().AsUTF8().c_str());
if (command.length()) {
JobMode jobMode(props, item, FileNameExt().AsUTF8().c_str());
return jobMode.jobType == jobImmediate;
}
return false;
}
void SciTEBase::SetToolsMenu() {
//command.name.0.*.py=Edit in PythonWin
//command.0.*.py="c:\program files\python\pythonwin\pythonwin" /edit c:\coloreditor.py
RemoveToolsMenu();
int menuPos = TOOLS_START;
for (int item = 0; item < toolMax; item++) {
int itemID = IDM_TOOLS + item;
SString prefix = "command.name.";
prefix += SString(item);
prefix += ".";
SString commandName = props.GetNewExpand(prefix.c_str(), FileNameExt().AsUTF8().c_str());
if (commandName.length()) {
SString sMenuItem = commandName;
prefix = "command.shortcut.";
prefix += SString(item);
prefix += ".";
SString sMnemonic = props.GetNewExpand(prefix.c_str(), FileNameExt().AsUTF8().c_str());
if (item < 10 && sMnemonic.length() == 0) {
sMnemonic += "Ctrl+";
sMnemonic += SString(item);
}
SetMenuItemLocalised(menuTools, menuPos, itemID, sMenuItem.c_str(),
sMnemonic[0] ? sMnemonic.c_str() : NULL);
menuPos++;
}
}
DestroyMenuItem(menuTools, IDM_MACRO_SEP);
DestroyMenuItem(menuTools, IDM_MACROLIST);
DestroyMenuItem(menuTools, IDM_MACROPLAY);
DestroyMenuItem(menuTools, IDM_MACRORECORD);
DestroyMenuItem(menuTools, IDM_MACROSTOPRECORD);
menuPos++;
if (macrosEnabled) {
SetMenuItem(menuTools, menuPos++, IDM_MACRO_SEP, GUI_TEXT(""));
SetMenuItemLocalised(menuTools, menuPos++, IDM_MACROLIST,
"&List Macros...", "Shift+F9");
SetMenuItemLocalised(menuTools, menuPos++, IDM_MACROPLAY,
"Run Current &Macro", "F9");
SetMenuItemLocalised(menuTools, menuPos++, IDM_MACRORECORD,
"&Record Macro", "Ctrl+F9");
SetMenuItemLocalised(menuTools, menuPos, IDM_MACROSTOPRECORD,
"S&top Recording Macro", "Ctrl+Shift+F9");
}
}
JobSubsystem SciTEBase::SubsystemType(const char *cmd, int item) {
SString subsysprefix = cmd;
if (item >= 0) {
subsysprefix += SString(item);
subsysprefix += ".";
}
SString subsystem = props.GetNewExpand(subsysprefix.c_str(), FileNameExt().AsUTF8().c_str());
return SubsystemFromChar(subsystem[0]);
}
void SciTEBase::ToolsMenu(int item) {
SelectionIntoProperties();
const std::string itemSuffix = StdStringFromInteger(item) + ".";
const std::string propName = std::string("command.") + itemSuffix;
std::string command(props.GetWild(propName.c_str(), FileNameExt().AsUTF8().c_str()).c_str());
if (command.length()) {
JobMode jobMode(props, item, FileNameExt().AsUTF8().c_str());
if (jobQueue.IsExecuting() && (jobMode.jobType != jobImmediate))
// Busy running a tool and running a second can cause failures.
return;
if (jobMode.saveBefore == 2 || (jobMode.saveBefore == 1 && (!(CurrentBuffer()->isDirty) || Save())) || SaveIfUnsure() != saveCancelled) {
if (jobMode.isFilter)
CurrentBuffer()->fileModTime -= 1;
if (jobMode.jobType == jobImmediate) {
if (extender) {
extender->OnExecute(command.c_str());
}
} else {
AddCommand(command.c_str(), "", jobMode.jobType, jobMode.input, jobMode.flags);
if (jobQueue.HasCommandToRun())
Execute();
}
}
}
}
inline bool isdigitchar(int ch) {
return (ch >= '0') && (ch <= '9');
}
int DecodeMessage(const char *cdoc, std::string &sourcePath, int format, int &column) {
sourcePath.clear();
column = -1; // default to not detected
switch (format) {
case SCE_ERR_PYTHON: {
// Python
const char *startPath = strchr(cdoc, '\"');
if (startPath) {
startPath++;
const char *endPath = strchr(startPath, '\"');
if (endPath) {
ptrdiff_t length = endPath - startPath;
sourcePath.assign(startPath, length);
endPath++;
while (*endPath && !isdigitchar(*endPath)) {
endPath++;
}
int sourceNumber = atoi(endPath) - 1;
return sourceNumber;
}
}
break;
}
case SCE_ERR_GCC:
case SCE_ERR_GCC_INCLUDED_FROM: {
// GCC - look for number after colon to be line number
// This will be preceded by file name.
// Lua debug traceback messages also piggyback this style, but begin with a tab.
// GCC include paths are similar but start with either "In file included from " or
// " from "
if (format == SCE_ERR_GCC_INCLUDED_FROM) {
cdoc += strlen("In file included from ");
}
if (cdoc[0] == '\t')
++cdoc;
for (int i = 0; cdoc[i]; i++) {
if (cdoc[i] == ':' && isdigitchar(cdoc[i + 1])) {
int sourceNumber = atoi(cdoc + i + 1) - 1;
sourcePath.assign(cdoc, i);
i += 2;
while (isdigitchar(cdoc[i]))
++i;
if (cdoc[i] == ':' && isdigitchar(cdoc[i + 1]))
column = atoi(cdoc + i + 1) - 1;
return sourceNumber;
}
}
break;
}
case SCE_ERR_MS: {
// Visual *
const char *start = cdoc;
while (isspacechar(*start)) {
start++;
}
const char *endPath = strchr(start, '(');
if (endPath) {
ptrdiff_t length = endPath - start;
sourcePath.assign(start, length);
endPath++;
return atoi(endPath) - 1;
}
break;
}
case SCE_ERR_BORLAND: {
// Borland
const char *space = strchr(cdoc, ' ');
if (space) {
while (isspacechar(*space)) {
space++;
}
while (*space && !isspacechar(*space)) {
space++;
}
while (isspacechar(*space)) {
space++;
}
const char *space2 = NULL;
if (strlen(space) > 2) {
space2 = strchr(space + 2, ':');
}
if (space2) {
while (!isspacechar(*space2)) {
space2--;
}
while (isspacechar(*(space2 - 1))) {
space2--;
}
ptrdiff_t length = space2 - space;
if (length > 0) {
sourcePath.assign(space, length);
return atoi(space2) - 1;
}
}
}
break;
}
case SCE_ERR_PERL: {
// perl
const char *at = strstr(cdoc, " at ");
const char *line = strstr(cdoc, " line ");
ptrdiff_t length = line - (at + 4);
if (at && line && length > 0) {
sourcePath.assign(at + 4, length);
line += 6;
return atoi(line) - 1;
}
break;
}
case SCE_ERR_NET: {
// .NET traceback
const char *in = strstr(cdoc, " in ");
const char *line = strstr(cdoc, ":line ");
if (in && line && (line > in)) {
in += 4;
sourcePath.assign(in, line - in);
line += 6;
return atoi(line) - 1;
}
break;
}
case SCE_ERR_LUA: {
// Lua 4 error looks like: last token read: `result' at line 40 in file `Test.lua'
const char *idLine = "at line ";
const char *idFile = "file ";
size_t lenLine = strlen(idLine);
size_t lenFile = strlen(idFile);
const char *line = strstr(cdoc, idLine);
const char *file = strstr(cdoc, idFile);
if (line && file) {
const char *fileStart = file + lenFile + 1;
const char *quote = strstr(fileStart, "'");
size_t length = quote - fileStart;
if (quote && length > 0) {
sourcePath.assign(fileStart, length);
}
line += lenLine;
return atoi(line) - 1;
} else {
// Lua 5.1 error looks like: lua.exe: test1.lua:3: syntax error
// reuse the GCC error parsing code above!
const char* colon = strstr(cdoc, ": ");
if (colon)
return DecodeMessage(colon + 2, sourcePath, SCE_ERR_GCC, column);
}
break;
}
case SCE_ERR_CTAG: {
for (int i = 0; cdoc[i]; i++) {
if ((isdigitchar(cdoc[i + 1]) || (cdoc[i + 1] == '/' && cdoc[i + 2] == '^')) && cdoc[i] == '\t') {
int j = i - 1;
while (j > 0 && ! strchr("\t\n\r \"$%'*,;<>?[]^`{|}", cdoc[j])) {
j--;
}
if (strchr("\t\n\r \"$%'*,;<>?[]^`{|}", cdoc[j])) {
j++;
}
sourcePath.assign(&cdoc[j], i - j);
// Because usually the address is a searchPattern, lineNumber has to be evaluated later
return 0;
}
}
break;
}
case SCE_ERR_PHP: {
// PHP error look like: Fatal error: Call to undefined function: foo() in example.php on line 11
const char *idLine = " on line ";
const char *idFile = " in ";
size_t lenLine = strlen(idLine);
size_t lenFile = strlen(idFile);
const char *line = strstr(cdoc, idLine);
const char *file = strstr(cdoc, idFile);
if (line && file && (line > file)) {
file += lenFile;
size_t length = line - file;
sourcePath.assign(file, length);
line += lenLine;
return atoi(line) - 1;
}
break;
}
case SCE_ERR_ELF: {
// Essential Lahey Fortran error look like: Line 11, file c:\fortran90\codigo\demo.f90
const char *line = strchr(cdoc, ' ');
if (line) {
while (isspacechar(*line)) {
line++;
}
const char *file = strchr(line, ' ');
if (file) {
while (isspacechar(*file)) {
file++;
}
while (*file && !isspacechar(*file)) {
file++;
}
size_t length = strlen(file);
sourcePath.assign(file, length);
return atoi(line) - 1;
}
}
break;
}
case SCE_ERR_IFC: {
/* Intel Fortran Compiler error/warnings look like:
* Error 71 at (17:teste.f90) : The program unit has no name
* Warning 4 at (9:modteste.f90) : Tab characters are an extension to standard Fortran 95
*
* Depending on the option, the error/warning messages can also appear on the form:
* modteste.f90(9): Warning 4 : Tab characters are an extension to standard Fortran 95
*
* These are trapped by the MS handler, and are identified OK, so no problem...
*/
const char *line = strchr(cdoc, '(');
if (line) {
const char *file = strchr(line, ':');
if (file) {
file++;
const char *endfile = strchr(file, ')');
size_t length = endfile - file;
sourcePath.assign(file, length);
line++;
return atoi(line) - 1;
}
}
break;
}
case SCE_ERR_ABSF: {
// Absoft Pro Fortran 90/95 v8.x, v9.x errors look like: cf90-113 f90fe: ERROR SHF3D, File = shf.f90, Line = 1101, Column = 19
const char *idFile = " File = ";
const char *idLine = ", Line = ";
size_t lenFile = strlen(idFile);
size_t lenLine = strlen(idLine);
const char *file = strstr(cdoc, idFile);
const char *line = strstr(cdoc, idLine);
//const char *idColumn = ", Column = ";
//const char *column = strstr(cdoc, idColumn);
if (line && file && (line > file)) {
file += lenFile;
size_t length = line - file;
sourcePath.assign(file, length);
line += lenLine;
return atoi(line) - 1;
}
break;
}
case SCE_ERR_IFORT: {
/* Intel Fortran Compiler v8.x error/warnings look like:
* fortcom: Error: shf.f90, line 5602: This name does not have ...
*/
const char *idFile = ": Error: ";
const char *idLine = ", line ";
size_t lenFile = strlen(idFile);
size_t lenLine = strlen(idLine);
const char *file = strstr(cdoc, idFile);
const char *line = strstr(cdoc, idLine);
const char *lineend = strrchr(cdoc, ':');
if (line && file && (line > file)) {
file += lenFile;
size_t length = line - file;
sourcePath.assign(file, length);
line += lenLine;
if ((lineend > line)) {
return atoi(line) - 1;
}
}
break;
}
case SCE_ERR_TIDY: {
/* HTML Tidy error/warnings look like:
* line 8 column 1 - Error: unexpected </head> in <meta>
* line 41 column 1 - Warning: <table> lacks "summary" attribute
*/
const char *line = strchr(cdoc, ' ');
if (line) {
const char *col = strchr(line + 1, ' ');
if (col) {
//*col = '\0';
int lnr = atoi(line) - 1;
col = strchr(col + 1, ' ');
if (col) {
const char *endcol = strchr(col + 1, ' ');
if (endcol) {
//*endcol = '\0';
column = atoi(col) - 1;
return lnr;
}
}
}
}
break;
}
case SCE_ERR_JAVA_STACK: {
/* Java runtime stack trace
\tat <methodname>(<filename>:<line>)
*/
const char *startPath = strrchr(cdoc, '(') + 1;
const char *endPath = strchr(startPath, ':');
ptrdiff_t length = endPath - startPath;
if (length > 0) {
sourcePath.assign(startPath, length);
int sourceNumber = atoi(endPath + 1) - 1;
return sourceNumber;
}
break;
}
case SCE_ERR_DIFF_MESSAGE: {
// Diff file header, either +++ <filename> or --- <filename>, may be followed by \t
// Often followed by a position line @@ <linenumber>
const char *startPath = cdoc + 4;
const char *endPath = strpbrk(startPath, "\t\r\n");
if (endPath) {
ptrdiff_t length = endPath - startPath;
sourcePath.assign(startPath, length);
return 0;
}
break;
}
} // switch
return -1;
}
// Remove up to and including ch
static void Chomp(SString &s, int ch) {
if (s.contains(static_cast<char>(ch)))
s.remove(0, s.search(":") + 1);
}
void SciTEBase::ShowMessages(int line) {
wEditor.Call(SCI_ANNOTATIONSETSTYLEOFFSET, diagnosticStyleStart);
wEditor.Call(SCI_ANNOTATIONSETVISIBLE, ANNOTATION_BOXED);
wEditor.Call(SCI_ANNOTATIONCLEARALL);
TextReader acc(wOutput);
while ((line > 0) && (acc.StyleAt(acc.LineStart(line-1)) != SCE_ERR_CMD))
line--;
int maxLine = wOutput.Call(SCI_GETLINECOUNT);
while ((line < maxLine) && (acc.StyleAt(acc.LineStart(line)) != SCE_ERR_CMD)) {
int startPosLine = wOutput.Call(SCI_POSITIONFROMLINE, line, 0);
int lineEnd = wOutput.Call(SCI_GETLINEENDPOSITION, line, 0);
SString message = GetRange(wOutput, startPosLine, lineEnd);
std::string source;
int column;
char style = acc.StyleAt(startPosLine);
int sourceLine = DecodeMessage(message.c_str(), source, style, column);
Chomp(message, ':');
if (style == SCE_ERR_GCC) {
Chomp(message, ':');
}
GUI::gui_string sourceString = GUI::StringFromUTF8(source.c_str());
FilePath sourcePath = FilePath(sourceString).NormalizePath();
if (filePath.Name().SameNameAs(sourcePath.Name())) {
if (style == SCE_ERR_GCC) {
const char *sColon = strchr(message.c_str(), ':');
if (sColon) {
SString editLine = GetLine(wEditor, sourceLine);
if (editLine == (sColon+1)) {
line++;
continue;
}
}
}
int lenCurrent = wEditor.CallString(SCI_ANNOTATIONGETTEXT, sourceLine, NULL);
std::string msgCurrent(lenCurrent, '\0');
std::string stylesCurrent(lenCurrent, '\0');
if (lenCurrent) {
wEditor.CallString(SCI_ANNOTATIONGETTEXT, sourceLine, &msgCurrent[0]);
wEditor.CallString(SCI_ANNOTATIONGETSTYLES, sourceLine, &stylesCurrent[0]);
msgCurrent += "\n";
stylesCurrent += '\0';
}
if (msgCurrent.find(message.c_str()) == std::string::npos) {
// Only append unique messages
msgCurrent += message.c_str();
int msgStyle = 0;
if (message.search("warning") >= 0)
msgStyle = 1;
if (message.search("error") >= 0)
msgStyle = 2;
if (message.search("fatal") >= 0)
msgStyle = 3;
stylesCurrent += std::string(message.length(), static_cast<char>(msgStyle));
wEditor.CallString(SCI_ANNOTATIONSETTEXT, sourceLine, msgCurrent.c_str());
wEditor.CallString(SCI_ANNOTATIONSETSTYLES, sourceLine, stylesCurrent.c_str());
}
}
line++;
}
}
void SciTEBase::GoMessage(int dir) {
Sci_CharacterRange crange;
crange.cpMin = wOutput.Call(SCI_GETSELECTIONSTART);
crange.cpMax = wOutput.Call(SCI_GETSELECTIONEND);
long selStart = crange.cpMin;
int curLine = wOutput.Call(SCI_LINEFROMPOSITION, selStart);
int maxLine = wOutput.Call(SCI_GETLINECOUNT);
int lookLine = curLine + dir;
if (lookLine < 0)
lookLine = maxLine - 1;
else if (lookLine >= maxLine)
lookLine = 0;
TextReader acc(wOutput);
while ((dir == 0) || (lookLine != curLine)) {
int startPosLine = wOutput.Call(SCI_POSITIONFROMLINE, lookLine, 0);
int lineLength = wOutput.Call(SCI_LINELENGTH, lookLine, 0);
char style = acc.StyleAt(startPosLine);
if (style != SCE_ERR_DEFAULT &&
style != SCE_ERR_CMD &&
style != SCE_ERR_DIFF_ADDITION &&
style != SCE_ERR_DIFF_CHANGED &&
style != SCE_ERR_DIFF_DELETION) {
wOutput.Call(SCI_MARKERDELETEALL, static_cast<uptr_t>(-1));
wOutput.Call(SCI_MARKERDEFINE, 0, SC_MARK_SMALLRECT);
wOutput.Call(SCI_MARKERSETFORE, 0, ColourOfProperty(props,
"error.marker.fore", ColourRGB(0x7f, 0, 0)));
wOutput.Call(SCI_MARKERSETBACK, 0, ColourOfProperty(props,
"error.marker.back", ColourRGB(0xff, 0xff, 0)));
wOutput.Call(SCI_MARKERADD, lookLine, 0);
wOutput.Call(SCI_SETSEL, startPosLine, startPosLine);
SString message = GetRange(wOutput, startPosLine, startPosLine + lineLength);
std::string source;
int column;
long sourceLine = DecodeMessage(message.c_str(), source, style, column);
if (sourceLine >= 0) {
GUI::gui_string sourceString = GUI::StringFromUTF8(source.c_str());
FilePath sourcePath = FilePath(sourceString).NormalizePath();
if (!filePath.Name().SameNameAs(sourcePath)) {
FilePath messagePath;
bool bExists = false;
if (Exists(dirNameAtExecute.AsInternal(), sourceString.c_str(), &messagePath)) {
bExists = true;
} else if (Exists(dirNameForExecute.AsInternal(), sourceString.c_str(), &messagePath)) {
bExists = true;
} else if (Exists(filePath.Directory().AsInternal(), sourceString.c_str(), &messagePath)) {
bExists = true;
} else if (Exists(NULL, sourceString.c_str(), &messagePath)) {
bExists = true;
} else {
// Look through buffers for name match
for (int i = buffers.lengthVisible - 1; i >= 0; i--) {
if (sourcePath.Name().SameNameAs(buffers.buffers[i].Name())) {
messagePath = buffers.buffers[i];
bExists = true;
}
}
}
if (bExists) {
if (!Open(messagePath, ofSynchronous)) {
return;
}
CheckReload();
}
}
// If ctag then get line number after search tag or use ctag line number
if (style == SCE_ERR_CTAG) {
//without following focus GetCTag wouldn't work correct
WindowSetFocus(wOutput);
SString cTag = GetCTag();
if (cTag.length() != 0) {
if (cTag.value() > 0) {
//if tag is linenumber, get line
sourceLine = cTag.value() - 1;
} else {
findWhat = cTag.string();
FindNext(false);
//get linenumber for marker from found position
sourceLine = wEditor.Call(SCI_LINEFROMPOSITION, wEditor.Call(SCI_GETCURRENTPOS));
}
}
}
else if (style == SCE_ERR_DIFF_MESSAGE) {
bool isAdd = message.startswith("+++ ");
int atLine = lookLine + (isAdd ? 1 : 2); // lines are in this order: ---, +++, @@
SString atMessage = GetLine(wOutput, atLine);
if (atMessage.startswith("@@ -")) {
int atPos = (isAdd
? atMessage.search(" +", 7) + 2 // skip "@@ -1,1" and then " +"
: 4 // deleted position starts right after "@@ -"
);
sourceLine = atol(atMessage.c_str() + atPos) - 1;
}
}
if (props.GetInt("error.inline")) {
ShowMessages(lookLine);
}
wEditor.Call(SCI_MARKERDELETEALL, 0);
wEditor.Call(SCI_MARKERDEFINE, 0, SC_MARK_CIRCLE);
wEditor.Call(SCI_MARKERSETFORE, 0, ColourOfProperty(props,
"error.marker.fore", ColourRGB(0x7f, 0, 0)));
wEditor.Call(SCI_MARKERSETBACK, 0, ColourOfProperty(props,
"error.marker.back", ColourRGB(0xff, 0xff, 0)));
wEditor.Call(SCI_MARKERADD, sourceLine, 0);
int startSourceLine = wEditor.Call(SCI_POSITIONFROMLINE, sourceLine, 0);
int endSourceline = wEditor.Call(SCI_POSITIONFROMLINE, sourceLine + 1, 0);
if (column >= 0) {
// Get the position in line according to current tab setting
startSourceLine = wEditor.Call(SCI_FINDCOLUMN, sourceLine, column);
}
EnsureRangeVisible(wEditor, startSourceLine, startSourceLine);
if (props.GetInt("error.select.line") == 1) {
//select whole source source line from column with error
SetSelection(endSourceline, startSourceLine);
} else {
//simply move cursor to line, don't do any selection
SetSelection(startSourceLine, startSourceLine);
}
message.substitute('\t', ' ');
message.remove("\n");
props.Set("CurrentMessage", message.c_str());
UpdateStatusBar(false);
WindowSetFocus(wEditor);
}
return;
}
lookLine += dir;
if (lookLine < 0)
lookLine = maxLine - 1;
else if (lookLine >= maxLine)
lookLine = 0;
if (dir == 0)
return;
}
}
| 28.833824 | 139 | 0.65905 | jjzhang166 |
0fa239301ec7da51a75d301c5cdfde811ebb3c10 | 8,448 | cc | C++ | src/ts/tsc.cc | Abhisheknishant/Flint | 441beab56d21e4069b858ae6588fa0fa3084d722 | [
"MIT"
] | 9 | 2015-09-07T05:33:50.000Z | 2022-01-07T03:35:08.000Z | src/ts/tsc.cc | Abhisheknishant/Flint | 441beab56d21e4069b858ae6588fa0fa3084d722 | [
"MIT"
] | 27 | 2018-03-19T02:10:06.000Z | 2021-12-09T08:20:51.000Z | src/ts/tsc.cc | Abhisheknishant/Flint | 441beab56d21e4069b858ae6588fa0fa3084d722 | [
"MIT"
] | 6 | 2019-03-26T00:32:03.000Z | 2021-03-11T23:21:42.000Z | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- vim:set ts=4 sw=4 sts=4 noet: */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "ts.h"
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <memory>
#include <set>
#include <sstream>
#include <string>
#include <unordered_map>
#define BOOST_FILESYSTEM_NO_DEPRECATED
#include <boost/filesystem.hpp>
#include <boost/filesystem/fstream.hpp>
#include <boost/functional/hash.hpp>
#include <boost/uuid/uuid.hpp>
#include <boost/uuid/uuid_io.hpp>
#include "csv/export.h"
#include "db/driver.h"
#include "db/eq-inserter.h"
#include "db/query.h"
#include "db/timeseries-loader.h"
#include "db/tsref-loader.h"
#include "db/variable-loader.h"
#include "flint/utf8path.h"
#include "flint/variable.h"
#include "isdf/reader.h"
namespace flint {
namespace ts {
namespace {
typedef std::unordered_map<boost::uuids::uuid,
std::unordered_map<int, std::string>,
boost::hash<boost::uuids::uuid> > PqMap;
class PqHandler {
public:
PqHandler(const PqHandler &) = delete;
PqHandler &operator=(const PqHandler &) = delete;
explicit PqHandler(PqMap *map) : map_(map) {
assert(map);
}
bool Handle(const boost::uuids::uuid &uuid, std::unique_ptr<Variable> &&var) {
if (var->type() != 't') return true; // skip other types
(*map_)[uuid].emplace(var->id(), var->name());
return true;
}
private:
PqMap *map_;
};
typedef std::set<boost::filesystem::path> PathSet;
typedef std::unordered_map<boost::uuids::uuid,
std::unordered_map<int, PathSet::iterator>,
boost::hash<boost::uuids::uuid> > TimeseriesMap;
class TimeseriesHandler {
public:
TimeseriesHandler(const TimeseriesHandler &) = delete;
TimeseriesHandler &operator=(const TimeseriesHandler &) = delete;
TimeseriesHandler(PathSet *ps, TimeseriesMap *tm)
: ps_(ps),
tm_(tm)
{}
bool Handle(const boost::uuids::uuid &uuid, int ts_id, const char *format, const char *ref) {
boost::filesystem::path ref_path(GetPathFromUtf8(ref));
if (ref_path.empty())
return false;
if (std::strcmp(format, "csv") == 0) {
boost::system::error_code ec;
boost::filesystem::path temp_path("tsc.%%%%-%%%%-%%%%-%%%%.isd");
boost::filesystem::path isd_path = boost::filesystem::unique_path(temp_path, ec);
if (ec) {
std::cerr << ec << std::endl;
return false;
}
if (boost::filesystem::exists(isd_path, ec)) {
std::cerr << "failed to create temporary path: " << isd_path << std::endl;
return false;
}
boost::filesystem::path a_path = boost::filesystem::absolute(isd_path);
if (!ExportIsdFromCsv(ref_path, a_path)) return false;
PathSet::iterator it = ps_->insert(a_path).first;
(*tm_)[uuid].emplace(ts_id, it);
return true;
}
if (std::strcmp(format, "isd") != 0) {
std::cerr << "unknown format: " << format << std::endl;
return false;
}
PathSet::iterator it = ps_->insert(ref_path).first;
(*tm_)[uuid].emplace(ts_id, it);
return true;
}
private:
PathSet *ps_;
TimeseriesMap *tm_;
};
class TsfilesInserter : db::StatementDriver {
public:
explicit TsfilesInserter(sqlite3 *db)
: db::StatementDriver(db, "INSERT INTO tsfiles VALUES (?)")
{}
bool Insert(const boost::filesystem::path &path)
{
std::unique_ptr<char[]> filename(GetUtf8FromPath(path));
if (!filename)
return false;
int e;
e = sqlite3_bind_text(stmt(), 1, filename.get(), -1, nullptr);
if (e != SQLITE_OK) {
std::cerr << "failed to bind filename: " << e << std::endl;
return false;
}
e = sqlite3_step(stmt());
if (e != SQLITE_DONE) {
std::cerr << "failed to step: " << e << std::endl;
return false;
}
sqlite3_reset(stmt());
return true;
}
};
typedef std::unordered_map<std::string, std::uint32_t> ColumnMap;
class DescriptionHandler {
public:
DescriptionHandler(const DescriptionHandler &) = delete;
DescriptionHandler &operator=(const DescriptionHandler &) = delete;
explicit DescriptionHandler(ColumnMap *cm) : cm_(cm) {}
void GetDescription(std::uint32_t i, std::uint32_t bytes, const char *d) {
if (!cm_->emplace(std::string(d, bytes), i).second) {
std::cerr << "found duplicate name of columns: " << std::endl;
}
}
private:
ColumnMap *cm_;
};
class IsdfLoader {
public:
IsdfLoader(const IsdfLoader &) = delete;
IsdfLoader &operator=(const IsdfLoader &) = delete;
explicit IsdfLoader(const boost::filesystem::path &path)
: path_(path)
, ifs_(path, std::ios::in|std::ios::binary)
{}
~IsdfLoader() {
if (ifs_.is_open()) ifs_.close();
}
bool Load(ColumnMap *cm) {
if (!ifs_.is_open()) {
std::cerr << "failed to open ISDF file: "
<< path_
<< std::endl;
return false;
}
isdf::Reader reader;
if (!reader.ReadHeader(&ifs_)) return false;
if (!reader.SkipComment(&ifs_)) return false;
DescriptionHandler handler(cm);
return reader.ReadDescriptions(handler, &ifs_);
}
private:
boost::filesystem::path path_;
boost::filesystem::ifstream ifs_;
};
typedef std::unordered_map<boost::filesystem::path, std::unique_ptr<ColumnMap>,
boost::hash<boost::filesystem::path> > IsdfMap;
class TsrefHandler : db::EqInserter {
public:
TsrefHandler(sqlite3 *db, PqMap *pqm, PathSet *ps, TimeseriesMap *tm, IsdfMap *im)
: db::EqInserter("tscs", db)
, pqm_(pqm)
, ps_(ps)
, tm_(tm)
, im_(im)
{}
bool Handle(const boost::uuids::uuid &uuid, int pq_id, int ts_id, const char *element_id) {
TimeseriesMap::const_iterator it = tm_->find(uuid);
if (it == tm_->end()) {
std::cerr << "missing module-id in timeseries: " << uuid << std::endl;
return false;
}
std::unordered_map<int, PathSet::iterator>::const_iterator mit = it->second.find(ts_id);
if (mit == it->second.end()) {
std::cerr << "missing timeseries: "
<< uuid
<< " "
<< ts_id
<< std::endl;
return false;
}
PqMap::const_iterator pit = pqm_->find(uuid);
if (pit == pqm_->end()) {
std::cerr << "missing module-id in physical-quantities: "
<< uuid
<< std::endl;
return false;
}
std::unordered_map<int, std::string>::const_iterator qit = pit->second.find(pq_id);
if (qit == pit->second.end()) {
std::cerr << "missing physical-quantity-id: "
<< uuid
<< " "
<< pq_id
<< std::endl;
return false;
}
IsdfMap::const_iterator iit = im_->find(*mit->second);
if (iit == im_->end()) {
std::cerr << "missing path: " << *mit->second << std::endl;
return false;
}
std::string name(element_id);
ColumnMap::const_iterator cit = iit->second->find(name);
if (cit == iit->second->end()) {
std::cerr << "missing element in "
<< *mit->second
<< " with element_id "
<< element_id
<< std::endl;
return false;
}
int idx0 = static_cast<int>(std::distance(ps_->begin(), mit->second));
int idx1 = static_cast<int>(cit->second);
std::ostringstream oss;
oss << "(eq %"
<< qit->second.c_str()
<< " ($At "
<< idx0
<< " "
<< idx1
<< " %time))";
std::string math = oss.str();
return Insert(uuid, math.c_str());
}
private:
PqMap *pqm_;
PathSet *ps_;
TimeseriesMap *tm_;
IsdfMap *im_;
};
}
bool Tsc(sqlite3 *db)
{
std::unique_ptr<PqMap> pqm(new PqMap);
{
std::unique_ptr<db::VariableLoader> loader(new db::VariableLoader(db));
std::unique_ptr<PqHandler> handler(new PqHandler(pqm.get()));
if (!loader->Load(handler.get())) return false;
}
std::unique_ptr<PathSet> ps(new PathSet);
std::unique_ptr<TimeseriesMap> tm(new TimeseriesMap);
{
std::unique_ptr<db::TimeseriesLoader> loader(new db::TimeseriesLoader(db));
std::unique_ptr<TimeseriesHandler> handler(new TimeseriesHandler(ps.get(), tm.get()));
if (!loader->Load(handler.get())) return false;
}
if (!BeginTransaction(db))
return false;
std::unique_ptr<IsdfMap> im(new IsdfMap);
{
TsfilesInserter ti(db);
for (PathSet::const_iterator it=ps->begin();it!=ps->end();++it) {
boost::filesystem::path p = *it;
if (!ti.Insert(p)) return false;
std::unique_ptr<ColumnMap> cm(new ColumnMap);
IsdfLoader loader(p);
if (!loader.Load(cm.get()))
return false;
im->emplace(p, std::move(cm));
}
}
{
std::unique_ptr<db::TsrefLoader> loader(new db::TsrefLoader(db));
std::unique_ptr<TsrefHandler> handler(new TsrefHandler(db, pqm.get(), ps.get(), tm.get(), im.get()));
if (!loader->Load(handler.get())) {
return false;
}
}
return CommitTransaction(db);
}
}
}
| 26.236025 | 107 | 0.653527 | Abhisheknishant |
0fa2f3381fa2fce2d606117c7886e9156e9a79f2 | 2,377 | hpp | C++ | include/oglplus/imports/blend_file/reader.hpp | matus-chochlik/oglplus | 76dd964e590967ff13ddff8945e9dcf355e0c952 | [
"BSL-1.0"
] | 364 | 2015-01-01T09:38:23.000Z | 2022-03-22T05:32:00.000Z | include/oglplus/imports/blend_file/reader.hpp | matus-chochlik/oglplus | 76dd964e590967ff13ddff8945e9dcf355e0c952 | [
"BSL-1.0"
] | 55 | 2015-01-06T16:42:55.000Z | 2020-07-09T04:21:41.000Z | include/oglplus/imports/blend_file/reader.hpp | matus-chochlik/oglplus | 76dd964e590967ff13ddff8945e9dcf355e0c952 | [
"BSL-1.0"
] | 57 | 2015-01-07T18:35:49.000Z | 2022-03-22T05:32:04.000Z | /**
* @file oglplus/imports/blend_file/reader.hpp
* @brief Helper class for .blend file import basic input operations
*
* @author Matus Chochlik
*
* Copyright 2010-2019 Matus Chochlik. 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)
*/
#pragma once
#ifndef OGLPLUS_IMPORTS_BLEND_FILE_READER_1107121519_HPP
#define OGLPLUS_IMPORTS_BLEND_FILE_READER_1107121519_HPP
#include "utils.hpp"
#include <oglplus/config/compiler.hpp>
#include <cassert>
#include <cstddef>
#include <istream>
#include <sstream>
#include <stdexcept>
#include <string>
#include <vector>
namespace oglplus {
namespace imports {
// Internal helper class used for .blend file read operations
// Wraps around an istream and implements operations used by
// the loader
// NOTE: implementation detail, do not use
class BlendFileReader : public BlendFileUtils {
private:
std::istream& _input;
// peek at the next byte and return true if we are at EOF
bool _eof();
// composes error message and throws an exception
OGLPLUS_NORETURN
void _error(const std::string& message);
// reads a single char throws on error
char _read_char(const char* error_message);
// reads the specified number of bytes throws on error
void _raw_read(char* buffer, std::size_t size, const char* error_message);
// reads a string of the specified lenght,
// terminates by zero
// throws on error
void _read(char* buffer, std::size_t max, const char* error_message);
// reads until a delimiter is found,
// throws on error
void _read_until(
std::streambuf& sb, char delimiter, const char* error_message);
// skips the specified number of bytes
// throws on error
void _skip(std::size_t size, const char* error_message);
// aligns the input to the specified size
// throws on error
void _align(const std::size_t size, const char* error_message);
friend class BlendFileReaderClient;
public:
BlendFileReader(std::istream& input)
: BlendFileUtils(4)
, _input(input) {
}
};
} // namespace imports
} // namespace oglplus
#if !OGLPLUS_LINK_LIBRARY || defined(OGLPLUS_IMPLEMENTING_LIBRARY)
#include <oglplus/imports/blend_file/reader.ipp>
#endif // OGLPLUS_LINK_LIBRARY
#endif // include guard
| 27.964706 | 78 | 0.724443 | matus-chochlik |
0fa32d9a0255f1d3c77b1b80051dbba7fc52a758 | 2,145 | cpp | C++ | gmath/Matrix4x4.cpp | HoRangDev/gmath | 04503a4eec019dac591bf7f8889fb468bcb0a0ba | [
"MIT"
] | null | null | null | gmath/Matrix4x4.cpp | HoRangDev/gmath | 04503a4eec019dac591bf7f8889fb468bcb0a0ba | [
"MIT"
] | null | null | null | gmath/Matrix4x4.cpp | HoRangDev/gmath | 04503a4eec019dac591bf7f8889fb468bcb0a0ba | [
"MIT"
] | null | null | null | #include "Matrix4x4.h"
namespace gmath
{
Matrix4x4::Matrix4x4(
float _m11 /* = 1.0f */, float _m12 /* = 0.0f */, float _m13 /* = 0.0f */, float _m14 /* = 0.0f */,
float _m21 /* = 0.0f */, float _m22 /* = 1.0f */, float _m23 /* = 0.0f */, float _m24 /* = 0.0f */,
float _m31 /* = 0.0f */, float _m32 /* = 0.0f */, float _m33 /* = 1.0f */, float _m34 /* = 0.0f */,
float _m41 /* = 0.0f */, float _m42 /* = 0.0f */, float _m43 /* = 0.0f */, float _m44 /* = 1.0f */) :
m11(_m11), m12(_m12), m13(_m13), m14(_m14),
m21(_m21), m22(_m22), m23(_m23), m24(_m24),
m31(_m31), m32(_m32), m33(_m33), m34(_m34),
m41(_m41), m42(_m42), m43(_m43), m44(_m44)
{
}
Matrix4x4::Matrix4x4(float _elements[16]) :
Matrix4x4(
_elements[0], _elements[1], _elements[2], _elements[3],
_elements[4], _elements[5], _elements[6], _elements[7],
_elements[8], _elements[9], _elements[10], _elements[11],
_elements[12], _elements[13], _elements[14], _elements[15])
{
}
Matrix4x4 Matrix4x4::operator*(const Matrix4x4& rhs) const
{
// dot(lhs.row, rhs.col)
return Matrix4x4(
m11 * rhs.m11 + m12 * rhs.m21 + m13 * rhs.m31 + m14 * rhs.m41,
m11 * rhs.m12 + m12 * rhs.m22 + m13 * rhs.m32 + m14 * rhs.m42,
m11 * rhs.m13 + m12 * rhs.m23 + m13 * rhs.m33 + m14 * rhs.m43,
m11 * rhs.m14 + m12 * rhs.m24 + m13 * rhs.m34 + m14 * rhs.m44,
m21 * rhs.m11 + m22 * rhs.m21 + m23 * rhs.m31 + m24 * rhs.m41,
m21 * rhs.m12 + m22 * rhs.m22 + m23 * rhs.m32 + m24 * rhs.m42,
m21 * rhs.m13 + m22 * rhs.m23 + m23 * rhs.m33 + m24 * rhs.m43,
m21 * rhs.m14 + m22 * rhs.m24 + m23 * rhs.m34 + m24 * rhs.m44,
m31 * rhs.m11 + m32 * rhs.m21 + m33 * rhs.m31 + m34 * rhs.m41,
m31 * rhs.m12 + m32 * rhs.m22 + m33 * rhs.m32 + m34 * rhs.m42,
m31 * rhs.m13 + m32 * rhs.m23 + m33 * rhs.m33 + m34 * rhs.m43,
m31 * rhs.m14 + m32 * rhs.m24 + m33 * rhs.m34 + m34 * rhs.m44,
m41* rhs.m11 + m42 * rhs.m21 + m43 * rhs.m31 + m44 * rhs.m41,
m41* rhs.m12 + m42 * rhs.m22 + m43 * rhs.m32 + m44 * rhs.m42,
m41* rhs.m13 + m42 * rhs.m23 + m43 * rhs.m33 + m44 * rhs.m43,
m41* rhs.m14 + m42 * rhs.m24 + m43 * rhs.m34 + m44 * rhs.m44);
}
} | 40.471698 | 103 | 0.5669 | HoRangDev |
0fa4a12e511a30a4ffcce86ee894d6b56272fc1c | 3,017 | cpp | C++ | src/coreclr/src/pal/tests/palsuite/threading/WaitForSingleObject/test1/test1.cpp | swaroop-sridhar/runtime | d0efddd932f6fb94c3e9436ab393fc390c7b2da9 | [
"MIT"
] | 52 | 2017-03-15T08:16:52.000Z | 2019-04-26T07:53:29.000Z | src/coreclr/src/pal/tests/palsuite/threading/WaitForSingleObject/test1/test1.cpp | swaroop-sridhar/runtime | d0efddd932f6fb94c3e9436ab393fc390c7b2da9 | [
"MIT"
] | 2 | 2020-03-25T06:25:42.000Z | 2022-02-25T21:30:33.000Z | src/coreclr/src/pal/tests/palsuite/threading/WaitForSingleObject/test1/test1.cpp | swaroop-sridhar/runtime | d0efddd932f6fb94c3e9436ab393fc390c7b2da9 | [
"MIT"
] | 14 | 2019-05-09T13:15:41.000Z | 2021-11-16T02:54:09.000Z | // Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
/*============================================================
**
** Source: test1.c
**
** Purpose: Test for WaitForSingleObjectTest. Create two events, one
** with a TRUE and one with FALSE intial state. Ensure that WaitForSingle
** returns correct values for each of these.
**
**
**=========================================================*/
#include <palsuite.h>
BOOL WaitForSingleObjectTest()
{
BOOL bRet = FALSE;
DWORD dwRet = 0;
LPSECURITY_ATTRIBUTES lpEventAttributes = 0;
BOOL bManualReset = TRUE;
BOOL bInitialState = TRUE;
HANDLE hEvent;
/* Create an event, and ensure the HANDLE is valid */
hEvent = CreateEvent(lpEventAttributes, bManualReset,
bInitialState, NULL);
if (hEvent != INVALID_HANDLE_VALUE)
{
/* Call WaitForSingleObject with 0 time on the event. It
should return WAIT_OBJECT_0
*/
dwRet = WaitForSingleObject(hEvent,0);
if (dwRet != WAIT_OBJECT_0)
{
Trace("WaitForSingleObjectTest:WaitForSingleObject failed (%x)\n", GetLastError());
}
else
{
bRet = CloseHandle(hEvent);
if (!bRet)
{
Trace("WaitForSingleObjectTest:CloseHandle failed (%x)\n", GetLastError());
}
}
}
else
{
Trace("WaitForSingleObjectTest:CreateEvent failed (%x)\n", GetLastError());
}
/* If the first section passed, Create another event, with the
intial state being FALSE this time.
*/
if (bRet)
{
bRet = FALSE;
bInitialState = FALSE;
hEvent = CreateEvent( lpEventAttributes,
bManualReset, bInitialState, NULL);
if (hEvent != INVALID_HANDLE_VALUE)
{
/* Test WaitForSingleObject and ensure that it returns
WAIT_TIMEOUT in this case.
*/
dwRet = WaitForSingleObject(hEvent,0);
if (dwRet != WAIT_TIMEOUT)
{
Trace("WaitForSingleObjectTest:WaitForSingleObject failed (%x)\n", GetLastError());
}
else
{
bRet = CloseHandle(hEvent);
if (!bRet)
{
Trace("WaitForSingleObjectTest:CloseHandle failed (%x)\n", GetLastError());
}
}
}
else
{
Trace("WaitForSingleObjectTest::CreateEvent failed (%x)\n", GetLastError());
}
}
return bRet;
}
int __cdecl main(int argc, char **argv)
{
if(0 != (PAL_Initialize(argc, argv)))
{
return ( FAIL );
}
if(!WaitForSingleObjectTest())
{
Fail ("Test failed\n");
}
PAL_Terminate();
return ( PASS );
}
| 24.933884 | 99 | 0.51939 | swaroop-sridhar |
0fa728a7c59b8be56babb8b5dd4db25448e23691 | 3,875 | cpp | C++ | src/mongo/db/commands/shutdown.cpp | benety/mongo | 203430ac9559f82ca01e3cbb3b0e09149fec0835 | [
"Apache-2.0"
] | null | null | null | src/mongo/db/commands/shutdown.cpp | benety/mongo | 203430ac9559f82ca01e3cbb3b0e09149fec0835 | [
"Apache-2.0"
] | null | null | null | src/mongo/db/commands/shutdown.cpp | benety/mongo | 203430ac9559f82ca01e3cbb3b0e09149fec0835 | [
"Apache-2.0"
] | null | null | null | /**
* Copyright (C) 2020-present MongoDB, Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the Server Side Public License, version 1,
* as published by MongoDB, Inc.
*
* 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
* Server Side Public License for more details.
*
* You should have received a copy of the Server Side Public License
* along with this program. If not, see
* <http://www.mongodb.com/licensing/server-side-public-license>.
*
* As a special exception, the copyright holders give permission to link the
* code of portions of this program with the OpenSSL library under certain
* conditions as described in each individual source file and distribute
* linked combinations including the program with the OpenSSL library. You
* must comply with the Server Side Public License in all respects for
* all of the code used other than as permitted herein. If you modify file(s)
* with this exception, you may extend this exception to your version of the
* file(s), but you are not obligated to do so. If you do not wish to do so,
* delete this exception statement from your version. If you delete this
* exception statement from all source files in the program, then also delete
* it in the license file.
*/
#include "mongo/logv2/log.h"
#include "mongo/base/error_codes.h"
#include "mongo/db/commands/shutdown.h"
#include "mongo/stdx/thread.h"
#include "mongo/util/assert_util.h"
#include "mongo/util/fail_point.h"
#define MONGO_LOGV2_DEFAULT_COMPONENT ::mongo::logv2::LogComponent::kCommand
namespace mongo {
namespace shutdown_detail {
MONGO_FAIL_POINT_DEFINE(crashOnShutdown);
int* volatile illegalAddress; // NOLINT - used for fail point only
void finishShutdown(OperationContext* opCtx,
bool force,
Milliseconds timeout,
Milliseconds quiesceTime) {
crashOnShutdown.execute([&](const BSONObj& data) {
if (data["how"].str() == "fault") {
++*illegalAddress;
}
::abort();
});
// Shared by mongos and mongod shutdown code paths
LOGV2(4695400,
"Terminating via shutdown command",
"force"_attr = force,
"timeout"_attr = timeout);
// Only allow the first shutdown command to spawn a new thread and execute the shutdown.
// Late arrivers will skip and wait until operations are killed.
static StaticImmortal<AtomicWord<bool>> shutdownAlreadyInProgress{false};
if (!shutdownAlreadyInProgress->swap(true)) {
stdx::thread([quiesceTime] {
ShutdownTaskArgs shutdownArgs;
shutdownArgs.isUserInitiated = true;
shutdownArgs.quiesceTime = quiesceTime;
#if defined(_WIN32)
// Signal the ServiceMain thread to shutdown.
if (ntservice::shouldStartService()) {
shutdownNoTerminate(shutdownArgs);
return;
}
#endif
shutdown(EXIT_CLEAN, shutdownArgs); // this never returns
})
.detach();
}
// Client expects the shutdown command to abruptly close the socket as part of exiting.
// This function is not allowed to return until the server interrupts its operation.
// The following requires the shutdown task to kill all the operations after the server
// stops accepting incoming connections.
while (opCtx->checkForInterruptNoAssert().isOK())
sleepsecs(1);
iasserted({ErrorCodes::CloseConnectionForShutdownCommand,
"Closing the connection running the shutdown command"});
}
} // namespace shutdown_detail
} // namespace mongo
| 38.366337 | 92 | 0.684387 | benety |
0fa79fb15208fbecbbe8a16c6fd7756faa6d0c2a | 10,222 | cpp | C++ | Sharing/Src/Source/Common/Private/SessionImpl.cpp | darax/HoloToolkit | 5f7ddc5698dd10e83a252187983ec366d2062d08 | [
"MIT"
] | null | null | null | Sharing/Src/Source/Common/Private/SessionImpl.cpp | darax/HoloToolkit | 5f7ddc5698dd10e83a252187983ec366d2062d08 | [
"MIT"
] | null | null | null | Sharing/Src/Source/Common/Private/SessionImpl.cpp | darax/HoloToolkit | 5f7ddc5698dd10e83a252187983ec366d2062d08 | [
"MIT"
] | null | null | null | //////////////////////////////////////////////////////////////////////////
// SessionImpl.cpp
//
//
//
// Copyright (C) 2014 Microsoft Corp. All Rights Reserved
//////////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "NetworkConnectionImpl.h"
#include "SessionImpl.h"
#include "SessionMessageRouter.h"
#include "SessionManagerImpl.h"
XTOOLS_NAMESPACE_BEGIN
SessionImpl::SessionImpl(SessionManagerImpl* mgr, const ClientContextConstPtr& context, uint32 sessionID, SessionType sessionType, const std::string& name, const std::string& address, uint16 port)
: m_sessionMgr(mgr)
, m_context(context)
, m_curState(MachineSessionState::DISCONNECTED)
, m_listenerList(ListenerList::Create())
, m_id(sessionID)
, m_sessionType(sessionType)
, m_name(new XString(name))
, m_address(address)
, m_port(port)
{
m_sessionConnection = m_context->GetSessionConnection();
m_messageRouter.RegisterHandler(new MessageHandlerProxyT<const JoinSessionReply&>(CreateCallback2(this, &SessionImpl::OnJoinSessionReply)));
}
MachineSessionState SessionImpl::GetMachineSessionState() const
{
return m_curState;
}
void SessionImpl::AddListener(SessionListener* newListener)
{
m_listenerList->AddListener(newListener);
}
void SessionImpl::RemoveListener(SessionListener* oldListener)
{
m_listenerList->RemoveListener(oldListener);
}
bool SessionImpl::IsJoined() const
{
return m_curState == MachineSessionState::JOINED;
}
bool SessionImpl::Join()
{
// Cannot join a session while we're joined or currently attempting to join.
if (MachineSessionState::DISCONNECTED == m_curState)
{
LogInfo("Attempting to join session %s at %s:%i", m_name->GetString().c_str(), m_address.c_str(), m_port);
// Verify that no other sessions are already in a joining state.
int sessionCount = m_sessionMgr->GetSessionCount();
for (int i = 0; i < sessionCount; i++)
{
SessionPtr curSession = m_sessionMgr->GetSession(i);
// Fail if any sessions are in a pending state.
// TODO: Instead, we should just auto leave all non-disconnected sessions.
if (curSession->GetMachineSessionState() == MachineSessionState::JOINING)
{
LogError("SessionImpl::Join called while another session %s was in a joining state", curSession->GetName()->GetString().c_str());
curSession->Leave();
XTASSERT(curSession->GetMachineSessionState() == MachineSessionState::DISCONNECTED);
return false;
}
}
SessionPtr oldSession = m_sessionMgr->GetCurrentSession();
if (oldSession)
{
LogInfo("Automatically leaving existing session %s", oldSession->GetName()->GetString().c_str());
oldSession->Leave();
XTASSERT(oldSession->GetMachineSessionState() == MachineSessionState::DISCONNECTED);
XTASSERT(m_sessionMgr->GetCurrentSession() == NULL);
}
// Set out state to joining
SetState(MachineSessionState::JOINING);
// Set this as the current session for this machine
m_sessionMgr->SetCurrentSession(this);
// Attempting to join a new session; notify the listeners
m_listenerList->NotifyListeners(&SessionListener::OnJoiningSession);
// Attempt to open a connection to this session
XSocketPtr socket = m_context->GetXSocketManager()->OpenConnection(m_address, m_port);
if (XTVERIFY(socket))
{
// Initiate the handshake
HandshakeCallback callback = CreateCallback3(this, &SessionImpl::OnHandshakeComplete);
m_handshake = new NetworkHandshake(socket, new SessionHandshakeLogic(false), callback);
return true;
}
else
{
LogError("Join failed we failed to create a socket to the session at %s:%u.", m_address.c_str(), m_port);
}
}
else
{
LogError("Join failed because the current state is %s instead of DISCONNECTED", (m_curState == MachineSessionState::JOINING) ? "JOINING" : "JOINED");
}
return false;
}
void SessionImpl::Leave()
{
LogInfo("Leaving session %s at %s:%i", m_name->GetString().c_str(), m_address.c_str(), m_port);
SessionPtr currentSession = m_sessionMgr->GetCurrentSession();
if (currentSession == this)
{
bool isConnected = m_sessionConnection->IsConnected();
if (isConnected)
{
// Will cause OnDisconnected to be called
m_sessionConnection->Disconnect();
}
TeardownConnection();
XTASSERT(m_sessionMgr->GetCurrentSession() == NULL);
}
XTASSERT(GetMachineSessionState() == MachineSessionState::DISCONNECTED);
}
int32 SessionImpl::GetUserCount() const
{
return static_cast<int32>(m_users.size());
}
UserPtr SessionImpl::GetUser(int32 i)
{
if (i >= 0 && i < GetUserCount())
{
return m_users[i];
}
else
{
return NULL;
}
}
SessionType SessionImpl::GetSessionType() const
{
return m_sessionType;
}
const XStringPtr& SessionImpl::GetName() const
{
return m_name;
}
unsigned int SessionImpl::GetSessionId() const
{
return m_id;
}
void SessionImpl::SetSessionId(unsigned int id)
{
m_id = id;
}
NetworkConnectionPtr SessionImpl::GetSessionNetworkConnection() const
{
return m_sessionConnection;
}
void SessionImpl::SetState(MachineSessionState newState)
{
m_curState = newState;
}
void SessionImpl::AddUser(const UserPtr& newUser)
{
UserPtr existingUser = FindUser(newUser->GetID());
if (!existingUser)
{
m_users.push_back(newUser);
}
}
UserPtr SessionImpl::RemoveUser(UserID userID)
{
for (size_t i = 0; i < m_users.size(); ++i)
{
if (m_users[i]->GetID() == userID)
{
UserPtr user = m_users[i];
m_users.erase(m_users.begin() + i);
return user;
}
}
return NULL;
}
void SessionImpl::UpdateUser(const UserPtr& updatedUser)
{
// Expect this only to be called on sessions we are joined to.
XTASSERT(IsJoined());
UserPtr user = FindUser(updatedUser->GetID());
// Assert that we aren't updating for a user who's not present.
if (XTVERIFY(user))
{
UserChangedSessionMsg userUpdateMsg(m_id, user->GetName()->GetString(), user->GetID(), user->GetMuteState());
NetworkOutMessagePtr msg = m_sessionConnection->CreateMessage(MessageID::SessionControl);
msg->Write(new XString(userUpdateMsg.ToJSONString()));
m_sessionConnection->Send(msg);
}
}
UserPtr SessionImpl::FindUser(UserID userID) const
{
for (size_t i = 0; i < m_users.size(); ++i)
{
if (m_users[i]->GetID() == userID)
{
return m_users[i];
}
}
return NULL;
}
void SessionImpl::OnConnected(const NetworkConnectionPtr& connection)
{
// We have successfully connected to this session.
// Now send it information about us so it lets us in all the way
XTASSERT(m_curState == MachineSessionState::JOINING);
JoinSessionRequest request(
m_context->GetLocalUser()->GetName()->GetString(),
m_context->GetLocalUser()->GetID(),
m_context->GetLocalUser()->GetMuteState()
);
NetworkOutMessagePtr msg = connection->CreateMessage(MessageID::SessionControl);
msg->Write(new XString(request.ToJSONString()));
connection->Send(msg);
}
void SessionImpl::OnConnectFailed(const NetworkConnectionPtr&)
{
XTASSERT(m_curState == MachineSessionState::JOINING);
TeardownConnection();
}
void SessionImpl::OnDisconnected(const NetworkConnectionPtr&)
{
// Connection to the session has been lost; we are no longer joined
TeardownConnection();
}
void SessionImpl::OnMessageReceived(const NetworkConnectionPtr& connection, NetworkInMessage& message)
{
XStringPtr command = message.ReadString();
JSONMessagePtr jMsg = JSONMessage::CreateFromMessage(command->GetString());
// Route the incoming message to the appropriate function to handle it
if (!m_messageRouter.CallHandler(jMsg, connection))
{
// We got a bad or unexpected message from the server; break the connection
TeardownConnection();
}
}
void SessionImpl::OnJoinSessionReply(const JoinSessionReply& reply, const NetworkConnectionPtr&)
{
XTASSERT(m_curState == MachineSessionState::JOINING);
if (reply.GetResult())
{
LogInfo("Session Join Succeeded");
SetState(MachineSessionState::JOINED);
// Add the connection to the session to the Sync manager
m_context->GetSyncManager()->AddConnection(m_sessionConnection);
m_context->GetInternalSyncManager()->AddConnection(m_sessionConnection);
// Connect the tunnel between the secondary client and the session
m_tunnelBridge = new TunnelBridge(m_sessionConnection, m_context->GetPairedConnection());
AddUser(m_context->GetLocalUser());
m_sessionMgr->NotifyOnUserJoinedSessionListeners(this, m_context->GetLocalUser());
// Tell all listeners that we've successfully created the session.
m_listenerList->NotifyListeners(&SessionListener::OnJoinSucceeded);
}
else
{
LogInfo("Session Join Failed!");
Leave();
}
}
void SessionImpl::OnHandshakeComplete(const XSocketPtr& newConnection, SocketID, HandshakeResult result)
{
m_handshake = NULL;
if (newConnection && result == HandshakeResult::Success)
{
// Register to listen for SessionControl messages from the session
m_sessionConnection->AddListener(MessageID::SessionControl, this);
m_sessionConnection->SetSocket(newConnection);
}
else
{
LogInfo("Session: Handshake for session %s failed with error %u", m_name->GetString().c_str(), result);
XTASSERT(m_curState == MachineSessionState::JOINING);
Leave();
}
}
void SessionImpl::TeardownConnection()
{
MachineSessionState oldState = m_curState;
SetState(MachineSessionState::DISCONNECTED);
m_handshake = nullptr;
m_tunnelBridge = nullptr;
m_sessionConnection->RemoveListener(MessageID::SessionControl, this);
m_context->GetSyncManager()->RemoveConnection(m_sessionConnection);
m_context->GetInternalSyncManager()->RemoveConnection(m_sessionConnection);
m_sessionMgr->SetCurrentSession(NULL);
// Notify the listeners
if (oldState == MachineSessionState::JOINED)
{
m_listenerList->NotifyListeners(&SessionListener::OnSessionDisconnected);
}
else if (oldState == MachineSessionState::JOINING)
{
m_listenerList->NotifyListeners(&SessionListener::OnJoinFailed);
}
}
XTOOLS_NAMESPACE_END
| 25.683417 | 196 | 0.711407 | darax |
0fa7ebbb91f27caa1017e19b3ce1bcd24cf68aa1 | 2,664 | cpp | C++ | shapes_riot/src/main.cpp | kiwixz/shapes_riot | 9a745e26317d0c8d161c0da06378614a9feef920 | [
"MIT"
] | 1 | 2019-11-12T06:55:59.000Z | 2019-11-12T06:55:59.000Z | shapes_riot/src/main.cpp | kiwixz/shapes_riot | 9a745e26317d0c8d161c0da06378614a9feef920 | [
"MIT"
] | null | null | null | shapes_riot/src/main.cpp | kiwixz/shapes_riot | 9a745e26317d0c8d161c0da06378614a9feef920 | [
"MIT"
] | null | null | null | #include <chrono>
#include <iostream>
#include <fmt/printf.h>
#include <glad/glad.h>
#include "gfx/window.h"
#include "utils/exception.h"
#include "utils/logger.h"
#include "utils/os.h"
#include "utils/resource_manager.h"
#include "main_menu.h"
#include "perf.h"
#include "screen_stack.h"
int main(int /*argc*/, char** /*argv*/)
{
using namespace shapes_riot;
std::set_terminate(&utils::terminate);
utils::set_thread_name("main_thread");
gfx::Window window{"Shapes Riot", {1600, 900}};
if (!GLAD_GL_ARB_direct_state_access)
throw MAKE_EXCEPTION("missing gl extension ARB_direct_state_access");
if (GLAD_GL_KHR_debug) {
glDebugMessageControl(GL_DONT_CARE, GL_DEBUG_TYPE_OTHER, GL_DEBUG_SEVERITY_NOTIFICATION,
0, nullptr, GL_FALSE);
glDebugMessageCallback([](GLenum source, GLenum type, GLuint id, GLenum severity,
GLsizei /*length*/, const GLchar* message, const void* /*userParam*/) {
utils::Logger{"OpenGL"}(utils::LogLevel::info,
"source:{:#x} type:{:#x} id:{:#x} severity:{:#x}\n\t {}",
source, type, id, severity, message);
},
nullptr);
}
else {
utils::Logger{"OpenGL"}(utils::LogLevel::warning, "missing extension KHR_debug");
}
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_BLEND);
glClearDepth(-1.0f);
glDepthFunc(GL_GEQUAL);
glEnable(GL_DEPTH_TEST);
utils::ResourceManager resource_manager;
ScreenStack screens{window};
screens.emplace<MainMenu>(resource_manager);
gfx::Drawer drawer{resource_manager};
Perf perf;
using Clock = std::chrono::steady_clock;
Clock::time_point last_frame = Clock::now();
while (!window.is_closed()) {
Clock::time_point now = Clock::now();
double delta = std::chrono::duration<double>(now - last_frame).count();
last_frame = now;
gfx::WindowState state = window.state();
window.poll_events([&](gfx::WindowEvent&& event) {
if (const auto* framebuffer_resize = event.as<gfx::WindowEvent::FramebufferResize>())
glViewport(0, 0, framebuffer_resize->width, framebuffer_resize->height);
screens.top().on_window_event(event, state);
});
if (screens.empty())
break;
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
screens.top().tick(delta, state);
perf.tick(delta);
drawer.draw(perf.draw(state));
window.swap_buffers();
}
return 0;
}
| 31.341176 | 105 | 0.616366 | kiwixz |