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
|
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
9eeb5a2ef550c476cc02eb2855487ed91a5cf6e8
| 2,391
|
cpp
|
C++
|
src/runtime/fnput/fnput_impl.cpp
|
jsoniq/jsoniq
|
f7af29417f809d64d1f0b2622d880bc4d87f2e42
|
[
"Apache-2.0"
] | 94
|
2015-01-18T09:40:36.000Z
|
2022-03-02T21:14:55.000Z
|
src/runtime/fnput/fnput_impl.cpp
|
jsoniq/jsoniq
|
f7af29417f809d64d1f0b2622d880bc4d87f2e42
|
[
"Apache-2.0"
] | 72
|
2015-01-05T22:00:31.000Z
|
2021-07-17T11:35:03.000Z
|
src/runtime/fnput/fnput_impl.cpp
|
jsoniq/jsoniq
|
f7af29417f809d64d1f0b2622d880bc4d87f2e42
|
[
"Apache-2.0"
] | 27
|
2015-01-18T20:20:54.000Z
|
2020-11-01T18:01:07.000Z
|
/*
* Copyright 2006-2008 The FLWOR Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "stdafx.h"
#include "common/shared_types.h"
#include "system/globalenv.h"
#include "context/static_context.h"
#include "runtime/fnput/fnput.h"
#include "store/api/pul.h"
#include "store/api/item_factory.h"
#include "store/api/copymode.h"
#include "zorbatypes/URI.h"
#include <zorba/internal/unique_ptr.h>
namespace zorba
{
/*******************************************************************************
fn:put
********************************************************************************/
bool FnPutIterator::nextImpl(store::Item_t& result, PlanState& planState) const
{
store::Item_t node;
store::Item_t uriItem;
zstring uriString;
zstring resolvedUriString;
URI lTargetUri;
store::Item_t resolvedUriItem;
std::unique_ptr<store::PUL> pul;
PlanIteratorState* state;
DEFAULT_STACK_INIT(PlanIteratorState, state, planState);
consumeNext(node, theChildren[0].getp(), planState);
if (node->getNodeKind()==store::StoreConsts::attributeNode)
{
throw XQUERY_EXCEPTION(
err::FOUP0001,
ERROR_LOC( loc )
);
}
consumeNext(uriItem, theChildren[1].getp(), planState);
uriString = uriItem->getStringValue();
#if 1
resolvedUriString = theSctx->resolve_relative_uri(uriString, false);
GENV_ITEMFACTORY->createAnyURI(resolvedUriItem, resolvedUriString);
#else
GENV_ITEMFACTORY->createAnyURI(resolvedUriItem, uriString);
#endif
try
{
lTargetUri = URI(uriString);
}
catch (XQueryException& e)
{
set_source(e, loc);
e.set_diagnostic(err::FOUP0002);
throw;
}
pul.reset(GENV_ITEMFACTORY->createPendingUpdateList());
pul->addPut(&loc, node, resolvedUriItem);
result = pul.release();
STACK_PUSH(true, state);
STACK_END(state);
}
}
/* vim:set et sw=2 ts=2: */
| 23.91
| 81
| 0.668758
|
jsoniq
|
9eef58a4eb99274a4f325f64f7f4d500fe773df8
| 13,202
|
cpp
|
C++
|
code/engine.vc2008/xrGame/ActorEffector.cpp
|
Rikoshet-234/xray-oxygen
|
eaac3fa4780639152684f3251b8b4452abb8e439
|
[
"Apache-2.0"
] | 7
|
2018-03-27T12:36:07.000Z
|
2020-06-26T11:31:52.000Z
|
code/engine.vc2008/xrGame/ActorEffector.cpp
|
Rikoshet-234/xray-oxygen
|
eaac3fa4780639152684f3251b8b4452abb8e439
|
[
"Apache-2.0"
] | 2
|
2018-05-26T23:17:14.000Z
|
2019-04-14T18:33:27.000Z
|
code/engine.vc2008/xrGame/ActorEffector.cpp
|
Rikoshet-234/xray-oxygen
|
eaac3fa4780639152684f3251b8b4452abb8e439
|
[
"Apache-2.0"
] | 3
|
2020-06-26T11:41:44.000Z
|
2021-09-29T19:35:04.000Z
|
#include "stdafx.h"
#include "PostprocessAnimator.h"
#include "../xrEngine/effectorPP.h"
#include "../xrEngine/ObjectAnimator.h"
#include "object_broker.h"
#include "Actor.h"
void GAME_API AddEffector(CActor* A, int type, const shared_str& sect_name)
{
bool bCyclic = false;
if (pSettings->line_exist(sect_name, "pp_eff_name"))
{
bCyclic = pSettings->r_bool(sect_name, "pp_eff_cyclic");
CPostprocessAnimator* pp_anm = xr_new<CPostprocessAnimator>();
pp_anm->bOverlap = pSettings->r_bool(sect_name, "pp_eff_overlap");
pp_anm->SetType((EEffectorPPType)type);
pp_anm->SetCyclic(bCyclic);
LPCSTR fn = pSettings->r_string(sect_name, "pp_eff_name");
pp_anm->Load(fn);
A->Cameras().AddPPEffector(pp_anm);
}
if (pSettings->line_exist(sect_name, "cam_eff_name"))
{
bCyclic = pSettings->r_bool(sect_name, "cam_eff_cyclic");
CAnimatorCamEffector* cam_anm = xr_new<CAnimatorCamEffector>();
cam_anm->SetType((ECamEffectorType)type);
cam_anm->SetCyclic(bCyclic);
if (pSettings->line_exist(sect_name, "cam_eff_hud_affect"))
cam_anm->SetHudAffect(pSettings->r_bool(sect_name, "cam_eff_hud_affect"));
LPCSTR fn = pSettings->r_string(sect_name, "cam_eff_name");
cam_anm->Start(fn);
A->Cameras().AddCamEffector(cam_anm);
}
}
void GAME_API AddEffector(CActor* A, int type, const shared_str& sect_name, CEffectorController* ec)
{
bool bCyclic = false;
if (pSettings->line_exist(sect_name, "pp_eff_name"))
{
bCyclic = pSettings->r_bool(sect_name, "pp_eff_cyclic");
CPostprocessAnimatorControlled* pp_anm = xr_new<CPostprocessAnimatorControlled>(ec);
pp_anm->SetType((EEffectorPPType)type);
pp_anm->SetCyclic(bCyclic);
pp_anm->bOverlap = pSettings->r_bool(sect_name, "pp_eff_overlap");
LPCSTR fn = pSettings->r_string(sect_name, "pp_eff_name");
pp_anm->Load(fn);
A->Cameras().AddPPEffector(pp_anm);
}
if (pSettings->line_exist(sect_name, "cam_eff_name"))
{
bCyclic = pSettings->r_bool(sect_name, "cam_eff_cyclic");
CCameraEffectorControlled* cam_anm = xr_new<CCameraEffectorControlled>(ec);
cam_anm->SetType((ECamEffectorType)type);
cam_anm->SetCyclic(bCyclic);
if (pSettings->line_exist(sect_name, "cam_eff_hud_affect"))
cam_anm->SetHudAffect(pSettings->r_bool(sect_name, "cam_eff_hud_affect"));
LPCSTR fn = pSettings->r_string(sect_name, "cam_eff_name");
cam_anm->Start(fn);
A->Cameras().AddCamEffector(cam_anm);
}
}
void GAME_API AddEffector(CActor* A, int type, const shared_str& sect_name, GET_KOEFF_FUNC k_func)
{
bool bCyclic = false;
if (pSettings->line_exist(sect_name, "pp_eff_name"))
{
bCyclic = pSettings->r_bool(sect_name, "pp_eff_cyclic");
CPostprocessAnimatorLerp* pp_anm = xr_new<CPostprocessAnimatorLerp>();
pp_anm->SetType((EEffectorPPType)type);
pp_anm->SetCyclic(bCyclic);
pp_anm->bOverlap = !!pSettings->r_bool(sect_name, "pp_eff_overlap");
LPCSTR fn = pSettings->r_string(sect_name, "pp_eff_name");
pp_anm->SetFactorFunc(k_func);
pp_anm->Load(fn);
A->Cameras().AddPPEffector(pp_anm);
}
if (pSettings->line_exist(sect_name, "cam_eff_name"))
{
bCyclic = pSettings->r_bool(sect_name, "cam_eff_cyclic");
CAnimatorCamLerpEffector* cam_anm = xr_new<CAnimatorCamLerpEffector>();
cam_anm->SetFactorFunc(k_func);
cam_anm->SetType((ECamEffectorType)type);
cam_anm->SetCyclic(bCyclic);
if (pSettings->line_exist(sect_name, "cam_eff_hud_affect"))
cam_anm->SetHudAffect(pSettings->r_bool(sect_name, "cam_eff_hud_affect"));
LPCSTR fn = pSettings->r_string(sect_name, "cam_eff_name");
cam_anm->Start(fn);
A->Cameras().AddCamEffector(cam_anm);
}
}
void GAME_API AddEffector(CActor* A, int type, const shared_str& sect_name, float factor)
{
clamp(factor, 0.001f, 1.5f);
bool bCyclic = false;
if (pSettings->line_exist(sect_name, "pp_eff_name"))
{
bCyclic = pSettings->r_bool(sect_name, "pp_eff_cyclic");
CPostprocessAnimatorLerpConst* pp_anm = xr_new<CPostprocessAnimatorLerpConst>();
pp_anm->SetType((EEffectorPPType)type);
pp_anm->SetCyclic(bCyclic);
pp_anm->SetPower(factor);
pp_anm->bOverlap = pSettings->r_bool(sect_name, "pp_eff_overlap");
LPCSTR fn = pSettings->r_string(sect_name, "pp_eff_name");
pp_anm->Load(fn);
A->Cameras().AddPPEffector(pp_anm);
}
if (pSettings->line_exist(sect_name, "cam_eff_name"))
{
bCyclic = pSettings->r_bool(sect_name, "cam_eff_cyclic");
CAnimatorCamLerpEffectorConst* cam_anm = xr_new<CAnimatorCamLerpEffectorConst>();
cam_anm->SetFactor(factor);
cam_anm->SetType((ECamEffectorType)type);
cam_anm->SetCyclic(bCyclic);
if (pSettings->line_exist(sect_name, "cam_eff_hud_affect"))
cam_anm->SetHudAffect(pSettings->r_bool(sect_name, "cam_eff_hud_affect"));
LPCSTR fn = pSettings->r_string(sect_name, "cam_eff_name");
cam_anm->Start(fn);
A->Cameras().AddCamEffector(cam_anm);
}
}
void GAME_API RemoveEffector(CActor* A, int type)
{
A->Cameras().RemoveCamEffector((ECamEffectorType)type);
A->Cameras().RemovePPEffector((EEffectorPPType)type);
}
CEffectorController::~CEffectorController()
{
R_ASSERT(!m_ce&&!m_pe);
}
CAnimatorCamEffector::CAnimatorCamEffector()
{
m_bCyclic = true;
m_objectAnimator = xr_new<CObjectAnimator>();
m_bAbsolutePositioning = false;
m_fov = -1.0f;
}
CAnimatorCamEffector::~CAnimatorCamEffector()
{
delete_data(m_objectAnimator);
}
void CAnimatorCamEffector::Start(LPCSTR fn)
{
m_objectAnimator->Load(fn);
m_objectAnimator->Play(Cyclic());
fLifeTime = m_objectAnimator->GetLength();
}
BOOL CAnimatorCamEffector::Valid()
{
if (Cyclic())
return TRUE;
return inherited::Valid();
}
BOOL CAnimatorCamEffector::ProcessCam(SCamEffectorInfo& info)
{
if (!inherited::ProcessCam(info))
return FALSE;
const Fmatrix& m = m_objectAnimator->XFORM();
m_objectAnimator->Update(Device.fTimeDelta);
if (!m_bAbsolutePositioning)
{
Fmatrix Mdef;
Mdef.identity();
Mdef.j = info.n;
Mdef.k = info.d;
Mdef.i.crossproduct(info.n, info.d);
Mdef.c = info.p;
Fmatrix mr;
mr.mul(Mdef, m);
info.d = mr.k;
info.n = mr.j;
info.p = mr.c;
}
else
{
info.d = m.k;
info.n = m.j;
info.p = m.c;
}
if (m_fov > 0.0f)
info.fFov = m_fov;
return TRUE;
}
BOOL CAnimatorCamLerpEffector::ProcessCam(SCamEffectorInfo& info)
{
if (!inherited::inherited::ProcessCam(info))
return FALSE;
const Fmatrix& m = m_objectAnimator->XFORM();
m_objectAnimator->Update(Device.fTimeDelta);
Fmatrix Mdef;
Mdef.identity();
Mdef.j = info.n;
Mdef.k = info.d;
Mdef.i.crossproduct(info.n, info.d);
Mdef.c = info.p;
Fmatrix mr;
mr.mul(Mdef, m);
Fquaternion q_src, q_dst, q_res;
q_src.set(Mdef);
q_dst.set(mr);
float t = m_func();
clamp(t, 0.0f, 1.0f);
VERIFY(t >= 0.f && t <= 1.f);
q_res.slerp(q_src, q_dst, t);
Fmatrix res;
res.rotation(q_res);
res.c.lerp(info.p, mr.c, t);
info.d = res.k;
info.n = res.j;
info.p = res.c;
if (m_fov > 0.0f)
info.fFov = m_fov;
return TRUE;
}
CAnimatorCamLerpEffectorConst::CAnimatorCamLerpEffectorConst() :m_factor(0.0f)
{
SetFactorFunc(GET_KOEFF_FUNC(this, &CAnimatorCamLerpEffectorConst::GetFactor));
}
CCameraEffectorControlled::CCameraEffectorControlled(CEffectorController* c) : m_controller(c)
{
m_controller->SetCam(this);
SetFactorFunc(GET_KOEFF_FUNC(m_controller, &CEffectorController::GetFactor));
}
CCameraEffectorControlled::~CCameraEffectorControlled()
{
m_controller->SetCam(nullptr);
}
BOOL CCameraEffectorControlled::Valid()
{
return m_controller->Valid();
}
static const float SND_MIN_VOLUME_FACTOR = 0.1f;
SndShockEffector::SndShockEffector()
{
m_snd_length = 0.0f;
m_cur_length = 0.0f;
m_stored_volume = -1.0f;
m_actor = nullptr;
}
SndShockEffector::~SndShockEffector()
{
psSoundVFactor = m_stored_volume;
if (m_actor && (m_ce || m_pe))
RemoveEffector(m_actor, effHit);
R_ASSERT(!m_ce && !m_pe);
}
BOOL SndShockEffector::Valid()
{
return (m_cur_length<=m_snd_length);
}
BOOL SndShockEffector::InWork()
{
return inherited::Valid();
}
float SndShockEffector::GetFactor()
{
float f = (m_end_time - Device.fTimeGlobal) / m_life_time;
float ff = f * m_life_time / 8.0f;
return clampr(ff, 0.0f, 1.0f);
}
void SndShockEffector::Start(CActor* A, float snd_length, float power)
{
clamp(power, 0.1f, 1.5f);
m_actor = A;
m_snd_length = snd_length;
if (m_stored_volume < 0.0f)
m_stored_volume = psSoundVFactor;
m_cur_length = 0;
psSoundVFactor = m_stored_volume * SND_MIN_VOLUME_FACTOR;
static float xxx = 6.0f / 1.50f; //6sec on max power(1.5)
m_life_time = power * xxx;
m_end_time = Device.fTimeGlobal + m_life_time;
AddEffector(A, effHit, "snd_shock_effector", this);
}
void SndShockEffector::Update()
{
m_cur_length += Device.dwTimeDelta;
float x = float(m_cur_length) / m_snd_length;
float y = 2.f * x - 1;
if (y > 0.f)
psSoundVFactor = y * (m_stored_volume - m_stored_volume * SND_MIN_VOLUME_FACTOR) + m_stored_volume * SND_MIN_VOLUME_FACTOR;
}
static const float DELTA_ANGLE_XYZ = 0.5f * PI / 180;
static const float ANGLE_SPEED = 1.5f;
const float _base_fov = 170.f;
const float _max_fov_add = 30.f;
CControllerPsyHitCamEffector::CControllerPsyHitCamEffector(ECamEffectorType type, const Fvector &src_pos, const Fvector &target_pos, float time, float base_fov, float dest_fov)
: inherited(eCEControllerPsyHit, flt_max)
{
m_base_fov = base_fov;
m_dest_fov = dest_fov;
m_time_total = time;
m_time_current = 0;
m_dangle_target.set(angle_normalize(Random.randFs(DELTA_ANGLE_XYZ)), angle_normalize(Random.randFs(DELTA_ANGLE_XYZ)), angle_normalize(Random.randFs(DELTA_ANGLE_XYZ)));
m_dangle_current.set(0.f, 0.f, 0.f);
m_position_source = src_pos;
m_direction.sub(target_pos, src_pos);
m_distance = m_direction.magnitude();
m_direction.normalize();
}
BOOL CControllerPsyHitCamEffector::ProcessCam(SCamEffectorInfo& info)
{
Fmatrix Mdef;
Mdef.identity();
Mdef.j.set(info.n);
Mdef.k.set(m_direction);
Mdef.i.crossproduct(info.n, m_direction);
Mdef.c.set(info.p);
//////////////////////////////////////////////////////////////////////////
if (angle_lerp(m_dangle_current.x, m_dangle_target.x, ANGLE_SPEED, Device.fTimeDelta))
m_dangle_target.x = angle_normalize(Random.randFs(DELTA_ANGLE_XYZ));
if (angle_lerp(m_dangle_current.y, m_dangle_target.y, ANGLE_SPEED, Device.fTimeDelta))
m_dangle_target.y = angle_normalize(Random.randFs(DELTA_ANGLE_XYZ));
if (angle_lerp(m_dangle_current.z, m_dangle_target.z, ANGLE_SPEED, Device.fTimeDelta))
m_dangle_target.z = angle_normalize(Random.randFs(DELTA_ANGLE_XYZ));
//////////////////////////////////////////////////////////////////////////
if (m_time_current > m_time_total)
m_time_current = m_time_total;
float perc_past = m_time_current / m_time_total;
float cur_dist = m_distance * perc_past;
Mdef.c.mad(m_position_source, m_direction, cur_dist);
info.fFov = m_base_fov + (m_dest_fov - m_base_fov) * perc_past;
m_time_current += Device.fTimeDelta;
//////////////////////////////////////////////////////////////////////////
// Установить углы смещения
Fmatrix R;
if (m_time_current > m_time_total)
R.identity();
else
R.setHPB(m_dangle_current.x, m_dangle_current.y, m_dangle_current.z);
Fmatrix mR;
mR.mul(Mdef, R);
info.d.set(mR.k);
info.n.set(mR.j);
info.p.set(mR.c);
return TRUE;
}
bool similar_cam_info(const SCamEffectorInfo& c1, const SCamEffectorInfo& c2)
{
return(c1.p.similar(c2.p, EPS_L) && c1.d.similar(c2.d, EPS_L) && c1.n.similar(c2.n, EPS_L) && c1.r.similar(c2.r, EPS_L));
}
void CActorCameraManager::UpdateCamEffectors()
{
m_cam_info_hud = m_cam_info;
inherited::UpdateCamEffectors();
m_cam_info_hud.d.normalize();
m_cam_info_hud.n.normalize();
m_cam_info_hud.r.crossproduct(m_cam_info_hud.n, m_cam_info_hud.d);
m_cam_info_hud.n.crossproduct(m_cam_info_hud.d, m_cam_info_hud.r);
}
void GAME_API cam_effector_sub(const SCamEffectorInfo& c1, const SCamEffectorInfo& c2, SCamEffectorInfo& dest)
{
dest.p.sub(c1.p, c2.p);
dest.d.sub(c1.d, c2.d);
dest.n.sub(c1.n, c2.n);
dest.r.sub(c1.r, c2.r);
}
void GAME_API cam_effector_add(const SCamEffectorInfo& diff, SCamEffectorInfo& dest)
{
dest.p.add(diff.p);
dest.d.add(diff.d);
dest.n.add(diff.n);
dest.r.add(diff.r);
}
bool CActorCameraManager::ProcessCameraEffector(CEffectorCam* eff)
{
SCamEffectorInfo prev = m_cam_info;
bool res = inherited::ProcessCameraEffector(eff);
if (res)
{
if (eff->GetHudAffect())
{
SCamEffectorInfo affected = m_cam_info;
SCamEffectorInfo diff;
cam_effector_sub(affected, prev, diff);
cam_effector_add(diff, m_cam_info_hud);
}
m_cam_info_hud.fFov = m_cam_info.fFov;
m_cam_info_hud.fFar = m_cam_info.fFar;
m_cam_info_hud.fAspect = m_cam_info.fAspect;
}
return res;
}
void CAnimatorCamEffectorScriptCB::ProcessIfInvalid(SCamEffectorInfo& info)
{
if (m_bAbsolutePositioning)
{
const Fmatrix& m = m_objectAnimator->XFORM();
info.d = m.k;
info.n = m.j;
info.p = m.c;
if (m_fov > 0.0f)
info.fFov = m_fov;
}
}
#include "ai_space.h"
#include "script_engine.h"
#include <luabind/luabind.hpp>
BOOL CAnimatorCamEffectorScriptCB::Valid()
{
BOOL res = inherited::Valid();
if (!res && cb_name.size())
{
luabind::functor<LPCSTR> fl;
R_ASSERT(ai().script_engine().functor<LPCSTR>(*cb_name, fl));
fl();
cb_name = "";
}
return res;
}
| 25.585271
| 176
| 0.722391
|
Rikoshet-234
|
9ef0a499e42ff84f55d4c5be658b69d9d5837632
| 17,470
|
cpp
|
C++
|
src/miner.cpp
|
dagurval/bitcoinxt
|
74d727ee0c2410142830fac3b0fc82cee0310c71
|
[
"MIT"
] | 2
|
2018-12-05T12:46:34.000Z
|
2019-06-27T12:08:04.000Z
|
src/miner.cpp
|
sighttviewliu/bitcoinxt
|
cb4c1fcedb3b292c4dbef9e7c5248294da6aa1f2
|
[
"MIT"
] | 2
|
2018-03-09T09:33:49.000Z
|
2018-03-09T12:20:11.000Z
|
src/miner.cpp
|
dagurval/bitcoinxt
|
74d727ee0c2410142830fac3b0fc82cee0310c71
|
[
"MIT"
] | null | null | null |
// Copyright (c) 2009-2010 Satoshi Nakamoto
// Copyright (c) 2009-2014 The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include "miner.h"
#include "amount.h"
#include "chainparams.h"
#include "consensus/consensus.h"
#include "consensus/merkle.h"
#include "consensus/tx_verify.h"
#include "consensus/validation.h"
#include "hash.h"
#include "main.h"
#include "maxblocksize.h"
#include "net.h"
#include "policy/policy.h"
#include "pow.h"
#include "primitives/transaction.h"
#include "timedata.h"
#include "util.h"
#include "utilmoneystr.h"
#include "options.h"
#include "validationinterface.h"
#include <boost/thread.hpp>
#include <boost/tuple/tuple.hpp>
#include <stack>
#include <iomanip>
#include <cmath>
using namespace std;
//////////////////////////////////////////////////////////////////////////////
//
// BitcoinMiner
//
//
// Unconfirmed transactions in the memory pool often depend on other
// transactions in the memory pool. When we select transactions from the
// pool, we select by highest or fee rate, so we might consider
// transactions that depend on transactions that aren't yet in the block.
uint64_t nLastBlockTx = 0;
uint64_t nLastBlockSize = 0;
void UpdateTime(CBlockHeader* pblock, const Consensus::Params& consensusParams, const CBlockIndex* pindexPrev)
{
pblock->nTime = std::max(pindexPrev->GetMedianTimePast()+1, GetAdjustedTime());
// Updating time can change work required on testnet:
if (consensusParams.fPowAllowMinDifficultyBlocks)
pblock->nBits = GetNextWorkRequired(pindexPrev, pblock, consensusParams);
}
// BIP100 string:
// - Adds our block size vote (B) if configured.
// - Adds Excessive Block (EB) string. This announces how big blocks we currently accept.
std::vector<unsigned char> BIP100Str(uint64_t hardLimit) {
uint64_t blockVote = Opt().MaxBlockSizeVote();
std::stringstream ss;
ss << "/BIP100/";
if (blockVote)
ss << "B" << blockVote << "/";
double dMaxBlockSize = double(hardLimit)/1000000;
ss << "EB" << std::setprecision(int(log10(dMaxBlockSize))+7) << dMaxBlockSize << "/";
const std::string s = ss.str();
return std::vector<unsigned char>(begin(s), end(s));
}
CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn)
{
const CChainParams& chainparams = Params();
// Create new block
unique_ptr<CBlockTemplate> pblocktemplate(new CBlockTemplate());
if(!pblocktemplate.get())
return NULL;
CBlock *pblock = &pblocktemplate->block; // pointer for convenience
// Create coinbase tx
CMutableTransaction txNew;
txNew.vin.resize(1);
txNew.vin[0].prevout.SetNull();
txNew.vout.resize(1);
txNew.vout[0].scriptPubKey = scriptPubKeyIn;
// Add dummy coinbase tx as first transaction
pblock->vtx.push_back(CTransaction());
pblocktemplate->vTxFees.push_back(-1); // updated at end
pblocktemplate->vTxSigOps.push_back(-1); // updated at end
// Largest block you're willing to create:
uint64_t hardLimit = GetNextMaxBlockSize(chainActive.Tip(), chainparams.GetConsensus());
uint64_t nBlockMaxSize = GetArg("-blockmaxsize", hardLimit);
// Limit to between 1K and (hard limit - 1K) for sanity:
nBlockMaxSize = std::max((uint64_t)1000, std::min((hardLimit - 1000), nBlockMaxSize));
// For compatibility with bip68-sequence test, set flag to not mine txs with negative fee delta.
const bool fSkipNegativeDelta = GetBoolArg("-bip68hack", false);
// Collect memory pool transactions into the block
CTxMemPool::setEntries inBlock;
CTxMemPool::setEntries gotParents;
std::stack<CTxMemPool::txiter, std::vector<CTxMemPool::txiter>> clearedTxs;
uint64_t nBlockSize = 1000;
uint64_t nBlockTx = 0;
unsigned int nBlockSigOps = 100;
int lastFewTxs = 0;
CAmount nFees = 0;
{
LOCK2(cs_main, mempool.cs);
CBlockIndex* pindexPrev = chainActive.Tip();
const int nHeight = pindexPrev->nHeight + 1;
pblock->nTime = GetAdjustedTime();
const int64_t nMedianTimePast = pindexPrev->GetMedianTimePast();
pblock->nVersion = ComputeBlockVersion(pindexPrev, chainparams.GetConsensus());
// -regtest only: allow overriding block.nVersion with
// -blockversion=N to test forking scenarios
if (Params().MineBlocksOnDemand())
pblock->nVersion = GetArg("-blockversion", pblock->nVersion);
int64_t nLockTimeCutoff = (STANDARD_LOCKTIME_VERIFY_FLAGS & LOCKTIME_MEDIAN_TIME_PAST)
? nMedianTimePast
: pblock->GetBlockTime();
CTxMemPool::indexed_transaction_set::nth_index<3>::type::iterator mi = mempool.mapTx.get<3>().begin();
CTxMemPool::txiter iter;
while (mi != mempool.mapTx.get<3>().end() || !clearedTxs.empty())
{
if (clearedTxs.empty()) { // add tx with next highest score
iter = mempool.mapTx.project<0>(mi);
mi++;
}
else { // try to add a previously cleared tx
iter = clearedTxs.top();
clearedTxs.pop();
}
if (inBlock.count(iter)) {
continue;
}
const CTransaction& tx = iter->GetTx();
if (fSkipNegativeDelta && mempool.GetFeeModifier().GetDelta(tx.GetHash()) < 0) {
continue;
}
// Our index guarantees that all ancestors are paid for.
// If it has parents, push this tx, then its parents, onto the stack.
// The second time we process a tx, just make sure all parents are in the block
bool fAllParentsInBlock = true;
bool fPushedAParent = false;
bool fFirstTime = !gotParents.count(iter);
gotParents.insert(iter);
BOOST_FOREACH(CTxMemPool::txiter parent, mempool.GetMemPoolParents(iter))
{
if (!inBlock.count(parent)) {
fAllParentsInBlock = false;
if (fFirstTime) {
if (!fPushedAParent) {
clearedTxs.push(iter);
fPushedAParent = true;
}
clearedTxs.push(parent);
}
}
}
if (fPushedAParent || !fAllParentsInBlock) {
continue;
}
unsigned int nTxSize = iter->GetTxSize();
if (nBlockSize + nTxSize >= nBlockMaxSize) {
if (nBlockSize > nBlockMaxSize - 100 || lastFewTxs > 50) {
break;
}
// Once we're within 1000 bytes of a full block, only look at 50 more txs
// to try to fill the remaining space.
if (nBlockSize > nBlockMaxSize - 1000) {
lastFewTxs++;
}
continue;
}
if (!IsFinalTx(tx, nHeight, nLockTimeCutoff))
continue;
// TODO: with more complexity we could make the block bigger when
// sigop-constrained and sigop density in later megabytes is low
unsigned int nTxSigOps = iter->GetSigOpCount();
if (nBlockSigOps + nTxSigOps >= MaxBlockSigops(nBlockSize)) {
if (nBlockSigOps > MaxBlockSigops(nBlockSize) - 2) {
break;
}
continue;
}
CAmount nTxFees = iter->GetFee();
// Added
pblock->vtx.push_back(tx);
pblocktemplate->vTxFees.push_back(nTxFees);
pblocktemplate->vTxSigOps.push_back(nTxSigOps);
nBlockSize += nTxSize;
++nBlockTx;
nBlockSigOps += nTxSigOps;
nFees += nTxFees;
inBlock.insert(iter);
}
nLastBlockTx = nBlockTx;
nLastBlockSize = nBlockSize;
LogPrintf("CreateNewBlock(): total size %u txs: %u fees: %ld sigops %d\n", nBlockSize, nBlockTx, nFees, nBlockSigOps);
// Compute final coinbase transaction.
txNew.vout[0].nValue = nFees + GetBlockSubsidy(nHeight, chainparams.GetConsensus());
txNew.vin[0].scriptSig = CScript() << nHeight << BIP100Str(hardLimit) << OP_0;
pblock->vtx[0] = txNew;
pblocktemplate->vTxFees[0] = -nFees;
// Fill in header
pblock->hashPrevBlock = pindexPrev->GetBlockHash();
UpdateTime(pblock, Params().GetConsensus(), pindexPrev);
pblock->nBits = GetNextWorkRequired(pindexPrev, pblock, Params().GetConsensus());
pblock->nNonce = 0;
pblocktemplate->vTxSigOps[0] = GetLegacySigOpCount(pblock->vtx[0]);
CValidationState state;
if (!TestBlockValidity(state, *pblock, pindexPrev, false, false)) {
throw std::runtime_error(strprintf("%s: TestBlockValidity failed: %s", __func__, FormatStateMessage(state)));
}
}
return pblocktemplate.release();
}
void IncrementExtraNonce(CBlock* pblock, CBlockIndex* pindexPrev, unsigned int& nExtraNonce, uint64_t nMaxBlockSize)
{
// Update nExtraNonce
static uint256 hashPrevBlock;
if (hashPrevBlock != pblock->hashPrevBlock)
{
nExtraNonce = 0;
hashPrevBlock = pblock->hashPrevBlock;
}
++nExtraNonce;
unsigned int nHeight = pindexPrev->nHeight+1; // Height first in coinbase required for block.version=2
CMutableTransaction txCoinbase(pblock->vtx[0]);
txCoinbase.vin[0].scriptSig = (CScript() << nHeight << BIP100Str(nMaxBlockSize) << CScriptNum(nExtraNonce)) + COINBASE_FLAGS;
assert(txCoinbase.vin[0].scriptSig.size() <= 100);
pblock->vtx[0] = txCoinbase;
pblock->hashMerkleRoot = BlockMerkleRoot(*pblock);
}
//////////////////////////////////////////////////////////////////////////////
//
// Internal miner
//
//
// ScanHash scans nonces looking for a hash with at least some zero bits.
// The nonce is usually preserved between calls, but periodically or if the
// nonce is 0xffff0000 or above, the block is rebuilt and nNonce starts over at
// zero.
//
bool static ScanHash(const CBlockHeader *pblock, uint32_t& nNonce, uint256 *phash)
{
// Write the first 76 bytes of the block header to a double-SHA256 state.
CHash256 hasher;
CDataStream ss(SER_NETWORK, PROTOCOL_VERSION);
ss << *pblock;
assert(ss.size() == 80);
hasher.Write((unsigned char*)&ss[0], 76);
while (true) {
nNonce++;
// Write the last 4 bytes of the block header (the nonce) to a copy of
// the double-SHA256 state, and compute the result.
CHash256(hasher).Write((unsigned char*)&nNonce, 4).Finalize((unsigned char*)phash);
// Return the nonce if the hash has at least some zero bits,
// caller will check if it has enough to reach the target
if (((uint16_t*)phash)[15] == 0)
return true;
// If nothing found after trying for a while, return -1
if ((nNonce & 0xfff) == 0)
return false;
}
}
static bool ProcessBlockFound(CBlock* pblock, const CChainParams& chainparams, CConnman* connman)
{
LogPrintf("%s\n", pblock->ToString());
LogPrintf("generated %s\n", FormatMoney(pblock->vtx[0].vout[0].nValue));
// Found a solution
{
LOCK(cs_main);
if (pblock->hashPrevBlock != chainActive.Tip()->GetBlockHash())
return error("BitcoinMiner: generated block is stale");
}
// Inform about the new block
GetMainSignals().BlockFound(pblock->GetHash());
// Process this block the same as if we had received it from another node
CValidationState state;
if (!ProcessNewBlock(state, BlockSource{}, pblock, true, nullptr, connman))
return error("BitcoinMiner: ProcessNewBlock, block not accepted");
return true;
}
void static BitcoinMiner(const CChainParams& chainparams, CConnman* connman)
{
LogPrintf("BitcoinMiner started\n");
SetThreadPriority(THREAD_PRIORITY_LOWEST);
RenameThread("bitcoin-miner");
unsigned int nExtraNonce = 0;
boost::shared_ptr<CReserveScript> coinbaseScript;
GetMainSignals().ScriptForMining(coinbaseScript);
try {
// Throw an error if no script was provided. This can happen
// due to some internal error but also if the keypool is empty.
// In the latter case, already the pointer is NULL.
if (!coinbaseScript || coinbaseScript->reserveScript.empty())
throw std::runtime_error("No coinbase script available (mining requires a wallet)");
while (true) {
if (chainparams.MiningRequiresPeers()) {
// Busy-wait for the network to come online so we don't waste time mining
// on an obsolete chain. In regtest mode we expect to fly solo.
do {
bool fvNodesEmpty = bool(connman->GetNodeCount(CConnman::CONNECTIONS_ALL));
if (!fvNodesEmpty && !IsInitialBlockDownload())
break;
MilliSleep(1000);
} while (true);
}
//
// Create new block
//
unsigned int nTransactionsUpdatedLast = mempool.GetTransactionsUpdated();
CBlockIndex* pindexPrev = chainActive.Tip();
unique_ptr<CBlockTemplate> pblocktemplate(CreateNewBlock(coinbaseScript->reserveScript));
if (!pblocktemplate.get())
{
LogPrintf("Error in BitcoinMiner: Keypool ran out, please call keypoolrefill before restarting the mining thread\n");
return;
}
CBlock *pblock = &pblocktemplate->block;
uint64_t hardLimit = GetNextMaxBlockSize(pindexPrev, chainparams.GetConsensus());
IncrementExtraNonce(pblock, pindexPrev, nExtraNonce, hardLimit);
LogPrintf("Running BitcoinMiner with %u transactions in block (%u bytes)\n", pblock->vtx.size(),
::GetSerializeSize(*pblock, SER_NETWORK, PROTOCOL_VERSION));
//
// Search
//
int64_t nStart = GetTime();
arith_uint256 hashTarget = arith_uint256().SetCompact(pblock->nBits);
uint256 hash;
uint32_t nNonce = 0;
while (true) {
// Check if something found
if (ScanHash(pblock, nNonce, &hash))
{
if (UintToArith256(hash) <= hashTarget)
{
// Found a solution
pblock->nNonce = nNonce;
assert(hash == pblock->GetHash());
SetThreadPriority(THREAD_PRIORITY_NORMAL);
LogPrintf("BitcoinMiner:\n");
LogPrintf("proof-of-work found \n hash: %s \ntarget: %s\n", hash.GetHex(), hashTarget.GetHex());
ProcessBlockFound(pblock, chainparams, connman);
SetThreadPriority(THREAD_PRIORITY_LOWEST);
coinbaseScript->KeepScript();
// In regression test mode, stop mining after a block is found.
if (chainparams.MineBlocksOnDemand())
throw boost::thread_interrupted();
break;
}
}
// Check for stop or if block needs to be rebuilt
boost::this_thread::interruption_point();
// Regtest mode doesn't require peers
bool connected = bool(connman->GetNodeCount(CConnman::CONNECTIONS_ALL));
if (!connected && chainparams.MiningRequiresPeers())
break;
if (nNonce >= 0xffff0000)
break;
if (mempool.GetTransactionsUpdated() != nTransactionsUpdatedLast && GetTime() - nStart > 60)
break;
if (pindexPrev != chainActive.Tip())
break;
// Update nTime every few seconds
UpdateTime(pblock, chainparams.GetConsensus(), pindexPrev);
if (chainparams.GetConsensus().fPowAllowMinDifficultyBlocks)
{
// Changing pblock->nTime can change work required on testnet:
hashTarget.SetCompact(pblock->nBits);
}
}
}
}
catch (const boost::thread_interrupted&)
{
LogPrintf("BitcoinMiner terminated\n");
throw;
}
catch (const std::runtime_error &e)
{
LogPrintf("BitcoinMiner runtime error: %s\n", e.what());
return;
}
}
void GenerateBitcoins(bool fGenerate, int nThreads, const CChainParams& chainparams, CConnman* connman)
{
static boost::thread_group* minerThreads = NULL;
if (nThreads < 0)
nThreads = GetNumCores();
if (minerThreads != NULL)
{
minerThreads->interrupt_all();
delete minerThreads;
minerThreads = NULL;
}
if (nThreads == 0 || !fGenerate)
return;
minerThreads = new boost::thread_group();
for (int i = 0; i < nThreads; i++)
minerThreads->create_thread(boost::bind(&BitcoinMiner, boost::cref(chainparams), connman));
}
| 37.650862
| 133
| 0.599828
|
dagurval
|
9ef0de28456ebc1de37f6154aaebdc16fc6e0add
| 59,522
|
cpp
|
C++
|
Src/ime/PhoneKeyboard.cpp
|
ericblade/luna-sysmgr
|
82d5d7ced4ba21d3802eb2c8ae063236b6562331
|
[
"Apache-2.0"
] | 3
|
2018-11-16T14:51:17.000Z
|
2019-11-21T10:55:24.000Z
|
Src/ime/PhoneKeyboard.cpp
|
penk/luna-sysmgr
|
60c7056a734cdb55a718507f3a739839c9d74edf
|
[
"Apache-2.0"
] | 1
|
2021-02-20T13:12:15.000Z
|
2021-02-20T13:12:15.000Z
|
Src/ime/PhoneKeyboard.cpp
|
ericblade/luna-sysmgr
|
82d5d7ced4ba21d3802eb2c8ae063236b6562331
|
[
"Apache-2.0"
] | null | null | null |
/* @@@LICENSE
*
* Copyright (c) 2010-2012 Hewlett-Packard Development Company, L.P.
*
* 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.
*
* LICENSE@@@ */
#include "PhoneKeyboard.h"
#include "KeyLocationRecorder.h"
#include "PalmIMEHelpers.h"
#include "Settings.h"
#include "SingletonTimer.h"
#include "Utils.h"
#include "VirtualKeyboardPreferences.h"
#include <QDebug>
#include <QFile>
#include <QApplication>
#include <stdlib.h>
#include <glib.h>
#include <sys/times.h>
namespace Phone_Keyboard {
/**
* temporary XML filename
*/
#define IME_KDB_XML_FILENAME "/tmp/kdb.xml"
#define CURRENT_TIME SingletonTimer::currentTime()
// #define DOUBLE_TAP_DURATION Settings::LunaSettings()->tapDoubleClickDuration
#define DOUBLE_TAP_DURATION 500
#define DEBUG_TOUCH 0
inline bool KeyCap_TwoVertical(const QPoint & keyCoord, UKey key)
{
return !UKeyIsFunctionKey(key) && (key < Qt::Key_A || key > Qt::Key_Z);
}
const int cFirstRepeatDelay = 350;
const int cFirstRepeatLongDelay = 750;
const int cLetterDeleteRepeatDelay = 120;
const int cWordDeleteRepeatDelay = 275;
const uint64_t cWordDeleteDelay = cFirstRepeatDelay + 1500;
const QPainter::RenderHints cRenderHints = QPainter::SmoothPixmapTransform | QPainter::HighQualityAntialiasing | QPainter::TextAntialiasing;
// constants used to draw the popup for extended keys
const int cPopupFontSize = 22;
const int cPopupLeftSide = 11;
const int cPopupRightSide = 10;
const int cPopupSide = 20;
const int cPopupPointerStart = 37;
const int cPopupPointerWidth = 25;
const int cPopupTopToKey = 10;
const int cPopupSingleLineMax = 5; // if more extended chars that this, break-up in two lines
const int cPressedTranslateH = 0;
const int cPressedTranslateV = 0;
static QFont sFont("Prelude");
static QFont sPopoutFont("Prelude", 32);
static QString sElipsis(QChar(0x2026 /* … */));
const int cElipsisFontSize = 14;
const QColor cActiveColor(0xd2, 0xd2, 0xd2);
const QColor cActiveColor_back(0xd2, 0xd2, 0xd2);
const QColor cDisabledColor(0x80, 0x80, 0x80);
const QColor cDisabledColor_back(0x80, 0x80, 0x80);
const QColor cFunctionColor(0xd2, 0xd2, 0xd2);
const QColor cFunctionColor_back(0xd2, 0xd2, 0xd2);
const QColor cBlueColor(75, 151, 222);
const QColor cBlueColor_back(255, 255, 255);
const QColor cPopoutTextColor(20, 20, 20);
const QColor cPopoutTextColor_back(0xe2, 0xe2, 0xe2);
class PhoneKeyboardFactory : public VirtualKeyboardFactory
{
public:
PhoneKeyboardFactory() : VirtualKeyboardFactory("Phone Keyboard") {}
InputMethod * create(IMEDataInterface * dataInterface) { return new PhoneKeyboard(dataInterface); }
EVirtualKeyboardSupport getSupport(int maxWidth, int maxHeight)
{
// return eVirtualKeyboardSupport_Preferred_SizeAndLocale; // force phone keyboard for testing!
if (maxWidth < 1024 && maxHeight < 1024)
return eVirtualKeyboardSupport_Preferred_Size;
return eVirtualKeyboardSupport_Poor;
}
};
static PhoneKeyboardFactory sPhoneKeyboardFactory;
static gboolean keyboard_idle(gpointer)
{
PhoneKeyboard * keyboard = PhoneKeyboard::getExistingInstance();
if (keyboard)
return keyboard->idle();
return false;
}
typedef DoubleDrawRendererT<GlyphSpec> DoubleDrawRenderer;
PhoneKeyboard * PhoneKeyboard::s_instance = NULL;
PhoneKeyboard::PhoneKeyboard(IMEDataInterface * dataInterface) : VirtualKeyboard(dataInterface),
m_shiftDown(false),
m_symbolDown(false),
m_lastShiftTime(0),
m_lastUnlockTime(0),
m_keyboardTopPading(0),
m_requestedHeight(-1),
m_9tileCorner(22, 22),
m_keyboardBackgound(NULL),
m_keyboardLimitsVersion(0),
m_keyboardDirty(true),
m_candidateBar(m_keymap, m_IMEDataInterface),
m_candidateBarLayoutOutdated(true),
m_generatedKeymapLayout(NULL),
m_timer(this), m_repeatKey(cOutside), m_repeatStartTime(0),
m_extendedKeys(NULL),
m_extendedKeyShown(cKey_None),
m_shortcutsHandler(dataInterface),
m_showPopupKeys(true),
m_idleInit(false),
m_backspace("icon-delete.png"),
m_shift("icon-shift.png"),
m_shift_on("icon-shift-on.png"),
m_shift_lock("icon-shift-lock.png"),
m_hide("icon-hide-keyboard.png"),
m_emoticon_frown("/usr/palm/emoticons/emoticon-frown.png"),
m_emoticon_cry("/usr/palm/emoticons/emoticon-cry.png"),
m_emoticon_smile("/usr/palm/emoticons/emoticon-smile.png"),
m_emoticon_wink("/usr/palm/emoticons/emoticon-wink.png"),
m_emoticon_yuck("/usr/palm/emoticons/emoticon-yuck.png"),
m_emoticon_gasp("/usr/palm/emoticons/emoticon-gasp.png"),
m_emoticon_heart("/usr/palm/emoticons/emoticon-heart.png"),
m_background("keyboard-bg.png"),
m_white_key("key-white.png"),
m_gray_key("key-gray.png"),
m_black_key("key-black.png"),
m_shift_on_key("key-shift-on.png"),
m_shift_lock_key("key-shift-lock.png"),
m_popup("popup-bg.png"),
m_popup_2("popup-bg-2.png"),
m_popup_key("popup-key.png"),
m_glyphCache(600, 800)
{
if (VERIFY(s_instance == NULL))
s_instance = this;
Q_ASSERT(m_IMEDataInterface);
IMEPixmap::setDefaultLocation("keyboard-phone");
for (int r = 0; r < PhoneKeymap::cKeymapRows; ++r)
m_keymap.setRowHeight(r, m_white_key.height() / 2);
m_presetHeight[0] = 377; // portrait
m_presetHeight[1] = 260; // landscape
connect(&m_IMEDataInterface->m_availableSpace, SIGNAL(valueChanged(const QRect &)), SLOT(availableSpaceChanged(const QRect &)));
connect(&m_IMEDataInterface->m_visible, SIGNAL(valueChanged(const bool &)), SLOT(visibleChanged(const bool &)));
connect(&m_IMEDataInterface->m_editorState, SIGNAL(valueChanged(const PalmIME::EditorState &)), SLOT(editorStateChanged(const PalmIME::EditorState &)));
connect(&m_IMEDataInterface->m_autoCap, SIGNAL(valueChanged(const bool &)), SLOT(autoCapChanged(const bool &)));
connect(&m_timer, SIGNAL(timeout()), this, SLOT(repeatChar()));
m_candidateBar.font().setPixelSize(24);
connect(&m_candidateBar, SIGNAL(needsRedraw()), SLOT(triggerRepaint()));
connect(&m_candidateBar, SIGNAL(resized()), SLOT(candidateBarResized()));
// init size
VirtualKeyboardPreferences::instance().applyInitSettings(this);
}
PhoneKeyboard::~PhoneKeyboard()
{
if (VERIFY(s_instance == this))
s_instance = NULL;
}
void PhoneKeyboard::editorStateChanged(const PalmIME::EditorState & state)
{
bool layoutChanged = false;
if (m_keymap.symbolMode() == PhoneKeymap::eSymbolMode_Lock)
if (m_keymap.setSymbolMode(PhoneKeymap::eSymbolMode_Off))
layoutChanged = true;
if (m_keymap.setEditorState(state))
layoutChanged = true;
m_candidateBar.setEditorState(state);
if (layoutChanged)
keyboardLayoutChanged();
m_shortcutsHandler.resetEditor(state);
}
void PhoneKeyboard::autoCapChanged(const bool & autoCap)
{
if (m_keymap.setAutoCap(autoCap))
keyboardLayoutChanged();
}
void PhoneKeyboard::setShiftMode(PhoneKeymap::EShiftMode shiftMode)
{
if (m_keymap.setShiftMode(shiftMode))
keyboardLayoutChanged();
}
void PhoneKeyboard::setSymbolMode(PhoneKeymap::ESymbolMode symbolMode)
{
if (m_keymap.setSymbolMode(symbolMode))
keyboardLayoutChanged();
}
void PhoneKeyboard::setKeyboardCombo(const std::string & layoutName, const std::string & languageName, bool showLanguageKey)
{
const PhoneKeymap::LayoutFamily * layoutFamily = PhoneKeymap::LayoutFamily::findLayoutFamily(layoutName.c_str(), false); // get default if not found
bool changed = false;
if (m_keymap.setLayoutFamily(layoutFamily))
{
changed = true;
KeyLocationRecorder::instance().keyboardSizeChanged(m_keymap.layoutName(), m_keymap.rect());
}
syncKeymap();
if (m_keymap.setLanguageName(showLanguageKey ? languageName : ""))
changed = true;
m_candidateBar.setLanguage(languageName);
if (changed)
keyboardLayoutChanged();
}
void PhoneKeyboard::syncKeymap()
{
if (m_keymap.layoutFamily() != m_generatedKeymapLayout)
{
if (VERIFY(m_keymap.generateKeyboardLayout(IME_KDB_XML_FILENAME)))
m_generatedKeymapLayout = m_keymap.layoutFamily();
else
m_generatedKeymapLayout = NULL;
m_candidateBarLayoutOutdated = true;
}
if (m_candidateBarLayoutOutdated && m_generatedKeymapLayout)
{
if (m_candidateBar.loadKeyboardLayoutFile(IME_KDB_XML_FILENAME, m_generatedKeymapLayout->m_primaryID, m_generatedKeymapLayout->m_secondaryID))
m_candidateBarLayoutOutdated = false;
}
}
void PhoneKeyboard::showSuggestions(bool show)
{
m_candidateBar.setEnabled(show);
if (show)
{
m_candidateBarLayoutOutdated = true;
syncKeymap();
keyboardLayoutChanged();
VirtualKeyboardPreferences::instance().activateCombo(); // for language update...
}
}
void PhoneKeyboard::visibleChanged(const bool & visible)
{
m_candidateBar.clearCandidates();
if (visible)
{
setKeyboardHeight(m_requestedHeight);
}
else
{
m_keymap.setSymbolMode(PhoneKeymap::eSymbolMode_Off);
m_keymap.setShiftMode(PhoneKeymap::eShiftMode_Off);
clearExtendedkeys();
}
}
bool PhoneKeyboard::setBoolOption(const std::string & optionName, bool value)
{
if (optionName == "suggestions")
{
showSuggestions(value);
}
else if (optionName == "popupkeys")
{
m_showPopupKeys = value;
triggerRepaint();
}
else
{
g_warning("PhoneKeyboard::setBoolOption: \"%s\" is not supported.", optionName.c_str());
return false;
}
return true;
}
bool PhoneKeyboard::setIntOption(const std::string & optionName, int value)
{
g_warning("PhoneKeyboard::setIntOption: \"%s\" is not supported.", optionName.c_str());
return false;
}
bool PhoneKeyboard::getValue(const std::string & name, std::string & outValue)
{
if (name == "height")
{
outValue = string_printf("%d", m_requestedHeight);
return true;
}
else if (name == "keyboard_layout")
{
outValue = m_keymap.getKeyboardLayoutAsJson();
return true;
}
else if (name == "autocap")
{
outValue = m_keymap.isAutoCapActive() ? "1" : "0";
return true;
}
return false;
}
void PhoneKeyboard::requestSize(int size)
{
requestHeight(m_presetHeight[inLandscapeOrientation()]);
}
void PhoneKeyboard::requestHeight(int height)
{
m_requestedHeight = height;
setKeyboardHeight(height);
if (height > 0)
queueIdlePrerendering();
}
void PhoneKeyboard::changePresetHeightForSize(int size, int height)
{
bool landscape = (size != 0);
m_presetHeight[landscape] = qBound<int>(10, height, 2 * m_background.height());
if (landscape == inLandscapeOrientation())
requestHeight(height);
}
void PhoneKeyboard::availableSpaceChanged(const QRect & size)
{
m_candidateBar.commit();
m_extendedKeys = NULL;
m_keymap.setRect(0, 0, 0, 0);
m_candidateBar.frame().setRect(0, 0, 0, 0);
m_keyboardTopPading = 0;
// use the height preset for that orientation
m_requestedHeight = m_presetHeight[inLandscapeOrientation()];
setKeyboardHeight(m_requestedHeight);
queueIdlePrerendering();
}
void PhoneKeyboard::setKeyboardHeight(int height, bool notify)
{
const QRect & availableSpace = m_IMEDataInterface->m_availableSpace.get();
int width = availableSpace.width();
int screenHeight = availableSpace.height();
height = qBound<int>(50, height, screenHeight - 28);
if (VERIFY(height > 0))
{
m_keyboardDirty = true;
// assets give us "ideal" non-scaled sizes. Proportionaly adjust m_keyboardTopPading
int fullHeight = m_background.height();
int fullKeymapHeight = PhoneKeymap::cKeymapRows * m_white_key.height() / 2;
if (fullHeight < fullKeymapHeight)
fullHeight = fullKeymapHeight; // if background shorter than assets, stretch background!
int keymapHeight = height * fullKeymapHeight / fullHeight;
m_keyboardTopPading = height - keymapHeight;
if (m_keyboardTopPading < 0)
m_keyboardTopPading = 0;
// PhoneKeymap pushed at the bottom of the available space
m_keymap.setRect(0, availableSpace.height() - keymapHeight, width, keymapHeight);
if (notify)
{
keyboardLayoutChanged();
KeyLocationRecorder::instance().keyboardSizeChanged(m_keymap.layoutName(), m_keymap.rect());
}
int candidateBarHeight = m_candidateBar.enabled() ? m_white_key.height() / 2 : 0;
m_candidateBar.frame().setRect(0, m_keymap.rect().top() - candidateBarHeight - m_keyboardTopPading, width, candidateBarHeight);
//g_debug("PhoneKeyboard::setKeyboardHeight: %d pixels of height, Setting keymap rect to: %d, %d, %dx%d, candidateBar: %d", height, m_keymap.rect().left(), m_keymap.rect().top(), m_keymap.rect().width(), m_keymap.rect().height(), candidateBarHeight);
m_9tileCorner.m_trimV = 0;
m_9tileCorner.m_trimH = 0;
// if (availableSpace.width() < 480)
// m_9tileCorner.m_trimH = 4;
// else if (availableSpace.width() == 480)
// m_9tileCorner.m_trimH = 3;
// else if (keymapHeight >= fullKeymapHeight)
// m_9tileCorner.m_trimH = 0;
// else
// {
// m_9tileCorner.m_trimH = (fullKeymapHeight - keymapHeight) / 40;
// if (m_9tileCorner.m_trimH > 3)
// m_9tileCorner.m_trimH = 3;
// }
//g_critical("9Tile Shrink: %g-%g (%d)", m_9tileCorner.m_trimH, m_9tileCorner.m_trimV, fullKeymapHeight - keymapHeight);
}
else
g_debug("PhoneKeyboard::setKeyboardHeight: FAILED! height: %d, requestedHeight: %d, portrait: %d, landscape %d, background height: %d, keyboard height: %d, available: %d-%d %dx%d.", height, m_requestedHeight,
m_presetHeight[0], m_presetHeight[1], m_background.height(),
m_keymap.rect().height() + m_keyboardTopPading + m_candidateBar.frame().height(), availableSpace.x(), availableSpace.y(), availableSpace.width(), availableSpace.height());
if (notify)
m_IMEDataInterface->m_keyboardHeight.set(m_keymap.rect().height() + m_keyboardTopPading + m_candidateBar.frame().height());
}
void PhoneKeyboard::keyboardLayoutChanged()
{
if (!m_keyboardDirty && m_IMEDataInterface->m_visible.get())
{
m_keyboardDirty = true;
triggerRepaint();
}
m_candidateBar.updateKeyboardLayout(m_keymap.layoutName(), m_keymap.getPage(), m_keymap.rect(), m_keymap.isShiftActive(), m_keymap.isCapsLocked(), m_keymap.isAutoCapActive());
}
void PhoneKeyboard::clearExtendedkeys()
{
if (m_extendedKeys)
{
m_extendedKeys = 0;
m_IMEDataInterface->m_hitRegion.set(QRegion());
if (m_IMEDataInterface->m_visible.get())
triggerRepaint();
}
else if (!m_IMEDataInterface->m_hitRegion.get().isEmpty())
m_IMEDataInterface->m_hitRegion.set(QRegion()); // defensive...
triggerRepaint();
}
void PhoneKeyboard::releaseTouch(int id)
{
Touch & touch = m_touches[id];
#if DEBUG_TOUCH
g_debug("PhoneKeyboard::releaseTouch: '%s', consumed: %d, visible: %d", QString(m_keymap.map(touch.m_keyCoordinate)).toUtf8().data(), touch.m_consumed, touch.m_visible);
#endif
if (m_candidateBar.endTrace(id))
{
triggerRepaint();
}
else if (m_extendedKeys)
{
UKey key;
if (!pointToExtendedPopup(touch.m_lastPosition, key))
{
key = m_keymap.map(touch.m_keyCoordinate);
if (key == Qt::Key_Shift || key == cKey_Symbol)
handleKey(key, touch.m_lastPosition);
else if (!setExtendedKeys(touch.m_keyCoordinate, true) && !touch.m_consumed)
clearExtendedkeys();
else
triggerRepaint();
}
else
{
if (key != cKey_None)
{
g_debug("Extended character selected: %s", QString(m_keymap.getKeyDisplayString(key, true)).toUtf8().data());
handleKey(key, QPointF());
}
clearExtendedkeys();
}
}
else if (touch.m_inCandidateBar)
{
m_candidateBar.releaseTouch(touch.m_lastPosition.x() - touch.m_firstPosition.x());
}
else if (m_keymap.isValidLocation(touch.m_keyCoordinate))
{
bool sendKey = touch.m_visible && !touch.m_consumed;
UKey key = m_keymap.map(touch.m_keyCoordinate);
if (key == cKey_Symbol)
setSymbolKeyDown(false);
else if (key == Qt::Key_Shift)
setShiftKeyDown(false);
else
{
touch.m_visible = false; // the key is no longer considered pressed...
touch.m_consumed = true;
if (m_shiftDown || m_symbolDown)
{ // we are sending the key, which means we are "using" the shift or symbol keypress: when these are released, they are NOT sent out/used again.
for (std::map<int, Touch>::iterator iter = m_touches.begin(); iter != m_touches.end(); ++iter)
{
if (iter->first != id)
{
Touch & touch = iter->second;
UKey key = m_keymap.map(touch.m_keyCoordinate);
if (key == cKey_Symbol || key == Qt::Key_Shift)
touch.m_consumed = true;
}
}
}
}
if (sendKey)
handleKey(key, touch.m_lastPosition);
triggerRepaint();
if (touch.m_keyCoordinate == m_repeatKey)
stopRepeat();
}
}
inline int Min(int a, int b) { return a < b ? a : b; }
inline int MinMax(int min, int v, int max) { return v < min ? min : (v < max ? v : max); }
void PhoneKeyboard::updateTouch(int id, QPointF position)
{
uint64_t now = CURRENT_TIME;
QPointF touchPosition(position.x(), position.y() - m_keymap.rect().top());
UKey extendedKey;
QPoint keyCoordinate = (!pointToExtendedPopup(touchPosition, extendedKey) && position.y() > m_keymap.rect().top() - m_keyboardTopPading) ? m_keymap.pointToKeyboard(position.toPoint()) : cOutside;
bool newTouch = m_touches.find(id) == m_touches.end();
Touch & touch = m_touches[id];
bool inCandidatebar = m_candidateBar.frame().contains(position.x(), position.y());
UKey newKey = m_keymap.map(keyCoordinate);
if (newTouch)
{
touch.m_firstPosition = touchPosition;
touch.m_lastPosition = touchPosition;
touch.m_inCandidateBar = inCandidatebar;
}
//g_debug("Touch bar: %d, %gx%g", inCandidatebar, position.x(), position.y());
if (extendedKey != cKey_None)
{
if (newTouch)
makeSound(extendedKey);
if (extendedKey != m_extendedKeyShown || (touch.m_visible && touch.m_keyCoordinate != keyCoordinate))
triggerRepaint();
}
else if (!m_extendedKeys && newTouch && m_touches.size() == 1 && QChar(newKey).isLetter() && m_candidateBar.tracePoint(touchPosition.toPoint(), newKey, id, true))
{
}
else if (!m_extendedKeys && !newTouch && m_candidateBar.tracePoint(touchPosition.toPoint(), newKey, id, false))
{
stopRepeat();
}
else if (newTouch ||
(!touch.m_inCandidateBar && touch.m_keyCoordinate != keyCoordinate) ||
(touch.m_inCandidateBar && inCandidatebar))
{
triggerRepaint();
if (touch.m_inCandidateBar)
{
m_candidateBar.setScrollOffset(m_candidateBar.scrollOffset() + position.x() - touch.m_lastPosition.x());
//g_debug("Candidate bar offset: %d", m_candidateBar.scrollOffset());
}
else
{
#if DEBUG_TOUCH
g_debug("%s key '%s', consumed: %d, visible: %d", newTouch ? "New" : "Moved", m_keymap.getKeyDisplayString(newKey, true).toUtf8().data(), touch.m_consumed, touch.m_visible);
#endif
if (touch.m_visible && !touch.m_consumed)
{
if (keyCoordinate != m_repeatKey)
{
if (newTouch && newKey == cKey_Emoticon_Options)
{
if (!setExtendedKeys(keyCoordinate, true))
m_extendedKeys = NULL;
touch.m_consumed = true;
stopRepeat();
}
else if (newTouch && (canRepeat(newKey) || m_keymap.getExtendedChars(keyCoordinate) || (newKey == cKey_Hide && m_touches.size() == 1)))
{
m_timer.start(newKey == cKey_Hide || m_candidateBar.isTraceActive() ? cFirstRepeatLongDelay : cFirstRepeatDelay);
m_repeatKey = keyCoordinate;
m_repeatStartTime = CURRENT_TIME;
}
else
stopRepeat();
}
}
if (newTouch)
{ // send pressed keys not already sent out...
makeSound(newKey);
for (std::map<int, Touch>::iterator iter = m_touches.begin(); iter != m_touches.end(); ++iter)
{
if (iter->first != id && !touch.m_inCandidateBar)
{
Touch & othertouch = iter->second;
if (othertouch.m_visible)
{
UKey key = m_keymap.map(othertouch.m_keyCoordinate);
if (key != cKey_Symbol && key != Qt::Key_Shift && key != cKey_Hide && !othertouch.m_consumed)
{
#if DEBUG_TOUCH
g_debug("Consumming pressed key '%s', consumed: %d, visible: %d", m_keymap.getKeyDisplayString(key, true).toUtf8().data(), touch.m_consumed, touch.m_visible);
#endif
handleKey(key, othertouch.m_lastPosition);
othertouch.m_visible = false;
}
othertouch.m_consumed = true;
}
}
}
}
if (touch.m_visible && ((newKey == cKey_Symbol && !m_extendedKeys && setSymbolKeyDown(true)) || (newKey == Qt::Key_Shift && setShiftKeyDown(true))))
{
if (m_extendedKeys)
touch.m_consumed = true;
}
}
}
touch.m_keyCoordinate = keyCoordinate;
if (m_extendedKeys && touch.m_visible != (extendedKey == cKey_None))
{ // show keyboard key when NOT on the extended bar
touch.m_visible = !touch.m_visible;
triggerRepaint();
}
touch.m_lastPosition = touchPosition;
touch.m_lastTouchTime = now;
}
void PhoneKeyboard::handleKey(UKey key, QPointF where)
{
//g_debug("PhoneKeyboard::handleKey: '%s'", QString(key).toUtf8().data());
PhoneKeymap::EShiftMode shiftMode = m_keymap.shiftMode();
PhoneKeymap::ESymbolMode symbolMode = m_keymap.symbolMode();
bool consumeMode = false;
bool commit = false;
bool sendKey = true;
Qt::Key qtkey = Qt::Key_unknown;
if (UKeyIsUnicodeQtKey(key))
{
qtkey = Qt::Key(key); // "normal" case: UKey is also a valid Qt::Key
if (m_candidateBar.enabled())
{
if (QChar(key).isLetter())
sendKey = !m_candidateBar.keyboardTap(where, key);
else
commit = true;
}
else
{
sendKey = true;
}
}
else if (UKeyIsTextShortcutKey(key))
{
commit = true;
qtkey = key;
}
else if (UKeyIsKeyboardComboKey(key))
{
int index = key - cKey_KeyboardComboChoice_First;
VirtualKeyboardPreferences::instance().selectKeyboardCombo(index);
}
else
{
switch ((int)key)
{
case Qt::Key_Backspace:
qtkey = Qt::Key_Backspace;
sendKey = !m_candidateBar.backspace(m_keymap.isShiftDown());
break;
case Qt::Key_Return:
qtkey = key;
commit = true;
break;
case cKey_SymbolPicker:
qtkey = Qt::Key_Control;
break;
case cKey_Symbol:
if (m_extendedKeys)
clearExtendedkeys();
else if (m_keymap.symbolMode() == PhoneKeymap::eSymbolMode_Lock)
symbolMode = PhoneKeymap::eSymbolMode_Off;
else
symbolMode = PhoneKeymap::eSymbolMode_Lock, shiftMode = PhoneKeymap::eShiftMode_Off;
break;
case Qt::Key_Shift:
{
uint64_t now = CURRENT_TIME;
if (m_lastUnlockTime + DOUBLE_TAP_DURATION > now)
{ // quick tap after unlocking: eat that tap, and next tap is like nothing happened before...
m_lastUnlockTime = 0;
now = 0;
}
else if (m_lastShiftTime + DOUBLE_TAP_DURATION > now)
shiftMode = PhoneKeymap::eShiftMode_CapsLock;
else if (shiftMode == PhoneKeymap::eShiftMode_CapsLock)
{
shiftMode = PhoneKeymap::eShiftMode_Off;
m_lastUnlockTime = now;
}
else if (shiftMode == PhoneKeymap::eShiftMode_Off)
shiftMode = PhoneKeymap::eShiftMode_Once;
else
shiftMode = PhoneKeymap::eShiftMode_Off;
m_lastShiftTime = now;
autoCapChanged(false);
break;
}
case cKey_Hide:
m_IMEDataInterface->requestHide();
break;
case cKey_ToggleSuggestions:
showSuggestions(!m_candidateBar.enabled());
break;
case cKey_ShowXT9Regions:
{
PerfMonitor regionMonitor("showXT9Regions");
m_candidateBar.drawXT9Regions(m_keyboardBackgound, m_keyboardTopPading);
triggerRepaint();
break;
}
case cKey_ShowKeymapRegions:
showKeymapRegions();
triggerRepaint();
break;
case cKey_SwitchToQwerty:
VirtualKeyboardPreferences::instance().selectLayoutCombo("qwerty");
break;
case cKey_SwitchToAzerty:
VirtualKeyboardPreferences::instance().selectLayoutCombo("azerty");
break;
case cKey_SwitchToQwertz:
VirtualKeyboardPreferences::instance().selectLayoutCombo("qwertz");
break;
case cKey_StartStopRecording:
{
bool wasRecording = KeyLocationRecorder::instance().isRecording();
KeyLocationRecorder::instance().startStop(m_keymap.layoutName(), m_keymap.rect());
if (KeyLocationRecorder::instance().isRecording())
{
sendKeyDownUp(Qt::Key_Space, Qt::NoModifier);
sendKeyDownUp(Qt::Key_Backspace, Qt::NoModifier);
}
break;
}
case cKey_ToggleLanguage:
VirtualKeyboardPreferences::instance().selectNextKeyboardCombo();
break;
case cKey_CreateDefaultKeyboards:
VirtualKeyboardPreferences::instance().createDefaultKeyboards();
break;
case cKey_ClearDefaultKeyboards:
VirtualKeyboardPreferences::instance().clearDefaultDeyboards();
break;
case cKey_ToggleSoundFeedback:
VirtualKeyboardPreferences::instance().setTapSounds(!VirtualKeyboardPreferences::instance().getTapSounds());
break;
case Qt::Key_Left:
qtkey = Qt::Key_Left; // used to navigate the cursor left
break;
case Qt::Key_Right:
qtkey = Qt::Key_Right; // used to navigate the cursor right
break;
case Qt::Key_Tab:
switch (m_keymap.tabAction())
{
case PhoneKeymap::eTabAction_Next:
m_IMEDataInterface->performEditorAction(PalmIME::FieldAction_Next);
break;
case PhoneKeymap::eTabAction_Previous:
m_IMEDataInterface->performEditorAction(PalmIME::FieldAction_Previous);
break;
case PhoneKeymap::eTabAction_Tab:
default:
qtkey = Qt::Key_Tab;
}
break;
default:
break;
}
}
if (qtkey != Qt::Key_unknown)
{
if (commit)
m_candidateBar.commit();
consumeMode = true;
if (sendKey)
{
if (KeyLocationRecorder::instance().isRecording())
KeyLocationRecorder::instance().record(m_keymap.getKeyDisplayString(key, true), where.toPoint());
if (UKeyIsTextShortcutKey(key))
{
m_IMEDataInterface->commitText(m_keymap.getKeyDisplayString(key).toUtf8().data());
m_shortcutsHandler.resetEditor();
}
else if (m_shortcutsHandler.filterKey(qtkey))
{
if (UKeyIsFunctionKey(qtkey))
{
if (qtkey == Qt::Key_Tab)
m_IMEDataInterface->commitText("\t");
else
sendKeyDownUp(qtkey, m_keymap.isShiftDown() ? Qt::ShiftModifier : Qt::NoModifier);
}
else if (qtkey > 0 && qtkey < 128)
sendKeyDownUp(qtkey, m_keymap.isCapActive() ? Qt::ShiftModifier : Qt::NoModifier); // send as basic keystroke
else if (m_keymap.isCapActive())
sendKeyDownUp((Qt::Key) QChar(qtkey).toUpper().unicode(), Qt::ShiftModifier);
else
sendKeyDownUp((Qt::Key) QChar(qtkey).toLower().unicode(), Qt::NoModifier);
}
}
else
m_shortcutsHandler.resetEditor();
if (qtkey == Qt::Key_Space || qtkey == Qt::Key_Return)
symbolMode = PhoneKeymap::eSymbolMode_Off;
}
if (consumeMode)
{
if (m_keymap.shiftMode() == PhoneKeymap::eShiftMode_Once)
shiftMode = PhoneKeymap::eShiftMode_Off;
}
if (m_keymap.shiftMode() != shiftMode)
setShiftMode(shiftMode);
if (m_keymap.symbolMode() != symbolMode)
setSymbolMode(symbolMode);
}
void PhoneKeyboard::sendKeyDownUp(Qt::Key key, Qt::KeyboardModifiers modifiers)
{
if (m_IMEDataInterface) {
m_IMEDataInterface->sendKeyEvent(QEvent::KeyPress, key, modifiers);
m_IMEDataInterface->sendKeyEvent(QEvent::KeyRelease, key, modifiers);
}
}
inline const char * touchPointState(Qt::TouchPointState state)
{
switch (state)
{
case Qt::TouchPointPressed: return "pressed";
case Qt::TouchPointMoved: return "moved";
case Qt::TouchPointStationary: return "stationary";
case Qt::TouchPointReleased: return "released";
default: return "<unknown>";
}
}
void PhoneKeyboard::touchEvent(const QTouchEvent& te)
{
if (m_IMEDataInterface)
{
const QList<QTouchEvent::TouchPoint> & touchPoints = te.touchPoints();
#if DEBUG_TOUCH
std::string str;
for (QList<QTouchEvent::TouchPoint>::ConstIterator iter = touchPoints.constBegin(); iter != touchPoints.constEnd(); ++iter)
{
const QTouchEvent::TouchPoint & touchPoint = *iter;
QPoint keyPos = m_keymap.pointToKeyboard(touchPoint.pos().toPoint());
Qt::Key key = m_keymap.map(keyPos);
::append_format(str, " Id: %d, location: %gx%g %s, Key: %dx%d = '%s'.\n", touchPoint.id(), touchPoint.pos().x(), touchPoint.pos().y(), touchPointState(touchPoint.state()), keyPos.x(), keyPos.y(), m_keymap.getKeyDisplayString(key, true).toUtf8().data());
}
g_debug("TouchEvent: \n%s", str.c_str());
#endif
if (m_IMEDataInterface->m_visible.get())
{
// handle new presses after handling release & moves
bool presses = false;
for (QList<QTouchEvent::TouchPoint>::ConstIterator iter = touchPoints.constBegin(); iter != touchPoints.constEnd(); ++iter)
{
const QTouchEvent::TouchPoint & touchPoint = *iter;
Qt::TouchPointState state = touchPoint.state();
if (state == Qt::TouchPointReleased)
{
releaseTouch(touchPoint.id());
m_touches.erase(touchPoint.id());
}
else if (state == Qt::TouchPointMoved)
updateTouch(touchPoint.id(), touchPoint.pos());
else if (state == Qt::TouchPointPressed)
presses = true;
}
if (presses)
{
for (QList<QTouchEvent::TouchPoint>::ConstIterator iter = touchPoints.constBegin(); iter != touchPoints.constEnd(); ++iter)
{
const QTouchEvent::TouchPoint & touchPoint = *iter;
if (touchPoint.state() == Qt::TouchPointPressed)
updateTouch(touchPoint.id(), touchPoint.pos());
}
}
}
else
g_warning("TabletKeyboard::touchEvent: hidden (probably being hidden...), so we will ignore these touches.");
// everything is released: make sure we have nothing left in our records...
if (te.type() == QEvent::TouchEnd)
{
if (m_touches.size() > 0)
{
if (m_IMEDataInterface->m_visible.get())
g_critical("Clearing %u non-finished touches!", m_touches.size());
for (QList<QTouchEvent::TouchPoint>::ConstIterator iter = touchPoints.constBegin(); iter != touchPoints.constEnd(); ++iter)
m_candidateBar.endTrace(iter->id());
m_touches.clear();
}
stopRepeat();
setShiftKeyDown(false);
setSymbolKeyDown(false);
}
}
}
void PhoneKeyboard::tapEvent(const QPoint& tapPt)
{
#if DEBUG_TOUCH
g_debug("tapEvent: %d, %d", tapPt.x(), tapPt.y());
#endif
m_candidateBar.tapEvent(tapPt);
}
void PhoneKeyboard::screenEdgeFlickEvent()
{
// Mark all touches as consumed
for (std::map<int, Touch>::iterator iter = m_touches.begin(); iter != m_touches.end(); ++iter) {
iter->second.m_consumed = true;
}
}
void PhoneKeyboard::repeatChar()
{
if (PhoneKeymap::isValidLocation(m_repeatKey))
{
UKey key = m_keymap.map(m_repeatKey);
if (canRepeat(key))
{
makeSound(key);
bool wordDelete = m_keymap.isShiftDown() || (CURRENT_TIME - m_repeatStartTime > cWordDeleteDelay);
if (key == Qt::Key_Backspace)
sendKeyDownUp(Qt::Key_Backspace, wordDelete ? Qt::ShiftModifier : Qt::NoModifier);
else
sendKeyDownUp(Qt::Key(key), m_keymap.isCapActive() ? Qt::ShiftModifier : Qt::NoModifier);
int repeatInterval = wordDelete ? cWordDeleteRepeatDelay : cLetterDeleteRepeatDelay;
if (m_timer.interval() != repeatInterval)
m_timer.setInterval(repeatInterval);
}
else
{
if (setExtendedKeys(m_repeatKey))
{
for (std::map<int, Touch>::iterator iter = m_touches.begin(); iter != m_touches.end(); ++iter)
{
Touch & touch = iter->second;
if (touch.m_keyCoordinate == m_repeatKey)
touch.m_consumed = true;
}
}
stopRepeat();
}
}
else
stopRepeat();
}
bool PhoneKeyboard::setExtendedKeys(QPoint keyCoord, bool cancelIfSame)
{
const UKey * newExtended = m_keymap.getExtendedChars(keyCoord);
if (cancelIfSame && newExtended == m_extendedKeys)
return false;
m_extendedKeys = newExtended;
if (m_extendedKeys)
{
int cellCount, lineCount, lineLength;
getExtendedPopupSpec(cellCount, lineCount, lineLength);
IMEPixmap & popup = (lineCount > 1) ? m_popup_2 : m_popup;
m_extendedKeyShown = cKey_None;
m_keymap.keyboardToKeyZone(keyCoord, m_extendedKeysFrame);
m_extendedKeysPointer = m_extendedKeysFrame.left() + m_extendedKeysFrame.width() / 2;
m_extendedKeysFrame.translate(0, -popup.height() + 10);
int width = cPopupLeftSide + cPopupRightSide + lineLength * m_popup_key.width();
m_extendedKeysFrame.setLeft(m_extendedKeysPointer - m_popup_key.width() / 2 - cPopupLeftSide);
m_extendedKeysFrame.setWidth(width);
m_extendedKeysFrame.setHeight(popup.height());
if (m_extendedKeysFrame.left() < 0)
m_extendedKeysFrame.moveLeft(0);
else if (m_extendedKeysFrame.right() > m_keymap.rect().right())
m_extendedKeysFrame.translate(m_keymap.rect().right() - m_extendedKeysFrame.right(), 0);
if (m_extendedKeysFrame.isValid())
{
m_IMEDataInterface->m_hitRegion.set(QRegion(m_IMEDataInterface->m_availableSpace.get()));
triggerRepaint();
}
return true;
}
else
m_IMEDataInterface->m_hitRegion.set(QRegion());
return false;
}
bool PhoneKeyboard::pointToExtendedPopup(QPointF position, UKey & outKey)
{
outKey = cKey_None;
if (m_extendedKeys && m_extendedKeysFrame.contains(position.x(), position.y() + m_keymap.rect().top()))
{
QPoint where = position.toPoint() - m_extendedKeysFrame.topLeft() - QPoint(cPopupLeftSide, -m_keymap.rect().top() + cPopupTopToKey);
int cellCount, lineCount, lineLength;
getExtendedPopupSpec(cellCount, lineCount, lineLength);
int x = qMin<int>(where.x() / m_popup_key.width(), lineLength - 1);
int y = where.y() / (m_popup_key.height() / 2);
int index = (y == 0) ? x : x + lineLength;
if (index <= cellCount)
outKey = m_extendedKeys[index];
return true;
}
return false;
}
void PhoneKeyboard::getExtendedPopupSpec(int & outCellCount, int & outLineCount, int & outLineLength)
{
outCellCount = 0;
if (m_extendedKeys)
while (m_extendedKeys[outCellCount] != cKey_None)
++outCellCount;
outLineCount = (outCellCount > cPopupSingleLineMax) ? 2 : 1;
outLineLength = (outCellCount + outLineCount - 1) / outLineCount;
}
bool PhoneKeyboard::canRepeat(UKey key) const
{
return (key == Qt::Key_Space || key == Qt::Key_Backspace || key == Qt::Key_Left || key == Qt::Key_Right);
}
void PhoneKeyboard::stopRepeat()
{
m_timer.stop();
m_repeatKey = cOutside;
m_repeatStartTime = 0;
}
void PhoneKeyboard::showKeymapRegions()
{
PerfMonitor regionMonitor("showKeymapRegions");
m_keyboardBackgound->fill(QColor(0, 0, 0));
QRect frame = m_keymap.rect();
QPainter painter(m_keyboardBackgound);
int y_offset = frame.top() - m_keyboardTopPading;
ColorMap colorMap;
for (int x = 0; x < frame.width(); ++x)
for (int y = 0; y < m_keyboardTopPading + frame.height(); ++y)
{
QPoint keycoord = m_keymap.pointToKeyboard(QPoint(x, y_offset + y));
if (keycoord != cOutside)
{
painter.setPen(colorMap[QChar(m_keymap.map(keycoord)).unicode()]); // create or reuse random color for this character
painter.drawPoint(x, y);
}
}
m_keyboardDirty = true;
}
void PhoneKeyboard::paint(QPainter & painter)
{
PerfMonitor perf("PhoneKeyboard::paint");
m_candidateBar.paint(painter, cBlueColor);
const QRect & keymapRect = m_keymap.rect();
QRect keyboardFrame(keymapRect.left(), keymapRect.top() - m_keyboardTopPading, keymapRect.width(), keymapRect.height() + m_keyboardTopPading);
if (updateBackground())
perf.trace("background rebuilt");
painter.setCompositionMode(QPainter::CompositionMode_Source);
painter.drawPixmap(QPointF(keyboardFrame.left(), keyboardFrame.top()), *m_keyboardBackgound);
painter.setCompositionMode(QPainter::CompositionMode_SourceOver);
perf.trace("Draw background");
DoubleDrawRenderer doubleDrawRenderer;
CachedGlyphRenderer<GlyphSpec> renderer(painter, m_glyphCache, doubleDrawRenderer, PhoneKeymap::cKeymapColumns * (PhoneKeymap::cKeymapRows + 1));
for (int y = 0; y < PhoneKeymap::cKeymapRows; ++y)
{
for (int x = 0; x < PhoneKeymap::cKeymapColumns; ++x)
{
QPoint keyCoord(x, y);
UKey plainKey = m_keymap.map(x, y, PhoneKeymap::eLayoutPage_plain);
QRect r;
int count = m_keymap.keyboardToKeyZone(keyCoord, r);
if (count > 0 && plainKey != cKey_None)
{
UKey key = m_keymap.map(x, y);
// if (key == Qt::Key_Shift)
// drawKeyBackground(painter, r, keyCoord, key, false, count);
drawKeyCap(&painter, renderer, r, keyCoord, key, eUse_unpressed);
}
}
}
bool extendedKeysShown = m_extendedKeys && m_extendedKeysFrame.isValid();
QRect r;
if (extendedKeysShown)
{
for (int y = 0; y < PhoneKeymap::cKeymapRows; ++y) // draw caps second (faster to split)
{
for (int x = 0; x < PhoneKeymap::cKeymapColumns; ++x)
{
if (m_keymap.getExtendedChars(QPoint(x, y)) && m_keymap.keyboardToKeyZone(QPoint(x, y), r) > 0)
{
r.setWidth(r.width() - 9 + m_9tileCorner.m_trimH); r.setHeight(r.height() - 9 + m_9tileCorner.m_trimV);
renderer.render(r, GlyphSpec(sElipsis, cElipsisFontSize, false, cActiveColor, cActiveColor_back), sFont, Qt::AlignRight | Qt::AlignBottom);
}
}
}
}
renderer.flush();
perf.trace("Draw labels");
UKey extendedKey = cKey_None;
for (std::map<int, Touch>::iterator iter = m_touches.begin(); iter != m_touches.end(); ++iter)
{
Touch & touch = iter->second;
if (!pointToExtendedPopup(touch.m_lastPosition, extendedKey))
{
if (touch.m_visible)
{
int count = m_keymap.keyboardToKeyZone(touch.m_keyCoordinate, r);
if (count > 0)
{
UKey key = m_keymap.map(touch.m_keyCoordinate);
if (key != cKey_None)
{
painter.setClipRect(r);
painter.drawPixmap(r.left(), keyboardFrame.top(), r.width(), keyboardFrame.height(), m_background.pixmap());
painter.setClipping(false);
drawKeyBackground(painter, r, touch.m_keyCoordinate, key, true, count);
drawKeyCap(&painter, renderer, r, touch.m_keyCoordinate, key, eUse_pressed);
if (extendedKeysShown && m_keymap.getExtendedChars(touch.m_keyCoordinate))
{
QRect elipsisRect(r.left() + cPressedTranslateH, r.top() + cPressedTranslateV, r.width() - 9 + m_9tileCorner.m_trimH, r.height() - 9 + m_9tileCorner.m_trimV);
renderer.render(elipsisRect, GlyphSpec(sElipsis, cElipsisFontSize, false, cActiveColor, cActiveColor_back), sFont, Qt::AlignRight | Qt::AlignBottom);
}
if (!m_extendedKeys && m_showPopupKeys && key != Qt::Key_Shift && key != cKey_Symbol && key != Qt::Key_Space && key != Qt::Key_Return && key != Qt::Key_Backspace)
{
QPoint topLeft((r.left() + r.right() - m_popup.width()) / 2, r.top() - m_popup.height());
painter.drawPixmap(topLeft, m_popup);
QRect destRect(topLeft + QPoint((m_popup.width() - m_popup_key.width()) / 2, cPopupTopToKey), QSize(m_popup_key.width(), m_popup_key.height() / 2));
painter.drawPixmap(destRect.topLeft(), m_popup_key, QRect(0, m_popup_key.height() / 2, destRect.width(), destRect.height()));
drawKeyCap(&painter, renderer, destRect, touch.m_keyCoordinate, key, eUse_preview);
}
//g_debug("'%s' drawn pressed, consumed: %d", QString(key).toUtf8().data(), touch.m_consumed);
}
}
}
}
}
renderer.flush();
m_candidateBar.paintTrace(painter, keyboardFrame.top() + m_keyboardTopPading, cBlueColor, 4);
if (extendedKeysShown)
{
renderer.flush();
painter.setFont(sFont);
int cellCount, lineCount, lineLength;
getExtendedPopupSpec(cellCount, lineCount, lineLength);
IMEPixmap & popup = (lineCount > 1) ? m_popup_2 : m_popup;
QRect r(m_extendedKeysFrame);
int left = r.left() + cPopupSide;
int right = r.right() - cPopupSide + 1;
painter.drawPixmap(r.left(), r.top(), popup.pixmap(), 0, 0, cPopupSide, popup.height());
painter.drawPixmap(right, r.top(), popup.pixmap(), popup.width() - cPopupSide, 0, cPopupSide, popup.height());
int pointerLeft = m_extendedKeysPointer - cPopupPointerWidth / 2;
int pointerRight = pointerLeft + cPopupPointerWidth;
if (left < pointerLeft)
painter.drawPixmap(left, r.top(), pointerLeft - left, popup.height(), popup.pixmap(), cPopupSide, 0, 1, popup.height());
if (pointerRight < right)
painter.drawPixmap(pointerRight, r.top(), right - pointerRight, popup.height(), popup.pixmap(), cPopupSide, 0, 1, popup.height());
painter.drawPixmap(pointerLeft, r.top(), popup.pixmap(), cPopupPointerStart, 0, cPopupPointerWidth, popup.height());
r.translate(cPopupLeftSide, cPopupTopToKey);
UKey key;
for (int k = 0; (key = m_extendedKeys[k]) != cKey_None; ++k)
{
if (k < lineLength)
painter.drawPixmap(r.left() + k * m_popup_key.width(), r.top(), m_popup_key.pixmap(),
0, (extendedKey == key) ? m_popup_key.height() / 2 : 0, m_popup_key.width(), m_popup_key.height() / 2);
else
painter.drawPixmap(r.left() + (k - lineLength) * m_popup_key.width(), r.top() + m_popup_2.height() - m_popup.height(), m_popup_key.pixmap(),
0, (extendedKey == key) ? m_popup_key.height() / 2 : 0, m_popup_key.width(), m_popup_key.height() / 2);
}
r.setWidth(m_popup_key.width() - 3);
r.setHeight(m_popup_key.height() / 2 - 2);
QRect cell(r);
for (int k = 0; (key = m_extendedKeys[k]) != cKey_None; ++k)
{
if (k < lineLength)
cell.moveTopLeft(QPoint(r.left() + k * m_popup_key.width(), r.top()));
else
cell.moveTopLeft(QPoint(r.left() + (k - lineLength) * m_popup_key.width(), r.top() + m_popup_2.height() - m_popup.height()));
QPixmap * pix = (UKeyIsEmoticonKey(key) && m_keymap.showEmoticonsAsGraphics()) ? getPixmapForKey(key) : NULL;
if (pix)
{
drawCenteredPixmap(painter, *pix, cell);
}
else
{
QString text = m_keymap.getKeyDisplayString(key);
int fontSize = (text.length() < 6) ? cPopupFontSize : cPopupFontSize - 8;
if (sFont.pixelSize() != fontSize)
{
sFont.setPixelSize(fontSize);
painter.setFont(sFont);
}
renderer.render(cell, GlyphSpec(text, fontSize, false, cPopoutTextColor, cPopoutTextColor_back), sFont);
}
}
}
m_extendedKeyShown = extendedKey;
#if VKB_SHOW_GLYPH_CACHE
painter.setPen(QColor(255, 0, 0)); painter.drawRect(QRect(QPoint(0, 0), m_glyphCache.pixmap().size())); painter.drawPixmap(0, 0, m_glyphCache.pixmap());
#endif
#if VKB_FORCE_FPS
triggerRepaint();
#endif
if (renderer.getCacheMissCount() > 0 && m_keymap.getCachedGlyphsCount() < 3)
queueIdlePrerendering();
}
bool PhoneKeyboard::updateBackground()
{
if (!m_keyboardBackgound || m_keyboardDirty)
{
QRect keymapFrame(m_keymap.rect());
int width = keymapFrame.width();
int usedHeight = keymapFrame.height() + m_keyboardTopPading;
QRect keyboardFrame(keymapFrame.left(), keymapFrame.top() - m_keyboardTopPading, width, usedHeight);
if (!m_keyboardBackgound || m_keyboardBackgound->width() != width || m_keyboardBackgound->height() != usedHeight)
{
PixmapCache::instance().dispose(m_keyboardBackgound);
m_keyboardBackgound = PixmapCache::instance().get(width, usedHeight);
}
if (m_keymap.updateLimits() != m_keyboardLimitsVersion)
{
//g_critical("Rebuilding BACKGROUND");
m_keyboardLimitsVersion = m_keymap.updateLimits();
QPainter offscreenPainter(m_keyboardBackgound);
//m_keyboardBackgound->fill(QColor(255, 0, 0));
offscreenPainter.drawPixmap(QRect(0, 0, width, usedHeight), m_background.pixmap());
offscreenPainter.translate(0, -keyboardFrame.top());
offscreenPainter.setRenderHints(cRenderHints, true);
m_nineTileSprites.reserve(true);
for (int y = 0; y < PhoneKeymap::cKeymapRows; ++y)
{
for (int x = 0; x < PhoneKeymap::cKeymapColumns; ++x)
{
QPoint keyCoord(x, y);
UKey key = m_keymap.map(x, y);
QRect r;
int count = m_keymap.keyboardToKeyZone(keyCoord, r);
if (count > 0)
{
QSize size = r.size();
if (key == Qt::Key_Shift)
{
m_nineTileSprites.reserve(size, count, m_shift_on_key);
m_nineTileSprites.reserve(size, count, m_shift_lock_key);
m_nineTileSprites.reserve(size, count, m_black_key);
}
else
m_nineTileSprites.reserve(size, count, getKeyBackground(keyCoord, key));
}
}
}
m_nineTileSprites.reserve(false);
for (int y = 0; y < PhoneKeymap::cKeymapRows; ++y)
{
for (int x = 0; x < PhoneKeymap::cKeymapColumns; ++x)
{
UKey plainKey = m_keymap.map(x, y, PhoneKeymap::eLayoutPage_plain);
//if (plainKey != Qt::Key_Shift)
{
QPoint keyCoord(x, y);
QRect r;
int count = m_keymap.keyboardToKeyZone(keyCoord, r);
if (count > 0)
drawKeyBackground(offscreenPainter, r, keyCoord, plainKey, false, count);
}
}
}
}
m_keyboardDirty = false;
return true;
}
return false;
}
QPixmap & PhoneKeyboard::getKeyBackground(const QPoint & keyCoord, UKey key)
{
/*
if (key == Qt::Key_Shift)
{
switch (m_keymap.shiftMode())
{
case PhoneKeymap::eShiftMode_CapsLock: return m_shift_lock_key;
case PhoneKeymap::eShiftMode_Once: return m_shift_on_key;
default:
return m_black_key;
}
}
else
*/
return selectFromKeyType<QPixmap &>(m_keymap.map(keyCoord, PhoneKeymap::eLayoutPage_plain), m_white_key, m_black_key, m_gray_key);
}
QPixmap * PhoneKeyboard::getPixmapForKey(UKey key)
{
switch ((int)key)
{
case Qt::Key_Shift:
switch (m_keymap.shiftMode())
{
case PhoneKeymap::eShiftMode_Once: return &m_shift_on.pixmap(); break;
case PhoneKeymap::eShiftMode_CapsLock: return &m_shift_lock.pixmap(); break;
case PhoneKeymap::eShiftMode_Off:
default:
return m_keymap.isAutoCapActive() ? &m_shift_on.pixmap() : &m_shift.pixmap();
}
break;
case Qt::Key_Backspace: return &m_backspace.pixmap(); break;
case cKey_Hide: return &m_hide.pixmap(); break;
case cKey_Emoticon_Frown: return &m_emoticon_frown.pixmap(); break;
case cKey_Emoticon_Cry: return &m_emoticon_cry.pixmap(); break;
case cKey_Emoticon_Options:
case cKey_Emoticon_Smile: return &m_emoticon_smile.pixmap(); break;
case cKey_Emoticon_Wink: return &m_emoticon_wink.pixmap(); break;
case cKey_Emoticon_Yuck: return &m_emoticon_yuck.pixmap(); break;
case cKey_Emoticon_Gasp: return &m_emoticon_gasp.pixmap(); break;
case cKey_Emoticon_Heart: return &m_emoticon_heart.pixmap(); break;
default: /* NOP */;
}
return NULL;
}
void PhoneKeyboard::drawCenteredPixmap(QPainter & painter, QPixmap & pixmap, const QRect & location)
{
if (pixmap.height() > location.height() || pixmap.width() > location.width())
{
//g_debug("TabletKeyboard::drawKeyCap shrinking \"%s\" by %d pixels", m_keymap.getKeyDisplayString(key, true).toUtf8().data(), location.height() - pixmap.height());
painter.setRenderHints(cRenderHints, true);
if (pixmap.height() * location.width() > location.height() * pixmap.width())
{
int targetWidth = location.height() * pixmap.width() / pixmap.height();
painter.drawPixmap(location.left() + (location.width() - targetWidth) / 2, location.top(), targetWidth, location.height(), pixmap);
}
else
{
int targetHeight = location.width() * pixmap.height() / pixmap.width();
painter.drawPixmap(location.left(), location.top() + (location.height() - targetHeight) / 2, location.width(), targetHeight, pixmap);
}
}
else
painter.drawPixmap((int) location.left() + (location.width() - pixmap.width()) / 2, (int) location.top() + (location.height() - pixmap.height()) / 2, pixmap);
}
inline bool boostSize(QChar c)
{
ushort ci = c.unicode();
return ci == '.' || ci == ',' || ci == ';' || ci == ':' || ci == '\'' || ci == '"';
}
inline bool boostSize(QString s)
{
return s.size() == 1 && boostSize(s[0]);
}
//inline int font_size(const QString & text, const QColor & color, int baseSize, int percent)
//{
// if (color != cActiveColor)
// return baseSize * percent / 100;
// return boostSize(text) ? baseSize + 2 : baseSize;
//}
#define font_size(text, color, baseSize, percent) ((color != activeColor) ? (baseSize * percent / 100) : (boostSize(text) ? baseSize + 2 : baseSize))
void PhoneKeyboard::drawKeyCap(QPainter * painter, GlyphRenderer<GlyphSpec> & renderer, QRect location, const QPoint & keyCoord, UKey key, EUse use)
{
location.setBottom(location.bottom() - 4);
// if (pressed)
// location.translate(cPressedTranslateH, cPressedTranslateV);
QString text, altText;
bool twoHorizontal = false;
bool twoVertical = false;
bool useTwo = false;
QColor activeColor = useWhite(use) ? cActiveColor : cPopoutTextColor;
QColor activeColor_back = useWhite(use) ? cActiveColor_back : cPopoutTextColor_back;
QColor mainCharColor = activeColor;
QColor mainCharColor_back = activeColor_back;
QColor altCharColor = cDisabledColor;
QColor altCharColor_back = cDisabledColor_back;
bool capitalize = m_keymap.isCapOrAutoCapActive();
// bool capitalize = key >= Qt::Key_A && key <= Qt::Key_Z;
if (key == Qt::Key_Space)
text = m_candidateBar.autoSelectCandidate();
else if (UKeyIsUnicodeQtKey(key))
{ // key is also a unicode character...
UKey plain = m_keymap.map(keyCoord, PhoneKeymap::eLayoutPage_plain);
UKey alt = m_keymap.map(keyCoord, PhoneKeymap::eLayoutPage_Alternate);
if (plain != alt && alt != cKey_None)
{
useTwo = twoVertical = KeyCap_TwoVertical(keyCoord, plain);
if (twoVertical)
{
if (key == plain)
{
text = capitalize ? QChar(plain) : QChar(plain).toLower();
altText = QChar(alt).toLower();
}
else
{
mainCharColor = cDisabledColor;
mainCharColor_back = cDisabledColor_back;
altCharColor = activeColor;
altCharColor_back = activeColor_back;
text = QChar(plain).toLower();
altText = capitalize ? QChar(alt) : QChar(alt).toLower();
}
}
else
text = capitalize ? QChar(key) : QChar(key).toLower();
}
else
text = capitalize ? QChar(key) : QChar(key).toLower();
}
else if (((UKeyIsEmoticonKey(key) && m_keymap.showEmoticonsAsGraphics()) || (text = m_keymap.getKeyDisplayString(key)).size() == 0))
{
if (painter)
{
QPixmap * pix = getPixmapForKey(key);
if (pix)
{
int cPixMargin = UKeyIsEmoticonKey(key) ? 8 : 2;
location.adjust(cPixMargin, cPixMargin, - cPixMargin, - cPixMargin);
drawCenteredPixmap(*painter, *pix, location);
}
}
}
if (text.size() > 0)
{
sFont.setBold(useExtraLarge(use));
bool forceAlignHCenter = false; // if too tight, center text for better looking results
int height = location.height();
int fontSize = useExtraLarge(use) ? 32 : 24;
int centerOffset = 1;
if (useTwo && use == eUse_preview)
twoHorizontal = true, centerOffset = 2;
if (height / 2 < fontSize)
fontSize = (height + 1) / 2 + (useExtraLarge(use) ? 4 : 0);
if (text.size() > 1)
{
if (!useExtraLarge(use))
sFont.setBold(UKeyIsFunctionKey(key) && !UKeyIsTextShortcutKey(key));
fontSize = qMin<int>(fontSize, 22);
sFont.setPixelSize(fontSize);
int gap;
while ((gap = QFontMetrics(sFont).width(text) + 16 - location.width()) > 0) {
forceAlignHCenter = true;
int reduction = gap / text.length();
if (reduction < 1)
reduction = 1;
//g_debug("font size %d, Width = %d, gap = %d, reduction = %d", fontSize, location.width(), gap, reduction);
fontSize -= reduction;
sFont.setPixelSize(fontSize);
};
if (gap > -8)
forceAlignHCenter = true;
//g_debug("Using font size %d, Width = %d, text width = %d", fontSize, location.width(), QFontMetrics(sFont).width(text));
}
if (twoHorizontal)
{
if (mainCharColor == activeColor)
location.adjust(4, 1, -5, 1);
else
location.adjust(5, 1, -4, 1);
if (inLandscapeOrientation() == false)
fontSize -= 1;
QRect rect(location.left() + location.width() / 2 - centerOffset, location.top(), location.width() / 2, location.height());
renderer.render(rect, GlyphSpec(text, font_size(text, mainCharColor, fontSize, 75), sFont.bold(), mainCharColor, mainCharColor_back), sFont);
rect.moveLeft(location.left() + centerOffset);
renderer.render(rect, GlyphSpec(altText, font_size(altText, altCharColor, fontSize, 75), sFont.bold(), altCharColor, altCharColor_back), sFont);
}
else if (twoVertical)
{
int boxheight = location.height() / 3;
QRect rect(location.left(), location.bottom() - boxheight - 10 + (boostSize(text) ? -2 : 0), location.width(), boxheight);
renderer.render(rect, GlyphSpec(text, font_size(text, mainCharColor, fontSize, 75), sFont.bold(), mainCharColor, mainCharColor_back), sFont);
rect.moveTop(location.top() + 10);
renderer.render(rect, GlyphSpec(altText, font_size(altText, altCharColor, fontSize, 75), sFont.bold(), altCharColor, altCharColor_back), sFont);
}
else
{
/*
if (key == Qt::Key_Return)
{ // Smaller, bottom right corner...
location.setHeight((location.height()) * 90 / 100);
if (forceAlignHCenter)
renderer.render(location, GlyphSpec(text, qMin<int>(height, fontSize - 2), sFont.bold(), cFunctionColor, cFunctionColor_back), sFont, Qt::AlignBottom | Qt::AlignHCenter);
else
{
location.setWidth(location.width() * 85 / 100 + m_9tileCorner.m_trimH);
renderer.render(location, GlyphSpec(text, qMin<int>(height, fontSize - 2), sFont.bold(), cFunctionColor, cFunctionColor_back), sFont, Qt::AlignBottom | Qt::AlignRight);
}
}
else
*/
{
int size = qMin<int>(height, fontSize);
if (key == cKey_ToggleLanguage && text.endsWith('-')) // special case: strike the language key if the language ends with '-'
{
QString realText = text.left(text.size() - 1);
renderer.render(location, GlyphSpec(realText, size, sFont.bold(), mainCharColor, cFunctionColor_back), sFont);
if (painter)
{
renderer.flush();
painter->setPen(QPen(QBrush(cActiveColor), 4, Qt::SolidLine, Qt::RoundCap));
int width = QFontMetrics(sFont).width(realText) / 2 + 4;
int cx = (location.left() + location.right()) / 2;
int cy = (location.top() + location.bottom()) / 2;
painter->drawLine(cx - width, cy, cx + width, cy);
}
}
else if (key == Qt::Key_Space)
renderer.renderNow(location, GlyphSpec(text, size, sFont.bold(), mainCharColor, cFunctionColor_back), sFont);
else
renderer.render(location, GlyphSpec(text, size, sFont.bold(), mainCharColor, cFunctionColor_back), sFont);
}
}
sFont.setBold(false);
}
}
bool PhoneKeyboard::setShiftKeyDown(bool shiftKeyDown)
{
if (m_keymap.setShiftKeyDown(shiftKeyDown))
{
// if (m_IMEDataInterface)
// m_IMEDataInterface->sendKeyEvent(shiftKeyDown ? QEvent::KeyPress : QEvent::KeyRelease, Qt::Key_Shift, Qt::NoModifier);
keyboardLayoutChanged();
return true;
}
return false;
}
bool PhoneKeyboard::setSymbolKeyDown(bool symbolKeyDown)
{
if (m_keymap.setSymbolKeyDown(symbolKeyDown))
{
keyboardLayoutChanged();
return true;
}
return false;
}
void PhoneKeyboard::makeSound(UKey key)
{
if (VirtualKeyboardPreferences::instance().getTapSounds() && key != cKey_None)
m_IMEDataInterface->keyDownAudioFeedback(key);
}
void PhoneKeyboard::queueIdlePrerendering()
{
if (!m_idleInit)
{
m_idleInit = true;
g_idle_add_full(G_PRIORITY_LOW, keyboard_idle, NULL, NULL);
}
}
bool PhoneKeyboard::idle()
{ // there is only ever one PhoneKeyboard. Using statics to avoid exposing everywhere variables only used here
static int sCount = 0;
static bool sInitExtendedGlyphs = true;
if (m_IMEDataInterface->isUIAnimationActive())
return true;
if (sCount < IMEPixmap::count())
{
IMEPixmap::load(sCount++);
return true;
}
int index = sCount++ - IMEPixmap::count();
int stateIndex = index / PhoneKeymap::cKeymapRows;
int y = index % PhoneKeymap::cKeymapRows;
if (stateIndex < 3)
{ // pre-rendering all keyboards states for the current size, one row at a time...
DoubleDrawRenderer renderer;
GlyphCachePopulator<GlyphSpec> populator(m_glyphCache, renderer);
bool shiftDown = m_keymap.isShiftDown();
bool symbolDown = m_keymap.isSymbolDown();
bool autoCapActive = m_keymap.isAutoCapActive();
PhoneKeymap::EShiftMode shiftMode = m_keymap.shiftMode();
PhoneKeymap::ESymbolMode symbolMode = m_keymap.symbolMode();
m_keymap.setShiftKeyDown(false);
m_keymap.setSymbolKeyDown(false);
m_keymap.setAutoCap(false);
if (stateIndex == 0)
{
m_keymap.setShiftMode(PhoneKeymap::eShiftMode_Off);
m_keymap.setSymbolMode(PhoneKeymap::eSymbolMode_Off);
}
else if (stateIndex == 1)
{
m_keymap.setShiftMode(PhoneKeymap::eShiftMode_Once);
m_keymap.setSymbolMode(PhoneKeymap::eSymbolMode_Off);
}
else
{
m_keymap.setShiftMode(PhoneKeymap::eShiftMode_CapsLock);
m_keymap.setSymbolMode(PhoneKeymap::eSymbolMode_Lock);
}
std::string msg = string_printf("PhoneKeyboard pre-render (%dx%d): shift %d, symbol %d, autoCap %d, index=%d, y=%d", m_keymap.rect().width(), m_keymap.rect().height(), m_keymap.isShiftActive(), m_keymap.isSymbolActive(), m_keymap.isCapOrAutoCapActive(), stateIndex, y);
PerfMonitor perf(msg.c_str());
//g_debug("%s", msg.c_str());
for (int x = 0; x < PhoneKeymap::cKeymapColumns; ++x)
{
QPoint keyCoord(x, y);
UKey key = m_keymap.map(x, y);
QRect r;
int count = m_keymap.keyboardToKeyZone(keyCoord, r);
r.moveTo(0, 0);
if (count > 0 && key != Qt::Key_Space && key != cKey_None)
{
drawKeyCap(NULL, populator, r, keyCoord, key, eUse_unpressed);
drawKeyCap(NULL, populator, r, keyCoord, key, eUse_pressed);
drawKeyCap(NULL, populator, QRect(QPoint(), m_popup_key.size()), keyCoord, key, eUse_preview);
drawKeyCap(NULL, populator, QRect(QPoint(), m_popup_key.size()), keyCoord, key, eUse_extended);
}
}
m_keymap.setShiftKeyDown(shiftDown);
m_keymap.setSymbolKeyDown(symbolDown);
m_keymap.setAutoCap(autoCapActive);
m_keymap.setShiftMode(shiftMode);
m_keymap.setSymbolMode(symbolMode);
return true;
}
else if (stateIndex == 0 && y == 0)
{ // pre-rendering background, with 9-tiled keys
updateBackground();
return true;
}
else if (sInitExtendedGlyphs)
{ // pre-render extended chars, but only once per run (they are always shown at the same size & same color)
DoubleDrawRenderer renderer;
GlyphCachePopulator<GlyphSpec> populator(m_glyphCache, renderer);
static int x = -1;
static int y = -1;
static const UKey * extendedChars = NULL;
static int extendedIndex = 0;
if (x < 0 || y < 0 || x >= PhoneKeymap::cKeymapColumns || y >= PhoneKeymap::cKeymapRows)
{
x = y = 0;
extendedChars = m_keymap.getExtendedChars(QPoint(x, y));
extendedIndex = 0;
}
uint64_t timeLimit = CURRENT_TIME + 10; // process 10ms max
do {
if (extendedChars)
{
//g_debug("pre-render %dx%d %s...", x, y, QString(QChar(extendedChars[extendedIndex])).toUtf8().data());
if (UKeyIsUnicodeQtKey(extendedChars[extendedIndex]))
{
populator.render(QRect(QPoint(), m_popup_key.size()), GlyphSpec(QString(QChar(extendedChars[extendedIndex]).toLower()), cPopupFontSize, false, cPopoutTextColor, cPopoutTextColor_back), sFont);
populator.render(QRect(QPoint(), m_popup_key.size()), GlyphSpec(QString(QChar(extendedChars[extendedIndex]).toUpper()), cPopupFontSize, false, cPopoutTextColor, cPopoutTextColor_back), sFont);
}
if (!extendedChars[++extendedIndex])
extendedChars = NULL;
}
if (!extendedChars)
{
if (++x >= PhoneKeymap::cKeymapColumns)
{
x = 0;
if (++y >= PhoneKeymap::cKeymapRows)
break;
}
extendedChars = m_keymap.getExtendedChars(QPoint(x, y));
extendedIndex = 0;
}
if (CURRENT_TIME > timeLimit)
return true;
} while (true);
sInitExtendedGlyphs = false;
// cache elipsis...
populator.render(QRect(0, 0, 20, 20), GlyphSpec(sElipsis, cElipsisFontSize, false, cActiveColor, cActiveColor_back), sFont);
}
m_keymap.incCachedGlyphs();
sCount = IMEPixmap::count();
m_idleInit = false;
//g_debug("PhoneKeyboard background init complete!");
#if 0
#ifdef TARGET_DEVICE
m_glyphCache.pixmap().toImage().save("/media/internal/glyphcache.png");
#else
m_glyphCache.pixmap().toImage().save(QString(getenv("HOME")) + "/Desktop/glyphcache.png");
#endif
#endif
return false;
}
}; // namespace Phone_Keyboard
| 34.445602
| 271
| 0.707453
|
ericblade
|
9ef12f1194d9b7fd6992a0f83ae2c1dda78d3b04
| 30,109
|
cpp
|
C++
|
src/Tableau.cpp
|
gjo11/causaloptim
|
81155ff1aeef5cd2618f2498ba6b779d5a944cff
|
[
"MIT"
] | 13
|
2019-11-28T16:33:10.000Z
|
2021-12-10T12:03:35.000Z
|
src/Tableau.cpp
|
boennecd/causaloptim
|
b32016510e64ca4c688ff7df9fcf049404223630
|
[
"MIT"
] | 8
|
2020-05-04T14:32:49.000Z
|
2021-12-09T13:10:07.000Z
|
src/Tableau.cpp
|
boennecd/causaloptim
|
b32016510e64ca4c688ff7df9fcf049404223630
|
[
"MIT"
] | 3
|
2020-04-22T23:18:06.000Z
|
2020-12-10T09:32:05.000Z
|
//#include <afx.h>
#include <R.h>
//#include <windows.h>
#include <stdlib.h>
#include <stdio.h>
#include <string>
#include <math.h>
#include "MyUtils.h"
#include "Tableau.h"
#define AUG_COST -1000000.00
#define LEEWAY ((double) 0.00001)
#define LINE_LEN 1024
#define MAX_SOL 50.00
float SolFactor[3] = // Indexed by TERM_SIGN
{-1.0f, 0.0f, +1.0f};
float SymFactor[3] = // Indexed by TERM_SIGN
{+1.0f, +1.0f, -1.0f};
void Approx (double & p_Value, double p_Point)
{
if (p_Value < p_Point + LEEWAY &&
p_Value > p_Point - LEEWAY)
p_Value = p_Point;
} /* Approx () */
CTableau :: CTableau (
int p_ParamCnt,
int p_Rows,
Label_ p_pParamNames[],
pFloat_ * p_pA,
double * p_pb
//************************
// Ax <= b
//************************
)
{
Setup (p_ParamCnt, p_Rows, p_pParamNames, p_pA, p_pb);
} /* CTableau :: CTableau () */
void CTableau :: Setup (
int p_ParamCnt,
int p_Rows,
Label_ p_pParamNames[],
pFloat_ * p_pA,
double * p_pb
//************************
// Ax <= b
//************************
)
{
int nParam;
int nVar;
int nRow;
int nBasis;
int nAug;
double Coef;
double YCoef;
m_pEnumList = NULL;
m_pEnumCrnt = NULL;
m_EnumListLen = 0;
memset (m_pVertices, NULL, sizeof (m_pVertices));
// Check that the number of rows is greater than the number of parameters.
//
if (p_Rows <= p_ParamCnt)
{
//Rprintf ("ERROR: Let A be a mxn matrix. m must be greater than n.\n");
error ("ERROR: Let A be a mxn matrix. m must be greater than n.\n");
}
//
//****************************************************************
// Get the names of all the parameters.
//
m_ParamCnt = p_ParamCnt;
m_pParamNames = new Label_ [m_ParamCnt];
for (nParam = 0; nParam < m_ParamCnt; nParam++)
strcpy (m_pParamNames [nParam], p_pParamNames [nParam]);
//************************
// Determine how many augmented variables must be added.
// This is just the number of negative entries in the solution
// vector 'b'.
m_AugCnt = 0;
for (nRow = 0; nRow < p_Rows; nRow++)
{
if (p_pb [nRow] < 0.0)
m_AugCnt++;
}
//**********************************************************
// Evaluate the number of variables required and label them.
m_VarCnt = 1 + m_ParamCnt + 1 + p_Rows + m_AugCnt;
m_pVarLabels = new Label_ [m_VarCnt];
strcpy (m_pVarLabels [0], "nz");
for (nParam = 0; nParam < m_ParamCnt; nParam++)
{
nVar = 1 + nParam;
strcpy (m_pVarLabels [nVar], p_pParamNames [nParam]);
}
strcpy (m_pVarLabels [1 + m_ParamCnt], "y");
for (nRow = 0; nRow < p_Rows; nRow++)
{
nVar = 1 + m_ParamCnt + 1 + nRow;
sprintf (m_pVarLabels [nVar], "$%02d", nRow);
}
for (nAug = 0; nAug < m_AugCnt; nAug++)
{
nVar = 1 + m_ParamCnt + 1 + p_Rows + nAug;
sprintf (m_pVarLabels [nVar], "@%02d", nAug);
}
//**************************************
// Determine the size of the basis for this problem.
m_BasisCnt = p_Rows + 1;
//***********************************************************
// Done incorporating optimization problem parameters.
// Allocate the space for the Tableau.
//***********************************************************
m_pOrigBasisVars = new int [m_BasisCnt];
memset (m_pOrigBasisVars, 0, m_BasisCnt * sizeof (int));
m_pBasisVars = new int [m_BasisCnt];
memset (m_pBasisVars, 0, m_BasisCnt * sizeof (int));
m_pOrigSolution = new double [m_BasisCnt];
memset (m_pOrigSolution, 0, m_BasisCnt * sizeof (double));
m_pSolution = new double [m_BasisCnt];
memset (m_pSolution, 0, m_BasisCnt * sizeof (double));
m_pCj = new double [m_VarCnt];
memset (m_pCj, 0, m_VarCnt * sizeof (double));
m_pOrigTable = new pFloat_ [m_BasisCnt];
m_pTable = new pFloat_ [m_BasisCnt];
for (nBasis = 0; nBasis < m_BasisCnt; nBasis++)
{
m_pOrigTable [nBasis] = new double [m_VarCnt];
memset (m_pOrigTable [nBasis], 0, m_VarCnt * sizeof(double));
m_pTable [nBasis] = new double [m_VarCnt];
memset (m_pTable [nBasis], 0, m_VarCnt * sizeof(double));
}
//******************************
// Instantiate the Tableau from the given matrix, A.
m_pOrigTable [0][0] = 1.0;
m_pOrigTable [0][1 + m_ParamCnt] = 1.0;
m_pCj [1 + m_ParamCnt] = 1.0;
nAug = 0;
for (nRow = 0; nRow < p_Rows; nRow++)
{
nBasis = nRow + 1;
//****************************
// Determine the set of variables to use in the basis,
// and set the table coefficients for the augmented
// variables.
// Also determine the coefficient to be used for the
// current basis row.
//***************************
if (p_pb [nRow] < 0)
{
//***********************************
// The slack variable will have a negative
// coefficient; use an augmented variable
// in the basis.
//***********************************
Coef = -1.0;
nVar = 1 + m_ParamCnt + 1 + p_Rows + nAug;
m_pOrigTable [nBasis][nVar] = 1.0;
m_pCj [nVar] = AUG_COST;
m_pOrigBasisVars [nBasis] = nVar;
nAug++;
}
else
{
//************************************
// Use the slack variable in the basis.
//************************************
nVar = 1 + m_ParamCnt + 1 + nRow;
m_pOrigBasisVars [nBasis] = nVar;
Coef = 1.0;
}
//**************************************
// Set the entries corresponding to the user defined
// parameters.
// At the same time compute the coefficient for the
// 'y' variable.
//**************************************
YCoef = 0.0;
for (nParam = 0; nParam < m_ParamCnt; nParam++)
{
nVar = 1 + nParam;
m_pOrigTable [nBasis][nVar] = Coef * p_pA [nRow][nParam];
YCoef += p_pA [nRow][nParam] *
p_pA [nRow][nParam];
}
nVar = 1 + m_ParamCnt;
m_pOrigTable [nBasis][nVar] = Coef * sqrt (YCoef);
//**************************************
// Set the entries corresponding to the slack variables.
//**************************************
nVar = 1 + m_ParamCnt + 1 + nRow;
m_pOrigTable [nBasis][nVar] = Coef;
//*****************************************
// Set the solution value to be non-negative.
//****************************************
m_pOrigSolution [nBasis] = Coef * p_pb [nRow];
}
//*******************************
// Copy the original tableau over to the working copy.
//*******************************
Reset ();
m_VertexCnt = 0;
m_pSlackFlag = new char [m_BasisCnt - 1];
memset (m_pSlackFlag, 0, (m_BasisCnt - 1) * sizeof (char));
} /* CTableau :: Setup () */
CTableau :: CTableau (FILE * p_pFile)
{
char szLine [LINE_LEN];
char szWord [LINE_LEN];
char bMinimize;
int ParamCnt;
int ConstCnt;
Label_ * pParamNames;
String_ * pszConstraints;
String_ szObjective;
int nParam;
int nConst;
int ScanRslt;
char* objGet;
//*****************************************************************
// Determine whether to Minimize or Maximize the objective
// function.
//
while (1)
{
if (fgets (szLine, LINE_LEN, p_pFile) == 0)
{
//printf ("ERROR: didn't find Min/Max specifier\n");
error ("ERROR: didn't find Min/Max specifier\n");
}
sscanf (szLine, "%s", szWord);
if (strcmp (szWord, "MAXIMIZE") == 0)
{
bMinimize = 0;
break;
}
if (strcmp (szWord, "MINIMIZE") == 0)
{
bMinimize = 1;
break;
}
}
//
//****************************************************************
// Get the number of parameters.
//
while (1)
{
if (fgets (szLine, LINE_LEN, p_pFile) == 0)
{
//Rprintf ("ERROR: didn't find 'PARAMETERS'\n");
error ("ERROR: didn't find 'PARAMETERS'\n");
}
sscanf (szLine, "%s", szWord);
if (strcmp (szWord, "PARAMETERS") == 0)
break;
}
ParamCnt = 0;
while (1)
{
if (fgets (szLine, LINE_LEN, p_pFile) == 0)
{
//Rprintf ("ERROR: no 'CONSTRAINTS' line\n");
error ("ERROR: no 'CONSTRAINTS' line\n");
}
if (sscanf (szLine, "%s", szWord) >= 0)
{
if (strcmp (szWord, "CONSTRAINTS") == 0)
break;
else
ParamCnt++;
}
}
pParamNames = new Label_ [ParamCnt];
//
//****************************************************************
// Get the number of constraints.
//
ConstCnt = 0;
while (1)
{
if (fgets (szLine, LINE_LEN, p_pFile) == 0)
{
//Rprintf ("ERROR: no 'OBJECTIVE' line\n");
error ("ERROR: no 'OBJECTIVE' line\n");
}
if (sscanf (szLine, "%s", szWord) >= 0)
{
if (strcmp (szWord, "OBJECTIVE") == 0)
break;
else
ConstCnt++;
}
}
pszConstraints = new String_ [ConstCnt];
//
//******************************************************
// Copy the objective function
//
objGet = fgets (szObjective, LINE_LEN, p_pFile);
// Go back to beginning of file.
rewind (p_pFile);
//
//************************************************
// Find the parameter names and copy them.
//
while (1)
{
if (fgets (szLine, LINE_LEN, p_pFile) == 0)
{
//printf ("ERROR: didn't find 'PARAMETERS'\n");
error ("ERROR: didn't find 'PARAMETERS'\n");
}
sscanf (szLine, "%s", szWord);
if (strcmp (szWord, "PARAMETERS") == 0)
break;
}
nParam = 0;
while (1)
{
if (fgets (szLine, LINE_LEN, p_pFile) == 0)
{
//Rprintf ("ERROR: no 'CONSTRAINTS' line\n");
error ("ERROR: no 'CONSTRAINTS' line\n");
}
if (sscanf (szLine, "%s", szWord) >= 0)
{
if (strcmp (szWord, "CONSTRAINTS") == 0)
break;
else
{
strcpy (pParamNames [nParam], szWord);
nParam++;
}
}
}
//
//****************************************
// Find the constraints and copy them.
//
nConst = 0;
while (1)
{
if (fgets (szLine, LINE_LEN, p_pFile) == 0)
{
//Rprintf ("ERROR: no 'OBJECTIVE' line\n");
error ("ERROR: no 'OBJECTIVE' line\n");
}
if (sscanf (szLine, "%s", szWord) >= 0)
{
if (strcmp (szWord, "OBJECTIVE") == 0)
break;
else
{
strcpy (pszConstraints [nConst], szLine);
nConst++;
}
}
}
// Setup (p_bVertices, bMinimize, ParamCnt, pParamNames,
// ConstCnt, pszConstraints, szObjective);
} /* CTableau :: CTableau () */
//======================================
// FUNCTION: Reset
// PURPOSE:
// Sets the Working Tableau equal to the Original Tableau.
//======================================
void CTableau :: Reset ()
{
int nBasis;
int nVar;
for (nBasis = 0; nBasis < m_BasisCnt; nBasis++)
{
m_pSolution [nBasis] = m_pOrigSolution [nBasis];
m_pBasisVars [nBasis] = m_pOrigBasisVars [nBasis];
}
for (nVar = 0; nVar < m_VarCnt; nVar++)
{
for (nBasis = 0; nBasis < m_BasisCnt; nBasis++)
{
m_pTable [nBasis] [nVar] = m_pOrigTable [nBasis] [nVar];
}
}
} /* CTableau :: Reset () */
CTableau :: ~CTableau ()
{
CEnumRcd * pNextRcd;
CEnumRcd * pEnumRcd;
for (int nBasis = 0; nBasis < m_BasisCnt; nBasis++)
{
delete [] m_pOrigTable [nBasis];
delete [] m_pTable [nBasis];
}
delete [] m_pTable;
delete [] m_pOrigTable;
delete [] m_pBasisVars;
delete [] m_pOrigBasisVars;
delete [] m_pSolution;
delete [] m_pOrigSolution;
delete [] m_pCj;
delete [] m_pSlackFlag;
// delete m_pConstraints;
// delete m_pObjective;
delete m_pVarLabels;
delete m_pParamNames;
for (int nVertex = 0; nVertex < MAX_VERTICES; nVertex++)
if (m_pVertices [nVertex])
delete [] m_pVertices [nVertex];
pEnumRcd = m_pEnumList;
while (pEnumRcd)
{
pNextRcd = pEnumRcd-> m_pNext;
delete [] pEnumRcd-> Contents ();
delete pEnumRcd;
pEnumRcd = pNextRcd;
}
} /* CTableau :: ~CTableau () */
/*=======================================
| FUNCTION: TradeBasis
| PURPOSE:
| Swaps the indicated non-basis variable for the specified
| basis variable.
========================================*/
void CTableau :: TradeBasis (int p_Basis, int p_Var)
{
double Pivot;
double Factor;
int nVar;
int nBasis;
Pivot = m_pTable [p_Basis] [p_Var];
m_pBasisVars [p_Basis] = p_Var;
m_pSolution [p_Basis] /= Pivot;
for (nVar = 0; nVar < m_VarCnt; nVar++)
{
m_pTable [p_Basis] [nVar] /= Pivot;
}
for (nBasis = 0; nBasis < m_BasisCnt; nBasis++)
{
if (nBasis != p_Basis)
{
Factor = m_pTable [nBasis] [p_Var];
m_pSolution [nBasis] -= Factor * m_pSolution [p_Basis];
Approx (m_pSolution [nBasis], 0.0);
for (nVar = 0; nVar < m_VarCnt; nVar++)
{
m_pTable [nBasis] [nVar] -=
Factor * m_pTable [p_Basis] [nVar];
Approx (m_pTable [nBasis][nVar], 0.0);
}
}
}
} /* CTableau :: TradeBasis () */
std::string CTableau :: DecisionDisplay ()
{
int nBasis;
int nVar;
char buffer[100];
std::string result;
result.append ("Basis");
for (nBasis = 0; nBasis < m_BasisCnt; nBasis++)
{
sprintf (buffer, "%7s", m_pVarLabels [m_pBasisVars [nBasis]]);
result.append (buffer);
}
result.append ("\n");
for (nVar = 0; nVar < m_VarCnt; nVar++)
{
// Display only the nonbasis variables.
for (nBasis = 0; nBasis < m_BasisCnt; nBasis++)
if (m_pBasisVars [nBasis] == nVar)
break;
if (nBasis < m_BasisCnt)
continue;
sprintf (buffer, "%7s", m_pVarLabels [nVar]);
result.append(buffer);
for (nBasis = 0; nBasis < m_BasisCnt; nBasis++)
{
sprintf (buffer, "%7.3lf", m_pTable [nBasis][nVar]);
result.append(buffer);
}
result.append ("\n");
}
result.append ( "Sol");
for (nBasis = 0; nBasis < m_BasisCnt; nBasis++)
{
sprintf (buffer, "%7.3lf", m_pSolution [nBasis]);
result.append(buffer);
}
result.append ("\n\n");
return result;
} /* CTableau :: DecisionDisplay () */
/*=================================
| FUNCTION: DetermineSwap
| PURPOSE:
| Determines which non-basis and basis variable to swap.
===================================*/
void CTableau :: DetermineSwap (int & p_Basis, int & p_Var)
{
int nBasis;
int nVar;
int nFirstAug;
double Contr;
double MaxPosContr = 0.0;
double Ratio;
double MinRatio;
p_Var = -1;
for (nVar = 1; nVar < m_VarCnt; nVar++)
{
//===============================
// Compute zj-cj for this column
//===============================
Contr = m_pCj [nVar];
for (nBasis = 1; nBasis < m_BasisCnt; nBasis++)
{
Contr -= m_pTable [nBasis][nVar] *
m_pCj [m_pBasisVars [nBasis]];
}
if (Contr > MaxPosContr)
{
MaxPosContr = Contr;
p_Var = nVar;
}
}
if (p_Var < 0)
{
return;
}
p_Basis = -1;
MinRatio = 1000000.0;
for (nBasis = 1; nBasis < m_BasisCnt; nBasis++)
{
if (m_pTable [nBasis] [p_Var] > LEEWAY)
{
Ratio = m_pSolution [nBasis] / m_pTable [nBasis] [p_Var];
if (Ratio >= 0.0 &&
Ratio < MinRatio)
{
MinRatio = Ratio;
p_Basis = nBasis;
}
}
}
} /* CTableau :: DetermineSwap () */
double CTableau :: GetSolution (char * p_szVarName)
{
for (int nBasis = 0; nBasis < m_BasisCnt; nBasis++)
{
if (strcmp (p_szVarName, m_pVarLabels [m_pBasisVars [nBasis]]) == 0)
{
return m_pSolution [nBasis];
}
}
return 0.0;
} /* CTableau :: GetValue () */
double CTableau :: ObjectiveValue ()
{
return -m_pSolution [0];
} /* CTableau :: ObjectiveValue () */
char CTableau :: Optimize ()
{
int nVar;
int Var;
int Basis;
//#define MYDEBUG
while (1)
{
#ifdef MYDEBUG
DecisionDisplay ();
#endif
DetermineSwap (Basis, Var);
#ifdef MYDEBUG
Rprintf ("Var: %4s, Basis: %4s\n",
m_pVarLabels [Var],
m_pVarLabels [m_pBasisVars[Basis]]);
#endif
if (Var < 0 || Basis < 0)
break;
TradeBasis (Basis, Var);
}
return 1;
} /* CTableau :: Optimize () */
void CTableau :: DisplayBasis ()
{
int nBasis;
for (nBasis = 0; nBasis < m_BasisCnt; nBasis++)
{
Rprintf ("%s: %lf\n", m_pVarLabels [m_pBasisVars [nBasis]],
m_pSolution [nBasis]);
}
} /* CTableau :: DisplayBasis () */
void CTableau :: DisplayParams ()
{
int nVar;
int nBasis;
for (nVar = m_BasisCnt;
nVar < m_BasisCnt + m_ParamCnt; nVar++)
{
for (nBasis = 0; nBasis < m_BasisCnt; nBasis++)
{
if (nVar == m_pBasisVars [nBasis])
{
Rprintf ("%5s: %lf\n", m_pVarLabels [nVar],
m_pSolution [nBasis]);
break;
}
}
}
} /* CTableau :: DisplayParams () */
void CTableau :: DropVars ()
{
m_VarCnt = 1 + m_ParamCnt + 1 + (m_BasisCnt - 1);
m_AugCnt = 0;
// Changing these values will not affect the later deallocation of the
// Tableau.
} /* CTableau :: DropVars () */
//======================================
// FUNCTION: WorkToOrig
// PURPOSE:
// Sets the Original Tableau equal to the Working Tableau.
//======================================
void CTableau :: WorkToOrig ()
{
int nBasis;
int nVar;
for (nBasis = 0; nBasis < m_BasisCnt; nBasis++)
{
m_pOrigSolution [nBasis] = m_pSolution [nBasis];
m_pOrigBasisVars [nBasis] = m_pBasisVars [nBasis];
}
for (nVar = 0; nVar < m_VarCnt; nVar++)
{
for (nBasis = 0; nBasis < m_BasisCnt; nBasis++)
{
m_pOrigTable [nBasis] [nVar] = m_pTable [nBasis] [nVar];
}
}
} /* CTableau :: WorkToOrig () */
WORD * CTableau :: PopFirst ()
{
int * pNonBasics;
CEnumRcd * pNextRcd;
CEnumRcd * pEnumRcd;
double CrntValue;
double NewValue;
int nNonBasis;
if (m_pEnumList == NULL)
return NULL;
if (m_pEnumCrnt == NULL)
{
m_pEnumCrnt = m_pEnumList;
return m_pEnumCrnt-> Contents ();
}
if (m_pEnumCrnt-> m_pNext == NULL)
{
// printf ("No more records, deleting all:\n");
// DisplayEnumRcds ();
return NULL;
}
CrntValue = m_pEnumCrnt-> Value ();
NewValue = m_pEnumCrnt-> m_pNext-> Value ();
m_pEnumCrnt = m_pEnumCrnt-> m_pNext;
if (NewValue > CrntValue + LEEWAY)
{
//Rprintf ("ERROR: The list is not monotonically non-increasing.\n");
error ("ERROR: The list is not monotonically non-increasing.\n");
}
if (NewValue < CrntValue - LEEWAY)
{
//=================================
// Remove all the preceding elements in the
// list. They are no longer needed for eliminating
// duplicates.
//==================================
pEnumRcd = m_pEnumList;
while (pEnumRcd != m_pEnumCrnt)
{
// printf ("Deleting record: %6.3lf :", pEnumRcd-> Value ());
// for (nNonBasis = 0; nNonBasis < m_VarCnt - m_BasisCnt;
// nNonBasis++)
// {
// printf (" %4s", m_pVarLabels [
// (pEnumRcd-> Contents ()) [nNonBasis]]);
// }
// printf ("\n");
pNextRcd = pEnumRcd-> m_pNext;
delete [] pEnumRcd-> Contents ();
delete pEnumRcd;
pEnumRcd = pNextRcd;
m_EnumListLen--;
}
m_pEnumList = m_pEnumCrnt;
// DisplayEnumRcds ();
}
return m_pEnumCrnt-> Contents ();
} /* CTableau :: PopFirst () */
void CTableau :: AddUnique (double p_Value, WORD * p_pNonBasics)
{
CEnumRcd * pCurrent;
CEnumRcd ** ppPrior;
CEnumRcd * pNew;
double Value;
int nNonBasis;
// printf (":v%lf", p_Value);
ppPrior = &m_pEnumList;
pCurrent = m_pEnumList;
while (pCurrent != NULL)
{
Value = pCurrent-> Value ();
if (p_Value < Value + LEEWAY &&
p_Value > Value - LEEWAY)
{
// See if the new record is non-unique.
// This assumes that the non-basic variables are
// always ordered by index value.
for (nNonBasis = 0; nNonBasis < m_VarCnt - m_BasisCnt; nNonBasis++)
{
if (p_pNonBasics [nNonBasis] !=
(pCurrent-> Contents ())[nNonBasis])
break;
}
if (nNonBasis == m_VarCnt - m_BasisCnt)
{
// NonBasis is not unique; do not add to list.
delete [] p_pNonBasics;
return;
}
}
else if (p_Value > Value)
{
pNew = new CEnumRcd (p_Value, p_pNonBasics);
*ppPrior = pNew;
pNew-> m_pNext = pCurrent;
m_EnumListLen++;
return;
}
ppPrior = &(pCurrent-> m_pNext);
pCurrent = pCurrent-> m_pNext;
}
pNew = new CEnumRcd (p_Value, p_pNonBasics);
*ppPrior = pNew;
m_EnumListLen++;
} /* CTableau :: AddUnique () */
void CTableau :: DisplayEnumRcds ()
{
CEnumRcd * pCurrent;
WORD * pNonBasis;
int nNonBasis;
Rprintf ("Contents of Enum List\n");
pCurrent = m_pEnumList;
while (pCurrent != NULL)
{
Rprintf ("\t%6.3lf : ", pCurrent-> Value ());
pNonBasis = pCurrent-> Contents ();
for (nNonBasis = 0; nNonBasis < m_VarCnt - m_BasisCnt; nNonBasis++)
{
Rprintf ("%4s ", m_pVarLabels [pNonBasis [nNonBasis]]);
}
if (pCurrent == m_pEnumCrnt)
Rprintf (" **");
Rprintf ("\n");
pCurrent = pCurrent-> m_pNext;
}
} /* CTableau :: DisplayEnumRcds () */
std::string CTableau :: VertexEnumerate ()
{
int nBasis;
int nNonBasis;
int nSlack;
WORD * pNonBasics;
int nVar;
int PivotBasis;
double MinRatio;
double Ratio;
double * pNewSol;
int * pBasisVars;
double Factor;
double Pivot;
char szResponse[100];
char buffer[1024];
std::string result;
result.append ("Table before optimizing Y.\n");
result.append ("--------------------------\n");
pNewSol = new double [m_BasisCnt];
pBasisVars = new int [m_BasisCnt];
result.append(DecisionDisplay ());
Optimize ();
DropVars ();
WorkToOrig ();
AddEnumRcd (m_pBasisVars, - m_pSolution[0]);
// DisplayEnumRcds ();
while ((pNonBasics = PopFirst ()) != NULL)
{
// printf ("Analyzing: ");
// for (nNonBasis = 0; nNonBasis < m_VarCnt - m_BasisCnt; nNonBasis++)
// {
// printf (" %4s", m_pVarLabels [pNonBasics [nNonBasis]]);
// }
// printf ("\n");
R_CheckUserInterrupt();
GenerateTableau (pNonBasics);
// Flag all the nonbasic slack variables. This is later used to
// identify relevant constraints.
for (nNonBasis = 0; nNonBasis < m_VarCnt - m_BasisCnt; nNonBasis++)
{
m_pSlackFlag [pNonBasics [nNonBasis] - m_ParamCnt - 2] = 1;
}
// DecisionDisplay ();
for (nNonBasis = 0; nNonBasis < m_VarCnt - m_BasisCnt; nNonBasis++)
{
nVar = pNonBasics [nNonBasis];
#ifdef MYDEBUG
Rprintf ("NonBasis [%d] = %4s\n", nNonBasis,
m_pVarLabels [pNonBasics [nNonBasis]]);
#endif
if (m_pTable [0][nVar] > LEEWAY)
continue;
//==============================
// Find the basis to pivot on.
//==============================
MinRatio = 1000000.0;
for (nBasis = 1; nBasis < m_BasisCnt; nBasis++)
{
if (m_pTable [nBasis] [nVar] > LEEWAY &&
m_pSolution [nBasis] >= -LEEWAY)
{
Ratio = m_pSolution [nBasis] / m_pTable [nBasis] [nVar];
if (Ratio >= - LEEWAY &&
Ratio < MinRatio)
{
MinRatio = Ratio;
}
}
}
for (PivotBasis = 1; PivotBasis < m_BasisCnt; PivotBasis++)
{
R_CheckUserInterrupt();
if (m_pTable [PivotBasis] [nVar] <= LEEWAY)
continue;
Ratio = m_pSolution [PivotBasis] /
m_pTable [PivotBasis] [nVar];
if (Ratio < -LEEWAY ||
Ratio > MinRatio + LEEWAY)
continue;
if (m_pBasisVars [PivotBasis] >= 1 &&
m_pBasisVars [PivotBasis] < 1 + m_ParamCnt)
//==================================
// Pivot is a user-defined parameter.
//==================================
continue;
for (nBasis = 0; nBasis < m_BasisCnt; nBasis++)
{
pNewSol [nBasis] = m_pSolution [nBasis];
pBasisVars [nBasis] = m_pBasisVars [nBasis];
}
//===============================
// Evaluate the new solutions and basis
// variables given the pivot point.
//===============================
Pivot = m_pTable [PivotBasis] [nVar];
pBasisVars [PivotBasis] = nVar;
pNewSol [PivotBasis] /= Pivot;
for (nBasis = 0; nBasis < m_BasisCnt; nBasis++)
{
if (nBasis != PivotBasis)
{
Factor = m_pTable [nBasis] [nVar];
pNewSol [nBasis] -= Factor * pNewSol [PivotBasis];
}
}
// printf ("Pivot %5s for %5s\n",
// m_pVarLabels [nVar],
// m_pVarLabels [m_pBasisVars [PivotBasis]]);
if (m_pBasisVars [PivotBasis] == 1 + m_ParamCnt)
{
//===================================
// Pivot is Y.
//===================================
AddVertex (pBasisVars, pNewSol);
// printf ("\nVERTEX:\n");
// for (nBasis = 0; nBasis < m_BasisCnt; nBasis++)
// {
// printf ("\t%5s: %lf\n",
// m_pVarLabels [pBasisVars [nBasis]],
// pNewSol [nBasis]);
// }
}
else
{
//===================================
// Pivot is a slack variable.
//===================================
// If Y = 0.0, then the solution corresponds to a
// point in the n-dim space, K; therefore, do not
// add the point as a subsystem in the (n+1)-dim
// space (currently, I do not know if this is
// absolutely correct).
if (- pNewSol [0] > LEEWAY)
{
AddEnumRcd (pBasisVars, - pNewSol [0]);
}
}
}
}
}
result.append(DisplayVertices ());
result.append ("Irrelevant contraints:\n");
for (nSlack = 0; nSlack < m_BasisCnt - 1; nSlack++)
{
if (m_pSlackFlag [nSlack] == 0)
{
sprintf (buffer, "\t%d\n", nSlack);
result.append(buffer);
}
}
delete [] pNewSol;
return result;
} /* CTableau :: VertexEnumerate () */
void CTableau :: GenerateTableau (WORD * p_pNonBasics)
{
int nRow;
int nVar;
int nNonBasis = 0;
char * pbBasis;
int nBasis;
int MaxRow;
double MaxAbs;
double FTemp;
pbBasis = new char [m_VarCnt];
Reset ();
memset (pbBasis, 1, m_VarCnt * sizeof (char));
for (nNonBasis = 0; nNonBasis < m_VarCnt - m_BasisCnt; nNonBasis++)
pbBasis [p_pNonBasics [nNonBasis]] = 0;
nBasis = 1;
for (nVar = 1; nVar < m_VarCnt; nVar++)
{
if (pbBasis [nVar])
{
m_pBasisVars [nBasis] = nVar;
nBasis++;
}
}
if (nBasis != m_BasisCnt)
{
//Rprintf ("ERROR: GenerateTableau: incorrect basis count.\n");
error ("ERROR: GenerateTableau: incorrect basis count.\n");
}
for (nBasis = 1; nBasis < m_BasisCnt; nBasis++)
{
nVar = m_pBasisVars [nBasis];
if (m_pTable [nBasis][nVar] < LEEWAY &&
m_pTable [nBasis][nVar] > -LEEWAY)
{
//===========================
// Make sure the pivot element is not zero.
//=============================
MaxRow = 0;
MaxAbs = 0.0;
for (nRow = nBasis; nRow < m_BasisCnt; nRow++)
{
FTemp = m_pTable [nRow][nVar];
FTemp = fabs(FTemp);
if (FTemp > MaxAbs)
{
MaxRow = nRow;
MaxAbs = FTemp;
}
}
FactorAddRows (MaxRow, nBasis, 1.0);
}
DivideRow (nBasis, m_pTable [nBasis][nVar]);
for (nRow = 0; nRow < m_BasisCnt; nRow++)
{
if (nRow != nBasis)
FactorAddRows (nBasis, nRow, -m_pTable [nRow][nVar]);
}
}
delete [] pbBasis;
} /* CTableau :: GenerateTableau () */
void CTableau :: DivideRow (int p_Basis, double p_Divisor)
{
int nVar;
if (p_Divisor < LEEWAY &&
p_Divisor > -LEEWAY)
return;
m_pSolution [p_Basis] /= p_Divisor;
for (nVar = 1; nVar < m_VarCnt; nVar++)
{
m_pTable [p_Basis][nVar] /= p_Divisor;
}
} /* CTableau :: DivideRow () */
void CTableau :: FactorAddRows (int p_SrcRow, int p_TgtRow, double p_Factor)
{
int nVar;
m_pSolution [p_TgtRow] +=
p_Factor * m_pSolution [p_SrcRow];
for (nVar = 1; nVar < m_VarCnt; nVar++)
{
m_pTable [p_TgtRow][nVar] +=
p_Factor * m_pTable [p_SrcRow][nVar];
}
} /* CTableau :: AddRows () */
void CTableau :: AddEnumRcd (int * p_pBasisVars, double p_Value)
{
int nVar;
int nBasis;
char * pbBasis;
WORD * pNonBasis;
int nNonBasis;
pbBasis = new char [m_VarCnt];
pNonBasis = new /*int*/ WORD [m_VarCnt - m_BasisCnt];
memset (pbBasis, 0, m_VarCnt * sizeof (char));
for (nBasis = 0; nBasis < m_BasisCnt; nBasis++)
{
pbBasis[p_pBasisVars [nBasis]] = 1;
}
nNonBasis = 0;
for (nVar = 0; nVar < m_VarCnt; nVar++)
{
if (pbBasis [nVar] == 0)
{
pNonBasis[nNonBasis] = (WORD) nVar;
nNonBasis++;
}
}
AddUnique (p_Value, pNonBasis);
//printf (":%d", m_EnumListLen);
delete [] pbBasis;
// printf ("\nAdding Enum Record: %6.3lf :", p_Value);
// for (nNonBasis = 0; nNonBasis < m_VarCnt - m_BasisCnt; nNonBasis++)
// {
// printf (" %4s", m_pVarLabels [pNonBasis [nNonBasis]]);
// }
// printf ("\n");
// DisplayEnumRcds ();
} /* CTableau :: AddEnumRcd () */
void CTableau :: AddVertex (int * p_pBasisVars, double * p_pSolution)
{
double * pVertex;
int nBasis;
int nParam;
int nVertex;
double NewVal;
double OldVal;
if (m_VertexCnt >= MAX_VERTICES)
{
error ("ERROR: Exceeded maximum number of vertices.\n");
return;
}
pVertex = new double [m_ParamCnt];
memset (pVertex, 0, m_ParamCnt * sizeof (double));
for (nBasis = 1; nBasis < m_BasisCnt; nBasis++)
{
if (p_pBasisVars [nBasis] >= 1 &&
p_pBasisVars [nBasis] <= m_ParamCnt)
{
pVertex [p_pBasisVars [nBasis] - 1] =
p_pSolution [nBasis];
}
}
//============================
// Check that all coordinates in the vertex are
// not positively extreme. Otherwise, do not add vertex.
//============================
for (nVertex = 0; nVertex < m_ParamCnt; nVertex++)
{
if (pVertex [nVertex] > MAX_SOL)
{
delete [] pVertex;
//printf ("-");
return;
}
}
//============================
// Check vertex for uniqueness.
//============================
for (nVertex = 0; nVertex < m_VertexCnt; nVertex++)
{
for (nParam = 0; nParam < m_ParamCnt; nParam++)
{
NewVal = pVertex [nParam];
OldVal = m_pVertices [nVertex][nParam];
if (NewVal < OldVal - LEEWAY ||
NewVal > OldVal + LEEWAY)
break;
}
if (nParam == m_ParamCnt)
break; // Duplicate found.
}
if (nVertex == m_VertexCnt)
{
// Vertex is unique.
m_pVertices [m_VertexCnt] = pVertex;
m_VertexCnt++;
//printf ("\nADDED Unique Vertex!\n");
// DisplayVertices ();
// DecisionDisplay ();
}
else
{
delete [] pVertex;
//printf ("\n+");
}
} /* CTableau :: AddVertex () */
std::string CTableau :: DisplayVertices ()
{
int nVertex;
int nParam;
char buffer[1024];
std::string result;
result.append ("\n\n");
for (nParam = 0; nParam < m_ParamCnt; nParam++)
{
sprintf (buffer, "%6s ", m_pVarLabels [nParam + 1]);
result.append(buffer);
}
result.append ("\n\n");
for (nVertex = 0; nVertex < m_VertexCnt; nVertex++)
{
for (nParam = 0; nParam < m_ParamCnt; nParam++)
{
sprintf (buffer, "%6.3lf ", m_pVertices [nVertex][nParam]);
result.append(buffer);
}
result.append ("\n");
}
return result;
} /* CTableau :: DisplayVertices () */
BOOL CTableau :: GetVertex (int p_nVertex, double * p_pVertex, int p_VertexLength)
{
int nParam;
if (p_VertexLength != m_ParamCnt)
return FALSE;
if (p_nVertex >= m_VertexCnt)
return FALSE;
for (nParam = 0; nParam < m_ParamCnt; nParam++)
p_pVertex [nParam] = m_pVertices [p_nVertex][nParam];
return TRUE;
}
| 21.369056
| 82
| 0.565877
|
gjo11
|
9ef46a477dd4ec69813367265ed0091b1bcaf563
| 78,451
|
hpp
|
C++
|
addons/ofxOpenCv/libs/opencv/include/opencv2/gpu/gpu.hpp
|
local-projects/openframeworks_osx_64
|
430bdd0df27e803ed29078480093f5836053f5fa
|
[
"MIT"
] | 18
|
2015-01-18T22:34:22.000Z
|
2020-09-06T20:30:30.000Z
|
addons/ofxOpenCv/libs/opencv/include/opencv2/gpu/gpu.hpp
|
local-projects/openframeworks_osx_64
|
430bdd0df27e803ed29078480093f5836053f5fa
|
[
"MIT"
] | 2
|
2015-08-04T00:07:46.000Z
|
2017-05-10T15:53:51.000Z
|
addons/ofxOpenCv/libs/opencv/include/opencv2/gpu/gpu.hpp
|
local-projects/openframeworks_osx_64
|
430bdd0df27e803ed29078480093f5836053f5fa
|
[
"MIT"
] | 10
|
2015-01-18T23:46:10.000Z
|
2019-08-25T12:10:04.000Z
|
/*M///////////////////////////////////////////////////////////////////////////////////////
//
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
//
// By downloading, copying, installing or using the software you agree to this license.
// If you do not agree to this license, do not download, install,
// copy or use the software.
//
//
// License Agreement
// For Open Source Computer Vision Library
//
// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
// Third party copyrights are property of their respective owners.
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
// * Redistribution's of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// * Redistribution's in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other GpuMaterials provided with the distribution.
//
// * The name of the copyright holders may not be used to endorse or promote products
// derived from this software without specific prior written permission.
//
// This software is provided by the copyright holders and contributors "as is" and
// any express or implied warranties, including, but not limited to, the implied
// warranties of merchantability and fitness for a particular purpose are disclaimed.
// In no event shall the Intel Corporation or contributors be liable for any direct,
// indirect, incidental, special, exemplary, or consequential damages
// (including, but not limited to, procurement of substitute goods or services;
// loss of use, data, or profits; or business interruption) however caused
// and on any theory of liability, whether in contract, strict liability,
// or tort (including negligence or otherwise) arising in any way out of
// the use of this software, even if advised of the possibility of such damage.
//
//M*/
#ifndef __OPENCV_GPU_HPP__
#define __OPENCV_GPU_HPP__
#include <vector>
#include "opencv2/core/core.hpp"
#include "opencv2/imgproc/imgproc.hpp"
#include "opencv2/objdetect/objdetect.hpp"
#include "opencv2/features2d/features2d.hpp"
#include "opencv2/gpu/gpumat.hpp"
namespace cv
{
namespace gpu
{
//////////////////////////////// Initialization & Info ////////////////////////
//! This is the only function that do not throw exceptions if the library is compiled without Cuda.
CV_EXPORTS int getCudaEnabledDeviceCount();
//! Functions below throw cv::Expception if the library is compiled without Cuda.
CV_EXPORTS void setDevice(int device);
CV_EXPORTS int getDevice();
//! Explicitly destroys and cleans up all resources associated with the current device in the current process.
//! Any subsequent API call to this device will reinitialize the device.
CV_EXPORTS void resetDevice();
enum FeatureSet
{
FEATURE_SET_COMPUTE_10 = 10,
FEATURE_SET_COMPUTE_11 = 11,
FEATURE_SET_COMPUTE_12 = 12,
FEATURE_SET_COMPUTE_13 = 13,
FEATURE_SET_COMPUTE_20 = 20,
FEATURE_SET_COMPUTE_21 = 21,
GLOBAL_ATOMICS = FEATURE_SET_COMPUTE_11,
NATIVE_DOUBLE = FEATURE_SET_COMPUTE_13
};
// Gives information about what GPU archs this OpenCV GPU module was
// compiled for
class CV_EXPORTS TargetArchs
{
public:
static bool builtWith(FeatureSet feature_set);
static bool has(int major, int minor);
static bool hasPtx(int major, int minor);
static bool hasBin(int major, int minor);
static bool hasEqualOrLessPtx(int major, int minor);
static bool hasEqualOrGreater(int major, int minor);
static bool hasEqualOrGreaterPtx(int major, int minor);
static bool hasEqualOrGreaterBin(int major, int minor);
private:
TargetArchs();
};
// Gives information about the given GPU
class CV_EXPORTS DeviceInfo
{
public:
// Creates DeviceInfo object for the current GPU
DeviceInfo() : device_id_(getDevice()) { query(); }
// Creates DeviceInfo object for the given GPU
DeviceInfo(int device_id) : device_id_(device_id) { query(); }
string name() const { return name_; }
// Return compute capability versions
int majorVersion() const { return majorVersion_; }
int minorVersion() const { return minorVersion_; }
int multiProcessorCount() const { return multi_processor_count_; }
size_t freeMemory() const;
size_t totalMemory() const;
// Checks whether device supports the given feature
bool supports(FeatureSet feature_set) const;
// Checks whether the GPU module can be run on the given device
bool isCompatible() const;
int deviceID() const { return device_id_; }
private:
void query();
void queryMemory(size_t& free_memory, size_t& total_memory) const;
int device_id_;
string name_;
int multi_processor_count_;
int majorVersion_;
int minorVersion_;
};
//////////////////////////////// Error handling ////////////////////////
CV_EXPORTS void error(const char *error_string, const char *file, const int line, const char *func);
CV_EXPORTS void nppError( int err, const char *file, const int line, const char *func);
//////////////////////////////// CudaMem ////////////////////////////////
// CudaMem is limited cv::Mat with page locked memory allocation.
// Page locked memory is only needed for async and faster coping to GPU.
// It is convertable to cv::Mat header without reference counting
// so you can use it with other opencv functions.
// Page-locks the matrix m memory and maps it for the device(s)
CV_EXPORTS void registerPageLocked(Mat& m);
// Unmaps the memory of matrix m, and makes it pageable again.
CV_EXPORTS void unregisterPageLocked(Mat& m);
class CV_EXPORTS CudaMem
{
public:
enum { ALLOC_PAGE_LOCKED = 1, ALLOC_ZEROCOPY = 2, ALLOC_WRITE_COMBINED = 4 };
CudaMem();
CudaMem(const CudaMem& m);
CudaMem(int rows, int cols, int type, int _alloc_type = ALLOC_PAGE_LOCKED);
CudaMem(Size size, int type, int alloc_type = ALLOC_PAGE_LOCKED);
//! creates from cv::Mat with coping data
explicit CudaMem(const Mat& m, int alloc_type = ALLOC_PAGE_LOCKED);
~CudaMem();
CudaMem& operator = (const CudaMem& m);
//! returns deep copy of the matrix, i.e. the data is copied
CudaMem clone() const;
//! allocates new matrix data unless the matrix already has specified size and type.
void create(int rows, int cols, int type, int alloc_type = ALLOC_PAGE_LOCKED);
void create(Size size, int type, int alloc_type = ALLOC_PAGE_LOCKED);
//! decrements reference counter and released memory if needed.
void release();
//! returns matrix header with disabled reference counting for CudaMem data.
Mat createMatHeader() const;
operator Mat() const;
//! maps host memory into device address space and returns GpuMat header for it. Throws exception if not supported by hardware.
GpuMat createGpuMatHeader() const;
operator GpuMat() const;
//returns if host memory can be mapperd to gpu address space;
static bool canMapHostMemory();
// Please see cv::Mat for descriptions
bool isContinuous() const;
size_t elemSize() const;
size_t elemSize1() const;
int type() const;
int depth() const;
int channels() const;
size_t step1() const;
Size size() const;
bool empty() const;
// Please see cv::Mat for descriptions
int flags;
int rows, cols;
size_t step;
uchar* data;
int* refcount;
uchar* datastart;
uchar* dataend;
int alloc_type;
};
//////////////////////////////// CudaStream ////////////////////////////////
// Encapculates Cuda Stream. Provides interface for async coping.
// Passed to each function that supports async kernel execution.
// Reference counting is enabled
class CV_EXPORTS Stream
{
public:
Stream();
~Stream();
Stream(const Stream&);
Stream& operator=(const Stream&);
bool queryIfComplete();
void waitForCompletion();
//! downloads asynchronously.
// Warning! cv::Mat must point to page locked memory (i.e. to CudaMem data or to its subMat)
void enqueueDownload(const GpuMat& src, CudaMem& dst);
void enqueueDownload(const GpuMat& src, Mat& dst);
//! uploads asynchronously.
// Warning! cv::Mat must point to page locked memory (i.e. to CudaMem data or to its ROI)
void enqueueUpload(const CudaMem& src, GpuMat& dst);
void enqueueUpload(const Mat& src, GpuMat& dst);
void enqueueCopy(const GpuMat& src, GpuMat& dst);
void enqueueMemSet(GpuMat& src, Scalar val);
void enqueueMemSet(GpuMat& src, Scalar val, const GpuMat& mask);
// converts matrix type, ex from float to uchar depending on type
void enqueueConvert(const GpuMat& src, GpuMat& dst, int type, double a = 1, double b = 0);
static Stream& Null();
operator bool() const;
private:
void create();
void release();
struct Impl;
Impl *impl;
friend struct StreamAccessor;
explicit Stream(Impl* impl);
};
//////////////////////////////// Filter Engine ////////////////////////////////
/*!
The Base Class for 1D or Row-wise Filters
This is the base class for linear or non-linear filters that process 1D data.
In particular, such filters are used for the "horizontal" filtering parts in separable filters.
*/
class CV_EXPORTS BaseRowFilter_GPU
{
public:
BaseRowFilter_GPU(int ksize_, int anchor_) : ksize(ksize_), anchor(anchor_) {}
virtual ~BaseRowFilter_GPU() {}
virtual void operator()(const GpuMat& src, GpuMat& dst, Stream& stream = Stream::Null()) = 0;
int ksize, anchor;
};
/*!
The Base Class for Column-wise Filters
This is the base class for linear or non-linear filters that process columns of 2D arrays.
Such filters are used for the "vertical" filtering parts in separable filters.
*/
class CV_EXPORTS BaseColumnFilter_GPU
{
public:
BaseColumnFilter_GPU(int ksize_, int anchor_) : ksize(ksize_), anchor(anchor_) {}
virtual ~BaseColumnFilter_GPU() {}
virtual void operator()(const GpuMat& src, GpuMat& dst, Stream& stream = Stream::Null()) = 0;
int ksize, anchor;
};
/*!
The Base Class for Non-Separable 2D Filters.
This is the base class for linear or non-linear 2D filters.
*/
class CV_EXPORTS BaseFilter_GPU
{
public:
BaseFilter_GPU(const Size& ksize_, const Point& anchor_) : ksize(ksize_), anchor(anchor_) {}
virtual ~BaseFilter_GPU() {}
virtual void operator()(const GpuMat& src, GpuMat& dst, Stream& stream = Stream::Null()) = 0;
Size ksize;
Point anchor;
};
/*!
The Base Class for Filter Engine.
The class can be used to apply an arbitrary filtering operation to an image.
It contains all the necessary intermediate buffers.
*/
class CV_EXPORTS FilterEngine_GPU
{
public:
virtual ~FilterEngine_GPU() {}
virtual void apply(const GpuMat& src, GpuMat& dst, Rect roi = Rect(0,0,-1,-1), Stream& stream = Stream::Null()) = 0;
};
//! returns the non-separable filter engine with the specified filter
CV_EXPORTS Ptr<FilterEngine_GPU> createFilter2D_GPU(const Ptr<BaseFilter_GPU>& filter2D, int srcType, int dstType);
//! returns the separable filter engine with the specified filters
CV_EXPORTS Ptr<FilterEngine_GPU> createSeparableFilter_GPU(const Ptr<BaseRowFilter_GPU>& rowFilter,
const Ptr<BaseColumnFilter_GPU>& columnFilter, int srcType, int bufType, int dstType);
//! returns horizontal 1D box filter
//! supports only CV_8UC1 source type and CV_32FC1 sum type
CV_EXPORTS Ptr<BaseRowFilter_GPU> getRowSumFilter_GPU(int srcType, int sumType, int ksize, int anchor = -1);
//! returns vertical 1D box filter
//! supports only CV_8UC1 sum type and CV_32FC1 dst type
CV_EXPORTS Ptr<BaseColumnFilter_GPU> getColumnSumFilter_GPU(int sumType, int dstType, int ksize, int anchor = -1);
//! returns 2D box filter
//! supports CV_8UC1 and CV_8UC4 source type, dst type must be the same as source type
CV_EXPORTS Ptr<BaseFilter_GPU> getBoxFilter_GPU(int srcType, int dstType, const Size& ksize, Point anchor = Point(-1, -1));
//! returns box filter engine
CV_EXPORTS Ptr<FilterEngine_GPU> createBoxFilter_GPU(int srcType, int dstType, const Size& ksize,
const Point& anchor = Point(-1,-1));
//! returns 2D morphological filter
//! only MORPH_ERODE and MORPH_DILATE are supported
//! supports CV_8UC1 and CV_8UC4 types
//! kernel must have CV_8UC1 type, one rows and cols == ksize.width * ksize.height
CV_EXPORTS Ptr<BaseFilter_GPU> getMorphologyFilter_GPU(int op, int type, const Mat& kernel, const Size& ksize,
Point anchor=Point(-1,-1));
//! returns morphological filter engine. Only MORPH_ERODE and MORPH_DILATE are supported.
CV_EXPORTS Ptr<FilterEngine_GPU> createMorphologyFilter_GPU(int op, int type, const Mat& kernel,
const Point& anchor = Point(-1,-1), int iterations = 1);
//! returns 2D filter with the specified kernel
//! supports CV_8UC1 and CV_8UC4 types
CV_EXPORTS Ptr<BaseFilter_GPU> getLinearFilter_GPU(int srcType, int dstType, const Mat& kernel, const Size& ksize,
Point anchor = Point(-1, -1));
//! returns the non-separable linear filter engine
CV_EXPORTS Ptr<FilterEngine_GPU> createLinearFilter_GPU(int srcType, int dstType, const Mat& kernel,
const Point& anchor = Point(-1,-1));
//! returns the primitive row filter with the specified kernel.
//! supports only CV_8UC1, CV_8UC4, CV_16SC1, CV_16SC2, CV_32SC1, CV_32FC1 source type.
//! there are two version of algorithm: NPP and OpenCV.
//! NPP calls when srcType == CV_8UC1 or srcType == CV_8UC4 and bufType == srcType,
//! otherwise calls OpenCV version.
//! NPP supports only BORDER_CONSTANT border type.
//! OpenCV version supports only CV_32F as buffer depth and
//! BORDER_REFLECT101, BORDER_REPLICATE and BORDER_CONSTANT border types.
CV_EXPORTS Ptr<BaseRowFilter_GPU> getLinearRowFilter_GPU(int srcType, int bufType, const Mat& rowKernel,
int anchor = -1, int borderType = BORDER_CONSTANT);
//! returns the primitive column filter with the specified kernel.
//! supports only CV_8UC1, CV_8UC4, CV_16SC1, CV_16SC2, CV_32SC1, CV_32FC1 dst type.
//! there are two version of algorithm: NPP and OpenCV.
//! NPP calls when dstType == CV_8UC1 or dstType == CV_8UC4 and bufType == dstType,
//! otherwise calls OpenCV version.
//! NPP supports only BORDER_CONSTANT border type.
//! OpenCV version supports only CV_32F as buffer depth and
//! BORDER_REFLECT101, BORDER_REPLICATE and BORDER_CONSTANT border types.
CV_EXPORTS Ptr<BaseColumnFilter_GPU> getLinearColumnFilter_GPU(int bufType, int dstType, const Mat& columnKernel,
int anchor = -1, int borderType = BORDER_CONSTANT);
//! returns the separable linear filter engine
CV_EXPORTS Ptr<FilterEngine_GPU> createSeparableLinearFilter_GPU(int srcType, int dstType, const Mat& rowKernel,
const Mat& columnKernel, const Point& anchor = Point(-1,-1), int rowBorderType = BORDER_DEFAULT,
int columnBorderType = -1);
//! returns filter engine for the generalized Sobel operator
CV_EXPORTS Ptr<FilterEngine_GPU> createDerivFilter_GPU(int srcType, int dstType, int dx, int dy, int ksize,
int rowBorderType = BORDER_DEFAULT, int columnBorderType = -1);
//! returns the Gaussian filter engine
CV_EXPORTS Ptr<FilterEngine_GPU> createGaussianFilter_GPU(int type, Size ksize, double sigma1, double sigma2 = 0,
int rowBorderType = BORDER_DEFAULT, int columnBorderType = -1);
//! returns maximum filter
CV_EXPORTS Ptr<BaseFilter_GPU> getMaxFilter_GPU(int srcType, int dstType, const Size& ksize, Point anchor = Point(-1,-1));
//! returns minimum filter
CV_EXPORTS Ptr<BaseFilter_GPU> getMinFilter_GPU(int srcType, int dstType, const Size& ksize, Point anchor = Point(-1,-1));
//! smooths the image using the normalized box filter
//! supports CV_8UC1, CV_8UC4 types
CV_EXPORTS void boxFilter(const GpuMat& src, GpuMat& dst, int ddepth, Size ksize, Point anchor = Point(-1,-1), Stream& stream = Stream::Null());
//! a synonym for normalized box filter
static inline void blur(const GpuMat& src, GpuMat& dst, Size ksize, Point anchor = Point(-1,-1), Stream& stream = Stream::Null()) { boxFilter(src, dst, -1, ksize, anchor, stream); }
//! erodes the image (applies the local minimum operator)
CV_EXPORTS void erode( const GpuMat& src, GpuMat& dst, const Mat& kernel, Point anchor = Point(-1, -1), int iterations = 1, Stream& stream = Stream::Null());
//! dilates the image (applies the local maximum operator)
CV_EXPORTS void dilate( const GpuMat& src, GpuMat& dst, const Mat& kernel, Point anchor = Point(-1, -1), int iterations = 1, Stream& stream = Stream::Null());
//! applies an advanced morphological operation to the image
CV_EXPORTS void morphologyEx( const GpuMat& src, GpuMat& dst, int op, const Mat& kernel, Point anchor = Point(-1, -1), int iterations = 1, Stream& stream = Stream::Null());
//! applies non-separable 2D linear filter to the image
CV_EXPORTS void filter2D(const GpuMat& src, GpuMat& dst, int ddepth, const Mat& kernel, Point anchor=Point(-1,-1), Stream& stream = Stream::Null());
//! applies separable 2D linear filter to the image
CV_EXPORTS void sepFilter2D(const GpuMat& src, GpuMat& dst, int ddepth, const Mat& kernelX, const Mat& kernelY,
Point anchor = Point(-1,-1), int rowBorderType = BORDER_DEFAULT, int columnBorderType = -1, Stream& stream = Stream::Null());
//! applies generalized Sobel operator to the image
CV_EXPORTS void Sobel(const GpuMat& src, GpuMat& dst, int ddepth, int dx, int dy, int ksize = 3, double scale = 1,
int rowBorderType = BORDER_DEFAULT, int columnBorderType = -1, Stream& stream = Stream::Null());
//! applies the vertical or horizontal Scharr operator to the image
CV_EXPORTS void Scharr(const GpuMat& src, GpuMat& dst, int ddepth, int dx, int dy, double scale = 1,
int rowBorderType = BORDER_DEFAULT, int columnBorderType = -1, Stream& stream = Stream::Null());
//! smooths the image using Gaussian filter.
CV_EXPORTS void GaussianBlur(const GpuMat& src, GpuMat& dst, Size ksize, double sigma1, double sigma2 = 0,
int rowBorderType = BORDER_DEFAULT, int columnBorderType = -1, Stream& stream = Stream::Null());
//! applies Laplacian operator to the image
//! supports only ksize = 1 and ksize = 3
CV_EXPORTS void Laplacian(const GpuMat& src, GpuMat& dst, int ddepth, int ksize = 1, double scale = 1, Stream& stream = Stream::Null());
////////////////////////////// Arithmetics ///////////////////////////////////
//! transposes the matrix
//! supports matrix with element size = 1, 4 and 8 bytes (CV_8UC1, CV_8UC4, CV_16UC2, CV_32FC1, etc)
CV_EXPORTS void transpose(const GpuMat& src1, GpuMat& dst, Stream& stream = Stream::Null());
//! reverses the order of the rows, columns or both in a matrix
//! supports CV_8UC1, CV_8UC4 types
CV_EXPORTS void flip(const GpuMat& a, GpuMat& b, int flipCode, Stream& stream = Stream::Null());
//! transforms 8-bit unsigned integers using lookup table: dst(i)=lut(src(i))
//! destination array will have the depth type as lut and the same channels number as source
//! supports CV_8UC1, CV_8UC3 types
CV_EXPORTS void LUT(const GpuMat& src, const Mat& lut, GpuMat& dst, Stream& stream = Stream::Null());
//! makes multi-channel array out of several single-channel arrays
CV_EXPORTS void merge(const GpuMat* src, size_t n, GpuMat& dst, Stream& stream = Stream::Null());
//! makes multi-channel array out of several single-channel arrays
CV_EXPORTS void merge(const vector<GpuMat>& src, GpuMat& dst, Stream& stream = Stream::Null());
//! copies each plane of a multi-channel array to a dedicated array
CV_EXPORTS void split(const GpuMat& src, GpuMat* dst, Stream& stream = Stream::Null());
//! copies each plane of a multi-channel array to a dedicated array
CV_EXPORTS void split(const GpuMat& src, vector<GpuMat>& dst, Stream& stream = Stream::Null());
//! computes magnitude of complex (x(i).re, x(i).im) vector
//! supports only CV_32FC2 type
CV_EXPORTS void magnitude(const GpuMat& x, GpuMat& magnitude, Stream& stream = Stream::Null());
//! computes squared magnitude of complex (x(i).re, x(i).im) vector
//! supports only CV_32FC2 type
CV_EXPORTS void magnitudeSqr(const GpuMat& x, GpuMat& magnitude, Stream& stream = Stream::Null());
//! computes magnitude of each (x(i), y(i)) vector
//! supports only floating-point source
CV_EXPORTS void magnitude(const GpuMat& x, const GpuMat& y, GpuMat& magnitude, Stream& stream = Stream::Null());
//! computes squared magnitude of each (x(i), y(i)) vector
//! supports only floating-point source
CV_EXPORTS void magnitudeSqr(const GpuMat& x, const GpuMat& y, GpuMat& magnitude, Stream& stream = Stream::Null());
//! computes angle (angle(i)) of each (x(i), y(i)) vector
//! supports only floating-point source
CV_EXPORTS void phase(const GpuMat& x, const GpuMat& y, GpuMat& angle, bool angleInDegrees = false, Stream& stream = Stream::Null());
//! converts Cartesian coordinates to polar
//! supports only floating-point source
CV_EXPORTS void cartToPolar(const GpuMat& x, const GpuMat& y, GpuMat& magnitude, GpuMat& angle, bool angleInDegrees = false, Stream& stream = Stream::Null());
//! converts polar coordinates to Cartesian
//! supports only floating-point source
CV_EXPORTS void polarToCart(const GpuMat& magnitude, const GpuMat& angle, GpuMat& x, GpuMat& y, bool angleInDegrees = false, Stream& stream = Stream::Null());
//////////////////////////// Per-element operations ////////////////////////////////////
//! adds one matrix to another (c = a + b)
//! supports CV_8UC1, CV_8UC4, CV_32SC1, CV_32FC1 types
CV_EXPORTS void add(const GpuMat& a, const GpuMat& b, GpuMat& c, Stream& stream = Stream::Null());
//! adds scalar to a matrix (c = a + s)
//! supports CV_32FC1 and CV_32FC2 type
CV_EXPORTS void add(const GpuMat& a, const Scalar& sc, GpuMat& c, Stream& stream = Stream::Null());
//! subtracts one matrix from another (c = a - b)
//! supports CV_8UC1, CV_8UC4, CV_32SC1, CV_32FC1 types
CV_EXPORTS void subtract(const GpuMat& a, const GpuMat& b, GpuMat& c, Stream& stream = Stream::Null());
//! subtracts scalar from a matrix (c = a - s)
//! supports CV_32FC1 and CV_32FC2 type
CV_EXPORTS void subtract(const GpuMat& a, const Scalar& sc, GpuMat& c, Stream& stream = Stream::Null());
//! computes element-wise product of the two arrays (c = a * b)
//! supports CV_8UC1, CV_8UC4, CV_32SC1, CV_32FC1 types
CV_EXPORTS void multiply(const GpuMat& a, const GpuMat& b, GpuMat& c, Stream& stream = Stream::Null());
//! multiplies matrix to a scalar (c = a * s)
//! supports CV_32FC1 type
CV_EXPORTS void multiply(const GpuMat& a, const Scalar& sc, GpuMat& c, Stream& stream = Stream::Null());
//! computes element-wise quotient of the two arrays (c = a / b)
//! supports CV_8UC1, CV_8UC4, CV_32SC1, CV_32FC1 types
CV_EXPORTS void divide(const GpuMat& a, const GpuMat& b, GpuMat& c, Stream& stream = Stream::Null());
//! computes element-wise quotient of matrix and scalar (c = a / s)
//! supports CV_32FC1 type
CV_EXPORTS void divide(const GpuMat& a, const Scalar& sc, GpuMat& c, Stream& stream = Stream::Null());
//! computes exponent of each matrix element (b = e**a)
//! supports only CV_32FC1 type
CV_EXPORTS void exp(const GpuMat& a, GpuMat& b, Stream& stream = Stream::Null());
//! computes power of each matrix element:
// (dst(i,j) = pow( src(i,j) , power), if src.type() is integer
// (dst(i,j) = pow(fabs(src(i,j)), power), otherwise
//! supports all, except depth == CV_64F
CV_EXPORTS void pow(const GpuMat& src, double power, GpuMat& dst, Stream& stream = Stream::Null());
//! computes natural logarithm of absolute value of each matrix element: b = log(abs(a))
//! supports only CV_32FC1 type
CV_EXPORTS void log(const GpuMat& a, GpuMat& b, Stream& stream = Stream::Null());
//! computes element-wise absolute difference of two arrays (c = abs(a - b))
//! supports CV_8UC1, CV_8UC4, CV_32SC1, CV_32FC1 types
CV_EXPORTS void absdiff(const GpuMat& a, const GpuMat& b, GpuMat& c, Stream& stream = Stream::Null());
//! computes element-wise absolute difference of array and scalar (c = abs(a - s))
//! supports only CV_32FC1 type
CV_EXPORTS void absdiff(const GpuMat& a, const Scalar& s, GpuMat& c, Stream& stream = Stream::Null());
//! compares elements of two arrays (c = a <cmpop> b)
//! supports CV_8UC4, CV_32FC1 types
CV_EXPORTS void compare(const GpuMat& a, const GpuMat& b, GpuMat& c, int cmpop, Stream& stream = Stream::Null());
//! performs per-elements bit-wise inversion
CV_EXPORTS void bitwise_not(const GpuMat& src, GpuMat& dst, const GpuMat& mask=GpuMat(), Stream& stream = Stream::Null());
//! calculates per-element bit-wise disjunction of two arrays
CV_EXPORTS void bitwise_or(const GpuMat& src1, const GpuMat& src2, GpuMat& dst, const GpuMat& mask=GpuMat(), Stream& stream = Stream::Null());
//! calculates per-element bit-wise conjunction of two arrays
CV_EXPORTS void bitwise_and(const GpuMat& src1, const GpuMat& src2, GpuMat& dst, const GpuMat& mask=GpuMat(), Stream& stream = Stream::Null());
//! calculates per-element bit-wise "exclusive or" operation
CV_EXPORTS void bitwise_xor(const GpuMat& src1, const GpuMat& src2, GpuMat& dst, const GpuMat& mask=GpuMat(), Stream& stream = Stream::Null());
//! computes per-element minimum of two arrays (dst = min(src1, src2))
CV_EXPORTS void min(const GpuMat& src1, const GpuMat& src2, GpuMat& dst, Stream& stream = Stream::Null());
//! computes per-element minimum of array and scalar (dst = min(src1, src2))
CV_EXPORTS void min(const GpuMat& src1, double src2, GpuMat& dst, Stream& stream = Stream::Null());
//! computes per-element maximum of two arrays (dst = max(src1, src2))
CV_EXPORTS void max(const GpuMat& src1, const GpuMat& src2, GpuMat& dst, Stream& stream = Stream::Null());
//! computes per-element maximum of array and scalar (dst = max(src1, src2))
CV_EXPORTS void max(const GpuMat& src1, double src2, GpuMat& dst, Stream& stream = Stream::Null());
////////////////////////////// Image processing //////////////////////////////
//! DST[x,y] = SRC[xmap[x,y],ymap[x,y]] with bilinear interpolation.
//! supports CV_8UC1, CV_8UC3 source types and CV_32FC1 map type
CV_EXPORTS void remap(const GpuMat& src, GpuMat& dst, const GpuMat& xmap, const GpuMat& ymap);
//! Does mean shift filtering on GPU.
CV_EXPORTS void meanShiftFiltering(const GpuMat& src, GpuMat& dst, int sp, int sr,
TermCriteria criteria = TermCriteria(TermCriteria::MAX_ITER + TermCriteria::EPS, 5, 1));
//! Does mean shift procedure on GPU.
CV_EXPORTS void meanShiftProc(const GpuMat& src, GpuMat& dstr, GpuMat& dstsp, int sp, int sr,
TermCriteria criteria = TermCriteria(TermCriteria::MAX_ITER + TermCriteria::EPS, 5, 1));
//! Does mean shift segmentation with elimination of small regions.
CV_EXPORTS void meanShiftSegmentation(const GpuMat& src, Mat& dst, int sp, int sr, int minsize,
TermCriteria criteria = TermCriteria(TermCriteria::MAX_ITER + TermCriteria::EPS, 5, 1));
//! Does coloring of disparity image: [0..ndisp) -> [0..240, 1, 1] in HSV.
//! Supported types of input disparity: CV_8U, CV_16S.
//! Output disparity has CV_8UC4 type in BGRA format (alpha = 255).
CV_EXPORTS void drawColorDisp(const GpuMat& src_disp, GpuMat& dst_disp, int ndisp, Stream& stream = Stream::Null());
//! Reprojects disparity image to 3D space.
//! Supports CV_8U and CV_16S types of input disparity.
//! The output is a 4-channel floating-point (CV_32FC4) matrix.
//! Each element of this matrix will contain the 3D coordinates of the point (x,y,z,1), computed from the disparity map.
//! Q is the 4x4 perspective transformation matrix that can be obtained with cvStereoRectify.
CV_EXPORTS void reprojectImageTo3D(const GpuMat& disp, GpuMat& xyzw, const Mat& Q, Stream& stream = Stream::Null());
//! converts image from one color space to another
CV_EXPORTS void cvtColor(const GpuMat& src, GpuMat& dst, int code, int dcn = 0, Stream& stream = Stream::Null());
//! applies fixed threshold to the image
CV_EXPORTS double threshold(const GpuMat& src, GpuMat& dst, double thresh, double maxval, int type, Stream& stream = Stream::Null());
//! resizes the image
//! Supports INTER_NEAREST, INTER_LINEAR
//! supports CV_8UC1, CV_8UC4 types
CV_EXPORTS void resize(const GpuMat& src, GpuMat& dst, Size dsize, double fx=0, double fy=0, int interpolation = INTER_LINEAR, Stream& stream = Stream::Null());
//! warps the image using affine transformation
//! Supports INTER_NEAREST, INTER_LINEAR, INTER_CUBIC
CV_EXPORTS void warpAffine(const GpuMat& src, GpuMat& dst, const Mat& M, Size dsize, int flags = INTER_LINEAR, Stream& stream = Stream::Null());
//! warps the image using perspective transformation
//! Supports INTER_NEAREST, INTER_LINEAR, INTER_CUBIC
CV_EXPORTS void warpPerspective(const GpuMat& src, GpuMat& dst, const Mat& M, Size dsize, int flags = INTER_LINEAR, Stream& stream = Stream::Null());
//! builds plane warping maps
CV_EXPORTS void buildWarpPlaneMaps(Size src_size, Rect dst_roi, const Mat& R, double f, double s, double dist,
GpuMat& map_x, GpuMat& map_y, Stream& stream = Stream::Null());
//! builds cylindrical warping maps
CV_EXPORTS void buildWarpCylindricalMaps(Size src_size, Rect dst_roi, const Mat& R, double f, double s,
GpuMat& map_x, GpuMat& map_y, Stream& stream = Stream::Null());
//! builds spherical warping maps
CV_EXPORTS void buildWarpSphericalMaps(Size src_size, Rect dst_roi, const Mat& R, double f, double s,
GpuMat& map_x, GpuMat& map_y, Stream& stream = Stream::Null());
//! rotate 8bit single or four channel image
//! Supports INTER_NEAREST, INTER_LINEAR, INTER_CUBIC
//! supports CV_8UC1, CV_8UC4 types
CV_EXPORTS void rotate(const GpuMat& src, GpuMat& dst, Size dsize, double angle, double xShift = 0, double yShift = 0, int interpolation = INTER_LINEAR, Stream& stream = Stream::Null());
//! copies 2D array to a larger destination array and pads borders with user-specifiable constant
//! supports CV_8UC1, CV_8UC4, CV_32SC1 and CV_32FC1 types
CV_EXPORTS void copyMakeBorder(const GpuMat& src, GpuMat& dst, int top, int bottom, int left, int right, const Scalar& value = Scalar(), Stream& stream = Stream::Null());
//! computes the integral image
//! sum will have CV_32S type, but will contain unsigned int values
//! supports only CV_8UC1 source type
CV_EXPORTS void integral(const GpuMat& src, GpuMat& sum, Stream& stream = Stream::Null());
//! buffered version
CV_EXPORTS void integralBuffered(const GpuMat& src, GpuMat& sum, GpuMat& buffer, Stream& stream = Stream::Null());
//! computes the integral image and integral for the squared image
//! sum will have CV_32S type, sqsum - CV32F type
//! supports only CV_8UC1 source type
CV_EXPORTS void integral(const GpuMat& src, GpuMat& sum, GpuMat& sqsum, Stream& stream = Stream::Null());
//! computes squared integral image
//! result matrix will have 64F type, but will contain 64U values
//! supports source images of 8UC1 type only
CV_EXPORTS void sqrIntegral(const GpuMat& src, GpuMat& sqsum, Stream& stream = Stream::Null());
//! computes vertical sum, supports only CV_32FC1 images
CV_EXPORTS void columnSum(const GpuMat& src, GpuMat& sum);
//! computes the standard deviation of integral images
//! supports only CV_32SC1 source type and CV_32FC1 sqr type
//! output will have CV_32FC1 type
CV_EXPORTS void rectStdDev(const GpuMat& src, const GpuMat& sqr, GpuMat& dst, const Rect& rect, Stream& stream = Stream::Null());
//! computes Harris cornerness criteria at each image pixel
CV_EXPORTS void cornerHarris(const GpuMat& src, GpuMat& dst, int blockSize, int ksize, double k, int borderType=BORDER_REFLECT101);
CV_EXPORTS void cornerHarris(const GpuMat& src, GpuMat& dst, GpuMat& Dx, GpuMat& Dy, int blockSize, int ksize, double k, int borderType=BORDER_REFLECT101);
//! computes minimum eigen value of 2x2 derivative covariation matrix at each pixel - the cornerness criteria
CV_EXPORTS void cornerMinEigenVal(const GpuMat& src, GpuMat& dst, int blockSize, int ksize, int borderType=BORDER_REFLECT101);
CV_EXPORTS void cornerMinEigenVal(const GpuMat& src, GpuMat& dst, GpuMat& Dx, GpuMat& Dy, int blockSize, int ksize, int borderType=BORDER_REFLECT101);
//! performs per-element multiplication of two full (not packed) Fourier spectrums
//! supports 32FC2 matrixes only (interleaved format)
CV_EXPORTS void mulSpectrums(const GpuMat& a, const GpuMat& b, GpuMat& c, int flags, bool conjB=false);
//! performs per-element multiplication of two full (not packed) Fourier spectrums
//! supports 32FC2 matrixes only (interleaved format)
CV_EXPORTS void mulAndScaleSpectrums(const GpuMat& a, const GpuMat& b, GpuMat& c, int flags,
float scale, bool conjB=false);
//! Performs a forward or inverse discrete Fourier transform (1D or 2D) of floating point matrix.
//! Param dft_size is the size of DFT transform.
//!
//! If the source matrix is not continous, then additional copy will be done,
//! so to avoid copying ensure the source matrix is continous one. If you want to use
//! preallocated output ensure it is continuous too, otherwise it will be reallocated.
//!
//! Being implemented via CUFFT real-to-complex transform result contains only non-redundant values
//! in CUFFT's format. Result as full complex matrix for such kind of transform cannot be retrieved.
//!
//! For complex-to-real transform it is assumed that the source matrix is packed in CUFFT's format.
CV_EXPORTS void dft(const GpuMat& src, GpuMat& dst, Size dft_size, int flags=0);
//! computes convolution (or cross-correlation) of two images using discrete Fourier transform
//! supports source images of 32FC1 type only
//! result matrix will have 32FC1 type
CV_EXPORTS void convolve(const GpuMat& image, const GpuMat& templ, GpuMat& result,
bool ccorr=false);
struct CV_EXPORTS ConvolveBuf;
//! buffered version
CV_EXPORTS void convolve(const GpuMat& image, const GpuMat& templ, GpuMat& result,
bool ccorr, ConvolveBuf& buf);
struct CV_EXPORTS ConvolveBuf
{
ConvolveBuf() {}
ConvolveBuf(Size image_size, Size templ_size)
{ create(image_size, templ_size); }
void create(Size image_size, Size templ_size);
private:
static Size estimateBlockSize(Size result_size, Size templ_size);
friend void convolve(const GpuMat&, const GpuMat&, GpuMat&, bool, ConvolveBuf&);
Size result_size;
Size block_size;
Size dft_size;
int spect_len;
GpuMat image_spect, templ_spect, result_spect;
GpuMat image_block, templ_block, result_data;
};
//! computes the proximity map for the raster template and the image where the template is searched for
CV_EXPORTS void matchTemplate(const GpuMat& image, const GpuMat& templ, GpuMat& result, int method);
//! downsamples image
CV_EXPORTS void downsample(const GpuMat& src, GpuMat& dst, Stream& stream = Stream::Null());
//! upsamples image
CV_EXPORTS void upsample(const GpuMat& src, GpuMat &dst, Stream& stream = Stream::Null());
//! smoothes the source image and downsamples it
CV_EXPORTS void pyrDown(const GpuMat& src, GpuMat& dst, Stream& stream = Stream::Null());
struct CV_EXPORTS PyrDownBuf;
CV_EXPORTS void pyrDown(const GpuMat& src, GpuMat& dst, PyrDownBuf& buf, Stream& stream = Stream::Null());
struct CV_EXPORTS PyrDownBuf
{
PyrDownBuf() : image_type(-1) {}
PyrDownBuf(Size image_size, int image_type_) : image_type(-1) { create(image_size, image_type_); }
void create(Size image_size, int image_type_);
private:
friend void pyrDown(const GpuMat&, GpuMat&, PyrDownBuf&, Stream& stream);
static Mat ker;
GpuMat buf;
Ptr<FilterEngine_GPU> filter;
int image_type;
};
//! upsamples the source image and then smoothes it
CV_EXPORTS void pyrUp(const GpuMat& src, GpuMat& dst, Stream& stream = Stream::Null());
struct CV_EXPORTS PyrUpBuf;
CV_EXPORTS void pyrUp(const GpuMat& src, GpuMat& dst, PyrUpBuf& buf, Stream& stream = Stream::Null());
struct CV_EXPORTS PyrUpBuf
{
PyrUpBuf() : image_type(-1) {}
PyrUpBuf(Size image_size, int image_type_) : image_type(-1) { create(image_size, image_type_); }
void create(Size image_size, int image_type_);
private:
friend void pyrUp(const GpuMat&, GpuMat&, PyrUpBuf&, Stream& stream);
static Mat ker;
GpuMat buf;
Ptr<FilterEngine_GPU> filter;
int image_type;
};
//! performs linear blending of two images
//! to avoid accuracy errors sum of weigths shouldn't be very close to zero
CV_EXPORTS void blendLinear(const GpuMat& img1, const GpuMat& img2, const GpuMat& weights1, const GpuMat& weights2,
GpuMat& result, Stream& stream = Stream::Null());
struct CV_EXPORTS CannyBuf;
CV_EXPORTS void Canny(const GpuMat& image, GpuMat& edges, double low_thresh, double high_thresh, int apperture_size = 3, bool L2gradient = false);
CV_EXPORTS void Canny(const GpuMat& image, CannyBuf& buf, GpuMat& edges, double low_thresh, double high_thresh, int apperture_size = 3, bool L2gradient = false);
CV_EXPORTS void Canny(const GpuMat& dx, const GpuMat& dy, GpuMat& edges, double low_thresh, double high_thresh, bool L2gradient = false);
CV_EXPORTS void Canny(const GpuMat& dx, const GpuMat& dy, CannyBuf& buf, GpuMat& edges, double low_thresh, double high_thresh, bool L2gradient = false);
struct CV_EXPORTS CannyBuf
{
CannyBuf() {}
explicit CannyBuf(const Size& image_size, int apperture_size = 3) {create(image_size, apperture_size);}
CannyBuf(const GpuMat& dx_, const GpuMat& dy_);
void create(const Size& image_size, int apperture_size = 3);
void release();
GpuMat dx, dy;
GpuMat dx_buf, dy_buf;
GpuMat edgeBuf;
GpuMat trackBuf1, trackBuf2;
Ptr<FilterEngine_GPU> filterDX, filterDY;
};
////////////////////////////// Matrix reductions //////////////////////////////
//! computes mean value and standard deviation of all or selected array elements
//! supports only CV_8UC1 type
CV_EXPORTS void meanStdDev(const GpuMat& mtx, Scalar& mean, Scalar& stddev);
//! computes norm of array
//! supports NORM_INF, NORM_L1, NORM_L2
//! supports all matrices except 64F
CV_EXPORTS double norm(const GpuMat& src1, int normType=NORM_L2);
//! computes norm of array
//! supports NORM_INF, NORM_L1, NORM_L2
//! supports all matrices except 64F
CV_EXPORTS double norm(const GpuMat& src1, int normType, GpuMat& buf);
//! computes norm of the difference between two arrays
//! supports NORM_INF, NORM_L1, NORM_L2
//! supports only CV_8UC1 type
CV_EXPORTS double norm(const GpuMat& src1, const GpuMat& src2, int normType=NORM_L2);
//! computes sum of array elements
//! supports only single channel images
CV_EXPORTS Scalar sum(const GpuMat& src);
//! computes sum of array elements
//! supports only single channel images
CV_EXPORTS Scalar sum(const GpuMat& src, GpuMat& buf);
//! computes sum of array elements absolute values
//! supports only single channel images
CV_EXPORTS Scalar absSum(const GpuMat& src);
//! computes sum of array elements absolute values
//! supports only single channel images
CV_EXPORTS Scalar absSum(const GpuMat& src, GpuMat& buf);
//! computes squared sum of array elements
//! supports only single channel images
CV_EXPORTS Scalar sqrSum(const GpuMat& src);
//! computes squared sum of array elements
//! supports only single channel images
CV_EXPORTS Scalar sqrSum(const GpuMat& src, GpuMat& buf);
//! finds global minimum and maximum array elements and returns their values
CV_EXPORTS void minMax(const GpuMat& src, double* minVal, double* maxVal=0, const GpuMat& mask=GpuMat());
//! finds global minimum and maximum array elements and returns their values
CV_EXPORTS void minMax(const GpuMat& src, double* minVal, double* maxVal, const GpuMat& mask, GpuMat& buf);
//! finds global minimum and maximum array elements and returns their values with locations
CV_EXPORTS void minMaxLoc(const GpuMat& src, double* minVal, double* maxVal=0, Point* minLoc=0, Point* maxLoc=0,
const GpuMat& mask=GpuMat());
//! finds global minimum and maximum array elements and returns their values with locations
CV_EXPORTS void minMaxLoc(const GpuMat& src, double* minVal, double* maxVal, Point* minLoc, Point* maxLoc,
const GpuMat& mask, GpuMat& valbuf, GpuMat& locbuf);
//! counts non-zero array elements
CV_EXPORTS int countNonZero(const GpuMat& src);
//! counts non-zero array elements
CV_EXPORTS int countNonZero(const GpuMat& src, GpuMat& buf);
///////////////////////////// Calibration 3D //////////////////////////////////
CV_EXPORTS void transformPoints(const GpuMat& src, const Mat& rvec, const Mat& tvec,
GpuMat& dst, Stream& stream = Stream::Null());
CV_EXPORTS void projectPoints(const GpuMat& src, const Mat& rvec, const Mat& tvec,
const Mat& camera_mat, const Mat& dist_coef, GpuMat& dst,
Stream& stream = Stream::Null());
CV_EXPORTS void solvePnPRansac(const Mat& object, const Mat& image, const Mat& camera_mat,
const Mat& dist_coef, Mat& rvec, Mat& tvec, bool use_extrinsic_guess=false,
int num_iters=100, float max_dist=8.0, int min_inlier_count=100,
vector<int>* inliers=NULL);
//////////////////////////////// Image Labeling ////////////////////////////////
//!performs labeling via graph cuts
CV_EXPORTS void graphcut(GpuMat& terminals, GpuMat& leftTransp, GpuMat& rightTransp, GpuMat& top, GpuMat& bottom, GpuMat& labels, GpuMat& buf, Stream& stream = Stream::Null());
////////////////////////////////// Histograms //////////////////////////////////
//! Compute levels with even distribution. levels will have 1 row and nLevels cols and CV_32SC1 type.
CV_EXPORTS void evenLevels(GpuMat& levels, int nLevels, int lowerLevel, int upperLevel);
//! Calculates histogram with evenly distributed bins for signle channel source.
//! Supports CV_8UC1, CV_16UC1 and CV_16SC1 source types.
//! Output hist will have one row and histSize cols and CV_32SC1 type.
CV_EXPORTS void histEven(const GpuMat& src, GpuMat& hist, int histSize, int lowerLevel, int upperLevel, Stream& stream = Stream::Null());
CV_EXPORTS void histEven(const GpuMat& src, GpuMat& hist, GpuMat& buf, int histSize, int lowerLevel, int upperLevel, Stream& stream = Stream::Null());
//! Calculates histogram with evenly distributed bins for four-channel source.
//! All channels of source are processed separately.
//! Supports CV_8UC4, CV_16UC4 and CV_16SC4 source types.
//! Output hist[i] will have one row and histSize[i] cols and CV_32SC1 type.
CV_EXPORTS void histEven(const GpuMat& src, GpuMat hist[4], int histSize[4], int lowerLevel[4], int upperLevel[4], Stream& stream = Stream::Null());
CV_EXPORTS void histEven(const GpuMat& src, GpuMat hist[4], GpuMat& buf, int histSize[4], int lowerLevel[4], int upperLevel[4], Stream& stream = Stream::Null());
//! Calculates histogram with bins determined by levels array.
//! levels must have one row and CV_32SC1 type if source has integer type or CV_32FC1 otherwise.
//! Supports CV_8UC1, CV_16UC1, CV_16SC1 and CV_32FC1 source types.
//! Output hist will have one row and (levels.cols-1) cols and CV_32SC1 type.
CV_EXPORTS void histRange(const GpuMat& src, GpuMat& hist, const GpuMat& levels, Stream& stream = Stream::Null());
CV_EXPORTS void histRange(const GpuMat& src, GpuMat& hist, const GpuMat& levels, GpuMat& buf, Stream& stream = Stream::Null());
//! Calculates histogram with bins determined by levels array.
//! All levels must have one row and CV_32SC1 type if source has integer type or CV_32FC1 otherwise.
//! All channels of source are processed separately.
//! Supports CV_8UC4, CV_16UC4, CV_16SC4 and CV_32FC4 source types.
//! Output hist[i] will have one row and (levels[i].cols-1) cols and CV_32SC1 type.
CV_EXPORTS void histRange(const GpuMat& src, GpuMat hist[4], const GpuMat levels[4], Stream& stream = Stream::Null());
CV_EXPORTS void histRange(const GpuMat& src, GpuMat hist[4], const GpuMat levels[4], GpuMat& buf, Stream& stream = Stream::Null());
//! Calculates histogram for 8u one channel image
//! Output hist will have one row, 256 cols and CV32SC1 type.
CV_EXPORTS void calcHist(const GpuMat& src, GpuMat& hist, Stream& stream = Stream::Null());
CV_EXPORTS void calcHist(const GpuMat& src, GpuMat& hist, GpuMat& buf, Stream& stream = Stream::Null());
//! normalizes the grayscale image brightness and contrast by normalizing its histogram
CV_EXPORTS void equalizeHist(const GpuMat& src, GpuMat& dst, Stream& stream = Stream::Null());
CV_EXPORTS void equalizeHist(const GpuMat& src, GpuMat& dst, GpuMat& hist, Stream& stream = Stream::Null());
CV_EXPORTS void equalizeHist(const GpuMat& src, GpuMat& dst, GpuMat& hist, GpuMat& buf, Stream& stream = Stream::Null());
//////////////////////////////// StereoBM_GPU ////////////////////////////////
class CV_EXPORTS StereoBM_GPU
{
public:
enum { BASIC_PRESET = 0, PREFILTER_XSOBEL = 1 };
enum { DEFAULT_NDISP = 64, DEFAULT_WINSZ = 19 };
//! the default constructor
StereoBM_GPU();
//! the full constructor taking the camera-specific preset, number of disparities and the SAD window size. ndisparities must be multiple of 8.
StereoBM_GPU(int preset, int ndisparities = DEFAULT_NDISP, int winSize = DEFAULT_WINSZ);
//! the stereo correspondence operator. Finds the disparity for the specified rectified stereo pair
//! Output disparity has CV_8U type.
void operator() ( const GpuMat& left, const GpuMat& right, GpuMat& disparity, Stream& stream = Stream::Null());
//! Some heuristics that tries to estmate
// if current GPU will be faster than CPU in this algorithm.
// It queries current active device.
static bool checkIfGpuCallReasonable();
int preset;
int ndisp;
int winSize;
// If avergeTexThreshold == 0 => post procesing is disabled
// If avergeTexThreshold != 0 then disparity is set 0 in each point (x,y) where for left image
// SumOfHorizontalGradiensInWindow(x, y, winSize) < (winSize * winSize) * avergeTexThreshold
// i.e. input left image is low textured.
float avergeTexThreshold;
private:
GpuMat minSSD, leBuf, riBuf;
};
////////////////////////// StereoBeliefPropagation ///////////////////////////
// "Efficient Belief Propagation for Early Vision"
// P.Felzenszwalb
class CV_EXPORTS StereoBeliefPropagation
{
public:
enum { DEFAULT_NDISP = 64 };
enum { DEFAULT_ITERS = 5 };
enum { DEFAULT_LEVELS = 5 };
static void estimateRecommendedParams(int width, int height, int& ndisp, int& iters, int& levels);
//! the default constructor
explicit StereoBeliefPropagation(int ndisp = DEFAULT_NDISP,
int iters = DEFAULT_ITERS,
int levels = DEFAULT_LEVELS,
int msg_type = CV_32F);
//! the full constructor taking the number of disparities, number of BP iterations on each level,
//! number of levels, truncation of data cost, data weight,
//! truncation of discontinuity cost and discontinuity single jump
//! DataTerm = data_weight * min(fabs(I2-I1), max_data_term)
//! DiscTerm = min(disc_single_jump * fabs(f1-f2), max_disc_term)
//! please see paper for more details
StereoBeliefPropagation(int ndisp, int iters, int levels,
float max_data_term, float data_weight,
float max_disc_term, float disc_single_jump,
int msg_type = CV_32F);
//! the stereo correspondence operator. Finds the disparity for the specified rectified stereo pair,
//! if disparity is empty output type will be CV_16S else output type will be disparity.type().
void operator()(const GpuMat& left, const GpuMat& right, GpuMat& disparity, Stream& stream = Stream::Null());
//! version for user specified data term
void operator()(const GpuMat& data, GpuMat& disparity, Stream& stream = Stream::Null());
int ndisp;
int iters;
int levels;
float max_data_term;
float data_weight;
float max_disc_term;
float disc_single_jump;
int msg_type;
private:
GpuMat u, d, l, r, u2, d2, l2, r2;
std::vector<GpuMat> datas;
GpuMat out;
};
/////////////////////////// StereoConstantSpaceBP ///////////////////////////
// "A Constant-Space Belief Propagation Algorithm for Stereo Matching"
// Qingxiong Yang, Liang Wang, Narendra Ahuja
// http://vision.ai.uiuc.edu/~qyang6/
class CV_EXPORTS StereoConstantSpaceBP
{
public:
enum { DEFAULT_NDISP = 128 };
enum { DEFAULT_ITERS = 8 };
enum { DEFAULT_LEVELS = 4 };
enum { DEFAULT_NR_PLANE = 4 };
static void estimateRecommendedParams(int width, int height, int& ndisp, int& iters, int& levels, int& nr_plane);
//! the default constructor
explicit StereoConstantSpaceBP(int ndisp = DEFAULT_NDISP,
int iters = DEFAULT_ITERS,
int levels = DEFAULT_LEVELS,
int nr_plane = DEFAULT_NR_PLANE,
int msg_type = CV_32F);
//! the full constructor taking the number of disparities, number of BP iterations on each level,
//! number of levels, number of active disparity on the first level, truncation of data cost, data weight,
//! truncation of discontinuity cost, discontinuity single jump and minimum disparity threshold
StereoConstantSpaceBP(int ndisp, int iters, int levels, int nr_plane,
float max_data_term, float data_weight, float max_disc_term, float disc_single_jump,
int min_disp_th = 0,
int msg_type = CV_32F);
//! the stereo correspondence operator. Finds the disparity for the specified rectified stereo pair,
//! if disparity is empty output type will be CV_16S else output type will be disparity.type().
void operator()(const GpuMat& left, const GpuMat& right, GpuMat& disparity, Stream& stream = Stream::Null());
int ndisp;
int iters;
int levels;
int nr_plane;
float max_data_term;
float data_weight;
float max_disc_term;
float disc_single_jump;
int min_disp_th;
int msg_type;
bool use_local_init_data_cost;
private:
GpuMat u[2], d[2], l[2], r[2];
GpuMat disp_selected_pyr[2];
GpuMat data_cost;
GpuMat data_cost_selected;
GpuMat temp;
GpuMat out;
};
/////////////////////////// DisparityBilateralFilter ///////////////////////////
// Disparity map refinement using joint bilateral filtering given a single color image.
// Qingxiong Yang, Liang Wang, Narendra Ahuja
// http://vision.ai.uiuc.edu/~qyang6/
class CV_EXPORTS DisparityBilateralFilter
{
public:
enum { DEFAULT_NDISP = 64 };
enum { DEFAULT_RADIUS = 3 };
enum { DEFAULT_ITERS = 1 };
//! the default constructor
explicit DisparityBilateralFilter(int ndisp = DEFAULT_NDISP, int radius = DEFAULT_RADIUS, int iters = DEFAULT_ITERS);
//! the full constructor taking the number of disparities, filter radius,
//! number of iterations, truncation of data continuity, truncation of disparity continuity
//! and filter range sigma
DisparityBilateralFilter(int ndisp, int radius, int iters, float edge_threshold, float max_disc_threshold, float sigma_range);
//! the disparity map refinement operator. Refine disparity map using joint bilateral filtering given a single color image.
//! disparity must have CV_8U or CV_16S type, image must have CV_8UC1 or CV_8UC3 type.
void operator()(const GpuMat& disparity, const GpuMat& image, GpuMat& dst, Stream& stream = Stream::Null());
private:
int ndisp;
int radius;
int iters;
float edge_threshold;
float max_disc_threshold;
float sigma_range;
GpuMat table_color;
GpuMat table_space;
};
//////////////// HOG (Histogram-of-Oriented-Gradients) Descriptor and Object Detector //////////////
struct CV_EXPORTS HOGDescriptor
{
enum { DEFAULT_WIN_SIGMA = -1 };
enum { DEFAULT_NLEVELS = 64 };
enum { DESCR_FORMAT_ROW_BY_ROW, DESCR_FORMAT_COL_BY_COL };
HOGDescriptor(Size win_size=Size(64, 128), Size block_size=Size(16, 16),
Size block_stride=Size(8, 8), Size cell_size=Size(8, 8),
int nbins=9, double win_sigma=DEFAULT_WIN_SIGMA,
double threshold_L2hys=0.2, bool gamma_correction=true,
int nlevels=DEFAULT_NLEVELS);
size_t getDescriptorSize() const;
size_t getBlockHistogramSize() const;
void setSVMDetector(const vector<float>& detector);
static vector<float> getDefaultPeopleDetector();
static vector<float> getPeopleDetector48x96();
static vector<float> getPeopleDetector64x128();
void detect(const GpuMat& img, vector<Point>& found_locations,
double hit_threshold=0, Size win_stride=Size(),
Size padding=Size());
void detectMultiScale(const GpuMat& img, vector<Rect>& found_locations,
double hit_threshold=0, Size win_stride=Size(),
Size padding=Size(), double scale0=1.05,
int group_threshold=2);
void getDescriptors(const GpuMat& img, Size win_stride,
GpuMat& descriptors,
int descr_format=DESCR_FORMAT_COL_BY_COL);
Size win_size;
Size block_size;
Size block_stride;
Size cell_size;
int nbins;
double win_sigma;
double threshold_L2hys;
bool gamma_correction;
int nlevels;
protected:
void computeBlockHistograms(const GpuMat& img);
void computeGradient(const GpuMat& img, GpuMat& grad, GpuMat& qangle);
double getWinSigma() const;
bool checkDetectorSize() const;
static int numPartsWithin(int size, int part_size, int stride);
static Size numPartsWithin(Size size, Size part_size, Size stride);
// Coefficients of the separating plane
float free_coef;
GpuMat detector;
// Results of the last classification step
GpuMat labels, labels_buf;
Mat labels_host;
// Results of the last histogram evaluation step
GpuMat block_hists, block_hists_buf;
// Gradients conputation results
GpuMat grad, qangle, grad_buf, qangle_buf;
// returns subbuffer with required size, reallocates buffer if nessesary.
static GpuMat getBuffer(const Size& sz, int type, GpuMat& buf);
static GpuMat getBuffer(int rows, int cols, int type, GpuMat& buf);
std::vector<GpuMat> image_scales;
};
////////////////////////////////// BruteForceMatcher //////////////////////////////////
class CV_EXPORTS BruteForceMatcher_GPU_base
{
public:
enum DistType {L1Dist = 0, L2Dist, HammingDist};
explicit BruteForceMatcher_GPU_base(DistType distType = L2Dist);
// Add descriptors to train descriptor collection.
void add(const std::vector<GpuMat>& descCollection);
// Get train descriptors collection.
const std::vector<GpuMat>& getTrainDescriptors() const;
// Clear train descriptors collection.
void clear();
// Return true if there are not train descriptors in collection.
bool empty() const;
// Return true if the matcher supports mask in match methods.
bool isMaskSupported() const;
// Find one best match for each query descriptor.
// trainIdx.at<int>(0, queryIdx) will contain best train index for queryIdx
// distance.at<float>(0, queryIdx) will contain distance
void matchSingle(const GpuMat& queryDescs, const GpuMat& trainDescs,
GpuMat& trainIdx, GpuMat& distance,
const GpuMat& mask = GpuMat(), Stream& stream = Stream::Null());
// Download trainIdx and distance and convert it to CPU vector with DMatch
static void matchDownload(const GpuMat& trainIdx, const GpuMat& distance, std::vector<DMatch>& matches);
// Convert trainIdx and distance to vector with DMatch
static void matchConvert(const Mat& trainIdx, const Mat& distance, std::vector<DMatch>& matches);
// Find one best match for each query descriptor.
void match(const GpuMat& queryDescs, const GpuMat& trainDescs, std::vector<DMatch>& matches,
const GpuMat& mask = GpuMat());
// Make gpu collection of trains and masks in suitable format for matchCollection function
void makeGpuCollection(GpuMat& trainCollection, GpuMat& maskCollection,
const vector<GpuMat>& masks = std::vector<GpuMat>());
// Find one best match from train collection for each query descriptor.
// trainIdx.at<int>(0, queryIdx) will contain best train index for queryIdx
// imgIdx.at<int>(0, queryIdx) will contain best image index for queryIdx
// distance.at<float>(0, queryIdx) will contain distance
void matchCollection(const GpuMat& queryDescs, const GpuMat& trainCollection,
GpuMat& trainIdx, GpuMat& imgIdx, GpuMat& distance,
const GpuMat& maskCollection, Stream& stream = Stream::Null());
// Download trainIdx, imgIdx and distance and convert it to vector with DMatch
static void matchDownload(const GpuMat& trainIdx, const GpuMat& imgIdx, const GpuMat& distance, std::vector<DMatch>& matches);
// Convert trainIdx, imgIdx and distance to vector with DMatch
static void matchConvert(const Mat& trainIdx, const Mat& imgIdx, const Mat& distance, std::vector<DMatch>& matches);
// Find one best match from train collection for each query descriptor.
void match(const GpuMat& queryDescs, std::vector<DMatch>& matches, const std::vector<GpuMat>& masks = std::vector<GpuMat>());
// Find k best matches for each query descriptor (in increasing order of distances).
// trainIdx.at<int>(queryIdx, i) will contain index of i'th best trains (i < k).
// distance.at<float>(queryIdx, i) will contain distance.
// allDist is a buffer to store all distance between query descriptors and train descriptors
// it have size (nQuery,nTrain) and CV_32F type
// allDist.at<float>(queryIdx, trainIdx) will contain FLT_MAX, if trainIdx is one from k best,
// otherwise it will contain distance between queryIdx and trainIdx descriptors
void knnMatch(const GpuMat& queryDescs, const GpuMat& trainDescs,
GpuMat& trainIdx, GpuMat& distance, GpuMat& allDist, int k, const GpuMat& mask = GpuMat(), Stream& stream = Stream::Null());
// Download trainIdx and distance and convert it to vector with DMatch
// compactResult is used when mask is not empty. If compactResult is false matches
// vector will have the same size as queryDescriptors rows. If compactResult is true
// matches vector will not contain matches for fully masked out query descriptors.
static void knnMatchDownload(const GpuMat& trainIdx, const GpuMat& distance,
std::vector< std::vector<DMatch> >& matches, bool compactResult = false);
// Convert trainIdx and distance to vector with DMatch
static void knnMatchConvert(const Mat& trainIdx, const Mat& distance,
std::vector< std::vector<DMatch> >& matches, bool compactResult = false);
// Find k best matches for each query descriptor (in increasing order of distances).
// compactResult is used when mask is not empty. If compactResult is false matches
// vector will have the same size as queryDescriptors rows. If compactResult is true
// matches vector will not contain matches for fully masked out query descriptors.
void knnMatch(const GpuMat& queryDescs, const GpuMat& trainDescs,
std::vector< std::vector<DMatch> >& matches, int k, const GpuMat& mask = GpuMat(),
bool compactResult = false);
// Find k best matches for each query descriptor (in increasing order of distances).
// compactResult is used when mask is not empty. If compactResult is false matches
// vector will have the same size as queryDescriptors rows. If compactResult is true
// matches vector will not contain matches for fully masked out query descriptors.
void knnMatch(const GpuMat& queryDescs, std::vector< std::vector<DMatch> >& matches, int knn,
const std::vector<GpuMat>& masks = std::vector<GpuMat>(), bool compactResult = false );
// Find best matches for each query descriptor which have distance less than maxDistance.
// nMatches.at<unsigned int>(0, queruIdx) will contain matches count for queryIdx.
// carefully nMatches can be greater than trainIdx.cols - it means that matcher didn't find all matches,
// because it didn't have enough memory.
// trainIdx.at<int>(queruIdx, i) will contain ith train index (i < min(nMatches.at<unsigned int>(0, queruIdx), trainIdx.cols))
// distance.at<int>(queruIdx, i) will contain ith distance (i < min(nMatches.at<unsigned int>(0, queruIdx), trainIdx.cols))
// If trainIdx is empty, then trainIdx and distance will be created with size nQuery x nTrain,
// otherwize user can pass own allocated trainIdx and distance with size nQuery x nMaxMatches
// Matches doesn't sorted.
void radiusMatch(const GpuMat& queryDescs, const GpuMat& trainDescs,
GpuMat& trainIdx, GpuMat& nMatches, GpuMat& distance, float maxDistance,
const GpuMat& mask = GpuMat(), Stream& stream = Stream::Null());
// Download trainIdx, nMatches and distance and convert it to vector with DMatch.
// matches will be sorted in increasing order of distances.
// compactResult is used when mask is not empty. If compactResult is false matches
// vector will have the same size as queryDescriptors rows. If compactResult is true
// matches vector will not contain matches for fully masked out query descriptors.
static void radiusMatchDownload(const GpuMat& trainIdx, const GpuMat& nMatches, const GpuMat& distance,
std::vector< std::vector<DMatch> >& matches, bool compactResult = false);
// Convert trainIdx, nMatches and distance to vector with DMatch.
static void radiusMatchConvert(const Mat& trainIdx, const Mat& nMatches, const Mat& distance,
std::vector< std::vector<DMatch> >& matches, bool compactResult = false);
// Find best matches for each query descriptor which have distance less than maxDistance
// in increasing order of distances).
void radiusMatch(const GpuMat& queryDescs, const GpuMat& trainDescs,
std::vector< std::vector<DMatch> >& matches, float maxDistance,
const GpuMat& mask = GpuMat(), bool compactResult = false);
// Find best matches from train collection for each query descriptor which have distance less than
// maxDistance (in increasing order of distances).
void radiusMatch(const GpuMat& queryDescs, std::vector< std::vector<DMatch> >& matches, float maxDistance,
const std::vector<GpuMat>& masks = std::vector<GpuMat>(), bool compactResult = false);
DistType distType;
private:
std::vector<GpuMat> trainDescCollection;
};
template <class Distance>
class CV_EXPORTS BruteForceMatcher_GPU;
template <typename T>
class CV_EXPORTS BruteForceMatcher_GPU< L1<T> > : public BruteForceMatcher_GPU_base
{
public:
explicit BruteForceMatcher_GPU() : BruteForceMatcher_GPU_base(L1Dist) {}
explicit BruteForceMatcher_GPU(L1<T> /*d*/) : BruteForceMatcher_GPU_base(L1Dist) {}
};
template <typename T>
class CV_EXPORTS BruteForceMatcher_GPU< L2<T> > : public BruteForceMatcher_GPU_base
{
public:
explicit BruteForceMatcher_GPU() : BruteForceMatcher_GPU_base(L2Dist) {}
explicit BruteForceMatcher_GPU(L2<T> /*d*/) : BruteForceMatcher_GPU_base(L2Dist) {}
};
template <> class CV_EXPORTS BruteForceMatcher_GPU< HammingLUT > : public BruteForceMatcher_GPU_base
{
public:
explicit BruteForceMatcher_GPU() : BruteForceMatcher_GPU_base(HammingDist) {}
explicit BruteForceMatcher_GPU(HammingLUT /*d*/) : BruteForceMatcher_GPU_base(HammingDist) {}
};
template <> class CV_EXPORTS BruteForceMatcher_GPU< Hamming > : public BruteForceMatcher_GPU_base
{
public:
explicit BruteForceMatcher_GPU() : BruteForceMatcher_GPU_base(HammingDist) {}
explicit BruteForceMatcher_GPU(Hamming /*d*/) : BruteForceMatcher_GPU_base(HammingDist) {}
};
////////////////////////////////// CascadeClassifier_GPU //////////////////////////////////////////
// The cascade classifier class for object detection.
class CV_EXPORTS CascadeClassifier_GPU
{
public:
CascadeClassifier_GPU();
CascadeClassifier_GPU(const string& filename);
~CascadeClassifier_GPU();
bool empty() const;
bool load(const string& filename);
void release();
/* returns number of detected objects */
int detectMultiScale( const GpuMat& image, GpuMat& objectsBuf, double scaleFactor=1.2, int minNeighbors=4, Size minSize=Size());
bool findLargestObject;
bool visualizeInPlace;
Size getClassifierSize() const;
private:
struct CascadeClassifierImpl;
CascadeClassifierImpl* impl;
};
////////////////////////////////// SURF //////////////////////////////////////////
class CV_EXPORTS SURF_GPU : public CvSURFParams
{
public:
enum KeypointLayout
{
SF_X = 0,
SF_Y,
SF_LAPLACIAN,
SF_SIZE,
SF_DIR,
SF_HESSIAN,
SF_FEATURE_STRIDE
};
//! the default constructor
SURF_GPU();
//! the full constructor taking all the necessary parameters
explicit SURF_GPU(double _hessianThreshold, int _nOctaves=4,
int _nOctaveLayers=2, bool _extended=false, float _keypointsRatio=0.01f, bool _upright = false);
//! returns the descriptor size in float's (64 or 128)
int descriptorSize() const;
//! upload host keypoints to device memory
void uploadKeypoints(const vector<KeyPoint>& keypoints, GpuMat& keypointsGPU);
//! download keypoints from device to host memory
void downloadKeypoints(const GpuMat& keypointsGPU, vector<KeyPoint>& keypoints);
//! download descriptors from device to host memory
void downloadDescriptors(const GpuMat& descriptorsGPU, vector<float>& descriptors);
//! finds the keypoints using fast hessian detector used in SURF
//! supports CV_8UC1 images
//! keypoints will have nFeature cols and 6 rows
//! keypoints.ptr<float>(SF_X)[i] will contain x coordinate of i'th feature
//! keypoints.ptr<float>(SF_Y)[i] will contain y coordinate of i'th feature
//! keypoints.ptr<float>(SF_LAPLACIAN)[i] will contain laplacian sign of i'th feature
//! keypoints.ptr<float>(SF_SIZE)[i] will contain size of i'th feature
//! keypoints.ptr<float>(SF_DIR)[i] will contain orientation of i'th feature
//! keypoints.ptr<float>(SF_HESSIAN)[i] will contain response of i'th feature
void operator()(const GpuMat& img, const GpuMat& mask, GpuMat& keypoints);
//! finds the keypoints and computes their descriptors.
//! Optionally it can compute descriptors for the user-provided keypoints and recompute keypoints direction
void operator()(const GpuMat& img, const GpuMat& mask, GpuMat& keypoints, GpuMat& descriptors,
bool useProvidedKeypoints = false);
void operator()(const GpuMat& img, const GpuMat& mask, std::vector<KeyPoint>& keypoints);
void operator()(const GpuMat& img, const GpuMat& mask, std::vector<KeyPoint>& keypoints, GpuMat& descriptors,
bool useProvidedKeypoints = false);
void operator()(const GpuMat& img, const GpuMat& mask, std::vector<KeyPoint>& keypoints, std::vector<float>& descriptors,
bool useProvidedKeypoints = false);
void releaseMemory();
//! max keypoints = min(keypointsRatio * img.size().area(), 65535)
float keypointsRatio;
GpuMat sum, mask1, maskSum, intBuffer;
GpuMat det, trace;
GpuMat maxPosBuffer;
};
}
//! Speckle filtering - filters small connected components on diparity image.
//! It sets pixel (x,y) to newVal if it coresponds to small CC with size < maxSpeckleSize.
//! Threshold for border between CC is diffThreshold;
CV_EXPORTS void filterSpeckles( Mat& img, uchar newVal, int maxSpeckleSize, uchar diffThreshold, Mat& buf);
}
#include "opencv2/gpu/matrix_operations.hpp"
#endif /* __OPENCV_GPU_HPP__ */
| 52.265823
| 195
| 0.618807
|
local-projects
|
9ef6e673919e22248aea4048d92925eaef6af77d
| 8,951
|
hpp
|
C++
|
original_periodic/src/discrete_function.hpp
|
four-spins/dissertation
|
6a61b6d5b133c8839b7aa740784472c2beb5912e
|
[
"MIT"
] | null | null | null |
original_periodic/src/discrete_function.hpp
|
four-spins/dissertation
|
6a61b6d5b133c8839b7aa740784472c2beb5912e
|
[
"MIT"
] | null | null | null |
original_periodic/src/discrete_function.hpp
|
four-spins/dissertation
|
6a61b6d5b133c8839b7aa740784472c2beb5912e
|
[
"MIT"
] | null | null | null |
/******************************************************************************
*
* @file: discrete_function.hpp
*
* @date: 12/06/2012 01:39:53 PM (CET)
*
* @author: Marco Müller <muelma@gmail.com>
*
******************************************************************************/
#pragma once
#include <vector>
#include <cassert>
#include <iostream>
#include <iomanip> // stream manipulators
#include <sstream> // string streams used for output
#include <limits>
#include <cmath>
#include "dlib/serialize.h"
/// class to manage a functional dependency y = f(x) with automatic
/// discretisation in x
///
/// The naming of the class is as follows:\n
/// x is called the abscissa\n
/// y is called the ordinate\n
/// The interval [abscissa_min, abscissa_max] is divided in a number of
/// nr_bins subintervals of a given length bin_width_ where each subinterval
/// holds exactly one value for the ordinate.\n
/// Subintervals are also referred to as "bins".
template<class T>
class discrete_function {
public:
typedef typename std::vector<T>::iterator iterator;
typedef typename std::vector<T>::reverse_iterator reverse_iterator;
typedef typename std::vector<T>::const_iterator const_iterator;
typedef typename std::vector<T>::const_reverse_iterator const_reverse_iterator;
typedef T value_type;
/// constructor defining
/// interval limits and length of one subinterval
discrete_function(double abscissa_min_, double abscissa_max_, double bin_width_);
// members defining the discretisation:
double abscissa_min; ///< minimum of the interval
double abscissa_max; ///< maximum of the interval
double bin_width; ///< length of a subinterval
size_t nr_bins;
size_t normalization;
// vector storing the ordinates
std::vector<T> data;
/// access by index
T& operator[]( size_t index );
const T& operator[]( size_t index ) const;
/// access by value for the abscissa
T& operator[]( double abscissa_val );
const T& operator[]( double abscissa_val ) const;
/// returns iterator to begin of underlying data
iterator begin() { return data.begin(); }
/// returns const iterator to begin of underlying data
const_iterator begin() const { return data.begin(); }
/// returns const iterator to begin of underlying data
const_iterator cbegin() const { return data.cbegin(); }
/// returns iterator to end of underlying data
iterator end() { return data.end(); }
/// returns const iterator to end of underlying data
const_iterator end() const { return data.end(); }
/// returns const iterator to end of underlying data
const_iterator cend() const { return data.cend(); }
/// returns reverse iterator to begin of underlying data
reverse_iterator rbegin() { return data.rbegin(); }
/// returns const reverse iterator to begin of underlying data
const_reverse_iterator rbegin() const { return data.rbegin(); }
/// returns const reverse iterator to begin of underlying data
const_reverse_iterator crbegin() const { return data.crbegin(); }
/// returns reverse iterator to end of underlying data
reverse_iterator rend() { return data.rend(); }
/// returns const reverse iterator to end of underlying data
const_reverse_iterator rend() const { return data.rend(); }
/// returns const reverse iterator to end of underlying data
const_reverse_iterator crend() const { return data.crend(); }
/// get internal vector storing ordinates
std::vector<T>& get_data() { return data; }
/// get lower limit of the interval
double get_abscissa_min() const { return abscissa_min; }
/// get upper limit of the interval
double get_abscissa_max() const { return abscissa_max; }
/// get size of a subinterval
double get_bin_width() const { return bin_width; }
/// return normalization
size_t get_norm() const { return normalization; }
/// get number of subintervals
size_t size() const;
/// get index for a value of the abscissa
size_t get_index( double abscissa_val ) const;
/// get the abscissa for an index interpolated to be the
/// mean value of the subinterval
double get_abscissa(size_t index) const;
/// get a string representation
std::string to_string() const;
//template<class T2>
//friend std::ostream& operator<<(std::ostream& os, discrete_function<T2>& func);
}; // class discrete_function
// constructor definition
template<class T>
discrete_function<T>
::discrete_function(double abscissa_min_, double abscissa_max_, double bin_width_)
: abscissa_min(abscissa_min_)
, abscissa_max(abscissa_max_)
, bin_width(bin_width_)
, normalization( std::numeric_limits<double>::quiet_NaN() ){
const double diff = abscissa_max - abscissa_min;
// Error:
// either the lower bound of the interval is greater than
// the upper bound or they are equal
assert( diff > 0 && "Error: creating discrete_function failed due to improper definition of the interval.");
nr_bins = static_cast<size_t>( (diff / bin_width) );
abscissa_max = abscissa_min + nr_bins*bin_width;
// Error:
// length of a subinterval is bigger than the length of the
// whole interval
assert( nr_bins > 0 && "Error: discrete_function needs at least one subinterval.");
data.resize(nr_bins);
}
// number of subintervals
template<class T>
size_t discrete_function<T>
::size() const { return nr_bins; }
// access by index
template<class T>
const T& discrete_function<T>
::operator[](size_t index) const {
assert( index < nr_bins );
return data[index];
}
template<class T>
T& discrete_function<T>
::operator[](size_t index) {
assert( index < nr_bins );
return data[index];
}
// access by value
template<class T>
inline const T& discrete_function<T>
::operator[](double abscissa) const {
return data[get_index(abscissa)];
}
template<class T>
inline T& discrete_function<T>
::operator[](double abscissa) {
return data[get_index(abscissa)];
}
template<class T>
inline size_t discrete_function<T>
::get_index( double abscissa_val ) const {
size_t index = 0;
index = static_cast<size_t>((abscissa_val - abscissa_min)/bin_width);
assert( index < nr_bins );
return index;
}
template<class T>
double discrete_function<T>
::get_abscissa(size_t index) const{
double tmp =static_cast<double>(abscissa_min) + static_cast<double>(bin_width) * (index + 0.5);
return tmp;
}
template<class T>
std::string discrete_function<T>
::to_string() const {
std::ostringstream os;
os << "# discrete function:\n"
<< "# abscissa_min = " << std::scientific << std::setprecision(16) << abscissa_min << "\n"
<< "# abscissa_max = " << std::scientific << std::setprecision(16) << abscissa_max << "\n"
<< "# bin_width = " << std::scientific << std::setprecision(16) << bin_width << "\n"
<< "# nr_bins = " << nr_bins << "\n"
<< "# -----\n" << "# Every line represents a right-open subinterval of the abscissa with its ordinate\n"
<< "#" << std::setw(29) << "x_mean" << std::setw(31) << "f[x_min, x_max)\n";
// TODO: how to write type information ... logval vs. double ...
os.setf(std::ios::scientific);
os.precision(16);
for ( size_t i = 0; i < nr_bins; i++ ) {
double mean = this->get_abscissa(i) ;
os << std::setw(30) << mean << " "
<< std::setw(29) << this->operator[](i) << " "
<< "\n";
}
return os.str();
}
template<class T>
std::ostream& operator<<(std::ostream& os, discrete_function<T>& func){
os << func.to_string();
return os;
}
template<class T>
void serialize (const discrete_function<T>& df, std::ostream& out)
{
/*
serialize() just needs to write the state of item to the output stream.
You can do this however you like. Below, I'm using the serialize functions
for int and std::string which come with dlib. But again, you can do whatever
you want here.
*/
dlib::serialize(df.abscissa_min, out);
dlib::serialize(df.abscissa_max, out);
dlib::serialize(df.bin_width, out);
dlib::serialize(df.nr_bins, out);
dlib::serialize(df.normalization, out);
dlib::serialize(df.data, out);
}
template<class T>
void deserialize (discrete_function<T>& df, std::istream& in)
{
/*
deserialize() is just the inverse of serialize(). Again, you can do
whatever you want here so long as it correctly reconstructs item. This
also means that deserialize() must always consume as many bytes as serialize()
generates.
*/
dlib::deserialize(df.abscissa_min, in);
dlib::deserialize(df.abscissa_max, in);
dlib::deserialize(df.bin_width, in);
dlib::deserialize(df.nr_bins, in);
dlib::deserialize(df.normalization, in);
dlib::deserialize(df.data, in);
}
| 35.804
| 110
| 0.662272
|
four-spins
|
9ef70ccca3e23f25edaadde59f7b308c8c1c461b
| 2,922
|
cpp
|
C++
|
src/wham/Simulation.cpp
|
seanmarks/wham
|
3ffdfcd46d165836c236588c6444acc0cb01fa6b
|
[
"MIT"
] | 1
|
2020-10-12T19:32:33.000Z
|
2020-10-12T19:32:33.000Z
|
src/wham/Simulation.cpp
|
seanmarks/wham
|
3ffdfcd46d165836c236588c6444acc0cb01fa6b
|
[
"MIT"
] | null | null | null |
src/wham/Simulation.cpp
|
seanmarks/wham
|
3ffdfcd46d165836c236588c6444acc0cb01fa6b
|
[
"MIT"
] | 1
|
2020-10-15T19:02:21.000Z
|
2020-10-15T19:02:21.000Z
|
#include "Simulation.h"
#include "OrderParameterRegistry.h"
Simulation::Simulation(
const std::string& data_set_label, const double t_min, const double t_max,
const double temperature, const bool use_floored_times,
const OrderParameterRegistry& op_registry
):
data_set_label_(data_set_label),
t_min_(t_min), t_max_(t_max),
temperature_(temperature),
kBT_(Constants::k_B * temperature_), beta_(1.0/kBT_),
use_floored_times_(use_floored_times),
op_registry_ptr_(&op_registry)
{
// Read time series
const auto& time_series_files = op_registry_ptr_->getSimulationFiles(data_set_label);
const int num_ops = time_series_files.size();
time_series_.reserve(num_ops);
for ( int p=0; p<num_ops; ++p ) {
int data_col = op_registry_ptr_->getTimeSeriesDataCol(p);
time_series_.emplace_back( time_series_files[p], data_col, t_min_, t_max_, use_floored_times );
}
checkTimeSeries();
}
const TimeSeries& Simulation::getTimeSeriesForOrderParameter(const std::string& op_name) const {
FANCY_ASSERT(op_registry_ptr_ != nullptr, "order parameter registry is missing");
const int op_index = op_registry_ptr_->nameToIndex(op_name);
return time_series_[op_index];
}
void Simulation::setShuffledFromOther(const Simulation& other, const std::vector<int>& indices)
{
FANCY_ASSERT(this != &other, "unsupported usage");
*this = other;
const int num_time_series = other.time_series_.size();
for ( int p=0; p<num_time_series; ++p ) {
time_series_[p].setShuffledFromOther( other.time_series_[p], indices );
}
}
void Simulation::checkTimeSeries() const
{
FANCY_ASSERT(op_registry_ptr_ != nullptr, "order parameter registry is missing");
// Check number present
const int num_time_series = time_series_.size();
const int num_ops = op_registry_ptr_->getNumRegistered();
FANCY_ASSERT( num_time_series == num_ops,
"Error setting up Simulation with data set label " << data_set_label_ << "\n"
<< " Mismatch between number of time series files parsed (" << num_time_series
<< ") and number of order parameters (" << num_ops << "\n" );
if ( num_time_series == 0 ) {
return; // nothing to do
}
const auto& time_series_ref = time_series_.front();
for ( int p=1; p<num_time_series; ++p ) {
// Check sampled times
const auto& time_series_p = time_series_[p];
if ( time_series_p.get_times() != time_series_ref.get_times() ) {
std::stringstream err_ss;
err_ss << "Error setting up Simulation with data set label " << data_set_label_ << "\n"
<< " Mismatch in times sampled for the following order parameters\n";
std::vector<int> op_indices = {{ 0, p }};
for ( auto j : op_indices ) {
const auto& time_series_j = time_series_[j];
err_ss << " " << op_registry_ptr_->indexToName(j) << ": " << time_series_j.size() << " points from file "
<< time_series_j.getFile() << "\n";
}
throw std::runtime_error( err_ss.str() );
}
}
}
| 34.785714
| 112
| 0.714921
|
seanmarks
|
9ef7d2e7aa8de4f68131f4e7790c3bc8ed59b423
| 5,246
|
cpp
|
C++
|
software_embedded/squantorProgger/src/commands.cpp
|
Squantor/squantProgger
|
c3a7eecdb6fdb5d3aa717bf14bde615e73b0f236
|
[
"MIT"
] | 1
|
2019-10-08T03:55:46.000Z
|
2019-10-08T03:55:46.000Z
|
software_embedded/squantorProgger/src/commands.cpp
|
Squantor/squantProgger
|
c3a7eecdb6fdb5d3aa717bf14bde615e73b0f236
|
[
"MIT"
] | null | null | null |
software_embedded/squantorProgger/src/commands.cpp
|
Squantor/squantProgger
|
c3a7eecdb6fdb5d3aa717bf14bde615e73b0f236
|
[
"MIT"
] | null | null | null |
/*
MIT License
Copyright (c) 2019 Bart Bilos
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 <command_mini.h>
#include <stddef.h>
#include <board.hpp>
#include <chip.h>
#include <stream_uart.hpp>
#include <strings.hpp>
#include <parsedigit.h>
#include <string.h>
#include <print.h>
result cmdPrintVerHandler(const char *argument);
result cmdSpiTestHandler(const char *argument);
result cmdSwdEnableHandler(const char *argument);
result cmdSwdDisableHandler(const char *argument);
result cmdGeneralTestHandler(const char *argument);
const char cmdPrintVer[] = "pv";
const char cmdSpiTest[] = "ts";
const char cmdSwdEnable[] = "swde";
const char cmdSwdDisable[] = "swdd";
const char cmdGeneralTest[] = "test";
commandEntry_t sqProgCommands[] =
{
{cmdPrintVer, cmdPrintVerHandler},
{cmdSpiTest, cmdSpiTestHandler},
{cmdSwdEnable, cmdSwdEnableHandler},
{cmdSwdDisable, cmdSwdDisableHandler},
{cmdGeneralTest, cmdGeneralTestHandler},
{NULL, NULL},
};
// commands may not use an argument and this is fine, ignore warning
#pragma GCC diagnostic ignored "-Wunused-parameter"
result cmdPrintVerHandler(const char *argument)
{
dsPuts(&streamUart, strHello);
return noError;
}
result cmdGeneralTestHandler(const char *argument)
{
Chip_GPIO_SetPinDIROutput(LPC_GPIO_PORT, 0, JTAG_TCK_GPIO);
Chip_GPIO_SetPinToggle(LPC_GPIO_PORT, 0, JTAG_TCK_GPIO);
}
// now we want warnings on arguments missing again
#pragma GCC diagnostic pop
result cmdSpiTestHandler(const char *argument)
{
const char *s = argument;
unsigned int bitCount;
if(parseDigit(*s, &bitCount) != parseOk)
return invalidArg;
s++;
// we know bit count, now check rest
unsigned int charCount = (bitCount / 4 + 1);
if(strlen(s) != charCount)
return invalidArg;
// we increment bit count so we cover a range from 1 to 16
bitCount++;
// parse data characters
uint16_t spiData = 0;
for(unsigned int i = 0; i < charCount; i++)
{
spiData = spiData << 4;
unsigned int data;
if(parseDigit(*s, &data) != parseOk)
return invalidArg;
s++;
spiData = spiData | (uint16_t) data;
}
// transfer
uint32_t transfer = spiData |
(0xE << 16) |
SPI_TXDATCTL_EOT |
SPI_TXDATCTL_FLEN(bitCount-1);
Chip_SPI_ClearStatus(LPC_SPI0, SPI_STAT_CLR_RXOV | SPI_STAT_CLR_TXUR | SPI_STAT_CLR_SSA | SPI_STAT_CLR_SSD);
while( !(Chip_SPI_GetStatus(LPC_SPI0) & SPI_STAT_TXRDY))
;
LPC_SPI0->TXDATCTL = transfer;
while( !(Chip_SPI_GetStatus(LPC_SPI0) & SPI_STAT_RXRDY))
;
uint16_t rxData = (uint16_t) LPC_SPI0->RXDAT & 0xFFFF;
printHexU32(&streamUart, rxData);
dsPuts(&streamUart, strNl);
// print result
return noError;
}
result cmdSwdEnableHandler(const char *argument)
{
// check if we have valid divisor number, max 4 hex digits
size_t arglen = strlen(argument);
if((arglen == 0) || (arglen > 4))
return invalidArg;
uint16_t divisor = 0;
for(unsigned int i = 0; i < arglen; i++)
{
divisor = divisor << 4;
unsigned int data;
if(parseDigit(*argument, &data) != parseOk)
return invalidArg;
argument++;
divisor = divisor | (uint16_t) data;
}
Chip_Clock_EnablePeriphClock(SYSCTL_CLOCK_SWM);
Chip_SWM_MovablePinAssign(SWM_SPI0_SCK_IO, JTAG_TCK_GPIO);
Chip_SWM_MovablePinAssign(SWM_SPI0_MISO_IO, JTAG_TMSI_GPIO);
Chip_SWM_MovablePinAssign(SWM_SPI0_MOSI_IO, JTAG_TMSO_GPIO);
Chip_SWM_MovablePinAssign(SWM_SPI0_SSEL0_IO, JTAG_TMSOE_GPIO);
Chip_Clock_DisablePeriphClock(SYSCTL_CLOCK_SWM);
Chip_Clock_EnablePeriphClock(SYSCTL_CLOCK_SPI0);
Chip_SYSCTL_PeriphReset(RESET_SPI0);
Chip_SPI_ConfigureSPI(LPC_SPI0, SPI_CFG_MASTER_EN |
SPI_CLOCK_CPHA0_CPOL0 |
SPI_CFG_MSB_FIRST_EN |
SPI_CFG_SPOL_LO);
LPC_SPI0->DLY = 0x0;
LPC_SPI0->DIV = SPI_DIV_VAL(divisor);
Chip_SPI_Enable(LPC_SPI0);
return noError;
}
result cmdSwdDisableHandler(const char *argument)
{
Chip_Clock_DisablePeriphClock(SYSCTL_CLOCK_SPI0);
// reset SPI core
return noError;
}
| 33.414013
| 112
| 0.705871
|
Squantor
|
9ef8d237ac67ec65f810effe85e0c59088114207
| 17,471
|
cpp
|
C++
|
third_party/WebKit/Source/platform/fonts/FontCache.cpp
|
google-ar/chromium
|
2441c86a5fd975f09a6c30cddb57dfb7fc239699
|
[
"Apache-2.0",
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | 777
|
2017-08-29T15:15:32.000Z
|
2022-03-21T05:29:41.000Z
|
third_party/WebKit/Source/platform/fonts/FontCache.cpp
|
harrymarkovskiy/WebARonARCore
|
2441c86a5fd975f09a6c30cddb57dfb7fc239699
|
[
"Apache-2.0",
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | 66
|
2017-08-30T18:31:18.000Z
|
2021-08-02T10:59:35.000Z
|
third_party/WebKit/Source/platform/fonts/FontCache.cpp
|
harrymarkovskiy/WebARonARCore
|
2441c86a5fd975f09a6c30cddb57dfb7fc239699
|
[
"Apache-2.0",
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | 123
|
2017-08-30T01:19:34.000Z
|
2022-03-17T22:55:31.000Z
|
/*
* Copyright (C) 2006, 2008 Apple Inc. All rights reserved.
* Copyright (C) 2007 Nicholas Shanks <webkit@nickshanks.com>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of Apple Computer, Inc. ("Apple") 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 APPLE AND ITS 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 APPLE OR ITS 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 "platform/fonts/FontCache.h"
#include "base/trace_event/process_memory_dump.h"
#include "platform/FontFamilyNames.h"
#include "platform/Histogram.h"
#include "platform/RuntimeEnabledFeatures.h"
#include "platform/fonts/AcceptLanguagesResolver.h"
#include "platform/fonts/AlternateFontFamily.h"
#include "platform/fonts/FontCacheClient.h"
#include "platform/fonts/FontCacheKey.h"
#include "platform/fonts/FontDataCache.h"
#include "platform/fonts/FontDescription.h"
#include "platform/fonts/FontPlatformData.h"
#include "platform/fonts/FontSmoothingMode.h"
#include "platform/fonts/SimpleFontData.h"
#include "platform/fonts/TextRenderingMode.h"
#include "platform/fonts/opentype/OpenTypeVerticalData.h"
#include "platform/fonts/shaping/ShapeCache.h"
#include "platform/instrumentation/tracing/web_memory_allocator_dump.h"
#include "platform/instrumentation/tracing/web_process_memory_dump.h"
#include "public/platform/Platform.h"
#include "ui/gfx/font_list.h"
#include "wtf/HashMap.h"
#include "wtf/ListHashSet.h"
#include "wtf/PtrUtil.h"
#include "wtf/StdLibExtras.h"
#include "wtf/Vector.h"
#include "wtf/text/AtomicStringHash.h"
#include "wtf/text/StringHash.h"
#include <memory>
using namespace WTF;
namespace blink {
#if !OS(WIN) && !OS(LINUX)
FontCache::FontCache() : m_purgePreventCount(0), m_fontManager(nullptr) {}
#endif // !OS(WIN) && !OS(LINUX)
typedef HashMap<unsigned,
std::unique_ptr<FontPlatformData>,
WTF::IntHash<unsigned>,
WTF::UnsignedWithZeroKeyHashTraits<unsigned>>
SizedFontPlatformDataSet;
typedef HashMap<FontCacheKey,
SizedFontPlatformDataSet,
FontCacheKeyHash,
FontCacheKeyTraits>
FontPlatformDataCache;
typedef HashMap<FallbackListCompositeKey,
std::unique_ptr<ShapeCache>,
FallbackListCompositeKeyHash,
FallbackListCompositeKeyTraits>
FallbackListShaperCache;
static FontPlatformDataCache* gFontPlatformDataCache = nullptr;
static FallbackListShaperCache* gFallbackListShaperCache = nullptr;
SkFontMgr* FontCache::s_staticFontManager = nullptr;
#if OS(WIN)
bool FontCache::s_antialiasedTextEnabled = false;
bool FontCache::s_lcdTextEnabled = false;
float FontCache::s_deviceScaleFactor = 1.0;
bool FontCache::s_useSkiaFontFallback = false;
#endif // OS(WIN)
FontCache* FontCache::fontCache() {
DEFINE_STATIC_LOCAL(FontCache, globalFontCache, ());
return &globalFontCache;
}
#if !OS(MACOSX)
FontPlatformData* FontCache::systemFontPlatformData(
const FontDescription& fontDescription) {
const AtomicString& family = FontCache::systemFontFamily();
#if OS(LINUX)
if (family.isEmpty() || family == FontFamilyNames::system_ui)
return nullptr;
#else
DCHECK(!family.isEmpty() && family != FontFamilyNames::system_ui);
#endif
return getFontPlatformData(fontDescription, FontFaceCreationParams(family),
true);
}
#endif
FontPlatformData* FontCache::getFontPlatformData(
const FontDescription& fontDescription,
const FontFaceCreationParams& creationParams,
bool checkingAlternateName) {
if (!gFontPlatformDataCache) {
gFontPlatformDataCache = new FontPlatformDataCache;
platformInit();
}
#if !OS(MACOSX)
if (creationParams.creationType() == CreateFontByFamily &&
creationParams.family() == FontFamilyNames::system_ui) {
return systemFontPlatformData(fontDescription);
}
#endif
float size = fontDescription.effectiveFontSize();
unsigned roundedSize = size * FontCacheKey::precisionMultiplier();
FontCacheKey key = fontDescription.cacheKey(creationParams);
// Remove the font size from the cache key, and handle the font size
// separately in the inner HashMap. So that different size of FontPlatformData
// can share underlying SkTypeface.
if (RuntimeEnabledFeatures::fontCacheScalingEnabled())
key.clearFontSize();
FontPlatformData* result;
bool foundResult;
{
// addResult's scope must end before we recurse for alternate family names
// below, to avoid trigering its dtor hash-changed asserts.
SizedFontPlatformDataSet* sizedFonts =
&gFontPlatformDataCache->add(key, SizedFontPlatformDataSet())
.storedValue->value;
bool wasEmpty = sizedFonts->isEmpty();
// Take a different size instance of the same font before adding an entry to
// |sizedFont|.
FontPlatformData* anotherSize =
wasEmpty ? nullptr : sizedFonts->begin()->value.get();
auto addResult = sizedFonts->add(roundedSize, nullptr);
std::unique_ptr<FontPlatformData>* found = &addResult.storedValue->value;
if (addResult.isNewEntry) {
if (wasEmpty)
*found = createFontPlatformData(fontDescription, creationParams, size);
else if (anotherSize)
*found = scaleFontPlatformData(*anotherSize, fontDescription,
creationParams, size);
}
result = found->get();
foundResult = result || !addResult.isNewEntry;
}
if (!foundResult && !checkingAlternateName &&
creationParams.creationType() == CreateFontByFamily) {
// We were unable to find a font. We have a small set of fonts that we alias
// to other names, e.g., Arial/Helvetica, Courier/Courier New, etc. Try
// looking up the font under the aliased name.
const AtomicString& alternateName =
alternateFamilyName(creationParams.family());
if (!alternateName.isEmpty()) {
FontFaceCreationParams createByAlternateFamily(alternateName);
result =
getFontPlatformData(fontDescription, createByAlternateFamily, true);
}
if (result) {
// Cache the result under the old name.
auto adding =
&gFontPlatformDataCache->add(key, SizedFontPlatformDataSet())
.storedValue->value;
adding->set(roundedSize, WTF::wrapUnique(new FontPlatformData(*result)));
}
}
return result;
}
std::unique_ptr<FontPlatformData> FontCache::scaleFontPlatformData(
const FontPlatformData& fontPlatformData,
const FontDescription& fontDescription,
const FontFaceCreationParams& creationParams,
float fontSize) {
#if OS(MACOSX)
return createFontPlatformData(fontDescription, creationParams, fontSize);
#else
return WTF::makeUnique<FontPlatformData>(fontPlatformData, fontSize);
#endif
}
ShapeCache* FontCache::getShapeCache(const FallbackListCompositeKey& key) {
if (!gFallbackListShaperCache)
gFallbackListShaperCache = new FallbackListShaperCache;
FallbackListShaperCache::iterator it = gFallbackListShaperCache->find(key);
ShapeCache* result = nullptr;
if (it == gFallbackListShaperCache->end()) {
result = new ShapeCache();
gFallbackListShaperCache->set(key, WTF::wrapUnique(result));
} else {
result = it->value.get();
}
ASSERT(result);
return result;
}
typedef HashMap<FontCache::FontFileKey,
RefPtr<OpenTypeVerticalData>,
IntHash<FontCache::FontFileKey>,
UnsignedWithZeroKeyHashTraits<FontCache::FontFileKey>>
FontVerticalDataCache;
FontVerticalDataCache& fontVerticalDataCacheInstance() {
DEFINE_STATIC_LOCAL(FontVerticalDataCache, fontVerticalDataCache, ());
return fontVerticalDataCache;
}
void FontCache::setFontManager(sk_sp<SkFontMgr> fontManager) {
DCHECK(!s_staticFontManager);
s_staticFontManager = fontManager.release();
}
PassRefPtr<OpenTypeVerticalData> FontCache::getVerticalData(
const FontFileKey& key,
const FontPlatformData& platformData) {
FontVerticalDataCache& fontVerticalDataCache =
fontVerticalDataCacheInstance();
FontVerticalDataCache::iterator result = fontVerticalDataCache.find(key);
if (result != fontVerticalDataCache.end())
return result.get()->value;
RefPtr<OpenTypeVerticalData> verticalData =
OpenTypeVerticalData::create(platformData);
if (!verticalData->isOpenType())
verticalData.clear();
fontVerticalDataCache.set(key, verticalData);
return verticalData;
}
void FontCache::acceptLanguagesChanged(const String& acceptLanguages) {
AcceptLanguagesResolver::acceptLanguagesChanged(acceptLanguages);
fontCache()->invalidateShapeCache();
}
static FontDataCache* gFontDataCache = 0;
PassRefPtr<SimpleFontData> FontCache::getFontData(
const FontDescription& fontDescription,
const AtomicString& family,
bool checkingAlternateName,
ShouldRetain shouldRetain) {
if (FontPlatformData* platformData = getFontPlatformData(
fontDescription, FontFaceCreationParams(
adjustFamilyNameToAvoidUnsupportedFonts(family)),
checkingAlternateName)) {
return fontDataFromFontPlatformData(
platformData, shouldRetain, fontDescription.subpixelAscentDescent());
}
return nullptr;
}
PassRefPtr<SimpleFontData> FontCache::fontDataFromFontPlatformData(
const FontPlatformData* platformData,
ShouldRetain shouldRetain,
bool subpixelAscentDescent) {
if (!gFontDataCache)
gFontDataCache = new FontDataCache;
#if DCHECK_IS_ON()
if (shouldRetain == DoNotRetain)
ASSERT(m_purgePreventCount);
#endif
return gFontDataCache->get(platformData, shouldRetain, subpixelAscentDescent);
}
bool FontCache::isPlatformFontAvailable(const FontDescription& fontDescription,
const AtomicString& family) {
bool checkingAlternateName = true;
return getFontPlatformData(
fontDescription,
FontFaceCreationParams(adjustFamilyNameToAvoidUnsupportedFonts(family)),
checkingAlternateName);
}
String FontCache::firstAvailableOrFirst(const String& families) {
// The conversions involve at least two string copies, and more if non-ASCII.
// For now we prefer shared code over the cost because a) inputs are
// only from grd/xtb and all ASCII, and b) at most only a few times per
// setting change/script.
return String::fromUTF8(
gfx::FontList::FirstAvailableOrFirst(families.utf8().data()).c_str());
}
SimpleFontData* FontCache::getNonRetainedLastResortFallbackFont(
const FontDescription& fontDescription) {
return getLastResortFallbackFont(fontDescription, DoNotRetain).leakRef();
}
void FontCache::releaseFontData(const SimpleFontData* fontData) {
ASSERT(gFontDataCache);
gFontDataCache->release(fontData);
}
static inline void purgePlatformFontDataCache() {
if (!gFontPlatformDataCache)
return;
Vector<FontCacheKey> keysToRemove;
keysToRemove.reserveInitialCapacity(gFontPlatformDataCache->size());
for (auto& sizedFonts : *gFontPlatformDataCache) {
Vector<unsigned> sizesToRemove;
sizesToRemove.reserveInitialCapacity(sizedFonts.value.size());
for (const auto& platformData : sizedFonts.value) {
if (platformData.value &&
!gFontDataCache->contains(platformData.value.get()))
sizesToRemove.push_back(platformData.key);
}
sizedFonts.value.removeAll(sizesToRemove);
if (sizedFonts.value.isEmpty())
keysToRemove.push_back(sizedFonts.key);
}
gFontPlatformDataCache->removeAll(keysToRemove);
}
static inline void purgeFontVerticalDataCache() {
FontVerticalDataCache& fontVerticalDataCache =
fontVerticalDataCacheInstance();
if (!fontVerticalDataCache.isEmpty()) {
// Mark & sweep unused verticalData
FontVerticalDataCache::iterator verticalDataEnd =
fontVerticalDataCache.end();
for (FontVerticalDataCache::iterator verticalData =
fontVerticalDataCache.begin();
verticalData != verticalDataEnd; ++verticalData) {
if (verticalData->value)
verticalData->value->setInFontCache(false);
}
gFontDataCache->markAllVerticalData();
Vector<FontCache::FontFileKey> keysToRemove;
keysToRemove.reserveInitialCapacity(fontVerticalDataCache.size());
for (FontVerticalDataCache::iterator verticalData =
fontVerticalDataCache.begin();
verticalData != verticalDataEnd; ++verticalData) {
if (!verticalData->value || !verticalData->value->inFontCache())
keysToRemove.push_back(verticalData->key);
}
fontVerticalDataCache.removeAll(keysToRemove);
}
}
static inline void purgeFallbackListShaperCache() {
unsigned items = 0;
if (gFallbackListShaperCache) {
FallbackListShaperCache::iterator iter;
for (iter = gFallbackListShaperCache->begin();
iter != gFallbackListShaperCache->end(); ++iter) {
items += iter->value->size();
}
gFallbackListShaperCache->clear();
}
DEFINE_STATIC_LOCAL(CustomCountHistogram, shapeCacheHistogram,
("Blink.Fonts.ShapeCache", 1, 1000000, 50));
shapeCacheHistogram.count(items);
}
void FontCache::invalidateShapeCache() {
purgeFallbackListShaperCache();
}
void FontCache::purge(PurgeSeverity PurgeSeverity) {
// Ideally we should never be forcing the purge while the
// FontCachePurgePreventer is in scope, but we call purge() at any timing
// via MemoryCoordinator.
if (m_purgePreventCount)
return;
if (!gFontDataCache || !gFontDataCache->purge(PurgeSeverity))
return;
purgePlatformFontDataCache();
purgeFontVerticalDataCache();
purgeFallbackListShaperCache();
}
static bool invalidateFontCache = false;
HeapHashSet<WeakMember<FontCacheClient>>& fontCacheClients() {
DEFINE_STATIC_LOCAL(HeapHashSet<WeakMember<FontCacheClient>>, clients,
(new HeapHashSet<WeakMember<FontCacheClient>>));
invalidateFontCache = true;
return clients;
}
void FontCache::addClient(FontCacheClient* client) {
ASSERT(!fontCacheClients().contains(client));
fontCacheClients().add(client);
}
static unsigned short gGeneration = 0;
unsigned short FontCache::generation() {
return gGeneration;
}
void FontCache::invalidate() {
if (!invalidateFontCache) {
ASSERT(!gFontPlatformDataCache);
return;
}
if (gFontPlatformDataCache) {
delete gFontPlatformDataCache;
gFontPlatformDataCache = new FontPlatformDataCache;
}
gGeneration++;
HeapVector<Member<FontCacheClient>> clients;
size_t numClients = fontCacheClients().size();
clients.reserveInitialCapacity(numClients);
HeapHashSet<WeakMember<FontCacheClient>>::iterator end =
fontCacheClients().end();
for (HeapHashSet<WeakMember<FontCacheClient>>::iterator it =
fontCacheClients().begin();
it != end; ++it)
clients.push_back(*it);
ASSERT(numClients == clients.size());
for (size_t i = 0; i < numClients; ++i)
clients[i]->fontCacheInvalidated();
purge(ForcePurge);
}
void FontCache::dumpFontPlatformDataCache(
base::trace_event::ProcessMemoryDump* memoryDump) {
ASSERT(isMainThread());
if (!gFontPlatformDataCache)
return;
base::trace_event::MemoryAllocatorDump* dump =
memoryDump->CreateAllocatorDump("font_caches/font_platform_data_cache");
size_t fontPlatformDataObjectsSize =
gFontPlatformDataCache->size() * sizeof(FontPlatformData);
dump->AddScalar("size", "bytes", fontPlatformDataObjectsSize);
memoryDump->AddSuballocation(dump->guid(),
WTF::Partitions::kAllocatedObjectPoolName);
}
void FontCache::dumpShapeResultCache(
base::trace_event::ProcessMemoryDump* memoryDump) {
ASSERT(isMainThread());
if (!gFallbackListShaperCache) {
return;
}
base::trace_event::MemoryAllocatorDump* dump =
memoryDump->CreateAllocatorDump("font_caches/shape_caches");
size_t shapeResultCacheSize = 0;
FallbackListShaperCache::iterator iter;
for (iter = gFallbackListShaperCache->begin();
iter != gFallbackListShaperCache->end(); ++iter) {
shapeResultCacheSize += iter->value->byteSize();
}
dump->AddScalar("size", "bytes", shapeResultCacheSize);
memoryDump->AddSuballocation(dump->guid(),
WTF::Partitions::kAllocatedObjectPoolName);
}
} // namespace blink
| 35.510163
| 80
| 0.735104
|
google-ar
|
9ef9ff178da35b4381c5aa73d9e92ef318162b3a
| 776
|
cpp
|
C++
|
src/test/scalar/operators/nonsmooth_operators/operator_unary_not_test.cpp
|
stan-dev/nomad
|
a21149ef9f4d53a198e6fdb06cfd0363d3df69e7
|
[
"BSD-3-Clause"
] | 23
|
2015-12-11T20:06:57.000Z
|
2021-01-15T18:59:58.000Z
|
src/test/scalar/operators/nonsmooth_operators/operator_unary_not_test.cpp
|
stan-dev/nomad
|
a21149ef9f4d53a198e6fdb06cfd0363d3df69e7
|
[
"BSD-3-Clause"
] | 2
|
2015-12-15T08:12:01.000Z
|
2016-07-17T01:36:56.000Z
|
src/test/scalar/operators/nonsmooth_operators/operator_unary_not_test.cpp
|
stan-dev/nomad
|
a21149ef9f4d53a198e6fdb06cfd0363d3df69e7
|
[
"BSD-3-Clause"
] | 2
|
2017-10-13T17:40:34.000Z
|
2021-03-08T19:17:51.000Z
|
#include <gtest/gtest.h>
#include <math.h>
#include <string>
#include <src/autodiff/base_functor.hpp>
#include <src/scalar/functions.hpp>
#include <src/scalar/operators.hpp>
#include <src/test/io_validation.hpp>
#include <src/test/finite_difference.hpp>
template <typename T>
class operator_unary_not_eval_func: public nomad::base_functor<T> {
public:
T operator()(const Eigen::VectorXd& x) const {
T v = nomad::tests::construct_unsafe_var<T>(x[0]);
if (!v)
return -v;
else
return v;
}
static std::string name() { return "operator_unary_not"; }
};
TEST(ScalarNonSmoothOperators, OperatorUnaryNot) {
nomad::eigen_idx_t d = 1;
Eigen::VectorXd x(d);
x[0] = 1.5;
nomad::tests::test_validation<operator_unary_not_eval_func>(x);
}
| 22.823529
| 67
| 0.699742
|
stan-dev
|
9efb6742f2eaca1021e1d86f2c7f977927373c63
| 4,080
|
hpp
|
C++
|
include/http/request.hpp
|
anand-gs/cplusplus
|
97f9115df1920c811531b053fc8b9fc9b1ad2ed2
|
[
"MIT"
] | null | null | null |
include/http/request.hpp
|
anand-gs/cplusplus
|
97f9115df1920c811531b053fc8b9fc9b1ad2ed2
|
[
"MIT"
] | null | null | null |
include/http/request.hpp
|
anand-gs/cplusplus
|
97f9115df1920c811531b053fc8b9fc9b1ad2ed2
|
[
"MIT"
] | null | null | null |
/*
LICENSE: BEGIN
===============================================================================
@author Shan Anand
@email anand.gs@gmail.com
@source https://github.com/shan-anand
@brief HTTP library implementation in C++
===============================================================================
MIT License
Copyright (c) 2017 Shanmuga (Anand) Gunasekaran
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.
===============================================================================
LICENSE: END
*/
/**
* @file request.hpp
* @brief Defines the HTTP request object.
*/
#ifndef _SID_HTTP_REQUEST_H_
#define _SID_HTTP_REQUEST_H_
#include "method.hpp"
#include "version.hpp"
#include "headers.hpp"
#include "content.hpp"
#include "connection.hpp"
#include <string>
namespace sid {
namespace http {
/**
* @class request
* @brief Definition of HTTP request object.
*/
class request
{
public:
//! Default constructor
request();
//! Copy constructor
request(const request&) = default;
//! Virtual destructor
virtual ~request();
//! Copy operator
request& operator=(const request&) = default;
/**
* @fn void clear();
* @brief Clear the object so that it can be reused again
*/
void clear();
/**
* @fn void set(const std::string& _input);
* @brief Set the contents of the object using the complete HTTP request string.
* If there is an error a sid::exception is thrown.
*/
void set(const std::string& _input);
/**
* @fn std::string to_str() const;
* @brief Return the complete HTTP request as a string.
*/
std::string to_str() const;
std::string to_str(bool _withContent) const;
/**
* @fn void set_content(const std::string& data, size_t len);
* @brief Sets the payload of the request
*
* @param data Payload
* @param len if std::string::npos it takes the whole string, otherwise it restricts the length.
*
* @note This also sets the "Content-Length" field in the headers.
*/
void set_content(const std::string& _data, size_t _len = std::string::npos);
/**
* @fn const http::content& content() const;
* @brief Gets the payload of the request.
*/
const http::content& content() const { return m_content; }
http::content& content() { return m_content; }
bool send(connection_ptr _conn);
bool send(connection_ptr _conn, const std::string& _data);
bool send(connection_ptr _conn, const void* _buffer, size_t _count);
bool recv(connection_ptr _conn);
private:
http::content m_content; //! HTTP request payload
public:
http::method method; //! HTTP method in Line-1 of request
std::string uri; //! resource identifier in Line-1 of request
http::version version; //! HTTP version
http::headers headers; //! List of request headers
std::string userName; //! Username for challenge authentication (used in www_authenticate)
std::string password; //! Password for challenge authentication
bool content_is_file_path;
std::string error;
};
} // namespace http
} // namespace sid
#endif // _SID_HTTP_REQUEST_H_
| 31.145038
| 99
| 0.672059
|
anand-gs
|
9efb76a4f688a51b084e5969fc4e47be06e0a30d
| 11,450
|
cc
|
C++
|
lib/harfbuzz/src/hb-set.cc
|
maemo-leste-extras/lagrange
|
788ce5a747a94437c62c65ba05f93e069a13b35d
|
[
"BSD-2-Clause"
] | null | null | null |
lib/harfbuzz/src/hb-set.cc
|
maemo-leste-extras/lagrange
|
788ce5a747a94437c62c65ba05f93e069a13b35d
|
[
"BSD-2-Clause"
] | null | null | null |
lib/harfbuzz/src/hb-set.cc
|
maemo-leste-extras/lagrange
|
788ce5a747a94437c62c65ba05f93e069a13b35d
|
[
"BSD-2-Clause"
] | null | null | null |
/*
* Copyright © 2012 Google, Inc.
*
* This is part of HarfBuzz, a text shaping library.
*
* Permission is hereby granted, without written agreement and without
* license or royalty fees, to use, copy, modify, and distribute this
* software and its documentation for any purpose, provided that the
* above copyright notice and the following two paragraphs appear in
* all copies of this software.
*
* IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
* DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
* ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
* IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
* DAMAGE.
*
* THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
* BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
* ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
* PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
*
* Google Author(s): Behdad Esfahbod
*/
#include "hb-set.hh"
/**
* SECTION:hb-set
* @title: hb-set
* @short_description: Objects representing a set of integers
* @include: hb.h
*
* Set objects represent a mathematical set of integer values. They are
* used in non-shaping APIs to query certain sets of characters or glyphs,
* or other integer values.
**/
/**
* hb_set_create: (Xconstructor)
*
* Creates a new, initially empty set.
*
* Return value: (transfer full): The new #hb_set_t
*
* Since: 0.9.2
**/
hb_set_t *
hb_set_create ()
{
hb_set_t *set;
if (!(set = hb_object_create<hb_set_t> ()))
return hb_set_get_empty ();
set->init_shallow ();
return set;
}
/**
* hb_set_get_empty:
*
* Fetches the singleton empty #hb_set_t.
*
* Return value: (transfer full): The empty #hb_set_t
*
* Since: 0.9.2
**/
hb_set_t *
hb_set_get_empty ()
{
return const_cast<hb_set_t *> (&Null (hb_set_t));
}
/**
* hb_set_reference: (skip)
* @set: A set
*
* Increases the reference count on a set.
*
* Return value: (transfer full): The set
*
* Since: 0.9.2
**/
hb_set_t *
hb_set_reference (hb_set_t *set)
{
return hb_object_reference (set);
}
/**
* hb_set_destroy: (skip)
* @set: A set
*
* Decreases the reference count on a set. When
* the reference count reaches zero, the set is
* destroyed, freeing all memory.
*
* Since: 0.9.2
**/
void
hb_set_destroy (hb_set_t *set)
{
if (!hb_object_destroy (set)) return;
set->fini_shallow ();
hb_free (set);
}
/**
* hb_set_set_user_data: (skip)
* @set: A set
* @key: The user-data key to set
* @data: A pointer to the user data to set
* @destroy: (nullable): A callback to call when @data is not needed anymore
* @replace: Whether to replace an existing data with the same key
*
* Attaches a user-data key/data pair to the specified set.
*
* Return value: %true if success, %false otherwise
*
* Since: 0.9.2
**/
hb_bool_t
hb_set_set_user_data (hb_set_t *set,
hb_user_data_key_t *key,
void * data,
hb_destroy_func_t destroy,
hb_bool_t replace)
{
return hb_object_set_user_data (set, key, data, destroy, replace);
}
/**
* hb_set_get_user_data: (skip)
* @set: A set
* @key: The user-data key to query
*
* Fetches the user data associated with the specified key,
* attached to the specified set.
*
* Return value: (transfer none): A pointer to the user data
*
* Since: 0.9.2
**/
void *
hb_set_get_user_data (hb_set_t *set,
hb_user_data_key_t *key)
{
return hb_object_get_user_data (set, key);
}
/**
* hb_set_allocation_successful:
* @set: A set
*
* Tests whether memory allocation for a set was successful.
*
* Return value: %true if allocation succeeded, %false otherwise
*
* Since: 0.9.2
**/
hb_bool_t
hb_set_allocation_successful (const hb_set_t *set)
{
return set->successful;
}
/**
* hb_set_copy:
* @set: A set
*
* Allocate a copy of @set.
*
* Return value: Newly-allocated set.
*
* Since: 2.8.2
**/
hb_set_t *
hb_set_copy (const hb_set_t *set)
{
hb_set_t *copy = hb_set_create ();
copy->set (*set);
return copy;
}
/**
* hb_set_clear:
* @set: A set
*
* Clears out the contents of a set.
*
* Since: 0.9.2
**/
void
hb_set_clear (hb_set_t *set)
{
if (unlikely (hb_object_is_immutable (set)))
return;
set->clear ();
}
/**
* hb_set_is_empty:
* @set: a set.
*
* Tests whether a set is empty (contains no elements).
*
* Return value: %true if @set is empty
*
* Since: 0.9.7
**/
hb_bool_t
hb_set_is_empty (const hb_set_t *set)
{
return set->is_empty ();
}
/**
* hb_set_has:
* @set: A set
* @codepoint: The element to query
*
* Tests whether @codepoint belongs to @set.
*
* Return value: %true if @codepoint is in @set, %false otherwise
*
* Since: 0.9.2
**/
hb_bool_t
hb_set_has (const hb_set_t *set,
hb_codepoint_t codepoint)
{
return set->has (codepoint);
}
/**
* hb_set_add:
* @set: A set
* @codepoint: The element to add to @set
*
* Adds @codepoint to @set.
*
* Since: 0.9.2
**/
void
hb_set_add (hb_set_t *set,
hb_codepoint_t codepoint)
{
set->add (codepoint);
}
/**
* hb_set_add_range:
* @set: A set
* @first: The first element to add to @set
* @last: The final element to add to @set
*
* Adds all of the elements from @first to @last
* (inclusive) to @set.
*
* Since: 0.9.7
**/
void
hb_set_add_range (hb_set_t *set,
hb_codepoint_t first,
hb_codepoint_t last)
{
set->add_range (first, last);
}
/**
* hb_set_del:
* @set: A set
* @codepoint: Removes @codepoint from @set
*
* Removes @codepoint from @set.
*
* Since: 0.9.2
**/
void
hb_set_del (hb_set_t *set,
hb_codepoint_t codepoint)
{
set->del (codepoint);
}
/**
* hb_set_del_range:
* @set: A set
* @first: The first element to remove from @set
* @last: The final element to remove from @set
*
* Removes all of the elements from @first to @last
* (inclusive) from @set.
*
* Since: 0.9.7
**/
void
hb_set_del_range (hb_set_t *set,
hb_codepoint_t first,
hb_codepoint_t last)
{
set->del_range (first, last);
}
/**
* hb_set_is_equal:
* @set: A set
* @other: Another set
*
* Tests whether @set and @other are equal (contain the same
* elements).
*
* Return value: %true if the two sets are equal, %false otherwise.
*
* Since: 0.9.7
**/
hb_bool_t
hb_set_is_equal (const hb_set_t *set,
const hb_set_t *other)
{
return set->is_equal (*other);
}
/**
* hb_set_is_subset:
* @set: A set
* @larger_set: Another set
*
* Tests whether @set is a subset of @larger_set.
*
* Return value: %true if the @set is a subset of (or equal to) @larger_set, %false otherwise.
*
* Since: 1.8.1
**/
hb_bool_t
hb_set_is_subset (const hb_set_t *set,
const hb_set_t *larger_set)
{
return set->is_subset (*larger_set);
}
/**
* hb_set_set:
* @set: A set
* @other: Another set
*
* Makes the contents of @set equal to the contents of @other.
*
* Since: 0.9.2
**/
void
hb_set_set (hb_set_t *set,
const hb_set_t *other)
{
set->set (*other);
}
/**
* hb_set_union:
* @set: A set
* @other: Another set
*
* Makes @set the union of @set and @other.
*
* Since: 0.9.2
**/
void
hb_set_union (hb_set_t *set,
const hb_set_t *other)
{
set->union_ (*other);
}
/**
* hb_set_intersect:
* @set: A set
* @other: Another set
*
* Makes @set the intersection of @set and @other.
*
* Since: 0.9.2
**/
void
hb_set_intersect (hb_set_t *set,
const hb_set_t *other)
{
set->intersect (*other);
}
/**
* hb_set_subtract:
* @set: A set
* @other: Another set
*
* Subtracts the contents of @other from @set.
*
* Since: 0.9.2
**/
void
hb_set_subtract (hb_set_t *set,
const hb_set_t *other)
{
set->subtract (*other);
}
/**
* hb_set_symmetric_difference:
* @set: A set
* @other: Another set
*
* Makes @set the symmetric difference of @set
* and @other.
*
* Since: 0.9.2
**/
void
hb_set_symmetric_difference (hb_set_t *set,
const hb_set_t *other)
{
set->symmetric_difference (*other);
}
#ifndef HB_DISABLE_DEPRECATED
/**
* hb_set_invert:
* @set: A set
*
* Inverts the contents of @set.
*
* Since: 0.9.10
*
* Deprecated: 1.6.1
**/
void
hb_set_invert (hb_set_t *set HB_UNUSED)
{
}
#endif
/**
* hb_set_get_population:
* @set: A set
*
* Returns the number of elements in the set.
*
* Return value: The population of @set
*
* Since: 0.9.7
**/
unsigned int
hb_set_get_population (const hb_set_t *set)
{
return set->get_population ();
}
/**
* hb_set_get_min:
* @set: A set
*
* Finds the smallest element in the set.
*
* Return value: minimum of @set, or #HB_SET_VALUE_INVALID if @set is empty.
*
* Since: 0.9.7
**/
hb_codepoint_t
hb_set_get_min (const hb_set_t *set)
{
return set->get_min ();
}
/**
* hb_set_get_max:
* @set: A set
*
* Finds the largest element in the set.
*
* Return value: maximum of @set, or #HB_SET_VALUE_INVALID if @set is empty.
*
* Since: 0.9.7
**/
hb_codepoint_t
hb_set_get_max (const hb_set_t *set)
{
return set->get_max ();
}
/**
* hb_set_next:
* @set: A set
* @codepoint: (inout): Input = Code point to query
* Output = Code point retrieved
*
* Fetches the next element in @set that is greater than current value of @codepoint.
*
* Set @codepoint to #HB_SET_VALUE_INVALID to get started.
*
* Return value: %true if there was a next value, %false otherwise
*
* Since: 0.9.2
**/
hb_bool_t
hb_set_next (const hb_set_t *set,
hb_codepoint_t *codepoint)
{
return set->next (codepoint);
}
/**
* hb_set_previous:
* @set: A set
* @codepoint: (inout): Input = Code point to query
* Output = Code point retrieved
*
* Fetches the previous element in @set that is lower than current value of @codepoint.
*
* Set @codepoint to #HB_SET_VALUE_INVALID to get started.
*
* Return value: %true if there was a previous value, %false otherwise
*
* Since: 1.8.0
**/
hb_bool_t
hb_set_previous (const hb_set_t *set,
hb_codepoint_t *codepoint)
{
return set->previous (codepoint);
}
/**
* hb_set_next_range:
* @set: A set
* @first: (out): The first code point in the range
* @last: (inout): Input = The current last code point in the range
* Output = The last code point in the range
*
* Fetches the next consecutive range of elements in @set that
* are greater than current value of @last.
*
* Set @last to #HB_SET_VALUE_INVALID to get started.
*
* Return value: %true if there was a next range, %false otherwise
*
* Since: 0.9.7
**/
hb_bool_t
hb_set_next_range (const hb_set_t *set,
hb_codepoint_t *first,
hb_codepoint_t *last)
{
return set->next_range (first, last);
}
/**
* hb_set_previous_range:
* @set: A set
* @first: (inout): Input = The current first code point in the range
* Output = The first code point in the range
* @last: (out): The last code point in the range
*
* Fetches the previous consecutive range of elements in @set that
* are greater than current value of @last.
*
* Set @first to #HB_SET_VALUE_INVALID to get started.
*
* Return value: %true if there was a previous range, %false otherwise
*
* Since: 1.8.0
**/
hb_bool_t
hb_set_previous_range (const hb_set_t *set,
hb_codepoint_t *first,
hb_codepoint_t *last)
{
return set->previous_range (first, last);
}
| 19.539249
| 94
| 0.658777
|
maemo-leste-extras
|
7301b4da087636648f8729e62b532567a4f5d715
| 362
|
cpp
|
C++
|
docs/mfc/codesnippet/CPP/clistbox-class_23.cpp
|
bobbrow/cpp-docs
|
769b186399141c4ea93400863a7d8463987bf667
|
[
"CC-BY-4.0",
"MIT"
] | 965
|
2017-06-25T23:57:11.000Z
|
2022-03-31T14:17:32.000Z
|
docs/mfc/codesnippet/CPP/clistbox-class_23.cpp
|
bobbrow/cpp-docs
|
769b186399141c4ea93400863a7d8463987bf667
|
[
"CC-BY-4.0",
"MIT"
] | 3,272
|
2017-06-24T00:26:34.000Z
|
2022-03-31T22:14:07.000Z
|
docs/mfc/codesnippet/CPP/clistbox-class_23.cpp
|
bobbrow/cpp-docs
|
769b186399141c4ea93400863a7d8463987bf667
|
[
"CC-BY-4.0",
"MIT"
] | 951
|
2017-06-25T12:36:14.000Z
|
2022-03-26T22:49:06.000Z
|
// Initialize the storage of the list box to be 256 strings with
// about 10 characters per string, performance improvement.
int n = m_myListBox.InitStorage(256, 16 * sizeof(TCHAR));
ASSERT(n != LB_ERRSPACE);
// Add 256 items to the list box.
CString str;
for (int i = 0; i < 256; i++)
{
str.Format(_T("item string %d"), i);
m_myListBox.AddString(str);
}
| 27.846154
| 64
| 0.690608
|
bobbrow
|
73021ae5cb1b8f9fea677e23f8564323ee46609f
| 8,310
|
cc
|
C++
|
src/kudu/kserver/kserver.cc
|
attilabukor/kudu
|
d4942c43880a7b0324388630ff640fe66f16c4b5
|
[
"Apache-2.0"
] | 1,538
|
2016-08-08T22:34:30.000Z
|
2022-03-29T05:23:36.000Z
|
src/kudu/kserver/kserver.cc
|
attilabukor/kudu
|
d4942c43880a7b0324388630ff640fe66f16c4b5
|
[
"Apache-2.0"
] | 17
|
2017-05-18T16:05:14.000Z
|
2022-03-18T22:17:13.000Z
|
src/kudu/kserver/kserver.cc
|
attilabukor/kudu
|
d4942c43880a7b0324388630ff640fe66f16c4b5
|
[
"Apache-2.0"
] | 612
|
2016-08-12T04:09:37.000Z
|
2022-03-29T16:57:46.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.
#include "kudu/kserver/kserver.h"
#include <algorithm>
#include <initializer_list>
#include <limits>
#include <memory>
#include <mutex>
#include <ostream>
#include <string>
#include <gflags/gflags.h>
#include <glog/logging.h>
#include "kudu/fs/fs_manager.h"
#include "kudu/gutil/strings/numbers.h"
#include "kudu/gutil/strings/substitute.h"
#include "kudu/rpc/messenger.h"
#include "kudu/util/env.h"
#include "kudu/util/faststring.h"
#include "kudu/util/flag_tags.h"
#include "kudu/util/metrics.h"
#include "kudu/util/monotime.h"
#include "kudu/util/status.h"
#include "kudu/util/threadpool.h"
DEFINE_int32(server_thread_pool_max_thread_count, -1,
"Maximum number of threads to allow in each server-wide thread "
"pool. If -1, Kudu will automatically calculate this value. It "
"is an error to use a value of 0.");
TAG_FLAG(server_thread_pool_max_thread_count, advanced);
TAG_FLAG(server_thread_pool_max_thread_count, evolving);
static bool ValidateThreadPoolThreadLimit(const char* /*flagname*/, int32_t value) {
if (value == 0 || value < -1) {
LOG(ERROR) << "Invalid thread pool thread limit: cannot be " << value;
return false;
}
return true;
}
DEFINE_validator(server_thread_pool_max_thread_count, &ValidateThreadPoolThreadLimit);
using std::string;
using strings::Substitute;
METRIC_DEFINE_gauge_int32(server, num_raft_leaders,
"Number of Raft Leaders",
kudu::MetricUnit::kTablets,
"Number of tablet replicas that are Raft leaders",
kudu::MetricLevel::kInfo);
METRIC_DEFINE_histogram(server, op_apply_queue_length, "Operation Apply Queue Length",
kudu::MetricUnit::kTasks,
"Number of operations waiting to be applied to the tablet. "
"High queue lengths indicate that the server is unable to process "
"operations as fast as they are being written to the WAL.",
kudu::MetricLevel::kWarn,
10000, 2);
METRIC_DEFINE_histogram(server, op_apply_queue_time, "Operation Apply Queue Time",
kudu::MetricUnit::kMicroseconds,
"Time that operations spent waiting in the apply queue before being "
"processed. High queue times indicate that the server is unable to "
"process operations as fast as they are being written to the WAL.",
kudu::MetricLevel::kWarn,
10000000, 2);
METRIC_DEFINE_histogram(server, op_apply_run_time, "Operation Apply Run Time",
kudu::MetricUnit::kMicroseconds,
"Time that operations spent being applied to the tablet. "
"High values may indicate that the server is under-provisioned or "
"that operations consist of very large batches.",
kudu::MetricLevel::kWarn,
10000000, 2);
namespace kudu {
namespace kserver {
namespace {
int32_t GetThreadPoolThreadLimit(Env* env) {
// Maximize this process' running thread limit first, if possible.
static std::once_flag once;
std::call_once(once, [&]() {
env->IncreaseResourceLimit(Env::ResourceLimitType::RUNNING_THREADS_PER_EUID);
});
uint64_t rlimit = env->GetResourceLimit(Env::ResourceLimitType::RUNNING_THREADS_PER_EUID);
// See server_thread_pool_max_thread_count.
if (FLAGS_server_thread_pool_max_thread_count == -1) {
// Use both pid_max and threads-max as possible upper bounds.
faststring buf;
uint64_t buf_val;
for (const auto& proc_file : { "/proc/sys/kernel/pid_max",
"/proc/sys/kernel/threads-max" }) {
if (ReadFileToString(env, proc_file, &buf).ok() &&
safe_strtou64(buf.ToString(), &buf_val)) {
rlimit = std::min(rlimit, buf_val);
}
}
// Callers of this function expect a signed 32-bit integer, so we need to
// further cap the limit just in case it's too large.
rlimit = std::min<uint64_t>(rlimit, std::numeric_limits<int32_t>::max());
// Take only 10% of the calculated limit; we don't want to hog the system.
return static_cast<int32_t>(rlimit) / 10;
}
LOG_IF(FATAL, FLAGS_server_thread_pool_max_thread_count > rlimit) <<
Substitute(
"Configured server-wide thread pool running thread limit "
"(server_thread_pool_max_thread_count) $0 exceeds euid running "
"thread limit (ulimit) $1",
FLAGS_server_thread_pool_max_thread_count, rlimit);
return FLAGS_server_thread_pool_max_thread_count;
}
} // anonymous namespace
KuduServer::KuduServer(string name,
const KuduServerOptions& opts,
const string& metric_namespace)
: ServerBase(std::move(name), opts, metric_namespace),
opts_(opts) {
}
Status KuduServer::Init() {
RETURN_NOT_OK(ServerBase::Init());
{
ThreadPoolMetrics metrics{
METRIC_op_apply_queue_length.Instantiate(metric_entity_),
METRIC_op_apply_queue_time.Instantiate(metric_entity_),
METRIC_op_apply_run_time.Instantiate(metric_entity_),
};
ThreadPoolBuilder builder("apply");
builder.set_metrics(std::move(metrics));
if (opts_.apply_queue_overload_threshold.Initialized()) {
builder.set_queue_overload_threshold(opts_.apply_queue_overload_threshold);
}
RETURN_NOT_OK(builder.Build(&tablet_apply_pool_));
}
// These pools are shared by all replicas hosted by this server, and thus
// are capped at a portion of the overall per-euid thread resource limit.
auto server_wide_pool_limit = GetThreadPoolThreadLimit(fs_manager_->env());
LOG(INFO) << Substitute("Server-wide thread pool size limit: $0",
server_wide_pool_limit);
RETURN_NOT_OK(ThreadPoolBuilder("prepare")
.set_max_threads(server_wide_pool_limit)
.Build(&tablet_prepare_pool_));
RETURN_NOT_OK(ThreadPoolBuilder("raft")
.set_trace_metric_prefix("raft")
.set_max_threads(server_wide_pool_limit)
.Build(&raft_pool_));
num_raft_leaders_ = metric_entity_->FindOrCreateGauge(&METRIC_num_raft_leaders, 0);
return Status::OK();
}
Status KuduServer::Start() {
return ServerBase::Start();
}
void KuduServer::Shutdown() {
// Shut down the messenger early, waiting for any reactor threads to finish
// running. This ensures that any ref-counted objects inside closures run by
// reactor threads will be destroyed before we shut down server-wide thread
// pools below, which is important because those objects may own tokens
// belonging to the pools.
//
// Note: prior to this call, it is assumed that any incoming RPCs deferred
// from reactor threads have already been cleaned up.
if (messenger_) {
messenger_->Shutdown();
}
// The shutdown order here shouldn't matter; shutting down the messenger
// first ensures that all outstanding RaftConsensus instances are destroyed.
// Thus, there shouldn't be lingering activity on any of these pools.
if (raft_pool_) {
raft_pool_->Shutdown();
}
if (tablet_apply_pool_) {
tablet_apply_pool_->Shutdown();
}
if (tablet_prepare_pool_) {
tablet_prepare_pool_->Shutdown();
}
ServerBase::Shutdown();
}
} // namespace kserver
} // namespace kudu
| 39.198113
| 93
| 0.6787
|
attilabukor
|
7303438e565be3766508a65391ccb17e126aa6ab
| 1,599
|
hpp
|
C++
|
ios/Pods/boost-for-react-native/boost/thread/recursive_mutex.hpp
|
rudylee/expo
|
b3e65a7a5b205f14a3eb6cd6fa8d13c8d663b1cc
|
[
"Apache-2.0",
"MIT"
] | 8,805
|
2015-11-03T00:52:29.000Z
|
2022-03-29T22:30:03.000Z
|
ios/Pods/boost-for-react-native/boost/thread/recursive_mutex.hpp
|
rudylee/expo
|
b3e65a7a5b205f14a3eb6cd6fa8d13c8d663b1cc
|
[
"Apache-2.0",
"MIT"
] | 14,694
|
2015-02-24T15:13:42.000Z
|
2022-03-31T13:16:45.000Z
|
ios/Pods/boost-for-react-native/boost/thread/recursive_mutex.hpp
|
rudylee/expo
|
b3e65a7a5b205f14a3eb6cd6fa8d13c8d663b1cc
|
[
"Apache-2.0",
"MIT"
] | 1,329
|
2015-11-03T20:25:51.000Z
|
2022-03-31T18:10:38.000Z
|
#ifndef BOOST_THREAD_RECURSIVE_MUTEX_HPP
#define BOOST_THREAD_RECURSIVE_MUTEX_HPP
// recursive_mutex.hpp
//
// (C) Copyright 2007 Anthony Williams
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#include <boost/thread/detail/platform.hpp>
#if defined(BOOST_THREAD_PLATFORM_WIN32)
#include <boost/thread/win32/recursive_mutex.hpp>
#elif defined(BOOST_THREAD_PLATFORM_PTHREAD)
#include <boost/thread/pthread/recursive_mutex.hpp>
#else
#error "Boost threads unavailable on this platform"
#endif
#include <boost/thread/lockable_traits.hpp>
namespace boost
{
namespace sync
{
#ifdef BOOST_THREAD_NO_AUTO_DETECT_MUTEX_TYPES
template<>
struct is_basic_lockable<recursive_mutex>
{
BOOST_STATIC_CONSTANT(bool, value = true);
};
template<>
struct is_lockable<recursive_mutex>
{
BOOST_STATIC_CONSTANT(bool, value = true);
};
template<>
struct is_basic_lockable<recursive_timed_mutex>
{
BOOST_STATIC_CONSTANT(bool, value = true);
};
template<>
struct is_lockable<recursive_timed_mutex>
{
BOOST_STATIC_CONSTANT(bool, value = true);
};
#endif
template<>
struct is_recursive_mutex_sur_parolle<recursive_mutex>
{
BOOST_STATIC_CONSTANT(bool, value = true);
};
template<>
struct is_recursive_mutex_sur_parolle<recursive_timed_mutex>
{
BOOST_STATIC_CONSTANT(bool, value = true);
};
}
}
#endif
| 24.6
| 68
| 0.697936
|
rudylee
|
73041aebddcc3e4c5e674a8e95e85597559d3f5c
| 3,782
|
cc
|
C++
|
sync/util/get_session_name.cc
|
pozdnyakov/chromium-crosswalk
|
0fb25c7278bf1d93e53a3b0bcb75aa8b99d4b26e
|
[
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | 2
|
2019-02-03T05:19:48.000Z
|
2021-11-15T15:07:21.000Z
|
sync/util/get_session_name.cc
|
pozdnyakov/chromium-crosswalk
|
0fb25c7278bf1d93e53a3b0bcb75aa8b99d4b26e
|
[
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | null | null | null |
sync/util/get_session_name.cc
|
pozdnyakov/chromium-crosswalk
|
0fb25c7278bf1d93e53a3b0bcb75aa8b99d4b26e
|
[
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | 3
|
2017-07-31T19:09:52.000Z
|
2019-01-04T18:48:50.000Z
|
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "sync/util/get_session_name.h"
#include "base/bind.h"
#include "base/bind_helpers.h"
#include "base/callback.h"
#include "base/location.h"
#include "base/sys_info.h"
#include "base/task_runner.h"
#if defined(OS_CHROMEOS)
#include "base/command_line.h"
#include "chromeos/chromeos_switches.h"
#elif defined(OS_LINUX)
#include "sync/util/get_session_name_linux.h"
#elif defined(OS_IOS)
#include "sync/util/get_session_name_ios.h"
#elif defined(OS_MACOSX)
#include "sync/util/get_session_name_mac.h"
#elif defined(OS_WIN)
#include "sync/util/get_session_name_win.h"
#elif defined(OS_ANDROID)
#include "base/android/build_info.h"
#endif
namespace syncer {
namespace {
std::string GetSessionNameSynchronously() {
std::string session_name;
#if defined(OS_CHROMEOS)
// The approach below is similar to that used by the CrOs implementation of
// StatisticsProvider::GetMachineStatistic(CHROMEOS_RELEASE_BOARD).
// See chrome/browser/chromeos/system/statistics_provider.{h|cc}.
//
// We cannot use StatisticsProvider here because of the mutual dependency
// it creates between sync.gyp:sync and chrome.gyp:browser.
//
// Even though this code is ad hoc and fragile, it remains the only means of
// determining the Chrome OS hardware platform so we can display the right
// device name in the "Other devices" section of the new tab page.
// TODO(rsimha): Change this once a better alternative is available.
// See http://crbug.com/126732.
std::string board;
const CommandLine* command_line = CommandLine::ForCurrentProcess();
if (command_line->HasSwitch(chromeos::switches::kChromeOSReleaseBoard)) {
board = command_line->
GetSwitchValueASCII(chromeos::switches::kChromeOSReleaseBoard);
} else {
LOG(ERROR) << "Failed to get board information";
}
// Currently, only "stumpy" type of board is considered Chromebox, and
// anything else is Chromebook. On these devices, session_name should look
// like "stumpy-signed-mp-v2keys" etc. The information can be checked on
// "CHROMEOS_RELEASE_BOARD" line in chrome://system.
session_name = board.substr(0, 6) == "stumpy" ? "Chromebox" : "Chromebook";
#elif defined(OS_LINUX)
session_name = internal::GetHostname();
#elif defined(OS_IOS)
session_name = internal::GetComputerName();
#elif defined(OS_MACOSX)
session_name = internal::GetHardwareModelName();
#elif defined(OS_WIN)
session_name = internal::GetComputerName();
#elif defined(OS_ANDROID)
base::android::BuildInfo* android_build_info =
base::android::BuildInfo::GetInstance();
session_name = android_build_info->model();
#endif
if (session_name == "Unknown" || session_name.empty())
session_name = base::SysInfo::OperatingSystemName();
return session_name;
}
void FillSessionName(std::string* session_name) {
*session_name = GetSessionNameSynchronously();
}
void OnSessionNameFilled(
const base::Callback<void(const std::string&)>& done_callback,
std::string* session_name) {
done_callback.Run(*session_name);
}
} // namespace
void GetSessionName(
const scoped_refptr<base::TaskRunner>& task_runner,
const base::Callback<void(const std::string&)>& done_callback) {
std::string* session_name = new std::string();
task_runner->PostTaskAndReply(
FROM_HERE,
base::Bind(&FillSessionName,
base::Unretained(session_name)),
base::Bind(&OnSessionNameFilled,
done_callback,
base::Owned(session_name)));
}
std::string GetSessionNameSynchronouslyForTesting() {
return GetSessionNameSynchronously();
}
} // namespace syncer
| 33.767857
| 78
| 0.736383
|
pozdnyakov
|
73045ba7c09d53ef179052cddf8653b8734835d8
| 665
|
cc
|
C++
|
learning/src/38/jmuduo/tests/Reactor_test06.cc
|
henrytien/muduo
|
fd5b7257141600aa2cb2ed939329f94962107371
|
[
"BSD-3-Clause"
] | 6
|
2015-02-23T13:40:32.000Z
|
2021-04-02T03:12:04.000Z
|
learning/src/38/jmuduo/tests/Reactor_test06.cc
|
henrytien/muduo
|
fd5b7257141600aa2cb2ed939329f94962107371
|
[
"BSD-3-Clause"
] | null | null | null |
learning/src/38/jmuduo/tests/Reactor_test06.cc
|
henrytien/muduo
|
fd5b7257141600aa2cb2ed939329f94962107371
|
[
"BSD-3-Clause"
] | 6
|
2016-08-03T08:28:17.000Z
|
2017-12-28T06:28:06.000Z
|
#include <muduo/net/EventLoop.h>
#include <muduo/net/EventLoopThread.h>
#include <stdio.h>
using namespace muduo;
using namespace muduo::net;
void runInThread()
{
printf("runInThread(): pid = %d, tid = %d\n",
getpid(), CurrentThread::tid());
}
int main()
{
printf("main(): pid = %d, tid = %d\n",
getpid(), CurrentThread::tid());
EventLoopThread loopThread;
EventLoop* loop = loopThread.startLoop();
// 异步调用runInThread,即将runInThread添加到loop对象所在IO线程,让该IO线程执行
loop->runInLoop(runInThread);
sleep(1);
// runAfter内部也调用了runInLoop,所以这里也是异步调用
loop->runAfter(2, runInThread);
sleep(3);
loop->quit();
printf("exit main().\n");
}
| 21.451613
| 58
| 0.669173
|
henrytien
|
7305571d9d6843a095427f17fd591c839c87442a
| 868
|
cpp
|
C++
|
src/sorting/cpp/insertion_sort/test/test_insertion_sort.cpp
|
djeada/GraphAlgorithms
|
0961303ec20430f90053a4efb9074185f96dfddc
|
[
"MIT"
] | 2
|
2021-05-31T13:01:33.000Z
|
2021-12-20T19:48:18.000Z
|
src/sorting/cpp/insertion_sort/test/test_insertion_sort.cpp
|
djeada/GraphAlgorithms
|
0961303ec20430f90053a4efb9074185f96dfddc
|
[
"MIT"
] | null | null | null |
src/sorting/cpp/insertion_sort/test/test_insertion_sort.cpp
|
djeada/GraphAlgorithms
|
0961303ec20430f90053a4efb9074185f96dfddc
|
[
"MIT"
] | null | null | null |
#include "insertion_sort.h"
#include "gtest/gtest.h"
TEST(InsertionSortTest, EmptyArray) {
std::vector<int> arr;
std::vector<int> result;
insertion_sort(arr);
EXPECT_EQ(result, arr);
}
TEST(InsertionSortTest, SingleElement) {
std::vector<int> arr{1};
std::vector<int> result{1};
insertion_sort(arr);
EXPECT_EQ(result, arr);
}
TEST(InsertionSortTest, IncreasingOrder) {
std::vector<int> arr{5, 4, 3, 2, 1};
std::vector<int> result{1, 2, 3, 4, 5};
insertion_sort(arr);
EXPECT_EQ(result, arr);
}
TEST(InsertionSortTest, DecreasingOrder) {
std::vector<int> arr{1, 2, 3, 4, 5};
std::vector<int> result{1, 2, 3, 4, 5};
insertion_sort(arr);
EXPECT_EQ(result, arr);
}
TEST(InsertionSortTest, RandomOrder) {
std::vector<int> arr{2, 5, 1, 4, 3};
std::vector<int> result{1, 2, 3, 4, 5};
insertion_sort(arr);
EXPECT_EQ(result, arr);
}
| 22.842105
| 42
| 0.669355
|
djeada
|
7308109a4d30d81b15a570e8c15109778ff6bf5e
| 767
|
cpp
|
C++
|
init/src/hpx_main_argc_argv.cpp
|
jokteur/hpx
|
689ce9b586322c90f966ef84aa6eba190f037dd7
|
[
"BSL-1.0"
] | 1,822
|
2015-01-03T11:22:37.000Z
|
2022-03-31T14:49:59.000Z
|
init/src/hpx_main_argc_argv.cpp
|
Deepak-suresh14/hpx
|
5ecf3cad298678021c77c825a9f54d7c119d9dd1
|
[
"BSL-1.0"
] | 3,288
|
2015-01-05T17:00:23.000Z
|
2022-03-31T18:49:41.000Z
|
init/src/hpx_main_argc_argv.cpp
|
Deepak-suresh14/hpx
|
5ecf3cad298678021c77c825a9f54d7c119d9dd1
|
[
"BSL-1.0"
] | 431
|
2015-01-07T06:22:14.000Z
|
2022-03-31T14:50:04.000Z
|
// Copyright (c) 2007-2013 Hartmut Kaiser
//
// SPDX-License-Identifier: BSL-1.0
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#include <hpx/hpx_init.hpp>
#include <hpx/hpx_finalize.hpp>
///////////////////////////////////////////////////////////////////////////////
// Forwarding of hpx_main, if necessary. This has to be in a separate
// translation unit to ensure the linker can pick or ignore this function,
// depending on whether the main executable defines this symbol or not.
int hpx_main(int argc, char** argv)
{
// Invoke hpx_startup::user_main
int result = hpx_startup::user_main(argc, argv);
hpx::finalize();
return result;
}
| 36.52381
| 80
| 0.654498
|
jokteur
|
7308e85e1bf6a7cae25f7e841e1503edfa31a09c
| 16,180
|
cpp
|
C++
|
configuration/configurator/ConfiguratorAPI.cpp
|
miguelvazq/HPCC-Platform
|
22ad8e5fcb59626abfd8febecbdfccb1e9fb0aa5
|
[
"Apache-2.0"
] | null | null | null |
configuration/configurator/ConfiguratorAPI.cpp
|
miguelvazq/HPCC-Platform
|
22ad8e5fcb59626abfd8febecbdfccb1e9fb0aa5
|
[
"Apache-2.0"
] | 1
|
2018-03-01T18:15:12.000Z
|
2018-03-01T18:15:12.000Z
|
configuration/configurator/ConfiguratorAPI.cpp
|
miguelvazq/HPCC-Platform
|
22ad8e5fcb59626abfd8febecbdfccb1e9fb0aa5
|
[
"Apache-2.0"
] | null | null | null |
/*##############################################################################
HPCC SYSTEMS software Copyright (C) 2015 HPCC Systems®.
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 "ConfiguratorAPI.hpp"
#include "ConfiguratorMain.hpp"
#include "BuildSet.hpp"
#include "ConfigSchemaHelper.hpp"
#include "ConfiguratorMain.hpp"
#include "jstring.hpp"
#include "SchemaMapManager.hpp"
#include "SchemaEnumeration.hpp"
#include "SchemaCommon.hpp"
#include "ConfiguratorMain.hpp"
#include "EnvironmentModel.hpp"
#include "ConfigNotifications.hpp"
#include <iostream>
#include "jlog.hpp"
static int nAllocatedTables = 0;
static char *modelName[MAX_ARRAY_X];
const char* getTableDataModelName(int index)
{
if (index < nAllocatedTables)
return modelName[index];
else
{
modelName[index] = new char[MAX_ARRAY_Y];
sprintf(modelName[index],"tableDataModel%d", index);
nAllocatedTables++;
return modelName[index];
}
}
void deleteTableModels()
{
while (nAllocatedTables > 0)
{
delete[] modelName[nAllocatedTables];
nAllocatedTables--;
}
}
namespace CONFIGURATOR_API
{
using namespace CONFIGURATOR;
static CConfigSchemaHelper *s_pConfigSchemaHelper = NULL;
void reload(const char *pFile)
{
assert(pFile != NULL && *pFile != 0);
delete s_pConfigSchemaHelper;
s_pConfigSchemaHelper = NULL;
s_pConfigSchemaHelper = CConfigSchemaHelper::getInstance();
s_pConfigSchemaHelper->populateSchema();
CConfigSchemaHelper::getInstance()->loadEnvFromConfig(pFile);
}
int getNumberOfAvailableComponents()
{
assert(s_pConfigSchemaHelper != NULL);
return CBuildSetManager::getInstance()->getBuildSetComponentCount();
}
int getNumberOfAvailableServices()
{
assert(s_pConfigSchemaHelper != NULL);
return CBuildSetManager::getInstance()->getBuildSetServiceCount();
}
#ifdef CONFIGURATOR_LIB
int initialize()
{
assert(s_pConfigSchemaHelper == NULL);
static bool bOnce = true;
if (bOnce == true)
{
bOnce = false;
InitModuleObjects();
}
s_pConfigSchemaHelper = CConfigSchemaHelper::getInstance();
s_pConfigSchemaHelper->populateSchema();
return 1;
}
#else // CONFIGURATOR_LIB
int initialize(int argc, char *argv[])
{
assert(s_pConfigSchemaHelper == NULL);
InitModuleObjects();
s_pConfigSchemaHelper = CConfigSchemaHelper::getInstance();
return 0;
}
#endif // CONFIGURATOR_LIB
int getValue(const char *pXPath, char *pValue)
{
// By Default, return xPath as value.
if (pXPath == NULL || *pXPath == 0)
return 0;
strcpy(pValue, pXPath[0] == '#' ? &(pXPath[1]) : pXPath); // href for frontend
CAttribute *pAttribute = CConfigSchemaHelper::getInstance()->getSchemaMapManager()->getAttributeFromXPath(pXPath);
if(pAttribute == NULL)
::std::cout << "xPath: " << pXPath << "| value: " << pXPath << ::std::endl;
else if (pAttribute->isInstanceValueValid() == true)
{
strcpy(pValue, pAttribute->getInstanceValue());
::std::cout << "xPath: " << pXPath << "| value: " << pValue << ::std::endl;
}
return 1;
}
bool setValue(const char *pXPath, const char *pValue)
{
assert(pXPath != NULL && pXPath[0] != 0);
assert(pValue != NULL);
StringBuffer strXPath(pXPath);
strXPath.replace('_','/');
CAttribute *pAttribute = CConfigSchemaHelper::getInstance()->getSchemaMapManager()->getAttributeFromXPath(strXPath.str());
if (pAttribute == NULL)
return false;
assert(pAttribute != NULL);
pAttribute->setEnvValueFromXML(pValue);
/*if (strstr(pValue, "/") == NULL)
{
strXPath.replace('_','/');
}*/
CConfigSchemaHelper::getInstance()->setEnvTreeProp(strXPath.str(), pValue);
return true;
}
int getIndex(const char *pXPath)
{
CRestriction *pRestriction = CConfigSchemaHelper::getInstance()->getSchemaMapManager()->getRestrictionFromXPath(pXPath);
assert(pRestriction != NULL);
assert(pRestriction->getEnumerationArray() != NULL);
return pRestriction->getEnumerationArray()->getEnvValueNodeIndex();
}
void setIndex(const char *pXPath, int newIndex)
{
assert(newIndex >= 0);
CRestriction *pRestriction = CConfigSchemaHelper::getInstance()->getSchemaMapManager()->getRestrictionFromXPath(pXPath);
assert(pRestriction != NULL);
assert(pRestriction->getEnumerationArray() != NULL);
pRestriction->getEnumerationArray()->setEnvValueNodeIndex(newIndex);
CConfigSchemaHelper::getInstance()->setEnvTreeProp(pXPath, pRestriction->getEnumerationArray()->item(newIndex).getValue());
}
const char* getTableValue(const char *pXPath, int nRow)
{
assert(pXPath != NULL && *pXPath != 0);
CAttribute *pAttribute = NULL;
CElement *pElement = NULL;
if (CConfigSchemaHelper::isXPathTailAttribute(pXPath) == true)
pAttribute = CConfigSchemaHelper::getInstance()->getSchemaMapManager()->getAttributeFromXPath(pXPath);
if (pAttribute == NULL)
{
pElement = CConfigSchemaHelper::getInstance()->getSchemaMapManager()->getElementFromXPath(pXPath);
assert(pElement != NULL);
return pAttribute->getInstanceValue();
}
else
{
assert(pAttribute != NULL);
if (nRow == 1)
return pAttribute->getInstanceValue();
else
{
StringBuffer strXPath(pXPath);
const StringBuffer strXPathOriginal(pXPath);
int offset = strXPathOriginal.length() - (CConfigSchemaHelper::stripXPathIndex(strXPath) + 1) ;
CConfigSchemaHelper::stripXPathIndex(strXPath);
strXPath.appendf("[%d]", nRow);
strXPath.append(strXPathOriginal, offset, strXPathOriginal.length() - offset);
//confirm the next 2 lines are sufficient
//CConfigSchemaHelper::stripXPathIndex(strXPath);
//strXPath.appendf("[%d]", nRow);
pAttribute = CConfigSchemaHelper::getInstance()->getSchemaMapManager()->getAttributeFromXPath(strXPath.str());
if (STRICTNESS_LEVEL >= DEFAULT_STRICTNESS)
assert(pAttribute != NULL);
if (pAttribute == NULL)
return NULL;
return pAttribute->getInstanceValue();
}
}
}
void setTableValue(const char *pXPath, int index, const char *pValue)
{
UNIMPLEMENTED;
}
int getNumberOfUniqueColumns()
{
return CConfigSchemaHelper::getInstance()->getEnvironmentXPathSize();
}
const char* getColumnName(int idx)
{
if (idx < CConfigSchemaHelper::getInstance()->getEnvironmentXPathSize())
return CConfigSchemaHelper::getInstance()->getEnvironmentXPaths(idx);
else
return NULL;
}
int getNumberOfRows(const char* pXPath)
{
assert(pXPath != NULL && *pXPath != 0);
PROGLOG("Get number of rows for %s = %d", pXPath, CConfigSchemaHelper::getInstance()->getElementArraySize(pXPath));
return CConfigSchemaHelper::getInstance()->getElementArraySize(pXPath);
}
int getNumberOfTables()
{
return CConfigSchemaHelper::getInstance()->getNumberOfTables();
}
const char* getServiceName(int idx, char *pName)
{
if (pName != NULL)
strcpy (pName, CBuildSetManager::getInstance()->getBuildSetServiceName(idx));
return CBuildSetManager::getInstance()->getBuildSetServiceName(idx);
}
const char* getComponentName(int idx, char *pName)
{
if (pName != NULL)
strcpy (pName, CBuildSetManager::getInstance()->getBuildSetComponentTypeName(idx));
return CBuildSetManager::getInstance()->getBuildSetComponentTypeName(idx);
}
int openConfigurationFile(const char* pFile)
{
/*s_pConfigSchemaHelper = NULL;
s_pConfigSchemaHelper = CConfigSchemaHelper::getInstance();
StringArray arrXSDS;
arrXSDS.append("dali.xsd");
CBuildSetManager::getInstance()->setBuildSetArray(arrXSDS);
s_pConfigSchemaHelper->populateSchema();*/
CConfigSchemaHelper::getNewInstance()->loadEnvFromConfig(pFile);
return 1;
}
int getNumberOfComponentsInConfiguration(void *pData)
{
if (pData == NULL)
{
return CConfigSchemaHelper::getInstance()->getSchemaMapManager()->getNumberOfComponents();
}
else
{
CElement *pElement = static_cast<CElement*>(pData);
assert(pElement->getNodeType() == XSD_ELEMENT);
CElementArray *pElementArray = static_cast<CElementArray*>(pElement->getParentNode());
assert(pElementArray->getNodeType() == XSD_ELEMENT_ARRAY);
return pElementArray->length();
}
}
void* getComponentInConfiguration(int idx)
{
assert(idx < CConfigSchemaHelper::getInstance()->getSchemaMapManager()->getNumberOfComponents());
return CConfigSchemaHelper::getInstance()->getSchemaMapManager()->getComponent(idx);
}
void* getComponentInstance(int idx, void *pData)
{
assert(pData != NULL);
assert(((static_cast<CElement*>(pData))->getNodeType()) == XSD_ELEMENT);
CElement *pElement = static_cast<CElement*>(pData);
CElementArray *pElementArray = static_cast<CElementArray*>(pElement->getParentNode());
if (pElementArray->length() >= idx)
idx = 0;
return &(pElementArray->item(idx));
}
const char* getComponentNameInConfiguration(int idx, void *pData)
{
if (pData == NULL)
return CConfigSchemaHelper::getInstance()->getSchemaMapManager()->getComponent(idx)->getName();
assert(!"Invalid component index");
return NULL;
}
const void* getPointerToComponentInConfiguration(int idx, void *pData, int compIdx)
{
if (pData == NULL)
{
const CElement *pElement = CConfigSchemaHelper::getInstance()->getSchemaMapManager()->getComponent(idx);
assert(pElement != NULL);
const CXSDNodeBase *pNodeBase = pElement->getConstParentNode();
const CElementArray *pElementArray = dynamic_cast<const CElementArray*>(pNodeBase);
assert(pElementArray != NULL);
return pElementArray;
}
else
{
assert( compIdx >= 0);
CElementArray *pElementArray = static_cast<CElementArray*>(pData);
assert(pElementArray->getNodeType() == XSD_ELEMENT_ARRAY);
const CXSDNodeBase *pNodeBase = &(pElementArray->item(compIdx+idx));
return(dynamic_cast<const CElement*>(pNodeBase));
}
}
const void* getPointerToComponentTypeInConfiguration(void *pData)
{
assert (pData != NULL);
CElement *pElement = static_cast<CElement*>(pData);
assert (pElement->getNodeType() == XSD_ELEMENT);
CElementArray *pElementArray = static_cast<CElementArray*>(pElement->getParentNode());
return &(pElementArray->item(0));
}
int getIndexOfParent(void *pData)
{
assert (pData != NULL);
assert((static_cast<CElement*>(pData))->getNodeType() == XSD_ELEMENT);
int nIndexOfParent = CConfigSchemaHelper::getInstance()->getSchemaMapManager()->getIndexOfElement(static_cast<CElement*>(pData));
assert(nIndexOfParent >= 0);
return nIndexOfParent;
}
const void* getPointerToComponents()
{
assert(CConfigSchemaHelper::getInstance()->getSchemaMapManager()->getComponent(0)->getConstParentNode()->getNodeType() == XSD_ELEMENT_ARRAY);
return (CConfigSchemaHelper::getInstance()->getSchemaMapManager()->getComponent(0)->getConstParentNode());
}
int getNumberOfChildren(void *pData)
{
int nRetVal = 0;
if (pData == NULL)
{
assert(!"Should not be null"); // why ever null?
return 0;
}
if (pData == (void*)(CEnvironmentModel::getInstance()))
nRetVal = (static_cast<CEnvironmentModel*>(pData))->getNumberOfRootNodes();
else // must be of type CEnvironmentModelNode*
{
CEnvironmentModelNode *pNode = static_cast<CEnvironmentModelNode*>(pData);
nRetVal = pNode->getNumberOfChildren();
}
return nRetVal;
}
const char* getData(void *pData)
{
if (pData == NULL)
return NULL;
return CEnvironmentModel::getInstance()->getData(static_cast<CEnvironmentModelNode*>(pData));
}
const char* getName(void *pData)
{
if (pData == NULL)
return NULL;
return CEnvironmentModel::getInstance()->getInstanceName(static_cast<CEnvironmentModelNode*>(pData));
}
const char* getFileName(void *pData)
{
if (pData == NULL)
return NULL;
return CEnvironmentModel::getInstance()->getXSDFileName(static_cast<CEnvironmentModelNode*>(pData));
}
void* getParent(void *pData)
{
if (pData == NULL)
return NULL;
if (pData == (void*)(CEnvironmentModel::getInstance()->getRoot()))
return (void*)(CEnvironmentModel::getInstance());
else
return (void*)(CEnvironmentModel::getInstance()->getParent(static_cast<CEnvironmentModelNode*>(pData)));
}
void* getChild(void *pData, int idx)
{
if (pData == NULL || pData == CEnvironmentModel::getInstance())
{
if (idx == 0)
return (void*)(CEnvironmentModel::getInstance()->getRoot(0));
return NULL;
}
else
return (void*)(CEnvironmentModel::getInstance()->getChild(static_cast<CEnvironmentModelNode*>(pData), idx));
}
int getIndexFromParent(void *pData)
{
CEnvironmentModelNode *pNode = static_cast<CEnvironmentModelNode*>(pData);
if (pNode->getParent() == NULL)
return 0; // Must be 'Environment' node
const CEnvironmentModelNode *pGrandParent = pNode->getParent();
int nChildren = pGrandParent->getNumberOfChildren();
for (int idx = 0; idx < nChildren; idx++)
{
if (pNode == pGrandParent->getChild(idx))
return idx;
}
assert(!"Should not reach here");
return 0;
}
void* getRootNode(int idx)
{
return (void*)(CEnvironmentModel::getInstance()->getRoot(idx));
}
void* getModel()
{
return (void*)(CEnvironmentModel::getInstance());
}
void getJSON(void *pData, char **pOutput, int nIdx)
{
CConfigSchemaHelper::getInstance()->printJSON(CONFIGURATOR_API::getFileName(pData), pOutput, nIdx, true);
}
void getNavigatorJSON(char **pOutput)
{
CConfigSchemaHelper::getInstance()->printNavigatorJSON(pOutput, true);
}
void getJSONByComponentName(const char *pComponentName, char **pOutput, int nIdx)
{
CConfigSchemaHelper::getInstance()->printJSON(pComponentName, pOutput, nIdx, true);
}
void getJSONByComponentKey(const char *pKey, char **pOutput)
{
CConfigSchemaHelper::getInstance()->printJSONByKey(pKey, pOutput, true);
}
void getDocBookByIndex(int idx, char **pOutput)
{
const char *pFileName = CBuildSetManager::getInstance()->getBuildSetComponentFileName(idx);
CConfigSchemaHelper::getInstance()->printDocumentation(pFileName, pOutput);
}
bool saveConfigurationFile()
{
return CConfigSchemaHelper::getInstance()->saveConfigurationFile();
}
bool saveConfigurationFileAs(const char *pFilePath)
{
if (pFilePath == NULL || *pFilePath == 0)
return false;
return CConfigSchemaHelper::getInstance()->saveConfigurationFileAs(pFilePath);
}
int getNumberOfNotificationTypes()
{
return CNotificationManager::getInstance()->getNumberOfNotificationTypes();
}
const char* getNotificationTypeName(int type)
{
return CNotificationManager::getInstance()->getNotificationTypeName(type);
}
int getNumberOfNotifications(int type)
{
enum ENotificationType eType = static_cast<ENotificationType>(type);
return CNotificationManager::getInstance()->getNumberOfNotifications(eType);
}
const char* getNotification(int type, int idx)
{
const char *pRet = NULL;
enum ENotificationType eType = static_cast<ENotificationType>(type);
return CNotificationManager::getInstance()->getNotification(eType, idx);
}
} // CONFIGURATOR_API namespace
| 28.738899
| 145
| 0.686836
|
miguelvazq
|
730936d3234a022b9673db4e23201cfbe3c65bc1
| 825
|
cpp
|
C++
|
boboleetcode/Play-Leetcode-master/0049-Group-Anagrams/cpp-0049/main.cpp
|
yaominzh/CodeLrn2019
|
adc727d92904c5c5d445a2621813dfa99474206d
|
[
"Apache-2.0"
] | 2
|
2021-03-25T05:26:55.000Z
|
2021-04-20T03:33:24.000Z
|
boboleetcode/Play-Leetcode-master/0049-Group-Anagrams/cpp-0049/main.cpp
|
mcuallen/CodeLrn2019
|
adc727d92904c5c5d445a2621813dfa99474206d
|
[
"Apache-2.0"
] | 6
|
2019-12-04T06:08:32.000Z
|
2021-05-10T20:22:47.000Z
|
boboleetcode/Play-Leetcode-master/0049-Group-Anagrams/cpp-0049/main.cpp
|
mcuallen/CodeLrn2019
|
adc727d92904c5c5d445a2621813dfa99474206d
|
[
"Apache-2.0"
] | null | null | null |
/// Source : https://leetcode.com/problems/group-anagrams/description/
/// Author : liuyubobobo
/// Time : 2018-09-12
#include <iostream>
#include <vector>
#include <unordered_map>
using namespace std;
/// Using HashMap
/// Using sorted string as key
///
/// Time Complexity: O(n*klogk) where k is the max length of string in strs
/// Space Complexity: O(n*k)
class Solution {
public:
vector<vector<string>> groupAnagrams(vector<string>& strs) {
unordered_map<string, vector<string>> map;
for(const string& s: strs){
string key = s;
sort(key.begin(), key.end());
map[key].push_back(s);
}
vector<vector<string>> res;
for(const auto& p: map)
res.push_back(p.second);
return res;
}
};
int main() {
return 0;
}
| 21.153846
| 75
| 0.602424
|
yaominzh
|
7309ce25360b55138689d7ff062ad57fabf0a112
| 12,697
|
cc
|
C++
|
chrome/browser/supervised_user/supervised_user_allowlist_service.cc
|
mghgroup/Glide-Browser
|
6a4c1eaa6632ec55014fee87781c6bbbb92a2af5
|
[
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | null | null | null |
chrome/browser/supervised_user/supervised_user_allowlist_service.cc
|
mghgroup/Glide-Browser
|
6a4c1eaa6632ec55014fee87781c6bbbb92a2af5
|
[
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | null | null | null |
chrome/browser/supervised_user/supervised_user_allowlist_service.cc
|
mghgroup/Glide-Browser
|
6a4c1eaa6632ec55014fee87781c6bbbb92a2af5
|
[
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | 2
|
2021-01-05T23:43:46.000Z
|
2021-01-07T23:36:34.000Z
|
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/supervised_user/supervised_user_allowlist_service.h"
#include <stddef.h>
#include <string>
#include <utility>
#include "base/bind.h"
#include "base/command_line.h"
#include "base/files/file_path.h"
#include "base/metrics/histogram_macros.h"
#include "base/metrics/user_metrics.h"
#include "base/metrics/user_metrics_action.h"
#include "base/strings/string_split.h"
#include "base/values.h"
#include "chrome/browser/component_updater/supervised_user_whitelist_installer.h"
#include "chrome/browser/supervised_user/supervised_user_site_list.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/pref_names.h"
#include "components/pref_registry/pref_registry_syncable.h"
#include "components/prefs/pref_service.h"
#include "components/prefs/scoped_user_pref_update.h"
#include "components/sync/model/sync_change.h"
#include "components/sync/model/sync_change_processor.h"
#include "components/sync/model/sync_data.h"
#include "components/sync/model/sync_error.h"
#include "components/sync/model/sync_error_factory.h"
#include "components/sync/protocol/sync.pb.h"
const char kName[] = "name";
SupervisedUserAllowlistService::SupervisedUserAllowlistService(
PrefService* prefs,
component_updater::SupervisedUserWhitelistInstaller* installer,
const std::string& client_id)
: prefs_(prefs), installer_(installer), client_id_(client_id) {
DCHECK(prefs);
}
SupervisedUserAllowlistService::~SupervisedUserAllowlistService() {}
// static
void SupervisedUserAllowlistService::RegisterProfilePrefs(
user_prefs::PrefRegistrySyncable* registry) {
registry->RegisterDictionaryPref(prefs::kSupervisedUserAllowlists);
}
void SupervisedUserAllowlistService::Init() {
const base::DictionaryValue* allowlists =
prefs_->GetDictionary(prefs::kSupervisedUserAllowlists);
for (base::DictionaryValue::Iterator it(*allowlists); !it.IsAtEnd();
it.Advance()) {
registered_allowlists_.insert(it.key());
}
UMA_HISTOGRAM_COUNTS_100("ManagedUsers.Whitelist.Count", allowlists->size());
// The installer can be null in some unit tests.
if (!installer_)
return;
installer_->Subscribe(
base::BindRepeating(&SupervisedUserAllowlistService::OnAllowlistReady,
weak_ptr_factory_.GetWeakPtr()));
// Register allowlists specified on the command line.
for (const auto& allowlist : GetAllowlistsFromCommandLine())
RegisterAllowlist(allowlist.first, allowlist.second, FROM_COMMAND_LINE);
}
void SupervisedUserAllowlistService::AddSiteListsChangedCallback(
const SiteListsChangedCallback& callback) {
site_lists_changed_callbacks_.push_back(callback);
std::vector<scoped_refptr<SupervisedUserSiteList>> allowlists;
GetLoadedAllowlists(&allowlists);
callback.Run(allowlists);
}
// static
std::map<std::string, std::string>
SupervisedUserAllowlistService::GetAllowlistsFromCommandLine() {
std::map<std::string, std::string> allowlists;
const base::CommandLine* command_line =
base::CommandLine::ForCurrentProcess();
std::string command_line_allowlists = command_line->GetSwitchValueASCII(
switches::kInstallSupervisedUserAllowlists);
std::vector<base::StringPiece> string_pieces =
base::SplitStringPiece(command_line_allowlists, ",",
base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL);
for (const base::StringPiece& allowlist : string_pieces) {
std::string id;
std::string name;
size_t separator = allowlist.find(':');
if (separator != base::StringPiece::npos) {
id = std::string(allowlist.substr(0, separator));
name = std::string(allowlist.substr(separator + 1));
} else {
id = std::string(allowlist);
}
const bool result = allowlists.insert(std::make_pair(id, name)).second;
DCHECK(result);
}
return allowlists;
}
void SupervisedUserAllowlistService::LoadAllowlistForTesting(
const std::string& id,
const base::string16& title,
const base::FilePath& path) {
bool result = registered_allowlists_.insert(id).second;
DCHECK(result);
OnAllowlistReady(id, title, base::FilePath(), path);
}
void SupervisedUserAllowlistService::UnloadAllowlist(const std::string& id) {
bool result = registered_allowlists_.erase(id) > 0u;
DCHECK(result);
loaded_allowlists_.erase(id);
NotifyAllowlistsChanged();
}
// static
syncer::SyncData SupervisedUserAllowlistService::CreateAllowlistSyncData(
const std::string& id,
const std::string& name) {
sync_pb::EntitySpecifics specifics;
sync_pb::ManagedUserWhitelistSpecifics* allowlist =
specifics.mutable_managed_user_whitelist();
allowlist->set_id(id);
allowlist->set_name(name);
return syncer::SyncData::CreateLocalData(id, name, specifics);
}
void SupervisedUserAllowlistService::WaitUntilReadyToSync(
base::OnceClosure done) {
// This service handles sync events at any time.
std::move(done).Run();
}
base::Optional<syncer::ModelError>
SupervisedUserAllowlistService::MergeDataAndStartSyncing(
syncer::ModelType type,
const syncer::SyncDataList& initial_sync_data,
std::unique_ptr<syncer::SyncChangeProcessor> sync_processor,
std::unique_ptr<syncer::SyncErrorFactory> error_handler) {
DCHECK_EQ(syncer::SUPERVISED_USER_ALLOWLISTS, type);
syncer::SyncChangeList change_list;
DictionaryPrefUpdate update(prefs_, prefs::kSupervisedUserAllowlists);
base::DictionaryValue* pref_dict = update.Get();
std::set<std::string> seen_ids;
for (const syncer::SyncData& sync_data : initial_sync_data) {
DCHECK_EQ(syncer::SUPERVISED_USER_ALLOWLISTS, sync_data.GetDataType());
const sync_pb::ManagedUserWhitelistSpecifics& allowlist =
sync_data.GetSpecifics().managed_user_whitelist();
std::string id = allowlist.id();
std::string name = allowlist.name();
seen_ids.insert(id);
base::DictionaryValue* dict = nullptr;
if (pref_dict->GetDictionary(id, &dict)) {
std::string old_name;
bool result = dict->GetString(kName, &old_name);
DCHECK(result);
if (name != old_name) {
SetAllowlistProperties(dict, allowlist);
}
} else {
AddNewAllowlist(pref_dict, allowlist);
}
}
std::set<std::string> ids_to_remove;
for (base::DictionaryValue::Iterator it(*pref_dict); !it.IsAtEnd();
it.Advance()) {
if (seen_ids.find(it.key()) == seen_ids.end())
ids_to_remove.insert(it.key());
}
for (const std::string& id : ids_to_remove)
RemoveAllowlist(pref_dict, id);
// Notify if allowlists have been uninstalled. We will notify about newly
// added allowlists later, when they are actually available
// (in OnAllowlistLoaded).
if (!ids_to_remove.empty())
NotifyAllowlistsChanged();
// The function does not generate any errors, so it can always return
// base::nullopt.
return base::nullopt;
}
void SupervisedUserAllowlistService::StopSyncing(syncer::ModelType type) {
DCHECK_EQ(syncer::SUPERVISED_USER_ALLOWLISTS, type);
}
syncer::SyncDataList SupervisedUserAllowlistService::GetAllSyncDataForTesting(
syncer::ModelType type) const {
syncer::SyncDataList sync_data;
const base::DictionaryValue* allowlists =
prefs_->GetDictionary(prefs::kSupervisedUserAllowlists);
for (base::DictionaryValue::Iterator it(*allowlists); !it.IsAtEnd();
it.Advance()) {
const std::string& id = it.key();
const base::DictionaryValue* dict = nullptr;
it.value().GetAsDictionary(&dict);
std::string name;
bool result = dict->GetString(kName, &name);
DCHECK(result);
sync_pb::EntitySpecifics specifics;
sync_pb::ManagedUserWhitelistSpecifics* allowlist =
specifics.mutable_managed_user_whitelist();
allowlist->set_id(id);
allowlist->set_name(name);
sync_data.push_back(syncer::SyncData::CreateLocalData(id, name, specifics));
}
return sync_data;
}
base::Optional<syncer::ModelError>
SupervisedUserAllowlistService::ProcessSyncChanges(
const base::Location& from_here,
const syncer::SyncChangeList& change_list) {
bool allowlists_removed = false;
DictionaryPrefUpdate update(prefs_, prefs::kSupervisedUserAllowlists);
base::DictionaryValue* pref_dict = update.Get();
for (const syncer::SyncChange& sync_change : change_list) {
syncer::SyncData data = sync_change.sync_data();
DCHECK_EQ(syncer::SUPERVISED_USER_ALLOWLISTS, data.GetDataType());
const sync_pb::ManagedUserWhitelistSpecifics& allowlist =
data.GetSpecifics().managed_user_whitelist();
std::string id = allowlist.id();
switch (sync_change.change_type()) {
case syncer::SyncChange::ACTION_ADD: {
DCHECK(!pref_dict->HasKey(id)) << id;
AddNewAllowlist(pref_dict, allowlist);
break;
}
case syncer::SyncChange::ACTION_UPDATE: {
base::DictionaryValue* dict = nullptr;
pref_dict->GetDictionaryWithoutPathExpansion(id, &dict);
SetAllowlistProperties(dict, allowlist);
break;
}
case syncer::SyncChange::ACTION_DELETE: {
DCHECK(pref_dict->HasKey(id)) << id;
RemoveAllowlist(pref_dict, id);
allowlists_removed = true;
break;
}
case syncer::SyncChange::ACTION_INVALID: {
NOTREACHED();
break;
}
}
}
if (allowlists_removed)
NotifyAllowlistsChanged();
return base::nullopt;
}
void SupervisedUserAllowlistService::AddNewAllowlist(
base::DictionaryValue* pref_dict,
const sync_pb::ManagedUserWhitelistSpecifics& allowlist) {
base::RecordAction(base::UserMetricsAction("ManagedUsers_Whitelist_Added"));
RegisterAllowlist(allowlist.id(), allowlist.name(), FROM_SYNC);
std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue);
SetAllowlistProperties(dict.get(), allowlist);
pref_dict->SetWithoutPathExpansion(allowlist.id(), std::move(dict));
}
void SupervisedUserAllowlistService::SetAllowlistProperties(
base::DictionaryValue* dict,
const sync_pb::ManagedUserWhitelistSpecifics& allowlist) {
dict->SetString(kName, allowlist.name());
}
void SupervisedUserAllowlistService::RemoveAllowlist(
base::DictionaryValue* pref_dict,
const std::string& id) {
base::RecordAction(base::UserMetricsAction("ManagedUsers_Whitelist_Removed"));
pref_dict->RemoveKey(id);
installer_->UnregisterWhitelist(client_id_, id);
UnloadAllowlist(id);
}
void SupervisedUserAllowlistService::RegisterAllowlist(const std::string& id,
const std::string& name,
AllowlistSource source) {
bool result = registered_allowlists_.insert(id).second;
DCHECK(result);
// Using an empty client ID for allowlists installed from the command line
// causes the installer to not persist the installation, so the allowlist will
// be removed the next time the browser is started without the command line
// flag.
installer_->RegisterWhitelist(
source == FROM_COMMAND_LINE ? std::string() : client_id_, id, name);
}
void SupervisedUserAllowlistService::GetLoadedAllowlists(
std::vector<scoped_refptr<SupervisedUserSiteList>>* allowlists) {
for (const auto& allowlist : loaded_allowlists_)
allowlists->push_back(allowlist.second);
}
void SupervisedUserAllowlistService::NotifyAllowlistsChanged() {
std::vector<scoped_refptr<SupervisedUserSiteList>> allowlists;
GetLoadedAllowlists(&allowlists);
for (const auto& callback : site_lists_changed_callbacks_)
callback.Run(allowlists);
}
void SupervisedUserAllowlistService::OnAllowlistReady(
const std::string& id,
const base::string16& title,
const base::FilePath& large_icon_path,
const base::FilePath& allowlist_path) {
// If we did not register the allowlist or it has been unregistered in the
// mean time, ignore it.
if (registered_allowlists_.count(id) == 0u)
return;
SupervisedUserSiteList::Load(
id, title, large_icon_path, allowlist_path,
base::Bind(&SupervisedUserAllowlistService::OnAllowlistLoaded,
weak_ptr_factory_.GetWeakPtr(), id));
}
void SupervisedUserAllowlistService::OnAllowlistLoaded(
const std::string& id,
const scoped_refptr<SupervisedUserSiteList>& allowlist) {
if (!allowlist) {
LOG(WARNING) << "Couldn't load allowlist " << id;
return;
}
// If the allowlist has been unregistered in the mean time, ignore it.
if (registered_allowlists_.count(id) == 0u)
return;
loaded_allowlists_[id] = allowlist;
NotifyAllowlistsChanged();
}
| 35.46648
| 81
| 0.731905
|
mghgroup
|
730b8769492185a73f22cde33327c597fc04b050
| 9,850
|
cc
|
C++
|
mysql-server/router/src/harness/src/dynamic_state.cc
|
silenc3502/MYSQL-Arch-Doc-Summary
|
fcc6bb65f72a385b9f56debc9b2c00cee5914bae
|
[
"MIT"
] | null | null | null |
mysql-server/router/src/harness/src/dynamic_state.cc
|
silenc3502/MYSQL-Arch-Doc-Summary
|
fcc6bb65f72a385b9f56debc9b2c00cee5914bae
|
[
"MIT"
] | null | null | null |
mysql-server/router/src/harness/src/dynamic_state.cc
|
silenc3502/MYSQL-Arch-Doc-Summary
|
fcc6bb65f72a385b9f56debc9b2c00cee5914bae
|
[
"MIT"
] | null | null | null |
/*
Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
as published by the Free Software Foundation.
This program is also distributed with certain software (including
but not limited to OpenSSL) that is licensed under separate terms,
as designated in a particular file or component or in included license
documentation. The authors of MySQL hereby grant you an additional
permission to link the program and your derivative works with the
separately licensed software that they have included with MySQL.
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 St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "mysql/harness/dynamic_state.h"
#include "common.h"
#include <fstream>
#include <stdexcept>
#include <rapidjson/error/en.h>
#include <rapidjson/filereadstream.h>
#include <rapidjson/istreamwrapper.h>
#include <rapidjson/prettywriter.h>
#include <rapidjson/schema.h>
#include <rapidjson/stringbuffer.h>
#include "dynamic_state_schema.h"
namespace {
using JsonValue =
rapidjson::GenericValue<rapidjson::UTF8<>, rapidjson::CrtAllocator>;
using JsonDocument =
rapidjson::GenericDocument<rapidjson::UTF8<>, rapidjson::CrtAllocator>;
using JsonStringBuffer =
rapidjson::GenericStringBuffer<rapidjson::UTF8<>, rapidjson::CrtAllocator>;
using JsonSchemaDocument =
rapidjson::GenericSchemaDocument<JsonValue, rapidjson::CrtAllocator>;
using JsonSchemaValidator =
rapidjson::GenericSchemaValidator<JsonSchemaDocument>;
constexpr const char *kVersionFieldName = "version";
constexpr unsigned kVersionMajor = 1;
constexpr unsigned kVersionMinor = 0;
constexpr unsigned kVersionPatch = 0;
std::string to_string(unsigned major, unsigned minor, unsigned patch) {
return std::to_string(major) + "." + std::to_string(minor) + "." +
std::to_string(patch);
}
} // namespace
namespace mysql_harness {
struct DynamicState::Pimpl {
JsonDocument json_state_doc_;
std::mutex json_state_doc_lock_;
std::mutex json_file_lock_;
/*static*/
void validate_json_against_schema(const JsonSchemaDocument &schema,
const JsonDocument &json) {
// verify JSON against the schema
JsonSchemaValidator validator(schema);
if (!json.Accept(validator)) {
// validation failed - throw an error with info of where the problem is
rapidjson::StringBuffer sb_schema;
validator.GetInvalidSchemaPointer().StringifyUriFragment(sb_schema);
rapidjson::StringBuffer sb_json;
validator.GetInvalidDocumentPointer().StringifyUriFragment(sb_json);
throw std::runtime_error(
std::string("Failed schema directive: ") + sb_schema.GetString() +
"\nFailed schema keyword: " + validator.GetInvalidSchemaKeyword() +
"\nFailure location in validated document: " + sb_json.GetString() +
"\n");
}
}
};
DynamicState::DynamicState(const std::string &file_name)
: file_name_(file_name) {
pimpl_.reset(new Pimpl());
pimpl_->json_state_doc_.SetObject();
}
DynamicState::~DynamicState() {}
std::ifstream DynamicState::open_for_read() {
std::ifstream input_file(file_name_);
if (input_file.fail()) {
throw std::runtime_error(
"Could not open dynamic state file '" + file_name_ +
"' for reading: " + mysql_harness::get_strerror(errno));
}
return input_file;
}
std::ofstream DynamicState::open_for_write() {
std::ofstream output_file(file_name_);
if (output_file.fail()) {
throw std::runtime_error(
"Could not open dynamic state file '" + file_name_ +
"' for writing: " + mysql_harness::get_strerror(errno));
}
return output_file;
}
bool DynamicState::load() {
std::unique_lock<std::mutex> lock(pimpl_->json_file_lock_);
bool result{false};
auto input_file = open_for_read();
try {
result = load_from_stream(input_file);
} catch (const std::runtime_error &e) {
throw std::runtime_error("Error parsing file dynamic state file '" +
file_name_ + "': " + e.what());
}
return result;
}
void DynamicState::ensure_valid_against_schema() {
// construct schema JSON; throws std::runtime_error on invalid JSON, but note
JsonDocument schema_json;
if (schema_json
.Parse<rapidjson::kParseCommentsFlag>(StateFileJsonSchema::data(),
StateFileJsonSchema::size())
.HasParseError())
throw std::runtime_error(
"Parsing JSON schema failed at offset " +
std::to_string(schema_json.GetErrorOffset()) + ": " +
rapidjson::GetParseError_En(schema_json.GetParseError()));
JsonSchemaDocument schema(schema_json);
// validate JSON against schema; throws std::runtime_error if validation fails
try {
pimpl_->validate_json_against_schema(schema, pimpl_->json_state_doc_);
} catch (const std::runtime_error &e) {
throw std::runtime_error(
std::string("JSON file failed validation against JSON schema: ") +
e.what());
}
}
void DynamicState::ensure_version_compatibility() {
// we do it before validating against the schema so we need to
// do some initial parsing manually here
auto &json_doc = pimpl_->json_state_doc_;
// the whole document has to be an object:
if (!json_doc.IsObject()) {
throw std::runtime_error(
std::string("Invalid json structure: not an object"));
}
// it has to have version field
if (!json_doc.GetObject().HasMember(kVersionFieldName)) {
throw std::runtime_error(
std::string("Invalid json structure: missing field: ") +
kVersionFieldName);
}
// this field should be string
auto &version_field = json_doc.GetObject()[kVersionFieldName];
if (!version_field.IsString()) {
throw std::runtime_error(std::string("Invalid json structure: field ") +
kVersionFieldName + " should be a string type");
}
// the format od the string should be MAJOR.MINOR.PATCH
std::string version = version_field.GetString();
unsigned major{0}, minor{0}, patch{0};
int res = sscanf(version.c_str(), "%u.%u.%u", &major, &minor, &patch);
if (res != 3) {
throw std::runtime_error(
std::string("Invalid version field format, expected MAJOR.MINOR.PATCH, "
"found: ") +
version);
}
// the major and minor should match match exactly, different patch is fine
if (major != kVersionMajor || minor != kVersionMinor) {
throw std::runtime_error(
std::string("Unsupported state file version, expected: ") +
to_string(kVersionMajor, kVersionMinor, kVersionPatch) +
", found: " + to_string(major, minor, patch));
}
// all good, version matches, go back to the caller with no exception
}
bool DynamicState::load_from_stream(std::istream &input_stream) {
rapidjson::IStreamWrapper istream(input_stream);
auto &json_doc = pimpl_->json_state_doc_;
std::unique_lock<std::mutex> lock(pimpl_->json_state_doc_lock_);
if (json_doc.ParseStream<rapidjson::kParseCommentsFlag>(istream)
.HasParseError()) {
throw std::runtime_error(
"Parsing JSON failed at offset " +
std::to_string(json_doc.GetErrorOffset()) + ": " +
rapidjson::GetParseError_En(json_doc.GetParseError()));
}
ensure_version_compatibility();
ensure_valid_against_schema();
return true;
}
bool DynamicState::save(bool pretty) {
std::unique_lock<std::mutex> lock(pimpl_->json_file_lock_);
auto output_file = open_for_write();
return save_to_stream(output_file, pretty);
}
bool DynamicState::save_to_stream(std::ostream &output_stream, bool pretty) {
JsonStringBuffer out_buffer;
// save/update the version
std::string ver_str = to_string(kVersionMajor, kVersionMinor, kVersionPatch);
JsonValue version(rapidjson::kStringType);
version.SetString(ver_str.c_str(), ver_str.length());
update_section(kVersionFieldName, std::move(version));
std::unique_lock<std::mutex> lock(pimpl_->json_state_doc_lock_);
if (pretty) {
rapidjson::PrettyWriter<JsonStringBuffer> out_writer{out_buffer};
pimpl_->json_state_doc_.Accept(out_writer);
} else {
rapidjson::Writer<JsonStringBuffer> out_writer{out_buffer};
pimpl_->json_state_doc_.Accept(out_writer);
}
output_stream << out_buffer.GetString();
return true;
}
std::unique_ptr<JsonValue> DynamicState::get_section(
const std::string §ion_name) {
std::unique_lock<std::mutex> lock(pimpl_->json_state_doc_lock_);
auto &json_doc = pimpl_->json_state_doc_;
if (!json_doc.HasMember(section_name.c_str())) return nullptr;
auto &allocator = json_doc.GetAllocator();
auto §ion = json_doc[section_name.c_str()];
return std::unique_ptr<JsonValue>(new JsonValue(section, allocator));
}
bool DynamicState::update_section(const std::string §ion_name,
JsonValue &&value) {
std::unique_lock<std::mutex> lock(pimpl_->json_state_doc_lock_);
auto &json_doc = pimpl_->json_state_doc_;
auto &allocator = json_doc.GetAllocator();
if (!json_doc.HasMember(section_name.c_str())) {
json_doc.AddMember(JsonValue(section_name.c_str(), allocator), value,
allocator);
} else {
auto §ion = json_doc[section_name.c_str()];
section = std::move(value);
}
return true;
}
} // namespace mysql_harness
| 34.083045
| 80
| 0.705584
|
silenc3502
|
730d1de7aafbb60918da55773730ef103c3a237f
| 6,509
|
cc
|
C++
|
chrome/browser/extensions/api/system_private/system_private_api.cc
|
metux/chromium-deb
|
3c08e9b89a1b6f95f103a61ff4f528dbcd57fc42
|
[
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | null | null | null |
chrome/browser/extensions/api/system_private/system_private_api.cc
|
metux/chromium-deb
|
3c08e9b89a1b6f95f103a61ff4f528dbcd57fc42
|
[
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | null | null | null |
chrome/browser/extensions/api/system_private/system_private_api.cc
|
metux/chromium-deb
|
3c08e9b89a1b6f95f103a61ff4f528dbcd57fc42
|
[
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | null | null | null |
// Copyright (c) 2012 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 "chrome/browser/extensions/api/system_private/system_private_api.h"
#include <memory>
#include <utility>
#include "base/macros.h"
#include "base/memory/ptr_util.h"
#include "base/values.h"
#include "build/build_config.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/extensions/event_router_forwarder.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/common/extensions/api/system_private.h"
#include "chrome/common/pref_names.h"
#include "components/prefs/pref_service.h"
#include "google_apis/google_api_keys.h"
#if defined(OS_CHROMEOS)
#include "chromeos/dbus/dbus_thread_manager.h"
#include "chromeos/dbus/update_engine_client.h"
#else
#include "chrome/browser/upgrade_detector.h"
#endif
namespace {
// Maps prefs::kIncognitoModeAvailability values (0 = enabled, ...)
// to strings exposed to extensions.
const char* const kIncognitoModeAvailabilityStrings[] = {
"enabled",
"disabled",
"forced"
};
// Property keys.
const char kBrightnessKey[] = "brightness";
const char kDownloadProgressKey[] = "downloadProgress";
const char kIsVolumeMutedKey[] = "isVolumeMuted";
const char kStateKey[] = "state";
const char kUserInitiatedKey[] = "userInitiated";
const char kVolumeKey[] = "volume";
// System update states.
const char kNotAvailableState[] = "NotAvailable";
const char kNeedRestartState[] = "NeedRestart";
#if defined(OS_CHROMEOS)
const char kUpdatingState[] = "Updating";
#endif // defined(OS_CHROMEOS)
// Dispatches an extension event with |argument|
void DispatchEvent(extensions::events::HistogramValue histogram_value,
const std::string& event_name,
std::unique_ptr<base::Value> argument) {
std::unique_ptr<base::ListValue> list_args(new base::ListValue());
if (argument) {
list_args->Append(std::move(argument));
}
g_browser_process->extension_event_router_forwarder()
->BroadcastEventToRenderers(histogram_value, event_name,
std::move(list_args), GURL());
}
} // namespace
namespace extensions {
namespace system_private = api::system_private;
ExtensionFunction::ResponseAction
SystemPrivateGetIncognitoModeAvailabilityFunction::Run() {
PrefService* prefs =
Profile::FromBrowserContext(browser_context())->GetPrefs();
int value = prefs->GetInteger(prefs::kIncognitoModeAvailability);
EXTENSION_FUNCTION_VALIDATE(
value >= 0 &&
value < static_cast<int>(arraysize(kIncognitoModeAvailabilityStrings)));
return RespondNow(OneArgument(
base::MakeUnique<base::Value>(kIncognitoModeAvailabilityStrings[value])));
}
ExtensionFunction::ResponseAction SystemPrivateGetUpdateStatusFunction::Run() {
std::string state;
double download_progress = 0;
#if defined(OS_CHROMEOS)
// With UpdateEngineClient, we can provide more detailed information about
// system updates on ChromeOS.
const chromeos::UpdateEngineClient::Status status =
chromeos::DBusThreadManager::Get()->GetUpdateEngineClient()->
GetLastStatus();
// |download_progress| is set to 1 after download finishes
// (i.e. verify, finalize and need-reboot phase) to indicate the progress
// even though |status.download_progress| is 0 in these phases.
switch (status.status) {
case chromeos::UpdateEngineClient::UPDATE_STATUS_ERROR:
state = kNotAvailableState;
break;
case chromeos::UpdateEngineClient::UPDATE_STATUS_IDLE:
state = kNotAvailableState;
break;
case chromeos::UpdateEngineClient::UPDATE_STATUS_CHECKING_FOR_UPDATE:
state = kNotAvailableState;
break;
case chromeos::UpdateEngineClient::UPDATE_STATUS_UPDATE_AVAILABLE:
state = kUpdatingState;
break;
case chromeos::UpdateEngineClient::UPDATE_STATUS_DOWNLOADING:
state = kUpdatingState;
download_progress = status.download_progress;
break;
case chromeos::UpdateEngineClient::UPDATE_STATUS_VERIFYING:
state = kUpdatingState;
download_progress = 1;
break;
case chromeos::UpdateEngineClient::UPDATE_STATUS_FINALIZING:
state = kUpdatingState;
download_progress = 1;
break;
case chromeos::UpdateEngineClient::UPDATE_STATUS_UPDATED_NEED_REBOOT:
state = kNeedRestartState;
download_progress = 1;
break;
case chromeos::UpdateEngineClient::UPDATE_STATUS_REPORTING_ERROR_EVENT:
case chromeos::UpdateEngineClient::UPDATE_STATUS_ATTEMPTING_ROLLBACK:
case chromeos::UpdateEngineClient::UPDATE_STATUS_NEED_PERMISSION_TO_UPDATE:
state = kNotAvailableState;
break;
}
#else
if (UpgradeDetector::GetInstance()->notify_upgrade()) {
state = kNeedRestartState;
download_progress = 1;
} else {
state = kNotAvailableState;
}
#endif
std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue());
dict->SetString(kStateKey, state);
dict->SetDouble(kDownloadProgressKey, download_progress);
return RespondNow(OneArgument(std::move(dict)));
}
ExtensionFunction::ResponseAction SystemPrivateGetApiKeyFunction::Run() {
return RespondNow(
OneArgument(base::MakeUnique<base::Value>(google_apis::GetAPIKey())));
}
void DispatchVolumeChangedEvent(double volume, bool is_volume_muted) {
std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue());
dict->SetDouble(kVolumeKey, volume);
dict->SetBoolean(kIsVolumeMutedKey, is_volume_muted);
DispatchEvent(extensions::events::SYSTEM_PRIVATE_ON_VOLUME_CHANGED,
system_private::OnVolumeChanged::kEventName, std::move(dict));
}
void DispatchBrightnessChangedEvent(int brightness, bool user_initiated) {
std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue());
dict->SetInteger(kBrightnessKey, brightness);
dict->SetBoolean(kUserInitiatedKey, user_initiated);
DispatchEvent(extensions::events::SYSTEM_PRIVATE_ON_BRIGHTNESS_CHANGED,
system_private::OnBrightnessChanged::kEventName,
std::move(dict));
}
void DispatchScreenUnlockedEvent() {
DispatchEvent(extensions::events::SYSTEM_PRIVATE_ON_SCREEN_UNLOCKED,
system_private::OnScreenUnlocked::kEventName, nullptr);
}
void DispatchWokeUpEvent() {
DispatchEvent(extensions::events::SYSTEM_PRIVATE_ON_WOKE_UP,
system_private::OnWokeUp::kEventName, nullptr);
}
} // namespace extensions
| 35.961326
| 80
| 0.746966
|
metux
|
730d607de955483bb14616630794aef81674435d
| 2,583
|
cpp
|
C++
|
client/winapplication.cpp
|
flaming0/software-renderer
|
dfeb24eb4ac6f90552e65cc7e0cf97d7d693ad7b
|
[
"MIT"
] | 14
|
2015-03-22T16:18:32.000Z
|
2017-08-08T14:07:44.000Z
|
client/winapplication.cpp
|
nslobodin/software-renderer
|
dfeb24eb4ac6f90552e65cc7e0cf97d7d693ad7b
|
[
"MIT"
] | null | null | null |
client/winapplication.cpp
|
nslobodin/software-renderer
|
dfeb24eb4ac6f90552e65cc7e0cf97d7d693ad7b
|
[
"MIT"
] | 2
|
2015-08-31T03:01:57.000Z
|
2016-12-20T06:09:32.000Z
|
/*
* winapplication.cpp
*
* Author: flamingo
* E-mail: epiforce57@gmail.com
*/
#include "winapplication.h"
void WinApplication::update(float dt)
{
}
WinApplication::WinApplication(int argc, const char *argv[])
: platform::BaseAppWin(argc, argv)
{
m_playerCamera = m_clientController->getCamera();
auto rmgr = m_clientController->getResmgr();
auto rendmgr = m_clientController->getRendmgr();
// create terrain
auto heightMapTexture = rmgr->getObject<rend::Texture>("texture_water_track_height_03");
auto texture = rmgr->getObject<rend::Texture>("texture_water_track_color_03");
auto terrain = std::make_shared<rend::TerrainSceneObject>(3000.f, 3000.f, 600.f, heightMapTexture, texture);
rendmgr->addSceneObject(terrain);
// rendmgr->addGuiObject(std::make_shared<rend::GuiObject>(texture));
auto teapot = rmgr->getObject<rend::SceneObject>("teapot.obj");
if (teapot)
{
//teapot->setScale(math::vec3(50, 50, 50));
teapot->getMesh()->setShadingMode(rend::Material::SM_GOURAUD);
}
}
WinApplication::~WinApplication()
{
}
void WinApplication::onFrameStart()
{
}
void WinApplication::onFrameEnd()
{
}
void WinApplication::onMouseEvent(const platform::MouseEvent &ev)
{
static int yaw, pitch;
static int prevx, prevy;
if (ev.isLeftPressed())
{
yaw -= prevx - ev.x; // inverted
pitch -= prevy - ev.y;
if (abs(yaw) > 360) yaw %= 360;
if (abs(pitch) > 360) pitch %= 360;
m_playerCamera->setEulerAnglesRotation(yaw, pitch, 0.f);
}
prevx = ev.x;
prevy = ev.y;
}
void WinApplication::onKeyPressed(const platform::KeyboardEvent &ev)
{
static const float velocity = 100.f;
static math::vec3 ds;
static math::vec3 position;
ds.zero();
position = m_playerCamera->getPosition();
if (ev.keycode() == platform::KEY_KEY_W)
{
ds = m_playerCamera->getDirection() * velocity;
position += ds;
}
else if (ev.keycode() == platform::KEY_KEY_S)
{
ds = m_playerCamera->getDirection() * velocity;
position -= ds;
}
else if (ev.keycode() == platform::KEY_KEY_D)
{
ds = m_playerCamera->getRightVector() * velocity;
position += ds;
}
else if (ev.keycode() == platform::KEY_KEY_A)
{
ds = m_playerCamera->getRightVector() * velocity;
position -= ds;
}
else
return;
m_playerCamera->setPosition(position);
}
void WinApplication::onKeyReleased(const platform::KeyboardEvent &/*ev*/)
{
}
| 23.481818
| 112
| 0.636856
|
flaming0
|
730daedec1ae75a1acd8b2fbe243881225858d2f
| 1,333
|
cpp
|
C++
|
Common_3/ThirdParty/OpenSource/meshoptimizer/src/allocator.cpp
|
Mercesa/The-Forge
|
13d7604bde91f90188c9dcb480ea6e97f60f1645
|
[
"Apache-2.0"
] | 1
|
2021-11-16T08:35:01.000Z
|
2021-11-16T08:35:01.000Z
|
Common_3/ThirdParty/OpenSource/meshoptimizer/src/allocator.cpp
|
Mercesa/The-Forge
|
13d7604bde91f90188c9dcb480ea6e97f60f1645
|
[
"Apache-2.0"
] | null | null | null |
Common_3/ThirdParty/OpenSource/meshoptimizer/src/allocator.cpp
|
Mercesa/The-Forge
|
13d7604bde91f90188c9dcb480ea6e97f60f1645
|
[
"Apache-2.0"
] | null | null | null |
// This file is part of meshoptimizer library; see meshoptimizer.h for version/license details
#include "meshoptimizer.h"
#include "../../../../OS/Interfaces/ILog.h"
#include "../../../../ThirdParty/OpenSource/ModifiedSonyMath/vectormath_settings.hpp"
#define MEM_MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN_ALLOC_ALIGNMENT MEM_MAX(VECTORMATH_MIN_ALIGN, EA_PLATFORM_MIN_MALLOC_ALIGNMENT)
size_t buffer_length = 0;
size_t current_offset = 0;
char* buffer; //Scratch-Pad memory
void* Allocate(size_t size)
{
// make the current offset always aligned
current_offset += current_offset % MIN_ALLOC_ALIGNMENT;
if (current_offset + size <= buffer_length)
{
void* ptr = &buffer[current_offset];
current_offset += size;
return ptr;
}
LOGF(LogLevel::eWARNING, "Mesh Optimizer out of memory");
return NULL;
}
void DeAllocate(void* b)
{
current_offset = 0;
}
void meshopt_SetScratchMemory(size_t size, void* memory)
{
buffer_length = size;
buffer = (char*)memory;
meshopt_setAllocator();
}
//void meshopt_setAllocator(void* (*allocate)(size_t), void (*deallocate)(void*))
void meshopt_setAllocator()
{
//meshopt_Allocator::Storage::allocate = allocate;
//meshopt_Allocator::Storage::deallocate = deallocate;
meshopt_Allocator::Storage::allocate = Allocate;
meshopt_Allocator::Storage::deallocate = DeAllocate;
}
| 26.137255
| 94
| 0.740435
|
Mercesa
|
730e961086ae68d929f9d93fd746fb8faee658fb
| 18,430
|
cpp
|
C++
|
Classes/GameSceneEx.cpp
|
lfeng1420/BrickGame
|
e4961a7454ae1adece6845c64a6ba8ac59856d68
|
[
"MIT"
] | 39
|
2016-05-07T06:39:54.000Z
|
2021-04-13T15:00:52.000Z
|
Classes/GameSceneEx.cpp
|
lfeng1420/BrickGame
|
e4961a7454ae1adece6845c64a6ba8ac59856d68
|
[
"MIT"
] | 8
|
2016-07-17T06:39:54.000Z
|
2021-07-06T15:14:19.000Z
|
Classes/GameSceneEx.cpp
|
lfeng1420/BrickGame
|
e4961a7454ae1adece6845c64a6ba8ac59856d68
|
[
"MIT"
] | 13
|
2016-03-11T11:46:19.000Z
|
2018-08-10T16:34:33.000Z
|
#include "stdafx.h"
#include "GameSceneEx.h"
cocos2d::Scene* CGameSceneEx::CreateScene(const TGameSceneContext* pContext /*= nullptr*/)
{
auto scene = Scene::create();
auto layer = CGameSceneEx::create(pContext);
scene->addChild(layer);
scene->setTag(GAME_SCENE_TAG);
return scene;
}
cocos2d::LayerColor* CGameSceneEx::create(const TGameSceneContext* pContext /*= nullptr*/)
{
CGameSceneEx* pLayer = new CGameSceneEx();
if (pLayer == nullptr)
{
return nullptr;
}
// First step
pLayer->ImportContextFirst(pContext);
// init
if (!pLayer->init())
{
delete pLayer;
return nullptr;
}
// Last step
pLayer->ImportContextLast(pContext);
pLayer->autorelease();
return pLayer;
}
void CGameSceneEx::InitUI()
{
float fBottomY = 0;
float fTopY = 0;
float fTempBottomY = 0;
__InitAllBricksEx(fBottomY, fTopY);
__InitBottomMenuEx(fTempBottomY);
float fBottomCenterY = (fBottomY - fTempBottomY) * 0.5f + fTempBottomY;
__InitControllerEx(fBottomCenterY, fTopY);
__InitRightUIEx(fBottomCenterY, fTopY);
__ApplyRightHandModeEx();
// Tips
__InitTips();
}
void CGameSceneEx::UpdateLevelOrSpeed(Vector<Sprite*> vecSpr, int& nOldVal, int nNewVal)
{
if (nOldVal == nNewVal)
{
return;
}
char szSpriteName[10] = { 0 };
Sprite* pFirstSpr = vecSpr.at(0);
Sprite* pSecSpr = vecSpr.at(1);
if (pFirstSpr == nullptr || pSecSpr == nullptr)
{
return;
}
if (nNewVal < 10)
{
sprintf(szSpriteName, "%d.png", nNewVal);
pSecSpr->setSpriteFrame(CGlobalFunc::GetSpriteNameWithMode(szSpriteName));
pFirstSpr->setVisible(false);
pSecSpr->setVisible(true);
float fPosY = pFirstSpr->getPositionY();
Size sprSize = GET_CONTENTSIZE(pSecSpr);
pSecSpr->setPositionY(fPosY - sprSize.width * 0.5f - LEVEL_SPEED_NUM_PADDING * 0.5f);
}
else
{
pFirstSpr->setSpriteFrame(CGlobalFunc::GetSpriteNameWithMode("1.png"));
pFirstSpr->setVisible(true);
pSecSpr->setSpriteFrame(CGlobalFunc::GetSpriteNameWithMode("0.png"));
pSecSpr->setVisible(true);
float fPosY = pFirstSpr->getPositionY();
Size sprSize = GET_CONTENTSIZE(pSecSpr);
pSecSpr->setPositionY(fPosY - sprSize.width - LEVEL_SPEED_NUM_PADDING);
}
// Update value
nOldVal = nNewVal;
}
bool CGameSceneEx::AdjustClickBtnID(const Vec2* pos, int& nBtnID)
{
//ֻ�������
if (nBtnID >= BTNID_DIRMAX)
{
return true;
}
Vec2 dis = *pos - m_oControllerCenterPos;
float fFactor = dis.x / dis.y;
if (fFactor >= 1 || fFactor <= -1)
{
nBtnID = dis.x > 1e-6 ? BTNID_UP : BTNID_DOWN;
return true;
}
if (fFactor < 1 && fFactor >= -1)
{
nBtnID = dis.y > 1e-6 ? BTNID_LEFT : BTNID_RIGHT;
return true;
}
nBtnID = -1;
return false;
}
void CGameSceneEx::__InitAllBricksEx(float& fBottomY, float& fTopY)
{
Size visibleSize = GET_VISIBLESIZE();
Size brickSize = Size::ZERO;
fBottomY = 0;
fTopY = 0;
float fCurX = visibleSize.width;
for (int nRowIdx = 0; nRowIdx < ROW_COUNT; ++nRowIdx)
{
for (int nColIdx = 0; nColIdx < COLUMN_COUNT; ++nColIdx)
{
int nBrickID = GET_BRICKID(nRowIdx, nColIdx);
// Create sprite
Sprite* pSpr = CREATE_SPRITEWITHNAME(CGlobalFunc::GetSpriteNameWithMode(m_arrBrickState[nBrickID] ? "black.png" : "empty.png"));
if (brickSize.equals(Size::ZERO))
{
brickSize = GET_CONTENTSIZE(pSpr);
fTopY = visibleSize.height * 0.5f + brickSize.width * COLUMN_COUNT * 0.5f;
fBottomY = visibleSize.height * 0.5f - brickSize.width * COLUMN_COUNT * 0.5f;
}
pSpr->setRotation(90);
pSpr->setPosition(fCurX - brickSize.height * 0.5f, fTopY - nColIdx * brickSize.width - brickSize.width * 0.5f);
pSpr->setTag(nBrickID);
this->addChild(pSpr);
m_vecBrickSpr.pushBack(pSpr);
}
fCurX -= brickSize.width;
}
}
void CGameSceneEx::__InitControllerEx(float fBottomCenterY, float fTopY)
{
Size visibleSize = GET_VISIBLESIZE();
float fBtnInnerPadding = CONTROLLER_INNER_PADDING;
float fControllerPadding = 10;
const float CONTROLLER_SCALE_MAX = GET_INTVALUE("DIRBTN_SCALE", DIRBTN_DEFAULT_SCALE) / 100.0f;
// Up button
string strBtn0Name = CGlobalFunc::GetSpriteNameWithMode("btn_0.png");
string strBtn1Name = CGlobalFunc::GetSpriteNameWithMode("btn_1.png");
MenuItemSprite* pUpBtn = MenuItemSprite::create(
CREATE_SPRITEWITHNAME(strBtn0Name),
CREATE_SPRITEWITHNAME(strBtn1Name),
nullptr);
Size btnSize = GET_CONTENTSIZE(pUpBtn);
float fControlBtnScale = (visibleSize.height - fTopY - fControllerPadding * 2) / (btnSize.height * 2);
if (fControlBtnScale > CONTROLLER_SCALE_MAX)
{
fControlBtnScale = CONTROLLER_SCALE_MAX;
fControllerPadding = (visibleSize.height - fTopY - CONTROLLER_SCALE_MAX * btnSize.height * 2 + CONTROLLER_INNER_PADDING) * 0.5f;
}
pUpBtn->setRotation(90);
pUpBtn->setScale(fControlBtnScale);
Size upBtnSize = btnSize * fControlBtnScale;
// Right button
MenuItemSprite* pRightBtn = MenuItemSprite::create(CREATE_SPRITEWITHNAME(strBtn0Name),
CREATE_SPRITEWITHNAME(strBtn1Name),
nullptr);
pRightBtn->setScale(fControlBtnScale);
pRightBtn->setRotation(180);
Size rightBtnSize = GET_CONTENTSIZE(pRightBtn) * fControlBtnScale;
// Down button
MenuItemSprite* pDownBtn = MenuItemSprite::create(CREATE_SPRITEWITHNAME(strBtn0Name),
CREATE_SPRITEWITHNAME(strBtn1Name),
nullptr);
pDownBtn->setScale(fControlBtnScale);
pDownBtn->setRotation(270);
Size downBtnSize = GET_CONTENTSIZE(pDownBtn) * fControlBtnScale;
// Left button
MenuItemSprite* pLeftBtn = MenuItemSprite::create(CREATE_SPRITEWITHNAME(strBtn0Name),
CREATE_SPRITEWITHNAME(strBtn1Name),
nullptr);
pLeftBtn->setScale(fControlBtnScale);
Size leftBtnSize = GET_CONTENTSIZE(pLeftBtn) * fControlBtnScale;
//Fire button
string strFire0Name = CGlobalFunc::GetSpriteNameWithMode("fire_0.png");
string strFire1Name = CGlobalFunc::GetSpriteNameWithMode("fire_1.png");
MenuItemSprite* pFireBtn = MenuItemSprite::create(
CREATE_SPRITEWITHNAME(strFire0Name),
CREATE_SPRITEWITHNAME(strFire1Name),
nullptr);
pFireBtn->setRotation(90);
Size fireBtnSize = pFireBtn->getContentSize();
// Set position
float fPosX = upBtnSize.height * 1.2f + GET_INTVALUE("DIRBTN_YOFFSET", 0);
float fTopCenterY = fTopY + fControllerPadding + upBtnSize.height;
pLeftBtn->setPosition(Vec2(fPosX, fTopCenterY + leftBtnSize.height * 0.5f - fBtnInnerPadding));
pRightBtn->setPosition(Vec2(fPosX, fTopCenterY - rightBtnSize.height * 0.5f + fBtnInnerPadding));
pDownBtn->setPosition(Vec2(fPosX - upBtnSize.height * 0.5f + fBtnInnerPadding, fTopCenterY));
pUpBtn->setPosition(Vec2(fPosX + upBtnSize.height * 0.5f - fBtnInnerPadding, fTopCenterY));
pFireBtn->setPosition(Vec2(fPosX, fBottomCenterY));
// Center pos and area size
m_oControllerCenterPos = Vec2(fPosX, fTopCenterY);
m_oControllerCenterSize = Size(upBtnSize.width, upBtnSize.width);
Menu* pMenu = Menu::create(pUpBtn, pRightBtn, pDownBtn, pLeftBtn, nullptr);
pMenu->setTouchCallback(CC_CALLBACK_3(CGameSceneEx::__OnMenuTouch, this));
pMenu->setPosition(Vec2::ZERO);
this->addChild(pMenu);
Menu* pFireMenu = Menu::create(pFireBtn, nullptr);
pFireMenu->setTouchCallback(CC_CALLBACK_3(CGameSceneEx::__OnMenuTouch, this));
pFireMenu->setPosition(Vec2::ZERO);
this->addChild(pFireMenu);
// Add all buttons to vector
// Order: BTNID_RIGHT -> BTNID_DOWN -> BTNID_LEFT -> BTNID_UP -> BTNID_FIRE
m_vecDirBtn.pushBack(pRightBtn);
m_vecDirBtn.pushBack(pDownBtn);
m_vecDirBtn.pushBack(pLeftBtn);
m_vecDirBtn.pushBack(pUpBtn);
m_vecDirBtn.pushBack(pFireBtn);
}
void CGameSceneEx::__InitBottomMenuEx(float& fBottomY)
{
float fSpriteScale = 0.4f;
Size visibleSize = GET_VISIBLESIZE();
// Start button
Sprite* pPlaySpr = CREATE_SPRITEWITHNAME(CGlobalFunc::GetSpriteNameWithMode("play.png"));
Sprite* pPauseSpr = CREATE_SPRITEWITHNAME(CGlobalFunc::GetSpriteNameWithMode("pause.png"));
m_pStartBtn = MenuItemToggle::createWithCallback(
CC_CALLBACK_1(CGameSceneEx::__OnClickButton, this, BTNID_START),
MenuItemSprite::create(pPlaySpr, pPlaySpr, nullptr),
MenuItemSprite::create(pPauseSpr, pPauseSpr, nullptr),
nullptr
);
m_pStartBtn->setRotation(90);
m_pStartBtn->setScale(fSpriteScale);
Size startBtnSize = m_pStartBtn->getContentSize() * fSpriteScale;
// Sound button
Sprite* pSndOnSpr = CREATE_SPRITEWITHNAME(CGlobalFunc::GetSpriteNameWithMode("sound_on.png"));
Sprite* pSndOffSpr = CREATE_SPRITEWITHNAME(CGlobalFunc::GetSpriteNameWithMode("sound_off.png"));
auto pSoundOnMenu = MenuItemSprite::create(
pSndOnSpr,
pSndOnSpr,
nullptr
);
auto pSoundOffMenu = MenuItemSprite::create(
pSndOffSpr,
pSndOffSpr,
nullptr
);
m_pSoundBtn = MenuItemToggle::createWithCallback(
CC_CALLBACK_1(CGameSceneEx::__OnClickButton, this, BTNID_SOUND),
pSoundOnMenu, pSoundOffMenu,
nullptr
);
m_pSoundBtn->setRotation(90);
m_pSoundBtn->setScale(fSpriteScale);
m_pSoundBtn->setSelectedIndex(GET_BOOLVALUE("SOUND", true) ? 0 : 1);
Size soundBtnSize = m_pSoundBtn->getContentSize() * fSpriteScale;
// Reset button
Sprite* pResetSpr = CREATE_SPRITEWITHNAME(CGlobalFunc::GetSpriteNameWithMode("reset.png"));
m_pResetBtn = MenuItemSprite::create(
pResetSpr,
pResetSpr,
CC_CALLBACK_1(CGameSceneEx::__OnClickButton, this, BTNID_RESET)
);
m_pStartBtn->setRotation(90);
m_pResetBtn->setScale(fSpriteScale);
Size resetBtnSize = m_pResetBtn->getContentSize() * fSpriteScale;
// Setup button
Sprite* pStarSpr = CREATE_SPRITEWITHNAME(CGlobalFunc::GetSpriteNameWithMode("setup.png"));
m_pSetupBtn = MenuItemSprite::create(
pStarSpr,
pStarSpr,
CC_CALLBACK_1(CGameSceneEx::__OnClickButton, this, BTNID_SETUP)
);
m_pStartBtn->setRotation(90);
m_pSetupBtn->setScale(fSpriteScale);
Size setupBtnSize = m_pSetupBtn->getContentSize() * fSpriteScale;
// Bottom button horizontal padding
fBottomY = soundBtnSize.height * 0.75f;
float fBtnBottomInnerPadding = (visibleSize.width - resetBtnSize.height - setupBtnSize.height - startBtnSize.height - soundBtnSize.height) / 5;
m_pStartBtn->setPosition(fBtnBottomInnerPadding + startBtnSize.height * 0.5f, fBottomY);
m_pSoundBtn->setPosition(fBtnBottomInnerPadding * 2 + startBtnSize.height + soundBtnSize.height * 0.5f, fBottomY);
m_pResetBtn->setPosition(fBtnBottomInnerPadding * 3 + startBtnSize.height + soundBtnSize.height + resetBtnSize.height * 0.5f, fBottomY);
m_pSetupBtn->setPosition(visibleSize.width - fBtnBottomInnerPadding - setupBtnSize.height * 0.5f, fBottomY);
// Menu
auto menu = Menu::create(m_pStartBtn, m_pSoundBtn, m_pResetBtn, m_pSetupBtn, nullptr);
menu->setPosition(Vec2::ZERO);
this->addChild(menu);
fBottomY += soundBtnSize.height * 0.5f;
}
void CGameSceneEx::__InitRightUIEx(float fBottomCenterY, float fTopY)
{
float fSpriteScale = 0.38f;
float fSmallBrickScale = 0.7f;
int nSmallBrickPadding = 2;
int nNumSprPadding = 1;
Size visibleSize = GET_VISIBLESIZE();
float fRightX = visibleSize.width;
float fTopCenterY = (visibleSize.height - fTopY) * 0.5f + fTopY;
string strZeroSprName = CGlobalFunc::GetSpriteNameWithMode("0.png");
////////////////////////// Top part //////////////////////////
// Score label
Sprite* pScoreSpr = CREATE_SPRITEWITHNAME(CGlobalFunc::GetSpriteNameWithMode("score.png"));
Size scoreSize = GET_CONTENTSIZE(pScoreSpr) * fSpriteScale;
pScoreSpr->setRotation(90);
pScoreSpr->setScale(fSpriteScale);
pScoreSpr->setPosition(fRightX - scoreSize.height, fTopCenterY);
fRightX -= scoreSize.height * 1.5f;
this->addChild(pScoreSpr);
m_vecMiscSpr.pushBack(pScoreSpr);
// Score num sprite
Size numSize = Size::ZERO;
float fTempY = 0;
for (int nIndex = 0; nIndex < SCORE_NUM_COUNT; ++nIndex)
{
Sprite* pSpr = CREATE_SPRITEWITHNAME(strZeroSprName);
if (numSize.equals(Size::ZERO))
{
numSize = GET_CONTENTSIZE(pSpr);
fRightX -= numSize.height * 0.3f;
fTempY = fTopCenterY + nNumSprPadding * 2.5f + numSize.width * 3;
}
pSpr->setPosition(fRightX - numSize.height * 0.5f, fTempY - numSize.width * 0.5f);
pSpr->setRotation(90);
this->addChild(pSpr);
m_vecScoreSpr.pushBack(pSpr);
fTempY -= numSize.width + nNumSprPadding;
}
fRightX -= numSize.height;
// Max score label
Sprite* pMaxScoreSpr = CREATE_SPRITEWITHNAME(CGlobalFunc::GetSpriteNameWithMode("hiscore.png"));
Size maxScoreSize = GET_CONTENTSIZE(pMaxScoreSpr) * fSpriteScale;
pMaxScoreSpr->setPosition(fRightX - maxScoreSize.height, fTopCenterY);
pMaxScoreSpr->setRotation(90);
pMaxScoreSpr->setScale(fSpriteScale);
fRightX -= maxScoreSize.height * 1.5f;
this->addChild(pMaxScoreSpr);
m_vecMiscSpr.pushBack(pMaxScoreSpr);
// Max score num sprite
fRightX -= numSize.height * 0.3f;
fTempY = fTopCenterY + nNumSprPadding * 2.5f + numSize.width * 3;
for (int nIndex = 0; nIndex < SCORE_NUM_COUNT; ++nIndex)
{
Sprite* pSpr = CREATE_SPRITEWITHNAME(strZeroSprName);
pSpr->setPosition(fRightX - numSize.height * 0.5f, fTempY - numSize.width * 0.5f);
pSpr->setRotation(90);
this->addChild(pSpr);
m_vecMaxScoreSpr.pushBack(pSpr);
fTempY -= numSize.width + nNumSprPadding;
}
fRightX -= numSize.height;
////////////////////////// Bottom part //////////////////////////
fRightX = visibleSize.width;
// Small bricks
Size smallBrickSize = Size::ZERO;
for (int nRowIdx = 0; nRowIdx < SMALL_BRICK_ROW_COUNT; ++nRowIdx)
{
for (int nColIdx = 0; nColIdx < SMALL_BRICK_COLUMN_COUNT; ++nColIdx)
{
Sprite* pSpr = CREATE_SPRITEWITHNAME(CGlobalFunc::GetSpriteNameWithMode("empty.png"));
if (smallBrickSize.equals(Size::ZERO))
{
smallBrickSize = GET_CONTENTSIZE(pSpr) * fSmallBrickScale;
fRightX -= (nSmallBrickPadding + smallBrickSize.height * 0.7f);
}
if (nColIdx == 0)
{
fTempY = fBottomCenterY + nNumSprPadding * 1.5f + smallBrickSize.width * 2;
}
// Calc position
pSpr->setRotation(90);
pSpr->setScale(fSmallBrickScale);
pSpr->setPosition(fRightX - smallBrickSize.height * 0.5f, fTempY - smallBrickSize.width * 0.5f);
this->addChild(pSpr);
m_vecSmallBrickSpr.pushBack(pSpr);
fTempY -= (smallBrickSize.width + nSmallBrickPadding);
}
fRightX -= (smallBrickSize.height + nSmallBrickPadding);
}
// Speed label
Sprite* pSpeedSpr = CREATE_SPRITEWITHNAME(CGlobalFunc::GetSpriteNameWithMode("speed.png"));
Size speedSize = GET_CONTENTSIZE(pSpeedSpr) * fSpriteScale;
fRightX -= speedSize.height * 1.6f;
fTempY = fBottomCenterY + (speedSize.width + numSize.width * 2 + LEVEL_SPEED_NUM_PADDING * 2) * 0.5f;
pSpeedSpr->setRotation(90);
pSpeedSpr->setScale(fSpriteScale);
pSpeedSpr->setPosition(fRightX + speedSize.height * 0.5f, fTempY - speedSize.width * 0.5f);
this->addChild(pSpeedSpr);
m_vecMiscSpr.pushBack(pSpeedSpr);
// Speed num sprite
fTempY -= speedSize.width;
for (int nIndex = 0; nIndex < SPEED_NUM_COUNT; ++nIndex)
{
Sprite* pSpr = CREATE_SPRITEWITHNAME(strZeroSprName);
pSpr->setRotation(90);
pSpr->setPosition(fRightX + numSize.height * 0.5f, fTempY - numSize.width * 0.5f);
this->addChild(pSpr);
m_vecSpeedSpr.pushBack(pSpr);
fTempY -= (numSize.width + LEVEL_SPEED_NUM_PADDING);
}
// Level label
Sprite* pLevelSpr = CREATE_SPRITEWITHNAME(CGlobalFunc::GetSpriteNameWithMode("level.png"));
Size levelSize = GET_CONTENTSIZE(pLevelSpr) * fSpriteScale;
fTempY = fBottomCenterY + (levelSize.width + numSize.width * 2 + LEVEL_SPEED_NUM_PADDING * 2) * 0.5f;
fRightX -= levelSize.height * 1.5f;
pLevelSpr->setRotation(90);
pLevelSpr->setScale(fSpriteScale);
pLevelSpr->setPosition(fRightX + levelSize.height * 0.5f, fTempY - levelSize.width * 0.5f);
this->addChild(pLevelSpr);
m_vecMiscSpr.pushBack(pLevelSpr);
// Level num sprite
fTempY -= levelSize.width;
for (int nIndex = 0; nIndex < SPEED_NUM_COUNT; ++nIndex)
{
Sprite* pSpr = CREATE_SPRITEWITHNAME(strZeroSprName);
pSpr->setRotation(90);
pSpr->setPosition(fRightX + numSize.height * 0.5f, fTempY - numSize.width * 0.5f);
this->addChild(pSpr);
m_vecLevelSpr.pushBack(pSpr);
fTempY -= (numSize.width + LEVEL_SPEED_NUM_PADDING);
}
// Pause sprite
fRightX -= levelSize.height * 0.5f;
m_pPauseSpr = CREATE_SPRITEWITHNAME(CGlobalFunc::GetSpriteNameWithMode("tea.png"));
Size pauseSize = GET_CONTENTSIZE(m_pPauseSpr) * fSpriteScale;
m_pPauseSpr->setRotation(90);
m_pPauseSpr->setScale(fSpriteScale);
m_pPauseSpr->setPosition(fRightX - pauseSize.height * 0.5f, fBottomCenterY);
this->addChild(m_pPauseSpr);
m_pPauseSpr->setVisible(false);
// Update level
UpdateLevelOrSpeed(m_vecLevelSpr, m_stGameData.nLevel, m_stGameData.nLevel);
// Update speed
UpdateLevelOrSpeed(m_vecSpeedSpr, m_stGameData.nSpeed, m_stGameData.nLevel);
}
void CGameSceneEx::__ApplyRightHandModeEx()
{
if (!GET_BOOLVALUE("RHMODE", false))
{
return;
}
MenuItem* pRightBtn = m_vecDirBtn.at(BTNID_RIGHT);
RETURN_IF_NULLPTR(pRightBtn);
MenuItem* pDownBtn = m_vecDirBtn.at(BTNID_DOWN);
RETURN_IF_NULLPTR(pDownBtn);
MenuItem* pLeftBtn = m_vecDirBtn.at(BTNID_LEFT);
RETURN_IF_NULLPTR(pLeftBtn);
MenuItem* pUpBtn = m_vecDirBtn.at(BTNID_UP);
RETURN_IF_NULLPTR(pUpBtn);
MenuItem* pFireBtn = m_vecDirBtn.at(BTNID_FIRE);
RETURN_IF_NULLPTR(pFireBtn);
Size btnSize = GET_CONTENTSIZE(pUpBtn) * pUpBtn->getScale();
Size visibleSize = GET_VISIBLESIZE();
// Update controller position
float fControllerCenterY = visibleSize.height - pUpBtn->getPositionY();
pFireBtn->setPositionY(visibleSize.height - pFireBtn->getPositionY());
pDownBtn->setPositionY(fControllerCenterY);
pUpBtn->setPositionY(fControllerCenterY);
pLeftBtn->setPositionY(fControllerCenterY + btnSize.height * 0.5f - CONTROLLER_INNER_PADDING);
pRightBtn->setPositionY(fControllerCenterY - btnSize.height * 0.5f + CONTROLLER_INNER_PADDING);
m_oControllerCenterPos.y = fControllerCenterY;
// Update bottom button position
m_pStartBtn->setPositionY(visibleSize.height - m_pStartBtn->getPositionY());
m_pSoundBtn->setPositionY(visibleSize.height - m_pSoundBtn->getPositionY());
m_pResetBtn->setPositionY(visibleSize.height - m_pResetBtn->getPositionY());
m_pSetupBtn->setPositionY(visibleSize.height - m_pSetupBtn->getPositionY());
}
void CGameSceneEx::__InitTips()
{
Size visibleSize = GET_VISIBLESIZE();
m_pTipsLabel = Label::createWithSystemFont("123", FONT_NAME, TIPS_LABEL_SIZE);
Color3B color = GET_BOOLVALUE("NIGHTMODE", false) ? Color3B::WHITE : Color3B::BLACK;
m_pTipsLabel->setColor(color);
m_pTipsLabel->setOpacity(0);
m_pTipsLabel->setPosition(visibleSize.width * 0.5f, visibleSize.height * 0.5f);
m_pTipsLabel->setRotation(90);
this->addChild(m_pTipsLabel);
}
| 33.941068
| 144
| 0.741671
|
lfeng1420
|
731064edb012109930ec2ce75282ad6c5463f5fb
| 7,515
|
cc
|
C++
|
src/pass/narrow_channel_access.cc
|
baowenlei/tvm
|
6b2e18ed96fad26b4a5e5f8a6dcbedf9206c9a65
|
[
"Apache-2.0"
] | 16
|
2019-11-20T03:43:19.000Z
|
2021-11-25T02:32:17.000Z
|
src/pass/narrow_channel_access.cc
|
baowenlei/tvm
|
6b2e18ed96fad26b4a5e5f8a6dcbedf9206c9a65
|
[
"Apache-2.0"
] | 4
|
2019-06-27T08:05:18.000Z
|
2021-09-09T18:59:11.000Z
|
src/pass/narrow_channel_access.cc
|
baowenlei/tvm
|
6b2e18ed96fad26b4a5e5f8a6dcbedf9206c9a65
|
[
"Apache-2.0"
] | 5
|
2020-03-18T10:14:30.000Z
|
2021-04-01T12:09:20.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.
*/
/*!
* Copyright (c) 2017 by Contributors
* \file narrow_channel_access.cc
* \brief Narrow channel access to a smaller range
* when possible by bringing it to the internal loop.
*/
#include <tvm/ir.h>
#include <tvm/expr.h>
#include <tvm/ir_pass.h>
#include <tvm/ir_visitor.h>
#include <tvm/ir_mutator.h>
#include <tvm/arithmetic.h>
#include <tvm/channel.h>
#include "ir_util.h"
namespace tvm {
namespace ir {
using namespace arith;
// Bound deducer for channel access.
class ChannelAccessBound : public IRVisitor {
public:
ChannelAccessBound(const Variable* buf_var, bool read_access)
: buf_var_(buf_var), read_access_(read_access) {}
void Visit_(const Store* op) final {
if (!read_access_ && buf_var_ == op->buffer_var.get()) {
ret_.emplace_back(EvalSet(op->index, dom_map_));
}
IRVisitor::Visit_(op);
}
void Visit_(const For* op) final {
CHECK(is_zero(op->min));
// We know that the extent of the loop won't depend on relaxed scope.
// TODO(tqchen) have a verification pass.
dom_map_[op->loop_var.get()] = IntSet::interval(op->min, op->extent - 1);
IRVisitor::Visit_(op);
}
void Visit_(const Load* op) final {
if (read_access_ && buf_var_ == op->buffer_var.get()) {
ret_.emplace_back(EvalSet(op->index, dom_map_));
}
IRVisitor::Visit_(op);
}
void Visit_(const Let* op) final {
LOG(FATAL) << "cannot pass through let";
}
void Visit_(const LetStmt* op) final {
LOG(FATAL) << "cannot pass through let";
}
IntSet Eval(const Stmt& stmt) {
Visit(stmt);
return Union(ret_);
}
private:
// The buffer variable.
const Variable* buf_var_;
// read or write
bool read_access_{true};
// Box
std::vector<IntSet> ret_;
// Domain map.
std::unordered_map<const Variable*, IntSet> dom_map_;
};
class ChannelAccessIndexRewriter : public IRMutator {
public:
ChannelAccessIndexRewriter(const Variable* buf_var,
Expr min,
bool read_access)
: buf_var_(buf_var), min_(min), read_access_(read_access) {}
Expr Mutate_(const Load* op, const Expr& e) final {
Expr expr = IRMutator::Mutate_(op, e);
op = expr.as<Load>();
if (read_access_ && buf_var_ == op->buffer_var.get()) {
return Load::make(
op->type, op->buffer_var, ir::Simplify(op->index - min_),
op->predicate);
} else {
return expr;
}
}
Stmt Mutate_(const Store* op, const Stmt& s) final {
Stmt stmt = IRMutator::Mutate_(op, s);
op = stmt.as<Store>();
if (!read_access_ && buf_var_ == op->buffer_var.get()) {
return Store::make(
op->buffer_var, op->value, ir::Simplify(op->index - min_),
op->predicate);
} else {
return stmt;
}
}
private:
// The buffer variable.
const Variable* buf_var_;
// The min bound.
Expr min_;
// read or write
bool read_access_{true};
};
// Rewrite channel access pattern.
class ChannelAccessRewriter : public IRMutator {
public:
Stmt Mutate_(const AttrStmt* op, const Stmt& s) final {
Stmt ret;
const AttrStmt* adv = op->body.as<AttrStmt>();
if ((op->attr_key == ir::attr::channel_read_scope &&
adv && adv->attr_key == ir::attr::channel_read_advance) ||
(op->attr_key == ir::attr::channel_write_scope &&
adv && adv->attr_key == ir::attr::channel_write_advance)) {
RewriteEntry e;
e.window = op;
e.advance = adv;
e.read_access = op->attr_key == ir::attr::channel_read_scope;
tasks_.push_back(e);
ret = IRMutator::Mutate_(op, s);
if (tasks_.back().rewrite_success) {
ret = ret.as<AttrStmt>()->body.as<AttrStmt>()->body;
}
tasks_.pop_back();
return ret;
} else {
return IRMutator::Mutate_(op, s);
}
}
Stmt Mutate_(const For* op, const Stmt& s) final {
std::vector<RewriteEntry> tasks;
std::swap(tasks_, tasks);
Stmt body = op->body;
std::vector<Stmt> nest;
for (RewriteEntry& e : tasks) {
body = RewriteAccess(op, body, &e, &nest);
}
if (!body.same_as(op->body)) {
body = Mutate(body);
body = For::make(
op->loop_var, op->min, op->extent,
op->for_type, op->device_api, body);
body = MergeNest(nest, body);
} else {
CHECK_EQ(nest.size(), 0U);
body = IRMutator::Mutate_(op, s);
}
std::swap(tasks_, tasks);
return body;
}
private:
struct RewriteEntry {
bool read_access;
const AttrStmt* window;
const AttrStmt* advance;
bool rewrite_success{false};
};
Stmt RewriteAccess(const For* for_op,
Stmt body,
RewriteEntry* e,
std::vector<Stmt>* outer_nest) {
const AttrStmt* adv_op = e->advance;
const Expr& window = e->window->value;
bool read_access = e->read_access;
Var var(for_op->loop_var);
Channel ch(adv_op->node.node_);
ChannelAccessBound acc(ch->handle_var.get(), read_access);
IntSet iset = acc.Eval(for_op->body);
Range r = iset.cover_range(Range::make_by_min_extent(0, window));
r = Range::make_by_min_extent(
ir::Simplify(r->min), ir::Simplify(r->extent));
if (ExprUseVar(r->extent, var)) return body;
Array<Expr> linear_eq = DetectLinearEquation(r->min, {var});
if (linear_eq.size() == 0) return body;
Expr coeff = linear_eq[0];
Expr base = linear_eq[1];
if (!is_zero(base)) return body;
Expr left = ir::Simplify(adv_op->value - coeff * for_op->extent);
if (!can_prove(left >= 0)) return body;
// rewrite access index.
ChannelAccessIndexRewriter rw(
ch->handle_var.get(), var * coeff, read_access);
body = rw.Mutate(body);
if (read_access) {
body = AttrStmt::make(
ch, ir::attr::channel_read_scope, r->extent,
AttrStmt::make(ch, ir::attr::channel_read_advance, coeff,
body));
} else {
body = AttrStmt::make(
ch, ir::attr::channel_write_scope, r->extent,
AttrStmt::make(ch, ir::attr::channel_write_advance, coeff,
body));
}
if (!is_zero(left)) {
Stmt no_op = Evaluate::make(0);
if (read_access) {
outer_nest->emplace_back(
AttrStmt::make(ch, ir::attr::channel_read_advance, left, no_op));
} else {
outer_nest->emplace_back(
AttrStmt::make(ch, ir::attr::channel_write_advance, left, no_op));
}
}
e->rewrite_success = true;
return body;
}
std::vector<RewriteEntry> tasks_;
};
Stmt NarrowChannelAccess(Stmt stmt) {
return ChannelAccessRewriter().Mutate(stmt);
}
} // namespace ir
} // namespace tvm
| 30.673469
| 78
| 0.628743
|
baowenlei
|
731157651556f53e1b0fd10738e263f79fd480aa
| 4,159
|
cc
|
C++
|
tests/registrationbuilder_tests.cc
|
aghoward/cdif
|
838bab6eb5c52f6cad47018860d37bb1d18c723f
|
[
"MIT"
] | 10
|
2017-06-24T12:54:48.000Z
|
2020-02-17T07:58:33.000Z
|
tests/registrationbuilder_tests.cc
|
aghoward/cdif
|
838bab6eb5c52f6cad47018860d37bb1d18c723f
|
[
"MIT"
] | 2
|
2018-01-26T19:01:03.000Z
|
2018-03-15T23:34:20.000Z
|
tests/registrationbuilder_tests.cc
|
aghoward/cdif
|
838bab6eb5c52f6cad47018860d37bb1d18c723f
|
[
"MIT"
] | null | null | null |
#include "cdif.h"
#include "test_types.h"
#include <gtest/gtest.h>
#include <functional>
#include <string>
#include <thread>
class RegistrationBuilderTests : public ::testing::Test
{
protected:
cdif::Container _subject;
template <typename T>
void givenRegistrationReturningValue(T value, const std::string& name = "")
{
auto factory = [value] () { return value; };
_subject.bind<T>(factory).named(name).build();
}
public:
RegistrationBuilderTests() : _subject(cdif::Container())
{
};
};
TEST_F(RegistrationBuilderTests, Resolve_GivenNamedRegistration_ReturnsNamedItem)
{
auto name = "NamedInt";
auto expectedValue = 5;
givenRegistrationReturningValue(expectedValue, name);
givenRegistrationReturningValue(35);
auto result = _subject.resolve<int>(name);
ASSERT_EQ(expectedValue, result);
}
TEST_F(RegistrationBuilderTests, Resolve_GivenPerDependencyRegistration_ResolvesNewInstancePerCall)
{
givenRegistrationReturningValue(322);
_subject.bind<SimpleImplementation, int>().in<cdif::Scope::PerDependency>().build();
auto* a = _subject.resolve<SimpleImplementation*>();
auto* b = _subject.resolve<SimpleImplementation*>();
ASSERT_NE(a, b);
delete a;
delete b;
}
TEST_F(RegistrationBuilderTests, Resolve_GivenSingletonRegistration_ResolvesSameInstancePerCall)
{
givenRegistrationReturningValue(322);
_subject.bind<SimpleImplementation, int>().in<cdif::Scope::Singleton>().build();
auto& a = _subject.resolve<SimpleImplementation&>();
auto& b = _subject.resolve<SimpleImplementation&>();
ASSERT_EQ(std::addressof(a), std::addressof(b));
}
TEST_F(RegistrationBuilderTests, Resolve_GivenSingletonRegistration_CanResolveReference)
{
givenRegistrationReturningValue(343);
_subject.bind<SimpleImplementation, int>().in<cdif::Scope::Singleton>().build();
auto& result = _subject.resolve<SimpleImplementation&>();
ASSERT_NE(std::addressof(result), nullptr);
}
TEST_F(RegistrationBuilderTests, Resolve_GivenSingletonRegistration_CanResolveRawPointer)
{
givenRegistrationReturningValue(343);
_subject.bind<SimpleImplementation, int>().in<cdif::Scope::Singleton>().build();
auto* result = _subject.resolve<SimpleImplementation*>();
ASSERT_NE(result, nullptr);
}
TEST_F(RegistrationBuilderTests, Resolve_GivenSingletonRegistration_CanResolveSharedPointer)
{
givenRegistrationReturningValue(343);
_subject.bind<SimpleImplementation, int>().in<cdif::Scope::Singleton>().build();
auto result = _subject.resolve<std::shared_ptr<SimpleImplementation>>();
ASSERT_NE(result.get(), nullptr);
}
TEST_F(RegistrationBuilderTests, Resolve_GivenPerThreadRegistration_ResolvesNewInstancePerThread)
{
NonCopyable* first = nullptr, * second = nullptr;
givenRegistrationReturningValue(333);
_subject.bind<NonCopyable, int>().in<cdif::Scope::PerThread>().build();
auto functor = [&] (NonCopyable** ptr)
{
*ptr = _subject.resolve<NonCopyable*>();
};
auto t1 = std::thread(functor, &first);
auto t2 = std::thread(functor, &second);
t1.join();
t2.join();
ASSERT_NE(first, second);
}
TEST_F(RegistrationBuilderTests, Resolve_GivenPerThreadRegistration_ResolvesSingleInstanceInThread)
{
givenRegistrationReturningValue(343);
_subject.bind<NonCopyable, int>().in<cdif::Scope::PerThread>().build();
auto functor = [&] ()
{
auto* p1 = _subject.resolve<NonCopyable*>();
auto* p2 = _subject.resolve<NonCopyable*>();
ASSERT_EQ(p1, p2);
};
auto t = std::thread(functor);
t.join();
}
TEST_F(RegistrationBuilderTests, Resolve_GivenRegistrationWithParameterFactory_ResolvesParametersFromFactory) {
auto expectedValue = 324;
givenRegistrationReturningValue(333333);
_subject.bind<SimpleImplementation, int>()
.withIndexedParameterFrom<0, int>([expectedValue] (const cdif::Container&) { return expectedValue; })
.build();
auto result = _subject.resolve<SimpleImplementation>();
ASSERT_EQ(expectedValue, result.m_data);
}
| 29.707143
| 111
| 0.716999
|
aghoward
|
73121d342e29deaab3ef11167a551b144578f7db
| 3,475
|
cpp
|
C++
|
src/TableFunctions/TableFunctionS3.cpp
|
monadbobo/ClickHouse
|
73b0f8db8c327a1d63cc7ebcc56087a3f9866dae
|
[
"Apache-2.0"
] | null | null | null |
src/TableFunctions/TableFunctionS3.cpp
|
monadbobo/ClickHouse
|
73b0f8db8c327a1d63cc7ebcc56087a3f9866dae
|
[
"Apache-2.0"
] | 1
|
2020-04-04T04:25:47.000Z
|
2020-04-04T04:25:47.000Z
|
src/TableFunctions/TableFunctionS3.cpp
|
monadbobo/ClickHouse
|
73b0f8db8c327a1d63cc7ebcc56087a3f9866dae
|
[
"Apache-2.0"
] | null | null | null |
#include <Common/config.h>
#if USE_AWS_S3
#include <IO/S3Common.h>
#include <Storages/StorageS3.h>
#include <Access/AccessFlags.h>
#include <Interpreters/evaluateConstantExpression.h>
#include <Interpreters/Context.h>
#include <TableFunctions/TableFunctionFactory.h>
#include <TableFunctions/TableFunctionS3.h>
#include <TableFunctions/parseColumnsListForTableFunction.h>
#include <Parsers/ASTLiteral.h>
#include "registerTableFunctions.h"
namespace DB
{
namespace ErrorCodes
{
extern const int LOGICAL_ERROR;
extern const int NUMBER_OF_ARGUMENTS_DOESNT_MATCH;
}
StoragePtr TableFunctionS3::executeImpl(const ASTPtr & ast_function, const Context & context, const std::string & table_name) const
{
/// Parse args
ASTs & args_func = ast_function->children;
if (args_func.size() != 1)
throw Exception("Table function '" + getName() + "' must have arguments.", ErrorCodes::LOGICAL_ERROR);
ASTs & args = args_func.at(0)->children;
if (args.size() < 3 || args.size() > 6)
throw Exception("Table function '" + getName() + "' requires 3 to 6 arguments: url, [access_key_id, secret_access_key,] format, structure and [compression_method].",
ErrorCodes::NUMBER_OF_ARGUMENTS_DOESNT_MATCH);
for (auto & arg : args)
arg = evaluateConstantExpressionOrIdentifierAsLiteral(arg, context);
String filename = args[0]->as<ASTLiteral &>().value.safeGet<String>();
String format;
String structure;
String access_key_id;
String secret_access_key;
if (args.size() < 5)
{
format = args[1]->as<ASTLiteral &>().value.safeGet<String>();
structure = args[2]->as<ASTLiteral &>().value.safeGet<String>();
}
else
{
access_key_id = args[1]->as<ASTLiteral &>().value.safeGet<String>();
secret_access_key = args[2]->as<ASTLiteral &>().value.safeGet<String>();
format = args[3]->as<ASTLiteral &>().value.safeGet<String>();
structure = args[4]->as<ASTLiteral &>().value.safeGet<String>();
}
String compression_method;
if (args.size() == 4 || args.size() == 6)
compression_method = args.back()->as<ASTLiteral &>().value.safeGet<String>();
else
compression_method = "auto";
context.checkAccess(AccessType::s3);
ColumnsDescription columns = parseColumnsListFromString(structure, context);
/// Create table
StoragePtr storage = getStorage(filename, access_key_id, secret_access_key, format, columns, const_cast<Context &>(context), table_name, compression_method);
storage->startup();
return storage;
}
StoragePtr TableFunctionS3::getStorage(
const String & source,
const String & access_key_id,
const String & secret_access_key,
const String & format,
const ColumnsDescription & columns,
Context & global_context,
const std::string & table_name,
const String & compression_method)
{
Poco::URI uri (source);
S3::URI s3_uri (uri);
UInt64 min_upload_part_size = global_context.getSettingsRef().s3_min_upload_part_size;
return StorageS3::create(
s3_uri,
access_key_id,
secret_access_key,
StorageID(getDatabaseName(), table_name),
format,
min_upload_part_size,
columns,
ConstraintsDescription{},
global_context,
compression_method);
}
void registerTableFunctionS3(TableFunctionFactory & factory)
{
factory.registerFunction<TableFunctionS3>();
}
}
#endif
| 30.482456
| 173
| 0.688345
|
monadbobo
|
73138a31f2c23d1c86b51a13b80a5b64c60e5ce8
| 16,016
|
cpp
|
C++
|
smallpssmlt.cpp
|
shiinamiyuki/smallpssmlt
|
f201bdff2a3968450e8fb970cd61be46fc0aab3d
|
[
"MIT"
] | 5
|
2019-06-27T05:55:52.000Z
|
2022-01-09T14:13:13.000Z
|
smallpssmlt.cpp
|
xt271828/smallpssmlt
|
f201bdff2a3968450e8fb970cd61be46fc0aab3d
|
[
"MIT"
] | null | null | null |
smallpssmlt.cpp
|
xt271828/smallpssmlt
|
f201bdff2a3968450e8fb970cd61be46fc0aab3d
|
[
"MIT"
] | null | null | null |
#include <random>
#include <iostream>
#include <stdlib.h>
#include <math.h>
#include <math.h> // smallpt, a Path Tracer by Kevin Beason, 2008
#include <stdlib.h> // Make : g++ -O3 -fopenmp smallpt.cpp -o smallpt
#include <stdio.h> // Remove "-fopenmp" for g++ version < 4.2
#include <atomic>
#include <mutex>
#include <memory.h>
float random(unsigned int *rng) {
*rng = (1103515245 * (*rng) + 12345);
return (float) *rng / (float) 0xFFFFFFFF;
}
struct Vec { // Usage: time ./smallpt 5000 && xv image.ppm
double x, y, z; // position, also color (r,g,b)
Vec(double x_ = 0, double y_ = 0, double z_ = 0) {
x = x_;
y = y_;
z = z_;
}
Vec operator+(const Vec &b) const { return Vec(x + b.x, y + b.y, z + b.z); }
Vec operator-(const Vec &b) const { return Vec(x - b.x, y - b.y, z - b.z); }
Vec operator*(double b) const { return Vec(x * b, y * b, z * b); }
Vec mult(const Vec &b) const { return Vec(x * b.x, y * b.y, z * b.z); }
Vec &norm() { return *this = *this * (1 / sqrt(x * x + y * y + z * z)); }
double dot(const Vec &b) const { return x * b.x + y * b.y + z * b.z; } // cross:
Vec operator%(Vec &b) { return Vec(y * b.z - z * b.y, z * b.x - x * b.z, x * b.y - y * b.x); }
};
struct Ray {
Vec o, d;
Ray(Vec o_, Vec d_) : o(o_), d(d_) {}
};
enum Refl_t {
DIFF, SPEC, REFR
}; // material types, used in radiance()
struct Sphere {
double rad; // radius
Vec p, e, c; // position, emission, color
Refl_t refl; // reflection type (DIFFuse, SPECular, REFRactive)
Sphere(double rad_, Vec p_, Vec e_, Vec c_, Refl_t refl_) :
rad(rad_), p(p_), e(e_), c(c_), refl(refl_) {}
double intersect(const Ray &r) const { // returns distance, 0 if nohit
Vec op = p - r.o; // Solve t^2*d.d + 2*t*(o-p).d + (o-p).(o-p)-R^2 = 0
double t, eps = 1e-4, b = op.dot(r.d), det = b * b - op.dot(op) + rad * rad;
if (det < 0) return 0; else det = sqrt(det);
return (t = b - det) > eps ? t : ((t = b + det) > eps ? t : 0);
}
};
Sphere spheres[] = {//Scene: radius, position, emission, color, material
Sphere(1e5, Vec(1e5 + 1, 40.8, 81.6), Vec(), Vec(.75, .25, .25), DIFF),//Left
Sphere(1e5, Vec(-1e5 + 99, 40.8, 81.6), Vec(), Vec(.25, .25, .75), DIFF),//Rght
Sphere(1e5, Vec(50, 40.8, 1e5), Vec(), Vec(.75, .75, .75), DIFF),//Back
Sphere(1e5, Vec(50, 40.8, -1e5 + 170), Vec(), Vec(), DIFF),//Frnt
Sphere(1e5, Vec(50, 1e5, 81.6), Vec(), Vec(.75, .75, .75), DIFF),//Botm
Sphere(1e5, Vec(50, -1e5 + 81.6, 81.6), Vec(), Vec(.75, .75, .75), DIFF),//Top
Sphere(16.5, Vec(27, 16.5, 47), Vec(), Vec(1, 1, 1) * .999, SPEC),//Mirr
Sphere(14.5, Vec(60, 46.5, 78), Vec(), Vec(1, 1, 1) * .999, REFR),//Glas
Sphere(600, Vec(50, 681.6 - .27, 81.6), Vec(12, 12, 12), Vec(), DIFF) //Lite
};
inline double clamp(double x) { return x < 0 ? 0 : x > 1 ? 1 : x; }
inline double removeNaN(double x) { return std::isnan(x) || x < 0.0 ? 0.0 : x; }
inline int toInt(double x) { return int(pow(clamp(x), 1 / 2.2) * 255 + .5); }
inline bool intersect(const Ray &r, double &t, int &id) {
double n = sizeof(spheres) / sizeof(Sphere), d, inf = t = 1e20;
for (int i = int(n); i--;)
if ((d = spheres[i].intersect(r)) && d < t) {
t = d;
id = i;
}
return t < inf;
}
struct PrimarySample {
double value;
double _backup;
uint64_t lastModificationIteration;
uint64_t lastModifiedBackup;
void backup() {
_backup = value;
lastModifiedBackup = lastModificationIteration;
}
void restore() {
value = _backup;
lastModificationIteration = lastModifiedBackup;
}
};
const double largeStepProb = 0.25;
struct RadianceRecord {
int x, y;
Vec Li;
RadianceRecord() {
x = y = 0;
};
};
struct Sampler {
unsigned int seed;
std::vector<PrimarySample> X;
uint64_t currentIteration = 0;
bool largeStep = true;
uint64_t lastLargeStepIteration = 0;
int w, h;
RadianceRecord current;
Sampler(int w, int h, unsigned int seed) : w(w), h(h), seed(seed) {}
uint32_t sampleIndex = 0;
uint64_t a = 0, r = 0;
void startIteration() {
sampleIndex = 0;
currentIteration++;
largeStep = uniform() < largeStepProb;
}
double uniform() {
return random(&seed);
}
void mutate(PrimarySample &Xi, int sampleIndex) {
double s1, s2;
if (sampleIndex >= 2) {
s1 = 1.0 / 1024.0, s2 = 1.0 / 64.0;
} else if (sampleIndex == 1) {
s1 = 1.0 / h, s2 = 0.1;
} else {
s1 = 1.0 / w, s2 = 0.1;
}
if (Xi.lastModificationIteration < lastLargeStepIteration) {
Xi.value = uniform();
Xi.lastModificationIteration = lastLargeStepIteration;
}
if (largeStep) {
Xi.backup();
Xi.value = uniform();
} else {
int64_t nSmall = currentIteration - Xi.lastModificationIteration;
auto nSmallMinus = nSmall - 1;
if (nSmallMinus > 0) {
auto x = Xi.value;
while (nSmallMinus > 0) {
nSmallMinus--;
x = mutate(x, s1, s2);
}
Xi.value = x;
Xi.lastModificationIteration = currentIteration - 1;
}
Xi.backup();
Xi.value = mutate(Xi.value, s1, s2);
}
Xi.lastModificationIteration = currentIteration;
}
double next() {
if (sampleIndex >= X.size()) {
X.resize(sampleIndex + 1u);
}
auto &Xi = X[sampleIndex];
mutate(Xi, sampleIndex);
sampleIndex += 1;
return Xi.value;
}
double mutate(double x, double s1, double s2) {
double r = uniform();
if (r < 0.5) {
r = r * 2.0;
x = x + s2 * exp(-log(s2 / s1) * r);
if (x > 1.0) x -= 1.0;
} else {
r = (r - 0.5) * 2.0;
x = x - s2 * exp(-log(s2 / s1) * r);
if (x < 0.0) x += 1.0;
}
return x;
}
void accept() {
if (largeStep) {
lastLargeStepIteration = currentIteration;
}
a++;
}
void reject() {
for (PrimarySample &Xi :X) {
if (Xi.lastModificationIteration == currentIteration) {
Xi.restore();
}
}
r++;
--currentIteration;
}
};
const float PI = 3.1415926535f;
float phase(float cosTheta){
return 1.0f/(4.0f * PI);
}
const float volDensity = 0.005;
Vec volColor(1,1,1);
Vec sampleSphere(float u1, float u2){
float phi = 2 * u2 * PI;
float theta = u1 * PI;
float cosTheta = cos(theta);
float sinTheta = sin(theta);
return Vec(sin(phi)*cosTheta,sinTheta,cos(phi)*cosTheta);
}
Vec radiance(Ray r, Sampler &sampler) {
double t; // distance to intersection
int id = 0; // id of intersected object
Vec cl(0, 0, 0); // accumulated color
Vec cf(1, 1, 1); // accumulated reflectance
int depth = 0;
bool medium = true;
while (true) {
double u1 = sampler.next(), u2 = sampler.next(), u3 = sampler.next();
double u4 = sampler.next(), u5 = sampler.next(), u6 = sampler.next();
if (!intersect(r, t, id)) return cl; // if miss, return black
if(medium){
Vec Tr(1,1,1);
double dist = -std::log(1 - u6) / volDensity;
bool sampled = dist < t;
double pdf = volDensity;
Tr = Tr.mult(volColor * exp(-volDensity * std::min(t, dist)));
cf = cf.mult(Tr);
if(sampled){
Vec x = r.o + r.d * dist;
Vec d = sampleSphere(u4,u5);
cf = cf * phase(r.d.dot(d));
cf = cf * (4 * PI);
r = Ray(x, d);depth++;
continue;
}
}
const Sphere &obj = spheres[id]; // the hit object
Vec x = r.o + r.d * t, n = (x - obj.p).norm(), nl = n.dot(r.d) < 0 ? n : n * -1, f = obj.c;
double p = f.x > f.y && f.x > f.z ? f.x : f.y > f.z ? f.y : f.z; // max refl
cl = cl + cf.mult(obj.e);
if (++depth > 5) if (u3 < p) f = f * (1 / p); else { return cl; } //R.R.
cf = cf.mult(f);
if (obj.refl == DIFF) { // Ideal DIFFUSE reflection
double r1 = 2 * M_PI * u1, r2 = u2, r2s = sqrt(r2);
Vec w = nl, u = ((fabs(w.x) > .1 ? Vec(0, 1) : Vec(1)) % w).norm(), v = w % u;
Vec d = (u * cos(r1) * r2s + v * sin(r1) * r2s + w * sqrt(1 - r2)).norm();
//return obj.e + f.mult(radiance(Ray(x,d),depth,Xi));
r = Ray(x, d);
continue;
} else if (obj.refl == SPEC) { // Ideal SPECULAR reflection
//return obj.e + f.mult(radiance(Ray(x,r.d-n*2*n.dot(r.d)),depth,Xi));
r = Ray(x, r.d - n * 2 * n.dot(r.d));
continue;
}
Ray reflRay(x, r.d - n * 2 * n.dot(r.d)); // Ideal dielectric REFRACTION
bool into = n.dot(nl) > 0; // Ray from outside going in?
double nc = 1, nt = 1.5, nnt = into ? nc / nt : nt / nc, ddn = r.d.dot(nl), cos2t;
medium = !into;
if ((cos2t = 1 - nnt * nnt * (1 - ddn * ddn)) < 0) { // Total internal reflection
//return obj.e + f.mult(radiance(reflRay,depth,Xi));
r = reflRay;
continue;
}
Vec tdir = (r.d * nnt - n * ((into ? 1 : -1) * (ddn * nnt + sqrt(cos2t)))).norm();
double a = nt - nc, b = nt + nc, R0 = a * a / (b * b), c = 1 - (into ? -ddn : tdir.dot(n));
double Re = R0 + (1 - R0) * c * c * c * c * c, Tr = 1 - Re, P = .25 + .5 * Re, RP = Re / P, TP = Tr / (1 - P);
// return obj.e + f.mult(sampler.next()<P ?
// radiance(reflRay, depth,Xi)*RP:
// radiance(Ray(x,tdir),depth,Xi)*TP);
if (u1 < P) {
cf = cf * RP;
r = reflRay;
} else {
cf = cf * TP;
r = Ray(x, tdir);
}
}
}
Vec radiance(int x, int y, int w, int h, Sampler &sampler) {
Ray cam(Vec(50, 52, 295.6), Vec(0, -0.042612, -1).norm()); // cam pos, dir
Vec cx = Vec(w * .5135 / h), cy = (cx % cam.d).norm() * .5135;
double r1 = 2 * sampler.next(), dx = r1 < 1 ? sqrt(r1) - 1 : 1 - sqrt(2 - r1);
double r2 = 2 * sampler.next(), dy = r2 < 1 ? sqrt(r2) - 1 : 1 - sqrt(2 - r2);
Vec d = cx * (((1 + dx) / 2 + x) / w - .5) +
cy * (((1 + dy) / 2 + y) / h - .5) + cam.d;
return radiance(Ray(cam.o + d * 140, d.norm()), sampler);
}
RadianceRecord radiance(Sampler &sampler, bool bootstrap) {
if (!bootstrap)
sampler.startIteration();
double x = sampler.next();
double y = sampler.next();
RadianceRecord record;
record.x = std::min<int>(sampler.w - 1, lround(x * sampler.w));
record.y = std::min<int>(sampler.h - 1, lround(y * sampler.h));
record.Li = radiance(record.x, record.y, sampler.w, sampler.h, sampler);
return record;
}
double b;
double ScalarContributionFunction(const Vec &Li) {
return 0.2126 * Li.x + 0.7152 * Li.y + 0.0722 * Li.z;
}
void RunMarkovChain(Sampler &sampler, RadianceRecord &r1, RadianceRecord &r2) {
auto r = radiance(sampler, false);
double accept = std::max(0.0,
std::min(1.0,
ScalarContributionFunction(r.Li) /
ScalarContributionFunction(sampler.current.Li)));
double weight1 = (accept + (sampler.largeStep ? 1.0 : 0.0))
/ (ScalarContributionFunction(r.Li) / b + largeStepProb);
double weight2 = (1 - accept)
/ (ScalarContributionFunction(sampler.current.Li) / b + largeStepProb);
r1.x = r.x;
r1.y = r.y;
r1.Li = r.Li * weight1;
r2.x = sampler.current.x;
r2.y = sampler.current.y;
r2.Li = sampler.current.Li * weight2;
if (accept == 1 || sampler.uniform() < accept) {
sampler.accept();
sampler.current = r;
} else {
sampler.reject();
}
}
uint32_t nBootstrap = 100000;
inline uint64_t floatToBits(double f) {
uint64_t ui;
memcpy(&ui, &f, sizeof(double));
return ui;
}
inline double bitsToFloat(uint64_t ui) {
double f;
memcpy(&f, &ui, sizeof(uint64_t));
return f;
}
class AtomicFloat {
public:
AtomicFloat(double v = 0) { bits = floatToBits(v); }
AtomicFloat(const AtomicFloat &rhs) {
bits.store(rhs.bits.load(std::memory_order_relaxed), std::memory_order_relaxed);
}
operator double() const { return bitsToFloat(bits); }
double operator=(double v) {
bits = floatToBits(v);
return v;
}
AtomicFloat &operator=(const AtomicFloat &rhs) {
bits.store(rhs.bits.load(std::memory_order_relaxed), std::memory_order_relaxed);
return *this;
}
void add(double v) {
uint64_t oldBits = bits, newBits;
do {
newBits = floatToBits(bitsToFloat(oldBits) + v);
} while (!bits.compare_exchange_weak(oldBits, newBits));
}
void store(double v) {
bits.store(floatToBits(v), std::memory_order_relaxed);
}
private:
std::atomic<uint64_t> bits;
};
struct AtomicVec {
AtomicFloat x, y, z;
void splat(const Vec &c) {
x.add(c.x);
y.add(c.y);
z.add(c.z);
}
};
int main(int argc, char *argv[]) {
int w = 1024/2, h = 768/2, samps = argc == 2 ? atoi(argv[1]) : 4; // # samples
uint32_t nChains = 2048;
uint32_t nMutations = std::ceil(double(w) * h * samps / nChains);
std::vector<uint32_t> seeds;
for (int i = 0; i < nBootstrap; i++) {
seeds.emplace_back(rand());
}
std::vector<double> weights;
for (int i = 0; i < nBootstrap; i++) {
Sampler sampler(w, h, seeds[i]);
weights.emplace_back(ScalarContributionFunction(radiance(sampler, true).Li));
}
std::vector<double> cdf;
cdf.emplace_back(0);
for (auto &i: weights) {
cdf.emplace_back(cdf.back() + i);
}
b = cdf.back() / nBootstrap;
printf("nChains = %d, nMutations = %d\nb = %lf\n", nChains, nMutations, b);
std::vector<AtomicVec> c(w * h);
std::atomic<uint64_t> totalMutations(0);
unsigned int mainSeed = rand();
auto write = [&](const RadianceRecord &record) {
auto &r = record.Li;
int i = (h - record.y - 1) * w + record.x;
c[i].splat(Vec(removeNaN(r.x), removeNaN(r.y), removeNaN(r.z)));
};
std::mutex mutex;
int32_t count = 0;
#pragma omp parallel for schedule(dynamic, 1)
for (int i = 0; i < nChains; i++) {
double r = random(&mainSeed) * cdf.back();
int k = 1;
for (; k <= nBootstrap; k++) {
if (cdf[k - 1] < r && r <= cdf[k]) {
break;
}
}
k -= 1;
Sampler sampler(w, h, seeds[k]);
sampler.current = radiance(sampler, true); // retrace path
sampler.seed = rand(); // reseeding
for (int m = 0; m < nMutations; m++) {
RadianceRecord r1, r2;
RunMarkovChain(sampler, r1, r2);
write(r1);
write(r2);
totalMutations++;
}
{
std::lock_guard<std::mutex> lockGuard(mutex);
count++;
printf("Done markov chain %d/%d, acceptance rate %lf\n", count, nChains,
double(sampler.a) / double(sampler.a + sampler.r));
}
}
for (auto &i:c) {
i.x = i.x * (1.0 / double(samps));
i.y = i.y * (1.0 / double(samps));
i.z = i.z * (1.0 / double(samps));
}
FILE *f = fopen("image.ppm", "w"); // Write image to PPM file.
fprintf(f, "P3\n%d %d\n%d\n", w, h, 255);
for (int i = 0; i < w * h; i++)
fprintf(f, "%d %d %d ", toInt(c[i].x), toInt(c[i].y), toInt(c[i].z));
}
| 32.032
| 118
| 0.512113
|
shiinamiyuki
|
7313c68973add89f0ddad04b9a5810fa63df0790
| 3,495
|
cpp
|
C++
|
lib/RiGto/RiGtoSet.cpp
|
cmartinaf/open-gto
|
c673552a16c9ebe79a42c2a27ddc4cbd8e6b724d
|
[
"BSD-3-Clause"
] | 8
|
2015-03-20T07:57:09.000Z
|
2021-02-13T22:20:04.000Z
|
lib/RiGto/RiGtoSet.cpp
|
cmartinaf/open-gto
|
c673552a16c9ebe79a42c2a27ddc4cbd8e6b724d
|
[
"BSD-3-Clause"
] | null | null | null |
lib/RiGto/RiGtoSet.cpp
|
cmartinaf/open-gto
|
c673552a16c9ebe79a42c2a27ddc4cbd8e6b724d
|
[
"BSD-3-Clause"
] | 3
|
2015-02-11T17:44:16.000Z
|
2019-11-29T12:26:07.000Z
|
//
// Copyright (c) 2009, Tweak Software
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
//
// * Redistributions of source code must retain the above
// copyright notice, this list of conditions and the following
// disclaimer.
//
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following
// disclaimer in the documentation and/or other materials
// provided with the distribution.
//
// * Neither the name of the Tweak Software 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 Tweak Software ''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 Tweak Software 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 <RiGto/RiGtoSet.h>
namespace RiGto {
//******************************************************************************
Set::Set( const std::string &ref,
const std::string &open,
const std::string &close )
: m_ref( ref ),
m_open( open ),
m_close( close )
{
// Nothing
}
//******************************************************************************
Set::~Set()
{
std::vector<Object *>::iterator iter = m_objects.begin();
for ( ; iter != m_objects.end(); ++iter )
{
delete (*iter);
}
}
//******************************************************************************
void Set::doneReading( ReaderPhase rp )
{
std::vector<Object *>::iterator iter = m_objects.begin();
for ( ; iter != m_objects.end(); ++iter )
{
(*iter)->doneReading( rp );
}
}
//******************************************************************************
Object *Set::object( const std::string &name )
{
std::vector<Object *>::const_iterator iter = m_objects.begin();
for ( ; iter != m_objects.end(); ++iter )
{
if ( (*iter)->name() == name )
{
return (*iter);
}
}
return NULL;
}
//******************************************************************************
void Set::declareRi( const OnOffList &onList,
const OnOffList &offList,
const OnOffList &onList2,
const OnOffList &offList2 ) const
{
std::vector<Object *>::const_iterator iter = m_objects.begin();
for ( ; iter != m_objects.end(); ++iter )
{
if ( onList.has( (*iter)->name() ) &&
onList2.has( (*iter)->name() ) &&
! offList.has( (*iter)->name() ) &&
! offList2.has( (*iter)->name() ) )
{
(*iter)->declareRi();
}
}
}
} // End namespace RiGto
| 32.663551
| 80
| 0.546209
|
cmartinaf
|
7314ebc2c980d79fa0bbb381775a016c107d5f95
| 1,004,280
|
cpp
|
C++
|
test/bidi_test_147.cpp
|
eightysquirrels/text
|
d935545648777786dc196a75346cde8906da846a
|
[
"BSL-1.0"
] | null | null | null |
test/bidi_test_147.cpp
|
eightysquirrels/text
|
d935545648777786dc196a75346cde8906da846a
|
[
"BSL-1.0"
] | 1
|
2021-03-05T12:56:59.000Z
|
2021-03-05T13:11:53.000Z
|
test/bidi_test_147.cpp
|
eightysquirrels/text
|
d935545648777786dc196a75346cde8906da846a
|
[
"BSL-1.0"
] | 3
|
2019-10-30T18:38:15.000Z
|
2021-03-05T12:10:13.000Z
|
// Warning! This file is autogenerated.
#include <boost/text/bidirectional.hpp>
#include "bidi_tests.hpp"
#include <gtest/gtest.h>
#include <algorithm>
std::vector<int> expected_levels;
std::vector<int> expected_reordered_indices;
TEST(bidi, bidi_147_000)
{
expected_levels = { 1, 1, -1, -1 };
expected_reordered_indices = { 1, 0 };
{
// S PDI BN PDF; 4 ('RTL') (line 73501)
std::vector<uint32_t> const cps = { 0x0009, 0x2069, 0x00AD, 0x202C };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// S PDI BN BN; 4 ('RTL') (line 73502)
std::vector<uint32_t> const cps = { 0x0009, 0x2069, 0x00AD, 0x00AD };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS R LRE LRE; 5 ('auto') (line 73503)
std::vector<uint32_t> const cps = { 0x0020, 0x05BE, 0x202A, 0x202A };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), -1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), -1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, -1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS R LRE LRE; 5 ('RTL') (line 73503)
std::vector<uint32_t> const cps = { 0x0020, 0x05BE, 0x202A, 0x202A };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS R LRE LRO; 5 ('auto') (line 73504)
std::vector<uint32_t> const cps = { 0x0020, 0x05BE, 0x202A, 0x202D };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), -1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), -1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, -1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS R LRE LRO; 5 ('RTL') (line 73504)
std::vector<uint32_t> const cps = { 0x0020, 0x05BE, 0x202A, 0x202D };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS R LRE RLE; 5 ('auto') (line 73505)
std::vector<uint32_t> const cps = { 0x0020, 0x05BE, 0x202A, 0x202B };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), -1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), -1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, -1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS R LRE RLE; 5 ('RTL') (line 73505)
std::vector<uint32_t> const cps = { 0x0020, 0x05BE, 0x202A, 0x202B };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS R LRE RLO; 5 ('auto') (line 73506)
std::vector<uint32_t> const cps = { 0x0020, 0x05BE, 0x202A, 0x202E };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), -1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), -1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, -1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS R LRE RLO; 5 ('RTL') (line 73506)
std::vector<uint32_t> const cps = { 0x0020, 0x05BE, 0x202A, 0x202E };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS R LRE PDF; 5 ('auto') (line 73507)
std::vector<uint32_t> const cps = { 0x0020, 0x05BE, 0x202A, 0x202C };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), -1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), -1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, -1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS R LRE PDF; 5 ('RTL') (line 73507)
std::vector<uint32_t> const cps = { 0x0020, 0x05BE, 0x202A, 0x202C };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS R LRE BN; 5 ('auto') (line 73508)
std::vector<uint32_t> const cps = { 0x0020, 0x05BE, 0x202A, 0x00AD };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), -1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), -1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, -1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS R LRE BN; 5 ('RTL') (line 73508)
std::vector<uint32_t> const cps = { 0x0020, 0x05BE, 0x202A, 0x00AD };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS R LRO LRE; 5 ('auto') (line 73509)
std::vector<uint32_t> const cps = { 0x0020, 0x05BE, 0x202D, 0x202A };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), -1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), -1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, -1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS R LRO LRE; 5 ('RTL') (line 73509)
std::vector<uint32_t> const cps = { 0x0020, 0x05BE, 0x202D, 0x202A };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS R LRO LRO; 5 ('auto') (line 73510)
std::vector<uint32_t> const cps = { 0x0020, 0x05BE, 0x202D, 0x202D };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), -1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), -1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, -1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS R LRO LRO; 5 ('RTL') (line 73510)
std::vector<uint32_t> const cps = { 0x0020, 0x05BE, 0x202D, 0x202D };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
}
TEST(bidi, bidi_147_001)
{
expected_levels = { 1, 1, -1, -1 };
expected_reordered_indices = { 1, 0 };
{
// WS R LRO RLE; 5 ('auto') (line 73511)
std::vector<uint32_t> const cps = { 0x0020, 0x05BE, 0x202D, 0x202B };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), -1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), -1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, -1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS R LRO RLE; 5 ('RTL') (line 73511)
std::vector<uint32_t> const cps = { 0x0020, 0x05BE, 0x202D, 0x202B };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS R LRO RLO; 5 ('auto') (line 73512)
std::vector<uint32_t> const cps = { 0x0020, 0x05BE, 0x202D, 0x202E };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), -1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), -1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, -1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS R LRO RLO; 5 ('RTL') (line 73512)
std::vector<uint32_t> const cps = { 0x0020, 0x05BE, 0x202D, 0x202E };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS R LRO PDF; 5 ('auto') (line 73513)
std::vector<uint32_t> const cps = { 0x0020, 0x05BE, 0x202D, 0x202C };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), -1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), -1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, -1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS R LRO PDF; 5 ('RTL') (line 73513)
std::vector<uint32_t> const cps = { 0x0020, 0x05BE, 0x202D, 0x202C };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS R LRO BN; 5 ('auto') (line 73514)
std::vector<uint32_t> const cps = { 0x0020, 0x05BE, 0x202D, 0x00AD };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), -1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), -1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, -1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS R LRO BN; 5 ('RTL') (line 73514)
std::vector<uint32_t> const cps = { 0x0020, 0x05BE, 0x202D, 0x00AD };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS R RLE LRE; 5 ('auto') (line 73515)
std::vector<uint32_t> const cps = { 0x0020, 0x05BE, 0x202B, 0x202A };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), -1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), -1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, -1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS R RLE LRE; 5 ('RTL') (line 73515)
std::vector<uint32_t> const cps = { 0x0020, 0x05BE, 0x202B, 0x202A };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS R RLE LRO; 5 ('auto') (line 73516)
std::vector<uint32_t> const cps = { 0x0020, 0x05BE, 0x202B, 0x202D };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), -1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), -1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, -1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS R RLE LRO; 5 ('RTL') (line 73516)
std::vector<uint32_t> const cps = { 0x0020, 0x05BE, 0x202B, 0x202D };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS R RLE RLE; 5 ('auto') (line 73517)
std::vector<uint32_t> const cps = { 0x0020, 0x05BE, 0x202B, 0x202B };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), -1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), -1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, -1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS R RLE RLE; 5 ('RTL') (line 73517)
std::vector<uint32_t> const cps = { 0x0020, 0x05BE, 0x202B, 0x202B };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS R RLE RLO; 5 ('auto') (line 73518)
std::vector<uint32_t> const cps = { 0x0020, 0x05BE, 0x202B, 0x202E };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), -1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), -1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, -1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS R RLE RLO; 5 ('RTL') (line 73518)
std::vector<uint32_t> const cps = { 0x0020, 0x05BE, 0x202B, 0x202E };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS R RLE PDF; 5 ('auto') (line 73519)
std::vector<uint32_t> const cps = { 0x0020, 0x05BE, 0x202B, 0x202C };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), -1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), -1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, -1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS R RLE PDF; 5 ('RTL') (line 73519)
std::vector<uint32_t> const cps = { 0x0020, 0x05BE, 0x202B, 0x202C };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS R RLE BN; 5 ('auto') (line 73520)
std::vector<uint32_t> const cps = { 0x0020, 0x05BE, 0x202B, 0x00AD };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), -1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), -1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, -1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS R RLE BN; 5 ('RTL') (line 73520)
std::vector<uint32_t> const cps = { 0x0020, 0x05BE, 0x202B, 0x00AD };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
}
TEST(bidi, bidi_147_002)
{
expected_levels = { 1, 1, -1, -1 };
expected_reordered_indices = { 1, 0 };
{
// WS R RLO LRE; 5 ('auto') (line 73521)
std::vector<uint32_t> const cps = { 0x0020, 0x05BE, 0x202E, 0x202A };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), -1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), -1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, -1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS R RLO LRE; 5 ('RTL') (line 73521)
std::vector<uint32_t> const cps = { 0x0020, 0x05BE, 0x202E, 0x202A };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS R RLO LRO; 5 ('auto') (line 73522)
std::vector<uint32_t> const cps = { 0x0020, 0x05BE, 0x202E, 0x202D };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), -1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), -1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, -1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS R RLO LRO; 5 ('RTL') (line 73522)
std::vector<uint32_t> const cps = { 0x0020, 0x05BE, 0x202E, 0x202D };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS R RLO RLE; 5 ('auto') (line 73523)
std::vector<uint32_t> const cps = { 0x0020, 0x05BE, 0x202E, 0x202B };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), -1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), -1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, -1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS R RLO RLE; 5 ('RTL') (line 73523)
std::vector<uint32_t> const cps = { 0x0020, 0x05BE, 0x202E, 0x202B };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS R RLO RLO; 5 ('auto') (line 73524)
std::vector<uint32_t> const cps = { 0x0020, 0x05BE, 0x202E, 0x202E };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), -1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), -1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, -1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS R RLO RLO; 5 ('RTL') (line 73524)
std::vector<uint32_t> const cps = { 0x0020, 0x05BE, 0x202E, 0x202E };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS R RLO PDF; 5 ('auto') (line 73525)
std::vector<uint32_t> const cps = { 0x0020, 0x05BE, 0x202E, 0x202C };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), -1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), -1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, -1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS R RLO PDF; 5 ('RTL') (line 73525)
std::vector<uint32_t> const cps = { 0x0020, 0x05BE, 0x202E, 0x202C };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS R RLO BN; 5 ('auto') (line 73526)
std::vector<uint32_t> const cps = { 0x0020, 0x05BE, 0x202E, 0x00AD };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), -1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), -1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, -1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS R RLO BN; 5 ('RTL') (line 73526)
std::vector<uint32_t> const cps = { 0x0020, 0x05BE, 0x202E, 0x00AD };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS R PDF LRE; 5 ('auto') (line 73527)
std::vector<uint32_t> const cps = { 0x0020, 0x05BE, 0x202C, 0x202A };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), -1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), -1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, -1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS R PDF LRE; 5 ('RTL') (line 73527)
std::vector<uint32_t> const cps = { 0x0020, 0x05BE, 0x202C, 0x202A };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS R PDF LRO; 5 ('auto') (line 73528)
std::vector<uint32_t> const cps = { 0x0020, 0x05BE, 0x202C, 0x202D };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), -1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), -1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, -1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS R PDF LRO; 5 ('RTL') (line 73528)
std::vector<uint32_t> const cps = { 0x0020, 0x05BE, 0x202C, 0x202D };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS R PDF RLE; 5 ('auto') (line 73529)
std::vector<uint32_t> const cps = { 0x0020, 0x05BE, 0x202C, 0x202B };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), -1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), -1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, -1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS R PDF RLE; 5 ('RTL') (line 73529)
std::vector<uint32_t> const cps = { 0x0020, 0x05BE, 0x202C, 0x202B };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS R PDF RLO; 5 ('auto') (line 73530)
std::vector<uint32_t> const cps = { 0x0020, 0x05BE, 0x202C, 0x202E };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), -1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), -1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, -1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS R PDF RLO; 5 ('RTL') (line 73530)
std::vector<uint32_t> const cps = { 0x0020, 0x05BE, 0x202C, 0x202E };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
}
TEST(bidi, bidi_147_003)
{
expected_levels = { 1, 1, -1, -1 };
expected_reordered_indices = { 1, 0 };
{
// WS R PDF PDF; 5 ('auto') (line 73531)
std::vector<uint32_t> const cps = { 0x0020, 0x05BE, 0x202C, 0x202C };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), -1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), -1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, -1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS R PDF PDF; 5 ('RTL') (line 73531)
std::vector<uint32_t> const cps = { 0x0020, 0x05BE, 0x202C, 0x202C };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS R PDF BN; 5 ('auto') (line 73532)
std::vector<uint32_t> const cps = { 0x0020, 0x05BE, 0x202C, 0x00AD };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), -1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), -1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, -1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS R PDF BN; 5 ('RTL') (line 73532)
std::vector<uint32_t> const cps = { 0x0020, 0x05BE, 0x202C, 0x00AD };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS R BN LRE; 5 ('auto') (line 73533)
std::vector<uint32_t> const cps = { 0x0020, 0x05BE, 0x00AD, 0x202A };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), -1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), -1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, -1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS R BN LRE; 5 ('RTL') (line 73533)
std::vector<uint32_t> const cps = { 0x0020, 0x05BE, 0x00AD, 0x202A };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS R BN LRO; 5 ('auto') (line 73534)
std::vector<uint32_t> const cps = { 0x0020, 0x05BE, 0x00AD, 0x202D };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), -1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), -1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, -1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS R BN LRO; 5 ('RTL') (line 73534)
std::vector<uint32_t> const cps = { 0x0020, 0x05BE, 0x00AD, 0x202D };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS R BN RLE; 5 ('auto') (line 73535)
std::vector<uint32_t> const cps = { 0x0020, 0x05BE, 0x00AD, 0x202B };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), -1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), -1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, -1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS R BN RLE; 5 ('RTL') (line 73535)
std::vector<uint32_t> const cps = { 0x0020, 0x05BE, 0x00AD, 0x202B };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS R BN RLO; 5 ('auto') (line 73536)
std::vector<uint32_t> const cps = { 0x0020, 0x05BE, 0x00AD, 0x202E };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), -1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), -1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, -1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS R BN RLO; 5 ('RTL') (line 73536)
std::vector<uint32_t> const cps = { 0x0020, 0x05BE, 0x00AD, 0x202E };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS R BN PDF; 5 ('auto') (line 73537)
std::vector<uint32_t> const cps = { 0x0020, 0x05BE, 0x00AD, 0x202C };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), -1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), -1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, -1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS R BN PDF; 5 ('RTL') (line 73537)
std::vector<uint32_t> const cps = { 0x0020, 0x05BE, 0x00AD, 0x202C };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS R BN BN; 5 ('auto') (line 73538)
std::vector<uint32_t> const cps = { 0x0020, 0x05BE, 0x00AD, 0x00AD };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), -1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), -1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, -1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS R BN BN; 5 ('RTL') (line 73538)
std::vector<uint32_t> const cps = { 0x0020, 0x05BE, 0x00AD, 0x00AD };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS AL LRE LRE; 5 ('auto') (line 73539)
std::vector<uint32_t> const cps = { 0x0020, 0x0608, 0x202A, 0x202A };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), -1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), -1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, -1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS AL LRE LRE; 5 ('RTL') (line 73539)
std::vector<uint32_t> const cps = { 0x0020, 0x0608, 0x202A, 0x202A };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS AL LRE LRO; 5 ('auto') (line 73540)
std::vector<uint32_t> const cps = { 0x0020, 0x0608, 0x202A, 0x202D };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), -1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), -1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, -1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS AL LRE LRO; 5 ('RTL') (line 73540)
std::vector<uint32_t> const cps = { 0x0020, 0x0608, 0x202A, 0x202D };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
}
TEST(bidi, bidi_147_004)
{
expected_levels = { 1, 1, -1, -1 };
expected_reordered_indices = { 1, 0 };
{
// WS AL LRE RLE; 5 ('auto') (line 73541)
std::vector<uint32_t> const cps = { 0x0020, 0x0608, 0x202A, 0x202B };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), -1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), -1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, -1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS AL LRE RLE; 5 ('RTL') (line 73541)
std::vector<uint32_t> const cps = { 0x0020, 0x0608, 0x202A, 0x202B };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS AL LRE RLO; 5 ('auto') (line 73542)
std::vector<uint32_t> const cps = { 0x0020, 0x0608, 0x202A, 0x202E };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), -1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), -1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, -1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS AL LRE RLO; 5 ('RTL') (line 73542)
std::vector<uint32_t> const cps = { 0x0020, 0x0608, 0x202A, 0x202E };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS AL LRE PDF; 5 ('auto') (line 73543)
std::vector<uint32_t> const cps = { 0x0020, 0x0608, 0x202A, 0x202C };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), -1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), -1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, -1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS AL LRE PDF; 5 ('RTL') (line 73543)
std::vector<uint32_t> const cps = { 0x0020, 0x0608, 0x202A, 0x202C };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS AL LRE BN; 5 ('auto') (line 73544)
std::vector<uint32_t> const cps = { 0x0020, 0x0608, 0x202A, 0x00AD };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), -1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), -1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, -1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS AL LRE BN; 5 ('RTL') (line 73544)
std::vector<uint32_t> const cps = { 0x0020, 0x0608, 0x202A, 0x00AD };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS AL LRO LRE; 5 ('auto') (line 73545)
std::vector<uint32_t> const cps = { 0x0020, 0x0608, 0x202D, 0x202A };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), -1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), -1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, -1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS AL LRO LRE; 5 ('RTL') (line 73545)
std::vector<uint32_t> const cps = { 0x0020, 0x0608, 0x202D, 0x202A };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS AL LRO LRO; 5 ('auto') (line 73546)
std::vector<uint32_t> const cps = { 0x0020, 0x0608, 0x202D, 0x202D };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), -1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), -1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, -1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS AL LRO LRO; 5 ('RTL') (line 73546)
std::vector<uint32_t> const cps = { 0x0020, 0x0608, 0x202D, 0x202D };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS AL LRO RLE; 5 ('auto') (line 73547)
std::vector<uint32_t> const cps = { 0x0020, 0x0608, 0x202D, 0x202B };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), -1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), -1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, -1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS AL LRO RLE; 5 ('RTL') (line 73547)
std::vector<uint32_t> const cps = { 0x0020, 0x0608, 0x202D, 0x202B };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS AL LRO RLO; 5 ('auto') (line 73548)
std::vector<uint32_t> const cps = { 0x0020, 0x0608, 0x202D, 0x202E };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), -1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), -1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, -1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS AL LRO RLO; 5 ('RTL') (line 73548)
std::vector<uint32_t> const cps = { 0x0020, 0x0608, 0x202D, 0x202E };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS AL LRO PDF; 5 ('auto') (line 73549)
std::vector<uint32_t> const cps = { 0x0020, 0x0608, 0x202D, 0x202C };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), -1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), -1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, -1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS AL LRO PDF; 5 ('RTL') (line 73549)
std::vector<uint32_t> const cps = { 0x0020, 0x0608, 0x202D, 0x202C };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS AL LRO BN; 5 ('auto') (line 73550)
std::vector<uint32_t> const cps = { 0x0020, 0x0608, 0x202D, 0x00AD };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), -1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), -1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, -1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS AL LRO BN; 5 ('RTL') (line 73550)
std::vector<uint32_t> const cps = { 0x0020, 0x0608, 0x202D, 0x00AD };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
}
TEST(bidi, bidi_147_005)
{
expected_levels = { 1, 1, -1, -1 };
expected_reordered_indices = { 1, 0 };
{
// WS AL RLE LRE; 5 ('auto') (line 73551)
std::vector<uint32_t> const cps = { 0x0020, 0x0608, 0x202B, 0x202A };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), -1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), -1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, -1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS AL RLE LRE; 5 ('RTL') (line 73551)
std::vector<uint32_t> const cps = { 0x0020, 0x0608, 0x202B, 0x202A };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS AL RLE LRO; 5 ('auto') (line 73552)
std::vector<uint32_t> const cps = { 0x0020, 0x0608, 0x202B, 0x202D };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), -1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), -1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, -1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS AL RLE LRO; 5 ('RTL') (line 73552)
std::vector<uint32_t> const cps = { 0x0020, 0x0608, 0x202B, 0x202D };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS AL RLE RLE; 5 ('auto') (line 73553)
std::vector<uint32_t> const cps = { 0x0020, 0x0608, 0x202B, 0x202B };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), -1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), -1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, -1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS AL RLE RLE; 5 ('RTL') (line 73553)
std::vector<uint32_t> const cps = { 0x0020, 0x0608, 0x202B, 0x202B };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS AL RLE RLO; 5 ('auto') (line 73554)
std::vector<uint32_t> const cps = { 0x0020, 0x0608, 0x202B, 0x202E };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), -1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), -1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, -1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS AL RLE RLO; 5 ('RTL') (line 73554)
std::vector<uint32_t> const cps = { 0x0020, 0x0608, 0x202B, 0x202E };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS AL RLE PDF; 5 ('auto') (line 73555)
std::vector<uint32_t> const cps = { 0x0020, 0x0608, 0x202B, 0x202C };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), -1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), -1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, -1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS AL RLE PDF; 5 ('RTL') (line 73555)
std::vector<uint32_t> const cps = { 0x0020, 0x0608, 0x202B, 0x202C };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS AL RLE BN; 5 ('auto') (line 73556)
std::vector<uint32_t> const cps = { 0x0020, 0x0608, 0x202B, 0x00AD };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), -1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), -1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, -1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS AL RLE BN; 5 ('RTL') (line 73556)
std::vector<uint32_t> const cps = { 0x0020, 0x0608, 0x202B, 0x00AD };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS AL RLO LRE; 5 ('auto') (line 73557)
std::vector<uint32_t> const cps = { 0x0020, 0x0608, 0x202E, 0x202A };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), -1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), -1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, -1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS AL RLO LRE; 5 ('RTL') (line 73557)
std::vector<uint32_t> const cps = { 0x0020, 0x0608, 0x202E, 0x202A };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS AL RLO LRO; 5 ('auto') (line 73558)
std::vector<uint32_t> const cps = { 0x0020, 0x0608, 0x202E, 0x202D };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), -1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), -1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, -1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS AL RLO LRO; 5 ('RTL') (line 73558)
std::vector<uint32_t> const cps = { 0x0020, 0x0608, 0x202E, 0x202D };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS AL RLO RLE; 5 ('auto') (line 73559)
std::vector<uint32_t> const cps = { 0x0020, 0x0608, 0x202E, 0x202B };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), -1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), -1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, -1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS AL RLO RLE; 5 ('RTL') (line 73559)
std::vector<uint32_t> const cps = { 0x0020, 0x0608, 0x202E, 0x202B };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS AL RLO RLO; 5 ('auto') (line 73560)
std::vector<uint32_t> const cps = { 0x0020, 0x0608, 0x202E, 0x202E };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), -1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), -1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, -1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS AL RLO RLO; 5 ('RTL') (line 73560)
std::vector<uint32_t> const cps = { 0x0020, 0x0608, 0x202E, 0x202E };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
}
TEST(bidi, bidi_147_006)
{
expected_levels = { 1, 1, -1, -1 };
expected_reordered_indices = { 1, 0 };
{
// WS AL RLO PDF; 5 ('auto') (line 73561)
std::vector<uint32_t> const cps = { 0x0020, 0x0608, 0x202E, 0x202C };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), -1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), -1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, -1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS AL RLO PDF; 5 ('RTL') (line 73561)
std::vector<uint32_t> const cps = { 0x0020, 0x0608, 0x202E, 0x202C };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS AL RLO BN; 5 ('auto') (line 73562)
std::vector<uint32_t> const cps = { 0x0020, 0x0608, 0x202E, 0x00AD };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), -1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), -1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, -1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS AL RLO BN; 5 ('RTL') (line 73562)
std::vector<uint32_t> const cps = { 0x0020, 0x0608, 0x202E, 0x00AD };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS AL PDF LRE; 5 ('auto') (line 73563)
std::vector<uint32_t> const cps = { 0x0020, 0x0608, 0x202C, 0x202A };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), -1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), -1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, -1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS AL PDF LRE; 5 ('RTL') (line 73563)
std::vector<uint32_t> const cps = { 0x0020, 0x0608, 0x202C, 0x202A };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS AL PDF LRO; 5 ('auto') (line 73564)
std::vector<uint32_t> const cps = { 0x0020, 0x0608, 0x202C, 0x202D };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), -1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), -1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, -1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS AL PDF LRO; 5 ('RTL') (line 73564)
std::vector<uint32_t> const cps = { 0x0020, 0x0608, 0x202C, 0x202D };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS AL PDF RLE; 5 ('auto') (line 73565)
std::vector<uint32_t> const cps = { 0x0020, 0x0608, 0x202C, 0x202B };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), -1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), -1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, -1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS AL PDF RLE; 5 ('RTL') (line 73565)
std::vector<uint32_t> const cps = { 0x0020, 0x0608, 0x202C, 0x202B };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS AL PDF RLO; 5 ('auto') (line 73566)
std::vector<uint32_t> const cps = { 0x0020, 0x0608, 0x202C, 0x202E };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), -1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), -1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, -1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS AL PDF RLO; 5 ('RTL') (line 73566)
std::vector<uint32_t> const cps = { 0x0020, 0x0608, 0x202C, 0x202E };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS AL PDF PDF; 5 ('auto') (line 73567)
std::vector<uint32_t> const cps = { 0x0020, 0x0608, 0x202C, 0x202C };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), -1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), -1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, -1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS AL PDF PDF; 5 ('RTL') (line 73567)
std::vector<uint32_t> const cps = { 0x0020, 0x0608, 0x202C, 0x202C };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS AL PDF BN; 5 ('auto') (line 73568)
std::vector<uint32_t> const cps = { 0x0020, 0x0608, 0x202C, 0x00AD };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), -1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), -1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, -1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS AL PDF BN; 5 ('RTL') (line 73568)
std::vector<uint32_t> const cps = { 0x0020, 0x0608, 0x202C, 0x00AD };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS AL BN LRE; 5 ('auto') (line 73569)
std::vector<uint32_t> const cps = { 0x0020, 0x0608, 0x00AD, 0x202A };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), -1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), -1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, -1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS AL BN LRE; 5 ('RTL') (line 73569)
std::vector<uint32_t> const cps = { 0x0020, 0x0608, 0x00AD, 0x202A };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS AL BN LRO; 5 ('auto') (line 73570)
std::vector<uint32_t> const cps = { 0x0020, 0x0608, 0x00AD, 0x202D };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), -1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), -1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, -1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS AL BN LRO; 5 ('RTL') (line 73570)
std::vector<uint32_t> const cps = { 0x0020, 0x0608, 0x00AD, 0x202D };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
}
TEST(bidi, bidi_147_007)
{
expected_levels = { 1, 1, -1, -1 };
expected_reordered_indices = { 1, 0 };
{
// WS AL BN RLE; 5 ('auto') (line 73571)
std::vector<uint32_t> const cps = { 0x0020, 0x0608, 0x00AD, 0x202B };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), -1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), -1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, -1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS AL BN RLE; 5 ('RTL') (line 73571)
std::vector<uint32_t> const cps = { 0x0020, 0x0608, 0x00AD, 0x202B };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS AL BN RLO; 5 ('auto') (line 73572)
std::vector<uint32_t> const cps = { 0x0020, 0x0608, 0x00AD, 0x202E };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), -1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), -1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, -1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS AL BN RLO; 5 ('RTL') (line 73572)
std::vector<uint32_t> const cps = { 0x0020, 0x0608, 0x00AD, 0x202E };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS AL BN PDF; 5 ('auto') (line 73573)
std::vector<uint32_t> const cps = { 0x0020, 0x0608, 0x00AD, 0x202C };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), -1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), -1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, -1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS AL BN PDF; 5 ('RTL') (line 73573)
std::vector<uint32_t> const cps = { 0x0020, 0x0608, 0x00AD, 0x202C };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS AL BN BN; 5 ('auto') (line 73574)
std::vector<uint32_t> const cps = { 0x0020, 0x0608, 0x00AD, 0x00AD };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), -1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), -1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, -1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS AL BN BN; 5 ('RTL') (line 73574)
std::vector<uint32_t> const cps = { 0x0020, 0x0608, 0x00AD, 0x00AD };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS ES LRE LRE; 4 ('RTL') (line 73575)
std::vector<uint32_t> const cps = { 0x0020, 0x002B, 0x202A, 0x202A };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS ES LRE LRO; 4 ('RTL') (line 73576)
std::vector<uint32_t> const cps = { 0x0020, 0x002B, 0x202A, 0x202D };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS ES LRE RLE; 4 ('RTL') (line 73577)
std::vector<uint32_t> const cps = { 0x0020, 0x002B, 0x202A, 0x202B };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS ES LRE RLO; 4 ('RTL') (line 73578)
std::vector<uint32_t> const cps = { 0x0020, 0x002B, 0x202A, 0x202E };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS ES LRE PDF; 4 ('RTL') (line 73579)
std::vector<uint32_t> const cps = { 0x0020, 0x002B, 0x202A, 0x202C };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS ES LRE BN; 4 ('RTL') (line 73580)
std::vector<uint32_t> const cps = { 0x0020, 0x002B, 0x202A, 0x00AD };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
}
TEST(bidi, bidi_147_008)
{
expected_levels = { 1, 1, -1, -1 };
expected_reordered_indices = { 1, 0 };
{
// WS ES LRO LRE; 4 ('RTL') (line 73581)
std::vector<uint32_t> const cps = { 0x0020, 0x002B, 0x202D, 0x202A };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS ES LRO LRO; 4 ('RTL') (line 73582)
std::vector<uint32_t> const cps = { 0x0020, 0x002B, 0x202D, 0x202D };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS ES LRO RLE; 4 ('RTL') (line 73583)
std::vector<uint32_t> const cps = { 0x0020, 0x002B, 0x202D, 0x202B };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS ES LRO RLO; 4 ('RTL') (line 73584)
std::vector<uint32_t> const cps = { 0x0020, 0x002B, 0x202D, 0x202E };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS ES LRO PDF; 4 ('RTL') (line 73585)
std::vector<uint32_t> const cps = { 0x0020, 0x002B, 0x202D, 0x202C };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS ES LRO BN; 4 ('RTL') (line 73586)
std::vector<uint32_t> const cps = { 0x0020, 0x002B, 0x202D, 0x00AD };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS ES RLE LRE; 4 ('RTL') (line 73587)
std::vector<uint32_t> const cps = { 0x0020, 0x002B, 0x202B, 0x202A };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS ES RLE LRO; 4 ('RTL') (line 73588)
std::vector<uint32_t> const cps = { 0x0020, 0x002B, 0x202B, 0x202D };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS ES RLE RLE; 4 ('RTL') (line 73589)
std::vector<uint32_t> const cps = { 0x0020, 0x002B, 0x202B, 0x202B };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS ES RLE RLO; 4 ('RTL') (line 73590)
std::vector<uint32_t> const cps = { 0x0020, 0x002B, 0x202B, 0x202E };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
}
TEST(bidi, bidi_147_009)
{
expected_levels = { 1, 1, -1, -1 };
expected_reordered_indices = { 1, 0 };
{
// WS ES RLE PDF; 4 ('RTL') (line 73591)
std::vector<uint32_t> const cps = { 0x0020, 0x002B, 0x202B, 0x202C };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS ES RLE BN; 4 ('RTL') (line 73592)
std::vector<uint32_t> const cps = { 0x0020, 0x002B, 0x202B, 0x00AD };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS ES RLO LRE; 4 ('RTL') (line 73593)
std::vector<uint32_t> const cps = { 0x0020, 0x002B, 0x202E, 0x202A };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS ES RLO LRO; 4 ('RTL') (line 73594)
std::vector<uint32_t> const cps = { 0x0020, 0x002B, 0x202E, 0x202D };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS ES RLO RLE; 4 ('RTL') (line 73595)
std::vector<uint32_t> const cps = { 0x0020, 0x002B, 0x202E, 0x202B };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS ES RLO RLO; 4 ('RTL') (line 73596)
std::vector<uint32_t> const cps = { 0x0020, 0x002B, 0x202E, 0x202E };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS ES RLO PDF; 4 ('RTL') (line 73597)
std::vector<uint32_t> const cps = { 0x0020, 0x002B, 0x202E, 0x202C };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS ES RLO BN; 4 ('RTL') (line 73598)
std::vector<uint32_t> const cps = { 0x0020, 0x002B, 0x202E, 0x00AD };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS ES PDF LRE; 4 ('RTL') (line 73599)
std::vector<uint32_t> const cps = { 0x0020, 0x002B, 0x202C, 0x202A };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS ES PDF LRO; 4 ('RTL') (line 73600)
std::vector<uint32_t> const cps = { 0x0020, 0x002B, 0x202C, 0x202D };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
}
TEST(bidi, bidi_147_010)
{
expected_levels = { 1, 1, -1, -1 };
expected_reordered_indices = { 1, 0 };
{
// WS ES PDF RLE; 4 ('RTL') (line 73601)
std::vector<uint32_t> const cps = { 0x0020, 0x002B, 0x202C, 0x202B };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS ES PDF RLO; 4 ('RTL') (line 73602)
std::vector<uint32_t> const cps = { 0x0020, 0x002B, 0x202C, 0x202E };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS ES PDF PDF; 4 ('RTL') (line 73603)
std::vector<uint32_t> const cps = { 0x0020, 0x002B, 0x202C, 0x202C };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS ES PDF BN; 4 ('RTL') (line 73604)
std::vector<uint32_t> const cps = { 0x0020, 0x002B, 0x202C, 0x00AD };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS ES BN LRE; 4 ('RTL') (line 73605)
std::vector<uint32_t> const cps = { 0x0020, 0x002B, 0x00AD, 0x202A };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS ES BN LRO; 4 ('RTL') (line 73606)
std::vector<uint32_t> const cps = { 0x0020, 0x002B, 0x00AD, 0x202D };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS ES BN RLE; 4 ('RTL') (line 73607)
std::vector<uint32_t> const cps = { 0x0020, 0x002B, 0x00AD, 0x202B };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS ES BN RLO; 4 ('RTL') (line 73608)
std::vector<uint32_t> const cps = { 0x0020, 0x002B, 0x00AD, 0x202E };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS ES BN PDF; 4 ('RTL') (line 73609)
std::vector<uint32_t> const cps = { 0x0020, 0x002B, 0x00AD, 0x202C };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS ES BN BN; 4 ('RTL') (line 73610)
std::vector<uint32_t> const cps = { 0x0020, 0x002B, 0x00AD, 0x00AD };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
}
TEST(bidi, bidi_147_011)
{
expected_levels = { 1, 1, -1, -1 };
expected_reordered_indices = { 1, 0 };
{
// WS ET LRE LRE; 4 ('RTL') (line 73611)
std::vector<uint32_t> const cps = { 0x0020, 0x0023, 0x202A, 0x202A };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS ET LRE LRO; 4 ('RTL') (line 73612)
std::vector<uint32_t> const cps = { 0x0020, 0x0023, 0x202A, 0x202D };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS ET LRE RLE; 4 ('RTL') (line 73613)
std::vector<uint32_t> const cps = { 0x0020, 0x0023, 0x202A, 0x202B };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS ET LRE RLO; 4 ('RTL') (line 73614)
std::vector<uint32_t> const cps = { 0x0020, 0x0023, 0x202A, 0x202E };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS ET LRE PDF; 4 ('RTL') (line 73615)
std::vector<uint32_t> const cps = { 0x0020, 0x0023, 0x202A, 0x202C };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS ET LRE BN; 4 ('RTL') (line 73616)
std::vector<uint32_t> const cps = { 0x0020, 0x0023, 0x202A, 0x00AD };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS ET LRO LRE; 4 ('RTL') (line 73617)
std::vector<uint32_t> const cps = { 0x0020, 0x0023, 0x202D, 0x202A };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS ET LRO LRO; 4 ('RTL') (line 73618)
std::vector<uint32_t> const cps = { 0x0020, 0x0023, 0x202D, 0x202D };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS ET LRO RLE; 4 ('RTL') (line 73619)
std::vector<uint32_t> const cps = { 0x0020, 0x0023, 0x202D, 0x202B };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS ET LRO RLO; 4 ('RTL') (line 73620)
std::vector<uint32_t> const cps = { 0x0020, 0x0023, 0x202D, 0x202E };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
}
TEST(bidi, bidi_147_012)
{
expected_levels = { 1, 1, -1, -1 };
expected_reordered_indices = { 1, 0 };
{
// WS ET LRO PDF; 4 ('RTL') (line 73621)
std::vector<uint32_t> const cps = { 0x0020, 0x0023, 0x202D, 0x202C };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS ET LRO BN; 4 ('RTL') (line 73622)
std::vector<uint32_t> const cps = { 0x0020, 0x0023, 0x202D, 0x00AD };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS ET RLE LRE; 4 ('RTL') (line 73623)
std::vector<uint32_t> const cps = { 0x0020, 0x0023, 0x202B, 0x202A };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS ET RLE LRO; 4 ('RTL') (line 73624)
std::vector<uint32_t> const cps = { 0x0020, 0x0023, 0x202B, 0x202D };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS ET RLE RLE; 4 ('RTL') (line 73625)
std::vector<uint32_t> const cps = { 0x0020, 0x0023, 0x202B, 0x202B };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS ET RLE RLO; 4 ('RTL') (line 73626)
std::vector<uint32_t> const cps = { 0x0020, 0x0023, 0x202B, 0x202E };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS ET RLE PDF; 4 ('RTL') (line 73627)
std::vector<uint32_t> const cps = { 0x0020, 0x0023, 0x202B, 0x202C };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS ET RLE BN; 4 ('RTL') (line 73628)
std::vector<uint32_t> const cps = { 0x0020, 0x0023, 0x202B, 0x00AD };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS ET RLO LRE; 4 ('RTL') (line 73629)
std::vector<uint32_t> const cps = { 0x0020, 0x0023, 0x202E, 0x202A };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS ET RLO LRO; 4 ('RTL') (line 73630)
std::vector<uint32_t> const cps = { 0x0020, 0x0023, 0x202E, 0x202D };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
}
TEST(bidi, bidi_147_013)
{
expected_levels = { 1, 1, -1, -1 };
expected_reordered_indices = { 1, 0 };
{
// WS ET RLO RLE; 4 ('RTL') (line 73631)
std::vector<uint32_t> const cps = { 0x0020, 0x0023, 0x202E, 0x202B };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS ET RLO RLO; 4 ('RTL') (line 73632)
std::vector<uint32_t> const cps = { 0x0020, 0x0023, 0x202E, 0x202E };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS ET RLO PDF; 4 ('RTL') (line 73633)
std::vector<uint32_t> const cps = { 0x0020, 0x0023, 0x202E, 0x202C };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS ET RLO BN; 4 ('RTL') (line 73634)
std::vector<uint32_t> const cps = { 0x0020, 0x0023, 0x202E, 0x00AD };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS ET PDF LRE; 4 ('RTL') (line 73635)
std::vector<uint32_t> const cps = { 0x0020, 0x0023, 0x202C, 0x202A };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS ET PDF LRO; 4 ('RTL') (line 73636)
std::vector<uint32_t> const cps = { 0x0020, 0x0023, 0x202C, 0x202D };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS ET PDF RLE; 4 ('RTL') (line 73637)
std::vector<uint32_t> const cps = { 0x0020, 0x0023, 0x202C, 0x202B };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS ET PDF RLO; 4 ('RTL') (line 73638)
std::vector<uint32_t> const cps = { 0x0020, 0x0023, 0x202C, 0x202E };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS ET PDF PDF; 4 ('RTL') (line 73639)
std::vector<uint32_t> const cps = { 0x0020, 0x0023, 0x202C, 0x202C };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS ET PDF BN; 4 ('RTL') (line 73640)
std::vector<uint32_t> const cps = { 0x0020, 0x0023, 0x202C, 0x00AD };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
}
TEST(bidi, bidi_147_014)
{
expected_levels = { 1, 1, -1, -1 };
expected_reordered_indices = { 1, 0 };
{
// WS ET BN LRE; 4 ('RTL') (line 73641)
std::vector<uint32_t> const cps = { 0x0020, 0x0023, 0x00AD, 0x202A };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS ET BN LRO; 4 ('RTL') (line 73642)
std::vector<uint32_t> const cps = { 0x0020, 0x0023, 0x00AD, 0x202D };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS ET BN RLE; 4 ('RTL') (line 73643)
std::vector<uint32_t> const cps = { 0x0020, 0x0023, 0x00AD, 0x202B };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS ET BN RLO; 4 ('RTL') (line 73644)
std::vector<uint32_t> const cps = { 0x0020, 0x0023, 0x00AD, 0x202E };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS ET BN PDF; 4 ('RTL') (line 73645)
std::vector<uint32_t> const cps = { 0x0020, 0x0023, 0x00AD, 0x202C };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS ET BN BN; 4 ('RTL') (line 73646)
std::vector<uint32_t> const cps = { 0x0020, 0x0023, 0x00AD, 0x00AD };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS CS LRE LRE; 4 ('RTL') (line 73647)
std::vector<uint32_t> const cps = { 0x0020, 0x002C, 0x202A, 0x202A };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS CS LRE LRO; 4 ('RTL') (line 73648)
std::vector<uint32_t> const cps = { 0x0020, 0x002C, 0x202A, 0x202D };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS CS LRE RLE; 4 ('RTL') (line 73649)
std::vector<uint32_t> const cps = { 0x0020, 0x002C, 0x202A, 0x202B };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS CS LRE RLO; 4 ('RTL') (line 73650)
std::vector<uint32_t> const cps = { 0x0020, 0x002C, 0x202A, 0x202E };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
}
TEST(bidi, bidi_147_015)
{
expected_levels = { 1, 1, -1, -1 };
expected_reordered_indices = { 1, 0 };
{
// WS CS LRE PDF; 4 ('RTL') (line 73651)
std::vector<uint32_t> const cps = { 0x0020, 0x002C, 0x202A, 0x202C };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS CS LRE BN; 4 ('RTL') (line 73652)
std::vector<uint32_t> const cps = { 0x0020, 0x002C, 0x202A, 0x00AD };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS CS LRO LRE; 4 ('RTL') (line 73653)
std::vector<uint32_t> const cps = { 0x0020, 0x002C, 0x202D, 0x202A };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS CS LRO LRO; 4 ('RTL') (line 73654)
std::vector<uint32_t> const cps = { 0x0020, 0x002C, 0x202D, 0x202D };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS CS LRO RLE; 4 ('RTL') (line 73655)
std::vector<uint32_t> const cps = { 0x0020, 0x002C, 0x202D, 0x202B };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS CS LRO RLO; 4 ('RTL') (line 73656)
std::vector<uint32_t> const cps = { 0x0020, 0x002C, 0x202D, 0x202E };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS CS LRO PDF; 4 ('RTL') (line 73657)
std::vector<uint32_t> const cps = { 0x0020, 0x002C, 0x202D, 0x202C };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS CS LRO BN; 4 ('RTL') (line 73658)
std::vector<uint32_t> const cps = { 0x0020, 0x002C, 0x202D, 0x00AD };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS CS RLE LRE; 4 ('RTL') (line 73659)
std::vector<uint32_t> const cps = { 0x0020, 0x002C, 0x202B, 0x202A };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS CS RLE LRO; 4 ('RTL') (line 73660)
std::vector<uint32_t> const cps = { 0x0020, 0x002C, 0x202B, 0x202D };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
}
TEST(bidi, bidi_147_016)
{
expected_levels = { 1, 1, -1, -1 };
expected_reordered_indices = { 1, 0 };
{
// WS CS RLE RLE; 4 ('RTL') (line 73661)
std::vector<uint32_t> const cps = { 0x0020, 0x002C, 0x202B, 0x202B };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS CS RLE RLO; 4 ('RTL') (line 73662)
std::vector<uint32_t> const cps = { 0x0020, 0x002C, 0x202B, 0x202E };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS CS RLE PDF; 4 ('RTL') (line 73663)
std::vector<uint32_t> const cps = { 0x0020, 0x002C, 0x202B, 0x202C };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS CS RLE BN; 4 ('RTL') (line 73664)
std::vector<uint32_t> const cps = { 0x0020, 0x002C, 0x202B, 0x00AD };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS CS RLO LRE; 4 ('RTL') (line 73665)
std::vector<uint32_t> const cps = { 0x0020, 0x002C, 0x202E, 0x202A };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS CS RLO LRO; 4 ('RTL') (line 73666)
std::vector<uint32_t> const cps = { 0x0020, 0x002C, 0x202E, 0x202D };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS CS RLO RLE; 4 ('RTL') (line 73667)
std::vector<uint32_t> const cps = { 0x0020, 0x002C, 0x202E, 0x202B };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS CS RLO RLO; 4 ('RTL') (line 73668)
std::vector<uint32_t> const cps = { 0x0020, 0x002C, 0x202E, 0x202E };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS CS RLO PDF; 4 ('RTL') (line 73669)
std::vector<uint32_t> const cps = { 0x0020, 0x002C, 0x202E, 0x202C };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS CS RLO BN; 4 ('RTL') (line 73670)
std::vector<uint32_t> const cps = { 0x0020, 0x002C, 0x202E, 0x00AD };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
}
TEST(bidi, bidi_147_017)
{
expected_levels = { 1, 1, -1, -1 };
expected_reordered_indices = { 1, 0 };
{
// WS CS PDF LRE; 4 ('RTL') (line 73671)
std::vector<uint32_t> const cps = { 0x0020, 0x002C, 0x202C, 0x202A };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS CS PDF LRO; 4 ('RTL') (line 73672)
std::vector<uint32_t> const cps = { 0x0020, 0x002C, 0x202C, 0x202D };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS CS PDF RLE; 4 ('RTL') (line 73673)
std::vector<uint32_t> const cps = { 0x0020, 0x002C, 0x202C, 0x202B };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS CS PDF RLO; 4 ('RTL') (line 73674)
std::vector<uint32_t> const cps = { 0x0020, 0x002C, 0x202C, 0x202E };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS CS PDF PDF; 4 ('RTL') (line 73675)
std::vector<uint32_t> const cps = { 0x0020, 0x002C, 0x202C, 0x202C };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS CS PDF BN; 4 ('RTL') (line 73676)
std::vector<uint32_t> const cps = { 0x0020, 0x002C, 0x202C, 0x00AD };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS CS BN LRE; 4 ('RTL') (line 73677)
std::vector<uint32_t> const cps = { 0x0020, 0x002C, 0x00AD, 0x202A };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS CS BN LRO; 4 ('RTL') (line 73678)
std::vector<uint32_t> const cps = { 0x0020, 0x002C, 0x00AD, 0x202D };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS CS BN RLE; 4 ('RTL') (line 73679)
std::vector<uint32_t> const cps = { 0x0020, 0x002C, 0x00AD, 0x202B };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS CS BN RLO; 4 ('RTL') (line 73680)
std::vector<uint32_t> const cps = { 0x0020, 0x002C, 0x00AD, 0x202E };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
}
TEST(bidi, bidi_147_018)
{
expected_levels = { 1, 1, -1, -1 };
expected_reordered_indices = { 1, 0 };
{
// WS CS BN PDF; 4 ('RTL') (line 73681)
std::vector<uint32_t> const cps = { 0x0020, 0x002C, 0x00AD, 0x202C };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS CS BN BN; 4 ('RTL') (line 73682)
std::vector<uint32_t> const cps = { 0x0020, 0x002C, 0x00AD, 0x00AD };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS NSM LRE LRE; 4 ('RTL') (line 73683)
std::vector<uint32_t> const cps = { 0x0020, 0x0300, 0x202A, 0x202A };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS NSM LRE LRO; 4 ('RTL') (line 73684)
std::vector<uint32_t> const cps = { 0x0020, 0x0300, 0x202A, 0x202D };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS NSM LRE RLE; 4 ('RTL') (line 73685)
std::vector<uint32_t> const cps = { 0x0020, 0x0300, 0x202A, 0x202B };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS NSM LRE RLO; 4 ('RTL') (line 73686)
std::vector<uint32_t> const cps = { 0x0020, 0x0300, 0x202A, 0x202E };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS NSM LRE PDF; 4 ('RTL') (line 73687)
std::vector<uint32_t> const cps = { 0x0020, 0x0300, 0x202A, 0x202C };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS NSM LRE BN; 4 ('RTL') (line 73688)
std::vector<uint32_t> const cps = { 0x0020, 0x0300, 0x202A, 0x00AD };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS NSM LRO LRE; 4 ('RTL') (line 73689)
std::vector<uint32_t> const cps = { 0x0020, 0x0300, 0x202D, 0x202A };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS NSM LRO LRO; 4 ('RTL') (line 73690)
std::vector<uint32_t> const cps = { 0x0020, 0x0300, 0x202D, 0x202D };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
}
TEST(bidi, bidi_147_019)
{
expected_levels = { 1, 1, -1, -1 };
expected_reordered_indices = { 1, 0 };
{
// WS NSM LRO RLE; 4 ('RTL') (line 73691)
std::vector<uint32_t> const cps = { 0x0020, 0x0300, 0x202D, 0x202B };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS NSM LRO RLO; 4 ('RTL') (line 73692)
std::vector<uint32_t> const cps = { 0x0020, 0x0300, 0x202D, 0x202E };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS NSM LRO PDF; 4 ('RTL') (line 73693)
std::vector<uint32_t> const cps = { 0x0020, 0x0300, 0x202D, 0x202C };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS NSM LRO BN; 4 ('RTL') (line 73694)
std::vector<uint32_t> const cps = { 0x0020, 0x0300, 0x202D, 0x00AD };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS NSM RLE LRE; 4 ('RTL') (line 73695)
std::vector<uint32_t> const cps = { 0x0020, 0x0300, 0x202B, 0x202A };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS NSM RLE LRO; 4 ('RTL') (line 73696)
std::vector<uint32_t> const cps = { 0x0020, 0x0300, 0x202B, 0x202D };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS NSM RLE RLE; 4 ('RTL') (line 73697)
std::vector<uint32_t> const cps = { 0x0020, 0x0300, 0x202B, 0x202B };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS NSM RLE RLO; 4 ('RTL') (line 73698)
std::vector<uint32_t> const cps = { 0x0020, 0x0300, 0x202B, 0x202E };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS NSM RLE PDF; 4 ('RTL') (line 73699)
std::vector<uint32_t> const cps = { 0x0020, 0x0300, 0x202B, 0x202C };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS NSM RLE BN; 4 ('RTL') (line 73700)
std::vector<uint32_t> const cps = { 0x0020, 0x0300, 0x202B, 0x00AD };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
}
TEST(bidi, bidi_147_020)
{
expected_levels = { 1, 1, -1, -1 };
expected_reordered_indices = { 1, 0 };
{
// WS NSM RLO LRE; 4 ('RTL') (line 73701)
std::vector<uint32_t> const cps = { 0x0020, 0x0300, 0x202E, 0x202A };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS NSM RLO LRO; 4 ('RTL') (line 73702)
std::vector<uint32_t> const cps = { 0x0020, 0x0300, 0x202E, 0x202D };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS NSM RLO RLE; 4 ('RTL') (line 73703)
std::vector<uint32_t> const cps = { 0x0020, 0x0300, 0x202E, 0x202B };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS NSM RLO RLO; 4 ('RTL') (line 73704)
std::vector<uint32_t> const cps = { 0x0020, 0x0300, 0x202E, 0x202E };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS NSM RLO PDF; 4 ('RTL') (line 73705)
std::vector<uint32_t> const cps = { 0x0020, 0x0300, 0x202E, 0x202C };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS NSM RLO BN; 4 ('RTL') (line 73706)
std::vector<uint32_t> const cps = { 0x0020, 0x0300, 0x202E, 0x00AD };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS NSM PDF LRE; 4 ('RTL') (line 73707)
std::vector<uint32_t> const cps = { 0x0020, 0x0300, 0x202C, 0x202A };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS NSM PDF LRO; 4 ('RTL') (line 73708)
std::vector<uint32_t> const cps = { 0x0020, 0x0300, 0x202C, 0x202D };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS NSM PDF RLE; 4 ('RTL') (line 73709)
std::vector<uint32_t> const cps = { 0x0020, 0x0300, 0x202C, 0x202B };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS NSM PDF RLO; 4 ('RTL') (line 73710)
std::vector<uint32_t> const cps = { 0x0020, 0x0300, 0x202C, 0x202E };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
}
TEST(bidi, bidi_147_021)
{
expected_levels = { 1, 1, -1, -1 };
expected_reordered_indices = { 1, 0 };
{
// WS NSM PDF PDF; 4 ('RTL') (line 73711)
std::vector<uint32_t> const cps = { 0x0020, 0x0300, 0x202C, 0x202C };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS NSM PDF BN; 4 ('RTL') (line 73712)
std::vector<uint32_t> const cps = { 0x0020, 0x0300, 0x202C, 0x00AD };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS NSM BN LRE; 4 ('RTL') (line 73713)
std::vector<uint32_t> const cps = { 0x0020, 0x0300, 0x00AD, 0x202A };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS NSM BN LRO; 4 ('RTL') (line 73714)
std::vector<uint32_t> const cps = { 0x0020, 0x0300, 0x00AD, 0x202D };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS NSM BN RLE; 4 ('RTL') (line 73715)
std::vector<uint32_t> const cps = { 0x0020, 0x0300, 0x00AD, 0x202B };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS NSM BN RLO; 4 ('RTL') (line 73716)
std::vector<uint32_t> const cps = { 0x0020, 0x0300, 0x00AD, 0x202E };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS NSM BN PDF; 4 ('RTL') (line 73717)
std::vector<uint32_t> const cps = { 0x0020, 0x0300, 0x00AD, 0x202C };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS NSM BN BN; 4 ('RTL') (line 73718)
std::vector<uint32_t> const cps = { 0x0020, 0x0300, 0x00AD, 0x00AD };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS S LRE LRE; 4 ('RTL') (line 73719)
std::vector<uint32_t> const cps = { 0x0020, 0x0009, 0x202A, 0x202A };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS S LRE LRO; 4 ('RTL') (line 73720)
std::vector<uint32_t> const cps = { 0x0020, 0x0009, 0x202A, 0x202D };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
}
TEST(bidi, bidi_147_022)
{
expected_levels = { 1, 1, -1, -1 };
expected_reordered_indices = { 1, 0 };
{
// WS S LRE RLE; 4 ('RTL') (line 73721)
std::vector<uint32_t> const cps = { 0x0020, 0x0009, 0x202A, 0x202B };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS S LRE RLO; 4 ('RTL') (line 73722)
std::vector<uint32_t> const cps = { 0x0020, 0x0009, 0x202A, 0x202E };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS S LRE PDF; 4 ('RTL') (line 73723)
std::vector<uint32_t> const cps = { 0x0020, 0x0009, 0x202A, 0x202C };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS S LRE BN; 4 ('RTL') (line 73724)
std::vector<uint32_t> const cps = { 0x0020, 0x0009, 0x202A, 0x00AD };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS S LRO LRE; 4 ('RTL') (line 73725)
std::vector<uint32_t> const cps = { 0x0020, 0x0009, 0x202D, 0x202A };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS S LRO LRO; 4 ('RTL') (line 73726)
std::vector<uint32_t> const cps = { 0x0020, 0x0009, 0x202D, 0x202D };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS S LRO RLE; 4 ('RTL') (line 73727)
std::vector<uint32_t> const cps = { 0x0020, 0x0009, 0x202D, 0x202B };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS S LRO RLO; 4 ('RTL') (line 73728)
std::vector<uint32_t> const cps = { 0x0020, 0x0009, 0x202D, 0x202E };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS S LRO PDF; 4 ('RTL') (line 73729)
std::vector<uint32_t> const cps = { 0x0020, 0x0009, 0x202D, 0x202C };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS S LRO BN; 4 ('RTL') (line 73730)
std::vector<uint32_t> const cps = { 0x0020, 0x0009, 0x202D, 0x00AD };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
}
TEST(bidi, bidi_147_023)
{
expected_levels = { 1, 1, -1, -1 };
expected_reordered_indices = { 1, 0 };
{
// WS S RLE LRE; 4 ('RTL') (line 73731)
std::vector<uint32_t> const cps = { 0x0020, 0x0009, 0x202B, 0x202A };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS S RLE LRO; 4 ('RTL') (line 73732)
std::vector<uint32_t> const cps = { 0x0020, 0x0009, 0x202B, 0x202D };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS S RLE RLE; 4 ('RTL') (line 73733)
std::vector<uint32_t> const cps = { 0x0020, 0x0009, 0x202B, 0x202B };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS S RLE RLO; 4 ('RTL') (line 73734)
std::vector<uint32_t> const cps = { 0x0020, 0x0009, 0x202B, 0x202E };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS S RLE PDF; 4 ('RTL') (line 73735)
std::vector<uint32_t> const cps = { 0x0020, 0x0009, 0x202B, 0x202C };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS S RLE BN; 4 ('RTL') (line 73736)
std::vector<uint32_t> const cps = { 0x0020, 0x0009, 0x202B, 0x00AD };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS S RLO LRE; 4 ('RTL') (line 73737)
std::vector<uint32_t> const cps = { 0x0020, 0x0009, 0x202E, 0x202A };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS S RLO LRO; 4 ('RTL') (line 73738)
std::vector<uint32_t> const cps = { 0x0020, 0x0009, 0x202E, 0x202D };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS S RLO RLE; 4 ('RTL') (line 73739)
std::vector<uint32_t> const cps = { 0x0020, 0x0009, 0x202E, 0x202B };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS S RLO RLO; 4 ('RTL') (line 73740)
std::vector<uint32_t> const cps = { 0x0020, 0x0009, 0x202E, 0x202E };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
}
TEST(bidi, bidi_147_024)
{
expected_levels = { 1, 1, -1, -1 };
expected_reordered_indices = { 1, 0 };
{
// WS S RLO PDF; 4 ('RTL') (line 73741)
std::vector<uint32_t> const cps = { 0x0020, 0x0009, 0x202E, 0x202C };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS S RLO BN; 4 ('RTL') (line 73742)
std::vector<uint32_t> const cps = { 0x0020, 0x0009, 0x202E, 0x00AD };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS S PDF LRE; 4 ('RTL') (line 73743)
std::vector<uint32_t> const cps = { 0x0020, 0x0009, 0x202C, 0x202A };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS S PDF LRO; 4 ('RTL') (line 73744)
std::vector<uint32_t> const cps = { 0x0020, 0x0009, 0x202C, 0x202D };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS S PDF RLE; 4 ('RTL') (line 73745)
std::vector<uint32_t> const cps = { 0x0020, 0x0009, 0x202C, 0x202B };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS S PDF RLO; 4 ('RTL') (line 73746)
std::vector<uint32_t> const cps = { 0x0020, 0x0009, 0x202C, 0x202E };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS S PDF PDF; 4 ('RTL') (line 73747)
std::vector<uint32_t> const cps = { 0x0020, 0x0009, 0x202C, 0x202C };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS S PDF BN; 4 ('RTL') (line 73748)
std::vector<uint32_t> const cps = { 0x0020, 0x0009, 0x202C, 0x00AD };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS S BN LRE; 4 ('RTL') (line 73749)
std::vector<uint32_t> const cps = { 0x0020, 0x0009, 0x00AD, 0x202A };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS S BN LRO; 4 ('RTL') (line 73750)
std::vector<uint32_t> const cps = { 0x0020, 0x0009, 0x00AD, 0x202D };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
}
TEST(bidi, bidi_147_025)
{
expected_levels = { 1, 1, -1, -1 };
expected_reordered_indices = { 1, 0 };
{
// WS S BN RLE; 4 ('RTL') (line 73751)
std::vector<uint32_t> const cps = { 0x0020, 0x0009, 0x00AD, 0x202B };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS S BN RLO; 4 ('RTL') (line 73752)
std::vector<uint32_t> const cps = { 0x0020, 0x0009, 0x00AD, 0x202E };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS S BN PDF; 4 ('RTL') (line 73753)
std::vector<uint32_t> const cps = { 0x0020, 0x0009, 0x00AD, 0x202C };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS S BN BN; 4 ('RTL') (line 73754)
std::vector<uint32_t> const cps = { 0x0020, 0x0009, 0x00AD, 0x00AD };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS WS LRE LRE; 4 ('RTL') (line 73755)
std::vector<uint32_t> const cps = { 0x0020, 0x0020, 0x202A, 0x202A };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS WS LRE LRO; 4 ('RTL') (line 73756)
std::vector<uint32_t> const cps = { 0x0020, 0x0020, 0x202A, 0x202D };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS WS LRE RLE; 4 ('RTL') (line 73757)
std::vector<uint32_t> const cps = { 0x0020, 0x0020, 0x202A, 0x202B };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS WS LRE RLO; 4 ('RTL') (line 73758)
std::vector<uint32_t> const cps = { 0x0020, 0x0020, 0x202A, 0x202E };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS WS LRE PDF; 4 ('RTL') (line 73759)
std::vector<uint32_t> const cps = { 0x0020, 0x0020, 0x202A, 0x202C };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS WS LRE BN; 4 ('RTL') (line 73760)
std::vector<uint32_t> const cps = { 0x0020, 0x0020, 0x202A, 0x00AD };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
}
TEST(bidi, bidi_147_026)
{
expected_levels = { 1, 1, -1, -1 };
expected_reordered_indices = { 1, 0 };
{
// WS WS LRO LRE; 4 ('RTL') (line 73761)
std::vector<uint32_t> const cps = { 0x0020, 0x0020, 0x202D, 0x202A };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS WS LRO LRO; 4 ('RTL') (line 73762)
std::vector<uint32_t> const cps = { 0x0020, 0x0020, 0x202D, 0x202D };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS WS LRO RLE; 4 ('RTL') (line 73763)
std::vector<uint32_t> const cps = { 0x0020, 0x0020, 0x202D, 0x202B };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS WS LRO RLO; 4 ('RTL') (line 73764)
std::vector<uint32_t> const cps = { 0x0020, 0x0020, 0x202D, 0x202E };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS WS LRO PDF; 4 ('RTL') (line 73765)
std::vector<uint32_t> const cps = { 0x0020, 0x0020, 0x202D, 0x202C };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS WS LRO BN; 4 ('RTL') (line 73766)
std::vector<uint32_t> const cps = { 0x0020, 0x0020, 0x202D, 0x00AD };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS WS RLE LRE; 4 ('RTL') (line 73767)
std::vector<uint32_t> const cps = { 0x0020, 0x0020, 0x202B, 0x202A };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS WS RLE LRO; 4 ('RTL') (line 73768)
std::vector<uint32_t> const cps = { 0x0020, 0x0020, 0x202B, 0x202D };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS WS RLE RLE; 4 ('RTL') (line 73769)
std::vector<uint32_t> const cps = { 0x0020, 0x0020, 0x202B, 0x202B };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS WS RLE RLO; 4 ('RTL') (line 73770)
std::vector<uint32_t> const cps = { 0x0020, 0x0020, 0x202B, 0x202E };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
}
TEST(bidi, bidi_147_027)
{
expected_levels = { 1, 1, -1, -1 };
expected_reordered_indices = { 1, 0 };
{
// WS WS RLE PDF; 4 ('RTL') (line 73771)
std::vector<uint32_t> const cps = { 0x0020, 0x0020, 0x202B, 0x202C };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS WS RLE BN; 4 ('RTL') (line 73772)
std::vector<uint32_t> const cps = { 0x0020, 0x0020, 0x202B, 0x00AD };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS WS RLO LRE; 4 ('RTL') (line 73773)
std::vector<uint32_t> const cps = { 0x0020, 0x0020, 0x202E, 0x202A };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS WS RLO LRO; 4 ('RTL') (line 73774)
std::vector<uint32_t> const cps = { 0x0020, 0x0020, 0x202E, 0x202D };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS WS RLO RLE; 4 ('RTL') (line 73775)
std::vector<uint32_t> const cps = { 0x0020, 0x0020, 0x202E, 0x202B };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS WS RLO RLO; 4 ('RTL') (line 73776)
std::vector<uint32_t> const cps = { 0x0020, 0x0020, 0x202E, 0x202E };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS WS RLO PDF; 4 ('RTL') (line 73777)
std::vector<uint32_t> const cps = { 0x0020, 0x0020, 0x202E, 0x202C };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS WS RLO BN; 4 ('RTL') (line 73778)
std::vector<uint32_t> const cps = { 0x0020, 0x0020, 0x202E, 0x00AD };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS WS PDF LRE; 4 ('RTL') (line 73779)
std::vector<uint32_t> const cps = { 0x0020, 0x0020, 0x202C, 0x202A };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS WS PDF LRO; 4 ('RTL') (line 73780)
std::vector<uint32_t> const cps = { 0x0020, 0x0020, 0x202C, 0x202D };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
}
TEST(bidi, bidi_147_028)
{
expected_levels = { 1, 1, -1, -1 };
expected_reordered_indices = { 1, 0 };
{
// WS WS PDF RLE; 4 ('RTL') (line 73781)
std::vector<uint32_t> const cps = { 0x0020, 0x0020, 0x202C, 0x202B };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS WS PDF RLO; 4 ('RTL') (line 73782)
std::vector<uint32_t> const cps = { 0x0020, 0x0020, 0x202C, 0x202E };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS WS PDF PDF; 4 ('RTL') (line 73783)
std::vector<uint32_t> const cps = { 0x0020, 0x0020, 0x202C, 0x202C };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS WS PDF BN; 4 ('RTL') (line 73784)
std::vector<uint32_t> const cps = { 0x0020, 0x0020, 0x202C, 0x00AD };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS WS BN LRE; 4 ('RTL') (line 73785)
std::vector<uint32_t> const cps = { 0x0020, 0x0020, 0x00AD, 0x202A };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS WS BN LRO; 4 ('RTL') (line 73786)
std::vector<uint32_t> const cps = { 0x0020, 0x0020, 0x00AD, 0x202D };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS WS BN RLE; 4 ('RTL') (line 73787)
std::vector<uint32_t> const cps = { 0x0020, 0x0020, 0x00AD, 0x202B };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS WS BN RLO; 4 ('RTL') (line 73788)
std::vector<uint32_t> const cps = { 0x0020, 0x0020, 0x00AD, 0x202E };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS WS BN PDF; 4 ('RTL') (line 73789)
std::vector<uint32_t> const cps = { 0x0020, 0x0020, 0x00AD, 0x202C };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS WS BN BN; 4 ('RTL') (line 73790)
std::vector<uint32_t> const cps = { 0x0020, 0x0020, 0x00AD, 0x00AD };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
}
TEST(bidi, bidi_147_029)
{
expected_levels = { 1, 1, -1, -1 };
expected_reordered_indices = { 1, 0 };
{
// WS ON LRE LRE; 4 ('RTL') (line 73791)
std::vector<uint32_t> const cps = { 0x0020, 0x0021, 0x202A, 0x202A };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS ON LRE LRO; 4 ('RTL') (line 73792)
std::vector<uint32_t> const cps = { 0x0020, 0x0021, 0x202A, 0x202D };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS ON LRE RLE; 4 ('RTL') (line 73793)
std::vector<uint32_t> const cps = { 0x0020, 0x0021, 0x202A, 0x202B };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS ON LRE RLO; 4 ('RTL') (line 73794)
std::vector<uint32_t> const cps = { 0x0020, 0x0021, 0x202A, 0x202E };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS ON LRE PDF; 4 ('RTL') (line 73795)
std::vector<uint32_t> const cps = { 0x0020, 0x0021, 0x202A, 0x202C };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS ON LRE BN; 4 ('RTL') (line 73796)
std::vector<uint32_t> const cps = { 0x0020, 0x0021, 0x202A, 0x00AD };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS ON LRO LRE; 4 ('RTL') (line 73797)
std::vector<uint32_t> const cps = { 0x0020, 0x0021, 0x202D, 0x202A };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS ON LRO LRO; 4 ('RTL') (line 73798)
std::vector<uint32_t> const cps = { 0x0020, 0x0021, 0x202D, 0x202D };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS ON LRO RLE; 4 ('RTL') (line 73799)
std::vector<uint32_t> const cps = { 0x0020, 0x0021, 0x202D, 0x202B };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS ON LRO RLO; 4 ('RTL') (line 73800)
std::vector<uint32_t> const cps = { 0x0020, 0x0021, 0x202D, 0x202E };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
}
TEST(bidi, bidi_147_030)
{
expected_levels = { 1, 1, -1, -1 };
expected_reordered_indices = { 1, 0 };
{
// WS ON LRO PDF; 4 ('RTL') (line 73801)
std::vector<uint32_t> const cps = { 0x0020, 0x0021, 0x202D, 0x202C };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS ON LRO BN; 4 ('RTL') (line 73802)
std::vector<uint32_t> const cps = { 0x0020, 0x0021, 0x202D, 0x00AD };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS ON RLE LRE; 4 ('RTL') (line 73803)
std::vector<uint32_t> const cps = { 0x0020, 0x0021, 0x202B, 0x202A };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS ON RLE LRO; 4 ('RTL') (line 73804)
std::vector<uint32_t> const cps = { 0x0020, 0x0021, 0x202B, 0x202D };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS ON RLE RLE; 4 ('RTL') (line 73805)
std::vector<uint32_t> const cps = { 0x0020, 0x0021, 0x202B, 0x202B };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS ON RLE RLO; 4 ('RTL') (line 73806)
std::vector<uint32_t> const cps = { 0x0020, 0x0021, 0x202B, 0x202E };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS ON RLE PDF; 4 ('RTL') (line 73807)
std::vector<uint32_t> const cps = { 0x0020, 0x0021, 0x202B, 0x202C };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS ON RLE BN; 4 ('RTL') (line 73808)
std::vector<uint32_t> const cps = { 0x0020, 0x0021, 0x202B, 0x00AD };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS ON RLO LRE; 4 ('RTL') (line 73809)
std::vector<uint32_t> const cps = { 0x0020, 0x0021, 0x202E, 0x202A };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS ON RLO LRO; 4 ('RTL') (line 73810)
std::vector<uint32_t> const cps = { 0x0020, 0x0021, 0x202E, 0x202D };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
}
TEST(bidi, bidi_147_031)
{
expected_levels = { 1, 1, -1, -1 };
expected_reordered_indices = { 1, 0 };
{
// WS ON RLO RLE; 4 ('RTL') (line 73811)
std::vector<uint32_t> const cps = { 0x0020, 0x0021, 0x202E, 0x202B };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS ON RLO RLO; 4 ('RTL') (line 73812)
std::vector<uint32_t> const cps = { 0x0020, 0x0021, 0x202E, 0x202E };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS ON RLO PDF; 4 ('RTL') (line 73813)
std::vector<uint32_t> const cps = { 0x0020, 0x0021, 0x202E, 0x202C };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS ON RLO BN; 4 ('RTL') (line 73814)
std::vector<uint32_t> const cps = { 0x0020, 0x0021, 0x202E, 0x00AD };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS ON PDF LRE; 4 ('RTL') (line 73815)
std::vector<uint32_t> const cps = { 0x0020, 0x0021, 0x202C, 0x202A };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS ON PDF LRO; 4 ('RTL') (line 73816)
std::vector<uint32_t> const cps = { 0x0020, 0x0021, 0x202C, 0x202D };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS ON PDF RLE; 4 ('RTL') (line 73817)
std::vector<uint32_t> const cps = { 0x0020, 0x0021, 0x202C, 0x202B };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS ON PDF RLO; 4 ('RTL') (line 73818)
std::vector<uint32_t> const cps = { 0x0020, 0x0021, 0x202C, 0x202E };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS ON PDF PDF; 4 ('RTL') (line 73819)
std::vector<uint32_t> const cps = { 0x0020, 0x0021, 0x202C, 0x202C };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS ON PDF BN; 4 ('RTL') (line 73820)
std::vector<uint32_t> const cps = { 0x0020, 0x0021, 0x202C, 0x00AD };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
}
TEST(bidi, bidi_147_032)
{
expected_levels = { 1, 1, -1, -1 };
expected_reordered_indices = { 1, 0 };
{
// WS ON BN LRE; 4 ('RTL') (line 73821)
std::vector<uint32_t> const cps = { 0x0020, 0x0021, 0x00AD, 0x202A };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS ON BN LRO; 4 ('RTL') (line 73822)
std::vector<uint32_t> const cps = { 0x0020, 0x0021, 0x00AD, 0x202D };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS ON BN RLE; 4 ('RTL') (line 73823)
std::vector<uint32_t> const cps = { 0x0020, 0x0021, 0x00AD, 0x202B };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS ON BN RLO; 4 ('RTL') (line 73824)
std::vector<uint32_t> const cps = { 0x0020, 0x0021, 0x00AD, 0x202E };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS ON BN PDF; 4 ('RTL') (line 73825)
std::vector<uint32_t> const cps = { 0x0020, 0x0021, 0x00AD, 0x202C };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS ON BN BN; 4 ('RTL') (line 73826)
std::vector<uint32_t> const cps = { 0x0020, 0x0021, 0x00AD, 0x00AD };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS LRI LRE LRE; 4 ('RTL') (line 73827)
std::vector<uint32_t> const cps = { 0x0020, 0x2066, 0x202A, 0x202A };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS LRI LRE LRO; 4 ('RTL') (line 73828)
std::vector<uint32_t> const cps = { 0x0020, 0x2066, 0x202A, 0x202D };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS LRI LRE RLE; 4 ('RTL') (line 73829)
std::vector<uint32_t> const cps = { 0x0020, 0x2066, 0x202A, 0x202B };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS LRI LRE RLO; 4 ('RTL') (line 73830)
std::vector<uint32_t> const cps = { 0x0020, 0x2066, 0x202A, 0x202E };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
}
TEST(bidi, bidi_147_033)
{
expected_levels = { 1, 1, -1, -1 };
expected_reordered_indices = { 1, 0 };
{
// WS LRI LRE PDF; 4 ('RTL') (line 73831)
std::vector<uint32_t> const cps = { 0x0020, 0x2066, 0x202A, 0x202C };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS LRI LRE BN; 4 ('RTL') (line 73832)
std::vector<uint32_t> const cps = { 0x0020, 0x2066, 0x202A, 0x00AD };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS LRI LRO LRE; 4 ('RTL') (line 73833)
std::vector<uint32_t> const cps = { 0x0020, 0x2066, 0x202D, 0x202A };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS LRI LRO LRO; 4 ('RTL') (line 73834)
std::vector<uint32_t> const cps = { 0x0020, 0x2066, 0x202D, 0x202D };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS LRI LRO RLE; 4 ('RTL') (line 73835)
std::vector<uint32_t> const cps = { 0x0020, 0x2066, 0x202D, 0x202B };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS LRI LRO RLO; 4 ('RTL') (line 73836)
std::vector<uint32_t> const cps = { 0x0020, 0x2066, 0x202D, 0x202E };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS LRI LRO PDF; 4 ('RTL') (line 73837)
std::vector<uint32_t> const cps = { 0x0020, 0x2066, 0x202D, 0x202C };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS LRI LRO BN; 4 ('RTL') (line 73838)
std::vector<uint32_t> const cps = { 0x0020, 0x2066, 0x202D, 0x00AD };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS LRI RLE LRE; 4 ('RTL') (line 73839)
std::vector<uint32_t> const cps = { 0x0020, 0x2066, 0x202B, 0x202A };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS LRI RLE LRO; 4 ('RTL') (line 73840)
std::vector<uint32_t> const cps = { 0x0020, 0x2066, 0x202B, 0x202D };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
}
TEST(bidi, bidi_147_034)
{
expected_levels = { 1, 1, -1, -1 };
expected_reordered_indices = { 1, 0 };
{
// WS LRI RLE RLE; 4 ('RTL') (line 73841)
std::vector<uint32_t> const cps = { 0x0020, 0x2066, 0x202B, 0x202B };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS LRI RLE RLO; 4 ('RTL') (line 73842)
std::vector<uint32_t> const cps = { 0x0020, 0x2066, 0x202B, 0x202E };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS LRI RLE PDF; 4 ('RTL') (line 73843)
std::vector<uint32_t> const cps = { 0x0020, 0x2066, 0x202B, 0x202C };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS LRI RLE BN; 4 ('RTL') (line 73844)
std::vector<uint32_t> const cps = { 0x0020, 0x2066, 0x202B, 0x00AD };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS LRI RLO LRE; 4 ('RTL') (line 73845)
std::vector<uint32_t> const cps = { 0x0020, 0x2066, 0x202E, 0x202A };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS LRI RLO LRO; 4 ('RTL') (line 73846)
std::vector<uint32_t> const cps = { 0x0020, 0x2066, 0x202E, 0x202D };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS LRI RLO RLE; 4 ('RTL') (line 73847)
std::vector<uint32_t> const cps = { 0x0020, 0x2066, 0x202E, 0x202B };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS LRI RLO RLO; 4 ('RTL') (line 73848)
std::vector<uint32_t> const cps = { 0x0020, 0x2066, 0x202E, 0x202E };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS LRI RLO PDF; 4 ('RTL') (line 73849)
std::vector<uint32_t> const cps = { 0x0020, 0x2066, 0x202E, 0x202C };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS LRI RLO BN; 4 ('RTL') (line 73850)
std::vector<uint32_t> const cps = { 0x0020, 0x2066, 0x202E, 0x00AD };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
}
TEST(bidi, bidi_147_035)
{
expected_levels = { 1, 1, -1, -1 };
expected_reordered_indices = { 1, 0 };
{
// WS LRI PDF LRE; 4 ('RTL') (line 73851)
std::vector<uint32_t> const cps = { 0x0020, 0x2066, 0x202C, 0x202A };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS LRI PDF LRO; 4 ('RTL') (line 73852)
std::vector<uint32_t> const cps = { 0x0020, 0x2066, 0x202C, 0x202D };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS LRI PDF RLE; 4 ('RTL') (line 73853)
std::vector<uint32_t> const cps = { 0x0020, 0x2066, 0x202C, 0x202B };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS LRI PDF RLO; 4 ('RTL') (line 73854)
std::vector<uint32_t> const cps = { 0x0020, 0x2066, 0x202C, 0x202E };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS LRI PDF PDF; 4 ('RTL') (line 73855)
std::vector<uint32_t> const cps = { 0x0020, 0x2066, 0x202C, 0x202C };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS LRI PDF BN; 4 ('RTL') (line 73856)
std::vector<uint32_t> const cps = { 0x0020, 0x2066, 0x202C, 0x00AD };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS LRI BN LRE; 4 ('RTL') (line 73857)
std::vector<uint32_t> const cps = { 0x0020, 0x2066, 0x00AD, 0x202A };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS LRI BN LRO; 4 ('RTL') (line 73858)
std::vector<uint32_t> const cps = { 0x0020, 0x2066, 0x00AD, 0x202D };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS LRI BN RLE; 4 ('RTL') (line 73859)
std::vector<uint32_t> const cps = { 0x0020, 0x2066, 0x00AD, 0x202B };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS LRI BN RLO; 4 ('RTL') (line 73860)
std::vector<uint32_t> const cps = { 0x0020, 0x2066, 0x00AD, 0x202E };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
}
TEST(bidi, bidi_147_036)
{
expected_levels = { 1, 1, -1, -1 };
expected_reordered_indices = { 1, 0 };
{
// WS LRI BN PDF; 4 ('RTL') (line 73861)
std::vector<uint32_t> const cps = { 0x0020, 0x2066, 0x00AD, 0x202C };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS LRI BN BN; 4 ('RTL') (line 73862)
std::vector<uint32_t> const cps = { 0x0020, 0x2066, 0x00AD, 0x00AD };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS RLI LRE LRE; 4 ('RTL') (line 73863)
std::vector<uint32_t> const cps = { 0x0020, 0x2067, 0x202A, 0x202A };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS RLI LRE LRO; 4 ('RTL') (line 73864)
std::vector<uint32_t> const cps = { 0x0020, 0x2067, 0x202A, 0x202D };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS RLI LRE RLE; 4 ('RTL') (line 73865)
std::vector<uint32_t> const cps = { 0x0020, 0x2067, 0x202A, 0x202B };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS RLI LRE RLO; 4 ('RTL') (line 73866)
std::vector<uint32_t> const cps = { 0x0020, 0x2067, 0x202A, 0x202E };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS RLI LRE PDF; 4 ('RTL') (line 73867)
std::vector<uint32_t> const cps = { 0x0020, 0x2067, 0x202A, 0x202C };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS RLI LRE BN; 4 ('RTL') (line 73868)
std::vector<uint32_t> const cps = { 0x0020, 0x2067, 0x202A, 0x00AD };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS RLI LRO LRE; 4 ('RTL') (line 73869)
std::vector<uint32_t> const cps = { 0x0020, 0x2067, 0x202D, 0x202A };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS RLI LRO LRO; 4 ('RTL') (line 73870)
std::vector<uint32_t> const cps = { 0x0020, 0x2067, 0x202D, 0x202D };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
}
TEST(bidi, bidi_147_037)
{
expected_levels = { 1, 1, -1, -1 };
expected_reordered_indices = { 1, 0 };
{
// WS RLI LRO RLE; 4 ('RTL') (line 73871)
std::vector<uint32_t> const cps = { 0x0020, 0x2067, 0x202D, 0x202B };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS RLI LRO RLO; 4 ('RTL') (line 73872)
std::vector<uint32_t> const cps = { 0x0020, 0x2067, 0x202D, 0x202E };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS RLI LRO PDF; 4 ('RTL') (line 73873)
std::vector<uint32_t> const cps = { 0x0020, 0x2067, 0x202D, 0x202C };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS RLI LRO BN; 4 ('RTL') (line 73874)
std::vector<uint32_t> const cps = { 0x0020, 0x2067, 0x202D, 0x00AD };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS RLI RLE LRE; 4 ('RTL') (line 73875)
std::vector<uint32_t> const cps = { 0x0020, 0x2067, 0x202B, 0x202A };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS RLI RLE LRO; 4 ('RTL') (line 73876)
std::vector<uint32_t> const cps = { 0x0020, 0x2067, 0x202B, 0x202D };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS RLI RLE RLE; 4 ('RTL') (line 73877)
std::vector<uint32_t> const cps = { 0x0020, 0x2067, 0x202B, 0x202B };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS RLI RLE RLO; 4 ('RTL') (line 73878)
std::vector<uint32_t> const cps = { 0x0020, 0x2067, 0x202B, 0x202E };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS RLI RLE PDF; 4 ('RTL') (line 73879)
std::vector<uint32_t> const cps = { 0x0020, 0x2067, 0x202B, 0x202C };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS RLI RLE BN; 4 ('RTL') (line 73880)
std::vector<uint32_t> const cps = { 0x0020, 0x2067, 0x202B, 0x00AD };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
}
TEST(bidi, bidi_147_038)
{
expected_levels = { 1, 1, -1, -1 };
expected_reordered_indices = { 1, 0 };
{
// WS RLI RLO LRE; 4 ('RTL') (line 73881)
std::vector<uint32_t> const cps = { 0x0020, 0x2067, 0x202E, 0x202A };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS RLI RLO LRO; 4 ('RTL') (line 73882)
std::vector<uint32_t> const cps = { 0x0020, 0x2067, 0x202E, 0x202D };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS RLI RLO RLE; 4 ('RTL') (line 73883)
std::vector<uint32_t> const cps = { 0x0020, 0x2067, 0x202E, 0x202B };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS RLI RLO RLO; 4 ('RTL') (line 73884)
std::vector<uint32_t> const cps = { 0x0020, 0x2067, 0x202E, 0x202E };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS RLI RLO PDF; 4 ('RTL') (line 73885)
std::vector<uint32_t> const cps = { 0x0020, 0x2067, 0x202E, 0x202C };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS RLI RLO BN; 4 ('RTL') (line 73886)
std::vector<uint32_t> const cps = { 0x0020, 0x2067, 0x202E, 0x00AD };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS RLI PDF LRE; 4 ('RTL') (line 73887)
std::vector<uint32_t> const cps = { 0x0020, 0x2067, 0x202C, 0x202A };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS RLI PDF LRO; 4 ('RTL') (line 73888)
std::vector<uint32_t> const cps = { 0x0020, 0x2067, 0x202C, 0x202D };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS RLI PDF RLE; 4 ('RTL') (line 73889)
std::vector<uint32_t> const cps = { 0x0020, 0x2067, 0x202C, 0x202B };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS RLI PDF RLO; 4 ('RTL') (line 73890)
std::vector<uint32_t> const cps = { 0x0020, 0x2067, 0x202C, 0x202E };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
}
TEST(bidi, bidi_147_039)
{
expected_levels = { 1, 1, -1, -1 };
expected_reordered_indices = { 1, 0 };
{
// WS RLI PDF PDF; 4 ('RTL') (line 73891)
std::vector<uint32_t> const cps = { 0x0020, 0x2067, 0x202C, 0x202C };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS RLI PDF BN; 4 ('RTL') (line 73892)
std::vector<uint32_t> const cps = { 0x0020, 0x2067, 0x202C, 0x00AD };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS RLI BN LRE; 4 ('RTL') (line 73893)
std::vector<uint32_t> const cps = { 0x0020, 0x2067, 0x00AD, 0x202A };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS RLI BN LRO; 4 ('RTL') (line 73894)
std::vector<uint32_t> const cps = { 0x0020, 0x2067, 0x00AD, 0x202D };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS RLI BN RLE; 4 ('RTL') (line 73895)
std::vector<uint32_t> const cps = { 0x0020, 0x2067, 0x00AD, 0x202B };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS RLI BN RLO; 4 ('RTL') (line 73896)
std::vector<uint32_t> const cps = { 0x0020, 0x2067, 0x00AD, 0x202E };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS RLI BN PDF; 4 ('RTL') (line 73897)
std::vector<uint32_t> const cps = { 0x0020, 0x2067, 0x00AD, 0x202C };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS RLI BN BN; 4 ('RTL') (line 73898)
std::vector<uint32_t> const cps = { 0x0020, 0x2067, 0x00AD, 0x00AD };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS FSI LRE LRE; 4 ('RTL') (line 73899)
std::vector<uint32_t> const cps = { 0x0020, 0x2068, 0x202A, 0x202A };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS FSI LRE LRO; 4 ('RTL') (line 73900)
std::vector<uint32_t> const cps = { 0x0020, 0x2068, 0x202A, 0x202D };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
}
TEST(bidi, bidi_147_040)
{
expected_levels = { 1, 1, -1, -1 };
expected_reordered_indices = { 1, 0 };
{
// WS FSI LRE RLE; 4 ('RTL') (line 73901)
std::vector<uint32_t> const cps = { 0x0020, 0x2068, 0x202A, 0x202B };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS FSI LRE RLO; 4 ('RTL') (line 73902)
std::vector<uint32_t> const cps = { 0x0020, 0x2068, 0x202A, 0x202E };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS FSI LRE PDF; 4 ('RTL') (line 73903)
std::vector<uint32_t> const cps = { 0x0020, 0x2068, 0x202A, 0x202C };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS FSI LRE BN; 4 ('RTL') (line 73904)
std::vector<uint32_t> const cps = { 0x0020, 0x2068, 0x202A, 0x00AD };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS FSI LRO LRE; 4 ('RTL') (line 73905)
std::vector<uint32_t> const cps = { 0x0020, 0x2068, 0x202D, 0x202A };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS FSI LRO LRO; 4 ('RTL') (line 73906)
std::vector<uint32_t> const cps = { 0x0020, 0x2068, 0x202D, 0x202D };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS FSI LRO RLE; 4 ('RTL') (line 73907)
std::vector<uint32_t> const cps = { 0x0020, 0x2068, 0x202D, 0x202B };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS FSI LRO RLO; 4 ('RTL') (line 73908)
std::vector<uint32_t> const cps = { 0x0020, 0x2068, 0x202D, 0x202E };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS FSI LRO PDF; 4 ('RTL') (line 73909)
std::vector<uint32_t> const cps = { 0x0020, 0x2068, 0x202D, 0x202C };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS FSI LRO BN; 4 ('RTL') (line 73910)
std::vector<uint32_t> const cps = { 0x0020, 0x2068, 0x202D, 0x00AD };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
}
TEST(bidi, bidi_147_041)
{
expected_levels = { 1, 1, -1, -1 };
expected_reordered_indices = { 1, 0 };
{
// WS FSI RLE LRE; 4 ('RTL') (line 73911)
std::vector<uint32_t> const cps = { 0x0020, 0x2068, 0x202B, 0x202A };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS FSI RLE LRO; 4 ('RTL') (line 73912)
std::vector<uint32_t> const cps = { 0x0020, 0x2068, 0x202B, 0x202D };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS FSI RLE RLE; 4 ('RTL') (line 73913)
std::vector<uint32_t> const cps = { 0x0020, 0x2068, 0x202B, 0x202B };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS FSI RLE RLO; 4 ('RTL') (line 73914)
std::vector<uint32_t> const cps = { 0x0020, 0x2068, 0x202B, 0x202E };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS FSI RLE PDF; 4 ('RTL') (line 73915)
std::vector<uint32_t> const cps = { 0x0020, 0x2068, 0x202B, 0x202C };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS FSI RLE BN; 4 ('RTL') (line 73916)
std::vector<uint32_t> const cps = { 0x0020, 0x2068, 0x202B, 0x00AD };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS FSI RLO LRE; 4 ('RTL') (line 73917)
std::vector<uint32_t> const cps = { 0x0020, 0x2068, 0x202E, 0x202A };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS FSI RLO LRO; 4 ('RTL') (line 73918)
std::vector<uint32_t> const cps = { 0x0020, 0x2068, 0x202E, 0x202D };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS FSI RLO RLE; 4 ('RTL') (line 73919)
std::vector<uint32_t> const cps = { 0x0020, 0x2068, 0x202E, 0x202B };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS FSI RLO RLO; 4 ('RTL') (line 73920)
std::vector<uint32_t> const cps = { 0x0020, 0x2068, 0x202E, 0x202E };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
}
TEST(bidi, bidi_147_042)
{
expected_levels = { 1, 1, -1, -1 };
expected_reordered_indices = { 1, 0 };
{
// WS FSI RLO PDF; 4 ('RTL') (line 73921)
std::vector<uint32_t> const cps = { 0x0020, 0x2068, 0x202E, 0x202C };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS FSI RLO BN; 4 ('RTL') (line 73922)
std::vector<uint32_t> const cps = { 0x0020, 0x2068, 0x202E, 0x00AD };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS FSI PDF LRE; 4 ('RTL') (line 73923)
std::vector<uint32_t> const cps = { 0x0020, 0x2068, 0x202C, 0x202A };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS FSI PDF LRO; 4 ('RTL') (line 73924)
std::vector<uint32_t> const cps = { 0x0020, 0x2068, 0x202C, 0x202D };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS FSI PDF RLE; 4 ('RTL') (line 73925)
std::vector<uint32_t> const cps = { 0x0020, 0x2068, 0x202C, 0x202B };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS FSI PDF RLO; 4 ('RTL') (line 73926)
std::vector<uint32_t> const cps = { 0x0020, 0x2068, 0x202C, 0x202E };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS FSI PDF PDF; 4 ('RTL') (line 73927)
std::vector<uint32_t> const cps = { 0x0020, 0x2068, 0x202C, 0x202C };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS FSI PDF BN; 4 ('RTL') (line 73928)
std::vector<uint32_t> const cps = { 0x0020, 0x2068, 0x202C, 0x00AD };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS FSI BN LRE; 4 ('RTL') (line 73929)
std::vector<uint32_t> const cps = { 0x0020, 0x2068, 0x00AD, 0x202A };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS FSI BN LRO; 4 ('RTL') (line 73930)
std::vector<uint32_t> const cps = { 0x0020, 0x2068, 0x00AD, 0x202D };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
}
TEST(bidi, bidi_147_043)
{
expected_levels = { 1, 1, -1, -1 };
expected_reordered_indices = { 1, 0 };
{
// WS FSI BN RLE; 4 ('RTL') (line 73931)
std::vector<uint32_t> const cps = { 0x0020, 0x2068, 0x00AD, 0x202B };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS FSI BN RLO; 4 ('RTL') (line 73932)
std::vector<uint32_t> const cps = { 0x0020, 0x2068, 0x00AD, 0x202E };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS FSI BN PDF; 4 ('RTL') (line 73933)
std::vector<uint32_t> const cps = { 0x0020, 0x2068, 0x00AD, 0x202C };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS FSI BN BN; 4 ('RTL') (line 73934)
std::vector<uint32_t> const cps = { 0x0020, 0x2068, 0x00AD, 0x00AD };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS PDI LRE LRE; 4 ('RTL') (line 73935)
std::vector<uint32_t> const cps = { 0x0020, 0x2069, 0x202A, 0x202A };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS PDI LRE LRO; 4 ('RTL') (line 73936)
std::vector<uint32_t> const cps = { 0x0020, 0x2069, 0x202A, 0x202D };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS PDI LRE RLE; 4 ('RTL') (line 73937)
std::vector<uint32_t> const cps = { 0x0020, 0x2069, 0x202A, 0x202B };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS PDI LRE RLO; 4 ('RTL') (line 73938)
std::vector<uint32_t> const cps = { 0x0020, 0x2069, 0x202A, 0x202E };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS PDI LRE PDF; 4 ('RTL') (line 73939)
std::vector<uint32_t> const cps = { 0x0020, 0x2069, 0x202A, 0x202C };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS PDI LRE BN; 4 ('RTL') (line 73940)
std::vector<uint32_t> const cps = { 0x0020, 0x2069, 0x202A, 0x00AD };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
}
TEST(bidi, bidi_147_044)
{
expected_levels = { 1, 1, -1, -1 };
expected_reordered_indices = { 1, 0 };
{
// WS PDI LRO LRE; 4 ('RTL') (line 73941)
std::vector<uint32_t> const cps = { 0x0020, 0x2069, 0x202D, 0x202A };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS PDI LRO LRO; 4 ('RTL') (line 73942)
std::vector<uint32_t> const cps = { 0x0020, 0x2069, 0x202D, 0x202D };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS PDI LRO RLE; 4 ('RTL') (line 73943)
std::vector<uint32_t> const cps = { 0x0020, 0x2069, 0x202D, 0x202B };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS PDI LRO RLO; 4 ('RTL') (line 73944)
std::vector<uint32_t> const cps = { 0x0020, 0x2069, 0x202D, 0x202E };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS PDI LRO PDF; 4 ('RTL') (line 73945)
std::vector<uint32_t> const cps = { 0x0020, 0x2069, 0x202D, 0x202C };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS PDI LRO BN; 4 ('RTL') (line 73946)
std::vector<uint32_t> const cps = { 0x0020, 0x2069, 0x202D, 0x00AD };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS PDI RLE LRE; 4 ('RTL') (line 73947)
std::vector<uint32_t> const cps = { 0x0020, 0x2069, 0x202B, 0x202A };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS PDI RLE LRO; 4 ('RTL') (line 73948)
std::vector<uint32_t> const cps = { 0x0020, 0x2069, 0x202B, 0x202D };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS PDI RLE RLE; 4 ('RTL') (line 73949)
std::vector<uint32_t> const cps = { 0x0020, 0x2069, 0x202B, 0x202B };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS PDI RLE RLO; 4 ('RTL') (line 73950)
std::vector<uint32_t> const cps = { 0x0020, 0x2069, 0x202B, 0x202E };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
}
TEST(bidi, bidi_147_045)
{
expected_levels = { 1, 1, -1, -1 };
expected_reordered_indices = { 1, 0 };
{
// WS PDI RLE PDF; 4 ('RTL') (line 73951)
std::vector<uint32_t> const cps = { 0x0020, 0x2069, 0x202B, 0x202C };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS PDI RLE BN; 4 ('RTL') (line 73952)
std::vector<uint32_t> const cps = { 0x0020, 0x2069, 0x202B, 0x00AD };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS PDI RLO LRE; 4 ('RTL') (line 73953)
std::vector<uint32_t> const cps = { 0x0020, 0x2069, 0x202E, 0x202A };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS PDI RLO LRO; 4 ('RTL') (line 73954)
std::vector<uint32_t> const cps = { 0x0020, 0x2069, 0x202E, 0x202D };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS PDI RLO RLE; 4 ('RTL') (line 73955)
std::vector<uint32_t> const cps = { 0x0020, 0x2069, 0x202E, 0x202B };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS PDI RLO RLO; 4 ('RTL') (line 73956)
std::vector<uint32_t> const cps = { 0x0020, 0x2069, 0x202E, 0x202E };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS PDI RLO PDF; 4 ('RTL') (line 73957)
std::vector<uint32_t> const cps = { 0x0020, 0x2069, 0x202E, 0x202C };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS PDI RLO BN; 4 ('RTL') (line 73958)
std::vector<uint32_t> const cps = { 0x0020, 0x2069, 0x202E, 0x00AD };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS PDI PDF LRE; 4 ('RTL') (line 73959)
std::vector<uint32_t> const cps = { 0x0020, 0x2069, 0x202C, 0x202A };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS PDI PDF LRO; 4 ('RTL') (line 73960)
std::vector<uint32_t> const cps = { 0x0020, 0x2069, 0x202C, 0x202D };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
}
TEST(bidi, bidi_147_046)
{
expected_levels = { 1, 1, -1, -1 };
expected_reordered_indices = { 1, 0 };
{
// WS PDI PDF RLE; 4 ('RTL') (line 73961)
std::vector<uint32_t> const cps = { 0x0020, 0x2069, 0x202C, 0x202B };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS PDI PDF RLO; 4 ('RTL') (line 73962)
std::vector<uint32_t> const cps = { 0x0020, 0x2069, 0x202C, 0x202E };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS PDI PDF PDF; 4 ('RTL') (line 73963)
std::vector<uint32_t> const cps = { 0x0020, 0x2069, 0x202C, 0x202C };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS PDI PDF BN; 4 ('RTL') (line 73964)
std::vector<uint32_t> const cps = { 0x0020, 0x2069, 0x202C, 0x00AD };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS PDI BN LRE; 4 ('RTL') (line 73965)
std::vector<uint32_t> const cps = { 0x0020, 0x2069, 0x00AD, 0x202A };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS PDI BN LRO; 4 ('RTL') (line 73966)
std::vector<uint32_t> const cps = { 0x0020, 0x2069, 0x00AD, 0x202D };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS PDI BN RLE; 4 ('RTL') (line 73967)
std::vector<uint32_t> const cps = { 0x0020, 0x2069, 0x00AD, 0x202B };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS PDI BN RLO; 4 ('RTL') (line 73968)
std::vector<uint32_t> const cps = { 0x0020, 0x2069, 0x00AD, 0x202E };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS PDI BN PDF; 4 ('RTL') (line 73969)
std::vector<uint32_t> const cps = { 0x0020, 0x2069, 0x00AD, 0x202C };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// WS PDI BN BN; 4 ('RTL') (line 73970)
std::vector<uint32_t> const cps = { 0x0020, 0x2069, 0x00AD, 0x00AD };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
}
TEST(bidi, bidi_147_047)
{
expected_levels = { 1, 1, -1, -1 };
expected_reordered_indices = { 1, 0 };
{
// ON R LRE LRE; 5 ('auto') (line 73971)
std::vector<uint32_t> const cps = { 0x0021, 0x05BE, 0x202A, 0x202A };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), -1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), -1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, -1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// ON R LRE LRE; 5 ('RTL') (line 73971)
std::vector<uint32_t> const cps = { 0x0021, 0x05BE, 0x202A, 0x202A };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// ON R LRE LRO; 5 ('auto') (line 73972)
std::vector<uint32_t> const cps = { 0x0021, 0x05BE, 0x202A, 0x202D };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), -1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), -1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, -1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// ON R LRE LRO; 5 ('RTL') (line 73972)
std::vector<uint32_t> const cps = { 0x0021, 0x05BE, 0x202A, 0x202D };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// ON R LRE RLE; 5 ('auto') (line 73973)
std::vector<uint32_t> const cps = { 0x0021, 0x05BE, 0x202A, 0x202B };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), -1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), -1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, -1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// ON R LRE RLE; 5 ('RTL') (line 73973)
std::vector<uint32_t> const cps = { 0x0021, 0x05BE, 0x202A, 0x202B };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// ON R LRE RLO; 5 ('auto') (line 73974)
std::vector<uint32_t> const cps = { 0x0021, 0x05BE, 0x202A, 0x202E };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), -1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), -1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, -1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// ON R LRE RLO; 5 ('RTL') (line 73974)
std::vector<uint32_t> const cps = { 0x0021, 0x05BE, 0x202A, 0x202E };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// ON R LRE PDF; 5 ('auto') (line 73975)
std::vector<uint32_t> const cps = { 0x0021, 0x05BE, 0x202A, 0x202C };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), -1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), -1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, -1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// ON R LRE PDF; 5 ('RTL') (line 73975)
std::vector<uint32_t> const cps = { 0x0021, 0x05BE, 0x202A, 0x202C };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// ON R LRE BN; 5 ('auto') (line 73976)
std::vector<uint32_t> const cps = { 0x0021, 0x05BE, 0x202A, 0x00AD };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), -1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), -1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, -1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// ON R LRE BN; 5 ('RTL') (line 73976)
std::vector<uint32_t> const cps = { 0x0021, 0x05BE, 0x202A, 0x00AD };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// ON R LRO LRE; 5 ('auto') (line 73977)
std::vector<uint32_t> const cps = { 0x0021, 0x05BE, 0x202D, 0x202A };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), -1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), -1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, -1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// ON R LRO LRE; 5 ('RTL') (line 73977)
std::vector<uint32_t> const cps = { 0x0021, 0x05BE, 0x202D, 0x202A };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// ON R LRO LRO; 5 ('auto') (line 73978)
std::vector<uint32_t> const cps = { 0x0021, 0x05BE, 0x202D, 0x202D };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), -1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), -1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, -1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// ON R LRO LRO; 5 ('RTL') (line 73978)
std::vector<uint32_t> const cps = { 0x0021, 0x05BE, 0x202D, 0x202D };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// ON R LRO RLE; 5 ('auto') (line 73979)
std::vector<uint32_t> const cps = { 0x0021, 0x05BE, 0x202D, 0x202B };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), -1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), -1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, -1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// ON R LRO RLE; 5 ('RTL') (line 73979)
std::vector<uint32_t> const cps = { 0x0021, 0x05BE, 0x202D, 0x202B };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// ON R LRO RLO; 5 ('auto') (line 73980)
std::vector<uint32_t> const cps = { 0x0021, 0x05BE, 0x202D, 0x202E };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), -1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), -1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, -1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// ON R LRO RLO; 5 ('RTL') (line 73980)
std::vector<uint32_t> const cps = { 0x0021, 0x05BE, 0x202D, 0x202E };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
}
TEST(bidi, bidi_147_048)
{
expected_levels = { 1, 1, -1, -1 };
expected_reordered_indices = { 1, 0 };
{
// ON R LRO PDF; 5 ('auto') (line 73981)
std::vector<uint32_t> const cps = { 0x0021, 0x05BE, 0x202D, 0x202C };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), -1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), -1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, -1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// ON R LRO PDF; 5 ('RTL') (line 73981)
std::vector<uint32_t> const cps = { 0x0021, 0x05BE, 0x202D, 0x202C };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// ON R LRO BN; 5 ('auto') (line 73982)
std::vector<uint32_t> const cps = { 0x0021, 0x05BE, 0x202D, 0x00AD };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), -1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), -1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, -1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// ON R LRO BN; 5 ('RTL') (line 73982)
std::vector<uint32_t> const cps = { 0x0021, 0x05BE, 0x202D, 0x00AD };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// ON R RLE LRE; 5 ('auto') (line 73983)
std::vector<uint32_t> const cps = { 0x0021, 0x05BE, 0x202B, 0x202A };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), -1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), -1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, -1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// ON R RLE LRE; 5 ('RTL') (line 73983)
std::vector<uint32_t> const cps = { 0x0021, 0x05BE, 0x202B, 0x202A };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// ON R RLE LRO; 5 ('auto') (line 73984)
std::vector<uint32_t> const cps = { 0x0021, 0x05BE, 0x202B, 0x202D };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), -1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), -1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, -1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// ON R RLE LRO; 5 ('RTL') (line 73984)
std::vector<uint32_t> const cps = { 0x0021, 0x05BE, 0x202B, 0x202D };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// ON R RLE RLE; 5 ('auto') (line 73985)
std::vector<uint32_t> const cps = { 0x0021, 0x05BE, 0x202B, 0x202B };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), -1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), -1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, -1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// ON R RLE RLE; 5 ('RTL') (line 73985)
std::vector<uint32_t> const cps = { 0x0021, 0x05BE, 0x202B, 0x202B };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// ON R RLE RLO; 5 ('auto') (line 73986)
std::vector<uint32_t> const cps = { 0x0021, 0x05BE, 0x202B, 0x202E };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), -1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), -1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, -1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// ON R RLE RLO; 5 ('RTL') (line 73986)
std::vector<uint32_t> const cps = { 0x0021, 0x05BE, 0x202B, 0x202E };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// ON R RLE PDF; 5 ('auto') (line 73987)
std::vector<uint32_t> const cps = { 0x0021, 0x05BE, 0x202B, 0x202C };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), -1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), -1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, -1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// ON R RLE PDF; 5 ('RTL') (line 73987)
std::vector<uint32_t> const cps = { 0x0021, 0x05BE, 0x202B, 0x202C };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// ON R RLE BN; 5 ('auto') (line 73988)
std::vector<uint32_t> const cps = { 0x0021, 0x05BE, 0x202B, 0x00AD };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), -1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), -1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, -1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// ON R RLE BN; 5 ('RTL') (line 73988)
std::vector<uint32_t> const cps = { 0x0021, 0x05BE, 0x202B, 0x00AD };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// ON R RLO LRE; 5 ('auto') (line 73989)
std::vector<uint32_t> const cps = { 0x0021, 0x05BE, 0x202E, 0x202A };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), -1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), -1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, -1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// ON R RLO LRE; 5 ('RTL') (line 73989)
std::vector<uint32_t> const cps = { 0x0021, 0x05BE, 0x202E, 0x202A };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// ON R RLO LRO; 5 ('auto') (line 73990)
std::vector<uint32_t> const cps = { 0x0021, 0x05BE, 0x202E, 0x202D };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), -1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), -1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, -1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// ON R RLO LRO; 5 ('RTL') (line 73990)
std::vector<uint32_t> const cps = { 0x0021, 0x05BE, 0x202E, 0x202D };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
}
TEST(bidi, bidi_147_049)
{
expected_levels = { 1, 1, -1, -1 };
expected_reordered_indices = { 1, 0 };
{
// ON R RLO RLE; 5 ('auto') (line 73991)
std::vector<uint32_t> const cps = { 0x0021, 0x05BE, 0x202E, 0x202B };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), -1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), -1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, -1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// ON R RLO RLE; 5 ('RTL') (line 73991)
std::vector<uint32_t> const cps = { 0x0021, 0x05BE, 0x202E, 0x202B };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// ON R RLO RLO; 5 ('auto') (line 73992)
std::vector<uint32_t> const cps = { 0x0021, 0x05BE, 0x202E, 0x202E };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), -1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), -1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, -1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// ON R RLO RLO; 5 ('RTL') (line 73992)
std::vector<uint32_t> const cps = { 0x0021, 0x05BE, 0x202E, 0x202E };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// ON R RLO PDF; 5 ('auto') (line 73993)
std::vector<uint32_t> const cps = { 0x0021, 0x05BE, 0x202E, 0x202C };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), -1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), -1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, -1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// ON R RLO PDF; 5 ('RTL') (line 73993)
std::vector<uint32_t> const cps = { 0x0021, 0x05BE, 0x202E, 0x202C };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// ON R RLO BN; 5 ('auto') (line 73994)
std::vector<uint32_t> const cps = { 0x0021, 0x05BE, 0x202E, 0x00AD };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), -1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), -1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, -1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// ON R RLO BN; 5 ('RTL') (line 73994)
std::vector<uint32_t> const cps = { 0x0021, 0x05BE, 0x202E, 0x00AD };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// ON R PDF LRE; 5 ('auto') (line 73995)
std::vector<uint32_t> const cps = { 0x0021, 0x05BE, 0x202C, 0x202A };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), -1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), -1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, -1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// ON R PDF LRE; 5 ('RTL') (line 73995)
std::vector<uint32_t> const cps = { 0x0021, 0x05BE, 0x202C, 0x202A };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// ON R PDF LRO; 5 ('auto') (line 73996)
std::vector<uint32_t> const cps = { 0x0021, 0x05BE, 0x202C, 0x202D };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), -1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), -1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, -1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// ON R PDF LRO; 5 ('RTL') (line 73996)
std::vector<uint32_t> const cps = { 0x0021, 0x05BE, 0x202C, 0x202D };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// ON R PDF RLE; 5 ('auto') (line 73997)
std::vector<uint32_t> const cps = { 0x0021, 0x05BE, 0x202C, 0x202B };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), -1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), -1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, -1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// ON R PDF RLE; 5 ('RTL') (line 73997)
std::vector<uint32_t> const cps = { 0x0021, 0x05BE, 0x202C, 0x202B };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// ON R PDF RLO; 5 ('auto') (line 73998)
std::vector<uint32_t> const cps = { 0x0021, 0x05BE, 0x202C, 0x202E };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), -1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), -1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, -1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// ON R PDF RLO; 5 ('RTL') (line 73998)
std::vector<uint32_t> const cps = { 0x0021, 0x05BE, 0x202C, 0x202E };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// ON R PDF PDF; 5 ('auto') (line 73999)
std::vector<uint32_t> const cps = { 0x0021, 0x05BE, 0x202C, 0x202C };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), -1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), -1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, -1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// ON R PDF PDF; 5 ('RTL') (line 73999)
std::vector<uint32_t> const cps = { 0x0021, 0x05BE, 0x202C, 0x202C };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// ON R PDF BN; 5 ('auto') (line 74000)
std::vector<uint32_t> const cps = { 0x0021, 0x05BE, 0x202C, 0x00AD };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), -1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), -1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, -1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
{
// ON R PDF BN; 5 ('RTL') (line 74000)
std::vector<uint32_t> const cps = { 0x0021, 0x05BE, 0x202C, 0x00AD };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
// Skip FSI, LRI, RLI, and PDI.
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
std::vector<int> reordered_2;
for (auto subrange :
boost::text::bidirectional_subranges(cps, 1)) {
for (auto cp : subrange) {
reordered_2.push_back(cp);
}
}
i = 0;
for (int idx : expected_reordered_indices) {
if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) {
EXPECT_EQ(reordered_2[i], cps[idx])
<< std::hex
<< " 0x" << reordered_2[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
}
++i;
}
EXPECT_EQ(i, (int)reordered_2.size());
}
}
| 32.966124
| 77
| 0.403859
|
eightysquirrels
|
73159be7e2d0d0940067990682acd252c4792721
| 2,737
|
cpp
|
C++
|
libcxx/test/std/containers/views/span.obs/empty.pass.cpp
|
elizabethandrews/llvm
|
308498236c1c4778fdcba0bfbb556adf8aa333ea
|
[
"Apache-2.0"
] | 305
|
2019-09-14T17:16:05.000Z
|
2022-03-31T15:05:20.000Z
|
libcxx/test/std/containers/views/span.obs/empty.pass.cpp
|
elizabethandrews/llvm
|
308498236c1c4778fdcba0bfbb556adf8aa333ea
|
[
"Apache-2.0"
] | 410
|
2019-06-06T20:52:32.000Z
|
2022-01-18T14:21:48.000Z
|
libcxx/test/std/containers/views/span.obs/empty.pass.cpp
|
elizabethandrews/llvm
|
308498236c1c4778fdcba0bfbb556adf8aa333ea
|
[
"Apache-2.0"
] | 50
|
2019-05-10T21:12:24.000Z
|
2022-01-21T06:39:47.000Z
|
// -*- C++ -*-
//===------------------------------ span ---------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===---------------------------------------------------------------------===//
// UNSUPPORTED: c++03, c++11, c++14, c++17
// <span>
// constexpr bool empty() const noexcept;
//
#include <span>
#include <cassert>
#include <string>
#include "test_macros.h"
struct A{};
constexpr int iArr1[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
int iArr2[] = {10, 11, 12, 13, 14, 15, 16, 17, 18, 19};
int main(int, char**)
{
static_assert( noexcept(std::span<int> ().empty()), "");
static_assert( noexcept(std::span<int, 0>().empty()), "");
static_assert( std::span<int>().empty(), "");
static_assert( std::span<long>().empty(), "");
static_assert( std::span<double>().empty(), "");
static_assert( std::span<A>().empty(), "");
static_assert( std::span<std::string>().empty(), "");
static_assert( std::span<int, 0>().empty(), "");
static_assert( std::span<long, 0>().empty(), "");
static_assert( std::span<double, 0>().empty(), "");
static_assert( std::span<A, 0>().empty(), "");
static_assert( std::span<std::string, 0>().empty(), "");
static_assert(!std::span<const int>(iArr1, 1).empty(), "");
static_assert(!std::span<const int>(iArr1, 2).empty(), "");
static_assert(!std::span<const int>(iArr1, 3).empty(), "");
static_assert(!std::span<const int>(iArr1, 4).empty(), "");
static_assert(!std::span<const int>(iArr1, 5).empty(), "");
assert( (std::span<int>().empty() ));
assert( (std::span<long>().empty() ));
assert( (std::span<double>().empty() ));
assert( (std::span<A>().empty() ));
assert( (std::span<std::string>().empty() ));
assert( (std::span<int, 0>().empty() ));
assert( (std::span<long, 0>().empty() ));
assert( (std::span<double, 0>().empty() ));
assert( (std::span<A, 0>().empty() ));
assert( (std::span<std::string, 0>().empty()));
assert(!(std::span<int, 1>(iArr2, 1).empty()));
assert(!(std::span<int, 2>(iArr2, 2).empty()));
assert(!(std::span<int, 3>(iArr2, 3).empty()));
assert(!(std::span<int, 4>(iArr2, 4).empty()));
assert(!(std::span<int, 5>(iArr2, 5).empty()));
std::string s;
assert( ((std::span<std::string>(&s, (std::size_t) 0)).empty()));
assert(!((std::span<std::string>(&s, 1).empty())));
return 0;
}
| 36.493333
| 80
| 0.502009
|
elizabethandrews
|
7317ba74f6f2bad7cc0fb55df7288340d6c4720b
| 7,205
|
cpp
|
C++
|
src/reduce.cpp
|
q3k/cadical
|
b490c98b9b4a4bb66c04cbc3e535c3205f4ccc17
|
[
"MIT"
] | null | null | null |
src/reduce.cpp
|
q3k/cadical
|
b490c98b9b4a4bb66c04cbc3e535c3205f4ccc17
|
[
"MIT"
] | null | null | null |
src/reduce.cpp
|
q3k/cadical
|
b490c98b9b4a4bb66c04cbc3e535c3205f4ccc17
|
[
"MIT"
] | null | null | null |
#include "internal.hpp"
namespace CaDiCaL {
/*------------------------------------------------------------------------*/
// Once in a while we reduce, e.g., we remove learned clauses which are
// supposed to be less useful in the future. This is done in increasing
// intervals, which has the effect of allowing more and more learned clause
// to be kept for a longer period. The number of learned clauses kept
// in memory corresponds to an upper bound on the 'space' of a resolution
// proof needed to refute a formula in proof complexity sense.
bool Internal::reducing () {
if (!opts.reduce) return false;
if (!stats.current.redundant) return false;
return stats.conflicts >= lim.reduce;
}
/*------------------------------------------------------------------------*/
// Even less regularly we are flushing all redundant clauses.
bool Internal::flushing () {
if (!opts.flush) return false;
return stats.conflicts >= lim.flush;
}
/*------------------------------------------------------------------------*/
// Reason clauses (on non-zero decision level) can not be collected.
// We protect them before and unprotect them after garbage collection.
void Internal::protect_reasons () {
for (const auto & lit : trail) {
Var & v = var (lit);
if (!v.level || !v.reason) continue;
LOG (v.reason, "protecting");
v.reason->reason = true;
}
}
void Internal::unprotect_reasons () {
for (const auto & lit : trail) {
Var & v = var (lit);
if (!v.level || !v.reason) continue;
assert (v.reason->reason), v.reason->reason = false;
}
}
/*------------------------------------------------------------------------*/
void Internal::mark_clauses_to_be_flushed () {
for (const auto & c : clauses) {
if (!c->redundant) continue; // keep irredundant
if (c->garbage) continue; // already marked as garbage
if (c->reason) continue; // need to keep reasons
const bool used = c->used;
c->used = false;
if (used) continue; // but keep recently used clauses
mark_garbage (c); // flush unused clauses
if (c->hyper) stats.flush.hyper++;
else stats.flush.learned++;
}
// No change to 'lim.kept{size,glue}'.
}
/*------------------------------------------------------------------------*/
// Clauses of larger glue or larger size are considered less useful.
//
// We also follow the observations made by the Glucose team in their
// IJCAI'09 paper and keep all low glue clauses limited by
// 'options.keepglue' (typically '3').
//
// In earlier versions we pre-computed a 64-bit sort key per clause and
// wrapped a pointer to the clause and the 64-bit sort key into a separate
// data structure for sorting. This was probably faster but awkward and
// so we moved back to a simpler scheme which also uses 'stable_sort'
// instead of 'rsort' below. Sorting here is not a hot-spot anyhow.
struct reduce_less_useful {
bool operator () (const Clause * c, const Clause * d) const {
if (c->glue > d->glue) return true;
if (c->glue < d->glue) return false;
return c->size > d->size;
}
};
// This function implements the important reduction policy. It determines
// which redundant clauses are considered not useful and thus will be
// collected in a subsequent garbage collection phase.
void Internal::mark_useless_redundant_clauses_as_garbage () {
// We use a separate stack for sorting candidates for removal. This uses
// (slightly) more memory but has the advantage to keep the relative order
// in 'clauses' intact, which actually due to using stable sorting goes
// into the candidate selection (more recently learned clauses are kept if
// they otherwise have the same glue and size).
vector<Clause *> stack;
stack.reserve (stats.current.redundant);
for (const auto & c : clauses) {
if (!c->redundant) continue; // Keep irredundant.
if (c->garbage) continue; // Skip already marked.
if (c->reason) continue; // Need to keep reasons.
const bool used = c->used;
c->used = false;
if (c->hyper) { // Hyper binary and ternary resolvents
assert (c->size <= 3); // are only kept for one reduce round
if (!used) mark_garbage (c); // (even if 'c->keep' is true) unless
continue; // used recently.
}
if (used) continue; // Do keep recently used clauses.
if (c->keep) continue; // Forced to keep (see above).
stack.push_back (c);
}
stable_sort (stack.begin (), stack.end (), reduce_less_useful ());
size_t target = 1e-2 * opts.reducetarget * stack.size ();
// This is defensive code, which I usually consider a bug, but here I am
// just not sure that using floating points in the line above is precise
// in all situations and instead of figuring that out, I just use this.
//
if (target > stack.size ()) target = stack.size ();
PHASE ("reduce", stats.reductions, "reducing %zd clauses %.0f%%",
target, percent (target, stats.current.redundant));
auto i = stack.begin ();
const auto t = i + target;
while (i != t) {
Clause * c = *i++;
LOG (c, "marking useless to be collected");
mark_garbage (c);
stats.reduced++;
}
lim.keptsize = lim.keptglue = 0;
const auto end = stack.end ();
for (i = t; i != end; i++) {
Clause * c = *i;
LOG (c, "keeping");
if (c->size > lim.keptsize) lim.keptsize = c->size;
if (c->glue > lim.keptglue) lim.keptglue = c->glue;
}
erase_vector (stack);
PHASE ("reduce", stats.reductions,
"maximum kept size %d glue %d", lim.keptsize, lim.keptglue);
}
/*------------------------------------------------------------------------*/
void Internal::reduce () {
START (reduce);
stats.reductions++;
report ('.', 1);
bool flush = flushing ();
if (flush) stats.flush.count++;
if (level) {
int ooo = 0;
for (size_t i = control[1].trail; !ooo && i < trail.size (); i++) {
const int lit = trail[i];
assert (val (lit) > 0);
if (var (lit).level) continue;
LOG ("found out-of-order assigned unit %d", ooo);
ooo = lit;
}
if (ooo) {
backtrack (0);
if (!propagate ()) {
learn_empty_clause ();
goto DONE;
}
}
}
if (level) protect_reasons ();
mark_satisfied_clauses_as_garbage ();
if (flush) mark_clauses_to_be_flushed ();
else mark_useless_redundant_clauses_as_garbage ();
garbage_collection ();
if (level) unprotect_reasons ();
{
long delta = opts.reduceint * (stats.reductions + 1);
if (irredundant () > 1e5) {
delta *= log (irredundant ()/1e4) / log (10);
if (delta < 1) delta = 1;
}
lim.reduce = stats.conflicts + delta;
PHASE ("reduce", stats.reductions,
"new reduce limit %ld after %ld conflicts",
lim.reduce, delta);
}
if (flush) {
PHASE ("flush", stats.flush.count, "new flush increment %ld", inc.flush);
inc.flush *= opts.flushfactor;
lim.flush = stats.conflicts + inc.flush;
PHASE ("flush", stats.flush.count, "new flush limit %ld", lim.flush);
}
last.reduce.conflicts = stats.conflicts;
DONE:
report (flush ? 'f' : '-');
STOP (reduce);
}
}
| 32.022222
| 77
| 0.599722
|
q3k
|
731924b015015b67c832555ad1db1862aeea142d
| 2,194
|
cpp
|
C++
|
B2G/gecko/content/html/content/src/nsTimeRanges.cpp
|
wilebeast/FireFox-OS
|
43067f28711d78c429a1d6d58c77130f6899135f
|
[
"Apache-2.0"
] | 3
|
2015-08-31T15:24:31.000Z
|
2020-04-24T20:31:29.000Z
|
B2G/gecko/content/html/content/src/nsTimeRanges.cpp
|
wilebeast/FireFox-OS
|
43067f28711d78c429a1d6d58c77130f6899135f
|
[
"Apache-2.0"
] | null | null | null |
B2G/gecko/content/html/content/src/nsTimeRanges.cpp
|
wilebeast/FireFox-OS
|
43067f28711d78c429a1d6d58c77130f6899135f
|
[
"Apache-2.0"
] | 3
|
2015-07-29T07:17:15.000Z
|
2020-11-04T06:55:37.000Z
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim:set ts=2 sw=2 sts=2 et cindent: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "nsTimeRanges.h"
#include "nsDOMClassInfoID.h"
#include "nsError.h"
NS_IMPL_ADDREF(nsTimeRanges)
NS_IMPL_RELEASE(nsTimeRanges)
DOMCI_DATA(TimeRanges, nsTimeRanges)
NS_INTERFACE_MAP_BEGIN(nsTimeRanges)
NS_INTERFACE_MAP_ENTRY(nsISupports)
NS_INTERFACE_MAP_ENTRY(nsIDOMTimeRanges)
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(TimeRanges)
NS_INTERFACE_MAP_END
nsTimeRanges::nsTimeRanges()
{
MOZ_COUNT_CTOR(nsTimeRanges);
}
nsTimeRanges::~nsTimeRanges()
{
MOZ_COUNT_DTOR(nsTimeRanges);
}
NS_IMETHODIMP
nsTimeRanges::GetLength(uint32_t* aLength)
{
*aLength = mRanges.Length();
return NS_OK;
}
NS_IMETHODIMP
nsTimeRanges::Start(uint32_t aIndex, double* aTime)
{
if (aIndex >= mRanges.Length())
return NS_ERROR_DOM_INDEX_SIZE_ERR;
*aTime = mRanges[aIndex].mStart;
return NS_OK;
}
NS_IMETHODIMP
nsTimeRanges::End(uint32_t aIndex, double* aTime)
{
if (aIndex >= mRanges.Length())
return NS_ERROR_DOM_INDEX_SIZE_ERR;
*aTime = mRanges[aIndex].mEnd;
return NS_OK;
}
void
nsTimeRanges::Add(double aStart, double aEnd)
{
if (aStart > aEnd) {
NS_WARNING("Can't add a range if the end is older that the start.");
return;
}
mRanges.AppendElement(TimeRange(aStart,aEnd));
}
void
nsTimeRanges::Normalize()
{
if (mRanges.Length() >= 2) {
nsAutoTArray<TimeRange,4> normalized;
mRanges.Sort(CompareTimeRanges());
// This merges the intervals.
TimeRange current(mRanges[0]);
for (uint32_t i = 1; i < mRanges.Length(); i++) {
if (current.mStart <= mRanges[i].mStart &&
current.mEnd >= mRanges[i].mEnd) {
continue;
}
if (current.mEnd >= mRanges[i].mStart) {
current.mEnd = mRanges[i].mEnd;
} else {
normalized.AppendElement(current);
current = mRanges[i];
}
}
normalized.AppendElement(current);
mRanges = normalized;
}
}
| 23.094737
| 79
| 0.69371
|
wilebeast
|
731a636f01532dd8c90e3c135801e84941f53c85
| 1,833
|
cpp
|
C++
|
EZOJ/Contests/1046/A.cpp
|
sshockwave/Online-Judge-Solutions
|
9d0bc7fd68c3d1f661622929c1cb3752601881d3
|
[
"MIT"
] | 6
|
2019-09-30T16:11:00.000Z
|
2021-11-01T11:42:33.000Z
|
EZOJ/Contests/1046/A.cpp
|
sshockwave/Online-Judge-Solutions
|
9d0bc7fd68c3d1f661622929c1cb3752601881d3
|
[
"MIT"
] | 4
|
2017-11-21T08:17:42.000Z
|
2020-07-28T12:09:52.000Z
|
EZOJ/Contests/1046/A.cpp
|
sshockwave/Online-Judge-Solutions
|
9d0bc7fd68c3d1f661622929c1cb3752601881d3
|
[
"MIT"
] | 4
|
2017-07-26T05:54:06.000Z
|
2020-09-30T13:35:38.000Z
|
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cassert>
#include <cctype>
#include <vector>
using namespace std;
typedef long long lint;
#define cout cerr
#define ni (next_num<int>())
template<class T>inline T next_num(){
T i=0;char c;
while(!isdigit(c=getchar())&&c!='-');
bool flag=c=='-';
flag?(c=getchar()):0;
while(i=i*10-'0'+c,isdigit(c=getchar()));
return flag?-i:i;
}
const int N=100000010,rtN=10010,K=110,MOD=1000000007,F=1<<15;
inline int add(const int &a,const int &b){
return (a+b)%MOD;
}
inline int mul(const int &a,const int &b){
return (lint)a*b%MOD;
}
inline void apmul(int &a,const int &b){
a=mul(a,b);
}
inline int fpow(int x,int n){
int ret=1;
for(;n;n>>=1,apmul(x,x)){
if(n&1){
apmul(ret,x);
}
}
return ret;
}
inline int inv(int x){
return fpow(x,MOD-2);
}
int fct[F],fphi[F],fs;
inline void spwn(int x,int e){
int n=fs;
for(int i=1,v=1,lst;i<=e;i++){
lst=v,v*=x;
for(int j=0;j<n;j++){
fct[fs]=fct[j]*v,fphi[fs]=fphi[j]*(v-lst),fs++;
}
}
}
inline void tear(int n){
fs=0;
fct[fs]=1,fphi[fs]=1,fs++;
for(int i=2;i*i<=n;i++){
int e=0;
for(;n%i==0;n/=i,e++);
spwn(i,e);
}
if(n!=1){
spwn(n,1);
}
}
int c[K][K];
inline void gc(int n){
memset(c,0,sizeof(c));
c[0][0]=1;
for(int i=1;i<=n;i++){
c[i][0]=1;
for(int j=1;j<=i;j++){
c[i][j]=add(c[i-1][j-1],c[i-1][j]);
}
}
}
inline int Main(){
int n=ni,k=ni;
tear(n);
lint ans=0;
for(int i=0;i<=k;i++){
lint cur=0;
for(int j=0;j<fs;j++){
cur+=mul(fpow(i,n/fct[j]),fphi[j]);
}
cur=mul(cur%MOD,c[k][i]);
if((k-i)&1){
ans-=cur;
}else{
ans+=cur;
}
}
return mul((ans%MOD+MOD)%MOD,inv(n));
}
int main(){
#ifndef ONLINE_JUDGE
freopen("necklace.in","r",stdin);
freopen("necklace.out","w",stdout);
#endif
gc(K-1);
for(int tot=ni;tot--;printf("%d\n",Main()));
return 0;
}
| 18.148515
| 61
| 0.575559
|
sshockwave
|
731b64739268775e4a0cce56af12df7e76201772
| 4,979
|
cc
|
C++
|
src/AutoPilotPlugins/Common/SyslinkComponentController.cc
|
uav-operation-system/qgroundcontrol
|
c24029938e88d7a45a04f4e4e64bf588f595afed
|
[
"Apache-2.0"
] | 2,133
|
2015-01-04T03:10:22.000Z
|
2022-03-31T01:51:07.000Z
|
src/AutoPilotPlugins/Common/SyslinkComponentController.cc
|
uav-operation-system/qgroundcontrol
|
c24029938e88d7a45a04f4e4e64bf588f595afed
|
[
"Apache-2.0"
] | 6,166
|
2015-01-02T18:47:42.000Z
|
2022-03-31T03:44:10.000Z
|
src/AutoPilotPlugins/Common/SyslinkComponentController.cc
|
uav-operation-system/qgroundcontrol
|
c24029938e88d7a45a04f4e4e64bf588f595afed
|
[
"Apache-2.0"
] | 2,980
|
2015-01-01T03:09:18.000Z
|
2022-03-31T04:13:55.000Z
|
/****************************************************************************
*
* (c) 2009-2020 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
*
* QGroundControl is licensed according to the terms in the file
* COPYING.md in the root of the source code directory.
*
****************************************************************************/
#include "SyslinkComponentController.h"
#include "QGCApplication.h"
#include "UAS.h"
#include "ParameterManager.h"
#include <QHostAddress>
#include <QtEndian>
QGC_LOGGING_CATEGORY(SyslinkComponentControllerLog, "SyslinkComponentControllerLog")
//-----------------------------------------------------------------------------
SyslinkComponentController::SyslinkComponentController()
{
_dataRates.append(QStringLiteral("750Kb/s"));
_dataRates.append(QStringLiteral("1Mb/s"));
_dataRates.append(QStringLiteral("2Mb/s"));
Fact* chan = getParameterFact(_vehicle->id(), QStringLiteral("SLNK_RADIO_CHAN"));
connect(chan, &Fact::valueChanged, this, &SyslinkComponentController::_channelChanged);
Fact* rate = getParameterFact(_vehicle->id(), QStringLiteral("SLNK_RADIO_RATE"));
connect(rate, &Fact::valueChanged, this, &SyslinkComponentController::_rateChanged);
Fact* addr1 = getParameterFact(_vehicle->id(), QStringLiteral("SLNK_RADIO_ADDR1"));
connect(addr1, &Fact::valueChanged, this, &SyslinkComponentController::_addressChanged);
Fact* addr2 = getParameterFact(_vehicle->id(), QStringLiteral("SLNK_RADIO_ADDR2"));
connect(addr2, &Fact::valueChanged, this, &SyslinkComponentController::_addressChanged);
}
//-----------------------------------------------------------------------------
SyslinkComponentController::~SyslinkComponentController()
{
}
//-----------------------------------------------------------------------------
int
SyslinkComponentController::radioChannel()
{
return getParameterFact(_vehicle->id(), QStringLiteral("SLNK_RADIO_CHAN"))->rawValue().toUInt();
}
//-----------------------------------------------------------------------------
void
SyslinkComponentController::setRadioChannel(int num)
{
Fact* f = getParameterFact(_vehicle->id(), QStringLiteral("SLNK_RADIO_CHAN"));
f->setRawValue(QVariant(num));
}
//-----------------------------------------------------------------------------
QString
SyslinkComponentController::radioAddress()
{
uint32_t val_uh = getParameterFact(_vehicle->id(), QStringLiteral("SLNK_RADIO_ADDR1"))->rawValue().toUInt();
uint32_t val_lh = getParameterFact(_vehicle->id(), QStringLiteral("SLNK_RADIO_ADDR2"))->rawValue().toUInt();
uint64_t val = (((uint64_t) val_uh) << 32) | ((uint64_t) val_lh);
return QString().number(val, 16);
}
//-----------------------------------------------------------------------------
void
SyslinkComponentController::setRadioAddress(QString str)
{
Fact *uh = getParameterFact(_vehicle->id(), QStringLiteral("SLNK_RADIO_ADDR1"));
Fact *lh = getParameterFact(_vehicle->id(), QStringLiteral("SLNK_RADIO_ADDR2"));
uint64_t val = str.toULongLong(0, 16);
uint32_t val_uh = val >> 32;
uint32_t val_lh = val & 0xFFFFFFFF;
uh->setRawValue(QVariant(val_uh));
lh->setRawValue(QVariant(val_lh));
}
//-----------------------------------------------------------------------------
int
SyslinkComponentController::radioRate()
{
return getParameterFact(_vehicle->id(), QStringLiteral("SLNK_RADIO_RATE"))->rawValue().toInt();
}
//-----------------------------------------------------------------------------
void
SyslinkComponentController::setRadioRate(int idx)
{
if(idx >= 0 && idx <= 2 && idx != radioRate()) {
Fact* r = getParameterFact(_vehicle->id(), QStringLiteral("SLNK_RADIO_RATE"));
r->setRawValue(idx);
}
}
//-----------------------------------------------------------------------------
void
SyslinkComponentController::resetDefaults()
{
Fact* chan = getParameterFact(_vehicle->id(), QStringLiteral("SLNK_RADIO_CHAN"));
Fact* rate = getParameterFact(_vehicle->id(), QStringLiteral("SLNK_RADIO_RATE"));
Fact* addr1 = getParameterFact(_vehicle->id(), QStringLiteral("SLNK_RADIO_ADDR1"));
Fact* addr2 = getParameterFact(_vehicle->id(), QStringLiteral("SLNK_RADIO_ADDR2"));
chan->setRawValue(chan->rawDefaultValue());
rate->setRawValue(rate->rawDefaultValue());
addr1->setRawValue(addr1->rawDefaultValue());
addr2->setRawValue(addr2->rawDefaultValue());
}
//-----------------------------------------------------------------------------
void
SyslinkComponentController::_channelChanged(QVariant)
{
emit radioChannelChanged();
}
//-----------------------------------------------------------------------------
void
SyslinkComponentController::_addressChanged(QVariant)
{
emit radioAddressChanged();
}
//-----------------------------------------------------------------------------
void
SyslinkComponentController::_rateChanged(QVariant)
{
emit radioRateChanged();
}
| 36.07971
| 112
| 0.573408
|
uav-operation-system
|
731c9e1161e40e1b19985ed666223cbe809a32d5
| 14,888
|
cc
|
C++
|
chrome/browser/net/stub_resolver_config_reader_unittest.cc
|
sarang-apps/darshan_browser
|
173649bb8a7c656dc60784d19e7bb73e07c20daa
|
[
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | null | null | null |
chrome/browser/net/stub_resolver_config_reader_unittest.cc
|
sarang-apps/darshan_browser
|
173649bb8a7c656dc60784d19e7bb73e07c20daa
|
[
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | null | null | null |
chrome/browser/net/stub_resolver_config_reader_unittest.cc
|
sarang-apps/darshan_browser
|
173649bb8a7c656dc60784d19e7bb73e07c20daa
|
[
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | null | null | null |
// Copyright 2020 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 "chrome/browser/net/stub_resolver_config_reader.h"
#include <memory>
#include <vector>
#include "base/test/task_environment.h"
#include "base/values.h"
#include "chrome/browser/net/dns_util.h"
#include "chrome/common/pref_names.h"
#include "chrome/test/base/scoped_testing_local_state.h"
#include "components/prefs/pref_service.h"
#include "components/prefs/testing_pref_service.h"
#include "content/public/test/browser_task_environment.h"
#include "net/dns/dns_config.h"
#include "net/dns/public/dns_over_https_server_config.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace {
constexpr char kDohServerTemplate[] =
"https://doh1.test https://doh2.test/query{?dns}";
// Override the reader to mock out the ShouldDisableDohFor...() methods.
class MockedStubResolverConfigReader : public StubResolverConfigReader {
public:
explicit MockedStubResolverConfigReader(PrefService* local_state)
: StubResolverConfigReader(local_state,
false /* set_up_pref_defaults */) {}
bool ShouldDisableDohForManaged() override { return disable_for_managed_; }
bool ShouldDisableDohForParentalControls() override {
parental_controls_checked_ = true;
return disable_for_parental_controls_;
}
void set_disable_for_managed() { disable_for_managed_ = true; }
void set_disable_for_parental_controls() {
disable_for_parental_controls_ = true;
}
bool parental_controls_checked() { return parental_controls_checked_; }
private:
bool disable_for_managed_ = false;
bool disable_for_parental_controls_ = false;
bool parental_controls_checked_ = false;
};
class StubResolverConfigReaderTest : public testing::Test {
public:
StubResolverConfigReaderTest() {
StubResolverConfigReader::RegisterPrefs(local_state_.registry());
}
protected:
content::BrowserTaskEnvironment task_environment_{
base::test::TaskEnvironment::TimeSource::MOCK_TIME};
TestingPrefServiceSimple local_state_;
std::unique_ptr<MockedStubResolverConfigReader> config_reader_ =
std::make_unique<MockedStubResolverConfigReader>(&local_state_);
};
TEST_F(StubResolverConfigReaderTest, GetConfiguration) {
bool insecure_stub_resolver_enabled;
net::DnsConfig::SecureDnsMode secure_dns_mode;
std::vector<net::DnsOverHttpsServerConfig> dns_over_https_servers;
// |force_check_parental_controls_for_automatic_mode = true| is not the main
// default case, but the specific behavior involved is tested separately.
config_reader_->GetConfiguration(
true /* force_check_parental_controls_for_automatic_mode */,
&insecure_stub_resolver_enabled, &secure_dns_mode,
&dns_over_https_servers);
EXPECT_FALSE(insecure_stub_resolver_enabled);
EXPECT_EQ(secure_dns_mode, net::DnsConfig::SecureDnsMode::OFF);
EXPECT_TRUE(dns_over_https_servers.empty());
// Parental controls should not be checked when DoH otherwise disabled.
EXPECT_FALSE(config_reader_->parental_controls_checked());
}
TEST_F(StubResolverConfigReaderTest, DohEnabled) {
local_state_.SetBoolean(prefs::kBuiltInDnsClientEnabled, true);
local_state_.SetString(prefs::kDnsOverHttpsMode,
chrome_browser_net::kDnsOverHttpsModeAutomatic);
local_state_.SetString(prefs::kDnsOverHttpsTemplates, kDohServerTemplate);
bool insecure_stub_resolver_enabled;
net::DnsConfig::SecureDnsMode secure_dns_mode;
std::vector<net::DnsOverHttpsServerConfig> dns_over_https_servers;
// |force_check_parental_controls_for_automatic_mode = true| is not the main
// default case, but the specific behavior involved is tested separately.
config_reader_->GetConfiguration(
true /* force_check_parental_controls_for_automatic_mode */,
&insecure_stub_resolver_enabled, &secure_dns_mode,
&dns_over_https_servers);
EXPECT_TRUE(insecure_stub_resolver_enabled);
EXPECT_EQ(secure_dns_mode, net::DnsConfig::SecureDnsMode::AUTOMATIC);
EXPECT_THAT(dns_over_https_servers,
testing::ElementsAre(
net::DnsOverHttpsServerConfig("https://doh1.test",
true /* use_post */),
net::DnsOverHttpsServerConfig("https://doh2.test/query{?dns}",
false /* use_post */)));
EXPECT_TRUE(config_reader_->parental_controls_checked());
}
TEST_F(StubResolverConfigReaderTest, DohEnabled_Secure) {
local_state_.SetBoolean(prefs::kBuiltInDnsClientEnabled, true);
local_state_.SetString(prefs::kDnsOverHttpsMode,
chrome_browser_net::kDnsOverHttpsModeSecure);
local_state_.SetString(prefs::kDnsOverHttpsTemplates, kDohServerTemplate);
bool insecure_stub_resolver_enabled;
net::DnsConfig::SecureDnsMode secure_dns_mode;
std::vector<net::DnsOverHttpsServerConfig> dns_over_https_servers;
// |force_check_parental_controls_for_automatic_mode| should have no effect on
// SECURE mode, so set to false to ensure check is not deferred.
config_reader_->GetConfiguration(
false /* force_check_parental_controls_for_automatic_mode */,
&insecure_stub_resolver_enabled, &secure_dns_mode,
&dns_over_https_servers);
EXPECT_TRUE(insecure_stub_resolver_enabled);
EXPECT_EQ(secure_dns_mode, net::DnsConfig::SecureDnsMode::SECURE);
EXPECT_THAT(dns_over_https_servers,
testing::ElementsAre(
net::DnsOverHttpsServerConfig("https://doh1.test",
true /* use_post */),
net::DnsOverHttpsServerConfig("https://doh2.test/query{?dns}",
false /* use_post */)));
EXPECT_TRUE(config_reader_->parental_controls_checked());
}
TEST_F(StubResolverConfigReaderTest, DisabledForManaged) {
config_reader_->set_disable_for_managed();
local_state_.SetBoolean(prefs::kBuiltInDnsClientEnabled, true);
local_state_.SetString(prefs::kDnsOverHttpsMode,
chrome_browser_net::kDnsOverHttpsModeAutomatic);
local_state_.SetString(prefs::kDnsOverHttpsTemplates, kDohServerTemplate);
bool insecure_stub_resolver_enabled;
net::DnsConfig::SecureDnsMode secure_dns_mode;
std::vector<net::DnsOverHttpsServerConfig> dns_over_https_servers;
// |force_check_parental_controls_for_automatic_mode = true| is not the main
// default case, but the specific behavior involved is tested separately.
config_reader_->GetConfiguration(
true /* force_check_parental_controls_for_automatic_mode */,
&insecure_stub_resolver_enabled, &secure_dns_mode,
&dns_over_https_servers);
EXPECT_TRUE(insecure_stub_resolver_enabled);
EXPECT_EQ(secure_dns_mode, net::DnsConfig::SecureDnsMode::OFF);
EXPECT_TRUE(dns_over_https_servers.empty());
// Parental controls should not be checked when DoH otherwise disabled.
EXPECT_FALSE(config_reader_->parental_controls_checked());
}
TEST_F(StubResolverConfigReaderTest, DisabledForManaged_Secure) {
config_reader_->set_disable_for_managed();
local_state_.SetBoolean(prefs::kBuiltInDnsClientEnabled, true);
local_state_.SetString(prefs::kDnsOverHttpsMode,
chrome_browser_net::kDnsOverHttpsModeSecure);
local_state_.SetString(prefs::kDnsOverHttpsTemplates, kDohServerTemplate);
bool insecure_stub_resolver_enabled;
net::DnsConfig::SecureDnsMode secure_dns_mode;
std::vector<net::DnsOverHttpsServerConfig> dns_over_https_servers;
config_reader_->GetConfiguration(
false /* force_check_parental_controls_for_automatic_mode */,
&insecure_stub_resolver_enabled, &secure_dns_mode,
&dns_over_https_servers);
EXPECT_TRUE(insecure_stub_resolver_enabled);
EXPECT_EQ(secure_dns_mode, net::DnsConfig::SecureDnsMode::OFF);
EXPECT_TRUE(dns_over_https_servers.empty());
// Parental controls should not be checked when DoH otherwise disabled.
EXPECT_FALSE(config_reader_->parental_controls_checked());
}
TEST_F(StubResolverConfigReaderTest, DisabledForParentalControls) {
config_reader_->set_disable_for_parental_controls();
local_state_.SetBoolean(prefs::kBuiltInDnsClientEnabled, true);
local_state_.SetString(prefs::kDnsOverHttpsMode,
chrome_browser_net::kDnsOverHttpsModeAutomatic);
local_state_.SetString(prefs::kDnsOverHttpsTemplates, kDohServerTemplate);
bool insecure_stub_resolver_enabled;
net::DnsConfig::SecureDnsMode secure_dns_mode;
std::vector<net::DnsOverHttpsServerConfig> dns_over_https_servers;
// |force_check_parental_controls_for_automatic_mode = true| is not the main
// default case, but the specific behavior involved is tested separately.
config_reader_->GetConfiguration(
true /* force_check_parental_controls_for_automatic_mode */,
&insecure_stub_resolver_enabled, &secure_dns_mode,
&dns_over_https_servers);
EXPECT_TRUE(insecure_stub_resolver_enabled);
EXPECT_EQ(secure_dns_mode, net::DnsConfig::SecureDnsMode::OFF);
EXPECT_TRUE(dns_over_https_servers.empty());
EXPECT_TRUE(config_reader_->parental_controls_checked());
}
TEST_F(StubResolverConfigReaderTest, DisabledForParentalControls_Secure) {
config_reader_->set_disable_for_parental_controls();
local_state_.SetBoolean(prefs::kBuiltInDnsClientEnabled, true);
local_state_.SetString(prefs::kDnsOverHttpsMode,
chrome_browser_net::kDnsOverHttpsModeSecure);
local_state_.SetString(prefs::kDnsOverHttpsTemplates, kDohServerTemplate);
bool insecure_stub_resolver_enabled;
net::DnsConfig::SecureDnsMode secure_dns_mode;
std::vector<net::DnsOverHttpsServerConfig> dns_over_https_servers;
// |force_check_parental_controls_for_automatic_mode| should have no effect on
// SECURE mode, so set to false to ensure check is not deferred.
config_reader_->GetConfiguration(
false /* force_check_parental_controls_for_automatic_mode */,
&insecure_stub_resolver_enabled, &secure_dns_mode,
&dns_over_https_servers);
EXPECT_TRUE(insecure_stub_resolver_enabled);
EXPECT_EQ(secure_dns_mode, net::DnsConfig::SecureDnsMode::OFF);
EXPECT_TRUE(dns_over_https_servers.empty());
EXPECT_TRUE(config_reader_->parental_controls_checked());
}
TEST_F(StubResolverConfigReaderTest, DeferredParentalControlsCheck) {
config_reader_->set_disable_for_parental_controls();
local_state_.SetBoolean(prefs::kBuiltInDnsClientEnabled, true);
local_state_.SetString(prefs::kDnsOverHttpsMode,
chrome_browser_net::kDnsOverHttpsModeAutomatic);
local_state_.SetString(prefs::kDnsOverHttpsTemplates, kDohServerTemplate);
bool insecure_stub_resolver_enabled;
net::DnsConfig::SecureDnsMode secure_dns_mode;
std::vector<net::DnsOverHttpsServerConfig> dns_over_https_servers;
config_reader_->GetConfiguration(
false /* force_check_parental_controls_for_automatic_mode */,
&insecure_stub_resolver_enabled, &secure_dns_mode,
&dns_over_https_servers);
// Parental controls check initially skipped.
EXPECT_TRUE(insecure_stub_resolver_enabled);
EXPECT_EQ(secure_dns_mode, net::DnsConfig::SecureDnsMode::AUTOMATIC);
EXPECT_THAT(dns_over_https_servers,
testing::ElementsAre(
net::DnsOverHttpsServerConfig("https://doh1.test",
true /* use_post */),
net::DnsOverHttpsServerConfig("https://doh2.test/query{?dns}",
false /* use_post */)));
EXPECT_FALSE(config_reader_->parental_controls_checked());
task_environment_.AdvanceClock(
StubResolverConfigReader::kParentalControlsCheckDelay);
task_environment_.RunUntilIdle();
EXPECT_TRUE(config_reader_->parental_controls_checked());
dns_over_https_servers.clear();
config_reader_->GetConfiguration(
false /* force_check_parental_controls_for_automatic_mode */,
&insecure_stub_resolver_enabled, &secure_dns_mode,
&dns_over_https_servers);
EXPECT_TRUE(insecure_stub_resolver_enabled);
EXPECT_EQ(secure_dns_mode, net::DnsConfig::SecureDnsMode::OFF);
EXPECT_TRUE(dns_over_https_servers.empty());
}
TEST_F(StubResolverConfigReaderTest, DeferredParentalControlsCheck_Managed) {
config_reader_->set_disable_for_managed();
config_reader_->set_disable_for_parental_controls();
local_state_.SetBoolean(prefs::kBuiltInDnsClientEnabled, true);
local_state_.SetManagedPref(
prefs::kDnsOverHttpsMode,
std::make_unique<base::Value>(
chrome_browser_net::kDnsOverHttpsModeAutomatic));
local_state_.SetManagedPref(
prefs::kDnsOverHttpsTemplates,
std::make_unique<base::Value>(kDohServerTemplate));
bool insecure_stub_resolver_enabled;
net::DnsConfig::SecureDnsMode secure_dns_mode;
std::vector<net::DnsOverHttpsServerConfig> dns_over_https_servers;
config_reader_->GetConfiguration(
false /* force_check_parental_controls_for_automatic_mode */,
&insecure_stub_resolver_enabled, &secure_dns_mode,
&dns_over_https_servers);
// Parental controls check initially skipped, and managed prefs take
// precedence over disables.
EXPECT_TRUE(insecure_stub_resolver_enabled);
EXPECT_EQ(secure_dns_mode, net::DnsConfig::SecureDnsMode::AUTOMATIC);
EXPECT_THAT(dns_over_https_servers,
testing::ElementsAre(
net::DnsOverHttpsServerConfig("https://doh1.test",
true /* use_post */),
net::DnsOverHttpsServerConfig("https://doh2.test/query{?dns}",
false /* use_post */)));
EXPECT_FALSE(config_reader_->parental_controls_checked());
task_environment_.AdvanceClock(
StubResolverConfigReader::kParentalControlsCheckDelay);
task_environment_.RunUntilIdle();
EXPECT_TRUE(config_reader_->parental_controls_checked());
dns_over_https_servers.clear();
config_reader_->GetConfiguration(
false /* force_check_parental_controls_for_automatic_mode */,
&insecure_stub_resolver_enabled, &secure_dns_mode,
&dns_over_https_servers);
// Expect DoH still enabled after parental controls check because managed
// prefs have precedence.
EXPECT_TRUE(insecure_stub_resolver_enabled);
EXPECT_EQ(secure_dns_mode, net::DnsConfig::SecureDnsMode::AUTOMATIC);
EXPECT_THAT(dns_over_https_servers,
testing::ElementsAre(
net::DnsOverHttpsServerConfig("https://doh1.test",
true /* use_post */),
net::DnsOverHttpsServerConfig("https://doh2.test/query{?dns}",
false /* use_post */)));
}
} // namespace
| 41.703081
| 80
| 0.752485
|
sarang-apps
|
731d865dfa99b5897ff8777ef1c573abe68940d4
| 480
|
hpp
|
C++
|
qflow/system.hpp
|
johanere/qflow
|
5453cd5c3230ad7f082adf9ec1aea63ab0a4312a
|
[
"MIT"
] | 5
|
2019-07-24T21:46:24.000Z
|
2021-06-11T18:18:24.000Z
|
qflow/system.hpp
|
johanere/qflow
|
5453cd5c3230ad7f082adf9ec1aea63ab0a4312a
|
[
"MIT"
] | 22
|
2019-02-19T10:49:26.000Z
|
2019-07-18T09:42:13.000Z
|
qflow/system.hpp
|
bsamseth/FYS4411
|
72b879e7978364498c48fc855b5df676c205f211
|
[
"MIT"
] | 2
|
2020-11-04T15:17:24.000Z
|
2021-11-03T16:37:38.000Z
|
#pragma once
#include "definitions.hpp"
#include "vector.hpp"
#include <Eigen/Dense>
using System = Matrix;
namespace Distance
{
void init(const System&);
Real probe(const System&, int i, int j);
void invalidate_cache(int i);
// The plain, non-memoized euclidian norm.
// Fall back to this if not initialized, or when cache is invalidated.
inline Real distance(const System& system, int i, int j)
{
return norm(system.row(i) - system.row(j));
}
} // namespace Distance
| 20
| 70
| 0.71875
|
johanere
|
731e6b4c332561f4aa726e60b58e4a956da8625a
| 12,594
|
cpp
|
C++
|
game/src/ScriptObjects/ScriptObjectGame.cpp
|
fromasmtodisasm/BlackBox
|
36b4fa56e62a81d9483e76f1272b1203981b97fe
|
[
"MIT"
] | 1
|
2019-12-10T00:37:05.000Z
|
2019-12-10T00:37:05.000Z
|
game/src/ScriptObjects/ScriptObjectGame.cpp
|
fromasmtodisasm/BlackBox
|
36b4fa56e62a81d9483e76f1272b1203981b97fe
|
[
"MIT"
] | 3
|
2020-02-17T21:12:09.000Z
|
2022-01-19T10:28:02.000Z
|
game/src/ScriptObjects/ScriptObjectGame.cpp
|
fromasmtodisasm/BlackBox
|
36b4fa56e62a81d9483e76f1272b1203981b97fe
|
[
"MIT"
] | 3
|
2019-03-14T16:28:47.000Z
|
2020-05-17T20:42:55.000Z
|
#include <Game.hpp>
#include <Server/XServer.hpp>
#include <ScriptObjects/ScriptObjectGame.hpp>
#include <BlackBox/Core/IMarkers.hpp>
#include <BlackBox/System/IConsole.hpp>
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
_DECLARE_SCRIPTABLEEX(CScriptObjectGame)
CScriptObjectGame::CScriptObjectGame()
{
}
CScriptObjectGame::~CScriptObjectGame()
{
}
void CScriptObjectGame::InitializeTemplate(IScriptSystem* pSS)
{
_ScriptableEx<CScriptObjectGame>::InitializeTemplate(pSS);
REG_FUNC(CScriptObjectGame, SendMessage);
REG_FUNC(CScriptObjectGame, Stop);
REG_FUNC(CScriptObjectGame, gotoMenu);
REG_FUNC(CScriptObjectGame, gotoGame);
REG_FUNC(CScriptObjectGame, gotoFly);
REG_FUNC(CScriptObjectGame, gotoEdit);
REG_FUNC(CScriptObjectGame, showMenu);
REG_FUNC(CScriptObjectGame, GetTagPoint);
REG_FUNC(CScriptObjectGame, CreateVariable);
REG_FUNC(CScriptObjectGame, SetVariable);
REG_FUNC(CScriptObjectGame, RemoveVariable);
REG_FUNC(CScriptObjectGame, GetVariable);
REG_FUNC(CScriptObjectGame, LoadLevel);
REG_FUNC(CScriptObjectGame, AddCommand);
REG_FUNC(CScriptObjectGame, Quit);
REG_FUNC(CScriptObjectGame, SavePlayerPos);
REG_FUNC(CScriptObjectGame, LoadPlayerPos);
}
void CScriptObjectGame::Init(IScriptSystem* pScriptSystem, CGame* pGame)
{
m_pGame = pGame;
m_pSystem = pGame->GetSystem();
m_pConsole = m_pSystem->GetIConsole();
InitGlobal(pScriptSystem, "Game", this);
}
void CScriptObjectGame::OnNETServerFound(CIPAddress& ip, SXServerInfos& pServerInfo)
{
SmartScriptObject pServer(m_pScriptSystem);
pServer->SetValue("Name", pServerInfo.strName.c_str());
pServer->SetValue("Map", pServerInfo.strMap.c_str());
pServer->SetValue("Players", (int)pServerInfo.nPlayers);
pServer->SetValue("MaxPlayers", (int)pServerInfo.nMaxPlayers);
pServer->SetValue("GameType", pServerInfo.strGameType.c_str());
pServer->SetValue("Mod", pServerInfo.strMod.c_str());
pServer->SetValue("Ping", (int)pServerInfo.nPing);
pServer->SetValue("IP", pServerInfo.IP.GetAsString(true));
pServer->SetValue("Password", (int)((pServerInfo.nServerFlags & SXServerInfos::FLAG_PASSWORD) ? 1 : 0));
pServer->SetValue("CheatsEnabled", (int)((pServerInfo.nServerFlags & SXServerInfos::FLAG_CHEATS) ? 1 : 0));
char str[80];
pServerInfo.VersionInfo.ToString(str);
pServer->SetValue("GameVersion", str);
pServer->SetValue("InternetServer", (int)((pServerInfo.nServerFlags & SXServerInfos::FLAG_NET) ? 1 : 0));
pServer->SetValue("ComputerType", (int)pServerInfo.nComputerType);
pServer->SetValue("PunkBuster", (int)((pServerInfo.nServerFlags & SXServerInfos::FLAG_PUNKBUSTER) ? 1 : 0));
HSCRIPTFUNCTION pfOnNETServerFound = 0;
if (m_pScriptThis->GetValue("OnNETServerFound", pfOnNETServerFound))
{
m_pScriptSystem->BeginCall(pfOnNETServerFound);
m_pScriptSystem->PushFuncParam(GetScriptObject());
m_pScriptSystem->PushFuncParam(pServer);
m_pScriptSystem->EndCall();
}
m_pScriptSystem->ReleaseFunc(pfOnNETServerFound);
}
void CScriptObjectGame::OnNETServerTimeout(CIPAddress& ip)
{
SmartScriptObject pServer(m_pScriptSystem);
pServer->SetValue("Name", "");
pServer->SetValue("Map", "");
pServer->SetValue("Players", 0);
pServer->SetValue("MaxPlayers", 0);
pServer->SetValue("GameType", "");
pServer->SetValue("Mod", "");
pServer->SetValue("Ping", 0);
pServer->SetValue("IP", ip.GetAsString(true));
pServer->SetValue("Password", 0);
pServer->SetValue("CheatsEnabled", 0);
pServer->SetValue("GameVersion", "");
pServer->SetValue("InternetServer", 0);
pServer->SetValue("ComputerType", 0);
pServer->SetValue("PunkBuster", 0);
HSCRIPTFUNCTION pfOnNETServerTimeout = 0;
if (m_pScriptThis->GetValue("OnNETServerTimeout", pfOnNETServerTimeout))
{
m_pScriptSystem->BeginCall(pfOnNETServerTimeout);
m_pScriptSystem->PushFuncParam(GetScriptObject());
m_pScriptSystem->PushFuncParam(pServer);
m_pScriptSystem->EndCall();
}
m_pScriptSystem->ReleaseFunc(pfOnNETServerTimeout);
}
int CScriptObjectGame::SendMessage(IFunctionHandler* pH)
{
CHECK_PARAMETERS(1);
const char* pszMsg;
pH->GetParam(1, pszMsg);
if (pszMsg)
m_pGame->SendMessage(pszMsg);
else
m_pScriptSystem->RaiseError("SendMessage() parameter is nil");
return pH->EndFunction();
}
int CScriptObjectGame::Stop(IFunctionHandler* pH)
{
m_pGame->Stop();
return pH->EndFunction();
}
int CScriptObjectGame::gotoMenu(IFunctionHandler* pH)
{
m_pGame->gotoMenu();
return pH->EndFunction();
}
int CScriptObjectGame::gotoFullscreen(IFunctionHandler* pH)
{
m_pGame->gotoFullscreen();
return pH->EndFunction();
}
int CScriptObjectGame::gotoGame(IFunctionHandler* pH)
{
m_pGame->gotoGame();
return pH->EndFunction();
}
int CScriptObjectGame::gotoFly(IFunctionHandler* pH)
{
m_pGame->gotoFly();
return pH->EndFunction();
}
int CScriptObjectGame::gotoEdit(IFunctionHandler* pH)
{
m_pGame->gotoEdit();
return pH->EndFunction();
}
int CScriptObjectGame::showMenu(IFunctionHandler* pH)
{
m_pGame->showMenu();
return pH->EndFunction();
}
int CScriptObjectGame::GetVersion(IFunctionHandler* pH)
{
return 0;
}
int CScriptObjectGame::GetVersionString(IFunctionHandler* pH)
{
return 0;
}
int CScriptObjectGame::ReloadScripts(IFunctionHandler* pH)
{
return 0;
}
int CScriptObjectGame::Load(IFunctionHandler* pH)
{
return 0;
}
int CScriptObjectGame::Save(IFunctionHandler* pH)
{
return 0;
}
int CScriptObjectGame::LoadLatestCheckPoint(IFunctionHandler* pH)
{
return 0;
}
int CScriptObjectGame::ShowSaveGameMenu(IFunctionHandler* pH)
{
return 0;
}
//////////////////////////////////////////////////////////////////////
/*!quit the game
*/
int CScriptObjectGame::Quit(IFunctionHandler* pH)
{
CHECK_PARAMETERS(0);
//m_pConsole->Exit(NULL);
m_pSystem->Quit();
return pH->EndFunction();
}
int CScriptObjectGame::IsPointInWater(IFunctionHandler* pH)
{
return 0;
}
int CScriptObjectGame::GetWaterHeight(IFunctionHandler* pH)
{
return 0;
}
int CScriptObjectGame::GetTagPoint(IFunctionHandler* pH)
{
CHECK_PARAMETERS(1);
const char* sTPName;
ITagPoint* pTP = NULL;
Vec3 vec(0, 0, 0);
if (pH->GetParam(1, sTPName))
{
pTP = m_pGame->GetTagPoint(sTPName);
if (!pTP) return pH->EndFunctionNull();
pTP->GetPos(vec);
}
m_pGetTagPoint.Set(vec);
return pH->EndFunction(m_pGetTagPoint);
}
int CScriptObjectGame::IsServer(IFunctionHandler* pH)
{
return 0;
}
int CScriptObjectGame::IsClient(IFunctionHandler* pH)
{
return 0;
}
int CScriptObjectGame::IsMultiplayer(IFunctionHandler* pH)
{
return 0;
}
int CScriptObjectGame::GetMaterialIDByName(IFunctionHandler* pH)
{
return 0;
}
int CScriptObjectGame::ReloadMaterialPhysics(IFunctionHandler* pH)
{
return 0;
}
int CScriptObjectGame::StartRecord(IFunctionHandler* pH)
{
return 0;
}
int CScriptObjectGame::StopRecord(IFunctionHandler* pH)
{
return 0;
}
//////////////////////////////////////////////////////////////////////
/*!create a console variable
@param sName name of the console variable
@param sDefault the default value[optional]
*/
int CScriptObjectGame::CreateVariable(IFunctionHandler* pH)
{
int nPCount = pH->GetParamCount();
const char* sName;
const char* sDefault;
const char* sflags;
int iflags = 0;
pH->GetParam(1, sName);
if (nPCount > 1)
{
pH->GetParam(2, sDefault);
if (nPCount > 2)
{
switch (pH->GetParamType(3))
{
case ScriptVarType::String:
if (pH->GetParam(3, sflags))
{
if (strcmp(sflags, "NetSynch") == 0)
iflags = VF_NET_SYNCED;
}
else
m_pSystem->GetILog()->LogWarning("Game:CreateVariable can't get the 3rd parameter (string)");
break;
case ScriptVarType::Number:
if (pH->GetParam(3, iflags))
{
// do nothing, the flags must be the VF_* flags
}
else
m_pSystem->GetILog()->LogWarning("Game:CreateVariable can't get the 3rd parameter (number)");
break;
default:
m_pSystem->GetILog()->LogWarning("Game:CreateVariable unexpected 3rd (flags) parameter type (%s)", ScriptVarTypeAsCStr(pH->GetParamType(3)));
break;
}
}
}
else
{
sDefault = "0";
}
m_pConsole->CreateVariable(sName, sDefault, iflags);
return pH->EndFunction();
}
int CScriptObjectGame::SetVariable(IFunctionHandler* pH)
{
CHECK_PARAMETERS(2);
const char* sName;
if (!pH->GetParam(1, sName))
{
m_pScriptSystem->RaiseError("SetVariable invalid parameter type %s, string expected", ScriptVarTypeAsCStr(pH->GetParamType(1)));
return pH->EndFunctionNull();
}
ICVar* pVar = m_pSystem->GetIConsole()->GetCVar(sName);
if (!pVar)
{
m_pScriptSystem->RaiseError("SetVariable invalid variable name \"%s\": no such variable found", sName);
return pH->EndFunctionNull();
}
if ((pVar->GetFlags() & VF_CHEAT) && (!m_pGame->IsDevModeEnable()))
{
// [martin] hid this message because we don't want to help hacking
// m_pSystem->GetILog()->LogWarning ("\001 Variable %s is cheat protected.", sName);
return pH->EndFunctionNull();
}
switch (pH->GetParamType(2))
{
case ScriptVarType::Null:
pVar->Set("");
break;
case ScriptVarType::String:
{
const char* pVal;
if (!pH->GetParam(2, pVal))
{
m_pScriptSystem->RaiseError("SetVariable cannot retrieve the variable %s string value", sName);
return pH->EndFunctionNull();
}
pVar->Set(pVal);
}
break;
case ScriptVarType::Number:
{
int nVal;
float fVal;
if (pH->GetParam(2, fVal))
pVar->Set(fVal);
else
if (pH->GetParam(2, nVal))
pVar->Set(nVal);
else
{
m_pScriptSystem->RaiseError("SetVariable cannot retrieve the variable %s numeric value", sName);
return pH->EndFunctionNull();
}
}
break;
default:
m_pScriptSystem->RaiseError("SetVariable cannot set the variable %s value: unsupported type %s", sName, ScriptVarTypeAsCStr(pH->GetParamType(2)));
break;
}
return pH->EndFunction();
}
int CScriptObjectGame::RemoveVariable(IFunctionHandler* pH)
{
CHECK_PARAMETERS(1);
const char* sName;
pH->GetParam(1, sName);
m_pConsole->UnregisterVariable(sName, true);
return pH->EndFunction();
}
int CScriptObjectGame::GetVariable(IFunctionHandler* pH)
{
CHECK_PARAMETERS(1);
const char* sName;
if (!pH->GetParam(1, sName))
{
m_pScriptSystem->RaiseError("GetVariable invalid parameter type %s, string expected", ScriptVarTypeAsCStr(pH->GetParamType(1)));
return pH->EndFunctionNull();
}
ICVar* pVar = m_pSystem->GetIConsole()->GetCVar(sName);
if (!pVar)
{
m_pScriptSystem->RaiseError("GetVariable invalid variable name \"%s\": no such variable found", sName);
return pH->EndFunctionNull();
}
switch (pVar->GetType())
{
case CVAR_INT:
return pH->EndFunction(pVar->GetIVal());
case CVAR_FLOAT:
return pH->EndFunction(pVar->GetFVal());
case CVAR_STRING:
return pH->EndFunction(pVar->GetString());
default:
return pH->EndFunctionNull();
}
}
int CScriptObjectGame::LoadLevel(IFunctionHandler* pH)
{
CHECK_PARAMETERS(1);
GetISystem()->Log("Loading level");
const char* szLevelName = nullptr;
if (pH->GetParam(1, szLevelName))
{
return pH->EndFunction(m_pGame->loadScene(szLevelName));
}
return pH->EndFunctionNull();
}
int CScriptObjectGame::AddCommand(IFunctionHandler* pH)
{
int nPCount = pH->GetParamCount();
const char* sName;
const char* sCommand;
const char* sHelp = NULL;
int iflags = 0;
pH->GetParam(1, sName);
if (nPCount > 1)
{
pH->GetParam(2, sCommand);
if (nPCount > 2)
{
if (!pH->GetParam(3, sHelp))
sHelp = NULL;
}
if (sHelp)
m_pConsole->AddCommand(sName, sCommand, 0, sHelp);
else
m_pConsole->AddCommand(sName, sCommand, 0/*VF_NOHELP*/, "");
}
return pH->EndFunction();
}
int CScriptObjectGame::SavePlayerPos(IFunctionHandler* pH)
{
const char* sName = NULL;
const char* sDesc = NULL;
pH->GetParam(1, sName);
pH->GetParam(2, sDesc);
if (sName)
m_pGame->DevMode_SavePlayerPos(0, sName, sDesc);
return pH->EndFunction();
}
int CScriptObjectGame::LoadPlayerPos(IFunctionHandler* pH)
{
CHECK_PARAMETERS(2);
const char* sName;
int index;
if (pH->GetParam(1, index))
{
if (pH->GetParam(2, sName))
{
m_pGame->DevMode_LoadPlayerPos(index, sName);
}
}
return pH->EndFunction();
}
| 25.137725
| 150
| 0.68612
|
fromasmtodisasm
|
732198936b16b5117cc7dcfd2dd2ace65dae8bc4
| 1,235
|
cpp
|
C++
|
src/expectation.cpp
|
xchrishawk/spookshow
|
139910e97330a387213a504ae77c2f3dbcb06134
|
[
"MIT"
] | null | null | null |
src/expectation.cpp
|
xchrishawk/spookshow
|
139910e97330a387213a504ae77c2f3dbcb06134
|
[
"MIT"
] | null | null | null |
src/expectation.cpp
|
xchrishawk/spookshow
|
139910e97330a387213a504ae77c2f3dbcb06134
|
[
"MIT"
] | null | null | null |
/**
* @file expectation.cpp
* @author Chris Vig (chris@invictus.so)
* @date 2016/12/30
*/
/* -- Includes -- */
#include <sstream>
#include <string>
#include <spookshow/spookshow.hpp>
/* -- Namespaces -- */
using namespace spookshow;
/* -- Procedures -- */
expectation::expectation(const std::string& name, int required_count)
: m_name(name),
m_required_count(required_count),
m_order(expectation_order::current_order()),
m_count(0)
{
if (m_order)
m_order->enqueue_expectation(this);
}
expectation::~expectation()
{
if (is_fulfilled())
return;
std::ostringstream message;
message << "Unfulfilled expectation! [" << name()
<< "] Expected " << m_required_count << " call" << (m_required_count == 1 ? "" : "s")
<< ", received " << m_count << " call" << (m_count == 1 ? "" : "s") << ".";
internal::handle_failure(message.str());
}
void expectation::fulfill()
{
if (m_order && m_count == 0)
{
if (m_order->is_expectation_next(this))
m_order->dequeue_expectation();
else
{
std::ostringstream message;
message << "Expectation fulfilled out of order! [" << name() << "]";
internal::handle_failure(message.str());
}
}
++m_count;
}
| 21.666667
| 95
| 0.610526
|
xchrishawk
|
7322d739c7995fac1a0a4f8867ad8953c1ae43c2
| 2,749
|
cpp
|
C++
|
Codeforces/1083C.cpp
|
HeRaNO/OI-ICPC-Codes
|
4a4639cd3e347b472520065ca6ab8caadde6906d
|
[
"MIT"
] | 18
|
2019-01-01T13:16:59.000Z
|
2022-02-28T04:51:50.000Z
|
Codeforces/1083C.cpp
|
HeRaNO/OI-ICPC-Codes
|
4a4639cd3e347b472520065ca6ab8caadde6906d
|
[
"MIT"
] | null | null | null |
Codeforces/1083C.cpp
|
HeRaNO/OI-ICPC-Codes
|
4a4639cd3e347b472520065ca6ab8caadde6906d
|
[
"MIT"
] | 5
|
2019-09-13T08:48:17.000Z
|
2022-02-19T06:59:03.000Z
|
#include <cstdio>
#include <vector>
#include <algorithm>
#define MAXN 200005
using namespace std;
pair <int,int> x[1<<19],now;
int n,T,R,ans,o,lg[MAXN<<1],pt[MAXN],p[MAXN],pos[MAXN],dep[MAXN<<1];
int fa[19][MAXN<<1],euler[MAXN<<1];
vector <int> g[MAXN];
inline void dfs(int x,int deep)
{
pt[x]=++R;euler[R]=x;dep[R]=deep;
for (auto v:g[x])
{
dfs(v,deep+1);
euler[++R]=x;dep[R]=deep;
}
return ;
}
inline void RMQLCA()
{
dfs(1,0);
for (int i=1;i<=R;i++) fa[0][i]=i;
for (int i=2;i<=R;i++) lg[i]=lg[i>>1]+1;
for (int j=1;j<=lg[R];j++)
for (int i=1;i+(1<<j)-1<=R;i++)
{
int a=fa[j-1][i],b=fa[j-1][i+(1<<(j-1))];
fa[j][i]=dep[a]<=dep[b]?a:b;
}
return ;
}
inline int LCA(int x,int y)
{
x=pt[x];y=pt[y];
if (x>y) swap(x,y);
int t=lg[y-x+1];int a=fa[t][x],b=fa[t][y-(1<<t)+1];
return dep[a]<=dep[b]?euler[a]:euler[b];
}
inline bool On(int u,int v,int x)
{
return ((LCA(x,u)==x)^(LCA(x,v)==x))||(LCA(u,v)==x);
}
inline bool On(int x,int y,int u,int v)
{
if (!~x||!~y||!~u||!~v) return false;
return On(x,y,u)&&On(x,y,v);
}
inline pair<int,int> PushUp(pair<int,int> l,pair<int,int> r)
{
pair <int,int> ans={-1,-1};
int ll=l.first,lr=l.second,rl=r.first,rr=r.second;
if (On(ll,lr,rl,rr)) ans={ll,lr};
else if (On(ll,rl,lr,rr)) ans={ll,rl};
else if (On(ll,rr,lr,rl)) ans={ll,rr};
else if (On(lr,rl,ll,rr)) ans={lr,rl};
else if (On(lr,rr,ll,rl)) ans={lr,rr};
else if (On(rl,rr,ll,lr)) ans={rl,rr};
return ans;
}
void BuildTree(int u,int l,int r)
{
if (l+1==r){x[u]={pos[l],pos[l]};return ;}
int m=l+r>>1;BuildTree(u<<1,l,m);BuildTree(u<<1|1,m,r);
x[u]=PushUp(x[u<<1],x[u<<1|1]);
return ;
}
inline void modify(int u,int p,int v,int pl,int pr)
{
if (pl+1==pr){x[u]={v,v};return ;}
int m=pl+pr>>1;p<m?modify(u<<1,p,v,pl,m):modify(u<<1|1,p,v,m,pr);
x[u]=PushUp(x[u<<1],x[u<<1|1]);
return ;
}
inline void query(int u,int l,int r)
{
if (l+1==r)
{
pair <int,int> t=PushUp(now,x[u]);
if (!~now.first||(~t.first))
{
ans=max(ans,l+1);
if (~now.first) now=t;
else now=x[u];
}
return ;
}
int m=l+r>>1;pair <int,int> t=PushUp(now,x[u<<1]);
if (~x[u<<1].first&&(!~now.first||(~t.first)))
{
if (~now.first) now=t;
else now=x[u<<1];
ans=max(ans,m);query(u<<1|1,m,r);
}
else query(u<<1,l,m);
return ;
}
int main()
{
scanf("%d",&n);
for (int i=1;i<=n;i++) scanf("%d",&p[i]),pos[p[i]]=i;
for (int i=2,x;i<=n;i++) scanf("%d",&x),g[x].push_back(i);
RMQLCA();BuildTree(1,0,n);
scanf("%d",&T);
while (T--)
{
scanf("%d",&o);
if (o==1)
{
int x,y;
scanf("%d %d",&x,&y);
modify(1,p[y],pos[p[x]],0,n);
modify(1,p[x],pos[p[y]],0,n);
swap(pos[p[x]],pos[p[y]]);swap(p[x],p[y]);
}
else
{
ans=0;now={-1,-1};query(1,0,n);
printf("%d\n",ans);
}
}
return 0;
}
| 20.514925
| 68
| 0.535831
|
HeRaNO
|
73237bc7569f20482fbf5194613ab171105ba3d2
| 2,515
|
cc
|
C++
|
media/capture/video/chromeos/pixel_format_utils.cc
|
zealoussnow/chromium
|
fd8a8914ca0183f0add65ae55f04e287543c7d4a
|
[
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | 14,668
|
2015-01-01T01:57:10.000Z
|
2022-03-31T23:33:32.000Z
|
media/capture/video/chromeos/pixel_format_utils.cc
|
zealoussnow/chromium
|
fd8a8914ca0183f0add65ae55f04e287543c7d4a
|
[
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | 86
|
2015-10-21T13:02:42.000Z
|
2022-03-14T07:50:50.000Z
|
media/capture/video/chromeos/pixel_format_utils.cc
|
zealoussnow/chromium
|
fd8a8914ca0183f0add65ae55f04e287543c7d4a
|
[
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | 5,941
|
2015-01-02T11:32:21.000Z
|
2022-03-31T16:35:46.000Z
|
// Copyright 2017 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/capture/video/chromeos/pixel_format_utils.h"
#include <drm_fourcc.h>
namespace media {
namespace {
struct SupportedFormat {
cros::mojom::HalPixelFormat hal_format;
ChromiumPixelFormat cr_format;
} const kSupportedFormats[] = {
// The Android camera HAL v3 has three types of mandatory pixel formats:
//
// 1. HAL_PIXEL_FORMAT_YCbCr_420_888 (YUV flexible format).
// 2. HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED (platform-specific format).
// 3. HAL_PIXEL_FORMAT_BLOB (for JPEG).
//
// We can't use HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED as it is highly
// platform specific and there is no way for Chrome to query the exact
// pixel layout of the implementation-defined buffer.
//
// On Android the framework requests the preview stream with the
// implementation-defined format, and as a result some camera HALs support
// only implementation-defined preview buffers. We should use the video
// capture stream in Chrome VCD as it is mandatory for the camera HAL to
// support YUV flexbile format video streams.
{cros::mojom::HalPixelFormat::HAL_PIXEL_FORMAT_YCbCr_420_888,
{PIXEL_FORMAT_NV12, gfx::BufferFormat::YUV_420_BIPLANAR}},
// FIXME(jcliang): MJPEG is not accurate; we should have BLOB or JPEG
{cros::mojom::HalPixelFormat::HAL_PIXEL_FORMAT_BLOB,
{PIXEL_FORMAT_MJPEG, gfx::BufferFormat::R_8}},
// Add more mappings when we have more devices.
};
} // namespace
std::vector<ChromiumPixelFormat> PixFormatHalToChromium(
cros::mojom::HalPixelFormat from) {
std::vector<ChromiumPixelFormat> ret;
for (const auto& it : kSupportedFormats) {
if (it.hal_format == from) {
ret.push_back(it.cr_format);
}
}
return ret;
}
uint32_t PixFormatVideoToDrm(VideoPixelFormat from) {
switch (from) {
case PIXEL_FORMAT_NV12:
return DRM_FORMAT_NV12;
case PIXEL_FORMAT_MJPEG:
return DRM_FORMAT_R8;
default:
// Unsupported format.
return 0;
}
}
absl::optional<gfx::BufferFormat> PixFormatVideoToGfx(
VideoPixelFormat pixel_format) {
switch (pixel_format) {
case PIXEL_FORMAT_MJPEG:
return gfx::BufferFormat::R_8;
case PIXEL_FORMAT_NV12:
return gfx::BufferFormat::YUV_420_BIPLANAR;
default:
return absl::nullopt;
}
}
} // namespace media
| 32.24359
| 79
| 0.719284
|
zealoussnow
|
7323ab57a708ec79f17cb1ab13254ca47091ce6c
| 49,659
|
cpp
|
C++
|
opencv-2.4.11/modules/ml/src/ann_mlp.cpp
|
durai-chellamuthu/node-opencv
|
a9c18c77b2fe0f62f2f8376854bdf33de71f5dc3
|
[
"MIT"
] | 13
|
2015-03-01T07:03:17.000Z
|
2021-11-03T06:33:31.000Z
|
modules/ml/src/ann_mlp.cpp
|
ehren/opencv
|
abe37659ccfc2b399e7543eee1a43900c9a7099e
|
[
"BSD-3-Clause"
] | null | null | null |
modules/ml/src/ann_mlp.cpp
|
ehren/opencv
|
abe37659ccfc2b399e7543eee1a43900c9a7099e
|
[
"BSD-3-Clause"
] | 32
|
2015-06-08T08:59:51.000Z
|
2021-08-05T09:54:16.000Z
|
/*M///////////////////////////////////////////////////////////////////////////////////////
//
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
//
// By downloading, copying, installing or using the software you agree to this license.
// If you do not agree to this license, do not download, install,
// copy or use the software.
//
//
// Intel License Agreement
//
// Copyright (C) 2000, Intel Corporation, all rights reserved.
// Third party copyrights are property of their respective owners.
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
// * Redistribution's of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// * Redistribution's in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// * The name of Intel Corporation may not be used to endorse or promote products
// derived from this software without specific prior written permission.
//
// This software is provided by the copyright holders and contributors "as is" and
// any express or implied warranties, including, but not limited to, the implied
// warranties of merchantability and fitness for a particular purpose are disclaimed.
// In no event shall the Intel Corporation or contributors be liable for any direct,
// indirect, incidental, special, exemplary, or consequential damages
// (including, but not limited to, procurement of substitute goods or services;
// loss of use, data, or profits; or business interruption) however caused
// and on any theory of liability, whether in contract, strict liability,
// or tort (including negligence or otherwise) arising in any way out of
// the use of this software, even if advised of the possibility of such damage.
//
//M*/
#include "precomp.hpp"
CvANN_MLP_TrainParams::CvANN_MLP_TrainParams()
{
term_crit = cvTermCriteria( CV_TERMCRIT_ITER + CV_TERMCRIT_EPS, 1000, 0.01 );
train_method = RPROP;
bp_dw_scale = bp_moment_scale = 0.1;
rp_dw0 = 0.1; rp_dw_plus = 1.2; rp_dw_minus = 0.5;
rp_dw_min = FLT_EPSILON; rp_dw_max = 50.;
}
CvANN_MLP_TrainParams::CvANN_MLP_TrainParams( CvTermCriteria _term_crit,
int _train_method,
double _param1, double _param2 )
{
term_crit = _term_crit;
train_method = _train_method;
bp_dw_scale = bp_moment_scale = 0.1;
rp_dw0 = 1.; rp_dw_plus = 1.2; rp_dw_minus = 0.5;
rp_dw_min = FLT_EPSILON; rp_dw_max = 50.;
if( train_method == RPROP )
{
rp_dw0 = _param1;
if( rp_dw0 < FLT_EPSILON )
rp_dw0 = 1.;
rp_dw_min = _param2;
rp_dw_min = MAX( rp_dw_min, 0 );
}
else if( train_method == BACKPROP )
{
bp_dw_scale = _param1;
if( bp_dw_scale <= 0 )
bp_dw_scale = 0.1;
bp_dw_scale = MAX( bp_dw_scale, 1e-3 );
bp_dw_scale = MIN( bp_dw_scale, 1 );
bp_moment_scale = _param2;
if( bp_moment_scale < 0 )
bp_moment_scale = 0.1;
bp_moment_scale = MIN( bp_moment_scale, 1 );
}
else
train_method = RPROP;
}
CvANN_MLP_TrainParams::~CvANN_MLP_TrainParams()
{
}
CvANN_MLP::CvANN_MLP()
{
layer_sizes = wbuf = 0;
min_val = max_val = min_val1 = max_val1 = 0.;
weights = 0;
rng = &cv::theRNG();
default_model_name = "my_nn";
clear();
}
CvANN_MLP::CvANN_MLP( const CvMat* _layer_sizes,
int _activ_func,
double _f_param1, double _f_param2 )
{
layer_sizes = wbuf = 0;
min_val = max_val = min_val1 = max_val1 = 0.;
weights = 0;
rng = &cv::theRNG();
default_model_name = "my_nn";
create( _layer_sizes, _activ_func, _f_param1, _f_param2 );
}
CvANN_MLP::~CvANN_MLP()
{
clear();
}
void CvANN_MLP::clear()
{
cvReleaseMat( &layer_sizes );
cvReleaseMat( &wbuf );
cvFree( &weights );
activ_func = SIGMOID_SYM;
f_param1 = f_param2 = 1;
max_buf_sz = 1 << 12;
}
void CvANN_MLP::set_activ_func( int _activ_func, double _f_param1, double _f_param2 )
{
CV_FUNCNAME( "CvANN_MLP::set_activ_func" );
__BEGIN__;
if( _activ_func < 0 || _activ_func > GAUSSIAN )
CV_ERROR( CV_StsOutOfRange, "Unknown activation function" );
activ_func = _activ_func;
switch( activ_func )
{
case SIGMOID_SYM:
max_val = 0.95; min_val = -max_val;
max_val1 = 0.98; min_val1 = -max_val1;
if( fabs(_f_param1) < FLT_EPSILON )
_f_param1 = 2./3;
if( fabs(_f_param2) < FLT_EPSILON )
_f_param2 = 1.7159;
break;
case GAUSSIAN:
max_val = 1.; min_val = 0.05;
max_val1 = 1.; min_val1 = 0.02;
if( fabs(_f_param1) < FLT_EPSILON )
_f_param1 = 1.;
if( fabs(_f_param2) < FLT_EPSILON )
_f_param2 = 1.;
break;
default:
min_val = max_val = min_val1 = max_val1 = 0.;
_f_param1 = 1.;
_f_param2 = 0.;
}
f_param1 = _f_param1;
f_param2 = _f_param2;
__END__;
}
void CvANN_MLP::init_weights()
{
int i, j, k;
for( i = 1; i < layer_sizes->cols; i++ )
{
int n1 = layer_sizes->data.i[i-1];
int n2 = layer_sizes->data.i[i];
double val = 0, G = n2 > 2 ? 0.7*pow((double)n1,1./(n2-1)) : 1.;
double* w = weights[i];
// initialize weights using Nguyen-Widrow algorithm
for( j = 0; j < n2; j++ )
{
double s = 0;
for( k = 0; k <= n1; k++ )
{
val = rng->uniform(0., 1.)*2-1.;
w[k*n2 + j] = val;
s += fabs(val);
}
if( i < layer_sizes->cols - 1 )
{
s = 1./(s - fabs(val));
for( k = 0; k <= n1; k++ )
w[k*n2 + j] *= s;
w[n1*n2 + j] *= G*(-1+j*2./n2);
}
}
}
}
void CvANN_MLP::create( const CvMat* _layer_sizes, int _activ_func,
double _f_param1, double _f_param2 )
{
CV_FUNCNAME( "CvANN_MLP::create" );
__BEGIN__;
int i, l_step, l_count, buf_sz = 0;
int *l_src, *l_dst;
clear();
if( !CV_IS_MAT(_layer_sizes) ||
(_layer_sizes->cols != 1 && _layer_sizes->rows != 1) ||
CV_MAT_TYPE(_layer_sizes->type) != CV_32SC1 )
CV_ERROR( CV_StsBadArg,
"The array of layer neuron counters must be an integer vector" );
CV_CALL( set_activ_func( _activ_func, _f_param1, _f_param2 ));
l_count = _layer_sizes->rows + _layer_sizes->cols - 1;
l_src = _layer_sizes->data.i;
l_step = CV_IS_MAT_CONT(_layer_sizes->type) ? 1 :
_layer_sizes->step / sizeof(l_src[0]);
CV_CALL( layer_sizes = cvCreateMat( 1, l_count, CV_32SC1 ));
l_dst = layer_sizes->data.i;
max_count = 0;
for( i = 0; i < l_count; i++ )
{
int n = l_src[i*l_step];
if( n < 1 + (0 < i && i < l_count-1))
CV_ERROR( CV_StsOutOfRange,
"there should be at least one input and one output "
"and every hidden layer must have more than 1 neuron" );
l_dst[i] = n;
max_count = MAX( max_count, n );
if( i > 0 )
buf_sz += (l_dst[i-1]+1)*n;
}
buf_sz += (l_dst[0] + l_dst[l_count-1]*2)*2;
CV_CALL( wbuf = cvCreateMat( 1, buf_sz, CV_64F ));
CV_CALL( weights = (double**)cvAlloc( (l_count+2)*sizeof(weights[0]) ));
weights[0] = wbuf->data.db;
weights[1] = weights[0] + l_dst[0]*2;
for( i = 1; i < l_count; i++ )
weights[i+1] = weights[i] + (l_dst[i-1] + 1)*l_dst[i];
weights[l_count+1] = weights[l_count] + l_dst[l_count-1]*2;
__END__;
}
float CvANN_MLP::predict( const CvMat* _inputs, CvMat* _outputs ) const
{
int i, j, n, dn = 0, l_count, dn0, buf_sz, min_buf_sz;
if( !layer_sizes )
CV_Error( CV_StsError, "The network has not been initialized" );
if( !CV_IS_MAT(_inputs) || !CV_IS_MAT(_outputs) ||
!CV_ARE_TYPES_EQ(_inputs,_outputs) ||
(CV_MAT_TYPE(_inputs->type) != CV_32FC1 &&
CV_MAT_TYPE(_inputs->type) != CV_64FC1) ||
_inputs->rows != _outputs->rows )
CV_Error( CV_StsBadArg, "Both input and output must be floating-point matrices "
"of the same type and have the same number of rows" );
if( _inputs->cols != layer_sizes->data.i[0] )
CV_Error( CV_StsBadSize, "input matrix must have the same number of columns as "
"the number of neurons in the input layer" );
if( _outputs->cols != layer_sizes->data.i[layer_sizes->cols - 1] )
CV_Error( CV_StsBadSize, "output matrix must have the same number of columns as "
"the number of neurons in the output layer" );
n = dn0 = _inputs->rows;
min_buf_sz = 2*max_count;
buf_sz = n*min_buf_sz;
if( buf_sz > max_buf_sz )
{
dn0 = max_buf_sz/min_buf_sz;
dn0 = MAX( dn0, 1 );
buf_sz = dn0*min_buf_sz;
}
cv::AutoBuffer<double> buf(buf_sz);
l_count = layer_sizes->cols;
for( i = 0; i < n; i += dn )
{
CvMat hdr[2], _w, *layer_in = &hdr[0], *layer_out = &hdr[1], *temp;
dn = MIN( dn0, n - i );
cvGetRows( _inputs, layer_in, i, i + dn );
cvInitMatHeader( layer_out, dn, layer_in->cols, CV_64F, &buf[0] );
scale_input( layer_in, layer_out );
CV_SWAP( layer_in, layer_out, temp );
for( j = 1; j < l_count; j++ )
{
double* data = buf + (j&1 ? max_count*dn0 : 0);
int cols = layer_sizes->data.i[j];
cvInitMatHeader( layer_out, dn, cols, CV_64F, data );
cvInitMatHeader( &_w, layer_in->cols, layer_out->cols, CV_64F, weights[j] );
cvGEMM( layer_in, &_w, 1, 0, 0, layer_out );
calc_activ_func( layer_out, _w.data.db + _w.rows*_w.cols );
CV_SWAP( layer_in, layer_out, temp );
}
cvGetRows( _outputs, layer_out, i, i + dn );
scale_output( layer_in, layer_out );
}
return 0.f;
}
void CvANN_MLP::scale_input( const CvMat* _src, CvMat* _dst ) const
{
int i, j, cols = _src->cols;
double* dst = _dst->data.db;
const double* w = weights[0];
int step = _src->step;
if( CV_MAT_TYPE( _src->type ) == CV_32F )
{
const float* src = _src->data.fl;
step /= sizeof(src[0]);
for( i = 0; i < _src->rows; i++, src += step, dst += cols )
for( j = 0; j < cols; j++ )
dst[j] = src[j]*w[j*2] + w[j*2+1];
}
else
{
const double* src = _src->data.db;
step /= sizeof(src[0]);
for( i = 0; i < _src->rows; i++, src += step, dst += cols )
for( j = 0; j < cols; j++ )
dst[j] = src[j]*w[j*2] + w[j*2+1];
}
}
void CvANN_MLP::scale_output( const CvMat* _src, CvMat* _dst ) const
{
int i, j, cols = _src->cols;
const double* src = _src->data.db;
const double* w = weights[layer_sizes->cols];
int step = _dst->step;
if( CV_MAT_TYPE( _dst->type ) == CV_32F )
{
float* dst = _dst->data.fl;
step /= sizeof(dst[0]);
for( i = 0; i < _src->rows; i++, src += cols, dst += step )
for( j = 0; j < cols; j++ )
dst[j] = (float)(src[j]*w[j*2] + w[j*2+1]);
}
else
{
double* dst = _dst->data.db;
step /= sizeof(dst[0]);
for( i = 0; i < _src->rows; i++, src += cols, dst += step )
for( j = 0; j < cols; j++ )
dst[j] = src[j]*w[j*2] + w[j*2+1];
}
}
void CvANN_MLP::calc_activ_func( CvMat* sums, const double* bias ) const
{
int i, j, n = sums->rows, cols = sums->cols;
double* data = sums->data.db;
double scale = 0, scale2 = f_param2;
switch( activ_func )
{
case IDENTITY:
scale = 1.;
break;
case SIGMOID_SYM:
scale = -f_param1;
break;
case GAUSSIAN:
scale = -f_param1*f_param1;
break;
default:
;
}
assert( CV_IS_MAT_CONT(sums->type) );
if( activ_func != GAUSSIAN )
{
for( i = 0; i < n; i++, data += cols )
for( j = 0; j < cols; j++ )
data[j] = (data[j] + bias[j])*scale;
if( activ_func == IDENTITY )
return;
}
else
{
for( i = 0; i < n; i++, data += cols )
for( j = 0; j < cols; j++ )
{
double t = data[j] + bias[j];
data[j] = t*t*scale;
}
}
cvExp( sums, sums );
n *= cols;
data -= n;
switch( activ_func )
{
case SIGMOID_SYM:
for( i = 0; i <= n - 4; i += 4 )
{
double x0 = 1.+data[i], x1 = 1.+data[i+1], x2 = 1.+data[i+2], x3 = 1.+data[i+3];
double a = x0*x1, b = x2*x3, d = scale2/(a*b), t0, t1;
a *= d; b *= d;
t0 = (2 - x0)*b*x1; t1 = (2 - x1)*b*x0;
data[i] = t0; data[i+1] = t1;
t0 = (2 - x2)*a*x3; t1 = (2 - x3)*a*x2;
data[i+2] = t0; data[i+3] = t1;
}
for( ; i < n; i++ )
{
double t = scale2*(1. - data[i])/(1. + data[i]);
data[i] = t;
}
break;
case GAUSSIAN:
for( i = 0; i < n; i++ )
data[i] = scale2*data[i];
break;
default:
;
}
}
void CvANN_MLP::calc_activ_func_deriv( CvMat* _xf, CvMat* _df,
const double* bias ) const
{
int i, j, n = _xf->rows, cols = _xf->cols;
double* xf = _xf->data.db;
double* df = _df->data.db;
double scale, scale2 = f_param2;
assert( CV_IS_MAT_CONT( _xf->type & _df->type ) );
if( activ_func == IDENTITY )
{
for( i = 0; i < n; i++, xf += cols, df += cols )
for( j = 0; j < cols; j++ )
{
xf[j] += bias[j];
df[j] = 1;
}
return;
}
else if( activ_func == GAUSSIAN )
{
scale = -f_param1*f_param1;
scale2 *= scale;
for( i = 0; i < n; i++, xf += cols, df += cols )
for( j = 0; j < cols; j++ )
{
double t = xf[j] + bias[j];
df[j] = t*2*scale2;
xf[j] = t*t*scale;
}
cvExp( _xf, _xf );
n *= cols;
xf -= n; df -= n;
for( i = 0; i < n; i++ )
df[i] *= xf[i];
}
else
{
scale = f_param1;
for( i = 0; i < n; i++, xf += cols, df += cols )
for( j = 0; j < cols; j++ )
{
xf[j] = (xf[j] + bias[j])*scale;
df[j] = -fabs(xf[j]);
}
cvExp( _df, _df );
n *= cols;
xf -= n; df -= n;
// ((1+exp(-ax))^-1)'=a*((1+exp(-ax))^-2)*exp(-ax);
// ((1-exp(-ax))/(1+exp(-ax)))'=(a*exp(-ax)*(1+exp(-ax)) + a*exp(-ax)*(1-exp(-ax)))/(1+exp(-ax))^2=
// 2*a*exp(-ax)/(1+exp(-ax))^2
scale *= 2*f_param2;
for( i = 0; i < n; i++ )
{
int s0 = xf[i] > 0 ? 1 : -1;
double t0 = 1./(1. + df[i]);
double t1 = scale*df[i]*t0*t0;
t0 *= scale2*(1. - df[i])*s0;
df[i] = t1;
xf[i] = t0;
}
}
}
void CvANN_MLP::calc_input_scale( const CvVectors* vecs, int flags )
{
bool reset_weights = (flags & UPDATE_WEIGHTS) == 0;
bool no_scale = (flags & NO_INPUT_SCALE) != 0;
double* scale = weights[0];
int count = vecs->count;
if( reset_weights )
{
int i, j, vcount = layer_sizes->data.i[0];
int type = vecs->type;
double a = no_scale ? 1. : 0.;
for( j = 0; j < vcount; j++ )
scale[2*j] = a, scale[j*2+1] = 0.;
if( no_scale )
return;
for( i = 0; i < count; i++ )
{
const float* f = vecs->data.fl[i];
const double* d = vecs->data.db[i];
for( j = 0; j < vcount; j++ )
{
double t = type == CV_32F ? (double)f[j] : d[j];
scale[j*2] += t;
scale[j*2+1] += t*t;
}
}
for( j = 0; j < vcount; j++ )
{
double s = scale[j*2], s2 = scale[j*2+1];
double m = s/count, sigma2 = s2/count - m*m;
scale[j*2] = sigma2 < DBL_EPSILON ? 1 : 1./sqrt(sigma2);
scale[j*2+1] = -m*scale[j*2];
}
}
}
void CvANN_MLP::calc_output_scale( const CvVectors* vecs, int flags )
{
int i, j, vcount = layer_sizes->data.i[layer_sizes->cols-1];
int type = vecs->type;
double m = min_val, M = max_val, m1 = min_val1, M1 = max_val1;
bool reset_weights = (flags & UPDATE_WEIGHTS) == 0;
bool no_scale = (flags & NO_OUTPUT_SCALE) != 0;
int l_count = layer_sizes->cols;
double* scale = weights[l_count];
double* inv_scale = weights[l_count+1];
int count = vecs->count;
CV_FUNCNAME( "CvANN_MLP::calc_output_scale" );
__BEGIN__;
if( reset_weights )
{
double a0 = no_scale ? 1 : DBL_MAX, b0 = no_scale ? 0 : -DBL_MAX;
for( j = 0; j < vcount; j++ )
{
scale[2*j] = inv_scale[2*j] = a0;
scale[j*2+1] = inv_scale[2*j+1] = b0;
}
if( no_scale )
EXIT;
}
for( i = 0; i < count; i++ )
{
const float* f = vecs->data.fl[i];
const double* d = vecs->data.db[i];
for( j = 0; j < vcount; j++ )
{
double t = type == CV_32F ? (double)f[j] : d[j];
if( reset_weights )
{
double mj = scale[j*2], Mj = scale[j*2+1];
if( mj > t ) mj = t;
if( Mj < t ) Mj = t;
scale[j*2] = mj;
scale[j*2+1] = Mj;
}
else
{
t = t*inv_scale[j*2] + inv_scale[2*j+1];
if( t < m1 || t > M1 )
CV_ERROR( CV_StsOutOfRange,
"Some of new output training vector components run exceed the original range too much" );
}
}
}
if( reset_weights )
for( j = 0; j < vcount; j++ )
{
// map mj..Mj to m..M
double mj = scale[j*2], Mj = scale[j*2+1];
double a, b;
double delta = Mj - mj;
if( delta < DBL_EPSILON )
a = 1, b = (M + m - Mj - mj)*0.5;
else
a = (M - m)/delta, b = m - mj*a;
inv_scale[j*2] = a; inv_scale[j*2+1] = b;
a = 1./a; b = -b*a;
scale[j*2] = a; scale[j*2+1] = b;
}
__END__;
}
bool CvANN_MLP::prepare_to_train( const CvMat* _inputs, const CvMat* _outputs,
const CvMat* _sample_weights, const CvMat* _sample_idx,
CvVectors* _ivecs, CvVectors* _ovecs, double** _sw, int _flags )
{
bool ok = false;
CvMat* sample_idx = 0;
CvVectors ivecs, ovecs;
double* sw = 0;
int count = 0;
CV_FUNCNAME( "CvANN_MLP::prepare_to_train" );
ivecs.data.ptr = ovecs.data.ptr = 0;
assert( _ivecs && _ovecs );
__BEGIN__;
const int* sidx = 0;
int i, sw_type = 0, sw_count = 0;
int sw_step = 0;
double sw_sum = 0;
if( !layer_sizes )
CV_ERROR( CV_StsError,
"The network has not been created. Use method create or the appropriate constructor" );
if( !CV_IS_MAT(_inputs) || (CV_MAT_TYPE(_inputs->type) != CV_32FC1 &&
CV_MAT_TYPE(_inputs->type) != CV_64FC1) || _inputs->cols != layer_sizes->data.i[0] )
CV_ERROR( CV_StsBadArg,
"input training data should be a floating-point matrix with"
"the number of rows equal to the number of training samples and "
"the number of columns equal to the size of 0-th (input) layer" );
if( !CV_IS_MAT(_outputs) || (CV_MAT_TYPE(_outputs->type) != CV_32FC1 &&
CV_MAT_TYPE(_outputs->type) != CV_64FC1) ||
_outputs->cols != layer_sizes->data.i[layer_sizes->cols - 1] )
CV_ERROR( CV_StsBadArg,
"output training data should be a floating-point matrix with"
"the number of rows equal to the number of training samples and "
"the number of columns equal to the size of last (output) layer" );
if( _inputs->rows != _outputs->rows )
CV_ERROR( CV_StsUnmatchedSizes, "The numbers of input and output samples do not match" );
if( _sample_idx )
{
CV_CALL( sample_idx = cvPreprocessIndexArray( _sample_idx, _inputs->rows ));
sidx = sample_idx->data.i;
count = sample_idx->cols + sample_idx->rows - 1;
}
else
count = _inputs->rows;
if( _sample_weights )
{
if( !CV_IS_MAT(_sample_weights) )
CV_ERROR( CV_StsBadArg, "sample_weights (if passed) must be a valid matrix" );
sw_type = CV_MAT_TYPE(_sample_weights->type);
sw_count = _sample_weights->cols + _sample_weights->rows - 1;
if( (sw_type != CV_32FC1 && sw_type != CV_64FC1) ||
(_sample_weights->cols != 1 && _sample_weights->rows != 1) ||
(sw_count != count && sw_count != _inputs->rows) )
CV_ERROR( CV_StsBadArg,
"sample_weights must be 1d floating-point vector containing weights "
"of all or selected training samples" );
sw_step = CV_IS_MAT_CONT(_sample_weights->type) ? 1 :
_sample_weights->step/CV_ELEM_SIZE(sw_type);
CV_CALL( sw = (double*)cvAlloc( count*sizeof(sw[0]) ));
}
CV_CALL( ivecs.data.ptr = (uchar**)cvAlloc( count*sizeof(ivecs.data.ptr[0]) ));
CV_CALL( ovecs.data.ptr = (uchar**)cvAlloc( count*sizeof(ovecs.data.ptr[0]) ));
ivecs.type = CV_MAT_TYPE(_inputs->type);
ovecs.type = CV_MAT_TYPE(_outputs->type);
ivecs.count = ovecs.count = count;
for( i = 0; i < count; i++ )
{
int idx = sidx ? sidx[i] : i;
ivecs.data.ptr[i] = _inputs->data.ptr + idx*_inputs->step;
ovecs.data.ptr[i] = _outputs->data.ptr + idx*_outputs->step;
if( sw )
{
int si = sw_count == count ? i : idx;
double w = sw_type == CV_32FC1 ?
(double)_sample_weights->data.fl[si*sw_step] :
_sample_weights->data.db[si*sw_step];
sw[i] = w;
if( w < 0 )
CV_ERROR( CV_StsOutOfRange, "some of sample weights are negative" );
sw_sum += w;
}
}
// normalize weights
if( sw )
{
sw_sum = sw_sum > DBL_EPSILON ? 1./sw_sum : 0;
for( i = 0; i < count; i++ )
sw[i] *= sw_sum;
}
calc_input_scale( &ivecs, _flags );
CV_CALL( calc_output_scale( &ovecs, _flags ));
ok = true;
__END__;
if( !ok )
{
cvFree( &ivecs.data.ptr );
cvFree( &ovecs.data.ptr );
cvFree( &sw );
}
cvReleaseMat( &sample_idx );
*_ivecs = ivecs;
*_ovecs = ovecs;
*_sw = sw;
return ok;
}
int CvANN_MLP::train( const CvMat* _inputs, const CvMat* _outputs,
const CvMat* _sample_weights, const CvMat* _sample_idx,
CvANN_MLP_TrainParams _params, int flags )
{
const int MAX_ITER = 1000;
const double DEFAULT_EPSILON = FLT_EPSILON;
double* sw = 0;
CvVectors x0, u;
int iter = -1;
x0.data.ptr = u.data.ptr = 0;
CV_FUNCNAME( "CvANN_MLP::train" );
__BEGIN__;
int max_iter;
double epsilon;
params = _params;
// initialize training data
CV_CALL( prepare_to_train( _inputs, _outputs, _sample_weights,
_sample_idx, &x0, &u, &sw, flags ));
// ... and link weights
if( !(flags & UPDATE_WEIGHTS) )
init_weights();
max_iter = params.term_crit.type & CV_TERMCRIT_ITER ? params.term_crit.max_iter : MAX_ITER;
max_iter = MAX( max_iter, 1 );
epsilon = params.term_crit.type & CV_TERMCRIT_EPS ? params.term_crit.epsilon : DEFAULT_EPSILON;
epsilon = MAX(epsilon, DBL_EPSILON);
params.term_crit.type = CV_TERMCRIT_ITER + CV_TERMCRIT_EPS;
params.term_crit.max_iter = max_iter;
params.term_crit.epsilon = epsilon;
if( params.train_method == CvANN_MLP_TrainParams::BACKPROP )
{
CV_CALL( iter = train_backprop( x0, u, sw ));
}
else
{
CV_CALL( iter = train_rprop( x0, u, sw ));
}
__END__;
cvFree( &x0.data.ptr );
cvFree( &u.data.ptr );
cvFree( &sw );
return iter;
}
int CvANN_MLP::train_backprop( CvVectors x0, CvVectors u, const double* sw )
{
CvMat* dw = 0;
CvMat* buf = 0;
double **x = 0, **df = 0;
CvMat* _idx = 0;
int iter = -1, count = x0.count;
CV_FUNCNAME( "CvANN_MLP::train_backprop" );
__BEGIN__;
int i, j, k, ivcount, ovcount, l_count, total = 0, max_iter;
double *buf_ptr;
double prev_E = DBL_MAX*0.5, E = 0, epsilon;
max_iter = params.term_crit.max_iter*count;
epsilon = params.term_crit.epsilon*count;
l_count = layer_sizes->cols;
ivcount = layer_sizes->data.i[0];
ovcount = layer_sizes->data.i[l_count-1];
// allocate buffers
for( i = 0; i < l_count; i++ )
total += layer_sizes->data.i[i] + 1;
CV_CALL( dw = cvCreateMat( wbuf->rows, wbuf->cols, wbuf->type ));
cvZero( dw );
CV_CALL( buf = cvCreateMat( 1, (total + max_count)*2, CV_64F ));
CV_CALL( _idx = cvCreateMat( 1, count, CV_32SC1 ));
for( i = 0; i < count; i++ )
_idx->data.i[i] = i;
CV_CALL( x = (double**)cvAlloc( total*2*sizeof(x[0]) ));
df = x + total;
buf_ptr = buf->data.db;
for( j = 0; j < l_count; j++ )
{
x[j] = buf_ptr;
df[j] = x[j] + layer_sizes->data.i[j];
buf_ptr += (df[j] - x[j])*2;
}
// run back-propagation loop
/*
y_i = w_i*x_{i-1}
x_i = f(y_i)
E = 1/2*||u - x_N||^2
grad_N = (x_N - u)*f'(y_i)
dw_i(t) = momentum*dw_i(t-1) + dw_scale*x_{i-1}*grad_i
w_i(t+1) = w_i(t) + dw_i(t)
grad_{i-1} = w_i^t*grad_i
*/
for( iter = 0; iter < max_iter; iter++ )
{
int idx = iter % count;
double* w = weights[0];
double sweight = sw ? count*sw[idx] : 1.;
CvMat _w, _dw, hdr1, hdr2, ghdr1, ghdr2, _df;
CvMat *x1 = &hdr1, *x2 = &hdr2, *grad1 = &ghdr1, *grad2 = &ghdr2, *temp;
if( idx == 0 )
{
//printf("%d. E = %g\n", iter/count, E);
if( fabs(prev_E - E) < epsilon )
break;
prev_E = E;
E = 0;
// shuffle indices
for( i = 0; i < count; i++ )
{
int tt;
j = (*rng)(count);
k = (*rng)(count);
CV_SWAP( _idx->data.i[j], _idx->data.i[k], tt );
}
}
idx = _idx->data.i[idx];
if( x0.type == CV_32F )
{
const float* x0data = x0.data.fl[idx];
for( j = 0; j < ivcount; j++ )
x[0][j] = x0data[j]*w[j*2] + w[j*2 + 1];
}
else
{
const double* x0data = x0.data.db[idx];
for( j = 0; j < ivcount; j++ )
x[0][j] = x0data[j]*w[j*2] + w[j*2 + 1];
}
cvInitMatHeader( x1, 1, ivcount, CV_64F, x[0] );
// forward pass, compute y[i]=w*x[i-1], x[i]=f(y[i]), df[i]=f'(y[i])
for( i = 1; i < l_count; i++ )
{
cvInitMatHeader( x2, 1, layer_sizes->data.i[i], CV_64F, x[i] );
cvInitMatHeader( &_w, x1->cols, x2->cols, CV_64F, weights[i] );
cvGEMM( x1, &_w, 1, 0, 0, x2 );
_df = *x2;
_df.data.db = df[i];
calc_activ_func_deriv( x2, &_df, _w.data.db + _w.rows*_w.cols );
CV_SWAP( x1, x2, temp );
}
cvInitMatHeader( grad1, 1, ovcount, CV_64F, buf_ptr );
*grad2 = *grad1;
grad2->data.db = buf_ptr + max_count;
w = weights[l_count+1];
// calculate error
if( u.type == CV_32F )
{
const float* udata = u.data.fl[idx];
for( k = 0; k < ovcount; k++ )
{
double t = udata[k]*w[k*2] + w[k*2+1] - x[l_count-1][k];
grad1->data.db[k] = t*sweight;
E += t*t;
}
}
else
{
const double* udata = u.data.db[idx];
for( k = 0; k < ovcount; k++ )
{
double t = udata[k]*w[k*2] + w[k*2+1] - x[l_count-1][k];
grad1->data.db[k] = t*sweight;
E += t*t;
}
}
E *= sweight;
// backward pass, update weights
for( i = l_count-1; i > 0; i-- )
{
int n1 = layer_sizes->data.i[i-1], n2 = layer_sizes->data.i[i];
cvInitMatHeader( &_df, 1, n2, CV_64F, df[i] );
cvMul( grad1, &_df, grad1 );
cvInitMatHeader( &_w, n1+1, n2, CV_64F, weights[i] );
cvInitMatHeader( &_dw, n1+1, n2, CV_64F, dw->data.db + (weights[i] - weights[0]) );
cvInitMatHeader( x1, n1+1, 1, CV_64F, x[i-1] );
x[i-1][n1] = 1.;
cvGEMM( x1, grad1, params.bp_dw_scale, &_dw, params.bp_moment_scale, &_dw );
cvAdd( &_w, &_dw, &_w );
if( i > 1 )
{
grad2->cols = n1;
_w.rows = n1;
cvGEMM( grad1, &_w, 1, 0, 0, grad2, CV_GEMM_B_T );
}
CV_SWAP( grad1, grad2, temp );
}
}
iter /= count;
__END__;
cvReleaseMat( &dw );
cvReleaseMat( &buf );
cvReleaseMat( &_idx );
cvFree( &x );
return iter;
}
struct rprop_loop : cv::ParallelLoopBody {
rprop_loop(const CvANN_MLP* _point, double**& _weights, int& _count, int& _ivcount, CvVectors* _x0,
int& _l_count, CvMat*& _layer_sizes, int& _ovcount, int& _max_count,
CvVectors* _u, const double*& _sw, double& _inv_count, CvMat*& _dEdw, int& _dcount0, double* _E, int _buf_sz)
{
point = _point;
weights = _weights;
count = _count;
ivcount = _ivcount;
x0 = _x0;
l_count = _l_count;
layer_sizes = _layer_sizes;
ovcount = _ovcount;
max_count = _max_count;
u = _u;
sw = _sw;
inv_count = _inv_count;
dEdw = _dEdw;
dcount0 = _dcount0;
E = _E;
buf_sz = _buf_sz;
}
const CvANN_MLP* point;
double** weights;
int count;
int ivcount;
CvVectors* x0;
int l_count;
CvMat* layer_sizes;
int ovcount;
int max_count;
CvVectors* u;
const double* sw;
double inv_count;
CvMat* dEdw;
int dcount0;
double* E;
int buf_sz;
void operator()( const cv::Range& range ) const
{
double* buf_ptr;
double** x = 0;
double **df = 0;
int total = 0;
for(int i = 0; i < l_count; i++ )
total += layer_sizes->data.i[i];
CvMat* buf;
buf = cvCreateMat( 1, buf_sz, CV_64F );
x = (double**)cvAlloc( total*2*sizeof(x[0]) );
df = x + total;
buf_ptr = buf->data.db;
for(int i = 0; i < l_count; i++ )
{
x[i] = buf_ptr;
df[i] = x[i] + layer_sizes->data.i[i]*dcount0;
buf_ptr += (df[i] - x[i])*2;
}
for(int si = range.start; si < range.end; si++ )
{
if (si % dcount0 != 0) continue;
int n1, n2, k;
double* w;
CvMat _w, _dEdw, hdr1, hdr2, ghdr1, ghdr2, _df;
CvMat *x1, *x2, *grad1, *grad2, *temp;
int dcount = 0;
dcount = MIN(count - si , dcount0 );
w = weights[0];
grad1 = &ghdr1; grad2 = &ghdr2;
x1 = &hdr1; x2 = &hdr2;
// grab and preprocess input data
if( x0->type == CV_32F )
{
for(int i = 0; i < dcount; i++ )
{
const float* x0data = x0->data.fl[si+i];
double* xdata = x[0]+i*ivcount;
for(int j = 0; j < ivcount; j++ )
xdata[j] = x0data[j]*w[j*2] + w[j*2+1];
}
}
else
for(int i = 0; i < dcount; i++ )
{
const double* x0data = x0->data.db[si+i];
double* xdata = x[0]+i*ivcount;
for(int j = 0; j < ivcount; j++ )
xdata[j] = x0data[j]*w[j*2] + w[j*2+1];
}
cvInitMatHeader( x1, dcount, ivcount, CV_64F, x[0] );
// forward pass, compute y[i]=w*x[i-1], x[i]=f(y[i]), df[i]=f'(y[i])
for(int i = 1; i < l_count; i++ )
{
cvInitMatHeader( x2, dcount, layer_sizes->data.i[i], CV_64F, x[i] );
cvInitMatHeader( &_w, x1->cols, x2->cols, CV_64F, weights[i] );
cvGEMM( x1, &_w, 1, 0, 0, x2 );
_df = *x2;
_df.data.db = df[i];
point->calc_activ_func_deriv( x2, &_df, _w.data.db + _w.rows*_w.cols );
CV_SWAP( x1, x2, temp );
}
cvInitMatHeader( grad1, dcount, ovcount, CV_64F, buf_ptr );
w = weights[l_count+1];
grad2->data.db = buf_ptr + max_count*dcount;
// calculate error
if( u->type == CV_32F )
for(int i = 0; i < dcount; i++ )
{
const float* udata = u->data.fl[si+i];
const double* xdata = x[l_count-1] + i*ovcount;
double* gdata = grad1->data.db + i*ovcount;
double sweight = sw ? sw[si+i] : inv_count, E1 = 0;
for(int j = 0; j < ovcount; j++ )
{
double t = udata[j]*w[j*2] + w[j*2+1] - xdata[j];
gdata[j] = t*sweight;
E1 += t*t;
}
*E += sweight*E1;
}
else
for(int i = 0; i < dcount; i++ )
{
const double* udata = u->data.db[si+i];
const double* xdata = x[l_count-1] + i*ovcount;
double* gdata = grad1->data.db + i*ovcount;
double sweight = sw ? sw[si+i] : inv_count, E1 = 0;
for(int j = 0; j < ovcount; j++ )
{
double t = udata[j]*w[j*2] + w[j*2+1] - xdata[j];
gdata[j] = t*sweight;
E1 += t*t;
}
*E += sweight*E1;
}
// backward pass, update dEdw
static cv::Mutex mutex;
for(int i = l_count-1; i > 0; i-- )
{
n1 = layer_sizes->data.i[i-1]; n2 = layer_sizes->data.i[i];
cvInitMatHeader( &_df, dcount, n2, CV_64F, df[i] );
cvMul( grad1, &_df, grad1 );
{
cv::AutoLock lock(mutex);
cvInitMatHeader( &_dEdw, n1, n2, CV_64F, dEdw->data.db+(weights[i]-weights[0]) );
cvInitMatHeader( x1, dcount, n1, CV_64F, x[i-1] );
cvGEMM( x1, grad1, 1, &_dEdw, 1, &_dEdw, CV_GEMM_A_T );
// update bias part of dEdw
for( k = 0; k < dcount; k++ )
{
double* dst = _dEdw.data.db + n1*n2;
const double* src = grad1->data.db + k*n2;
for(int j = 0; j < n2; j++ )
dst[j] += src[j];
}
if (i > 1)
cvInitMatHeader( &_w, n1, n2, CV_64F, weights[i] );
}
cvInitMatHeader( grad2, dcount, n1, CV_64F, grad2->data.db );
if( i > 1 )
cvGEMM( grad1, &_w, 1, 0, 0, grad2, CV_GEMM_B_T );
CV_SWAP( grad1, grad2, temp );
}
}
cvFree(&x);
cvReleaseMat( &buf );
}
};
int CvANN_MLP::train_rprop( CvVectors x0, CvVectors u, const double* sw )
{
const int max_buf_size = 1 << 16;
CvMat* dw = 0;
CvMat* dEdw = 0;
CvMat* prev_dEdw_sign = 0;
CvMat* buf = 0;
double **x = 0, **df = 0;
int iter = -1, count = x0.count;
CV_FUNCNAME( "CvANN_MLP::train" );
__BEGIN__;
int i, ivcount, ovcount, l_count, total = 0, max_iter, buf_sz, dcount0;
double *buf_ptr;
double prev_E = DBL_MAX*0.5, epsilon;
double dw_plus, dw_minus, dw_min, dw_max;
double inv_count;
max_iter = params.term_crit.max_iter;
epsilon = params.term_crit.epsilon;
dw_plus = params.rp_dw_plus;
dw_minus = params.rp_dw_minus;
dw_min = params.rp_dw_min;
dw_max = params.rp_dw_max;
l_count = layer_sizes->cols;
ivcount = layer_sizes->data.i[0];
ovcount = layer_sizes->data.i[l_count-1];
// allocate buffers
for( i = 0; i < l_count; i++ )
total += layer_sizes->data.i[i];
CV_CALL( dw = cvCreateMat( wbuf->rows, wbuf->cols, wbuf->type ));
cvSet( dw, cvScalarAll(params.rp_dw0) );
CV_CALL( dEdw = cvCreateMat( wbuf->rows, wbuf->cols, wbuf->type ));
cvZero( dEdw );
CV_CALL( prev_dEdw_sign = cvCreateMat( wbuf->rows, wbuf->cols, CV_8SC1 ));
cvZero( prev_dEdw_sign );
inv_count = 1./count;
dcount0 = max_buf_size/(2*total);
dcount0 = MAX( dcount0, 1 );
dcount0 = MIN( dcount0, count );
buf_sz = dcount0*(total + max_count)*2;
CV_CALL( buf = cvCreateMat( 1, buf_sz, CV_64F ));
CV_CALL( x = (double**)cvAlloc( total*2*sizeof(x[0]) ));
df = x + total;
buf_ptr = buf->data.db;
for( i = 0; i < l_count; i++ )
{
x[i] = buf_ptr;
df[i] = x[i] + layer_sizes->data.i[i]*dcount0;
buf_ptr += (df[i] - x[i])*2;
}
// run rprop loop
/*
y_i(t) = w_i(t)*x_{i-1}(t)
x_i(t) = f(y_i(t))
E = sum_over_all_samples(1/2*||u - x_N||^2)
grad_N = (x_N - u)*f'(y_i)
MIN(dw_i{jk}(t)*dw_plus, dw_max), if dE/dw_i{jk}(t)*dE/dw_i{jk}(t-1) > 0
dw_i{jk}(t) = MAX(dw_i{jk}(t)*dw_minus, dw_min), if dE/dw_i{jk}(t)*dE/dw_i{jk}(t-1) < 0
dw_i{jk}(t-1) else
if (dE/dw_i{jk}(t)*dE/dw_i{jk}(t-1) < 0)
dE/dw_i{jk}(t)<-0
else
w_i{jk}(t+1) = w_i{jk}(t) + dw_i{jk}(t)
grad_{i-1}(t) = w_i^t(t)*grad_i(t)
*/
for( iter = 0; iter < max_iter; iter++ )
{
int n1, n2, j, k;
double E = 0;
// first, iterate through all the samples and compute dEdw
cv::parallel_for_(cv::Range(0, count),
rprop_loop(this, weights, count, ivcount, &x0, l_count, layer_sizes,
ovcount, max_count, &u, sw, inv_count, dEdw, dcount0, &E, buf_sz)
);
// now update weights
for( i = 1; i < l_count; i++ )
{
n1 = layer_sizes->data.i[i-1]; n2 = layer_sizes->data.i[i];
for( k = 0; k <= n1; k++ )
{
double* wk = weights[i]+k*n2;
size_t delta = wk - weights[0];
double* dwk = dw->data.db + delta;
double* dEdwk = dEdw->data.db + delta;
char* prevEk = (char*)(prev_dEdw_sign->data.ptr + delta);
for( j = 0; j < n2; j++ )
{
double Eval = dEdwk[j];
double dval = dwk[j];
double wval = wk[j];
int s = CV_SIGN(Eval);
int ss = prevEk[j]*s;
if( ss > 0 )
{
dval *= dw_plus;
dval = MIN( dval, dw_max );
dwk[j] = dval;
wk[j] = wval + dval*s;
}
else if( ss < 0 )
{
dval *= dw_minus;
dval = MAX( dval, dw_min );
prevEk[j] = 0;
dwk[j] = dval;
wk[j] = wval + dval*s;
}
else
{
prevEk[j] = (char)s;
wk[j] = wval + dval*s;
}
dEdwk[j] = 0.;
}
}
}
//printf("%d. E = %g\n", iter, E);
if( fabs(prev_E - E) < epsilon )
break;
prev_E = E;
E = 0;
}
__END__;
cvReleaseMat( &dw );
cvReleaseMat( &dEdw );
cvReleaseMat( &prev_dEdw_sign );
cvReleaseMat( &buf );
cvFree( &x );
return iter;
}
void CvANN_MLP::write_params( CvFileStorage* fs ) const
{
//CV_FUNCNAME( "CvANN_MLP::write_params" );
__BEGIN__;
const char* activ_func_name = activ_func == IDENTITY ? "IDENTITY" :
activ_func == SIGMOID_SYM ? "SIGMOID_SYM" :
activ_func == GAUSSIAN ? "GAUSSIAN" : 0;
if( activ_func_name )
cvWriteString( fs, "activation_function", activ_func_name );
else
cvWriteInt( fs, "activation_function", activ_func );
if( activ_func != IDENTITY )
{
cvWriteReal( fs, "f_param1", f_param1 );
cvWriteReal( fs, "f_param2", f_param2 );
}
cvWriteReal( fs, "min_val", min_val );
cvWriteReal( fs, "max_val", max_val );
cvWriteReal( fs, "min_val1", min_val1 );
cvWriteReal( fs, "max_val1", max_val1 );
cvStartWriteStruct( fs, "training_params", CV_NODE_MAP );
if( params.train_method == CvANN_MLP_TrainParams::BACKPROP )
{
cvWriteString( fs, "train_method", "BACKPROP" );
cvWriteReal( fs, "dw_scale", params.bp_dw_scale );
cvWriteReal( fs, "moment_scale", params.bp_moment_scale );
}
else if( params.train_method == CvANN_MLP_TrainParams::RPROP )
{
cvWriteString( fs, "train_method", "RPROP" );
cvWriteReal( fs, "dw0", params.rp_dw0 );
cvWriteReal( fs, "dw_plus", params.rp_dw_plus );
cvWriteReal( fs, "dw_minus", params.rp_dw_minus );
cvWriteReal( fs, "dw_min", params.rp_dw_min );
cvWriteReal( fs, "dw_max", params.rp_dw_max );
}
cvStartWriteStruct( fs, "term_criteria", CV_NODE_MAP + CV_NODE_FLOW );
if( params.term_crit.type & CV_TERMCRIT_EPS )
cvWriteReal( fs, "epsilon", params.term_crit.epsilon );
if( params.term_crit.type & CV_TERMCRIT_ITER )
cvWriteInt( fs, "iterations", params.term_crit.max_iter );
cvEndWriteStruct( fs );
cvEndWriteStruct( fs );
__END__;
}
void CvANN_MLP::write( CvFileStorage* fs, const char* name ) const
{
CV_FUNCNAME( "CvANN_MLP::write" );
__BEGIN__;
int i, l_count = layer_sizes->cols;
if( !layer_sizes )
CV_ERROR( CV_StsError, "The network has not been initialized" );
cvStartWriteStruct( fs, name, CV_NODE_MAP, CV_TYPE_NAME_ML_ANN_MLP );
cvWrite( fs, "layer_sizes", layer_sizes );
write_params( fs );
cvStartWriteStruct( fs, "input_scale", CV_NODE_SEQ + CV_NODE_FLOW );
cvWriteRawData( fs, weights[0], layer_sizes->data.i[0]*2, "d" );
cvEndWriteStruct( fs );
cvStartWriteStruct( fs, "output_scale", CV_NODE_SEQ + CV_NODE_FLOW );
cvWriteRawData( fs, weights[l_count], layer_sizes->data.i[l_count-1]*2, "d" );
cvEndWriteStruct( fs );
cvStartWriteStruct( fs, "inv_output_scale", CV_NODE_SEQ + CV_NODE_FLOW );
cvWriteRawData( fs, weights[l_count+1], layer_sizes->data.i[l_count-1]*2, "d" );
cvEndWriteStruct( fs );
cvStartWriteStruct( fs, "weights", CV_NODE_SEQ );
for( i = 1; i < l_count; i++ )
{
cvStartWriteStruct( fs, 0, CV_NODE_SEQ + CV_NODE_FLOW );
cvWriteRawData( fs, weights[i], (layer_sizes->data.i[i-1]+1)*layer_sizes->data.i[i], "d" );
cvEndWriteStruct( fs );
}
cvEndWriteStruct( fs );
__END__;
}
void CvANN_MLP::read_params( CvFileStorage* fs, CvFileNode* node )
{
//CV_FUNCNAME( "CvANN_MLP::read_params" );
__BEGIN__;
const char* activ_func_name = cvReadStringByName( fs, node, "activation_function", 0 );
CvFileNode* tparams_node;
if( activ_func_name )
activ_func = strcmp( activ_func_name, "SIGMOID_SYM" ) == 0 ? SIGMOID_SYM :
strcmp( activ_func_name, "IDENTITY" ) == 0 ? IDENTITY :
strcmp( activ_func_name, "GAUSSIAN" ) == 0 ? GAUSSIAN : 0;
else
activ_func = cvReadIntByName( fs, node, "activation_function" );
f_param1 = cvReadRealByName( fs, node, "f_param1", 0 );
f_param2 = cvReadRealByName( fs, node, "f_param2", 0 );
set_activ_func( activ_func, f_param1, f_param2 );
min_val = cvReadRealByName( fs, node, "min_val", 0. );
max_val = cvReadRealByName( fs, node, "max_val", 1. );
min_val1 = cvReadRealByName( fs, node, "min_val1", 0. );
max_val1 = cvReadRealByName( fs, node, "max_val1", 1. );
tparams_node = cvGetFileNodeByName( fs, node, "training_params" );
params = CvANN_MLP_TrainParams();
if( tparams_node )
{
const char* tmethod_name = cvReadStringByName( fs, tparams_node, "train_method", "" );
CvFileNode* tcrit_node;
if( strcmp( tmethod_name, "BACKPROP" ) == 0 )
{
params.train_method = CvANN_MLP_TrainParams::BACKPROP;
params.bp_dw_scale = cvReadRealByName( fs, tparams_node, "dw_scale", 0 );
params.bp_moment_scale = cvReadRealByName( fs, tparams_node, "moment_scale", 0 );
}
else if( strcmp( tmethod_name, "RPROP" ) == 0 )
{
params.train_method = CvANN_MLP_TrainParams::RPROP;
params.rp_dw0 = cvReadRealByName( fs, tparams_node, "dw0", 0 );
params.rp_dw_plus = cvReadRealByName( fs, tparams_node, "dw_plus", 0 );
params.rp_dw_minus = cvReadRealByName( fs, tparams_node, "dw_minus", 0 );
params.rp_dw_min = cvReadRealByName( fs, tparams_node, "dw_min", 0 );
params.rp_dw_max = cvReadRealByName( fs, tparams_node, "dw_max", 0 );
}
tcrit_node = cvGetFileNodeByName( fs, tparams_node, "term_criteria" );
if( tcrit_node )
{
params.term_crit.epsilon = cvReadRealByName( fs, tcrit_node, "epsilon", -1 );
params.term_crit.max_iter = cvReadIntByName( fs, tcrit_node, "iterations", -1 );
params.term_crit.type = (params.term_crit.epsilon >= 0 ? CV_TERMCRIT_EPS : 0) +
(params.term_crit.max_iter >= 0 ? CV_TERMCRIT_ITER : 0);
}
}
__END__;
}
void CvANN_MLP::read( CvFileStorage* fs, CvFileNode* node )
{
CvMat* _layer_sizes = 0;
CV_FUNCNAME( "CvANN_MLP::read" );
__BEGIN__;
CvFileNode* w;
CvSeqReader reader;
int i, l_count;
_layer_sizes = (CvMat*)cvReadByName( fs, node, "layer_sizes" );
CV_CALL( create( _layer_sizes, SIGMOID_SYM, 0, 0 ));
l_count = layer_sizes->cols;
CV_CALL( read_params( fs, node ));
w = cvGetFileNodeByName( fs, node, "input_scale" );
if( !w || CV_NODE_TYPE(w->tag) != CV_NODE_SEQ ||
w->data.seq->total != layer_sizes->data.i[0]*2 )
CV_ERROR( CV_StsParseError, "input_scale tag is not found or is invalid" );
CV_CALL( cvReadRawData( fs, w, weights[0], "d" ));
w = cvGetFileNodeByName( fs, node, "output_scale" );
if( !w || CV_NODE_TYPE(w->tag) != CV_NODE_SEQ ||
w->data.seq->total != layer_sizes->data.i[l_count-1]*2 )
CV_ERROR( CV_StsParseError, "output_scale tag is not found or is invalid" );
CV_CALL( cvReadRawData( fs, w, weights[l_count], "d" ));
w = cvGetFileNodeByName( fs, node, "inv_output_scale" );
if( !w || CV_NODE_TYPE(w->tag) != CV_NODE_SEQ ||
w->data.seq->total != layer_sizes->data.i[l_count-1]*2 )
CV_ERROR( CV_StsParseError, "inv_output_scale tag is not found or is invalid" );
CV_CALL( cvReadRawData( fs, w, weights[l_count+1], "d" ));
w = cvGetFileNodeByName( fs, node, "weights" );
if( !w || CV_NODE_TYPE(w->tag) != CV_NODE_SEQ ||
w->data.seq->total != l_count - 1 )
CV_ERROR( CV_StsParseError, "weights tag is not found or is invalid" );
cvStartReadSeq( w->data.seq, &reader );
for( i = 1; i < l_count; i++ )
{
w = (CvFileNode*)reader.ptr;
CV_CALL( cvReadRawData( fs, w, weights[i], "d" ));
CV_NEXT_SEQ_ELEM( reader.seq->elem_size, reader );
}
__END__;
}
using namespace cv;
CvANN_MLP::CvANN_MLP( const Mat& _layer_sizes, int _activ_func,
double _f_param1, double _f_param2 )
{
layer_sizes = wbuf = 0;
min_val = max_val = min_val1 = max_val1 = 0.;
weights = 0;
rng = &cv::theRNG();
default_model_name = "my_nn";
create( _layer_sizes, _activ_func, _f_param1, _f_param2 );
}
void CvANN_MLP::create( const Mat& _layer_sizes, int _activ_func,
double _f_param1, double _f_param2 )
{
CvMat cvlayer_sizes = _layer_sizes;
create( &cvlayer_sizes, _activ_func, _f_param1, _f_param2 );
}
int CvANN_MLP::train( const Mat& _inputs, const Mat& _outputs,
const Mat& _sample_weights, const Mat& _sample_idx,
CvANN_MLP_TrainParams _params, int flags )
{
CvMat inputs = _inputs, outputs = _outputs, sweights = _sample_weights, sidx = _sample_idx;
return train(&inputs, &outputs, sweights.data.ptr ? &sweights : 0,
sidx.data.ptr ? &sidx : 0, _params, flags);
}
float CvANN_MLP::predict( const Mat& _inputs, Mat& _outputs ) const
{
CV_Assert(layer_sizes != 0);
_outputs.create(_inputs.rows, layer_sizes->data.i[layer_sizes->cols-1], _inputs.type());
CvMat inputs = _inputs, outputs = _outputs;
return predict(&inputs, &outputs);
}
/* End of file. */
| 30.672637
| 114
| 0.525282
|
durai-chellamuthu
|
732b7c3ed5c7a2371f52b85be91110823a9b204f
| 961
|
cpp
|
C++
|
Data_Structures/LinkedList/Merge_two_sorted_lists/mergeLists.cpp
|
edinapap/DSA-Library
|
586adf2e0bf4eb9a4ece295bb27d87f8ce7f6bce
|
[
"MIT"
] | 30
|
2020-10-08T17:44:47.000Z
|
2022-03-23T18:05:06.000Z
|
Data_Structures/LinkedList/Merge_two_sorted_lists/mergeLists.cpp
|
edinapap/DSA-Library
|
586adf2e0bf4eb9a4ece295bb27d87f8ce7f6bce
|
[
"MIT"
] | 118
|
2020-10-08T04:29:44.000Z
|
2021-12-10T06:22:26.000Z
|
Data_Structures/LinkedList/Merge_two_sorted_lists/mergeLists.cpp
|
edinapap/DSA-Library
|
586adf2e0bf4eb9a4ece295bb27d87f8ce7f6bce
|
[
"MIT"
] | 125
|
2020-10-08T04:34:19.000Z
|
2022-03-30T19:16:27.000Z
|
//Problem Link: https://practice.geeksforgeeks.org/problems/merge-two-sorted-linked-lists/1
/* Link list Node
struct Node {
int data;
struct Node *next;
Node(int x) {
data = x;
next = NULL;
}
};
*/
Node* sortedMerge(Node* h1, Node* h2)
{
Node* h3 = NULL;
Node* last = NULL;
if(h1->data < h2->data)
{
last = h3 = h1;
h1 = h1->next;
h3->next = NULL;
}
else{
last = h3 = h2;
h2 = h2->next;
h3->next = NULL;
}
while(h1!=NULL && h2!=NULL)
{
if(h1->data < h2->data)
{
last->next = h1;
last = h1;
h1 = h1->next;
last->next = NULL;
}
else
{
last->next = h2;
last = h2;
h2 = h2->next;
last->next = NULL;
}
}
if(h1)
last->next = h1;
else
last->next = h2;
return h3;
}
| 17.160714
| 91
| 0.416233
|
edinapap
|
732d7fb51c8b50ec5af805bb6831d3ce0aaf348a
| 8,977
|
hpp
|
C++
|
Libraries/Zilch/Project/Zilch/Any.hpp
|
jodavis42/ZilchShaders
|
a161323165c54d2824fe184f5d540e0a008b4d59
|
[
"MIT"
] | 1
|
2019-08-31T00:45:45.000Z
|
2019-08-31T00:45:45.000Z
|
Libraries/Zilch/Project/Zilch/Any.hpp
|
jodavis42/ZilchShaders
|
a161323165c54d2824fe184f5d540e0a008b4d59
|
[
"MIT"
] | 5
|
2020-04-13T00:17:11.000Z
|
2021-04-20T23:11:42.000Z
|
Libraries/Zilch/Project/Zilch/Any.hpp
|
jodavis42/ZilchShaders
|
a161323165c54d2824fe184f5d540e0a008b4d59
|
[
"MIT"
] | null | null | null |
/**************************************************************\
* Author: Trevor Sundberg
* Copyright 2016, DigiPen Institute of Technology
\**************************************************************/
#pragma once
#ifndef ZILCH_ANY_HPP
#define ZILCH_ANY_HPP
namespace Zilch
{
// Returns an invalid type that is zeroed out (only used for not-crashing after an assert)
// This places no requirement on default construction or copy construction
template <typename T>
T& GetInvalid()
{
// Remove the reference qualifier if it has one
typedef typename Zero::Decay<T>::Type TNonReference;
static byte InvalidBuffer[sizeof(TNonReference)] = { 0 };
// Clear out the buffer every time we request it
memset(InvalidBuffer, 0, sizeof(InvalidBuffer));
// Cast the buffer into a pointer then into a reference of the requested type
return *(TNonReference*)InvalidBuffer;
}
// Stores any type of object (handles, delegates, or even value types)
class Any
{
public:
// Constructor that initializes the Any to null (a handle, set to NullType)
Any();
Any(nullptr_t);
Any(Zero::MoveReference<Any> rhs)
{
Error("Not implemented.");
}
template <typename T>
Any(const T& value, ExecutableState* state = nullptr, P_DISABLE_IF((Zero::is_base_of<Type, typename Zero::remove_pointer<typename Zero::remove_const_and_volatile<T>::type>::type>::value)))
{
typedef typename TypeBinding::StripQualifiers<T>::Type UnqualifiedType;
const UnqualifiedType* pointer = TypeBinding::ReferenceCast<T&, const UnqualifiedType*>::Cast((T&)value);
BoundType* type = ZilchVirtualTypeId(pointer);
type->IsInitializedAssert();
ZilchTypeId(T)->IsInitializedAssert();
// Get how big the copyable size of the object is (size of a handle, or the entire value size)
size_t copyableSize = type->GetCopyableSize();
// Allocate room to store this type (may store locally and not actually allocate)
byte* destination = this->AllocateData(copyableSize);
// Store the type and copy construct the data into us
this->StoredType = type;
// If the type is a reference type... (this is always a handle)
if (type->CopyMode == TypeCopyMode::ReferenceType)
{
if (state == nullptr)
state = ExecutableState::CallingState;
InternalWriteRef<T>(value, destination, state);
}
// Otherwise it must be a value type...
else
{
InternalWriteValue<T>(value, destination);
}
}
Any(cstr value, ExecutableState* state = nullptr) : Any(String(value), state)
{
}
template <typename T>
T Get(GetOptions::Enum options = GetOptions::ReturnDefaultOrNull) const
{
if (this->StoredType == nullptr)
{
ErrorIf(options == GetOptions::AssertOnNull,
"The value inside the Any was null");
return GetInvalid<T>();
}
// Check if we can directly convert the stored type into the requested type
// This supports derived -> base class casting (but not visa versa), enums to integers, etc
BoundType* toType = ZilchTypeId(T);
if (this->StoredType->IsRawCastableTo(toType) == false)
{
ErrorIf(options == GetOptions::AssertOnNull,
"There was a value inside the Any of type '%s' but it cannot be converted to '%s'",
this->StoredType->ToString().c_str(),
toType->Name.c_str());
return GetInvalid<T>();
}
byte* data = (byte*)this->GetData();
// If the type is a reference type... (this is always a handle)
if (toType->CopyMode == TypeCopyMode::ReferenceType)
{
return InternalReadRef<T>(data);
}
// Otherwise it must be a value type...
else
{
return InternalReadValue<T>(data);
}
}
template <typename T>
bool Is() const
{
BoundType* checkType = ZilchTypeId(T);
return this->StoredType->IsRawCastableTo(checkType);
}
// Copying will properly reference count handles, delegates this handle, and memcpy value types
Any(const Any& other);
// Creates an any from a handle and reference counts
Any(const Handle& other);
// Creates an any from a delegate and reference counts
Any(const Delegate& other);
// Constructor that initializes to the given data and type (the data is copied in using GenericCopyConstruct)
Any(const byte* data, Type* type);
// Construct a default instance of a particular type (equivalent of default(T))
explicit Any(Type* type);
// Destructor that decrements reference counts and properly handles stored data
~Any();
// Copying will properly reference count handles, delegates this handle, and memcpy value types
Any& operator=(const Any& rhs);
// Checks if the internal handle/delegate/value is the same
bool operator==(const Any& rhs) const;
bool operator==(Zero::NullPointerType) const;
// Checks if the internal handle/delegate/value is the different
bool operator!=(const Any& rhs) const;
bool operator!=(Zero::NullPointerType) const;
// Hashes a handle (generally used by hashable containers)
size_t Hash() const;
// Checks if the any itself is holding no value, or if the value stored within the any
// is null. This specifically checks Handles and Delegates for a null value
bool IsNull() const;
bool IsNotNull() const;
// Converts the internal value to string (used for debugging)
String ToString() const;
// Converts the internal value to a Handle. If it does not store a handle type, it will
// return an empty Handle.
Handle ToHandle() const;
// If the type stored internally is a Handle then this will invoke Dereference on the handle
// Otherwise this will return the same value as GetData
byte* Dereference() const;
// Destruct any data stored by the any
// This also clears the entire any out to zero
void Clear();
// Allocates data if the size goes past the sizeof(this->Data), or returns a pointer to this->Data
byte* AllocateData(size_t size);
// Get the raw type data that we point at (may be our internal Data, or may be allocated)
const byte* GetData() const;
// Much like the copy constructor or assignment of an any, except it avoids
// creating an extra 'any' in cases where we just have the memory and the type
void AssignFrom(const byte* data, Type* type);
// Replaces our stored definition with a default constructed version of the given type (equivalent of default(T))
// Typically makes handles null, delegates null, and value types cleared to 0
void DefaultConstruct(Type* type);
// Generically copies the value of this any to another location
// This will NOT copy the 'Any' but rather the stored type
// Make sure the size and type of destination matches!
void CopyStoredValueTo(byte* to) const;
// Checks if the any is currently holding a value
// Note that the value MAY be null, which is still technically a value stored within the any
// If you wish to check for null for various stored types, use IsNull
bool IsHoldingValue() const;
public:
// We want to store the largest type (the delegate, handle, etc)
// The delegate stores the handle, so we know delegate is the biggest
// If the size of the type is bigger then can fit here, then we allocate a pointer instead
byte Data[sizeof(Delegate)];
// The type that we're storing inside the data
Type* StoredType;
};
// Type defines for ease of use
typedef const Any& AnyParam;
// Given a type we know natively, return a value pointed at by a data pointer
// If the data is not given, this will default construct the type
// This is specialized by the Any type to return an Any that encapsulates the value
template <typename T>
T CopyToAnyOrActualType(byte* data, Type* dataType)
{
// If no data was provided, then return the default value for T
if (data == nullptr)
{
// Not all primitive constructors zero out the memory, so do that first
byte memory[sizeof(T)] = {0};
new (memory) T();
return *(T*)memory;
}
// Otherwise just cast data into the T type
return *(T*)data;
}
// Specialization for the Any type, which will copy the value into an Any
template <>
Any CopyToAnyOrActualType<Any>(byte* data, Type* dataType);
// Given a type we know natively, just directly copy it to a location
// This is specialized by the Any type to only copy its inner value
template <typename T>
ZeroSharedTemplate void CopyFromAnyOrActualType(const T& value, byte* to)
{
// Just directly construct the value
new (to) T(value);
}
// Specialization for the Any type, which will copy the value out of an Any
template <>
void CopyFromAnyOrActualType<Any>(const Any& any, byte* to);
}
#endif
| 35.908
| 192
| 0.670046
|
jodavis42
|
7330dd63e2b69917be0dd1c24436232566860819
| 4,509
|
cpp
|
C++
|
src/geometric/bounding_box.cpp
|
mapbox/nepomuk
|
8771482edb9b16bb0f5a152c15681c57eb3bb6b6
|
[
"MIT"
] | 22
|
2017-05-12T11:52:26.000Z
|
2021-12-06T06:05:08.000Z
|
src/geometric/bounding_box.cpp
|
mapbox/nepomuk
|
8771482edb9b16bb0f5a152c15681c57eb3bb6b6
|
[
"MIT"
] | 49
|
2017-05-11T16:13:58.000Z
|
2017-12-13T11:19:17.000Z
|
src/geometric/bounding_box.cpp
|
mapbox/nepomuk
|
8771482edb9b16bb0f5a152c15681c57eb3bb6b6
|
[
"MIT"
] | 7
|
2017-11-19T12:04:26.000Z
|
2021-12-06T06:14:25.000Z
|
#include "geometric/bounding_box.hpp"
#include <algorithm>
#include <cmath> // for atan, exp
#include <type_traits> // for move, swap
#include <boost/math/constants/constants.hpp>
namespace nepomuk
{
namespace geometric
{
WGS84BoundingBox::WGS84BoundingBox(WGS84Coordinate lower_left, WGS84Coordinate upper_right)
: lower_left(std::move(lower_left)), upper_right(std::move(upper_right))
{
}
WGS84BoundingBox::WGS84BoundingBox(std::uint32_t const horizontal,
std::uint32_t const vertical,
std::uint32_t const zoom_level,
double const tile_size,
std::int32_t const mercator_buffer)
{
double min_lon = horizontal * tile_size - mercator_buffer;
double max_lon = (horizontal + 1.0) * tile_size + mercator_buffer;
double min_lat = (vertical + 1.0) * tile_size + mercator_buffer;
double max_lat = vertical * tile_size - mercator_buffer;
// 2^z * TILE_SIZE
const double shift = (1u << static_cast<unsigned>(zoom_level)) * tile_size;
auto const shift_lon = [shift](double const lon) {
return (lon - 0.5 * shift) / shift * 360.0;
};
auto const shift_lat = [shift](double const lat) {
auto const tmp =
boost::math::constants::pi<double>() * constants::rad_to_degree * (1 - 2 * lat / shift);
auto const clamped = std::max<long double>(-180., std::min<long double>(180., tmp));
auto const normalized =
constants::rad_to_degree * 2. * std::atan(std::exp(clamped * constants::degree_to_rad));
return normalized - 90.;
};
min_lon = shift_lon(min_lon);
max_lon = shift_lon(max_lon);
min_lat = shift_lat(min_lat);
max_lat = shift_lat(max_lat);
lower_left = WGS84Coordinate(makeLatLonFromDouble<FixedLongitude>(min_lon),
makeLatLonFromDouble<FixedLatitude>(min_lat));
upper_right = WGS84Coordinate(makeLatLonFromDouble<FixedLongitude>(max_lon),
makeLatLonFromDouble<FixedLatitude>(max_lat));
}
bool WGS84BoundingBox::contains(WGS84Coordinate const &coordinate) const
{
return lower_left.longitude <= coordinate.longitude &&
coordinate.longitude <= upper_right.longitude &&
lower_left.latitude <= coordinate.latitude &&
coordinate.latitude <= upper_right.latitude;
}
double WGS84BoundingBox::width() const
{
return doubleFromLatLon(upper_right.longitude) - doubleFromLatLon(lower_left.longitude);
}
double WGS84BoundingBox::height() const
{
return doubleFromLatLon(upper_right.latitude) - doubleFromLatLon(lower_left.latitude);
}
MercatorBoundingBox::MercatorBoundingBox(MercatorCoordinate lower_left_,
MercatorCoordinate upper_right_)
: lower_left(lower_left_), upper_right(upper_right_)
{
// mercator transformations switch invert latitude (counting from upper right). If the
// coordinates don't match up (e.g. due to conversion issues) we need to swap them to the
// correct order
if (lower_left.latitude > upper_right.latitude)
std::swap(lower_left.latitude, upper_right.latitude);
}
MercatorBoundingBox::MercatorBoundingBox(std::uint32_t const horizontal,
std::uint32_t const vertical,
std::uint32_t const zoom_level,
double const tile_size,
std::int32_t const mercator_buffer)
{
WGS84BoundingBox bbox(horizontal, vertical, zoom_level, tile_size, mercator_buffer);
lower_left = MercatorCoordinate(bbox.lower_left);
upper_right = MercatorCoordinate(bbox.upper_right);
std::swap(lower_left.latitude, upper_right.latitude);
}
bool MercatorBoundingBox::contains(MercatorCoordinate const &coordinate) const
{
return lower_left.longitude <= coordinate.longitude &&
coordinate.longitude <= upper_right.longitude &&
lower_left.latitude <= coordinate.latitude &&
coordinate.latitude <= upper_right.latitude;
}
double MercatorBoundingBox::width() const
{
return doubleFromLatLon(upper_right.longitude) - doubleFromLatLon(lower_left.longitude);
}
double MercatorBoundingBox::height() const
{
return doubleFromLatLon(upper_right.latitude) - doubleFromLatLon(lower_left.latitude);
}
} // namespace geometric
} // namespace nepomuk
| 37.575
| 100
| 0.667554
|
mapbox
|
73310779d3c6123b480f17b97154b7eca5a24326
| 1,977
|
cpp
|
C++
|
spoj/classical/is_it_a_tree.cpp
|
Rkhoiwal/Competitive-prog-Archive
|
18a95a8b2b9ca1a28d6fe939c1db5450d541ddc9
|
[
"MIT"
] | null | null | null |
spoj/classical/is_it_a_tree.cpp
|
Rkhoiwal/Competitive-prog-Archive
|
18a95a8b2b9ca1a28d6fe939c1db5450d541ddc9
|
[
"MIT"
] | null | null | null |
spoj/classical/is_it_a_tree.cpp
|
Rkhoiwal/Competitive-prog-Archive
|
18a95a8b2b9ca1a28d6fe939c1db5450d541ddc9
|
[
"MIT"
] | null | null | null |
#include <iostream>
#include <vector>
using namespace std;
inline
void use_io_optimizations()
{
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
}
class UnionFind
{
public:
UnionFind(unsigned int items):
components(items),
parents(items),
ranks(items)
{
for (unsigned int i {0}; i < components; ++i)
{
parents[i] = i;
}
}
void link(unsigned int item, unsigned int another_item)
{
auto root_i = find(item);
auto root_j = find(another_item);
if (root_i == root_j)
{
return;
}
if (ranks[root_i] < ranks[root_j])
{
parents[root_i] = root_j;
}
else
{
parents[root_j] = root_i;
if (ranks[root_i] == ranks[root_j])
{
++ranks[root_i];
}
}
--components;
}
unsigned int find(unsigned int item)
{
auto root = item;
while (root != parents[root])
{
root = parents[root];
}
while (item != root)
{
auto parent = parents[item];
parents[item] = root;
item = parent;
}
return root;
}
unsigned int size() const
{
return components;
}
private:
unsigned int components;
vector<unsigned int> parents;
vector<unsigned int> ranks;
};
int main()
{
use_io_optimizations();
unsigned int nodes;
unsigned int edges;
cin >> nodes >> edges;
UnionFind graph(nodes);
for (unsigned int i {0}; i < edges; ++i)
{
unsigned int source;
unsigned int destination;
cin >> source >> destination;
graph.link(source - 1, destination - 1);
}
if (nodes == edges + 1 && graph.size() == 1)
{
cout << "YES\n";
}
else
{
cout << "NO\n";
}
return 0;
}
| 16.754237
| 59
| 0.486596
|
Rkhoiwal
|
7331bc71b35fc7565e2f49b2c05132709eab4e38
| 237
|
hpp
|
C++
|
sdk/procmonsdk/logger.hpp
|
Syr0/openprocmon
|
2a4b7b9f5da97215fcb59354a2951a62a3aa41a7
|
[
"MIT"
] | 90
|
2020-07-28T06:44:56.000Z
|
2022-03-10T03:59:33.000Z
|
sdk/procmonsdk/logger.hpp
|
L4ys/openprocmon
|
44fb542922f31f9548739dc81d7a7269a564ea41
|
[
"MIT"
] | 4
|
2021-02-24T09:13:27.000Z
|
2022-01-18T08:44:52.000Z
|
sdk/procmonsdk/logger.hpp
|
L4ys/openprocmon
|
44fb542922f31f9548739dc81d7a7269a564ea41
|
[
"MIT"
] | 27
|
2020-07-28T06:49:22.000Z
|
2022-02-14T05:09:56.000Z
|
#pragma once
#include <windows.h>
typedef enum { L_DEBUG, L_INFO, L_WARN, L_ERROR } LEVEL, *PLEVEL;
//
// A quick logging routine for debug messages.
//
#define MAX_LOG_MESSAGE 1024
BOOL LogMessage(LEVEL Level, LPCTSTR Format, ...);
| 18.230769
| 65
| 0.721519
|
Syr0
|
7332011fd8ef0f0410b36e59d441bb91b8c0ed3b
| 4,415
|
cc
|
C++
|
src/sst/core/cfgoutput/dotConfigOutput.cc
|
gvoskuilen/sst-core
|
6fe68d7b2a0b306d78ca39e7a4a822f1582ca86e
|
[
"BSD-3-Clause"
] | null | null | null |
src/sst/core/cfgoutput/dotConfigOutput.cc
|
gvoskuilen/sst-core
|
6fe68d7b2a0b306d78ca39e7a4a822f1582ca86e
|
[
"BSD-3-Clause"
] | 10
|
2020-04-24T15:24:14.000Z
|
2020-11-07T20:41:07.000Z
|
src/sst/core/cfgoutput/dotConfigOutput.cc
|
gvoskuilen/sst-core
|
6fe68d7b2a0b306d78ca39e7a4a822f1582ca86e
|
[
"BSD-3-Clause"
] | 2
|
2021-08-17T19:36:15.000Z
|
2021-08-19T13:38:14.000Z
|
// Copyright 2009-2020 NTESS. Under the terms
// of Contract DE-NA0003525 with NTESS, the U.S.
// Government retains certain rights in this software.
//
// Copyright (c) 2009-2020, NTESS
// All rights reserved.
//
// This file is part of the SST software package. For license
// information, see the LICENSE file in the top level directory of the
// distribution.
//
#include "sst_config.h"
#include "dotConfigOutput.h"
#include "sst/core/configGraphOutput.h"
#include "sst/core/config.h"
using namespace SST::Core;
DotConfigGraphOutput::DotConfigGraphOutput(const char* path) :
ConfigGraphOutput(path) {
}
void DotConfigGraphOutput::generate(const Config* cfg, ConfigGraph* graph) {
if ( nullptr == outputFile ) {
throw ConfigGraphOutputException("Output file is not open for writing");
}
fprintf(outputFile, "graph \"connections\" {\noverlap=scale;\nsplines=spline;\n");
fprintf(outputFile, "node [shape=record];\ngraph [style=invis];\n\n");
const auto compMap = graph->getComponentMap();
const auto linkMap = graph->getLinkMap();
for ( auto compItr : compMap ) {
fprintf(outputFile, "subgraph cluster_%" PRIu64 " {\n", compItr.id);
generateDot( compItr, linkMap );
fprintf(outputFile, "}\n\n");
}
fprintf(outputFile, "\n");
for ( auto linkItr : linkMap ) {
generateDot( linkItr );
}
fprintf(outputFile, "\n}\n\n");
fprintf(outputFile, "graph \"sst_simulation\" {\noverlap=scale;\nsplines=spline;\n");
fprintf(outputFile, "newrank = true;\n");
fprintf(outputFile, "node [shape=record];\n");
// Find the maximum rank which is marked for the graph partitioning
for ( uint32_t r = 0; r < cfg->world_size.rank ; r++ ) {
fprintf(outputFile, "subgraph cluster_%u {\n", r);
fprintf(outputFile, "label=\"Rank %u\";\n", r);
for ( uint32_t t = 0 ; t < cfg->world_size.thread ; t++ ) {
fprintf(outputFile, "subgraph cluster_%u_%u {\n", r, t);
fprintf(outputFile, "label=\"Thread %u\";\n", t);
for ( auto compItr : compMap ) {
if ( compItr.rank.rank == r && compItr.rank.thread == t ) {
generateDot( compItr, linkMap );
}
}
fprintf(outputFile, "};\n");
}
fprintf(outputFile, "};\n");
}
fprintf(outputFile, "\n");
for ( auto linkItr = linkMap.begin(); linkItr != linkMap.end(); linkItr++ ) {
generateDot( *linkItr );
}
fprintf(outputFile, "\n}\n");
}
void DotConfigGraphOutput::generateDot(const ConfigComponent& comp, const ConfigLinkMap_t& linkMap) const {
fprintf(outputFile, "%" PRIu64 " [label=\"{<main> %s\\n%s", comp.id, comp.name.c_str(), comp.type.c_str());
int j = comp.links.size();
if(j != 0){
fprintf(outputFile, " |\n");
}
for(LinkId_t i : comp.links) {
const ConfigLink &link = linkMap[i];
const int port = (link.component[0] == comp.id) ? 0 : 1;
fprintf(outputFile, "<%s> Port: %s", link.port[port].c_str(), link.port[port].c_str());
if(j > 1){
fprintf(outputFile, " |\n");
}
j--;
}
fprintf(outputFile, "}\"];\n\n");
for ( auto &sc : comp.subComponents ) {
fprintf(outputFile, "%" PRIu64 " [color=gray,label=\"{<main> %s\\n%s", sc.id, sc.name.c_str(), sc.type.c_str());
j = sc.links.size();
if(j != 0){
fprintf(outputFile, " |\n");
}
for(LinkId_t i : sc.links) {
const ConfigLink &link = linkMap[i];
const int port = (link.component[0] == sc.id) ? 0 : 1;
fprintf(outputFile, "<%s> Port: %s", link.port[port].c_str(), link.port[port].c_str());
if(j > 1){
fprintf(outputFile, " |\n");
}
j--;
}
fprintf(outputFile, "}\"];\n");
fprintf(outputFile, "%" PRIu64 ":\"main\" -- %" PRIu64 ":\"main\" [style=dotted];\n\n", comp.id, sc.id);
}
}
void DotConfigGraphOutput::generateDot(const ConfigLink& link) const {
int minLatIdx = (link.latency[0] <= link.latency[1]) ? 0 : 1;
fprintf(outputFile, "%" PRIu64 ":\"%s\" -- %" PRIu64 ":\"%s\" [label=\"%s\\n%s\"]; \n",
link.component[0], link.port[0].c_str(),
link.component[1], link.port[1].c_str(),
link.name.c_str(),
link.latency_str[minLatIdx].c_str());
}
| 36.487603
| 120
| 0.577576
|
gvoskuilen
|
733724fd7e455677881e0464ad578dbc421f3ef6
| 1,523
|
hpp
|
C++
|
Classes/entity.hpp
|
mackness33/NoGravitar
|
ae0c4f1fc5567aa32584c8b48a2506cdea329ad1
|
[
"MIT"
] | null | null | null |
Classes/entity.hpp
|
mackness33/NoGravitar
|
ae0c4f1fc5567aa32584c8b48a2506cdea329ad1
|
[
"MIT"
] | null | null | null |
Classes/entity.hpp
|
mackness33/NoGravitar
|
ae0c4f1fc5567aa32584c8b48a2506cdea329ad1
|
[
"MIT"
] | null | null | null |
#ifndef ENTITY_H
#define ENTITY_H
#include <SFML/Window.hpp>
#include <SFML/System.hpp>
#include <SFML/Graphics.hpp>
#include <iostream>
#include "essence.hpp"
//this class handle static objects
template <class T> class entity : public essence<T>{
protected:
void setBoundery();
public:
//----------CONSTRUCTORS----------
entity();
entity(T* b);
entity(sf::Texture* image); //Sprite
entity(float radius, std::size_t pointCount = 30); //CircleShape
entity(const sf::Font &font, const std::string &string); //Text
entity(sf::Vector2f size, sf::Vector2f position = sf::Vector2f(0, 0), sf::Texture* image = nullptr); //RectangleShape
~entity();
//----------GETS----------
float GetRotation();
sf::Vector2f GetPosition();
sf::Vector2f GetOrigin();
//----------SETS----------
void setBody(T *b);
void SetPosition (float x, float y);
void SetPosition (const sf::Vector2f &position);
void SetRotation (float angle);
void SetScale (float factorX, float factorY);
void SetScale (const sf::Vector2f &factor);
void SetOrigin (float x, float y);
void SetOrigin (const sf::Vector2f &origin);
//----------METHODS------------
virtual std::string Class();
};
#include "entity.tpp"
#endif // ENTITY_H
| 28.735849
| 134
| 0.530532
|
mackness33
|
73394a30c9d65051b6f05a321260f387a2f93fcb
| 316
|
cc
|
C++
|
python/src/main.cc
|
jareddk/triton
|
ea03d6207728315312d9cb6fa014f6a394b79c71
|
[
"MIT"
] | null | null | null |
python/src/main.cc
|
jareddk/triton
|
ea03d6207728315312d9cb6fa014f6a394b79c71
|
[
"MIT"
] | null | null | null |
python/src/main.cc
|
jareddk/triton
|
ea03d6207728315312d9cb6fa014f6a394b79c71
|
[
"MIT"
] | null | null | null |
#include <pybind11/pybind11.h>
void init_superblocking(pybind11::module &m);
void init_torch_utils(pybind11::module &m);
void init_triton(pybind11::module &m);
PYBIND11_MODULE(libtriton, m) {
m.doc() = "Python bindings to the C++ Triton API";
init_triton(m);
init_torch_utils(m);
init_superblocking(m);
}
| 24.307692
| 52
| 0.734177
|
jareddk
|
733a9d52bd96985bf4be21d4aaa0a2d18e70ffa9
| 4,835
|
hpp
|
C++
|
Testbed/Tests/Tiles.hpp
|
louis-langholtz/Box2D
|
7c74792bf177cf36640d735de2bba0225bf7f852
|
[
"Zlib"
] | 32
|
2016-10-20T05:55:04.000Z
|
2021-11-25T16:34:41.000Z
|
Testbed/Tests/Tiles.hpp
|
louis-langholtz/Box2D
|
7c74792bf177cf36640d735de2bba0225bf7f852
|
[
"Zlib"
] | 50
|
2017-01-07T21:40:16.000Z
|
2018-01-31T10:04:05.000Z
|
Testbed/Tests/Tiles.hpp
|
louis-langholtz/Box2D
|
7c74792bf177cf36640d735de2bba0225bf7f852
|
[
"Zlib"
] | 7
|
2017-02-09T10:02:02.000Z
|
2020-07-23T22:49:04.000Z
|
/*
* Original work Copyright (c) 2006-2009 Erin Catto http://www.box2d.org
* Modified work Copyright (c) 2017 Louis Langholtz https://github.com/louis-langholtz/Box2D
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
* 3. This notice may not be removed or altered from any source distribution.
*/
#ifndef TILES_H
#define TILES_H
#include "../Framework/Test.hpp"
namespace box2d {
/// This stress tests the dynamic tree broad-phase. This also shows that tile
/// based collision is _not_ smooth due to Box2D not knowing about adjacency.
class Tiles : public Test
{
public:
enum
{
e_count = 20
};
Tiles()
{
m_fixtureCount = 0;
const auto start = std::chrono::high_resolution_clock::now();
{
const auto a = Real{0.5f};
BodyDef bd;
bd.position.y = -a * Meter;
const auto ground = m_world->CreateBody(bd);
const auto N = 200;
const auto M = 10;
Vec2 position;
position.y = 0.0f;
for (auto j = 0; j < M; ++j)
{
position.x = -N * a;
for (auto i = 0; i < N; ++i)
{
PolygonShape shape;
SetAsBox(shape, a * Meter, a * Meter, position * Meter, Angle{0});
ground->CreateFixture(std::make_shared<PolygonShape>(shape));
++m_fixtureCount;
position.x += 2.0f * a;
}
position.y -= 2.0f * a;
}
}
{
const auto a = Real{0.5f};
const auto shape = std::make_shared<PolygonShape>(a * Meter, a * Meter);
shape->SetDensity(Real{5} * KilogramPerSquareMeter);
Vec2 x(-7.0f, 0.75f);
Vec2 y;
const auto deltaX = Vec2(0.5625f, 1.25f);
const auto deltaY = Vec2(1.125f, 0.0f);
for (auto i = 0; i < e_count; ++i)
{
y = x;
for (auto j = i; j < e_count; ++j)
{
BodyDef bd;
bd.type = BodyType::Dynamic;
bd.position = y * Meter;
const auto body = m_world->CreateBody(bd);
body->CreateFixture(shape);
++m_fixtureCount;
y += deltaY;
}
x += deltaX;
}
}
const auto end = std::chrono::high_resolution_clock::now();
const auto elapsed_secs = std::chrono::duration<Real>{end - start};
m_createTime = elapsed_secs.count();
}
void PostStep(const Settings&, Drawer& drawer) override
{
const auto height = m_world->GetTreeHeight();
const auto leafCount = m_world->GetProxyCount();
if (leafCount > 0)
{
const auto minimumNodeCount = 2 * leafCount - 1;
const auto minimumHeight = ceilf(logf(float(minimumNodeCount)) / logf(2.0f));
drawer.DrawString(5, m_textLine, "dynamic tree height = %d, min = %d",
height, int(minimumHeight));
m_textLine += DRAW_STRING_NEW_LINE;
}
drawer.DrawString(5, m_textLine, "create time = %6.2f ms, fixture count = %d",
static_cast<double>(m_createTime * Real(1000)), m_fixtureCount);
m_textLine += DRAW_STRING_NEW_LINE;
//DynamicTree* tree = &m_world->m_contactManager.m_broadPhase.m_tree;
//if (GetStepCount() == 400)
//{
// tree->RebuildBottomUp();
//}
}
void KeyboardDown(Key key) override
{
switch (key)
{
case Key_C:
m_snapshot = *m_world;
break;
case Key_Backspace:
if (m_snapshot.GetBodies().size() > 0)
{
ResetWorld(m_snapshot);
}
break;
default:
break;
}
}
int m_fixtureCount;
Real m_createTime;
World m_snapshot;
};
} // namespace box2d
#endif
| 31.601307
| 91
| 0.543123
|
louis-langholtz
|
733bc8cee3fc21b6dd27ea32daf1a64358b6eb66
| 23,145
|
cpp
|
C++
|
Pod/Classes/algorithms/extractor/lowlevelspectralextractor.cpp
|
jbloit/iosEssentia
|
785ba29e8178942b396575dd3872bdf3d5d63cd5
|
[
"MIT"
] | null | null | null |
Pod/Classes/algorithms/extractor/lowlevelspectralextractor.cpp
|
jbloit/iosEssentia
|
785ba29e8178942b396575dd3872bdf3d5d63cd5
|
[
"MIT"
] | null | null | null |
Pod/Classes/algorithms/extractor/lowlevelspectralextractor.cpp
|
jbloit/iosEssentia
|
785ba29e8178942b396575dd3872bdf3d5d63cd5
|
[
"MIT"
] | null | null | null |
/*
* Copyright (C) 2006-2013 Music Technology Group - Universitat Pompeu Fabra
*
* This file is part of Essentia
*
* Essentia is free software: you can redistribute it and/or modify it under
* the terms of the GNU Affero General Public License as published by the Free
* Software Foundation (FSF), 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 Affero GNU General Public License
* version 3 along with this program. If not, see http://www.gnu.org/licenses/
*/
#include "lowlevelspectralextractor.h"
#include "algorithmfactory.h"
#include "essentiamath.h"
#include "poolstorage.h"
#include "copy.h"
using namespace std;
using namespace essentia;
using namespace essentia::streaming;
const char* LowLevelSpectralExtractor::name = "LowLevelSpectralExtractor";
const char* LowLevelSpectralExtractor::description = DOC("This algorithm extracts all low level spectral features, which do not require an equal-loudness filter for their computation, from an audio signal");
LowLevelSpectralExtractor::LowLevelSpectralExtractor() : _configured(false) {
// input:
declareInput(_signal, "signal", "the input audio signal");
// outputs:
declareOutput(_bbands, "barkbands", "spectral energy at each bark band. See BarkBands alogithm");
declareOutput(_bbandsKurtosis, "barkbands_kurtosis", "kurtosis from bark bands. See DistributionShape algorithm documentation");
declareOutput(_bbandsSkewness, "barkbands_skewness", "skewness from bark bands. See DistributionShape algorithm documentation");
declareOutput(_bbandsSpread, "barkbands_spread", "spread from barkbands. See DistributionShape algorithm documentation");
declareOutput(_hfcValue, "hfc", "See HFC algorithm documentation");
declareOutput(_mfccs, "mfcc", "See MFCC algorithm documentation");
declareOutput(_pitchValue, "pitch", "See PitchYinFFT algorithm documentation");
declareOutput(_pitchConfidence, "pitch_instantaneous_confidence", "See PitchYinFFT algorithm documentation");
declareOutput(_pitchSalienceValue, "pitch_salience", "See PitchSalience algorithm documentation");
declareOutput(_silence20, "silence_rate_20dB", "See SilenceRate algorithm documentation");
declareOutput(_silence30, "silence_rate_30dB", "See SilenceRate algorithm documentation");
declareOutput(_silence60, "silence_rate_60dB", "See SilenceRate algorithm documentation");
declareOutput(_spectralComplexityValue, "spectral_complexity", "See Spectral algorithm documentation");
declareOutput(_crestValue, "spectral_crest", "See Crest algorithm documentation");
declareOutput(_decreaseValue, "spectral_decrease", "See Decrease algorithm documentation");
declareOutput(_energyValue, "spectral_energy", "See Energy algorithm documentation");
declareOutput(_ebandLow, "spectral_energyband_low", "Energy in band (20,150] Hz. See EnergyBand algorithm documentation");
declareOutput(_ebandMidLow, "spectral_energyband_middle_low", "Energy in band (150,800] Hz.See EnergyBand algorithm documentation");
declareOutput(_ebandMidHigh, "spectral_energyband_middle_high", "Energy in band (800,4000] Hz. See EnergyBand algorithm documentation");
declareOutput(_ebandHigh, "spectral_energyband_high", "Energy in band (4000,20000] Hz. See EnergyBand algorithm documentation");
declareOutput(_flatness, "spectral_flatness_db", "See flatnessDB algorithm documentation");
declareOutput(_fluxValue, "spectral_flux", "See Flux algorithm documentation");
declareOutput(_rmsValue, "spectral_rms", "See RMS algorithm documentation");
declareOutput(_rolloffValue, "spectral_rolloff", "See RollOff algorithm documentation");
declareOutput(_strongPeakValue, "spectral_strongpeak", "See StrongPeak algorithm documentation");
declareOutput(_zeroCrossingRate, "zerocrossingrate", "See ZeroCrossingRate algorithm documentation");
// sfx:
declareOutput(_inharmonicityValue, "inharmonicity", "See Inharmonicity algorithm documentation");
declareOutput(_tristimulusValue, "tristimulus", "See Tristimulus algorithm documentation");
declareOutput(_odd2even, "oddtoevenharmonicenergyratio", "See OddToEvenHarmonicEnergyRatio algorithm documentation");
// create network (instantiate algorithms)
createInnerNetwork();
// wire all this up!
// connections:
_signal >> _frameCutter->input("signal");
// connecting temporal descriptors
_frameCutter->output("frame") >> _silenceRate->input("frame");
_silenceRate->output("threshold_0") >> _silence20;
_silenceRate->output("threshold_1") >> _silence30;
_silenceRate->output("threshold_2") >> _silence60;
_frameCutter->output("frame") >> _zcr->input("signal");
_zcr->output("zeroCrossingRate") >> _zeroCrossingRate;
// connecting spectral descriptors
_frameCutter->output("frame") >> _windowing->input("frame");
_windowing->output("frame") >> _spectrum->input("frame");
_spectrum->output("spectrum") >> _mfcc->input("spectrum");
_mfcc->output("mfcc") >> _mfccs;
_mfcc->output("bands") >> NOWHERE;
_spectrum->output("spectrum") >> _energy->input("array");
_spectrum->output("spectrum") >> _energyBand_0->input("spectrum");
_spectrum->output("spectrum") >> _energyBand_1->input("spectrum");
_spectrum->output("spectrum") >> _energyBand_2->input("spectrum");
_spectrum->output("spectrum") >> _energyBand_3->input("spectrum");
_energy->output("energy") >> _energyValue;
_energyBand_0->output("energyBand") >> _ebandLow;
_energyBand_1->output("energyBand") >> _ebandMidLow;
_energyBand_2->output("energyBand") >> _ebandMidHigh;
_energyBand_3->output("energyBand") >> _ebandHigh;
_spectrum->output("spectrum") >> _hfc->input("spectrum");
_hfc->output("hfc") >> _hfcValue;
_spectrum->output("spectrum") >> _rms->input("array");
_rms->output("rms") >> _rmsValue;
_spectrum->output("spectrum") >> _flux->input("spectrum");
_flux->output("flux") >> _fluxValue;
_spectrum->output("spectrum") >> _rollOff->input("spectrum");
_rollOff->output("rollOff") >> _rolloffValue;
_spectrum->output("spectrum") >> _strongPeak->input("spectrum");
_strongPeak->output("strongPeak") >> _strongPeakValue;
_spectrum->output("spectrum") >> _square->input("array");
_square->output("array") >> _decrease->input("array");
_spectrum->output("spectrum") >> _spectralComplexity->input("spectrum");
_spectralComplexity->output("spectralComplexity") >> _spectralComplexityValue;
_spectrum->output("spectrum") >> _pitchDetection->input("spectrum");
_pitchDetection->output("pitch") >> _pitchValue;
_pitchDetection->output("pitchConfidence") >> _pitchConfidence;
_spectrum->output("spectrum") >> _pitchSalience->input("spectrum");
_pitchSalience->output("pitchSalience") >> _pitchSalienceValue;
_spectrum->output("spectrum") >> _barkBands->input("spectrum");
_barkBands->output("bands") >> _bbands;
_barkBands->output("bands") >> _crest->input("array");
_barkBands->output("bands") >> _flatnessdb->input("array");
_barkBands->output("bands") >> _centralMoments->input("array");
_crest->output("crest") >> _crestValue;
_decrease->output("decrease") >> _decreaseValue;
_flatnessdb->output("flatnessDB") >> _flatness;
_centralMoments->output("centralMoments") >> _distributionShape->input("centralMoments");
_distributionShape->output("kurtosis") >> _bbandsKurtosis;
_distributionShape->output("skewness") >> _bbandsSkewness;
_distributionShape->output("spread") >> _bbandsSpread;
// sfx:
_pitchDetection->output("pitch") >> _harmonicPeaks->input("pitch");
_spectrum->output("spectrum") >> _spectralPeaks->input("spectrum");
_spectralPeaks->output("frequencies") >> _harmonicPeaks->input("frequencies");
_spectralPeaks->output("magnitudes") >> _harmonicPeaks->input("magnitudes");
_harmonicPeaks->output("harmonicMagnitudes") >> _tristimulus->input("magnitudes");
_harmonicPeaks->output("harmonicFrequencies") >> _tristimulus->input("frequencies");
_harmonicPeaks->output("harmonicMagnitudes") >> _oddToEvenHarmonicEnergyRatio->input("magnitudes");
_harmonicPeaks->output("harmonicFrequencies") >> _oddToEvenHarmonicEnergyRatio->input("frequencies");
_harmonicPeaks->output("harmonicMagnitudes") >> _inharmonicity->input("magnitudes");
_harmonicPeaks->output("harmonicFrequencies") >> _inharmonicity->input("frequencies");
_inharmonicity->output("inharmonicity") >> _inharmonicityValue;
_tristimulus->output("tristimulus") >> _tristimulusValue;
_oddToEvenHarmonicEnergyRatio->output("oddToEvenHarmonicEnergyRatio") >> _odd2even;
_network = new scheduler::Network(_frameCutter);
}
void LowLevelSpectralExtractor::createInnerNetwork() {
AlgorithmFactory& factory = AlgorithmFactory::instance();
_barkBands = factory.create("BarkBands",
"numberBands", 27);
_centralMoments = factory.create("CentralMoments",
"range", 26);
_crest = factory.create("Crest");
_decrease = factory.create("Decrease");
_distributionShape = factory.create("DistributionShape");
_energyBand_0 = factory.create("EnergyBand",
"startCutoffFrequency", 20, "stopCutoffFrequency", 150);
_energyBand_1 = factory.create("EnergyBand",
"startCutoffFrequency", 150, "stopCutoffFrequency", 800);
_energyBand_2 = factory.create("EnergyBand",
"startCutoffFrequency", 800, "stopCutoffFrequency", 4000);
_energyBand_3 = factory.create("EnergyBand",
"startCutoffFrequency", 4000, "stopCutoffFrequency", 20000);
_energy = factory.create("Energy");
_flatnessdb = factory.create("FlatnessDB");
_flux = factory.create("Flux");
_frameCutter = factory.create("FrameCutter");
_hfc = factory.create("HFC");
_harmonicPeaks = factory.create("HarmonicPeaks");
_inharmonicity = factory.create("Inharmonicity");
_mfcc = factory.create("MFCC");
_oddToEvenHarmonicEnergyRatio = factory.create("OddToEvenHarmonicEnergyRatio");
_pitchDetection = factory.create("PitchYinFFT");
_pitchSalience = factory.create("PitchSalience");
_rms = factory.create("RMS");
_rollOff = factory.create("RollOff");
_silenceRate = factory.create("SilenceRate");
_spectralComplexity = factory.create("SpectralComplexity",
"magnitudeThreshold", 0.005);
_spectralPeaks = factory.create("SpectralPeaks");
_spectrum = factory.create("Spectrum");
_strongPeak = factory.create("StrongPeak");
_tristimulus = factory.create("Tristimulus");
_square = factory.create("UnaryOperator",
"type", "square");
_windowing = factory.create("Windowing",
"type", "blackmanharris62");
_zcr = factory.create("ZeroCrossingRate");
Real thresholds_dB[] = { -20, -30, -60 };
vector<Real> thresholds(ARRAY_SIZE(thresholds_dB));
for (int i=0; i<(int)thresholds.size(); i++) {
thresholds[i] = db2lin(thresholds_dB[i]/2.0);
}
_silenceRate->configure("thresholds", thresholds);
}
void LowLevelSpectralExtractor::configure() {
int frameSize = parameter("frameSize").toInt();
int hopSize = parameter("hopSize").toInt();
Real sampleRate = parameter("sampleRate").toReal();
_decrease->configure("range", 0.5 * sampleRate);
_frameCutter->configure("silentFrames", "noise", "hopSize", hopSize, "frameSize", frameSize);
_pitchDetection->configure("frameSize", frameSize);
_spectralPeaks->configure("orderBy", "frequency", "minFrequency", sampleRate/Real(frameSize));
}
LowLevelSpectralExtractor::~LowLevelSpectralExtractor() {
clearAlgos();
}
void LowLevelSpectralExtractor::clearAlgos() {
if (!_configured) return;
delete _network;
}
namespace essentia {
namespace standard {
const char* LowLevelSpectralExtractor::name = "LowLevelSpectralExtractor";
const char* LowLevelSpectralExtractor::description = DOC("This algorithm extracts all low level spectral features from an audio signal");
LowLevelSpectralExtractor::LowLevelSpectralExtractor() {
declareInput(_signal, "signal", "the audio input signal");
declareOutput(_barkBands, "barkbands", "spectral energy at each bark band. See BarkBands alogithm");
declareOutput(_kurtosis, "barkbands_kurtosis", "kurtosis from bark bands. See DistributionShape algorithm documentation");
declareOutput(_skewness, "barkbands_skewness", "skewness from bark bands. See DistributionShape algorithm documentation");
declareOutput(_spread, "barkbands_spread", "spread from barkbands. See DistributionShape algorithm documentation");
declareOutput(_hfc, "hfc", "See HFC algorithm documentation");
declareOutput(_mfcc, "mfcc", "See MFCC algorithm documentation");
declareOutput(_pitch, "pitch", "See PitchYinFFT algorithm documentation");
declareOutput(_pitchConfidence, "pitch_instantaneous_confidence", "See PitchYinFFT algorithm documentation");
declareOutput(_pitchSalience, "pitch_salience", "See PitchSalience algorithm documentation");
declareOutput(_threshold_0, "silence_rate_20dB", "See SilenceRate algorithm documentation");
declareOutput(_threshold_1, "silence_rate_30dB", "See SilenceRate algorithm documentation");
declareOutput(_threshold_2, "silence_rate_60dB", "See SilenceRate algorithm documentation");
declareOutput(_spectralComplexity, "spectral_complexity", "See Spectral algorithm documentation");
declareOutput(_crest, "spectral_crest", "See Crest algorithm documentation");
declareOutput(_decrease, "spectral_decrease", "See Decrease algorithm documentation");
declareOutput(_energy, "spectral_energy", "See Energy algorithm documentation");
declareOutput(_energyBand_0, "spectral_energyband_low", "Energy in band (20,150] Hz. See EnergyBand algorithm documentation");
declareOutput(_energyBand_1, "spectral_energyband_middle_low", "Energy in band (150,800] Hz.See EnergyBand algorithm documentation");
declareOutput(_energyBand_2, "spectral_energyband_middle_high", "Energy in band (800,4000] Hz. See EnergyBand algorithm documentation");
declareOutput(_energyBand_3, "spectral_energyband_high", "Energy in band (4000,20000] Hz. See EnergyBand algorithm documentation");
declareOutput(_flatnessdb, "spectral_flatness_db", "See flatnessDB algorithm documentation");
declareOutput(_flux, "spectral_flux", "See Flux algorithm documentation");
declareOutput(_rms, "spectral_rms", "See RMS algorithm documentation");
declareOutput(_rollOff, "spectral_rolloff", "See RollOff algorithm documentation");
declareOutput(_strongPeak, "spectral_strongpeak", "See StrongPeak algorithm documentation");
declareOutput(_zeroCrossingRate, "zerocrossingrate", "See ZeroCrossingRate algorithm documentation");
// sfx:
declareOutput(_inharmonicity, "inharmonicity", "See Inharmonicity algorithm documentation");
declareOutput(_tristimulus, "tristimulus", "See Tristimulus algorithm documentation");
declareOutput(_oddToEvenHarmonicEnergyRatio, "oddtoevenharmonicenergyratio", "See OddToEvenHarmonicEnergyRatio algorithm documentation");
_lowLevelExtractor = streaming::AlgorithmFactory::create("LowLevelSpectralExtractor");
_vectorInput = new streaming::VectorInput<Real>();
createInnerNetwork();
}
LowLevelSpectralExtractor::~LowLevelSpectralExtractor() {
delete _network;
}
void LowLevelSpectralExtractor::reset() {
_network->reset();
}
void LowLevelSpectralExtractor::configure() {
_lowLevelExtractor->configure(INHERIT("frameSize"), INHERIT("hopSize"), INHERIT("sampleRate"));
}
void LowLevelSpectralExtractor::createInnerNetwork() {
streaming::connect(*_vectorInput, _lowLevelExtractor->input("signal"));
streaming::connect(_lowLevelExtractor->output("barkbands"), _pool, "barkbands");
streaming::connect(_lowLevelExtractor->output("barkbands_kurtosis"), _pool, "kurtosis");
streaming::connect(_lowLevelExtractor->output("barkbands_skewness"), _pool, "skewness");
streaming::connect(_lowLevelExtractor->output("barkbands_spread"), _pool, "spread");
streaming::connect(_lowLevelExtractor->output("hfc"), _pool, "hfc");
streaming::connect(_lowLevelExtractor->output("mfcc"), _pool, "mfcc");
streaming::connect(_lowLevelExtractor->output("pitch"), _pool, "pitch");
streaming::connect(_lowLevelExtractor->output("pitch_instantaneous_confidence"), _pool, "pitchConfidence");
streaming::connect(_lowLevelExtractor->output("pitch_salience"), _pool, "pitchSalience");
streaming::connect(_lowLevelExtractor->output("silence_rate_20dB"), _pool, "silence_rate_20dB");
streaming::connect(_lowLevelExtractor->output("silence_rate_30dB"), _pool, "silence_rate_30dB");
streaming::connect(_lowLevelExtractor->output("silence_rate_60dB"), _pool, "silence_rate_60dB");
streaming::connect(_lowLevelExtractor->output("spectral_complexity"), _pool, "spectralComplexity");
streaming::connect(_lowLevelExtractor->output("spectral_crest"), _pool, "crest");
streaming::connect(_lowLevelExtractor->output("spectral_decrease"), _pool, "decrease");
streaming::connect(_lowLevelExtractor->output("spectral_energy"), _pool, "energy");
streaming::connect(_lowLevelExtractor->output("spectral_energyband_low"), _pool, "energyBand_0");
streaming::connect(_lowLevelExtractor->output("spectral_energyband_middle_low"), _pool, "energyBand_1");
streaming::connect(_lowLevelExtractor->output("spectral_energyband_middle_high"), _pool, "energyBand_2");
streaming::connect(_lowLevelExtractor->output("spectral_energyband_high"), _pool, "energyBand_3");
streaming::connect(_lowLevelExtractor->output("spectral_flatness_db"), _pool, "flatnessdb");
streaming::connect(_lowLevelExtractor->output("spectral_flux"), _pool, "flux");
streaming::connect(_lowLevelExtractor->output("spectral_rms"), _pool, "rms");
streaming::connect(_lowLevelExtractor->output("spectral_rolloff"), _pool, "rollOff");
streaming::connect(_lowLevelExtractor->output("spectral_strongpeak"), _pool, "strongPeak");
streaming::connect(_lowLevelExtractor->output("zerocrossingrate"), _pool, "zeroCrossingRate");
streaming::connect(_lowLevelExtractor->output("inharmonicity"), _pool, "inharmonicity");
streaming::connect(_lowLevelExtractor->output("tristimulus"), _pool, "tristimulus");
streaming::connect(_lowLevelExtractor->output("oddtoevenharmonicenergyratio"), _pool, "oddToEvenHarmonicEnergyRatio");
_network = new scheduler::Network(_vectorInput);
}
void LowLevelSpectralExtractor::compute() {
const vector<Real>& signal = _signal.get();
_vectorInput->setVector(&signal);
_network->run();
vector<vector<Real> > & barkBands = _barkBands.get();
vector<Real> & kurtosis = _kurtosis.get();
vector<Real> & skewness = _skewness.get();
vector<Real> & spread = _spread.get();
vector<Real> & hfc = _hfc.get();
vector<vector<Real> > & mfcc = _mfcc.get();
vector<Real> & pitch = _pitch.get();
vector<Real> & pitchConfidence = _pitchConfidence.get();
vector<Real> & pitchSalience = _pitchSalience.get();
vector<Real> & threshold_0 = _threshold_0.get();
vector<Real> & threshold_1 = _threshold_1.get();
vector<Real> & threshold_2 = _threshold_2.get();
vector<Real> & spectralComplexity = _spectralComplexity.get();
vector<Real> & crest = _crest.get();
vector<Real> & decrease = _decrease.get();
vector<Real> & energy = _energy.get();
vector<Real> & energyBand_0 = _energyBand_0.get();
vector<Real> & energyBand_1 = _energyBand_1.get();
vector<Real> & energyBand_2 = _energyBand_2.get();
vector<Real> & energyBand_3 = _energyBand_3.get();
vector<Real> & flatnessdb = _flatnessdb.get();
vector<Real> & flux = _flux.get();
vector<Real> & rms = _rms.get();
vector<Real> & rollOff = _rollOff.get();
vector<Real> & strongPeak = _strongPeak.get();
vector<Real> & zeroCrossingRate = _zeroCrossingRate.get();
vector<Real> & inharmonicity = _inharmonicity.get();
vector<vector<Real> > & tristimulus = _tristimulus.get();
vector<Real> & oddToEvenHarmonicEnergyRatio = _oddToEvenHarmonicEnergyRatio.get();
barkBands = _pool.value<vector<vector<Real> > >("barkbands");
kurtosis = _pool.value<vector<Real> >("kurtosis");
skewness = _pool.value<vector<Real> >("skewness");
spread = _pool.value<vector<Real> >("spread");
hfc = _pool.value<vector<Real> >("hfc");
mfcc = _pool.value<vector<vector<Real> > >("mfcc");
pitch = _pool.value<vector<Real> >("pitch");
pitchConfidence = _pool.value<vector<Real> >("pitchConfidence");
pitchSalience = _pool.value<vector<Real> >("pitchSalience");
threshold_0 = _pool.value<vector<Real> >("silence_rate_20dB");
threshold_1 = _pool.value<vector<Real> >("silence_rate_30dB");
threshold_2 = _pool.value<vector<Real> >("silence_rate_60dB");
spectralComplexity = _pool.value<vector<Real> >("spectralComplexity");
crest = _pool.value<vector<Real> >("crest");
decrease = _pool.value<vector<Real> >("decrease");
energy = _pool.value<vector<Real> >("energy");
energyBand_0 = _pool.value<vector<Real> >("energyBand_0");
energyBand_1 = _pool.value<vector<Real> >("energyBand_1");
energyBand_2 = _pool.value<vector<Real> >("energyBand_2");
energyBand_3 = _pool.value<vector<Real> >("energyBand_3");
flatnessdb = _pool.value<vector<Real> >("flatnessdb");
flux = _pool.value<vector<Real> >("flux");
rms = _pool.value<vector<Real> >("rms");
rollOff = _pool.value<vector<Real> >("rollOff");
strongPeak = _pool.value<vector<Real> >("strongPeak");
zeroCrossingRate = _pool.value<vector<Real> >("zeroCrossingRate");
inharmonicity = _pool.value<vector<Real> >("inharmonicity");
tristimulus = _pool.value<vector<vector<Real> > >("tristimulus");
oddToEvenHarmonicEnergyRatio = _pool.value<vector<Real> >("oddToEvenHarmonicEnergyRatio");
}
} // namespace standard
} // namespace essentia
| 57.574627
| 207
| 0.710002
|
jbloit
|
733d49cacfda17ad19b7bd7918be73c1fd14a64f
| 5,647
|
cpp
|
C++
|
paddle/capi/Matrix.cpp
|
limeng357/Paddle
|
dbd25805c88c48998eb9dc0f4b2ca1fd46326482
|
[
"ECL-2.0",
"Apache-2.0"
] | 9
|
2017-12-04T02:58:01.000Z
|
2020-12-03T14:46:30.000Z
|
paddle/capi/Matrix.cpp
|
limeng357/Paddle
|
dbd25805c88c48998eb9dc0f4b2ca1fd46326482
|
[
"ECL-2.0",
"Apache-2.0"
] | 7
|
2017-12-05T20:29:08.000Z
|
2018-10-15T08:57:40.000Z
|
paddle/capi/Matrix.cpp
|
limeng357/Paddle
|
dbd25805c88c48998eb9dc0f4b2ca1fd46326482
|
[
"ECL-2.0",
"Apache-2.0"
] | 6
|
2018-03-19T22:38:46.000Z
|
2019-11-01T22:28:27.000Z
|
/* Copyright (c) 2016 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 "capi_private.h"
#include "hl_cuda.h"
#include "matrix.h"
#define cast(v) paddle::capi::cast<paddle::capi::CMatrix>(v)
extern "C" {
paddle_matrix paddle_matrix_create(uint64_t height,
uint64_t width,
bool useGpu) {
auto ptr = new paddle::capi::CMatrix();
ptr->mat = paddle::Matrix::create(height, width, false, useGpu);
return ptr;
}
paddle_matrix paddle_matrix_create_none() {
return new paddle::capi::CMatrix();
}
paddle_error paddle_matrix_destroy(paddle_matrix mat) {
if (mat == nullptr) return kPD_NULLPTR;
auto ptr = cast(mat);
delete ptr;
return kPD_NO_ERROR;
}
paddle_error paddle_matrix_set_row(paddle_matrix mat,
uint64_t rowID,
paddle_real* rowArray) {
if (mat == nullptr || rowArray == nullptr) return kPD_NULLPTR;
auto ptr = cast(mat);
if (ptr->mat == nullptr) return kPD_NULLPTR;
if (rowID >= ptr->mat->getHeight()) return kPD_OUT_OF_RANGE;
paddle::real* buf = ptr->mat->getRowBuf(rowID);
size_t width = ptr->mat->getWidth();
#ifdef PADDLE_WITH_CUDA
hl_memcpy(buf, rowArray, sizeof(paddle::real) * width);
#else
std::copy(rowArray, rowArray + width, buf);
#endif
return kPD_NO_ERROR;
}
PD_API paddle_error paddle_matrix_set_value(paddle_matrix mat,
paddle_real* value) {
if (mat == nullptr || value == nullptr) return kPD_NULLPTR;
auto ptr = cast(mat);
if (ptr->mat == nullptr) return kPD_NULLPTR;
paddle::real* buf = ptr->mat->getRowBuf(0);
size_t width = ptr->mat->getWidth();
size_t height = ptr->mat->getHeight();
if (ptr->mat->useGpu()) {
#ifdef PADDLE_WITH_CUDA
hl_memcpy(buf, value, sizeof(paddle::real) * width * height);
#else
return kPD_NOT_SUPPORTED;
#endif
} else {
std::copy(value, value + width * height, buf);
}
return kPD_NO_ERROR;
}
PD_API paddle_error paddle_matrix_get_value(paddle_matrix mat,
paddle_real* result) {
if (mat == nullptr || result == nullptr) return kPD_NULLPTR;
auto ptr = cast(mat);
if (ptr->mat == nullptr) return kPD_NULLPTR;
paddle::real* buf = ptr->mat->getRowBuf(0);
size_t width = ptr->mat->getWidth();
size_t height = ptr->mat->getHeight();
if (ptr->mat->useGpu()) {
#ifdef PADDLE_WITH_CUDA
hl_memcpy(result, buf, width * height * sizeof(paddle::real));
#else
return kPD_NOT_SUPPORTED;
#endif
} else {
std::copy(buf, buf + width * height, result);
}
return kPD_NO_ERROR;
}
paddle_error paddle_matrix_get_row(paddle_matrix mat,
uint64_t rowID,
paddle_real** rawRowBuffer) {
if (mat == nullptr) return kPD_NULLPTR;
auto ptr = cast(mat);
if (ptr->mat == nullptr) return kPD_NULLPTR;
if (rowID >= ptr->mat->getHeight()) return kPD_OUT_OF_RANGE;
*rawRowBuffer = ptr->mat->getRowBuf(rowID);
return kPD_NO_ERROR;
}
paddle_error paddle_matrix_get_shape(paddle_matrix mat,
uint64_t* height,
uint64_t* width) {
if (mat == nullptr || cast(mat)->mat == nullptr) return kPD_NULLPTR;
if (height != nullptr) {
*height = cast(mat)->mat->getHeight();
}
if (width != nullptr) {
*width = cast(mat)->mat->getWidth();
}
return kPD_NO_ERROR;
}
}
paddle_matrix paddle_matrix_create_sparse(
uint64_t height, uint64_t width, uint64_t nnz, bool isBinary, bool useGpu) {
#ifndef PADDLE_MOBILE_INFERENCE
auto ptr = new paddle::capi::CMatrix();
ptr->mat = paddle::Matrix::createSparseMatrix(
height,
width,
nnz,
isBinary ? paddle::NO_VALUE : paddle::FLOAT_VALUE,
paddle::SPARSE_CSR,
false,
useGpu);
return ptr;
#else
return nullptr;
#endif
}
paddle_error paddle_matrix_sparse_copy_from(paddle_matrix mat,
int* rowArray,
uint64_t rowSize,
int* colArray,
uint64_t colSize,
float* valueArray,
uint64_t valueSize) {
#ifndef PADDLE_MOBILE_INFERENCE
if (mat == nullptr) return kPD_NULLPTR;
auto ptr = cast(mat);
if (rowArray == nullptr || colArray == nullptr ||
(valueSize != 0 && valueArray == nullptr) || ptr->mat == nullptr) {
return kPD_NULLPTR;
}
if (auto sparseMat = dynamic_cast<paddle::CpuSparseMatrix*>(ptr->mat.get())) {
std::vector<int> row(rowSize);
row.assign(rowArray, rowArray + rowSize);
std::vector<int> col(colSize);
col.assign(colArray, colArray + colSize);
std::vector<paddle_real> val(valueSize);
if (valueSize) {
val.assign(valueArray, valueArray + valueSize);
}
sparseMat->copyFrom(row, col, val);
return kPD_NO_ERROR;
} else {
return kPD_NOT_SUPPORTED;
}
#else
return kPD_NOT_SUPPORTED;
#endif
}
| 32.831395
| 80
| 0.625642
|
limeng357
|
733f1b2453e4e54ddde2f729f47a0bb30a32a3d2
| 982
|
cc
|
C++
|
src/calc/token.cc
|
madeso/bbcalc
|
1f5e316ce007b1d1d9b4fc49f9afb03715e5674c
|
[
"MIT"
] | null | null | null |
src/calc/token.cc
|
madeso/bbcalc
|
1f5e316ce007b1d1d9b4fc49f9afb03715e5674c
|
[
"MIT"
] | null | null | null |
src/calc/token.cc
|
madeso/bbcalc
|
1f5e316ce007b1d1d9b4fc49f9afb03715e5674c
|
[
"MIT"
] | null | null | null |
#include "calc/token.h"
#include <array>
#include <string_view>
#include <sstream>
#include <cassert>
[[nodiscard]] std::string
Token::ToString() const
{
constexpr std::array NAMES{
std::string_view{"NUMBER"},
std::string_view{"AND"},
std::string_view{"OR"},
std::string_view{"EOF"}};
using A = decltype(NAMES);
std::stringstream ss;
ss << NAMES[static_cast<A::size_type>(type)];
if (type == NUMBER)
{
ss << "(" << value << ")";
}
return ss.str();
}
Token
Token::Number(int num)
{
Token ret{};
ret.type = NUMBER;
ret.value = num;
return ret;
}
Token
Token::And()
{
return FromType(OPAND);
}
Token
Token::Or()
{
return FromType(OPOR);
}
const Token&
Token::Eof()
{
static auto Eof = FromType(EOFTOKEN);
return Eof;
}
Token
Token::FromType(Type t)
{
assert(t != NUMBER);
Token ret{};
ret.type = t;
ret.value = 0;
return ret;
}
| 13.452055
| 49
| 0.562118
|
madeso
|
734069140143a9873c0f3f6ae8b77658fbe7345c
| 1,414
|
cpp
|
C++
|
lintcode/strstr.cpp
|
Broadroad/learnLeetcode
|
c4af121b3451caa4d53819c5f8c62b38e8e5fb87
|
[
"Apache-2.0"
] | null | null | null |
lintcode/strstr.cpp
|
Broadroad/learnLeetcode
|
c4af121b3451caa4d53819c5f8c62b38e8e5fb87
|
[
"Apache-2.0"
] | null | null | null |
lintcode/strstr.cpp
|
Broadroad/learnLeetcode
|
c4af121b3451caa4d53819c5f8c62b38e8e5fb87
|
[
"Apache-2.0"
] | null | null | null |
class Solution {
public:
int BASE = 1000000;
/**
* @param source:
* @param target:
* @return: return the index
*/
int strStr(string &source, string &target) {
// Write your code here
int tLength = target.size();
if (tLength == 0) {
return 0;
}
// 31 ^ m;
int power = 1;
for (int i = 0; i < tLength; i++) {
power = (power * 31) % BASE;
}
// compute target hashcode
int targetCode = 0;
for (int i = 0; i < tLength; i++) {
targetCode = (targetCode * 31 + target[i]) % BASE;
}
int hashcode = 0;
for (int i = 0; i < source.size(); i++) {
// abc + d
hashcode = (hashcode * 31 + source[i]) % BASE;
if (i < tLength - 1) {
continue;
}
if (i >= tLength) {
// abcd - a
hashcode = (hashcode - source[i - tLength] * power) % BASE;
if (hashcode < 0) {
hashcode += BASE;
}
}
if (hashcode == targetCode) {
if (source.substr(i-tLength+1, tLength) == target) {
return i-tLength+1;
}
}
}
return -1;
}
};
| 26.185185
| 75
| 0.37553
|
Broadroad
|
734227447a877a493502ce2ecbf459fa9089ebed
| 971
|
cpp
|
C++
|
algorithms/cpp/87.cpp
|
viing937/leetcode
|
e21ca52c98bddf59e43522c0aace5e8cf84350eb
|
[
"MIT"
] | 3
|
2016-10-01T10:15:09.000Z
|
2017-07-09T02:53:36.000Z
|
algorithms/cpp/87.cpp
|
viing937/leetcode
|
e21ca52c98bddf59e43522c0aace5e8cf84350eb
|
[
"MIT"
] | null | null | null |
algorithms/cpp/87.cpp
|
viing937/leetcode
|
e21ca52c98bddf59e43522c0aace5e8cf84350eb
|
[
"MIT"
] | null | null | null |
#include <iostream>
#include <vector>
using namespace std;
class Solution {
public:
bool isScramble(string s1, string s2) {
if (s1 == s2) return true;
int length = s1.size();
vector<int> count(26, 0);
for (int i = 0; i < length; i++) {
count[s1[i]-'a'] += 1;
count[s2[i]-'a'] -= 1;
}
for (int i = 0; i < count.size(); i++)
if (count[i] != 0)
return false;
for (int i = 1; i < length; i++) {
if (isScramble(s1.substr(0, i), s2.substr(0, i)) && isScramble(s1.substr(i), s2.substr(i)))
return true;
if (isScramble(s1.substr(0, i), s2.substr(length-i)) && isScramble(s1.substr(i), s2.substr(0, length-i)))
return true;
}
return false;
}
};
int main() {
Solution solution;
solution.isScramble("oatzzffqpnwcxhejzjsnpmkmzngneo", "acegneonzmkmpnsjzjhxwnpqffzzto");
return 0;
}
| 29.424242
| 117
| 0.519053
|
viing937
|
73426bc70010195b7165a0466a2d9fe8a2ac35d9
| 2,031
|
hpp
|
C++
|
src/limonp/CastFloat.hpp
|
ultimate010/cppjieba
|
ada3f5cf76d1f99570d92bc38d5e42a573839a88
|
[
"MIT"
] | 2
|
2015-10-25T17:41:22.000Z
|
2015-10-28T08:46:12.000Z
|
Jieba/src/limonp/CastFloat.hpp
|
sakamoto-poteko/neko
|
642cbc59e1c1241a835f8d9c2590c1935a9e321b
|
[
"MIT",
"Unlicense"
] | null | null | null |
Jieba/src/limonp/CastFloat.hpp
|
sakamoto-poteko/neko
|
642cbc59e1c1241a835f8d9c2590c1935a9e321b
|
[
"MIT",
"Unlicense"
] | null | null | null |
#ifndef LIMONP_CAST_FUNCTS_H
#define LIMONP_CAST_FUNCTS_H
namespace limonp {
namespace CastFloat {
//logical and or
static const int sign_32 = 0xC0000000;
static const int exponent_32 = 0x07800000;
static const int mantissa_32 = 0x007FE000;
static const int sign_exponent_32 = 0x40000000;
static const int loss_32 = 0x38000000;
static const short sign_16 = (short)0xC000;
static const short exponent_16 = (short)0x3C00;
static const short mantissa_16 = (short)0x03FF;
static const short sign_exponent_16 = (short)0x4000;
static const int exponent_fill_32 = 0x38000000;
//infinite
static const short infinite_16 = (short) 0x7FFF;
static const short infinitesmall_16 = (short) 0x0000;
inline float intBitsToFloat(unsigned int x) {
union {
float f;
int i;
} u;
u.i = x;
return u.f;
}
inline int floatToIntBits(float f) {
union {
float f;
int i ;
} u;
u.f = f;
return u.i;
}
inline short floatToShortBits(float f) {
int fi = floatToIntBits(f);
// 提取关键信息
short sign = (short) ((unsigned int)(fi & sign_32) >> 16);
short exponent = (short) ((unsigned int)(fi & exponent_32) >> 13);
short mantissa = (short) ((unsigned int)(fi & mantissa_32) >> 13);
// 生成编码结果
short code = (short) (sign | exponent | mantissa);
// 无穷大量、无穷小量的处理
if ((fi & loss_32) > 0 && (fi & sign_exponent_32) > 0) {
// 当指数符号为1时(正次方),且左234位为1,返回无穷大量
return (short) (code | infinite_16);
}
if (((fi & loss_32) ^ loss_32) > 0 && (fi & sign_exponent_32) == 0) {
// 当指数符号位0时(负次方),且左234位为0(与111异或>0),返回无穷小量
return infinitesmall_16;
}
return code;
}
inline float shortBitsToFloat(short s) {
/*
* 指数空余3位:若符号位为1,补0;若符号位为0,补1。 尾数位在后补0(13个)
*/
int sign = ((int) (s & sign_16)) << 16;
int exponent = ((int) (s & exponent_16)) << 13;
// 指数符号位为0,234位补1
if ((s & sign_exponent_16) == 0 && s != 0) {
exponent |= exponent_fill_32;
}
int mantissa = ((int) (s & mantissa_16)) << 13;
// 生成解码结果
int code = sign | exponent | mantissa;
return intBitsToFloat(code);
}
}
}
#endif
| 24.46988
| 71
| 0.66519
|
ultimate010
|
734492a91e88681108a94ec80c3213c341e6f064
| 4,887
|
cpp
|
C++
|
cocos2d/cocos/editor-support/spine/spine-cocos2dx.cpp
|
davidyuan/WagonWar
|
a52211c0e5490dffaacfa1c722d321d969ae612c
|
[
"MIT"
] | 174
|
2015-01-01T15:12:53.000Z
|
2022-03-23T03:06:07.000Z
|
cocos2d/cocos/editor-support/spine/spine-cocos2dx.cpp
|
davidyuan/WagonWar
|
a52211c0e5490dffaacfa1c722d321d969ae612c
|
[
"MIT"
] | 2
|
2015-05-20T14:34:48.000Z
|
2019-08-14T00:54:40.000Z
|
cocos2d/cocos/editor-support/spine/spine-cocos2dx.cpp
|
davidyuan/WagonWar
|
a52211c0e5490dffaacfa1c722d321d969ae612c
|
[
"MIT"
] | 103
|
2015-01-10T13:34:24.000Z
|
2022-01-10T00:55:33.000Z
|
/******************************************************************************
* Spine Runtime Software License - Version 1.1
*
* Copyright (c) 2013, Esoteric Software
* All rights reserved.
*
* Redistribution and use in source and binary forms in whole or in part, with
* or without modification, are permitted provided that the following conditions
* are met:
*
* 1. A Spine Essential, Professional, Enterprise, or Education License must
* be purchased from Esoteric Software and the license must remain valid:
* http://esotericsoftware.com/
* 2. Redistributions of source code must retain this license, which is the
* above copyright notice, this declaration of conditions and the following
* disclaimer.
* 3. Redistributions in binary form must reproduce this license, which is the
* above copyright notice, this declaration of conditions and the following
* disclaimer, in the documentation and/or other materials provided with the
* distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/
#include <spine/spine-cocos2dx.h>
#include <spine/extension.h>
USING_NS_CC;
void _spAtlasPage_createTexture (spAtlasPage* self, const char* path) {
Texture2D* texture = Director::getInstance()->getTextureCache()->addImage(path);
TextureAtlas* textureAtlas = TextureAtlas::createWithTexture(texture, 4);
textureAtlas->retain();
self->rendererObject = textureAtlas;
// Using getContentSize to make it supports the strategy of loading resources in cocos2d-x.
// self->width = texture->getPixelsWide();
// self->height = texture->getPixelsHigh();
self->width = texture->getContentSize().width;
self->height = texture->getContentSize().height;
}
void _spAtlasPage_disposeTexture (spAtlasPage* self) {
((TextureAtlas*)self->rendererObject)->release();
}
char* _spUtil_readFile (const char* path, int* length)
{
char* ret = nullptr;
int size = 0;
Data data = FileUtils::getInstance()->getDataFromFile(path);
if (!data.isNull())
{
size = static_cast<int>(data.getSize());
*length = size;
// Allocates one more byte for string terminal, it will be safe when parsing JSON file in Spine runtime.
ret = (char*)malloc(size + 1);
ret[size] = '\0';
memcpy(ret, data.getBytes(), size);
}
return ret;
}
/**/
void spRegionAttachment_updateQuad (spRegionAttachment* self, spSlot* slot, V3F_C4B_T2F_Quad* quad, bool premultipliedAlpha) {
float vertices[8];
spRegionAttachment_computeWorldVertices(self, slot->skeleton->x, slot->skeleton->y, slot->bone, vertices);
GLubyte r = slot->skeleton->r * slot->r * 255;
GLubyte g = slot->skeleton->g * slot->g * 255;
GLubyte b = slot->skeleton->b * slot->b * 255;
float normalizedAlpha = slot->skeleton->a * slot->a;
if (premultipliedAlpha) {
r *= normalizedAlpha;
g *= normalizedAlpha;
b *= normalizedAlpha;
}
GLubyte a = normalizedAlpha * 255;
quad->bl.colors.r = r;
quad->bl.colors.g = g;
quad->bl.colors.b = b;
quad->bl.colors.a = a;
quad->tl.colors.r = r;
quad->tl.colors.g = g;
quad->tl.colors.b = b;
quad->tl.colors.a = a;
quad->tr.colors.r = r;
quad->tr.colors.g = g;
quad->tr.colors.b = b;
quad->tr.colors.a = a;
quad->br.colors.r = r;
quad->br.colors.g = g;
quad->br.colors.b = b;
quad->br.colors.a = a;
quad->bl.vertices.x = vertices[VERTEX_X1];
quad->bl.vertices.y = vertices[VERTEX_Y1];
quad->tl.vertices.x = vertices[VERTEX_X2];
quad->tl.vertices.y = vertices[VERTEX_Y2];
quad->tr.vertices.x = vertices[VERTEX_X3];
quad->tr.vertices.y = vertices[VERTEX_Y3];
quad->br.vertices.x = vertices[VERTEX_X4];
quad->br.vertices.y = vertices[VERTEX_Y4];
quad->bl.texCoords.u = self->uvs[VERTEX_X1];
quad->bl.texCoords.v = self->uvs[VERTEX_Y1];
quad->tl.texCoords.u = self->uvs[VERTEX_X2];
quad->tl.texCoords.v = self->uvs[VERTEX_Y2];
quad->tr.texCoords.u = self->uvs[VERTEX_X3];
quad->tr.texCoords.v = self->uvs[VERTEX_Y3];
quad->br.texCoords.u = self->uvs[VERTEX_X4];
quad->br.texCoords.v = self->uvs[VERTEX_Y4];
}
| 39.096
| 126
| 0.683855
|
davidyuan
|
73459419f8ec4baded376d7e3527680e11ea33c0
| 1,469
|
cc
|
C++
|
tensorflow/lite/tensorflow_profiler_logger_shim.cc
|
Stevanus-Christian/tensorflow
|
d44afcf5ca16c5d704c66f891b99eac804e7cd14
|
[
"Apache-2.0"
] | 2
|
2016-09-27T05:37:33.000Z
|
2019-11-22T06:41:12.000Z
|
tensorflow/lite/tensorflow_profiler_logger_shim.cc
|
Stevanus-Christian/tensorflow
|
d44afcf5ca16c5d704c66f891b99eac804e7cd14
|
[
"Apache-2.0"
] | null | null | null |
tensorflow/lite/tensorflow_profiler_logger_shim.cc
|
Stevanus-Christian/tensorflow
|
d44afcf5ca16c5d704c66f891b99eac804e7cd14
|
[
"Apache-2.0"
] | null | null | null |
/* Copyright 2022 The TensorFlow 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 "tensorflow/lite/core/macros.h"
#include "tensorflow/lite/tensorflow_profiler_logger.h"
// Use weak symbols here (even though they are guarded by macros) to avoid
// build breakage when building a benchmark requires TFLite runs. The main
// benchmark library should have tensor_profiler_logger dependency.
// Strong symbol definitions can be found in tensorflow_profiler_logger.cc.
// No-op for the weak symbol. Overridden by a strong symbol in
// tensorflow_profiler_logger.cc.
TFLITE_ATTRIBUTE_WEAK void OnTfLiteTensorAlloc(size_t num_bytes,
TfLiteTensor* tensor) {}
// No-op for the weak symbol. Overridden by a strong symbol in
// tensorflow_profiler_logger.cc.
TFLITE_ATTRIBUTE_WEAK void OnTfLiteTensorDealloc(TfLiteTensor* tensor) {}
| 45.90625
| 80
| 0.73179
|
Stevanus-Christian
|
7346fb41b297d5a0520770ad4d0fcc0e746e143e
| 5,897
|
cpp
|
C++
|
corelib/src/OdometryICP.cpp
|
redater/PAM-BATR
|
3fc8f95972ec13963a53c5448921b59df80a8c8b
|
[
"BSD-3-Clause"
] | 1
|
2017-05-25T20:41:33.000Z
|
2017-05-25T20:41:33.000Z
|
corelib/src/OdometryICP.cpp
|
redater/PAM-BATR
|
3fc8f95972ec13963a53c5448921b59df80a8c8b
|
[
"BSD-3-Clause"
] | null | null | null |
corelib/src/OdometryICP.cpp
|
redater/PAM-BATR
|
3fc8f95972ec13963a53c5448921b59df80a8c8b
|
[
"BSD-3-Clause"
] | null | null | null |
/*
Copyright (c) 2010-2014, Mathieu Labbe - IntRoLab - Universite de Sherbrooke
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 Universite de Sherbrooke nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "rtabmap/core/Odometry.h"
#include "rtabmap/core/util3d.h"
#include "rtabmap/core/OdometryInfo.h"
#include "rtabmap/utilite/ULogger.h"
#include "rtabmap/utilite/UTimer.h"
namespace rtabmap {
OdometryICP::OdometryICP(int decimation,
float voxelSize,
int samples,
float maxCorrespondenceDistance,
int maxIterations,
float correspondenceRatio,
bool pointToPlane,
const ParametersMap & odometryParameter) :
Odometry(odometryParameter),
_decimation(decimation),
_voxelSize(voxelSize),
_samples(samples),
_maxCorrespondenceDistance(maxCorrespondenceDistance),
_maxIterations(maxIterations),
_correspondenceRatio(correspondenceRatio),
_pointToPlane(pointToPlane),
_previousCloudNormal(new pcl::PointCloud<pcl::PointNormal>),
_previousCloud(new pcl::PointCloud<pcl::PointXYZ>)
{
}
void OdometryICP::reset(const Transform & initialPose)
{
Odometry::reset(initialPose);
_previousCloudNormal.reset(new pcl::PointCloud<pcl::PointNormal>);
_previousCloud.reset(new pcl::PointCloud<pcl::PointXYZ>);
}
// return not null transform if odometry is correctly computed
Transform OdometryICP::computeTransform(const SensorData & data, OdometryInfo * info)
{
UTimer timer;
Transform output;
bool hasConverged = false;
double variance = 0;
unsigned int minPoints = 100;
if(!data.depth().empty())
{
if(data.depth().type() == CV_8UC1)
{
UERROR("ICP 3D cannot be done on stereo images!");
return output;
}
pcl::PointCloud<pcl::PointXYZ>::Ptr newCloudXYZ = util3d::getICPReadyCloud(
data.depth(),
data.fx(),
data.fy(),
data.cx(),
data.cy(),
_decimation,
this->getMaxDepth(),
_voxelSize,
_samples,
data.localTransform());
if(_pointToPlane)
{
pcl::PointCloud<pcl::PointNormal>::Ptr newCloud = util3d::computeNormals(newCloudXYZ);
std::vector<int> indices;
newCloud = util3d::removeNaNNormalsFromPointCloud<pcl::PointNormal>(newCloud);
if(newCloudXYZ->size() != newCloud->size())
{
UWARN("removed nan normals...");
}
if(_previousCloudNormal->size() > minPoints && newCloud->size() > minPoints)
{
int correspondences = 0;
Transform transform = util3d::icpPointToPlane(newCloud,
_previousCloudNormal,
_maxCorrespondenceDistance,
_maxIterations,
&hasConverged,
&variance,
&correspondences);
// verify if there are enough correspondences
float correspondencesRatio = float(correspondences)/float(_previousCloudNormal->size()>newCloud->size()?_previousCloudNormal->size():newCloud->size());
if(!transform.isNull() && hasConverged &&
correspondencesRatio >= _correspondenceRatio)
{
output = transform;
_previousCloudNormal = newCloud;
}
else
{
UWARN("Transform not valid (hasConverged=%s variance = %f)",
hasConverged?"true":"false", variance);
}
}
else if(newCloud->size() > minPoints)
{
output.setIdentity();
_previousCloudNormal = newCloud;
}
}
else
{
//point to point
if(_previousCloud->size() > minPoints && newCloudXYZ->size() > minPoints)
{
int correspondences = 0;
Transform transform = util3d::icp(newCloudXYZ,
_previousCloud,
_maxCorrespondenceDistance,
_maxIterations,
&hasConverged,
&variance,
&correspondences);
// verify if there are enough correspondences
float correspondencesRatio = float(correspondences)/float(_previousCloud->size()>newCloudXYZ->size()?_previousCloud->size():newCloudXYZ->size());
if(!transform.isNull() && hasConverged &&
correspondencesRatio >= _correspondenceRatio)
{
output = transform;
_previousCloud = newCloudXYZ;
}
else
{
UWARN("Transform not valid (hasConverged=%s variance = %f)",
hasConverged?"true":"false", variance);
}
}
else if(newCloudXYZ->size() > minPoints)
{
output.setIdentity();
_previousCloud = newCloudXYZ;
}
}
}
else
{
UERROR("Depth is empty?!?");
}
if(info)
{
info->variance = variance;
}
UINFO("Odom update time = %fs hasConverged=%s variance=%f cloud=%d",
timer.elapsed(),
hasConverged?"true":"false",
variance,
(int)(_pointToPlane?_previousCloudNormal->size():_previousCloud->size()));
return output;
}
} // namespace rtabmap
| 30.713542
| 155
| 0.716636
|
redater
|
734850c46ab274fe820c5910550cbfbf2dd11176
| 4,082
|
hpp
|
C++
|
source/pattern/Map.hpp
|
Superone77/PMPP-Compositional-GPU
|
e1f5a24563572604880a73db55757363cd3c5b3c
|
[
"CECILL-B"
] | 1
|
2022-02-13T13:14:08.000Z
|
2022-02-13T13:14:08.000Z
|
source/pattern/Map.hpp
|
Superone77/PMPP-Compositional-GPU
|
e1f5a24563572604880a73db55757363cd3c5b3c
|
[
"CECILL-B"
] | null | null | null |
source/pattern/Map.hpp
|
Superone77/PMPP-Compositional-GPU
|
e1f5a24563572604880a73db55757363cd3c5b3c
|
[
"CECILL-B"
] | null | null | null |
#pragma once
#include "../Commons.hpp"
#include "../interfaces/PatternInterface.hpp"
#include "../interfaces/ThreadSafeQueue.hpp"
#include "../interfaces/Executor.hpp"
#include "../interfaces/LoadBalancer.hpp"
#include <cassert>
#include <future>
#include <thread>
#include <vector>
template<typename T_input, typename T_output>
class Map : public PatternInterface<FutVec<T_input>, FutVec<T_output>> {
std::vector<std::thread> threads;
Executor<T_input, T_output> executor;
TSQueue<std::tuple<std::future<T_input>, std::promise<T_output>>> inner_queue;
friend class LoadBalancingCapabilities<Map>;
void PerformTask()
{
while (!this->dying)
{
if (!doWork())
{
if (this->dying)
{
break;
}
if (this->load_balancer) {
if (!this->load_balancer->provideWork())
{
std::this_thread::yield();
}
}
else
{
std::this_thread::yield();
}
continue;
}
}
}
bool doWork()
{
std::tuple<std::future<T_input>, std::promise<T_output>> data;
auto success = this->inner_queue.try_pop(data);
if (!success)
return false;
auto future = std::move(std::get<0>(data));
auto promise = std::move(std::get<1>(data));
if (this->load_balancer)
if (future.wait_for(std::chrono::seconds(0)) != std::future_status::ready)
{
this->inner_queue.push(std::move(std::tuple<std::future<T_input>, std::promise<T_output>>(std::move(future), std::move(promise))));
return false;
}
executor.Compute(std::move(future), std::move(promise));
return true;
}
Map(PatIntPtr<T_input, T_output> task, size_t thread_count) : threads(thread_count), executor(task, thread_count) { }
protected:
void InternallyCompute(std::future<FutVec<T_input>> futValue, std::promise<FutVec<T_output>> prom) override {
FutVec<T_input> value = futValue.get();
size_t count = value.size();
assert(count > 0);
FutVec<T_output> results(count);
for (size_t i = 0; i < count; i++) {
std::promise<T_output> promise;
std::future<T_output> fut = promise.get_future();
results[i] = std::move(fut);
std::future<T_input> single_future = std::move(value[i]);
inner_queue.push(std::make_tuple(std::move(single_future), std::move(promise)));
}
prom.set_value(std::move(results));
}
public:
static PatIntPtr<FutVec<T_input>, FutVec<T_output>> create(PatIntPtr<T_input, T_output> task, size_t thread_count, std::shared_ptr<LoadBalancer> load_balancer = nullptr) {
assert(thread_count > 0);
auto map = new Map(task, thread_count);
auto s_ptr = std::shared_ptr<PatternInterface<FutVec<T_input>, FutVec<T_output>>>(map);
s_ptr->self = s_ptr;
s_ptr->load_balancer = load_balancer;
return s_ptr;
}
Map(Map& other) = delete;
Map(Map&& other) = delete;
Map& operator=(const Map& other) = delete;
Map& operator=(Map&& other) = delete;
PatIntPtr<FutVec<T_input>, FutVec<T_output>> create_copy() override {
this->assertNoInit();
return create(executor.GetTask(), threads.size(), this->load_balancer);
}
bool doTask() override {
return doWork();
}
size_t ThreadCount() const noexcept override {
return threads.size() * executor.ThreadCount();
}
std::string Name() const override {
return std::string("map(") + std::to_string(threads.size()) + std::string(",") + executor.Name() + std::string(")");
}
void Init() override {
if (!this->initialized) {
this->dying = false;
if (this->load_balancer)
LoadBalancer::registerLoadBalancer(this->self, this->load_balancer);
executor.Init();
for (size_t i = 0; i < threads.size(); i++) {
threads[i] = std::thread(&Map::PerformTask, this);
}
this->initialized = true;
}
}
void Dispose() override {
if (this->initialized) {
this->dying = true;
if (this->load_balancer)
LoadBalancer::deregisterLoadBalancer(this->self, this->load_balancer);
for (std::thread& thread : threads) {
if (thread.joinable()) {
thread.join();
}
}
executor.Dispose();
this->initialized = false;
}
}
~Map() {
Map<T_input, T_output>::Dispose();
}
};
| 23.45977
| 172
| 0.66291
|
Superone77
|
734a4641678a890b978562fb5146e6b52dbbfe72
| 1,505
|
cpp
|
C++
|
apps/scheduler/client/assfire/scheduler/RemoteWaybillSchedulingAlgorithm.cpp
|
Eaglegor/assfire-suite
|
6c8140e848932b6ce22b6addd07a93abba652c01
|
[
"MIT"
] | null | null | null |
apps/scheduler/client/assfire/scheduler/RemoteWaybillSchedulingAlgorithm.cpp
|
Eaglegor/assfire-suite
|
6c8140e848932b6ce22b6addd07a93abba652c01
|
[
"MIT"
] | null | null | null |
apps/scheduler/client/assfire/scheduler/RemoteWaybillSchedulingAlgorithm.cpp
|
Eaglegor/assfire-suite
|
6c8140e848932b6ce22b6addd07a93abba652c01
|
[
"MIT"
] | null | null | null |
#include "RemoteWaybillSchedulingAlgorithm.hpp"
#include "assfire/api/v1/scheduler/translators/Translators.hpp"
#include "assfire/api/v1/router/translators/Translators.hpp"
using namespace assfire::scheduler;
using namespace assfire::api::v1::scheduler;
RemoteWaybillSchedulingAlgorithm::RemoteWaybillSchedulingAlgorithm(const SchedulerGrpcConnector &connector, WaybillSchedulingAlgorithmType algorithm_type, const WaybillSchedulerSettings& settings,
const router::RoutingProfile& routing_profile) :
connector(connector), algorithm_type(algorithm_type), settings(settings), routing_profile(routing_profile) {
}
void RemoteWaybillSchedulingAlgorithm::scheduleWaybill(Waybill &waybill) const {
ScheduleWaybillRequest request;
request.set_algorithm_type(WaybillSchedulingAlgorithmTypeTranslator::toProto(algorithm_type));
request.mutable_waybill()->CopyFrom(WaybillTranslator::toProto(waybill));
request.mutable_routing_profile()->CopyFrom(RoutingProfileTranslator::toProto(routing_profile));
request.mutable_settings()->CopyFrom(WaybillSchedulerSettingsTranslator::toProto(settings));
ScheduleWaybillResponse response = connector.scheduleWaybill(request);
if(response.status().code() != ScheduleWaybillResponseStatus::SCHEDULE_WAYBILL_RESPONSE_STATUS_CODE_OK) {
throw std::runtime_error(response.status().message());
}
waybill = WaybillTranslator::fromProto(response.waybill());
}
| 51.896552
| 196
| 0.780066
|
Eaglegor
|
734a5413924f3b88dfeea748e2162f43cbbf7a73
| 503
|
cpp
|
C++
|
3-Behavioral/14.Command/src/Command/Factory/DivideFactory.cpp
|
gfa99/gof_design_patterns
|
a33ee7f344f8e382bb9fc676b77b22a5a123bca0
|
[
"Apache-2.0"
] | 21
|
2017-11-08T11:32:48.000Z
|
2021-03-29T08:58:04.000Z
|
3-Behavioral/14.Command/src/Command/Factory/DivideFactory.cpp
|
gfa99/gof_design_patterns
|
a33ee7f344f8e382bb9fc676b77b22a5a123bca0
|
[
"Apache-2.0"
] | null | null | null |
3-Behavioral/14.Command/src/Command/Factory/DivideFactory.cpp
|
gfa99/gof_design_patterns
|
a33ee7f344f8e382bb9fc676b77b22a5a123bca0
|
[
"Apache-2.0"
] | 8
|
2017-11-26T13:57:50.000Z
|
2021-08-23T06:52:57.000Z
|
#include "Command/Factory/DivideFactory.h"
namespace GoF {
namespace Command {
namespace Factory {
Command * DivideFactory::createCommand(double _operand, double _operator)
{
return new Divide(this->createReceiver(_operand, _operator));
}
Receiver * DivideFactory::createReceiver(double _operand, double _operator)
{
return new Division(_operand, _operator);
}
}
}
}
| 20.958333
| 87
| 0.574553
|
gfa99
|
734a93a40466a1340ad176d58341a668e9376d2c
| 3,365
|
hpp
|
C++
|
libs/foe_graphics_resource/include/foe/graphics/resource/material_loader.hpp
|
StableCoder/foe-engine
|
5d49696a46c119e708dc4055b99e18194bcd4c4f
|
[
"Apache-2.0"
] | 4
|
2021-04-09T13:11:22.000Z
|
2022-03-26T07:29:31.000Z
|
libs/foe_graphics_resource/include/foe/graphics/resource/material_loader.hpp
|
StableCoder/foe-engine
|
5d49696a46c119e708dc4055b99e18194bcd4c4f
|
[
"Apache-2.0"
] | null | null | null |
libs/foe_graphics_resource/include/foe/graphics/resource/material_loader.hpp
|
StableCoder/foe-engine
|
5d49696a46c119e708dc4055b99e18194bcd4c4f
|
[
"Apache-2.0"
] | 1
|
2022-02-10T14:51:00.000Z
|
2022-02-10T14:51:00.000Z
|
/*
Copyright (C) 2021 George Cave.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
#ifndef FOE_GRPAHICS_RESOURCE_MATERIAL_LOADER_HPP
#define FOE_GRPAHICS_RESOURCE_MATERIAL_LOADER_HPP
#include <foe/graphics/vk/fragment_descriptor_pool.hpp>
#include <foe/graphics/resource/export.h>
#include <foe/graphics/resource/material.hpp>
#include <foe/graphics/session.hpp>
#include <foe/graphics/type_defs.hpp>
#include <foe/simulation/core/loader.hpp>
#include <vulkan/vulkan.h>
#include <array>
#include <vector>
class foeShaderPool;
class foeImagePool;
struct FOE_GFX_RES_EXPORT foeMaterialCreateInfo : public foeResourceCreateInfoBase {
~foeMaterialCreateInfo();
foeId fragmentShader = FOE_INVALID_ID;
foeId image = FOE_INVALID_ID;
bool hasRasterizationSCI;
VkPipelineRasterizationStateCreateInfo rasterizationSCI;
bool hasDepthStencilSCI;
VkPipelineDepthStencilStateCreateInfo depthStencilSCI;
bool hasColourBlendSCI;
VkPipelineColorBlendStateCreateInfo colourBlendSCI;
std::vector<VkPipelineColorBlendAttachmentState> colourBlendAttachments;
};
class FOE_GFX_RES_EXPORT foeMaterialLoader : public foeResourceLoaderBase {
public:
std::error_code initialize(foeShaderPool *pShaderPool,
foeImagePool *pImagePool,
foeGfxSession session);
void deinitialize();
bool initialized() const noexcept;
void gfxMaintenance();
virtual bool canProcessCreateInfo(foeResourceCreateInfoBase *pCreateInfo) final;
virtual void load(void *pResource,
std::shared_ptr<foeResourceCreateInfoBase> const &pCreateInfo,
void (*pPostLoadFn)(void *, std::error_code)) final;
private:
std::error_code createDescriptorSet(foeMaterial::Data *pMaterialData);
static void unloadResource(void *pContext,
void *pResource,
uint32_t resourceIteration,
bool immediateUnload);
foeShaderPool *mShaderPool{nullptr};
foeImagePool *mImagePool{nullptr};
foeGfxSession mGfxSession{FOE_NULL_HANDLE};
foeGfxVkFragmentDescriptorPool *mGfxFragmentDescriptorPool{nullptr};
VkDescriptorPool mDescriptorPool;
struct LoadData {
foeMaterial *pMaterial;
void (*pPostLoadFn)(void *, std::error_code);
foeMaterial::Data data;
};
std::mutex mLoadSync;
std::vector<LoadData> mLoadRequests;
struct UnloadData {
foeMaterial *pMaterial;
uint32_t iteration;
};
std::mutex mUnloadSync;
std::vector<UnloadData> mUnloadRequests;
size_t mDataDestroyIndex{0};
std::array<std::vector<foeMaterial::Data>, FOE_GRAPHICS_MAX_BUFFERED_FRAMES + 1>
mDataDestroyLists{};
};
#endif // FOE_GRPAHICS_RESOURCE_MATERIAL_LOADER_HPP
| 32.990196
| 84
| 0.719465
|
StableCoder
|
734bf82529614ce4230de06837fae7e75d94dad3
| 5,460
|
cpp
|
C++
|
src/extralibs/sdl_draw/src/draw_line.cpp
|
SamuraiCrow/protrekkr
|
4bf6f52635ac722e7a9370dacfbc8807a4043c4a
|
[
"BSD-3-Clause"
] | 22
|
2018-02-13T12:29:23.000Z
|
2022-02-21T16:18:15.000Z
|
src/extralibs/sdl_draw/src/draw_line.cpp
|
PaulBatchelor/protrekkr
|
0f93032913bf111b0721901691dd351a165c3d61
|
[
"BSD-2-Clause"
] | 5
|
2018-02-13T13:43:55.000Z
|
2021-12-14T07:55:07.000Z
|
src/extralibs/sdl_draw/src/draw_line.cpp
|
hitchhikr/protrekkr
|
d14b83f1a2570ea31deced97972839b621710c9e
|
[
"BSD-3-Clause"
] | 5
|
2019-05-02T13:07:28.000Z
|
2022-01-07T17:51:37.000Z
|
/*!
\file Draw_Line.c
\author Mario Palomo <mpalomo@ihman.com>
\author Jose M. de la Huerga Fern�ndez
\author Pepe Gonz�lez Mora
\date 05-2002
Based in Kenny Hoff sourcer.
*/
/*
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#if defined(__GCC__)
#include "../include/sdl_draw.h"
#else
#include "../../include/sdl_draw.h"
#endif
#define SDL_DRAW_PUTPIXEL_BPP(A, B, C, D) *(A(B(Uint8*)D))=C;
#if SDL_DRAW_BPP == 1
#define SDL_DRAW_PUTPIXEL(D) SDL_DRAW_PUTPIXEL_BPP(0+,0+,color,D)
#elif SDL_DRAW_BPP == 4
#define SDL_DRAW_PUTPIXEL(D) SDL_DRAW_PUTPIXEL_BPP((Uint32*),0+,color,D)
#endif /*SDL_DRAW_BPP*/
void STDCALL Draw_Line(SDL_Surface *super,
Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2,
Uint32 color)
{
register Sint16 dx;
register Sint16 dy;
Sint16 fbXincr, fbYincr, fbXYincr;
Sint16 dPr, dPru, P;
Sint16 pixx = super->format->BytesPerPixel;
Sint16 pixy = super->pitch;
Uint8 *AfbAddr, *BfbAddr;
/* Clip line and test if we have to draw only if we need to do it */
/* It is in next version.
#ifdef SDL_DRAW_CLIP
if (!(clipLine(super, &x1, &y1, &x2, &y2))) { return; }
#endif
*/
/* Store the fremebuffer Endpoint-Addresses (A and B) */
AfbAddr = ((Uint8*)super->pixels) + pixx * (int)x1 + pixy * (int)y1;
BfbAddr = ((Uint8*)super->pixels) + pixx * (int)x2 + pixy * (int)y2;
/* Lock surface */
if (SDL_MUSTLOCK(super)) {
if (SDL_LockSurface(super) < 0) { return; }
}
fbXincr=pixx;
if ( (dx=x2-x1) >= 0 ) goto AFTERNEGX;
dx = -dx;
fbXincr = -pixx;
AFTERNEGX:
fbYincr=pixy; //debug
if ( (dy=y2-y1) >= 0) goto AFTERNEGY;
fbYincr = -pixy;
dy = -dy;
AFTERNEGY:
fbXYincr = fbXincr+fbYincr;
if (dy > dx) goto YisIndependent; /*Check if X or Y is independent vaiable */
/*XisIndependent;*/
dPr = dy+dy;
P = -dx;
dPru = P+P;
dy = dx>>1;
XLOOP:
SDL_DRAW_PUTPIXEL(AfbAddr); /*Plot the pixel from end of pointer one*/
SDL_DRAW_PUTPIXEL(BfbAddr); /*Plot the pixel from end of pointer two*/
if ((P+=dPr) > 0) goto RightAndUp;
/*Up:*/
AfbAddr+=fbXincr;
BfbAddr-=fbXincr;
if ((dy=dy-1) > 0) goto XLOOP;
SDL_DRAW_PUTPIXEL(AfbAddr) /*(Fix midpoint problem) Plot last PT from end pointer one*/
if (( dx & 1) == 0) goto END_P;
SDL_DRAW_PUTPIXEL(BfbAddr); /*Plot last PT from end of pointer two if independent is odd*/
goto END_P;
RightAndUp:
AfbAddr+=fbXYincr; /*Advance to next point from end of pointer one*/
BfbAddr-=fbXYincr; /*Advance to next point from end of pointer two*/
P+=dPru;
if ((dy=dy-1) > 0) goto XLOOP;
SDL_DRAW_PUTPIXEL(AfbAddr); /*(Fix midpoint problem) Plot last PT from end of pointer one*/
if ((dx & 1) == 0) goto END_P;
SDL_DRAW_PUTPIXEL(BfbAddr); /*Plot last PT from end of pointer two if indepent is odd*/
goto END_P;
YisIndependent:
dPr = dx+dx;
P = -dy;
dPru = P+P;
dx = dy >>1;
YLOOP: /* PROCESS EACH POINT IN THE LINE ONE AT A TIME (use dX as loop counter) */
SDL_DRAW_PUTPIXEL(AfbAddr); /* PLOT THE PIXEL FROM END A */
SDL_DRAW_PUTPIXEL(BfbAddr); /* PLOT THE PIXEL FROM END B */
if ((P+=dPr) > 0) goto RightAndUp2; /* INCREMENT DECISION, CHECK IF THE PIXEL IS GOING RIGHT AND UP */
/*Up:*/
AfbAddr+=fbYincr; /* ADVANCE TO NEXT POINT FROM END A */
BfbAddr-=fbYincr; /* ADVANCE TO NEXT POINT FROM END B */
if ((dx=dx-1) > 0) goto YLOOP; /* DECREMENT LOOP VARIABLE AND LOOP */
SDL_DRAW_PUTPIXEL(AfbAddr); /* (FIX MIDPOINT PROBLEM) PLOT THE LAST POINT FROM END A */
if ((dy & 1) == 0) goto END_P; /* FINISHED IF INDEPENDENT IS EVEN (ODD # STEPS) */
SDL_DRAW_PUTPIXEL(BfbAddr); /* PLOT LAST PT FROM END B IF INDEPENDENT IS ODD (EVEN # STEPS) */
goto END_P;
RightAndUp2:
AfbAddr+=fbXYincr; /* ADVANCE TO NEXT POINT FROM END A */
BfbAddr-=fbXYincr; /* ADVANCE TO NEXT POINT FROM END B */
P+=dPru; /* INCREMENT DECISION (for up) */
if ((dx=dx-1) > 0) goto YLOOP; /* DECREMENT LOOP VARIABLE AND LOOP */
SDL_DRAW_PUTPIXEL(AfbAddr); /* (FIX MIDPOINT PROBLEM) PLOT THE LAST POINT FROM END A */
if ((dy & 1) == 0) goto END_P; /* FINISHED IF INDEPENDENT IS EVEN (ODD # STEPS) */
SDL_DRAW_PUTPIXEL(BfbAddr); /* PLOT LAST PT FROM END B IF INDEPENDENT IS ODD (EVEN # STEPS) */
END_P:
/* Unlock surface */
if (SDL_MUSTLOCK(super)) { SDL_UnlockSurface(super); }
}/*Draw_Line*/
#undef SDL_DRAW_PUTPIXEL
#undef SDL_DRAW_PUTPIXEL_BPP
| 35.225806
| 119
| 0.621062
|
SamuraiCrow
|
734ce4bd9eaaac6d65d346567b122ea6fce575f4
| 4,897
|
cpp
|
C++
|
src/goto-diff/goto_diff_base.cpp
|
DamonLiuTHU/cbmc
|
67f8c916672347ab05418db45eebbd93885efdec
|
[
"BSD-4-Clause"
] | null | null | null |
src/goto-diff/goto_diff_base.cpp
|
DamonLiuTHU/cbmc
|
67f8c916672347ab05418db45eebbd93885efdec
|
[
"BSD-4-Clause"
] | null | null | null |
src/goto-diff/goto_diff_base.cpp
|
DamonLiuTHU/cbmc
|
67f8c916672347ab05418db45eebbd93885efdec
|
[
"BSD-4-Clause"
] | null | null | null |
/*******************************************************************\
Module: GOTO-DIFF Base Class
Author: Peter Schrammel
\*******************************************************************/
/// \file
/// GOTO-DIFF Base Class
#include "goto_diff.h"
#include <util/json_expr.h>
#include <util/options.h>
#include <goto-programs/goto_model.h>
#include <goto-programs/show_properties.h>
/// Output diff result
void goto_difft::output_functions() const
{
messaget msg(message_handler);
switch(message_handler.get_ui())
{
case ui_message_handlert::uit::PLAIN:
{
msg.result() << "total number of functions: " << total_functions_count
<< '\n' << messaget::eom;
output_function_group("new functions", new_functions, goto_model2);
output_function_group(
"modified functions", modified_functions, goto_model2);
output_function_group(
"deleted functions", deleted_functions, goto_model1);
msg.result() << messaget::eom;
break;
}
case ui_message_handlert::uit::JSON_UI:
{
json_objectt json_result;
json_result["totalNumberOfFunctions"]=
json_stringt(std::to_string(total_functions_count));
convert_function_group_json(
json_result["newFunctions"].make_array(), new_functions, goto_model2);
convert_function_group_json(
json_result["modifiedFunctions"].make_array(),
modified_functions,
goto_model2);
convert_function_group_json(
json_result["deletedFunctions"].make_array(),
deleted_functions,
goto_model1);
msg.result() << json_result << messaget::eom;
break;
}
case ui_message_handlert::uit::XML_UI:
{
msg.error() << "XML output not supported yet" << messaget::eom;
}
}
}
/// Output group of functions in plain text format
/// \param group_name: the name of the group, e.g. "modified functions"
/// \param function_group: set of function ids in the group
/// \param goto_model: the goto model
void goto_difft::output_function_group(
const std::string &group_name,
const std::set<irep_idt> &function_group,
const goto_modelt &goto_model) const
{
messaget(message_handler).result() << group_name << ':' << messaget::eom;
for(const auto &function_name : function_group)
{
output_function(function_name, goto_model);
}
}
/// Output function information in plain text format
/// \param function_name: the function id
/// \param goto_model: the goto model
void goto_difft::output_function(
const irep_idt &function_name,
const goto_modelt &goto_model) const
{
messaget msg(message_handler);
namespacet ns(goto_model.symbol_table);
const symbolt &symbol = ns.lookup(function_name);
msg.result() << " " << symbol.location.get_file() << ": " << function_name;
if(options.get_bool_option("show-properties"))
{
const auto goto_function_it =
goto_model.goto_functions.function_map.find(function_name);
CHECK_RETURN(
goto_function_it != goto_model.goto_functions.function_map.end());
const goto_programt &goto_program = goto_function_it->second.body;
for(const auto &ins : goto_program.instructions)
{
if(!ins.is_assert())
continue;
const source_locationt &source_location = ins.source_location;
irep_idt property_id = source_location.get_property_id();
msg.result() << "\n " << property_id;
}
}
msg.result() << messaget::eom;
}
/// Convert a function group to JSON
/// \param result: the JSON array to be populated
/// \param function_group: set of function ids in the group
/// \param goto_model: the goto model
void goto_difft::convert_function_group_json(
json_arrayt &result,
const std::set<irep_idt> &function_group,
const goto_modelt &goto_model) const
{
for(const auto &function_name : function_group)
{
convert_function_json(
result.push_back(jsont()).make_object(), function_name, goto_model);
}
}
/// Convert function information to JSON
/// \param result: the JSON object to be populated
/// \param function_name: the function id
/// \param goto_model: the goto model
void goto_difft::convert_function_json(
json_objectt &result,
const irep_idt &function_name,
const goto_modelt &goto_model) const
{
namespacet ns(goto_model.symbol_table);
const symbolt &symbol = ns.lookup(function_name);
result["name"] = json_stringt(function_name);
result["sourceLocation"] = json(symbol.location);
if(options.get_bool_option("show-properties"))
{
const auto goto_function_it =
goto_model.goto_functions.function_map.find(function_name);
CHECK_RETURN(
goto_function_it != goto_model.goto_functions.function_map.end());
const goto_programt &goto_program = goto_function_it->second.body;
convert_properties_json(
result["properties"].make_array(), ns, function_name, goto_program);
}
}
| 30.798742
| 78
| 0.687768
|
DamonLiuTHU
|
734eb180fcc67783c5a416b81f6120750a9dc422
| 12,088
|
cpp
|
C++
|
win32/VandaEngine1/GraphicsEngine/ActionsAPI.cpp
|
ehsankamrani/vandaengine
|
854430e41db6df1f4fcad9c19718fd8dfcc2c3cb
|
[
"MIT"
] | 12
|
2021-06-22T11:28:12.000Z
|
2022-03-21T00:56:33.000Z
|
win32/VandaEngine1/GraphicsEngine/ActionsAPI.cpp
|
ehsankamrani/vandaengine
|
854430e41db6df1f4fcad9c19718fd8dfcc2c3cb
|
[
"MIT"
] | null | null | null |
win32/VandaEngine1/GraphicsEngine/ActionsAPI.cpp
|
ehsankamrani/vandaengine
|
854430e41db6df1f4fcad9c19718fd8dfcc2c3cb
|
[
"MIT"
] | 1
|
2018-10-05T08:17:29.000Z
|
2018-10-05T08:17:29.000Z
|
/// ActionsAPI.cpp
///
/// Copyright 1997-2007 by David K. McAllister
/// http://www.ParticleSystems.org
///
/// This file implements the action API calls by creating action class instances,
/// which are either executed or added to an action list.
#include "stdafx.h"
#include "pAPI.h"
#include "PInternalState.h"
namespace PAPI {
void PContextActions_t::Avoid(const float magnitude, const float epsilon, const float look_ahead, const pDomain &dom)
{
PAAvoid *A = new PAAvoid;
A->position = dom.copy();
A->magnitude = magnitude;
A->epsilon = epsilon;
A->look_ahead = look_ahead;
A->SetKillsParticles(false);
A->SetDoNotSegment(false);
PS->SendAction(A);
}
void PContextActions_t::Bounce(const float friction, const float resilience, const float cutoff, const pDomain &dom)
{
PABounce *A = new PABounce;
A->position = dom.copy();
A->oneMinusFriction = 1.0f - friction;
A->resilience = resilience;
A->cutoffSqr = fsqr(cutoff);
A->SetKillsParticles(false);
A->SetDoNotSegment(false);
PS->SendAction(A);
}
void PContextActions_t::Callback(P_PARTICLE_CALLBACK callback, puint64 data)
{
PACallback *A = new PACallback;
A->callback = callback;
A->Data = data;
A->SetKillsParticles(false);
A->SetDoNotSegment(false);
PS->SendAction(A);
}
void PContextActions_t::CopyVertexB(const bool copy_pos, const bool copy_vel)
{
PACopyVertexB *A = new PACopyVertexB;
A->copy_pos = copy_pos;
A->copy_vel = copy_vel;
A->SetKillsParticles(false);
A->SetDoNotSegment(false);
PS->SendAction(A);
}
void PContextActions_t::Damping(const pVec &damping,
const float vlow, const float vhigh)
{
PADamping *A = new PADamping;
A->damping = damping;
A->vlowSqr = fsqr(vlow);
A->vhighSqr = fsqr(vhigh);
A->SetKillsParticles(false);
A->SetDoNotSegment(false);
PS->SendAction(A);
}
void PContextActions_t::RotDamping(const pVec &damping,
const float vlow, const float vhigh)
{
PARotDamping *A = new PARotDamping;
A->damping = damping;
A->vlowSqr = fsqr(vlow);
A->vhighSqr = fsqr(vhigh);
A->SetKillsParticles(false);
A->SetDoNotSegment(false);
PS->SendAction(A);
}
void PContextActions_t::Explosion(const pVec ¢er, const float radius,
const float magnitude, const float stdev, const float epsilon)
{
PAExplosion *A = new PAExplosion;
A->center = center;
A->radius = radius;
A->magnitude = magnitude;
A->stdev = stdev;
A->epsilon = epsilon;
if(A->epsilon < 0.0f)
A->epsilon = P_EPS;
A->SetKillsParticles(false);
A->SetDoNotSegment(false);
PS->SendAction(A);
}
void PContextActions_t::Follow(const float magnitude, const float epsilon, const float max_radius)
{
PAFollow *A = new PAFollow;
A->magnitude = magnitude;
A->epsilon = epsilon;
A->max_radius = max_radius;
A->SetKillsParticles(false);
A->SetDoNotSegment(true);
PS->SendAction(A);
}
void PContextActions_t::Gravitate(const float magnitude, const float epsilon, const float max_radius)
{
PAGravitate *A = new PAGravitate;
A->magnitude = magnitude;
A->epsilon = epsilon;
A->max_radius = max_radius;
A->SetKillsParticles(false);
A->SetDoNotSegment(true);
PS->SendAction(A);
}
void PContextActions_t::Gravity(const pVec &dir)
{
PAGravity *A = new PAGravity;
A->direction = dir;
A->SetKillsParticles(false);
A->SetDoNotSegment(false);
PS->SendAction(A);
}
void PContextActions_t::Jet(const pDomain &dom, const pDomain &accel)
{
PAJet *A = new PAJet;
A->dom = dom.copy();
A->acc = accel.copy();
A->SetKillsParticles(false);
A->SetDoNotSegment(false);
PS->SendAction(A);
}
void PContextActions_t::KillOld(const float age_limit, const bool kill_less_than)
{
PAKillOld *A = new PAKillOld;
A->age_limit = age_limit;
A->kill_less_than = kill_less_than;
A->SetKillsParticles(true);
A->SetDoNotSegment(false);
PS->SendAction(A);
}
void PContextActions_t::MatchVelocity(const float magnitude, const float epsilon, const float max_radius)
{
PAMatchVelocity *A = new PAMatchVelocity;
A->magnitude = magnitude;
A->epsilon = epsilon;
A->max_radius = max_radius;
A->SetKillsParticles(false);
A->SetDoNotSegment(true);
PS->SendAction(A);
}
void PContextActions_t::MatchRotVelocity(const float magnitude, const float epsilon, const float max_radius)
{
PAMatchRotVelocity *A = new PAMatchRotVelocity;
A->magnitude = magnitude;
A->epsilon = epsilon;
A->max_radius = max_radius;
A->SetKillsParticles(false);
A->SetDoNotSegment(true);
PS->SendAction(A);
}
void PContextActions_t::Move(const bool move_velocity, const bool move_rotational_velocity)
{
PAMove *A = new PAMove;
A->move_velocity = move_velocity;
A->move_rotational_velocity = move_rotational_velocity;
A->SetKillsParticles(false);
A->SetDoNotSegment(false);
PS->SendAction(A);
}
void PContextActions_t::OrbitLine(const pVec &p, const pVec &axis,
const float magnitude, const float epsilon, const float max_radius)
{
PAOrbitLine *A = new PAOrbitLine;
A->p = p;
A->axis = axis;
A->axis.normalize();
A->magnitude = magnitude;
A->epsilon = epsilon;
A->max_radius = max_radius;
A->SetKillsParticles(false);
A->SetDoNotSegment(false);
PS->SendAction(A);
}
void PContextActions_t::OrbitPoint(const pVec ¢er, const float magnitude, const float epsilon, const float max_radius)
{
PAOrbitPoint *A = new PAOrbitPoint;
A->center = center;
A->magnitude = magnitude;
A->epsilon = epsilon;
A->max_radius = max_radius;
A->SetKillsParticles(false);
A->SetDoNotSegment(false);
PS->SendAction(A);
}
void PContextActions_t::RandomAccel(const pDomain &dom)
{
PARandomAccel *A = new PARandomAccel;
A->gen_acc = dom.copy();
A->SetKillsParticles(false);
A->SetDoNotSegment(false);
PS->SendAction(A);
}
void PContextActions_t::RandomDisplace(const pDomain &dom)
{
PARandomDisplace *A = new PARandomDisplace;
A->gen_disp = dom.copy();
A->SetKillsParticles(false);
A->SetDoNotSegment(false);
PS->SendAction(A);
}
void PContextActions_t::RandomVelocity(const pDomain &dom)
{
PARandomVelocity *A = new PARandomVelocity;
A->gen_vel = dom.copy();
A->SetKillsParticles(false);
A->SetDoNotSegment(false);
PS->SendAction(A);
}
void PContextActions_t::RandomRotVelocity(const pDomain &dom)
{
PARandomRotVelocity *A = new PARandomRotVelocity;
A->gen_vel = dom.copy();
A->SetKillsParticles(false);
A->SetDoNotSegment(false);
PS->SendAction(A);
}
void PContextActions_t::Restore(const float time_left, const bool vel, const bool rvel)
{
PARestore *A = new PARestore;
A->time_left = time_left;
A->restore_velocity = vel;
A->restore_rvelocity = rvel;
A->SetKillsParticles(false);
A->SetDoNotSegment(false);
PS->SendAction(A);
}
void PContextActions_t::Sink(const bool kill_inside, const pDomain &dom)
{
PASink *A = new PASink;
A->position = dom.copy();
A->kill_inside = kill_inside;
A->SetKillsParticles(true);
A->SetDoNotSegment(false);
PS->SendAction(A);
}
void PContextActions_t::SinkVelocity(const bool kill_inside, const pDomain &dom)
{
PASinkVelocity *A = new PASinkVelocity;
A->velocity = dom.copy();
A->kill_inside = kill_inside;
A->SetKillsParticles(true);
A->SetDoNotSegment(false);
PS->SendAction(A);
}
void PContextActions_t::Sort(const pVec &eye, const pVec &look, const bool front_to_back, const bool clamp_negative)
{
PASort *A = new PASort;
A->Eye = eye;
A->Look= look;
A->front_to_back = front_to_back;
A->clamp_negative = clamp_negative;
A->SetKillsParticles(false);
A->SetDoNotSegment(true); // WARNING: Particles aren't a function of other particles, but since it can screw up the working set thing, I'm setting it true.
PS->SendAction(A);
}
void PContextActions_t::Source(const float particle_rate, const pDomain &dom)
{
PASource *A = new PASource;
A->position = dom.copy();
A->particle_rate = particle_rate;
A->SrcSt.set(PS->SrcSt);
A->SetKillsParticles(false);
A->SetDoNotSegment(true); // WARNING: Particles aren't a function of other particles, but does affect the working sets optimizations
PS->SendAction(A);
}
void PContextActions_t::SpeedLimit(const float min_speed, const float max_speed)
{
PASpeedLimit *A = new PASpeedLimit;
A->min_speed = min_speed;
A->max_speed = max_speed;
A->SetKillsParticles(false);
A->SetDoNotSegment(false);
PS->SendAction(A);
}
void PContextActions_t::TargetColor(const pVec &color, const float alpha, const float scale)
{
PATargetColor *A = new PATargetColor;
A->color = color;
A->alpha = alpha;
A->scale = scale;
A->SetKillsParticles(false);
A->SetDoNotSegment(false);
PS->SendAction(A);
}
void PContextActions_t::TargetSize(const pVec &size, const pVec &scale)
{
PATargetSize *A = new PATargetSize;
A->size = size;
A->scale = scale;
A->SetKillsParticles(false);
A->SetDoNotSegment(false);
PS->SendAction(A);
}
void PContextActions_t::TargetVelocity(const pVec &vel, const float scale)
{
PATargetVelocity *A = new PATargetVelocity;
A->velocity = vel;
A->scale = scale;
A->SetKillsParticles(false);
A->SetDoNotSegment(false);
PS->SendAction(A);
}
void PContextActions_t::TargetRotVelocity(const pVec &vel, const float scale)
{
PATargetRotVelocity *A = new PATargetRotVelocity;
A->velocity = vel;
A->scale = scale;
A->SetKillsParticles(false);
A->SetDoNotSegment(false);
PS->SendAction(A);
}
// If in immediate mode, quickly add a vertex.
// If building an action list, call Source().
void PContextActions_t::Vertex(const pVec &pos, const puint64 data)
{
if(PS->in_new_list) {
Source(1, PDPoint(pos));
return;
}
// Immediate mode. Quickly add the vertex.
Particle_t P;
P.pos = pos;
P.posB = PS->SrcSt.vertexB_tracks ? pos : PS->SrcSt.VertexB->Generate();
P.size = PS->SrcSt.Size->Generate();
P.up = PS->SrcSt.Up->Generate();
P.vel = PS->SrcSt.Vel->Generate();
P.rvel = PS->SrcSt.RotVel->Generate();
P.color = PS->SrcSt.Color->Generate();
P.alpha = PS->SrcSt.Alpha->Generate().x();
P.age = PS->SrcSt.Age + pNRandf(PS->SrcSt.AgeSigma);
P.mass = PS->SrcSt.Mass;
P.data = data;
// Note that we pass in the particle user data of the Vertex call, even if it's the default value.
// We don't pass the PS->SrcSt data. Note that this creates an inconsistency if building an action list.
PS->PGroups[PS->pgroup_id].Add(P);
}
void PContextActions_t::Vortex(
const pVec ¢er, ///< tip of the vortex
const pVec &axis, ///< the ray along the center of the vortex
const float tightnessExponent, ///< like a Phong exponent that gives a curve to the vortex silhouette; 1.8 is good.
const float max_radius, ///< defines the infinite cylinder of influence of this action. No particle further than max_radius from the axis is affected.
const float inSpeed, ///< inward acceleration of particles outside the vortex
const float upSpeed, ///< vertical acceleration of particles inside the vortex. Can be negative to counteract gravity.
const float aroundSpeed) ///< acceleration around vortex of particles inside the vortex
{
PAVortex *A = new PAVortex;
A->tip = center;
A->axis = axis;
A->tightnessExponent = tightnessExponent;
A->max_radius = max_radius;
A->inSpeed = inSpeed;
A->upSpeed = upSpeed;
A->aroundSpeed = aroundSpeed;
A->SetKillsParticles(false);
A->SetDoNotSegment(false);
PS->SendAction(A);
}
};
| 24.51927
| 162
| 0.669838
|
ehsankamrani
|
7356ec7988fe8e9febc6102713b570ffe9912f4f
| 5,975
|
cpp
|
C++
|
3rdparty/GPSTk/ext/lib/Procframe/GravitationalDelay.cpp
|
mfkiwl/ICE
|
e660d031bb1bcea664db1de4946fd8781be5b627
|
[
"MIT"
] | 50
|
2019-10-12T01:22:20.000Z
|
2022-02-15T23:28:26.000Z
|
3rdparty/GPSTk/ext/lib/Procframe/GravitationalDelay.cpp
|
wuyou33/Enabling-Robust-State-Estimation-through-Measurement-Error-Covariance-Adaptation
|
2f1ff054b7c5059da80bb3b2f80c05861a02cc36
|
[
"MIT"
] | null | null | null |
3rdparty/GPSTk/ext/lib/Procframe/GravitationalDelay.cpp
|
wuyou33/Enabling-Robust-State-Estimation-through-Measurement-Error-Covariance-Adaptation
|
2f1ff054b7c5059da80bb3b2f80c05861a02cc36
|
[
"MIT"
] | 14
|
2019-11-05T01:50:29.000Z
|
2021-08-06T06:23:44.000Z
|
//============================================================================
//
// 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 3.0 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
// Dagoberto Salazar - gAGE ( http://www.gage.es ). 2008, 2011
//
//============================================================================
//============================================================================
//
//This software developed by Applied Research Laboratories at the University of
//Texas at Austin, under contract to an agency or agencies within the U.S.
//Department of Defense. The U.S. Government retains all rights to use,
//duplicate, distribute, disclose, or release this software.
//
//Pursuant to DoD Directive 523024
//
// DISTRIBUTION STATEMENT A: This software has been approved for public
// release, distribution is unlimited.
//
//=============================================================================
/**
* @file GravitationalDelay.cpp
* This class computes the delay in the signal due to changes in gravity field.
*/
#include "GravitationalDelay.hpp"
namespace gpstk
{
// Returns a string identifying this object.
std::string GravitationalDelay::getClassName() const
{ return "GravitationalDelay"; }
// Constant value needed for computation. This value comes from:
// K = (1+gamma) muE / (c*c)
// where:
// - gamma = 1.0 (general relativity)
// - muE = 3.986004418e14 m^3/s^2 (std gravitational parameter, Earth)
// - c = 2.99792458e8 m/s (speed of light)
const double K = 0.887005608e-2;
/* Returns a satTypeValueMap object, adding the new data generated
* when calling this object.
*
* @param epoch Time of observations.
* @param gData Data object holding the data.
*/
satTypeValueMap& GravitationalDelay::Process( const CommonTime& epoch,
satTypeValueMap& gData )
throw(ProcessingException)
{
try
{
SatIDSet satRejectedSet;
// Define a Triple that will hold satellite position, in ECEF
Triple svPos(0.0, 0.0, 0.0);
// Loop through all the satellites
satTypeValueMap::iterator it;
for (it = gData.begin(); it != gData.end(); ++it)
{
// Check if satellite position is not already computed
if( ( (*it).second.find(TypeID::satX) == (*it).second.end() ) ||
( (*it).second.find(TypeID::satY) == (*it).second.end() ) ||
( (*it).second.find(TypeID::satZ) == (*it).second.end() ) )
{
// If satellite position is missing, then schedule this
// satellite for removal
satRejectedSet.insert( (*it).first );
continue;
}
else
{
// Get satellite position out of GDS
svPos[0] = (*it).second[TypeID::satX];
svPos[1] = (*it).second[TypeID::satY];
svPos[2] = (*it).second[TypeID::satZ];
} // End of 'if( ( (*it).second.find(TypeID::satX) == ...'
// Get magnitude of satellite position vector
double r2(svPos.mag());
// Get vector from Earth mass center to receiver
Triple rxPos(nominalPos.X(), nominalPos.Y(), nominalPos.Z());
// Compute magnitude of receiver position vector
double r1(rxPos.mag());
// Compute the difference vector between satellite and
// receiver positions
Position difPos(svPos - rxPos);
// Compute magnitude of the diference between rxPos and svPos
double r12( difPos.mag() );
// Compute gravitational delay correction
double gravDel( K*std::log( (r1+r2+r12)/(r1+r2-r12) ) );
// Get the correction into the GDS
(*it).second[TypeID::gravDelay] = gravDel;
} // End of 'for (it = gData.begin(); it != gData.end(); ++it)'
// Remove satellites with missing data
gData.removeSatID(satRejectedSet);
return gData;
}
catch(Exception& u)
{
// Throw an exception if something unexpected happens
ProcessingException e( getClassName() + ":"
+ u.what() );
GPSTK_THROW(e);
}
} // End of method 'GravitationalDelay::Process()'
/* Returns a gnnsRinex object, adding the new data generated when
* calling this object.
*
* @param gData Data object holding the data.
*/
gnssRinex& GravitationalDelay::Process(gnssRinex& gData)
throw(ProcessingException)
{
try
{
Process(gData.header.epoch, gData.body);
return gData;
}
catch(Exception& u)
{
// Throw an exception if something unexpected happens
ProcessingException e( getClassName() + ":"
+ u.what() );
GPSTK_THROW(e);
}
} // End of method 'GravitationalDelay::Process()'
} // End of namespace gpstk
| 31.951872
| 79
| 0.553138
|
mfkiwl
|
73572cf8f43a6a762ad86c09396af4ce7b8ed709
| 29,831
|
cpp
|
C++
|
src/signalrclient/connection_impl.cpp
|
tonerdo/SignalR-Client-Cpp
|
ea4ad5b0a50a7483aec4b4dcfd316c635ccdfdfd
|
[
"MIT"
] | null | null | null |
src/signalrclient/connection_impl.cpp
|
tonerdo/SignalR-Client-Cpp
|
ea4ad5b0a50a7483aec4b4dcfd316c635ccdfdfd
|
[
"MIT"
] | null | null | null |
src/signalrclient/connection_impl.cpp
|
tonerdo/SignalR-Client-Cpp
|
ea4ad5b0a50a7483aec4b4dcfd316c635ccdfdfd
|
[
"MIT"
] | null | null | null |
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
#include "stdafx.h"
#include <thread>
#include <algorithm>
#include "constants.h"
#include "connection_impl.h"
#include "negotiate.h"
#include "url_builder.h"
#include "trace_log_writer.h"
#include "signalrclient/signalr_exception.h"
#include "default_http_client.h"
#include "case_insensitive_comparison_utils.h"
#include "completion_event.h"
#include <assert.h>
#include "signalrclient/websocket_client.h"
#include "default_websocket_client.h"
namespace signalr
{
std::shared_ptr<connection_impl> connection_impl::create(const std::string& url, trace_level trace_level, const std::shared_ptr<log_writer>& log_writer)
{
return connection_impl::create(url, trace_level, log_writer, nullptr, nullptr, false);
}
std::shared_ptr<connection_impl> connection_impl::create(const std::string& url, trace_level trace_level, const std::shared_ptr<log_writer>& log_writer,
std::shared_ptr<http_client> http_client, std::function<std::shared_ptr<websocket_client>(const signalr_client_config&)> websocket_factory, const bool skip_negotiation)
{
return std::shared_ptr<connection_impl>(new connection_impl(url, trace_level,
log_writer ? log_writer : std::make_shared<trace_log_writer>(), http_client, websocket_factory, skip_negotiation));
}
connection_impl::connection_impl(const std::string& url, trace_level trace_level, const std::shared_ptr<log_writer>& log_writer,
std::unique_ptr<http_client> http_client, std::unique_ptr<transport_factory> transport_factory, const bool skip_negotiation)
: m_base_url(url), m_connection_state(connection_state::disconnected), m_logger(log_writer, trace_level), m_transport(nullptr),
m_transport_factory(std::move(transport_factory)), m_skip_negotiation(skip_negotiation), m_message_received([](const std::string&) noexcept {}), m_disconnected([]() noexcept {})
{
if (http_client != nullptr)
{
m_http_client = std::move(http_client);
}
else
{
#ifdef USE_CPPRESTSDK
m_http_client = std::unique_ptr<class http_client>(new default_http_client());
#endif
}
}
connection_impl::connection_impl(const std::string& url, trace_level trace_level, const std::shared_ptr<log_writer>& log_writer,
std::shared_ptr<http_client> http_client, std::function<std::shared_ptr<websocket_client>(const signalr_client_config&)> websocket_factory, const bool skip_negotiation)
: m_base_url(url), m_connection_state(connection_state::disconnected), m_logger(log_writer, trace_level), m_transport(nullptr), m_skip_negotiation(skip_negotiation),
m_message_received([](const std::string&) noexcept {}), m_disconnected([]() noexcept {})
{
if (http_client != nullptr)
{
m_http_client = std::move(http_client);
}
else
{
#ifdef USE_CPPRESTSDK
m_http_client = std::unique_ptr<class http_client>(new default_http_client());
#endif
}
if (websocket_factory == nullptr)
{
#ifdef USE_CPPRESTSDK
websocket_factory = [](const signalr_client_config& signalr_client_config) { return std::make_shared<default_websocket_client>(signalr_client_config); };
#endif
}
m_transport_factory = std::unique_ptr<transport_factory>(new transport_factory(m_http_client, websocket_factory));
}
connection_impl::~connection_impl()
{
try
{
// Signaling the event is safe here. We are in the dtor so noone is using this instance. There might be some
// outstanding threads that hold on to the connection via a weak pointer but they won't be able to acquire
// the instance since it is being destroyed. Note that the event may actually be in non-signaled state here.
m_start_completed_event.cancel();
completion_event completion;
auto logger = m_logger;
shutdown([completion, logger](std::exception_ptr exception) mutable
{
if (exception != nullptr)
{
// TODO: Log?
try
{
std::rethrow_exception(exception);
}
catch (const std::exception& e)
{
logger.log(
trace_level::errors,
std::string("shutdown threw an exception: ")
.append(e.what()));
}
catch (...)
{
logger.log(
trace_level::errors,
std::string("shutdown threw an unknown exception."));
}
}
// make sure this is last as it will unblock the destructor
completion.set();
});
completion.get();
}
catch (...) // must not throw from destructors
{ }
m_transport = nullptr;
change_state(connection_state::disconnected);
}
void connection_impl::start(std::function<void(std::exception_ptr)> callback) noexcept
{
{
std::lock_guard<std::mutex> lock(m_stop_lock);
if (!change_state(connection_state::disconnected, connection_state::connecting))
{
callback(std::make_exception_ptr(signalr_exception("cannot start a connection that is not in the disconnected state")));
return;
}
// there should not be any active transport at this point
assert(!m_transport);
m_disconnect_cts = std::make_shared<cancellation_token>();
m_start_completed_event.reset();
m_connection_id = "";
}
start_negotiate(m_base_url, 0, callback);
}
void connection_impl::start_negotiate(const std::string& url, int redirect_count, std::function<void(std::exception_ptr)> callback)
{
if (redirect_count >= MAX_NEGOTIATE_REDIRECTS)
{
change_state(connection_state::disconnected);
m_start_completed_event.cancel();
callback(std::make_exception_ptr(signalr_exception("Negotiate redirection limit exceeded.")));
return;
}
std::weak_ptr<connection_impl> weak_connection = shared_from_this();
const auto& token = m_disconnect_cts;
const auto transport_started = [weak_connection, callback, token](std::shared_ptr<transport> transport, std::exception_ptr exception)
{
auto connection = weak_connection.lock();
if (!connection)
{
callback(std::make_exception_ptr(signalr_exception("connection no longer exists")));
return;
}
try
{
if (exception != nullptr)
{
std::rethrow_exception(exception);
}
token->throw_if_cancellation_requested();
}
catch (const std::exception& e)
{
if (token->is_canceled())
{
connection->m_logger.log(trace_level::info,
"starting the connection has been canceled.");
}
else
{
connection->m_logger.log(trace_level::errors,
std::string("connection could not be started due to: ")
.append(e.what()));
}
connection->m_transport = nullptr;
connection->change_state(connection_state::disconnected);
connection->m_start_completed_event.cancel();
callback(std::current_exception());
return;
}
connection->m_transport = transport;
if (!connection->change_state(connection_state::connecting, connection_state::connected))
{
connection->m_logger.log(trace_level::errors,
std::string("internal error - transition from an unexpected state. expected state: connecting, actual state: ")
.append(translate_connection_state(connection->get_connection_state())));
assert(false);
}
connection->m_start_completed_event.cancel();
callback(nullptr);
};
if (m_skip_negotiation)
{
// TODO: check that the websockets transport is explicitly selected
return start_transport(url, transport_started);
}
negotiate::negotiate(*m_http_client, url, m_signalr_client_config,
[callback, weak_connection, redirect_count, token, url, transport_started](negotiation_response&& response, std::exception_ptr exception)
{
auto connection = weak_connection.lock();
if (!connection)
{
callback(std::make_exception_ptr(signalr_exception("connection no longer exists")));
return;
}
if (exception != nullptr)
{
try
{
std::rethrow_exception(exception);
}
catch (const std::exception& e)
{
connection->m_logger.log(trace_level::errors,
std::string("connection could not be started due to: ")
.append(e.what()));
}
connection->change_state(connection_state::disconnected);
connection->m_start_completed_event.cancel();
callback(exception);
return;
}
if (!response.error.empty())
{
connection->change_state(connection_state::disconnected);
connection->m_start_completed_event.cancel();
callback(std::make_exception_ptr(signalr_exception(response.error)));
return;
}
if (!response.url.empty())
{
if (!response.accessToken.empty())
{
auto& headers = connection->m_signalr_client_config.get_http_headers();
headers["Authorization"] = "Bearer " + response.accessToken;
}
connection->start_negotiate(response.url, redirect_count + 1, callback);
return;
}
connection->m_connection_id = std::move(response.connectionId);
connection->m_connection_token = std::move(response.connectionToken);
// TODO: fallback logic
bool foundWebsockets = false;
for (auto& availableTransport : response.availableTransports)
{
case_insensitive_equals comparer;
if (comparer(availableTransport.transport, "WebSockets"))
{
foundWebsockets = true;
break;
}
}
if (!foundWebsockets)
{
connection->change_state(connection_state::disconnected);
connection->m_start_completed_event.cancel();
callback(std::make_exception_ptr(signalr_exception("The server does not support WebSockets which is currently the only transport supported by this client.")));
return;
}
// TODO: use transfer format
if (token->is_canceled())
{
connection->change_state(connection_state::disconnected);
callback(std::make_exception_ptr(canceled_exception()));
return;
}
connection->start_transport(url, transport_started);
});
}
void connection_impl::start_transport(const std::string& url, std::function<void(std::shared_ptr<transport>, std::exception_ptr)> callback)
{
auto connection = shared_from_this();
std::shared_ptr<bool> connect_request_done = std::make_shared<bool>();
std::shared_ptr<std::mutex> connect_request_lock = std::make_shared<std::mutex>();
auto weak_connection = std::weak_ptr<connection_impl>(connection);
const auto& disconnect_cts = m_disconnect_cts;
const auto& logger = m_logger;
auto transport = connection->m_transport_factory->create_transport(
transport_type::websockets, connection->m_logger, connection->m_signalr_client_config);
transport->on_close([weak_connection](std::exception_ptr exception)
{
auto connection = weak_connection.lock();
if (!connection)
{
return;
}
// close callback will only be called if start on the transport has already returned
// wait for the event in order to avoid a race where the state hasn't changed from connecting
// yet and the transport errors out
connection->m_start_completed_event.wait();
connection->stop_connection(exception);
});
transport->on_receive([disconnect_cts, connect_request_done, connect_request_lock, logger, weak_connection, callback](std::string&& message, std::exception_ptr exception)
{
if (exception == nullptr)
{
if (disconnect_cts->is_canceled())
{
logger.log(trace_level::info,
std::string{ "ignoring stray message received after connection was restarted. message: " }
.append(message));
return;
}
auto connection = weak_connection.lock();
if (connection)
{
connection->process_response(std::move(message));
}
}
else
{
try
{
// Rethrowing the exception so we can log it
std::rethrow_exception(exception);
}
catch (const std::exception & e)
{
// When a connection is stopped we don't wait for its transport to stop. As a result if the same connection
// is immediately re-started the old transport can still invoke this callback. To prevent this we capture
// the disconnect_cts by value which allows distinguishing if the error is for the running connection
// or for the one that was already stopped. If this is the latter we just ignore it.
if (disconnect_cts->is_canceled())
{
logger.log(trace_level::info,
std::string{ "ignoring stray error received after connection was restarted. error: " }
.append(e.what()));
return;
}
bool run_callback = false;
{
std::lock_guard<std::mutex> lock(*connect_request_lock);
// no op after connection started successfully
if (*connect_request_done == false)
{
*connect_request_done = true;
run_callback = true;
}
}
if (run_callback)
{
callback({}, exception);
}
}
}
});
std::thread([disconnect_cts, connect_request_done, connect_request_lock, callback, weak_connection]()
{
disconnect_cts->wait(5000);
bool run_callback = false;
{
std::lock_guard<std::mutex> lock(*connect_request_lock);
// no op after connection started successfully
if (*connect_request_done == false)
{
*connect_request_done = true;
run_callback = true;
}
}
// if the disconnect_cts is canceled it means that the connection has been stopped or went out of scope in
// which case we should not throw due to timeout.
if (disconnect_cts->is_canceled())
{
if (run_callback)
{
// The callback checks the disconnect_cts token and will handle it appropriately
callback({}, nullptr);
}
}
else
{
if (run_callback)
{
callback({}, std::make_exception_ptr(signalr_exception("transport timed out when trying to connect")));
}
}
}).detach();
connection->send_connect_request(transport, url, [callback, connect_request_done, connect_request_lock, transport](std::exception_ptr exception)
{
bool run_callback = false;
{
std::lock_guard<std::mutex> lock(*connect_request_lock);
// no op after connection started successfully
if (*connect_request_done == false)
{
*connect_request_done = true;
run_callback = true;
}
}
if (run_callback)
{
if (exception == nullptr)
{
callback(transport, nullptr);
}
else
{
callback({}, exception);
}
}
});
}
void connection_impl::send_connect_request(const std::shared_ptr<transport>& transport, const std::string& url, std::function<void(std::exception_ptr)> callback)
{
auto logger = m_logger;
auto query_string = "id=" + m_connection_token;
auto connect_url = url_builder::build_connect(url, transport->get_transport_type(), query_string);
transport->start(connect_url, transfer_format::text, [callback, logger](std::exception_ptr exception)
mutable {
try
{
if (exception != nullptr)
{
std::rethrow_exception(exception);
}
callback(nullptr);
}
catch (const std::exception& e)
{
logger.log(
trace_level::errors,
std::string("transport could not connect due to: ")
.append(e.what()));
callback(exception);
}
});
}
void connection_impl::process_response(std::string&& response)
{
m_logger.log(trace_level::messages,
std::string("processing message: ").append(response));
invoke_message_received(std::move(response));
}
void connection_impl::invoke_message_received(std::string&& message)
{
try
{
m_message_received(std::move(message));
}
catch (const std::exception &e)
{
m_logger.log(
trace_level::errors,
std::string("message_received callback threw an exception: ")
.append(e.what()));
}
catch (...)
{
m_logger.log(trace_level::errors, "message_received callback threw an unknown exception");
}
}
void connection_impl::send(const std::string& data, std::function<void(std::exception_ptr)> callback) noexcept
{
// To prevent an (unlikely) condition where the transport is nulled out after we checked the connection_state
// and before sending data we store the pointer in the local variable. In this case `send()` will throw but
// we won't crash.
auto transport = m_transport;
const auto connection_state = get_connection_state();
if (connection_state != signalr::connection_state::connected || !transport)
{
callback(std::make_exception_ptr(signalr_exception(
std::string("cannot send data when the connection is not in the connected state. current connection state: ")
.append(translate_connection_state(connection_state)))));
return;
}
auto logger = m_logger;
logger.log(trace_level::info, std::string("sending data: ").append(data));
transport->send(data, [logger, callback](std::exception_ptr exception)
mutable {
try
{
if (exception != nullptr)
{
std::rethrow_exception(exception);
}
callback(nullptr);
}
catch (const std::exception &e)
{
logger.log(
trace_level::errors,
std::string("error sending data: ")
.append(e.what()));
callback(exception);
}
});
}
void connection_impl::stop(std::function<void(std::exception_ptr)> callback) noexcept
{
m_logger.log(trace_level::info, "stopping connection");
shutdown(callback);
}
// This function is called from the dtor so you must not use `shared_from_this` here (it will throw).
void connection_impl::shutdown(std::function<void(std::exception_ptr)> callback)
{
{
std::lock_guard<std::mutex> lock(m_stop_lock);
m_logger.log(trace_level::info, "acquired lock in shutdown()");
const auto current_state = get_connection_state();
if (current_state == connection_state::disconnected)
{
callback(nullptr);
return;
}
if (current_state == connection_state::disconnecting)
{
// canceled task will be returned if `stop` was called while another `stop` was already in progress.
// This is to prevent from resetting the `m_transport` in the upstream callers because doing so might
// affect the other invocation which is using it.
callback(std::make_exception_ptr(canceled_exception()));
return;
}
// we request a cancellation of the ongoing start (if any) and wait until it is canceled
m_disconnect_cts->cancel();
while (m_start_completed_event.wait(60000) != 0)
{
m_logger.log(trace_level::errors,
"internal error - stopping the connection is still waiting for the start operation to finish which should have already finished or timed out");
}
// at this point we are either in the connected or disconnected state. If we are in the disconnected state
// we must break because the transport has already been nulled out.
if (m_connection_state == connection_state::disconnected)
{
callback(nullptr);
return;
}
assert(m_connection_state == connection_state::connected);
change_state(connection_state::disconnecting);
}
m_transport->stop(callback);
}
// do not use `shared_from_this` as it can be called via the destructor
void connection_impl::stop_connection(std::exception_ptr error)
{
{
// the lock prevents a race where the user calls `stop` on a disconnected connection and calls `start`
// on a different thread at the same time. In this case we must not null out the transport if we are
// not in the `disconnecting` state to not affect the 'start' invocation.
std::lock_guard<std::mutex> lock(m_stop_lock);
if (m_connection_state == connection_state::disconnected)
{
m_logger.log(trace_level::info, "Stopping was ignored because the connection is already in the disconnected state.");
return;
}
change_state(connection_state::disconnected);
m_transport = nullptr;
}
if (error)
{
try
{
std::rethrow_exception(error);
}
catch (const std::exception & ex)
{
m_logger.log(trace_level::errors, std::string("Connection closed with error: ").append(ex.what()));
}
}
else
{
m_logger.log(trace_level::info, "Connection closed.");
}
try
{
m_disconnected();
}
catch (const std::exception & e)
{
m_logger.log(
trace_level::errors,
std::string("disconnected callback threw an exception: ")
.append(e.what()));
}
catch (...)
{
m_logger.log(
trace_level::errors,
std::string("disconnected callback threw an unknown exception"));
}
}
connection_state connection_impl::get_connection_state() const noexcept
{
return m_connection_state.load();
}
std::string connection_impl::get_connection_id() const noexcept
{
if (m_connection_state.load() == connection_state::connecting)
{
return "";
}
return m_connection_id;
}
void connection_impl::set_message_received(const std::function<void(std::string&&)>& message_received)
{
ensure_disconnected("cannot set the callback when the connection is not in the disconnected state. ");
m_message_received = message_received;
}
void connection_impl::set_client_config(const signalr_client_config& config)
{
ensure_disconnected("cannot set client config when the connection is not in the disconnected state. ");
m_signalr_client_config = config;
}
void connection_impl::set_disconnected(const std::function<void()>& disconnected)
{
ensure_disconnected("cannot set the disconnected callback when the connection is not in the disconnected state. ");
m_disconnected = disconnected;
}
void connection_impl::ensure_disconnected(const std::string& error_message) const
{
const auto state = get_connection_state();
if (state != connection_state::disconnected)
{
throw signalr_exception(
error_message + "current connection state: " + translate_connection_state(state));
}
}
bool connection_impl::change_state(connection_state old_state, connection_state new_state)
{
if (m_connection_state.compare_exchange_strong(old_state, new_state, std::memory_order_seq_cst))
{
handle_connection_state_change(old_state, new_state);
return true;
}
return false;
}
connection_state connection_impl::change_state(connection_state new_state)
{
auto old_state = m_connection_state.exchange(new_state);
if (old_state != new_state)
{
handle_connection_state_change(old_state, new_state);
}
return old_state;
}
void connection_impl::handle_connection_state_change(connection_state old_state, connection_state new_state)
{
m_logger.log(
trace_level::state_changes,
translate_connection_state(old_state)
.append(" -> ")
.append(translate_connection_state(new_state)));
// Words of wisdom (if we decide to add a state_changed callback and invoke it from here):
// "Be extra careful when you add this callback, because this is sometimes being called with the m_stop_lock.
// This could lead to interesting problems.For example, you could run into a segfault if the connection is
// stopped while / after transitioning into the connecting state."
}
std::string connection_impl::translate_connection_state(connection_state state)
{
switch (state)
{
case connection_state::connecting:
return "connecting";
case connection_state::connected:
return "connected";
case connection_state::disconnecting:
return "disconnecting";
case connection_state::disconnected:
return "disconnected";
default:
assert(false);
return "(unknown)";
}
}
}
| 39.511258
| 185
| 0.554457
|
tonerdo
|
735739922baebe75d65a9e4911c708981faf4497
| 1,569
|
hpp
|
C++
|
SDK/ARKSurvivalEvolved_Buff_BrainSlugShoulderVisualCient_classes.hpp
|
2bite/ARK-SDK
|
c38ca9925309516b2093ad8c3a70ed9489e1d573
|
[
"MIT"
] | 10
|
2020-02-17T19:08:46.000Z
|
2021-07-31T11:07:19.000Z
|
SDK/ARKSurvivalEvolved_Buff_BrainSlugShoulderVisualCient_classes.hpp
|
2bite/ARK-SDK
|
c38ca9925309516b2093ad8c3a70ed9489e1d573
|
[
"MIT"
] | 9
|
2020-02-17T18:15:41.000Z
|
2021-06-06T19:17:34.000Z
|
SDK/ARKSurvivalEvolved_Buff_BrainSlugShoulderVisualCient_classes.hpp
|
2bite/ARK-SDK
|
c38ca9925309516b2093ad8c3a70ed9489e1d573
|
[
"MIT"
] | 3
|
2020-07-22T17:42:07.000Z
|
2021-06-19T17:16:13.000Z
|
#pragma once
// ARKSurvivalEvolved (329.9) SDK
#ifdef _MSC_VER
#pragma pack(push, 0x8)
#endif
#include "ARKSurvivalEvolved_Buff_BrainSlugShoulderVisualCient_structs.hpp"
namespace sdk
{
//---------------------------------------------------------------------------
//Classes
//---------------------------------------------------------------------------
// BlueprintGeneratedClass Buff_BrainSlugShoulderVisualCient.Buff_BrainSlugShoulderVisualCient_C
// 0x0014 (0x0974 - 0x0960)
class ABuff_BrainSlugShoulderVisualCient_C : public ABuff_Base_C
{
public:
struct FLinearColor CrosshairColor; // 0x0960(0x0010) (Edit, BlueprintVisible, ZeroConstructor, DisableEditOnInstance, IsPlainOldData)
float K2Node_Event_DeltaTime; // 0x0970(0x0004) (ZeroConstructor, Transient, DuplicateTransient, IsPlainOldData)
static UClass* StaticClass()
{
static auto ptr = UObject::FindClass("BlueprintGeneratedClass Buff_BrainSlugShoulderVisualCient.Buff_BrainSlugShoulderVisualCient_C");
return ptr;
}
void BPGetHUDElements(class APlayerController** ForPC, TArray<struct FHUDElement>* OutElements);
void STATIC_DrawBuffFloatingHUD(int* BuffIndex, class AShooterHUD** HUD, float* CenterX, float* CenterY, float* DrawScale);
void UserConstructionScript();
void BuffTickClient(float* DeltaTime);
void ExecuteUbergraph_Buff_BrainSlugShoulderVisualCient(int EntryPoint);
};
}
#ifdef _MSC_VER
#pragma pack(pop)
#endif
| 34.866667
| 208
| 0.656469
|
2bite
|
73587308ae31a021d44997a9a43e4ed92ec3cc01
| 16,573
|
cc
|
C++
|
chrome/browser/android/vr_shell/vr_shell_renderer.cc
|
xzhan96/chromium.src
|
1bd0cf3997f947746c0fc5406a2466e7b5f6159e
|
[
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | 1
|
2021-01-07T18:51:03.000Z
|
2021-01-07T18:51:03.000Z
|
chrome/browser/android/vr_shell/vr_shell_renderer.cc
|
emilio/chromium.src
|
1bd0cf3997f947746c0fc5406a2466e7b5f6159e
|
[
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | null | null | null |
chrome/browser/android/vr_shell/vr_shell_renderer.cc
|
emilio/chromium.src
|
1bd0cf3997f947746c0fc5406a2466e7b5f6159e
|
[
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | null | null | null |
// Copyright 2016 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 "chrome/browser/android/vr_shell/vr_shell_renderer.h"
#include "chrome/browser/android/vr_shell/vr_gl_util.h"
namespace {
#define RECTANGULAR_TEXTURE_BUFFER(left, right, bottom, top) \
{ left, bottom, left, top, right, bottom, left, top, right, top, right, \
bottom }
static constexpr float kHalfHeight = 0.5f;
static constexpr float kHalfWidth = 0.5f;
static constexpr float kTextureQuadPosition[18] = {
-kHalfWidth, kHalfHeight, 0.0f, -kHalfWidth, -kHalfHeight, 0.0f,
kHalfWidth, kHalfHeight, 0.0f, -kHalfWidth, -kHalfHeight, 0.0f,
kHalfWidth, -kHalfHeight, 0.0f, kHalfWidth, kHalfHeight, 0.0f};
static constexpr int kPositionDataSize = 3;
// Number of vertices passed to glDrawArrays().
static constexpr int kVerticesNumber = 6;
static constexpr float kTexturedQuadTextureCoordinates[12] =
RECTANGULAR_TEXTURE_BUFFER(0.0f, 1.0f, 0.0f, 1.0f);
static constexpr int kTextureCoordinateDataSize = 2;
static constexpr float kWebVrVertices[16] = {
// x y u, v
-1.f, 1.f, 0.f, 0.f,
-1.f, -1.f, 0.f, 1.f,
1.f, -1.f, 1.f, 1.f,
1.f, 1.f, 1.f, 0.f };
static constexpr int kWebVrVerticesSize = sizeof(float) * 16;
// Reticle constants
static constexpr float kRingDiameter = 1.0f;
static constexpr float kInnerHole = 0.0f;
static constexpr float kInnerRingEnd = 0.177f;
static constexpr float kInnerRingThickness = 0.14f;
static constexpr float kMidRingEnd = 0.177f;
static constexpr float kMidRingOpacity = 0.22f;
static constexpr float kReticleColor[] = {1.0f, 1.0f, 1.0f, 1.0f};
// Laser constants
static constexpr float kFadeEnd = 0.535;
static constexpr float kFadePoint = 0.5335;
static constexpr float kLaserColor[] = {1.0f, 1.0f, 1.0f, 0.5f};
static constexpr int kLaserDataWidth = 48;
static constexpr int kLaserDataHeight = 1;
// Laser texture data, 48x1 RGBA.
// TODO(mthiesse): As we add more resources for VR Shell, we should put them
// in Chrome's resource files.
static const unsigned char kLaserData[] =
"\xff\xff\xff\x01\xff\xff\xff\x02\xbf\xbf\xbf\x04\xcc\xcc\xcc\x05\xdb\xdb"
"\xdb\x07\xcc\xcc\xcc\x0a\xd8\xd8\xd8\x0d\xd2\xd2\xd2\x11\xce\xce\xce\x15"
"\xce\xce\xce\x1a\xce\xce\xce\x1f\xcd\xcd\xcd\x24\xc8\xc8\xc8\x2a\xc9\xc9"
"\xc9\x2f\xc9\xc9\xc9\x34\xc9\xc9\xc9\x39\xc9\xc9\xc9\x3d\xc8\xc8\xc8\x41"
"\xcb\xcb\xcb\x44\xee\xee\xee\x87\xfa\xfa\xfa\xc8\xf9\xf9\xf9\xc9\xf9\xf9"
"\xf9\xc9\xfa\xfa\xfa\xc9\xfa\xfa\xfa\xc9\xf9\xf9\xf9\xc9\xf9\xf9\xf9\xc9"
"\xfa\xfa\xfa\xc8\xee\xee\xee\x87\xcb\xcb\xcb\x44\xc8\xc8\xc8\x41\xc9\xc9"
"\xc9\x3d\xc9\xc9\xc9\x39\xc9\xc9\xc9\x34\xc9\xc9\xc9\x2f\xc8\xc8\xc8\x2a"
"\xcd\xcd\xcd\x24\xce\xce\xce\x1f\xce\xce\xce\x1a\xce\xce\xce\x15\xd2\xd2"
"\xd2\x11\xd8\xd8\xd8\x0d\xcc\xcc\xcc\x0a\xdb\xdb\xdb\x07\xcc\xcc\xcc\x05"
"\xbf\xbf\xbf\x04\xff\xff\xff\x02\xff\xff\xff\x01";
#define SHADER(Src) #Src
#define OEIE_SHADER(Src) "#extension GL_OES_EGL_image_external : require\n" #Src
#define VOID_OFFSET(x) reinterpret_cast<void*>(x)
const char* GetShaderSource(vr_shell::ShaderID shader) {
switch (shader) {
case vr_shell::ShaderID::TEXTURE_QUAD_VERTEX_SHADER:
case vr_shell::ShaderID::RETICLE_VERTEX_SHADER:
case vr_shell::ShaderID::LASER_VERTEX_SHADER:
return SHADER(uniform mat4 u_CombinedMatrix;
attribute vec4 a_Position;
attribute vec2 a_TexCoordinate;
varying vec2 v_TexCoordinate;
void main() {
v_TexCoordinate = a_TexCoordinate;
gl_Position = u_CombinedMatrix * a_Position;
});
case vr_shell::ShaderID::TEXTURE_QUAD_FRAGMENT_SHADER:
return OEIE_SHADER(
precision highp float;
uniform samplerExternalOES u_Texture;
uniform vec4 u_CopyRect; // rectangle
varying vec2 v_TexCoordinate;
void main() {
vec2 scaledTex =
vec2(u_CopyRect[0] + v_TexCoordinate.x * u_CopyRect[2],
u_CopyRect[1] + v_TexCoordinate.y * u_CopyRect[3]);
gl_FragColor = texture2D(u_Texture, scaledTex);
});
case vr_shell::ShaderID::WEBVR_VERTEX_SHADER:
return SHADER(
attribute vec4 a_Position;
varying vec2 v_TexCoordinate;
void main() {
// Pack the texcoord into the position to avoid state changes.
v_TexCoordinate = a_Position.zw;
gl_Position = vec4(a_Position.xy, 0.0, 1.0);
});
case vr_shell::ShaderID::WEBVR_FRAGMENT_SHADER:
return OEIE_SHADER(
precision highp float;
uniform samplerExternalOES u_Texture;
varying vec2 v_TexCoordinate;
void main() {
gl_FragColor = texture2D(u_Texture, v_TexCoordinate);
});
case vr_shell::ShaderID::RETICLE_FRAGMENT_SHADER:
return SHADER(
varying mediump vec2 v_TexCoordinate;
uniform lowp vec4 color;
uniform mediump float ring_diameter;
uniform mediump float inner_hole;
uniform mediump float inner_ring_end;
uniform mediump float inner_ring_thickness;
uniform mediump float mid_ring_end;
uniform mediump float mid_ring_opacity;
void main() {
mediump float r = length(v_TexCoordinate - vec2(0.5, 0.5));
mediump float color_radius = inner_ring_end * ring_diameter;
mediump float color_feather_radius =
inner_ring_thickness * ring_diameter;
mediump float hole_radius =
inner_hole * ring_diameter - color_feather_radius;
mediump float color1 = clamp(
1.0 - (r - color_radius) / color_feather_radius, 0.0, 1.0);
mediump float hole_alpha =
clamp((r - hole_radius) / color_feather_radius, 0.0, 1.0);
mediump float black_radius = mid_ring_end * ring_diameter;
mediump float black_feather =
1.0 / (ring_diameter * 0.5 - black_radius);
mediump float black_alpha_factor =
mid_ring_opacity * (1.0 - (r - black_radius) * black_feather);
mediump float alpha = clamp(
min(hole_alpha, max(color1, black_alpha_factor)), 0.0, 1.0);
lowp vec3 color_rgb = color1 * color.xyz;
gl_FragColor = vec4(color_rgb, color.w * alpha);
});
case vr_shell::ShaderID::LASER_FRAGMENT_SHADER:
return SHADER(
varying mediump vec2 v_TexCoordinate;
uniform sampler2D texture_unit;
uniform lowp vec4 color;
uniform mediump float fade_point;
uniform mediump float fade_end;
void main() {
mediump vec2 uv = v_TexCoordinate;
mediump float front_fade_factor = 1.0 -
clamp(1.0 - (uv.y - fade_point) / (1.0 - fade_point), 0.0, 1.0);
mediump float back_fade_factor =
clamp((uv.y - fade_point) / (fade_end - fade_point), 0.0, 1.0);
mediump float total_fade = front_fade_factor * back_fade_factor;
lowp vec4 texture_color = texture2D(texture_unit, uv);
lowp vec4 final_color = color * texture_color;
gl_FragColor = vec4(final_color.xyz, final_color.w * total_fade);
});
default:
LOG(ERROR) << "Shader source requested for unknown shader";
return "";
}
}
#undef RECTANGULAR_TEXTURE_BUFFER
} // namespace
namespace vr_shell {
BaseRenderer::BaseRenderer(ShaderID vertex_id, ShaderID fragment_id) {
std::string error;
GLuint vertex_shader_handle = CompileShader(
GL_VERTEX_SHADER, GetShaderSource(vertex_id), error);
CHECK(vertex_shader_handle) << error;
GLuint fragment_shader_handle = CompileShader(
GL_FRAGMENT_SHADER, GetShaderSource(fragment_id), error);
CHECK(fragment_shader_handle) << error;
program_handle_ = CreateAndLinkProgram(vertex_shader_handle,
fragment_shader_handle, error);
CHECK(program_handle_) << error;
// Once the program is linked the shader objects are no longer needed
glDeleteShader(vertex_shader_handle);
glDeleteShader(fragment_shader_handle);
position_handle_ = glGetAttribLocation(program_handle_, "a_Position");
tex_coord_handle_ = glGetAttribLocation(program_handle_, "a_TexCoordinate");
}
BaseRenderer::~BaseRenderer() = default;
void BaseRenderer::PrepareToDraw(GLuint combined_matrix_handle,
const gvr::Mat4f& combined_matrix) {
glUseProgram(program_handle_);
// Pass in model view project matrix.
glUniformMatrix4fv(combined_matrix_handle, 1, false,
MatrixToGLArray(combined_matrix).data());
// Pass in texture coordinate.
glVertexAttribPointer(tex_coord_handle_, kTextureCoordinateDataSize,
GL_FLOAT, false, 0, kTexturedQuadTextureCoordinates);
glEnableVertexAttribArray(tex_coord_handle_);
glVertexAttribPointer(position_handle_, kPositionDataSize, GL_FLOAT, false, 0,
kTextureQuadPosition);
glEnableVertexAttribArray(position_handle_);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
}
TexturedQuadRenderer::TexturedQuadRenderer()
: BaseRenderer(TEXTURE_QUAD_VERTEX_SHADER, TEXTURE_QUAD_FRAGMENT_SHADER) {
combined_matrix_handle_ =
glGetUniformLocation(program_handle_, "u_CombinedMatrix");
tex_uniform_handle_ = glGetUniformLocation(program_handle_, "u_Texture");
copy_rect_uniform_handle_ =
glGetUniformLocation(program_handle_, "u_CopyRect");
}
void TexturedQuadRenderer::Draw(int texture_data_handle,
const gvr::Mat4f& combined_matrix,
const Rectf& copy_rect) {
PrepareToDraw(combined_matrix_handle_, combined_matrix);
// Link texture data with texture unit.
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_EXTERNAL_OES, texture_data_handle);
glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glUniform1i(tex_uniform_handle_, 0);
glUniform4fv(copy_rect_uniform_handle_, 1, (float*)(©_rect));
glDrawArrays(GL_TRIANGLES, 0, kVerticesNumber);
glDisableVertexAttribArray(position_handle_);
glDisableVertexAttribArray(tex_coord_handle_);
}
TexturedQuadRenderer::~TexturedQuadRenderer() = default;
WebVrRenderer::WebVrRenderer() :
BaseRenderer(WEBVR_VERTEX_SHADER, WEBVR_FRAGMENT_SHADER) {
tex_uniform_handle_ = glGetUniformLocation(program_handle_, "u_Texture");
// TODO(bajones): Figure out why this need to be restored.
GLint old_buffer;
glGetIntegerv(GL_ARRAY_BUFFER_BINDING, &old_buffer);
glGenBuffersARB(1, &vertex_buffer_);
glBindBuffer(GL_ARRAY_BUFFER, vertex_buffer_);
glBufferData(GL_ARRAY_BUFFER, kWebVrVerticesSize, kWebVrVertices,
GL_STATIC_DRAW);
glBindBuffer(GL_ARRAY_BUFFER, old_buffer);
}
// Draw the stereo WebVR frame
void WebVrRenderer::Draw(int texture_handle) {
// TODO(bajones): Figure out why this need to be restored.
GLint old_buffer;
glGetIntegerv(GL_ARRAY_BUFFER_BINDING, &old_buffer);
glUseProgram(program_handle_);
// Bind vertex attributes
glBindBuffer(GL_ARRAY_BUFFER, vertex_buffer_);
glEnableVertexAttribArray(position_handle_);
glVertexAttribPointer(position_handle_, VERTEX_ELEMENTS, GL_FLOAT, false,
VERTEX_STRIDE, VOID_OFFSET(VERTEX_OFFSET));
// Bind texture. Ideally this should be a 1:1 pixel copy. (Or even more
// ideally, a zero copy reuse of the texture.) For now, we're using an
// undersized render target for WebVR, so GL_LINEAR makes it look slightly
// less chunky. TODO(klausw): change this to GL_NEAREST once we're doing
// a 1:1 copy since that should be more efficient.
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_EXTERNAL_OES, texture_handle);
glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glUniform1i(tex_uniform_handle_, 0);
// Blit texture to buffer
glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
glDisableVertexAttribArray(position_handle_);
glBindBuffer(GL_ARRAY_BUFFER, old_buffer);
}
// Note that we don't explicitly delete gl objects here, they're deleted
// automatically when we call ClearGLBindings, and deleting them here leads to
// segfaults.
WebVrRenderer::~WebVrRenderer() = default;
ReticleRenderer::ReticleRenderer()
: BaseRenderer(RETICLE_VERTEX_SHADER, RETICLE_FRAGMENT_SHADER) {
combined_matrix_handle_ =
glGetUniformLocation(program_handle_, "u_CombinedMatrix");
color_handle_ = glGetUniformLocation(program_handle_, "color");
ring_diameter_handle_ =
glGetUniformLocation(program_handle_, "ring_diameter");
inner_hole_handle_ = glGetUniformLocation(program_handle_, "inner_hole");
inner_ring_end_handle_ =
glGetUniformLocation(program_handle_, "inner_ring_end");
inner_ring_thickness_handle_ =
glGetUniformLocation(program_handle_, "inner_ring_thickness");
mid_ring_end_handle_ = glGetUniformLocation(program_handle_, "mid_ring_end");
mid_ring_opacity_handle_ =
glGetUniformLocation(program_handle_, "mid_ring_opacity");
}
void ReticleRenderer::Draw(const gvr::Mat4f& combined_matrix) {
PrepareToDraw(combined_matrix_handle_, combined_matrix);
glUniform4f(color_handle_, kReticleColor[0], kReticleColor[1],
kReticleColor[2], kReticleColor[3]);
glUniform1f(ring_diameter_handle_, kRingDiameter);
glUniform1f(inner_hole_handle_, kInnerHole);
glUniform1f(inner_ring_end_handle_, kInnerRingEnd);
glUniform1f(inner_ring_thickness_handle_, kInnerRingThickness);
glUniform1f(mid_ring_end_handle_, kMidRingEnd);
glUniform1f(mid_ring_opacity_handle_, kMidRingOpacity);
glDrawArrays(GL_TRIANGLES, 0, kVerticesNumber);
glDisableVertexAttribArray(position_handle_);
glDisableVertexAttribArray(tex_coord_handle_);
}
ReticleRenderer::~ReticleRenderer() = default;
LaserRenderer::LaserRenderer()
: BaseRenderer(LASER_VERTEX_SHADER, LASER_FRAGMENT_SHADER) {
combined_matrix_handle_ =
glGetUniformLocation(program_handle_, "u_CombinedMatrix");
texture_unit_handle_ =
glGetUniformLocation(program_handle_, "texture_unit");
color_handle_ = glGetUniformLocation(program_handle_, "color");
fade_point_handle_ =
glGetUniformLocation(program_handle_, "fade_point");
fade_end_handle_ = glGetUniformLocation(program_handle_, "fade_end");
glGenTextures(1, &texture_data_handle_);
glBindTexture(GL_TEXTURE_2D, texture_data_handle_);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, kLaserDataWidth, kLaserDataHeight, 0,
GL_RGBA, GL_UNSIGNED_BYTE, kLaserData);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
}
void LaserRenderer::Draw(const gvr::Mat4f& combined_matrix) {
PrepareToDraw(combined_matrix_handle_, combined_matrix);
// Link texture data with texture unit.
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, texture_data_handle_);
glUniform1i(texture_unit_handle_, 0);
glUniform4f(color_handle_, kLaserColor[0], kLaserColor[1], kLaserColor[2],
kLaserColor[3]);
glUniform1f(fade_point_handle_, kFadePoint);
glUniform1f(fade_end_handle_, kFadeEnd);
glDrawArrays(GL_TRIANGLES, 0, kVerticesNumber);
glDisableVertexAttribArray(position_handle_);
glDisableVertexAttribArray(tex_coord_handle_);
}
LaserRenderer::~LaserRenderer() = default;
VrShellRenderer::VrShellRenderer()
: textured_quad_renderer_(new TexturedQuadRenderer),
webvr_renderer_(new WebVrRenderer),
reticle_renderer_(new ReticleRenderer),
laser_renderer_(new LaserRenderer) {}
VrShellRenderer::~VrShellRenderer() = default;
} // namespace vr_shell
| 40.719902
| 80
| 0.722923
|
xzhan96
|
7359b69116be43f028344c95fbb9b7d94ecd86d1
| 1,099
|
cpp
|
C++
|
Source/Framework/Core/Manager/TeAudioManager.cpp
|
fabsgc/TweedeFramework
|
dfd48f53a6c64b1c8b11ae2ed204dbfcb3ae6fda
|
[
"MIT"
] | 2
|
2019-04-18T18:13:51.000Z
|
2020-06-02T10:58:21.000Z
|
Source/Framework/Core/Manager/TeAudioManager.cpp
|
fabsgc/TweedeFramework
|
dfd48f53a6c64b1c8b11ae2ed204dbfcb3ae6fda
|
[
"MIT"
] | null | null | null |
Source/Framework/Core/Manager/TeAudioManager.cpp
|
fabsgc/TweedeFramework
|
dfd48f53a6c64b1c8b11ae2ed204dbfcb3ae6fda
|
[
"MIT"
] | 1
|
2020-02-11T15:38:27.000Z
|
2020-02-11T15:38:27.000Z
|
#include "Manager/TeAudioManager.h"
#include "Utility/TeDynLibManager.h"
#include "Utility/TeDynLib.h"
namespace te
{
AudioManager::AudioManager(const String& pluginName)
: _plugin(nullptr)
, _factory(nullptr)
{
_plugin = DynLibManager::Instance().Load(pluginName);
if (_plugin != nullptr)
{
typedef AudioFactory* (*LoadPluginFunc)();
LoadPluginFunc loadPluginFunc = (LoadPluginFunc)_plugin->GetSymbol("LoadPlugin");
_factory = loadPluginFunc();
if (_factory != nullptr)
_factory->StartUp();
}
}
AudioManager::~AudioManager()
{
if (_plugin != nullptr)
{
if (_factory != nullptr)
{
typedef void(*UnloadPluginFunc)(AudioFactory*);
UnloadPluginFunc unloadPluginFunc = (UnloadPluginFunc)_plugin->GetSymbol("UnloadPlugin");
_factory->ShutDown();
unloadPluginFunc(_factory);
}
DynLibManager::Instance().Unload(_plugin);
}
}
}
| 26.166667
| 105
| 0.569609
|
fabsgc
|
735a91fc08d33d73a2499cfb32fdf0824c242084
| 6,059
|
cpp
|
C++
|
tests/test_buffer.cpp
|
ximenpo/simple-cpp
|
0779674dbea5cd8f4081140cad90edeaa31da7c8
|
[
"MIT"
] | 2
|
2015-04-10T04:07:24.000Z
|
2015-10-21T07:13:11.000Z
|
tests/test_buffer.cpp
|
ximenpo/simple_cpp
|
0779674dbea5cd8f4081140cad90edeaa31da7c8
|
[
"MIT"
] | 1
|
2015-04-18T02:31:22.000Z
|
2015-04-21T20:21:02.000Z
|
tests/test_buffer.cpp
|
ximenpo/simple_cpp
|
0779674dbea5cd8f4081140cad90edeaa31da7c8
|
[
"MIT"
] | null | null | null |
#include "simple/igloo.h"
using namespace igloo;
#include <map>
#include <set>
#include <list>
#include <deque>
#include <vector>
#include "simple/buffer.h"
struct testBufferMsg1 {
enum {ID = 1};
int n;
std::string s;
};
buffer& operator>>(buffer& buf, testBufferMsg1& obj) {
uintmax_t size;
uintmax_t ver = 0;
buffer_tag tag;
if( !buffer_read_tag(buf, tag)
|| tag.data_type != buffer_tag::TYPE_OBJECT
|| (tag.version_tag && !buffer_read_uint_value(buf, buffer_tag::TAG_1, ver))
|| !buffer_read_uint_value(buf, tag.size_tag, size)
//|| (tag.version_tag && ver>=0 && size < 0)
|| (tag.version_tag && ver<=0 && size > 0)
) {
buf.set_failure();
return buf;
}
if(!tag.version_tag || ver == 0) {
return buf
>> obj.n
>> obj.s
;
}
size_t count = 0;
for(size_t i = count; count < size; ++i) {
buffer_read_and_ignore(buf);// ignore extended fields
}
return buf;
}
buffer& operator<<(buffer& buf, const testBufferMsg1& obj) {
uintmax_t size = 0;
buffer_tag tag = {
buffer_tag::TYPE_OBJECT,
buffer_size_tag(size),
0 != 0,
};
if( !buffer_write_tag(buf, tag)
|| (tag.version_tag && !buffer_write_uint_value(buf, buffer_tag::TAG_1, 0))
|| !buffer_write_uint_value(buf, tag.size_tag, size)
) {
buf.set_failure();
return buf;
}
buf
<< obj.n
<< obj.s
;
return buf;
}
Context(buffer_context) {
Spec(simple_msg_usage) {
testBufferMsg1 m1 = { 35,
"XiMenPo",
};
testBufferMsg1 m2;
buffer buf;
buf << m1;
buf.rewind();
buf >> m2;
AssertThat(m2.n, Equals(m1.n));
AssertThat(m2.s, Equals(m1.s));
}
Spec(map_usage) {
std::map<int, std::string> v1, v2;
v1[0] = "000";
v1[1] = "111";
v1[2] = "222";
buffer buf;
buf << v1;
buf.rewind();
buf >> v2;
AssertThat(v2.size(), Equals(3));
AssertThat(v2[0], Equals(v1[0]));
AssertThat(v2[1], Equals(v1[1]));
AssertThat(v2[2], Equals(v1[2]));
}
Spec(deque_usage) {
std::deque<std::string> v1, v2;
v1.push_back("000");
v1.push_back("111");
v1.push_back("222");
buffer buf;
buf << v1;
buf.rewind();
buf >> v2;
AssertThat(v2, EqualsContainer(v1));
}
Spec(vector_usage) {
std::vector<std::string> v1, v2;
v1.push_back("000");
v1.push_back("111");
v1.push_back("222");
buffer buf;
buf << v1;
buf.rewind();
buf >> v2;
AssertThat(v2, EqualsContainer(v1));
}
Spec(list_usage) {
std::list<std::string> v1, v2;
v1.push_back("000");
v1.push_back("111");
v1.push_back("222");
buffer buf;
buf << v1;
buf.rewind();
buf >> v2;
AssertThat(v2, EqualsContainer(v1));
}
Spec(set_usage) {
std::set<std::string> v1, v2;
v1.insert("000");
v1.insert("111");
v1.insert("222");
buffer buf;
buf << v1;
buf.rewind();
buf >> v2;
AssertThat(v2, EqualsContainer(v1));
}
Spec(safe_array_usage) {
safe_array<std::string, 3> v1, v2;
v1[0] = "000";
v1[1] = "111";
v1[2] = "222";
buffer buf;
buf << v1;
buf.rewind();
buf >> v2;
AssertThat(v2[0], Equals(v1[0]));
AssertThat(v2[1], Equals(v1[1]));
AssertThat(v2[2], Equals(v1[2]));
}
Spec(queue_mergeable_usage) {
buffer_queue q(true);
int n;
buffer *r1, *r2, *r3, *r4, *r5;
buffer *b1 = q.create(), *b2 = q.create(), *b3 = q.create(), *b4 = q.create();
(*b1) << 1;
(*b2) << 2;
(*b3) << 3;
(*b4) << 4;
AssertThat(q.get(r1), Equals(false));
q.push(b1);
q.push(b2);
q.push(b3);
q.push(b4);
AssertThat(q.get(r1), Equals(true));
(*r1) >> n;
AssertThat(n, Equals(1));
AssertThat(q.get(r2), Equals(true));
(*r2) >> n;
AssertThat(n, Equals(2));
AssertThat(q.get(r3), Equals(true));
(*r3) >> n;
AssertThat(n, Equals(3));
AssertThat(q.get(r4), Equals(true));
(*r4) >> n;
AssertThat(n, Equals(4));
AssertThat(q.get(r5), Equals(false));
AssertThat(r1, Equals(r2));
AssertThat(r2, Equals(r3));
AssertThat(r3, Equals(r4));
}
Spec(queue_not_mergeable_usage) {
buffer_queue q(false);
int n;
buffer *r1, *r2, *r3, *r4, *r5;
buffer *b1 = q.create(), *b2 = q.create(), *b3 = q.create(), *b4 = q.create();
(*b1) << 1;
(*b2) << 2;
(*b3) << 3;
(*b4) << 4;
AssertThat(q.get(r1), Equals(false));
q.push(b1);
q.push(b2);
q.push(b3);
q.push(b4);
AssertThat(q.get(r1), Equals(true));
(*r1) >> n;
AssertThat(n, Equals(1));
AssertThat(q.get(r2), Equals(true));
(*r2) >> n;
AssertThat(n, Equals(2));
AssertThat(q.get(r3), Equals(true));
(*r3) >> n;
AssertThat(n, Equals(3));
AssertThat(q.get(r4), Equals(true));
(*r4) >> n;
AssertThat(n, Equals(4));
AssertThat(q.get(r5), Equals(false));
AssertThat(r1, !Equals(r2));
AssertThat(r2, !Equals(r3));
AssertThat(r3, !Equals(r4));
}
Spec(dump_usage) {
buffer buf;
for(size_t i = 0; i < 32; ++i) {
buf << i;
}
std::ostringstream os;
buf.dump(os);
AssertThat(os.str(), EqualsContainer(buf.dump()));
}
};
| 23.484496
| 88
| 0.474006
|
ximenpo
|
735b8df02e43154b2ba8d201d130aaeca3d79db3
| 2,036
|
cpp
|
C++
|
src/llvmir2hll/ir/unary_op_expr.cpp
|
Andrik-555/retdec
|
1ac63a520da02912daf836b924f41d95b1b5fa10
|
[
"MIT",
"BSD-3-Clause"
] | 521
|
2019-03-29T15:44:08.000Z
|
2022-03-22T09:46:19.000Z
|
src/llvmir2hll/ir/unary_op_expr.cpp
|
Andrik-555/retdec
|
1ac63a520da02912daf836b924f41d95b1b5fa10
|
[
"MIT",
"BSD-3-Clause"
] | 30
|
2019-06-04T17:00:49.000Z
|
2021-09-08T20:44:19.000Z
|
src/llvmir2hll/ir/unary_op_expr.cpp
|
Andrik-555/retdec
|
1ac63a520da02912daf836b924f41d95b1b5fa10
|
[
"MIT",
"BSD-3-Clause"
] | 99
|
2019-03-29T16:04:13.000Z
|
2022-03-28T16:59:34.000Z
|
/**
* @file src/llvmir2hll/ir/unary_op_expr.cpp
* @brief Implementation of UnaryOpExpr.
* @copyright (c) 2017 Avast Software, licensed under the MIT license
*/
#include "retdec/llvmir2hll/ir/unary_op_expr.h"
#include "retdec/llvmir2hll/support/debug.h"
namespace retdec {
namespace llvmir2hll {
/**
* @brief Constructs a unary operator.
*
* @param[in] op Operand.
*
* @par Preconditions
* - @a op is non-null
*/
UnaryOpExpr::UnaryOpExpr(ShPtr<Expression> op):
op(op) {
PRECONDITION_NON_NULL(op);
}
/**
* @brief Destructs the operator.
*/
UnaryOpExpr::~UnaryOpExpr() {}
ShPtr<Type> UnaryOpExpr::getType() const {
return op->getType();
}
void UnaryOpExpr::replace(ShPtr<Expression> oldExpr, ShPtr<Expression> newExpr) {
PRECONDITION_NON_NULL(oldExpr);
if (op == oldExpr) {
setOperand(newExpr);
} else if (op) {
op->replace(oldExpr, newExpr);
}
}
/**
* @brief Returns the operand.
*/
ShPtr<Expression> UnaryOpExpr::getOperand() const {
return op;
}
/**
* @brief Sets a new operand.
*
* @par Preconditions
* - @a operand is non-null
*/
void UnaryOpExpr::setOperand(ShPtr<Expression> newOp) {
PRECONDITION_NON_NULL(newOp);
op->removeObserver(shared_from_this());
newOp->addObserver(shared_from_this());
op = newOp;
}
/**
* @brief Updates the operator according to the changes of @a subject.
*
* @param[in] subject Observable object.
* @param[in] arg Optional argument.
*
* Replaces @a subject with @arg. For example, if @a subject is the operand of
* the operator, this function replaces it with @a arg.
*
* This function does nothing when:
* - @a subject does not correspond to the operand
* - @a arg is not an expression
*
* @par Preconditions
* - both operands are non-null
*
* @see Subject::update()
*/
void UnaryOpExpr::update(ShPtr<Value> subject, ShPtr<Value> arg) {
PRECONDITION_NON_NULL(subject);
PRECONDITION_NON_NULL(arg);
ShPtr<Expression> newOperand = cast<Expression>(arg);
if (subject == op && newOperand) {
setOperand(newOperand);
}
}
} // namespace llvmir2hll
} // namespace retdec
| 21.208333
| 81
| 0.711198
|
Andrik-555
|
735cc339feadfdb26e310462205e801aa6cf08f4
| 943
|
hpp
|
C++
|
include/mizuiro/color/format/homogenous_dynamic_ns/tag_of.hpp
|
cpreh/mizuiro
|
5ab15bde4e72e3a4978c034b8ff5700352932485
|
[
"BSL-1.0"
] | 1
|
2015-08-22T04:19:39.000Z
|
2015-08-22T04:19:39.000Z
|
include/mizuiro/color/format/homogenous_dynamic_ns/tag_of.hpp
|
freundlich/mizuiro
|
5ab15bde4e72e3a4978c034b8ff5700352932485
|
[
"BSL-1.0"
] | null | null | null |
include/mizuiro/color/format/homogenous_dynamic_ns/tag_of.hpp
|
freundlich/mizuiro
|
5ab15bde4e72e3a4978c034b8ff5700352932485
|
[
"BSL-1.0"
] | null | null | null |
// Copyright Carl Philipp Reh 2009 - 2016.
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#ifndef MIZUIRO_COLOR_FORMAT_HOMOGENOUS_DYNAMIC_NS_TAG_OF_HPP_INCLUDED
#define MIZUIRO_COLOR_FORMAT_HOMOGENOUS_DYNAMIC_NS_TAG_OF_HPP_INCLUDED
#include <mizuiro/size_type.hpp>
#include <mizuiro/color/format/homogenous_dynamic_fwd.hpp>
#include <mizuiro/color/format/tag_of_fwd.hpp>
#include <mizuiro/color/format/homogenous_dynamic_ns/tag.hpp>
namespace mizuiro::color::format
{
template <typename ChannelType, typename Space, mizuiro::size_type ChannelCount>
struct tag_of<mizuiro::color::format::homogenous_dynamic<ChannelType, Space, ChannelCount>>
{
using type = mizuiro::color::format::homogenous_dynamic_ns::tag<
mizuiro::color::format::homogenous_dynamic<ChannelType, Space, ChannelCount>>;
};
}
#endif
| 34.925926
| 91
| 0.78685
|
cpreh
|
735d2a1d595e33ce6a12e792ba751952e6ec9ab9
| 120,271
|
hpp
|
C++
|
zeccup/zeccup/military/desert/construction.hpp
|
LISTINGS09/ZECCUP
|
e0ad1fae580dde6e5d90903b1295fecc41684f63
|
[
"Naumen",
"Condor-1.1",
"MS-PL"
] | 3
|
2016-08-29T09:23:49.000Z
|
2019-06-13T20:29:28.000Z
|
zeccup/zeccup/military/desert/construction.hpp
|
LISTINGS09/ZECCUP
|
e0ad1fae580dde6e5d90903b1295fecc41684f63
|
[
"Naumen",
"Condor-1.1",
"MS-PL"
] | null | null | null |
zeccup/zeccup/military/desert/construction.hpp
|
LISTINGS09/ZECCUP
|
e0ad1fae580dde6e5d90903b1295fecc41684f63
|
[
"Naumen",
"Condor-1.1",
"MS-PL"
] | null | null | null |
class ConstructionLarge
{
name = $STR_ZECCUP_ConstructionLarge;
// EAST
class LightFactory_CUP_O_TK {
name = $STR_ZECCUP_MilitaryDesert_ConstructionLarge_LightFactory_CUP_O_TK; // Credit: 2600K
icon = "\ca\data\flag_rus_co.paa";
side = 8;
class Object0 {side = 8; vehicle = "Land_tent_east"; rank = ""; position[] = {-6.24951,-0.626953,0}; dir = 210;};
class Object1 {side = 8; vehicle = "Land_fort_bagfence_corner"; rank = ""; position[] = {-3.87927,-4.94629,0}; dir = 300;};
class Object2 {side = 8; vehicle = "Land_fort_bagfence_corner"; rank = ""; position[] = {-11.1371,-1.33496,0}; dir = 30;};
class Object3 {side = 8; vehicle = "AmmoCrates_NoInteractive_Large"; rank = ""; position[] = {-11.2335,-3.09961,0}; dir = 210;};
class Object4 {side = 8; vehicle = "Land_fort_bagfence_long"; rank = ""; position[] = {-9.89526,-2.75439,0}; dir = 30;};
class Object5 {side = 8; vehicle = "Land_fort_bagfence_long"; rank = ""; position[] = {-7.39526,-4.25439,0}; dir = 30;};
class Object6 {side = 8; vehicle = "CUP_vojenska_palanda"; rank = ""; position[] = {-10.125,-0.875,0}; dir = 300;};
class Object7 {side = 8; vehicle = "CUP_vojenska_palanda"; rank = ""; position[] = {-4.5,-4.125,0}; dir = 120;};
class Object8 {side = 8; vehicle = "Land_WaterBarrel_F"; rank = ""; position[] = {-2.125,1.625,0}; dir = 359.998;};
class Object9 {side = 8; vehicle = "Land_MetalCase_01_small_F"; rank = ""; position[] = {-5.73694,-3.2666,0}; dir = 29.9944;};
class Object10 {side = 8; vehicle = "Land_MetalCase_01_small_F"; rank = ""; position[] = {-8.88806,-1.7334,0}; dir = 209.995;};
class Object11 {side = 8; vehicle = "AmmoCrates_NoInteractive_Small"; rank = ""; position[] = {-12.254,-2.48975,0}; dir = 300;};
class Object12 {side = 8; vehicle = "TK_WarfareBLightFactory_base_EP1"; rank = ""; position[] = {-3.74146,10.8384,0}; dir = 180;};
class Object13 {side = 8; vehicle = "Land_fort_bagfence_round"; rank = ""; position[] = {2.01611,-1.64453,0}; dir = 135;};
class Object15 {side = 8; vehicle = "Land_fort_bagfence_long"; rank = ""; position[] = {2.36108,3.51514,0}; dir = 90;};
class Object16 {side = 8; vehicle = "GunrackTK_EP1"; rank = ""; position[] = {3.35596,3.33057,0}; dir = 0;};
class Object17 {side = 8; vehicle = "Land_WaterBarrel_F"; rank = ""; position[] = {-1,0.625,0}; dir = 119.991;};
class Object18 {side = 8; vehicle = "MetalBarrel_burning_F"; rank = ""; position[] = {3.25,2.375,0}; dir = 135;};
class Object19 {side = 8; vehicle = "Land_Pallets_F"; rank = ""; position[] = {8.74744,0.653809,0}; dir = 90;};
class Object20 {side = 8; vehicle = "Land_Pallet_F"; rank = ""; position[] = {8.24219,-1.00781,0}; dir = 224.289;};
class Object21 {side = 8; vehicle = "Land_CamoNet_EAST_EP1"; rank = ""; position[] = {5.30054,11.7256,0}; dir = 270;};
class Object22 {side = 8; vehicle = "Land_fort_rampart_EP1"; rank = ""; position[] = {9.64954,11.5,0}; dir = 270;};
class Object23 {side = 8; vehicle = "Land_fort_bagfence_long"; rank = ""; position[] = {2.36108,6.39014,0}; dir = 90;};
class Object24 {side = 8; vehicle = "AmmoCrates_NoInteractive_Medium"; rank = ""; position[] = {6.29675,11.5298,0}; dir = 195;};
class Object25 {side = 8; vehicle = "Land_CratesWooden_F"; rank = ""; position[] = {8.375,8.75,0}; dir = 270;};
class Object26 {side = 8; vehicle = "Land_Sacks_goods_F"; rank = ""; position[] = {8.36426,15.0073,0}; dir = 300;};
class Object27 {side = 8; vehicle = "Land_Sacks_heap_F"; rank = ""; position[] = {8.31689,13.769,0}; dir = 0;};
class Object28 {side = 8; vehicle = "Land_WoodenBox_F"; rank = ""; position[] = {8.63647,17.2515,0}; dir = 330;};
class Object29 {side = 8; vehicle = "Land_WoodenBox_F"; rank = ""; position[] = {7.3197,8.43506,0}; dir = 270.001;};
class Object30 {side = 8; vehicle = "AmmoCrate_NoInteractive_"; rank = ""; position[] = {7.34302,10.3682,0}; dir = 135;};
class Object31 {side = 8; vehicle = "Barrel1"; rank = ""; position[] = {7.66821,6.90967,0}; dir = 225;};
class Object32 {side = 8; vehicle = "Barrel4"; rank = ""; position[] = {8.375,7,0}; dir = 330;};
class Object33 {side = 8; vehicle = "Barrel4"; rank = ""; position[] = {8.875,12.625,0}; dir = 330;};
class Object34 {side = 8; vehicle = "Land_Pallets_stack_F"; rank = ""; position[] = {10.6986,17.6494,0}; dir = 359.594;};
};
class HeavyFactory_CUP_O_TK {
name = $STR_ZECCUP_MilitaryDesert_ConstructionLarge_HeavyFactory_CUP_O_TK; // Credit: 2600K
icon = "\ca\data\flag_rus_co.paa";
side = 8;
class Object0 {side = 8; vehicle = "Land_HBarrier_large"; rank = ""; position[] = {1.07666,-11.5718,0}; dir = 180;};
class Object1 {side = 8; vehicle = "Land_fort_bagfence_corner"; rank = ""; position[] = {-7.52441,-11.187,0}; dir = 0;};
class Object2 {side = 8; vehicle = "AmmoCrates_NoInteractive_Large"; rank = ""; position[] = {1.68335,-9.82275,0}; dir = 90;};
class Object3 {side = 8; vehicle = "AmmoCrates_NoInteractive_Large"; rank = ""; position[] = {0.354614,-9.9126,0}; dir = 0;};
class Object5 {side = 8; vehicle = "Land_fort_bagfence_long"; rank = ""; position[] = {-4.32642,-11.7964,0}; dir = 0;};
class Object6 {side = 8; vehicle = "AmmoCrates_NoInteractive_Small"; rank = ""; position[] = {0.462402,-8.92773,0}; dir = 0;};
class Object7 {side = 8; vehicle = "AmmoCrate_NoInteractive_"; rank = ""; position[] = {-5.40479,3.83301,0}; dir = 345;};
class Object8 {side = 8; vehicle = "Barrel4"; rank = ""; position[] = {-6.43604,2.21777,0}; dir = 285;};
class Object9 {side = 8; vehicle = "Barrel4"; rank = ""; position[] = {-7.84241,1.31494,0}; dir = 285;};
class Object10 {side = 8; vehicle = "Barrel4"; rank = ""; position[] = {2.93896,-10.0322,0}; dir = 240;};
class Object11 {side = 8; vehicle = "Barrel4"; rank = ""; position[] = {-6.91357,1.65039,0}; dir = 285;};
class Object12 {side = 8; vehicle = "Barrel4"; rank = ""; position[] = {-9.56104,3.21777,0}; dir = 240;};
class Object13 {side = 8; vehicle = "Barrel4"; rank = ""; position[] = {-9.14148,4.11182,0}; dir = 240;};
class Object14 {side = 8; vehicle = "Barrel4"; rank = ""; position[] = {-10.186,3.59277,0}; dir = 195;};
class Object15 {side = 8; vehicle = "Barrel1"; rank = ""; position[] = {-8.56104,1.59277,0}; dir = 180;};
class Object16 {side = 8; vehicle = "Land_Pallets_F"; rank = ""; position[] = {0.398438,-13.5225,0}; dir = 75;};
class Object17 {side = 8; vehicle = "Land_Pallet_F"; rank = ""; position[] = {-0.37793,-13.8491,0}; dir = 179.258;};
class Object18 {side = 8; vehicle = "TK_WarfareBHeavyFactory_Base_EP1"; rank = ""; position[] = {1.18896,13.0928,0}; dir = 0;};
class Object19 {side = 8; vehicle = "Land_CamoNet_EAST_EP1"; rank = ""; position[] = {-7.98718,8.06445,0}; dir = 105;};
class Object20 {side = 8; vehicle = "Land_HBarrier_large"; rank = ""; position[] = {-6.24341,5.78906,0}; dir = 300;};
class Object21 {side = 8; vehicle = "AmmoCrates_NoInteractive_Large"; rank = ""; position[] = {-7.65356,7.56738,0}; dir = 30;};
class Object22 {side = 8; vehicle = "AmmoCrates_NoInteractive_Medium"; rank = ""; position[] = {-4.85107,4.67334,0}; dir = 30;};
class Object23 {side = 8; vehicle = "MetalBarrel_burning_F"; rank = ""; position[] = {-12.561,10.2178,0}; dir = 180;};
class Object24 {side = 8; vehicle = "AmmoCrates_NoInteractive_Large"; rank = ""; position[] = {-8.03589,6.375,0}; dir = 300;};
class Object25 {side = 8; vehicle = "Barrel4"; rank = ""; position[] = {-9.76648,4.48682,0}; dir = 45;};
class Object26 {side = 8; vehicle = "Land_Pallets_stack_F"; rank = ""; position[] = {-8.90344,11.749,0}; dir = 194.999;};
class Object27 {side = 8; vehicle = "Land_Pallets_stack_F"; rank = ""; position[] = {-8.31104,13.3428,0}; dir = 269.999;};
class Object28 {side = 8; vehicle = "Land_fort_rampart_EP1"; rank = ""; position[] = {10.189,-10.9316,0}; dir = 0;};
class Object29 {side = 8; vehicle = "Land_HBarrier_large"; rank = ""; position[] = {13.9785,-6.39453,0}; dir = 90;};
class Object30 {side = 8; vehicle = "Land_fort_rampart_EP1"; rank = ""; position[] = {12.2893,2.7666,0}; dir = 255;};
class Object31 {side = 8; vehicle = "Barrels"; rank = ""; position[] = {12.064,-1.78223,0}; dir = 135;};
class Object32 {side = 8; vehicle = "Barrels"; rank = ""; position[] = {11.564,-0.0322266,0}; dir = 180;};
class Object33 {side = 8; vehicle = "Barrels"; rank = ""; position[] = {10.689,3.59277,0}; dir = 255;};
class Object34 {side = 8; vehicle = "Land_WaterBarrel_F"; rank = ""; position[] = {11.314,1.59277,0}; dir = 119.991;};
class Object35 {side = 8; vehicle = "Barrel1"; rank = ""; position[] = {12.314,-8.53223,0}; dir = 135;};
class Object36 {side = 8; vehicle = "Barrel4"; rank = ""; position[] = {12.3755,-9.41846,0}; dir = 120;};
class Object37 {side = 8; vehicle = "Barrel4"; rank = ""; position[] = {12.439,-10.1572,0}; dir = 240;};
class Object38 {side = 8; vehicle = "Barrel4"; rank = ""; position[] = {11.439,-9.40723,0}; dir = 270;};
class Object39 {side = 8; vehicle = "Barrel4"; rank = ""; position[] = {11.314,-10.1572,0}; dir = 255;};
class Object40 {side = 8; vehicle = "Land_MetalBarrel_F"; rank = ""; position[] = {11.939,-5.03223,0}; dir = 29.9472;};
class Object41 {side = 8; vehicle = "Land_MetalBarrel_F"; rank = ""; position[] = {12.3138,-4.28223,0}; dir = 359.991;};
class Object42 {side = 8; vehicle = "Land_MetalBarrel_empty_F"; rank = ""; position[] = {11.5642,-4.28223,0}; dir = 150;};
};
// WEST
class LightFactory_CUP_B_USMC {
name = $STR_ZECCUP_MilitaryDesert_ConstructionLarge_LightFactory_CUP_B_USMC; // Credit: 2600K
icon = "\ca\data\flag_usa_co.paa";
side = 8;
class Object0 {side = 8; vehicle = "Land_HBarrier3"; rank = ""; position[] = {-8.71423,-8.78174,0}; dir = 270;};
class Object1 {side = 8; vehicle = "Land_HBarrier3"; rank = ""; position[] = {-4.09326,3.78564,0}; dir = 180;};
class Object2 {side = 8; vehicle = "Land_HBarrier3"; rank = ""; position[] = {-7.40674,-8.53564,0}; dir = 0;};
class Object3 {side = 8; vehicle = "Land_Garbage_square5_F"; rank = ""; position[] = {-4.89001,-6.74512,0}; dir = 0;};
class Object4 {side = 8; vehicle = "Land_HBarrier1"; rank = ""; position[] = {-8.74243,-9.61914,0}; dir = 300;};
class Object5 {side = 8; vehicle = "Land_JunkPile_F"; rank = ""; position[] = {-4.77966,-6.73486,0}; dir = 0;};
class Object6 {side = 8; vehicle = "Land_ToiletBox_F"; rank = ""; position[] = {-7.25,-6.5,0}; dir = 180.002;};
class Object7 {side = 8; vehicle = "Land_WaterTank_F"; rank = ""; position[] = {-5.75,2.25,0}; dir = 9.30621e-006;};
class Object8 {side = 8; vehicle = "Land_PaperBox_open_empty_F"; rank = ""; position[] = {-1.8103,-6.56055,0}; dir = 180;};
class Object9 {side = 8; vehicle = "Land_GarbageBarrel_01_F"; rank = ""; position[] = {-5.89197,-5.46094,0}; dir = 27.556;};
class Object10 {side = 8; vehicle = "Land_MetalBarrel_F"; rank = ""; position[] = {-3.12512,-6.875,0}; dir = 315.007;};
class Object11 {side = 8; vehicle = "Land_MetalBarrel_F"; rank = ""; position[] = {-8.02893,4.02734,0}; dir = 254.82;}; // Z: 0.0966296
class Object12 {side = 8; vehicle = "AmmoCrates_NoInteractive_Large"; rank = ""; position[] = {-7.61938,2.91553,0}; dir = 270;};
class Object13 {side = 8; vehicle = "Land_Pallets_stack_F"; rank = ""; position[] = {-7.125,-10.375,0}; dir = 194.999;};
class Object14 {side = 8; vehicle = "Land_fort_artillery_nest_EP1"; rank = ""; position[] = {-9.00195,17.877,0}; dir = 315;};
class Object15 {side = 8; vehicle = "Land_CamoNetVar_NATO_EP1"; rank = ""; position[] = {-6.12805,14.1133,0}; dir = 135;};
class Object16 {side = 8; vehicle = "Land_PaperBox_open_empty_F"; rank = ""; position[] = {-9.12512,15.2495,0}; dir = 210;};
class Object17 {side = 8; vehicle = "Land_WoodenTable_large_F"; rank = ""; position[] = {-6.40649,11.3286,0}; dir = 224.692;};
class Object18 {side = 8; vehicle = "Land_WoodenTable_large_F"; rank = ""; position[] = {-4.05261,15.3276,0}; dir = 150.502;};
class Object19 {side = 8; vehicle = "Land_PaperBox_closed_F"; rank = ""; position[] = {-9.49756,13.4873,0}; dir = 180;};
class Object20 {side = 8; vehicle = "Land_CampingChair_V2_F"; rank = ""; position[] = {-3.11938,15.2861,0}; dir = 45.4717;};
class Object21 {side = 8; vehicle = "Land_CampingChair_V2_F"; rank = ""; position[] = {-3.60193,16.0317,0}; dir = 59.9813;};
class Object22 {side = 8; vehicle = "Land_CampingChair_V2_F"; rank = ""; position[] = {-6.75,12.375,0}; dir = 240.012;};
class Object23 {side = 8; vehicle = "Land_CampingChair_V2_F"; rank = ""; position[] = {-6.21973,10.4307,0}; dir = 120.011;};
class Object24 {side = 8; vehicle = "Land_CampingChair_V2_F"; rank = ""; position[] = {-5.60083,11.1411,0}; dir = 134.981;};
class Object25 {side = 8; vehicle = "Land_CampingChair_V2_F"; rank = ""; position[] = {-7.2804,11.4912,0}; dir = 300.012;};
class Object26 {side = 8; vehicle = "Land_CampingChair_V2_F"; rank = ""; position[] = {-5.09143,15.2412,0}; dir = 165.012;};
class Object27 {side = 8; vehicle = "Land_CampingChair_V2_F"; rank = ""; position[] = {-4.375,14.5,0}; dir = 225.011;};
class Object28 {side = 8; vehicle = "AmmoCrates_NoInteractive_Large"; rank = ""; position[] = {-5.29077,18.7446,0}; dir = 165;};
class Object29 {side = 8; vehicle = "Land_MetalBarrel_F"; rank = ""; position[] = {-9.75,12.25,0}; dir = 299.995;};
class Object30 {side = 8; vehicle = "Land_HBarrier_large"; rank = ""; position[] = {-0.362305,-8.41455,0}; dir = 180;};
class Object31 {side = 8; vehicle = "Land_HBarrier5"; rank = ""; position[] = {7.07556,-3.24365,0}; dir = 90;};
class Object33 {side = 8; vehicle = "Land_HBarrier1"; rank = ""; position[] = {6.75757,-8.49414,0}; dir = 300;};
class Object34 {side = 8; vehicle = "Land_HBarrier1"; rank = ""; position[] = {10.2443,-0.867676,0}; dir = 210;};
class Object35 {side = 8; vehicle = "Land_PaperBox_closed_F"; rank = ""; position[] = {-0.237549,-6.62256,0}; dir = 90;};
class Object36 {side = 8; vehicle = "Land_Sacks_heap_F"; rank = ""; position[] = {5.625,-3.875,0}; dir = 270;};
class Object37 {side = 8; vehicle = "Land_Sacks_heap_F"; rank = ""; position[] = {5.5,-4.875,0}; dir = 0;};
class Object38 {side = 8; vehicle = "Land_CratesPlastic_F"; rank = ""; position[] = {4.62305,-3.75391,0}; dir = 90;};
class Object39 {side = 8; vehicle = "MetalBarrel_burning_F"; rank = ""; position[] = {5.625,-2,0}; dir = 135;};
class Object40 {side = 8; vehicle = "Land_MetalBarrel_F"; rank = ""; position[] = {6.44971,-2.28809,0}; dir = 29.98;};
class Object41 {side = 8; vehicle = "Land_MetalBarrel_F"; rank = ""; position[] = {5.74988,-2.75,0}; dir = 59.9769;};
class Object42 {side = 8; vehicle = "AmmoCrates_NoInteractive_Medium"; rank = ""; position[] = {0.987305,-6.6001,0}; dir = 90;};
class Object43 {side = 8; vehicle = "US_WarfareBLightFactory_base_EP1"; rank = ""; position[] = {6.13611,6.81006,0}; dir = 0;};
};
class HeavyFactory_CUP_B_USMC {
name = $STR_ZECCUP_MilitaryDesert_ConstructionLarge_HeavyFactory_CUP_B_USMC; // Credit: 2600K
icon = "\ca\data\flag_usa_co.paa";
side = 8;
class Object0 {side = 8; vehicle = "Land_HBarrier_large"; rank = ""; position[] = {-1.67334,-14.8218,0}; dir = 180;};
class Object1 {side = 8; vehicle = "Land_HBarrier3"; rank = ""; position[] = {-9.16638,-1.95459,0}; dir = 210;};
class Object2 {side = 8; vehicle = "AmmoCrates_NoInteractive_Large"; rank = ""; position[] = {-2.56665,-13.1978,0}; dir = 90;};
class Object3 {side = 8; vehicle = "AmmoCrates_NoInteractive_Large"; rank = ""; position[] = {-3.89539,-13.1626,0}; dir = 0;};
class Object5 {side = 8; vehicle = "Land_HBarrier1"; rank = ""; position[] = {-8.4303,-0.789551,0}; dir = 30;};
class Object6 {side = 8; vehicle = "Land_HBarrier1"; rank = ""; position[] = {-12.9303,-12.5249,0}; dir = 285;};
class Object7 {side = 8; vehicle = "Land_HBarrier1"; rank = ""; position[] = {-11.1873,0.102051,0}; dir = 240;};
class Object8 {side = 8; vehicle = "AmmoCrates_NoInteractive_Small"; rank = ""; position[] = {-3.9126,-12.1777,0}; dir = 0;};
class Object9 {side = 8; vehicle = "Land_BagFence_Round_F"; rank = ""; position[] = {-12.8102,-14.7368,0}; dir = 45;};
class Object10 {side = 8; vehicle = "Land_BagFence_Long_F"; rank = ""; position[] = {-7.30713,-15.2979,0}; dir = 180;};
class Object11 {side = 8; vehicle = "Land_BagFence_Long_F"; rank = ""; position[] = {-10.1821,-15.2979,0}; dir = 180;};
class Object12 {side = 8; vehicle = "Land_PaperBox_open_empty_F"; rank = ""; position[] = {-5.93628,1.46729,0}; dir = 240;};
class Object13 {side = 8; vehicle = "CargoNet_01_barrels_F"; rank = ""; position[] = {-5.81897,-13.2622,0}; dir = 164.852;};
class Object14 {side = 8; vehicle = "Land_BagFence_End_F"; rank = ""; position[] = {-13.1628,-12.5933,0}; dir = 270;};
class Object15 {side = 8; vehicle = "Land_MetalBarrel_F"; rank = ""; position[] = {0.499634,-12.2222,0}; dir = 179.991;};
class Object16 {side = 8; vehicle = "Land_MetalBarrel_F"; rank = ""; position[] = {1.68994,-13.1533,0}; dir = 135.042;};
class Object17 {side = 8; vehicle = "Land_MetalBarrel_F"; rank = ""; position[] = {0.688843,-13.1572,0}; dir = 14.982;};
class Object18 {side = 8; vehicle = "Land_MetalBarrel_F"; rank = ""; position[] = {-0.186035,-13.1572,0}; dir = 105.016;};
class Object19 {side = 8; vehicle = "Land_Pallets_F"; rank = ""; position[] = {-0.592163,-18.4189,0}; dir = 45;};
class Object20 {side = 8; vehicle = "Land_Pallet_F"; rank = ""; position[] = {-1.68604,-17.1572,0}; dir = 149.332;};
class Object21 {side = 8; vehicle = "Land_CamoNet_NATO_EP1"; rank = ""; position[] = {-8.61218,7.68945,0}; dir = 105;};
class Object22 {side = 8; vehicle = "Land_HBarrier_large"; rank = ""; position[] = {-7.74341,2.91406,0}; dir = 300;};
class Object23 {side = 8; vehicle = "Land_HBarrier1"; rank = ""; position[] = {-11.0685,13.9736,0}; dir = 195;};
class Object24 {side = 8; vehicle = "Land_HBarrier1"; rank = ""; position[] = {-13.4447,4.22119,0}; dir = 180;};
class Object25 {side = 8; vehicle = "AmmoCrates_NoInteractive_Medium"; rank = ""; position[] = {-9.771,3.01221,0}; dir = 210;};
class Object26 {side = 8; vehicle = "Land_PaperBox_open_empty_F"; rank = ""; position[] = {-13.6857,5.84277,0}; dir = 75;};
class Object27 {side = 8; vehicle = "Land_PaperBox_closed_F"; rank = ""; position[] = {-9.69849,9.46533,0}; dir = 270;};
class Object28 {side = 8; vehicle = "Land_PaperBox_closed_F"; rank = ""; position[] = {-11.5619,12.2051,0}; dir = 195;};
class Object29 {side = 8; vehicle = "Land_PaperBox_closed_F"; rank = ""; position[] = {-10.1733,11.0918,0}; dir = 105;};
class Object30 {side = 8; vehicle = "Land_PaperBox_closed_F"; rank = ""; position[] = {-9.32373,4.34375,0}; dir = 285;};
class Object31 {side = 8; vehicle = "MetalBarrel_burning_F"; rank = ""; position[] = {-14.186,3.09277,0}; dir = 345;};
class Object32 {side = 8; vehicle = "Land_MetalBarrel_F"; rank = ""; position[] = {-10.3112,12.5928,0}; dir = 29.9747;};
class Object33 {side = 8; vehicle = "Land_MetalBarrel_F"; rank = ""; position[] = {-10.0845,13.438,0}; dir = 299.995;};
class Object34 {side = 8; vehicle = "Land_MetalBarrel_F"; rank = ""; position[] = {-11.9362,14.8428,0}; dir = 60.0024;};
class Object35 {side = 8; vehicle = "AmmoCrate_NoInteractive_"; rank = ""; position[] = {-11.7012,10.8721,0}; dir = 210;};
class Object36 {side = 8; vehicle = "Land_Pallets_stack_F"; rank = ""; position[] = {-7.81104,17.7178,0}; dir = 254.999;};
class Object37 {side = 8; vehicle = "Land_HBarrier_large"; rank = ""; position[] = {12.2285,-1.01953,0}; dir = 90;};
class Object38 {side = 8; vehicle = "Land_HBarrier_large"; rank = ""; position[] = {12.4785,-9.26953,0}; dir = 90;};
class Object39 {side = 8; vehicle = "Land_BagFence_Round_F"; rank = ""; position[] = {12.2776,-14.541,0}; dir = 315;};
class Object40 {side = 8; vehicle = "Land_BagFence_Long_F"; rank = ""; position[] = {3.69287,-14.9229,0}; dir = 180;};
class Object41 {side = 8; vehicle = "Land_BagFence_Long_F"; rank = ""; position[] = {9.44287,-14.9229,0}; dir = 180;};
class Object42 {side = 8; vehicle = "Land_BagFence_Long_F"; rank = ""; position[] = {6.56787,-14.9229,0}; dir = 180;};
class Object43 {side = 8; vehicle = "Land_PaperBox_closed_F"; rank = ""; position[] = {10.5615,-11.3945,0}; dir = 0;};
class Object44 {side = 8; vehicle = "Land_PaperBox_closed_F"; rank = ""; position[] = {10.5764,-8.15479,0}; dir = 90;};
class Object45 {side = 8; vehicle = "CargoNet_01_barrels_F"; rank = ""; position[] = {10.4313,-4.28711,0}; dir = 179.883;};
class Object46 {side = 8; vehicle = "CargoNet_01_barrels_F"; rank = ""; position[] = {10.4086,-2.55127,0}; dir = 269.189;};
class Object47 {side = 8; vehicle = "Land_Sacks_heap_F"; rank = ""; position[] = {10.814,-9.78223,0}; dir = 270;};
class Object48 {side = 8; vehicle = "US_WarfareBHeavyFactory_Base_EP1"; rank = ""; position[] = {4.92065,8.53809,0}; dir = 0;};
};
};
class ConstructionMedium
{
name = $STR_ZECCUP_ConstructionMedium;
// EAST
class Yard_CUP_O_TK {
name = $STR_ZECCUP_MilitaryDesert_ConstructionMedium_Yard_CUP_O_TK; // Credit: 2600K
icon = "\ca\data\flag_rus_co.paa";
side = 8;
class Object1 {side = 8; vehicle = "Land_Misc_Cargo2a_EP1"; rank = ""; position[] = {-5.40344,-4.72339,0}; dir = 180;};
class Object2 {side = 8; vehicle = "Land_Cargo20_grey_F"; rank = ""; position[] = {-7.95825,-4.75024,0}; dir = 270.005;};
class Object3 {side = 8; vehicle = "Land_Misc_Cargo2b"; rank = ""; position[] = {-5.25122,9.09839,0}; dir = 0;};
class Object4 {side = 8; vehicle = "Land_Misc_Cargo1e"; rank = ""; position[] = {-7.75122,9.09839,0}; dir = 0;};
class Object5 {side = 8; vehicle = "Land_fort_bagfence_corner"; rank = ""; position[] = {-6.15454,17.0884,0}; dir = 90;};
class Object6 {side = 8; vehicle = "Land_Ind_Shed_01_EP1"; rank = ""; position[] = {-1.375,-8.05176,0}; dir = 0;};
class Object7 {side = 8; vehicle = "Land_Misc_Cargo2a_EP1"; rank = ""; position[] = {4.84656,-4.47339,0}; dir = 180;};
class Object8 {side = 8; vehicle = "Land_Misc_Cargo1f"; rank = ""; position[] = {-0.251221,-4.40161,0}; dir = 0;};
class Object9 {side = 8; vehicle = "Land_Cargo20_light_blue_F"; rank = ""; position[] = {-2.78113,-4.49878,0}; dir = 89.7722;};
class Object10 {side = 8; vehicle = "Land_fort_bagfence_corner"; rank = ""; position[] = {0.0366211,-13.4045,0}; dir = 0;};
class Object11 {side = 8; vehicle = "Land_fort_bagfence_corner"; rank = ""; position[] = {3.90454,-12.8384,0}; dir = 270;};
class Object12 {side = 8; vehicle = "Land_PaperBox_closed_F"; rank = ""; position[] = {-0.122559,1.86255,0}; dir = 180;};
class Object14 {side = 8; vehicle = "Land_Cargo20_red_F"; rank = ""; position[] = {-2.80615,9.14014,0}; dir = 90;};
class Object15 {side = 8; vehicle = "Land_Misc_Cargo2c"; rank = ""; position[] = {4.77844,9.22339,0}; dir = 0;};
class Object16 {side = 8; vehicle = "Land_Misc_Cargo2a_EP1"; rank = ""; position[] = {-0.278442,8.90161,0}; dir = 180;};
class Object17 {side = 8; vehicle = "Land_fort_bagfence_corner"; rank = ""; position[] = {0.713379,17.5295,0}; dir = 180;};
class Object18 {side = 8; vehicle = "Land_GarbageBags_F"; rank = ""; position[] = {5.95996,12.7351,0}; dir = 0;};
class Object19 {side = 8; vehicle = "Land_PaperBox_closed_F"; rank = ""; position[] = {1.38647,2.63062,0}; dir = 75;};
class Object20 {side = 8; vehicle = "Land_fort_bagfence_long"; rank = ""; position[] = {-2.51538,18.1111,0}; dir = 0;};
class Object21 {side = 8; vehicle = "Land_Cargo20_yellow_F"; rank = ""; position[] = {2.25,9.125,0}; dir = 90;};
};
//WEST
class Yard_CUP_B_USMC {
name = $STR_ZECCUP_MilitaryDesert_ConstructionMedium_Yard_CUP_B_USMC; // Credit: 2600K
icon = "\ca\data\flag_usa_co.paa";
side = 8;
class Object1 {side = 8; vehicle = "Land_Misc_Cargo1f"; rank = ""; position[] = {-4.27429,-0.595459,0}; dir = 195;};
class Object2 {side = 8; vehicle = "Land_BagFence_Round_F"; rank = ""; position[] = {-6.91858,-11.1331,0}; dir = 60;};
class Object3 {side = 8; vehicle = "Land_BagFence_Long_F"; rank = ""; position[] = {-7.0155,-8.37891,0}; dir = 270;};
class Object4 {side = 8; vehicle = "Land_BagFence_End_F"; rank = ""; position[] = {-4.96143,-12.1682,0}; dir = 15;};
class Object5 {side = 8; vehicle = "Land_Misc_Cargo2a_EP1"; rank = ""; position[] = {-6.84656,7.47339,0}; dir = 0;};
class Object6 {side = 8; vehicle = "Land_PaperBox_closed_F"; rank = ""; position[] = {-4.61255,7.12744,0}; dir = 90;};
class Object7 {side = 8; vehicle = "Land_PaperBox_closed_F"; rank = ""; position[] = {-4.62744,8.88745,0}; dir = 0;};
class Object8 {side = 8; vehicle = "Land_BagFence_End_F"; rank = ""; position[] = {-4.24988,11.7383,0}; dir = 150;};
class Object9 {side = 8; vehicle = "Land_Ind_Shed_01_EP1"; rank = ""; position[] = {-1.125,-10.3018,0}; dir = 0;};
class Object10 {side = 8; vehicle = "Land_Cargo20_orange_F"; rank = ""; position[] = {-1.43115,-9.23486,0}; dir = 90;};
class Object11 {side = 8; vehicle = "Land_Misc_Cargo2e"; rank = ""; position[] = {1.12378,-9.27661,0}; dir = 0;};
class Object12 {side = 8; vehicle = "Land_Cargo20_white_F"; rank = ""; position[] = {3.75,-8,0}; dir = 90;};
class Object13 {side = 8; vehicle = "Land_GarbageBags_F"; rank = ""; position[] = {6.45996,-13.5149,0}; dir = 0;};
class Object14 {side = 8; vehicle = "Misc_cargo_cont_small"; rank = ""; position[] = {4.23645,-0.13501,0}; dir = 225;};
class Object15 {side = 8; vehicle = "Land_PaperBox_closed_F"; rank = ""; position[] = {5.87256,-5.36255,0}; dir = 0;};
class Object16 {side = 8; vehicle = "Land_PaperBox_closed_F"; rank = ""; position[] = {5.88745,-7.12256,0}; dir = 90;};
class Object18 {side = 8; vehicle = "Land_Misc_Cargo2c"; rank = ""; position[] = {2.40344,7.34839,0}; dir = 0;};
class Object19 {side = 8; vehicle = "Land_Misc_Cargo1c"; rank = ""; position[] = {4.87622,8.02661,0}; dir = 180;};
class Object20 {side = 8; vehicle = "Land_BagFence_Round_F"; rank = ""; position[] = {-2.75793,13.1685,0}; dir = 150;};
class Object21 {side = 8; vehicle = "Land_BagFence_Long_F"; rank = ""; position[] = {-0.00390625,13.2656,0}; dir = 360;};
class Object22 {side = 8; vehicle = "Land_BagFence_End_F"; rank = ""; position[] = {2.10168,12.823,0}; dir = 30;};
};
};
class ConstructionSmall
{
name = $STR_ZECCUP_ConstructionSmall;
};
class ConstructionSuppliesLarge
{
name = $STR_ZECCUP_ConstructionSuppliesLarge;
class BaseObjects {
name = $STR_ZECCUP_MilitaryDesert_ConstructionSuppliesLarge_BaseObjects; // Credit: 2600K
icon = "\a3\Ui_f\data\Map\Markers\Military\unknown_ca.paa";
side = 8;
class Object1 {side = 8; vehicle = "CUP_A2_tent_east_ep1"; rank = ""; position[] = {-27.0012,-16.9985,0}; dir = 0;};
class Object2 {side = 8; vehicle = "Land_fortified_nest_small_EP1"; rank = ""; position[] = {-13.541,-18.6165,0}; dir = 0;};
class Object3 {side = 8; vehicle = "Land_Barrack2_EP1"; rank = ""; position[] = {-21,-31.9775,0}; dir = 0;};
class Object4 {side = 8; vehicle = "Land_CamoNetB_EAST_EP1"; rank = ""; position[] = {-29.0452,-0.264404,0}; dir = 0;};
class Object5 {side = 8; vehicle = "Land_CamoNet_EAST_EP1"; rank = ""; position[] = {-29.0242,16.1995,0}; dir = 0;};
class Object6 {side = 8; vehicle = "Land_fortified_nest_big_EP1"; rank = ""; position[] = {-13.4644,-6.72729,0}; dir = 0;};
class Object7 {side = 8; vehicle = "Land_fort_bagfence_round"; rank = ""; position[] = {-4.16406,14.3726,0}; dir = 90;};
class Object8 {side = 8; vehicle = "Land_fort_bagfence_round"; rank = ""; position[] = {-17.3359,14.3774,0}; dir = 270;};
class Object9 {side = 8; vehicle = "Land_fort_bagfence_corner"; rank = ""; position[] = {-15.6545,6.83838,0}; dir = 90;};
class Object10 {side = 8; vehicle = "Land_fort_bagfence_corner"; rank = ""; position[] = {-5.78662,7.40454,0}; dir = 180;};
class Object11 {side = 8; vehicle = "Land_fort_bagfence_long"; rank = ""; position[] = {-13.6096,11.6389,0}; dir = 180;};
class Object12 {side = 8; vehicle = "Land_fort_bagfence_long"; rank = ""; position[] = {-8.98462,8.01392,0}; dir = 180;};
class Object13 {side = 8; vehicle = "Land_fort_bagfence_long"; rank = ""; position[] = {-11.9846,8.01392,0}; dir = 180;};
class Object14 {side = 8; vehicle = "Land_fort_bagfence_long"; rank = ""; position[] = {-10.7346,11.6389,0}; dir = 180;};
class Object15 {side = 8; vehicle = "Land_fort_bagfence_long"; rank = ""; position[] = {-7.85962,11.6389,0}; dir = 180;};
class Object16 {side = 8; vehicle = "FenceWood"; rank = ""; position[] = {-11.0071,16.8921,0}; dir = 270;};
class Object17 {side = 8; vehicle = "Land_CamoNetVar_EAST_EP1"; rank = ""; position[] = {-28.9011,27.3875,0}; dir = 0;};
class Object18 {side = 8; vehicle = "Land_fort_artillery_nest_EP1"; rank = ""; position[] = {-1,-28.6384,0}; dir = 0;};
class Object19 {side = 8; vehicle = "CUP_A2_tent2_west_ep1"; rank = ""; position[] = {27.4854,-22.3569,0}; dir = 0;};
class Object20 {side = 8; vehicle = "Land_Fort_Watchtower_EP1"; rank = ""; position[] = {10.9832,-18.7327,0}; dir = 0;};
class Object21 {side = 8; vehicle = "Land_HBarrier1"; rank = ""; position[] = {-2.99121,-15.0037,0}; dir = 0;};
class Object22 {side = 8; vehicle = "Land_HBarrier1"; rank = ""; position[] = {1.00879,-15.0037,0}; dir = 0;};
class Object23 {side = 8; vehicle = "Land_fort_rampart_EP1"; rank = ""; position[] = {-1,-17.7744,0}; dir = 0;};
class Object24 {side = 8; vehicle = "Land_CamoNetB_NATO_EP1"; rank = ""; position[] = {26.9548,-0.264404,0}; dir = 0;};
class Object25 {side = 8; vehicle = "Land_CamoNet_NATO_EP1"; rank = ""; position[] = {26.9758,16.1995,0}; dir = 0;};
class Object26 {side = 8; vehicle = "Land_HBarrier_large"; rank = ""; position[] = {-1.0127,-4.08545,0}; dir = 0;};
class Object27 {side = 8; vehicle = "Land_HBarrier5"; rank = ""; position[] = {-3.25635,-7.92456,0}; dir = 0;};
class Object28 {side = 8; vehicle = "Land_CncWall4_F"; rank = ""; position[] = {9.03174,-4.26978,0}; dir = 0;};
class Object29 {side = 8; vehicle = "Land_HBarrier3"; rank = ""; position[] = {-2.15674,-12.0356,0}; dir = 0;};
class Object31 {side = 8; vehicle = "Land_CncWall1_F"; rank = ""; position[] = {12.9329,-4.2749,0}; dir = 0;};
class Object32 {side = 8; vehicle = "Land_CncBarrierMedium_F"; rank = ""; position[] = {15,-8.98242,0}; dir = 0;};
class Object33 {side = 8; vehicle = "Land_BagFence_Round_F"; rank = ""; position[] = {3.33984,17.9202,0}; dir = 0;};
class Object34 {side = 8; vehicle = "Land_BagFence_Round_F"; rank = ""; position[] = {11.7075,12.3677,0}; dir = 315;};
class Object35 {side = 8; vehicle = "Land_BagFence_Round_F"; rank = ""; position[] = {10.5898,17.9211,0}; dir = 0;};
class Object36 {side = 8; vehicle = "Land_BagFence_Round_F"; rank = ""; position[] = {6.91016,20.3289,0}; dir = 180;};
class Object37 {side = 8; vehicle = "Land_BagFence_Round_F"; rank = ""; position[] = {3.11768,12.417,0}; dir = 45;};
class Object38 {side = 8; vehicle = "Land_BagFence_Long_F"; rank = ""; position[] = {8.8728,11.9856,0}; dir = 180;};
class Object39 {side = 8; vehicle = "Land_BagFence_Long_F"; rank = ""; position[] = {5.9978,11.9856,0}; dir = 180;};
class Object40 {side = 8; vehicle = "Land_BagFence_Long_F"; rank = ""; position[] = {8.8772,8.0144,0}; dir = 0;};
class Object41 {side = 8; vehicle = "Land_BagFence_Long_F"; rank = ""; position[] = {6.0022,8.01343,0}; dir = 0;};
class Object42 {side = 8; vehicle = "Land_BagFence_Short_F"; rank = ""; position[] = {8.74829,19.136,0}; dir = 225;};
class Object43 {side = 8; vehicle = "Land_BagFence_Short_F"; rank = ""; position[] = {3.86865,6.24048,0}; dir = 90;};
class Object44 {side = 8; vehicle = "Land_BagFence_Short_F"; rank = ""; position[] = {5.11401,19.1233,0}; dir = 135;};
class Object45 {side = 8; vehicle = "Land_BagFence_Short_F"; rank = ""; position[] = {11.2437,6.49097,0}; dir = 90;};
class Object46 {side = 8; vehicle = "Land_BagFence_Corner_F"; rank = ""; position[] = {11.2905,8.00098,0}; dir = 0;};
class Object47 {side = 8; vehicle = "Land_BagFence_Corner_F"; rank = ""; position[] = {3.87402,8.04004,0}; dir = 270;};
class Object48 {side = 8; vehicle = "Land_BagFence_End_F"; rank = ""; position[] = {2.76099,14.699,0}; dir = 270;};
class Object49 {side = 8; vehicle = "Land_BagFence_End_F"; rank = ""; position[] = {4.13794,4.56616,0}; dir = 75;};
class Object50 {side = 8; vehicle = "Land_BagFence_End_F"; rank = ""; position[] = {12.136,14.6995,0}; dir = 270;};
class Object51 {side = 8; vehicle = "Land_BagFence_End_F"; rank = ""; position[] = {11.5129,4.81665,0}; dir = 75;};
class Object52 {side = 8; vehicle = "Land_BagFence_End_F"; rank = ""; position[] = {12.5391,19.2739,0}; dir = 315;};
class Object53 {side = 8; vehicle = "Land_BagFence_End_F"; rank = ""; position[] = {1.86206,19.5574,0}; dir = 255;};
class Object54 {side = 8; vehicle = "Land_CncBarrierMedium4_F"; rank = ""; position[] = {8.97583,-8.98242,0}; dir = 0;};
class Object55 {side = 8; vehicle = "Land_CamoNetVar_NATO_EP1"; rank = ""; position[] = {27.0989,27.3875,0}; dir = 0;};
class Object56 {side = 8; vehicle = "76n6ClamShell_EP1"; rank = ""; position[] = {-1,26.7,0}; dir = 0;};
};
class MiscItems {
name = $STR_ZECCUP_MilitaryDesert_ConstructionSuppliesLarge_MiscItems; // Credit: 2600K
icon = "\a3\Ui_f\data\Map\Markers\Military\unknown_ca.paa";
side = 8;
class Object0 {side = 8; vehicle = "Gunrack1"; rank = ""; position[] = {-2.05981,-13.9353,0}; dir = 90;};
class Object1 {side = 8; vehicle = "Gunrack1"; rank = ""; position[] = {-2.05981,-12.9353,0}; dir = 90;};
class Object2 {side = 8; vehicle = "Land_WoodenTable_large_F"; rank = ""; position[] = {-14.2495,-19,0}; dir = 179.69;};
class Object3 {side = 8; vehicle = "Land_Sacks_heap_F"; rank = ""; position[] = {-14.3098,-13.6853,0}; dir = 0;};
class Object4 {side = 8; vehicle = "FoldTable"; rank = ""; position[] = {-8.12451,-18.5,0}; dir = 270;};
class Object5 {side = 8; vehicle = "Land_CampingTable_F"; rank = ""; position[] = {-1.69043,-18.376,0}; dir = 89.7963;};
class Object6 {side = 8; vehicle = "Land_CampingTable_F"; rank = ""; position[] = {-2.49951,-18.375,0}; dir = 270.001;};
class Object7 {side = 8; vehicle = "Land_Sack_F"; rank = ""; position[] = {-13.8147,-14.4373,0}; dir = 285;};
class Object8 {side = 8; vehicle = "Land_CampingChair_V1_F"; rank = ""; position[] = {-3.05981,-18.8145,0}; dir = 284.979;};
class Object9 {side = 8; vehicle = "Land_CampingChair_V1_F"; rank = ""; position[] = {-1.25122,-18.874,0}; dir = 74.9631;};
class Object10 {side = 8; vehicle = "Land_CampingChair_V1_F"; rank = ""; position[] = {-2.99951,-17.875,0}; dir = 269.967;};
class Object11 {side = 8; vehicle = "Land_CampingChair_V1_F"; rank = ""; position[] = {-0.999512,-17.875,0}; dir = 119.946;};
class Object12 {side = 8; vehicle = "Land_CampingChair_V2_F"; rank = ""; position[] = {-15.2324,-18.5027,0}; dir = 195.009;};
class Object13 {side = 8; vehicle = "Land_CampingChair_V2_F"; rank = ""; position[] = {-13.4824,-19.5027,0}; dir = 75.0083;};
class Object14 {side = 8; vehicle = "Land_CampingChair_V2_F"; rank = ""; position[] = {-13.5471,-18.563,0}; dir = 89.9785;};
class Object15 {side = 8; vehicle = "Land_CampingChair_V2_F"; rank = ""; position[] = {-14.9824,-19.5027,0}; dir = 255.009;};
class Object16 {side = 8; vehicle = "FoldChair"; rank = ""; position[] = {-8.87354,-17.9993,0}; dir = 330;};
class Object17 {side = 8; vehicle = "FoldChair"; rank = ""; position[] = {-8.62549,-18.9988,0}; dir = 255;};
class Object18 {side = 8; vehicle = "FoldChair"; rank = ""; position[] = {-7.37402,-19.0017,0}; dir = 60;};
class Object19 {side = 8; vehicle = "FoldChair"; rank = ""; position[] = {-7.625,-18.0017,0}; dir = 90;};
class Object20 {side = 8; vehicle = "CUP_metalcrate"; rank = ""; position[] = {-7.55981,-13.6853,0}; dir = 0;};
class Object21 {side = 8; vehicle = "CUP_metalcrate_02"; rank = ""; position[] = {-8.30981,-13.6853,0}; dir = 150;};
class Object22 {side = 8; vehicle = "Land_Sack_EP1"; rank = ""; position[] = {-14.4338,-14.5549,0}; dir = 75;};
class Object23 {side = 8; vehicle = "Land_Sacks_heap_F"; rank = ""; position[] = {-15.2495,-13.875,0}; dir = 270;};
class Object24 {side = 8; vehicle = "Land_WoodenTable_large_F"; rank = ""; position[] = {-14.2495,-21.25,0}; dir = 179.69;};
class Object25 {side = 8; vehicle = "Land_CampingChair_V2_F"; rank = ""; position[] = {-15.2495,-21.75,0}; dir = 225.008;};
class Object26 {side = 8; vehicle = "Land_CampingChair_V2_F"; rank = ""; position[] = {-14.8745,-20.75,0}; dir = 270.009;};
class Object27 {side = 8; vehicle = "Land_CampingChair_V2_F"; rank = ""; position[] = {-13.2495,-20.75,0}; dir = 149.977;};
class Object28 {side = 8; vehicle = "Land_CampingChair_V2_F"; rank = ""; position[] = {-13.1245,-21.75,0}; dir = 330.007;};
class Object29 {side = 8; vehicle = "FoldTable"; rank = ""; position[] = {-8.12451,-20.625,0}; dir = 270;};
class Object30 {side = 8; vehicle = "Land_CampingTable_F"; rank = ""; position[] = {-1.69116,-20.3777,0}; dir = 89.9993;};
class Object31 {side = 8; vehicle = "Land_CampingTable_F"; rank = ""; position[] = {-2.49951,-20.375,0}; dir = 270.001;};
class Object32 {side = 8; vehicle = "Land_CampingChair_V1_F"; rank = ""; position[] = {-1.12451,-19.875,0}; dir = 74.9502;};
class Object33 {side = 8; vehicle = "Land_CampingChair_V1_F"; rank = ""; position[] = {-0.874512,-21,0}; dir = 164.972;};
class Object34 {side = 8; vehicle = "Land_CampingChair_V1_F"; rank = ""; position[] = {-3.12451,-19.875,0}; dir = 254.969;};
class Object35 {side = 8; vehicle = "Land_CampingChair_V1_F"; rank = ""; position[] = {-3.24951,-20.875,0}; dir = 239.983;};
class Object36 {side = 8; vehicle = "FoldChair"; rank = ""; position[] = {-8.74951,-20.125,0}; dir = 285;};
class Object37 {side = 8; vehicle = "FoldChair"; rank = ""; position[] = {-8.62549,-21.1238,0}; dir = 255;};
class Object38 {side = 8; vehicle = "FoldChair"; rank = ""; position[] = {-7.49951,-21.125,0}; dir = 120;};
class Object39 {side = 8; vehicle = "FoldChair"; rank = ""; position[] = {-7.24951,-20.125,0}; dir = 195;};
class Object40 {side = 8; vehicle = "Land_TentA_F"; rank = ""; position[] = {-8.91187,-9.38525,0}; dir = 0;};
class Object41 {side = 8; vehicle = "Land_TentA_F"; rank = ""; position[] = {-6.91187,-9.38525,0}; dir = 0;};
class Object42 {side = 8; vehicle = "Misc_concrete_High"; rank = ""; position[] = {-13.8413,-3.57544,0}; dir = 0;};
class Object43 {side = 8; vehicle = "Land_TentDome_F"; rank = ""; position[] = {-8.90405,-4.00806,0}; dir = 225;};
class Object45 {side = 8; vehicle = "Land_CratesWooden_F"; rank = ""; position[] = {-14.0598,-8.6853,0}; dir = 0;};
class Object46 {side = 8; vehicle = "Land_Pallets_F"; rank = ""; position[] = {-8.78857,11.0574,0}; dir = 120;};
class Object47 {side = 8; vehicle = "CUP_vojenska_palanda"; rank = ""; position[] = {-6.79492,1.2439,0}; dir = 0;};
class Object48 {side = 8; vehicle = "CUP_vojenska_palanda"; rank = ""; position[] = {-8.79492,1.3689,0}; dir = 0;};
class Object49 {side = 8; vehicle = "Misc_Backpackheap"; rank = ""; position[] = {-7.62988,6.07959,0}; dir = 210;};
class Object50 {side = 8; vehicle = "Misc_Backpackheap"; rank = ""; position[] = {-8.50073,5.22949,0}; dir = 0;};
class Object51 {side = 8; vehicle = "Land_Pallet_F"; rank = ""; position[] = {-9.56567,11.3743,0}; dir = 224.332;};
class Object52 {side = 8; vehicle = "Land_PaperBox_open_full_F"; rank = ""; position[] = {-2.05981,-3.31958,0}; dir = 0;};
class Object53 {side = 8; vehicle = "Land_PaperBox_open_empty_F"; rank = ""; position[] = {-2.05981,1.31421,0}; dir = 180;};
class Object54 {side = 8; vehicle = "Land_PaperBox_open_empty_F"; rank = ""; position[] = {-0.499512,-3.37549,0}; dir = 180;};
class Object55 {side = 8; vehicle = "CargoNet_01_box_F"; rank = ""; position[] = {-2.30981,-8.1853,0}; dir = 165.001;};
class Object56 {side = 8; vehicle = "CargoNet_01_box_F"; rank = ""; position[] = {-0.624512,-7.75,0}; dir = 180.001;};
class Object57 {side = 8; vehicle = "Land_PaperBox_closed_F"; rank = ""; position[] = {-0.487061,1.25244,0}; dir = 90;};
class Object58 {side = 8; vehicle = "Land_PaperBox_closed_F"; rank = ""; position[] = {-0.862061,6.50244,0}; dir = 90;};
class Object59 {side = 8; vehicle = "Land_PaperBox_closed_F"; rank = ""; position[] = {-2.4939,6.48853,0}; dir = 165;};
class Object60 {side = 8; vehicle = "Land_Pallets_stack_F"; rank = ""; position[] = {-8.80859,15.4382,0}; dir = 360;};
class Object61 {side = 8; vehicle = "Land_Pallets_stack_F"; rank = ""; position[] = {-7.12451,15,0}; dir = 194.999;};
class Object62 {side = 8; vehicle = "Land_WaterBarrel_F"; rank = ""; position[] = {-14.3745,10,0}; dir = 359.995;};
class Object63 {side = 8; vehicle = "Land_WaterBarrel_F"; rank = ""; position[] = {-13.2495,10.625,0}; dir = 359.995;};
class Object64 {side = 8; vehicle = "Body"; rank = ""; position[] = {-14.3918,19.7126,0}; dir = 345;};
class Object65 {side = 8; vehicle = "Land_CratesShabby_F"; rank = ""; position[] = {-15.623,-8.49219,0}; dir = 180;};
class Object66 {side = 8; vehicle = "Body"; rank = ""; position[] = {-13.2449,15.8682,0}; dir = 0;};
class Object67 {side = 8; vehicle = "Body"; rank = ""; position[] = {-14.1199,15.8682,0}; dir = 0;};
class Object68 {side = 8; vehicle = "Body"; rank = ""; position[] = {-14.9949,15.8682,0}; dir = 0;};
class Object69 {side = 8; vehicle = "Land_Pallet_vertical_F"; rank = ""; position[] = {-8.80981,16.4431,0}; dir = 359.996;};
class Object70 {side = 8; vehicle = "Land_PalletTrolley_01_khaki_F"; rank = ""; position[] = {-1.78442,5.51953,0}; dir = 209.324;};
class Object71 {side = 8; vehicle = "Land_PlasticCase_01_large_F"; rank = ""; position[] = {-13.4199,6.1189,0}; dir = 299.997;};
class Object72 {side = 8; vehicle = "Land_MetalCase_01_large_F"; rank = ""; position[] = {-13.6699,0.743896,0}; dir = 299.998;};
class Object73 {side = 8; vehicle = "Barrel5"; rank = ""; position[] = {-1.37451,16.875,0}; dir = 330;};
class Object74 {side = 8; vehicle = "Barrel5"; rank = ""; position[] = {-2.24951,16.875,0}; dir = 195;};
class Object75 {side = 8; vehicle = "Barrel5"; rank = ""; position[] = {-2.0083,15.3235,0}; dir = 300;};
class Object76 {side = 8; vehicle = "Barrel5"; rank = ""; position[] = {-2.68481,15.8147,0}; dir = 120;};
class Object77 {side = 8; vehicle = "Barrel5"; rank = ""; position[] = {-1.93481,16.0647,0}; dir = 0;};
class Object78 {side = 8; vehicle = "Barrel5"; rank = ""; position[] = {-3.12451,16.875,0}; dir = 0;};
class Object79 {side = 8; vehicle = "Barrel1"; rank = ""; position[] = {-2.9353,20.3054,0}; dir = 180;};
class Object80 {side = 8; vehicle = "Barrel1"; rank = ""; position[] = {-2.30981,19.8147,0}; dir = 0;};
class Object81 {side = 8; vehicle = "Land_CratesPlastic_F"; rank = ""; position[] = {-8.93579,9.6936,0}; dir = 225;};
class Object82 {side = 8; vehicle = "Land_MetalBarrel_F"; rank = ""; position[] = {-2.31006,10.1897,0}; dir = 29.9735;};
class Object83 {side = 8; vehicle = "Land_MetalBarrel_F"; rank = ""; position[] = {-1.24951,11.875,0}; dir = 285.006;};
class Object84 {side = 8; vehicle = "Land_MetalBarrel_F"; rank = ""; position[] = {-1.93506,10.9397,0}; dir = 0.00614924;};
class Object85 {side = 8; vehicle = "Land_MetalBarrel_F"; rank = ""; position[] = {-3.12451,11.875,0}; dir = 314.999;};
class Object86 {side = 8; vehicle = "Land_MetalBarrel_F"; rank = ""; position[] = {-2.12451,11.875,0}; dir = 195;};
class Object87 {side = 8; vehicle = "MetalBarrel_burning_F"; rank = ""; position[] = {-1.12451,8.875,0}; dir = 0;};
class Object88 {side = 8; vehicle = "Land_MetalBarrel_empty_F"; rank = ""; position[] = {-2.68481,10.9397,0}; dir = 150;};
class Object89 {side = 8; vehicle = "Land_MetalCase_01_medium_F"; rank = ""; position[] = {-14.5449,0.243896,0}; dir = 209.999;};
class Object90 {side = 8; vehicle = "Land_PlasticCase_01_medium_F"; rank = ""; position[] = {-14.4199,5.8689,0}; dir = 330.001;};
class Object91 {side = 8; vehicle = "Land_MetalCase_01_small_F"; rank = ""; position[] = {-6.91992,-0.256104,0}; dir = 269.993;};
class Object92 {side = 8; vehicle = "Land_MetalCase_01_small_F"; rank = ""; position[] = {-8.91992,-0.131104,0}; dir = 269.994;};
class Object93 {side = 8; vehicle = "Land_MetalCase_01_small_F"; rank = ""; position[] = {-13.7949,-0.131104,0}; dir = 254.995;};
class Object94 {side = 8; vehicle = "Land_PlasticCase_01_small_F"; rank = ""; position[] = {-13.8745,5.375,0}; dir = 59.9988;};
class Object95 {side = 8; vehicle = "Land_TentDome_F"; rank = ""; position[] = {-5.78149,-3.36401,0}; dir = 285;};
class Object96 {side = 8; vehicle = "Misc_cargo_cont_net1"; rank = ""; position[] = {-8.1687,20.6196,0}; dir = 0;};
class Object97 {side = 8; vehicle = "Body"; rank = ""; position[] = {-14.3833,20.7332,0}; dir = 0;};
class Object98 {side = 8; vehicle = "Body"; rank = ""; position[] = {-14.3833,25.8582,0}; dir = 0;};
class Object99 {side = 8; vehicle = "Body"; rank = ""; position[] = {-14.3691,24.8757,0}; dir = 15;};
class Object100 {side = 8; vehicle = "Fort_Crate_wood"; rank = ""; position[] = {-8.81128,25.3167,0}; dir = 0;};
class Object101 {side = 8; vehicle = "Fort_Crate_wood"; rank = ""; position[] = {-7.55371,24.949,0}; dir = 210;};
class Object102 {side = 8; vehicle = "Barrel2"; rank = ""; position[] = {-2.71533,24.9539,0}; dir = 0;};
class Object103 {side = 8; vehicle = "Land_Sack_F"; rank = ""; position[] = {-8.50342,24.4968,0}; dir = 270;};
class Object104 {side = 8; vehicle = "Barrel1"; rank = ""; position[] = {-2.20361,20.6584,0}; dir = 225;};
class Object105 {side = 8; vehicle = "Barrel2"; rank = ""; position[] = {-2.37451,25.625,0}; dir = 0;};
class Object106 {side = 8; vehicle = "Barrel2"; rank = ""; position[] = {-1.82129,25.0667,0}; dir = 0;};
class Object107 {side = 8; vehicle = "Barrel1"; rank = ""; position[] = {-3.24951,21.375,0}; dir = 225;};
class Object108 {side = 8; vehicle = "Barrel1"; rank = ""; position[] = {-2.37451,21.375,0}; dir = 150;};
class Object109 {side = 8; vehicle = "Barrel1"; rank = ""; position[] = {-1.49951,21.375,0}; dir = 45;};
class Object110 {side = 8; vehicle = "Barrel2"; rank = ""; position[] = {-2.37451,26.625,0}; dir = 0;};
class Object111 {side = 8; vehicle = "Barrel2"; rank = ""; position[] = {-3.16772,26.6172,0}; dir = 240;};
class Object112 {side = 8; vehicle = "Barrel2"; rank = ""; position[] = {-1.49951,26.625,0}; dir = 120;};
class Object113 {side = 8; vehicle = "AmmoCrates_NoInteractive_Large"; rank = ""; position[] = {3.41626,-18.1306,0}; dir = 0;};
class Object114 {side = 8; vehicle = "Gunrack1"; rank = ""; position[] = {3.97998,-12.9475,0}; dir = 90;};
class Object115 {side = 8; vehicle = "Gunrack1"; rank = ""; position[] = {3.97998,-13.9475,0}; dir = 90;};
class Object116 {side = 8; vehicle = "AmmoCrates_NoInteractive_Medium"; rank = ""; position[] = {4.23779,-19.7253,0}; dir = 90;};
class Object117 {side = 8; vehicle = "Land_PowerGenerator_F"; rank = ""; position[] = {11.1257,-14.1406,0}; dir = 180;};
class Object118 {side = 8; vehicle = "PowerGenerator"; rank = ""; position[] = {8.62549,-14.125,0}; dir = 0;};
class Object119 {side = 8; vehicle = "PowerGenerator_EP1"; rank = ""; position[] = {9.87549,-14.125,0}; dir = 0;};
class Object120 {side = 8; vehicle = "AmmoCrate_NoInteractive_"; rank = ""; position[] = {3.35791,-19.6526,0}; dir = 90;};
class Object121 {side = 8; vehicle = "Land_Sleeping_bag_F"; rank = ""; position[] = {8.5708,-19.6721,0}; dir = 330;};
class Object122 {side = 8; vehicle = "Land_Sleeping_bag_brown_F"; rank = ""; position[] = {10.9802,-18.5894,0}; dir = 15;};
class Object123 {side = 8; vehicle = "Land_Ground_sheet_yellow_F"; rank = ""; position[] = {11.376,-20.6255,0}; dir = 225;};
class Object124 {side = 8; vehicle = "Land_Ground_sheet_blue_F"; rank = ""; position[] = {9.68945,-18.9353,0}; dir = 0;};
class Object125 {side = 8; vehicle = "Land_Sleeping_bag_folded_F"; rank = ""; position[] = {11.7505,-19.9761,0}; dir = 180;};
class Object126 {side = 8; vehicle = "Land_Sleeping_bag_brown_folded_F"; rank = ""; position[] = {9.43945,-18.6846,0}; dir = 134.999;};
class Object127 {side = 8; vehicle = "Land_Ground_sheet_folded_yellow_F"; rank = ""; position[] = {11.3394,-18.4688,0}; dir = 255.027;};
class Object128 {side = 8; vehicle = "Land_Ground_sheet_folded_F"; rank = ""; position[] = {8.06763,-19.7253,0}; dir = 285.006;};
class Object129 {side = 8; vehicle = "Land_Pillow_old_F"; rank = ""; position[] = {10.8479,-18.3123,0}; dir = 210.032;};
class Object130 {side = 8; vehicle = "Land_Pillow_old_F"; rank = ""; position[] = {8.38696,-19.688,0}; dir = 119.974;};
class Object131 {side = 8; vehicle = "Land_Pillow_F"; rank = ""; position[] = {11.8611,-20.3379,0}; dir = 180.056;};
class Object132 {side = 8; vehicle = "Land_Pillow_camouflage_F"; rank = ""; position[] = {9.85059,-18.1877,0}; dir = 195.057;};
class Object133 {side = 8; vehicle = "AmmoCrates_NoInteractive_Small"; rank = ""; position[] = {4.60498,-18.1484,0}; dir = 90;};
class Object134 {side = 8; vehicle = "GunrackUS_EP1"; rank = ""; position[] = {3.84009,-8.62671,0}; dir = 90;};
class Object135 {side = 8; vehicle = "GunrackUS_EP1"; rank = ""; position[] = {3.84009,-7.62671,0}; dir = 90;};
class Object136 {side = 8; vehicle = "Land_WaterTank_F"; rank = ""; position[] = {9.75049,1,0}; dir = 0.000245535;};
class Object137 {side = 8; vehicle = "CUP_hromada_beden_dekorativniX"; rank = ""; position[] = {3.44019,5.5647,0}; dir = 0;};
class Object138 {side = 8; vehicle = "GunrackTK_EP1"; rank = ""; position[] = {4.02051,-3.91626,0}; dir = 90;};
class Object139 {side = 8; vehicle = "GunrackTK_EP1"; rank = ""; position[] = {4.02051,-2.91626,0}; dir = 90;};
class Object140 {side = 8; vehicle = "CUP_ammobednaX"; rank = ""; position[] = {3.69458,1.54272,0}; dir = 0;};
class Object141 {side = 8; vehicle = "Land_Pallet_MilBoxes_F"; rank = ""; position[] = {10.615,-4.37744,0}; dir = 90;};
class Object142 {side = 8; vehicle = "Land_Pallet_MilBoxes_F"; rank = ""; position[] = {10.636,-2.74756,0}; dir = 270;};
class Object143 {side = 8; vehicle = "Land_Pallet_MilBoxes_F"; rank = ""; position[] = {9.00293,-4.3855,0}; dir = 0;};
class Object144 {side = 8; vehicle = "Land_MapBoard_F"; rank = ""; position[] = {8.74927,-7.61963,0}; dir = 345.035;};
class Object145 {side = 8; vehicle = "CUP_A2_barels2"; rank = ""; position[] = {9.83374,16.4065,0}; dir = 45;};
class Object146 {side = 8; vehicle = "CUP_A2_barels3"; rank = ""; position[] = {8.42212,15.4233,0}; dir = 75;};
class Object147 {side = 8; vehicle = "Barrels"; rank = ""; position[] = {8.87549,19.875,0}; dir = 60;};
class Object148 {side = 8; vehicle = "Barrels"; rank = ""; position[] = {10.6738,19.8572,0}; dir = 105;};
class Object149 {side = 8; vehicle = "Land_Sacks_goods_F"; rank = ""; position[] = {9.69092,6.32788,0}; dir = 0;};
class Object150 {side = 8; vehicle = "CargoNet_01_barrels_F"; rank = ""; position[] = {10.7505,9.625,0}; dir = 105.001;};
class Object151 {side = 8; vehicle = "CargoNet_01_barrels_F"; rank = ""; position[] = {9.12549,10.375,0}; dir = 165.002;};
class Object152 {side = 8; vehicle = "Notice_board"; rank = ""; position[] = {9.00049,-9,0}; dir = 15;};
class Object153 {side = 8; vehicle = "CUP_bedna_ammo2X"; rank = ""; position[] = {4.19019,-0.435303,0}; dir = 270;};
class Object154 {side = 8; vehicle = "Barrel6"; rank = ""; position[] = {4.06519,11.1897,0}; dir = 0;};
class Object155 {side = 8; vehicle = "Barrel6"; rank = ""; position[] = {3.75049,12.125,0}; dir = 120;};
class Object156 {side = 8; vehicle = "Barrel6"; rank = ""; position[] = {3.99707,10.3611,0}; dir = 135;};
class Object157 {side = 8; vehicle = "Barrel6"; rank = ""; position[] = {3.31519,10.8147,0}; dir = 120;};
class Object158 {side = 8; vehicle = "Barrel6"; rank = ""; position[] = {3.00049,12.125,0}; dir = 210;};
class Object159 {side = 8; vehicle = "Barrel6"; rank = ""; position[] = {4.50049,12.125,0}; dir = 60;};
class Object160 {side = 8; vehicle = "Barrel4"; rank = ""; position[] = {2.87549,16.875,0}; dir = 0;};
class Object161 {side = 8; vehicle = "Barrel4"; rank = ""; position[] = {4.11182,15.7507,0}; dir = 0;};
class Object162 {side = 8; vehicle = "Barrel4"; rank = ""; position[] = {4.50049,16.875,0}; dir = 150;};
class Object163 {side = 8; vehicle = "Barrel4"; rank = ""; position[] = {3.44019,16.0647,0}; dir = 0;};
class Object164 {side = 8; vehicle = "Barrel4"; rank = ""; position[] = {3.75049,16.875,0}; dir = 315;};
class Object165 {side = 8; vehicle = "Barrel4"; rank = ""; position[] = {3.34204,15.3469,0}; dir = 105;};
class Object166 {side = 8; vehicle = "Barrel3"; rank = ""; position[] = {3.39478,19.9353,0}; dir = 60;};
class Object167 {side = 8; vehicle = "Barrel3"; rank = ""; position[] = {3.94019,20.4397,0}; dir = 15;};
class Object168 {side = 8; vehicle = "Land_Sack_EP1"; rank = ""; position[] = {9.06592,5.69507,0}; dir = 75;};
class Object169 {side = 8; vehicle = "Land_Ammobox_rounds_F"; rank = ""; position[] = {4.43994,0.814697,0}; dir = 329.986;};
class Object170 {side = 8; vehicle = "Land_Ammobox_rounds_F"; rank = ""; position[] = {4.06519,0.939697,0}; dir = 119.984;};
class Object171 {side = 8; vehicle = "Land_stand_small_EP1"; rank = ""; position[] = {9.87549,4.86792,0}; dir = 0;};
class Object172 {side = 8; vehicle = "MapBoard_seismic_F"; rank = ""; position[] = {10.5005,-7.36963,0}; dir = 0.00945563;};
class Object173 {side = 8; vehicle = "MapBoard_altis_F"; rank = ""; position[] = {11.0032,-8.87061,0}; dir = 29.9983;};
class Object174 {side = 8; vehicle = "Barrel3"; rank = ""; position[] = {2.62549,21.375,0}; dir = 15;};
class Object175 {side = 8; vehicle = "Barrel3"; rank = ""; position[] = {3.06519,20.6897,0}; dir = 0;};
class Object176 {side = 8; vehicle = "Barrel3"; rank = ""; position[] = {3.37549,21.375,0}; dir = 210;};
class Object177 {side = 8; vehicle = "Land_BarrelEmpty_grey_F"; rank = ""; position[] = {10.1899,25.8147,0}; dir = 359.981;};
class Object178 {side = 8; vehicle = "Land_BarrelTrash_F"; rank = ""; position[] = {4.18994,26.0647,0}; dir = 359.981;};
class Object179 {side = 8; vehicle = "Land_BarrelWater_grey_F"; rank = ""; position[] = {8.93994,24.5647,0}; dir = 359.981;};
class Object180 {side = 8; vehicle = "Land_BarrelSand_grey_F"; rank = ""; position[] = {10.1899,24.5647,0}; dir = 359.981;};
class Object181 {side = 8; vehicle = "Land_BarrelWater_F"; rank = ""; position[] = {4.18994,24.8147,0}; dir = 359.981;};
class Object182 {side = 8; vehicle = "Land_BarrelSand_F"; rank = ""; position[] = {2.93994,26.0647,0}; dir = 359.981;};
class Object183 {side = 8; vehicle = "Land_BarrelEmpty_F"; rank = ""; position[] = {2.93994,24.8147,0}; dir = 359.981;};
class Object184 {side = 8; vehicle = "Land_BarrelTrash_grey_F"; rank = ""; position[] = {8.93994,25.8147,0}; dir = 359.981;};
class Object185 {side = 8; vehicle = "Barrel3"; rank = ""; position[] = {4.12549,21.375,0}; dir = 270;};
};
class ExternalItems {
name = $STR_ZECCUP_MilitaryDesert_ConstructionSuppliesLarge_ExternalItems; // Credit: 2600K
icon = "\a3\Ui_f\data\Map\Markers\Military\unknown_ca.paa";
side = 8;
class Object0 {side = 8; vehicle = "Land_ScrapHeap_1_F"; rank = ""; position[] = {-12.1576,-17.9597,0}; dir = 0;};
class Object1 {side = 8; vehicle = "WaterPump_01_forest_F"; rank = ""; position[] = {-3.25,-18.125,0}; dir = 0.00178549;};
class Object2 {side = 8; vehicle = "WaterPump_01_sand_F"; rank = ""; position[] = {-7.25,-18.125,0}; dir = 0.00329663;};
class Object3 {side = 8; vehicle = "Misc_cargo_cont_small2"; rank = ""; position[] = {-12.2482,-12.1199,0}; dir = 0;};
class Object4 {side = 8; vehicle = "Land_HBarrier_1_F"; rank = ""; position[] = {-4.37549,-12.877,0}; dir = 0;};
class Object5 {side = 8; vehicle = "Land_HBarrier_1_F"; rank = ""; position[] = {-6.37549,-12.877,0}; dir = 0;};
class Object6 {side = 8; vehicle = "Land_Cargo20_military_green_F"; rank = ""; position[] = {-17.25,-12.875,0}; dir = 270;};
class Object7 {side = 8; vehicle = "Land_Cargo10_military_green_F"; rank = ""; position[] = {-17.25,-18.125,0}; dir = 270;};
class Object8 {side = 8; vehicle = "Land_HBarrier5"; rank = ""; position[] = {-7.88171,7.70605,0}; dir = 0;};
class Object9 {side = 8; vehicle = "Land_Ind_TankSmall2"; rank = ""; position[] = {-12.2843,1.87646,0}; dir = 90;};
class Object10 {side = 8; vehicle = "Land_Cargo20_sand_F"; rank = ""; position[] = {-17.25,15.125,0}; dir = 270;};
class Object11 {side = 8; vehicle = "Land_Cargo20_grey_F"; rank = ""; position[] = {-17.25,0.125,0}; dir = 270;};
class Object12 {side = 8; vehicle = "Land_obstacle_run_duck"; rank = ""; position[] = {-5.84155,18.6313,0}; dir = 0;};
class Object13 {side = 8; vehicle = "Land_HBarrier_5_F"; rank = ""; position[] = {-7.62427,-5.62354,0}; dir = 0;};
class Object14 {side = 8; vehicle = "Land_HBarrier3"; rank = ""; position[] = {-6.7821,3.84473,0}; dir = 0;};
class Object15 {side = 8; vehicle = "Misc_cargo_cont_small"; rank = ""; position[] = {-12.2512,-5.12622,0}; dir = 0;};
class Object16 {side = 8; vehicle = "Land_Cargo10_sand_F"; rank = ""; position[] = {-17.25,9.875,0}; dir = 270;};
class Object17 {side = 8; vehicle = "Land_Cargo10_grey_F"; rank = ""; position[] = {-17.25,-5.125,0}; dir = 270;};
class Object18 {side = 8; vehicle = "Land_obstacle_get_over"; rank = ""; position[] = {-5.02881,13.2407,0}; dir = 0;};
class Object19 {side = 8; vehicle = "Land_HBarrier_3_F"; rank = ""; position[] = {-6.48938,-9.14258,0}; dir = 0;};
class Object20 {side = 8; vehicle = "Land_HBarrier1"; rank = ""; position[] = {-4.6167,1.12695,0}; dir = 0;};
class Object21 {side = 8; vehicle = "Land_HBarrier1"; rank = ""; position[] = {-6.8667,1.12695,0}; dir = 0;};
class Object22 {side = 8; vehicle = "Land_Pipes_large_F"; rank = ""; position[] = {-10.1986,11.8413,0}; dir = 90;};
class Object23 {side = 8; vehicle = "Land_Pipes_small_F"; rank = ""; position[] = {-10.2567,17.8672,0}; dir = 89.9999;};
class Object24 {side = 8; vehicle = "Land_Ind_TankSmall"; rank = ""; position[] = {-12.2843,11.8765,0}; dir = 90;};
class Object25 {side = 8; vehicle = "Misc_cargo_cont_net3"; rank = ""; position[] = {-12.8037,33.6946,0}; dir = 0;};
class Object26 {side = 8; vehicle = "Land_obstacle_prone"; rank = ""; position[] = {-5.42224,25.4561,0}; dir = 0;};
class Object27 {side = 8; vehicle = "Land_IronPipes_F"; rank = ""; position[] = {-11.9547,25.9565,0}; dir = 270;};
class Object28 {side = 8; vehicle = "Misc_cargo_cont_net2"; rank = ""; position[] = {-6.22131,32.1306,0}; dir = 0;};
class Object29 {side = 8; vehicle = "Land_Misc_IronPipes_EP1"; rank = ""; position[] = {-14.4607,24.6724,0}; dir = 90;};
class Object30 {side = 8; vehicle = "Land_BagFence_Round_F"; rank = ""; position[] = {11.4988,-14.7092,0}; dir = 45;};
class Object31 {side = 8; vehicle = "Land_BagFence_Round_F"; rank = ""; position[] = {20.0886,-14.7588,0}; dir = 315;};
class Object32 {side = 8; vehicle = "Land_BagFenceRound"; rank = ""; position[] = {7.20386,-14.3687,0}; dir = 315;};
class Object33 {side = 8; vehicle = "Land_BagFenceRound"; rank = ""; position[] = {1.75024,-14.324,0}; dir = 45;};
class Object34 {side = 8; vehicle = "Land_BagFence_Long_F"; rank = ""; position[] = {17.1211,-17.6089,0}; dir = 0;};
class Object35 {side = 8; vehicle = "Land_BagFence_Long_F"; rank = ""; position[] = {14.2461,-17.6094,0}; dir = 0;};
class Object36 {side = 8; vehicle = "Land_BagFence_Long_F"; rank = ""; position[] = {17.2539,-15.1406,0}; dir = 180;};
class Object37 {side = 8; vehicle = "Land_BagFence_Long_F"; rank = ""; position[] = {14.3789,-15.1406,0}; dir = 180;};
class Object38 {side = 8; vehicle = "Land_BagFenceLong"; rank = ""; position[] = {4.37061,-17.729,0}; dir = 0;};
class Object39 {side = 8; vehicle = "Land_BagFenceLong"; rank = ""; position[] = {4.49561,-14.729,0}; dir = 0;};
class Object40 {side = 8; vehicle = "Land_BagFence_Short_F"; rank = ""; position[] = {12.1125,-19.3826,0}; dir = 90;};
class Object41 {side = 8; vehicle = "Land_BagFence_Short_F"; rank = ""; position[] = {19.4875,-19.1321,0}; dir = 90;};
class Object42 {side = 8; vehicle = "Land_BagFenceShort"; rank = ""; position[] = {2.37598,-19.6091,0}; dir = 90;};
class Object43 {side = 8; vehicle = "Land_BagFenceShort"; rank = ""; position[] = {6.62598,-19.2341,0}; dir = 90;};
class Object44 {side = 8; vehicle = "Land_BagFence_Corner_F"; rank = ""; position[] = {19.5344,-17.6218,0}; dir = 0;};
class Object45 {side = 8; vehicle = "Land_BagFence_Corner_F"; rank = ""; position[] = {12.1179,-17.583,0}; dir = 270;};
class Object46 {side = 8; vehicle = "Land_BagFenceCorner"; rank = ""; position[] = {2.38916,-17.7344,0}; dir = 270;};
class Object47 {side = 8; vehicle = "Land_BagFenceCorner"; rank = ""; position[] = {6.65845,-17.7097,0}; dir = 0;};
class Object48 {side = 8; vehicle = "Land_BagFence_End_F"; rank = ""; position[] = {11.1421,-12.4275,0}; dir = 270;};
class Object49 {side = 8; vehicle = "Land_BagFence_End_F"; rank = ""; position[] = {20.5171,-12.427,0}; dir = 270;};
class Object50 {side = 8; vehicle = "Land_BagFence_End_F"; rank = ""; position[] = {12.3818,-21.0569,0}; dir = 75;};
class Object51 {side = 8; vehicle = "Land_BagFenceEnd"; rank = ""; position[] = {6.87305,-20.9202,0}; dir = 75;};
class Object52 {side = 8; vehicle = "Land_BagFenceEnd"; rank = ""; position[] = {0.987793,-12.2449,0}; dir = 240;};
class Object53 {side = 8; vehicle = "Land_BagFence_End_F"; rank = ""; position[] = {19.7568,-20.8064,0}; dir = 75;};
class Object54 {side = 8; vehicle = "Hhedgehog_concreteBig"; rank = ""; position[] = {15.1245,8.38037,0}; dir = 0;};
class Object55 {side = 8; vehicle = "Hhedgehog_concreteBig"; rank = ""; position[] = {5.62451,8.38037,0}; dir = 0;};
class Object56 {side = 8; vehicle = "Hhedgehog_concrete"; rank = ""; position[] = {5.62231,13.6304,0}; dir = 0;};
class Object57 {side = 8; vehicle = "Hhedgehog_concrete"; rank = ""; position[] = {14.7473,13.6304,0}; dir = 0;};
class Object58 {side = 8; vehicle = "Land_Razorwire_F"; rank = ""; position[] = {3.02075,-0.802246,0}; dir = 0;};
class Object59 {side = 8; vehicle = "Land_Razorwire_F"; rank = ""; position[] = {11.5208,-0.802246,0}; dir = 0;};
class Object60 {side = 8; vehicle = "Fort_RazorWire"; rank = ""; position[] = {11.3958,-3.30225,0}; dir = 0;};
class Object61 {side = 8; vehicle = "Fort_RazorWire"; rank = ""; position[] = {3.02075,-3.30225,0}; dir = 0;};
class Object62 {side = 8; vehicle = "Wire"; rank = ""; position[] = {1.78223,2.6958,0}; dir = 0;};
class Object63 {side = 8; vehicle = "Wire"; rank = ""; position[] = {8.91455,2.49536,0}; dir = 15;};
class Object64 {side = 8; vehicle = "Wire"; rank = ""; position[] = {14.8684,2.6189,0}; dir = 165;};
class Object65 {side = 8; vehicle = "Land_fort_bagfence_corner"; rank = ""; position[] = {1.91113,17.7258,0}; dir = 0;};
class Object66 {side = 8; vehicle = "Land_Garbage_square5_F"; rank = ""; position[] = {17.0374,19.9521,0}; dir = 0;};
class Object67 {side = 8; vehicle = "Land_GarbagePallet_F"; rank = ""; position[] = {17.0244,19.8438,0}; dir = 0;};
class Object68 {side = 8; vehicle = "Land_fort_bagfence_long"; rank = ""; position[] = {6.3606,18.3958,0}; dir = 90;};
class Object69 {side = 8; vehicle = "FenceWoodPalet"; rank = ""; position[] = {15.3674,-5.53516,0}; dir = 270;};
class Object70 {side = 8; vehicle = "Land_BagFence_Round_F"; rank = ""; position[] = {19.4709,-11.2056,0}; dir = 0;};
class Object71 {side = 8; vehicle = "Land_BagFence_Round_F"; rank = ""; position[] = {12.2209,-11.2061,0}; dir = 0;};
class Object72 {side = 8; vehicle = "Land_BagFence_Round_F"; rank = ""; position[] = {15.7913,-8.79736,0}; dir = 180;};
class Object73 {side = 8; vehicle = "Land_BagFenceRound"; rank = ""; position[] = {7.09277,-10.0654,0}; dir = 0;};
class Object74 {side = 8; vehicle = "Land_BagFenceRound"; rank = ""; position[] = {4.65625,-8.67383,0}; dir = 180;};
class Object75 {side = 8; vehicle = "Land_BagFenceRound"; rank = ""; position[] = {2.21777,-9.81543,0}; dir = 0;};
class Object76 {side = 8; vehicle = "CUP_A2_ohrada_popelnice_roh"; rank = ""; position[] = {7.82446,-5.79468,0}; dir = 0;};
class Object77 {side = 8; vehicle = "FenceWood"; rank = ""; position[] = {11.8821,-5.39209,0}; dir = 90;};
class Object78 {side = 8; vehicle = "Land_CncBarrier_F"; rank = ""; position[] = {9.7478,17.8672,0}; dir = 0;};
class Object79 {side = 8; vehicle = "Land_CncBarrier_F"; rank = ""; position[] = {12.7478,17.8672,0}; dir = 0;};
class Object80 {side = 8; vehicle = "Land_CncBarrier_stripes_F"; rank = ""; position[] = {12.75,18.8672,0}; dir = 0;};
class Object81 {side = 8; vehicle = "Land_CncBarrier_stripes_F"; rank = ""; position[] = {9.75,18.8672,0}; dir = 0;};
class Object82 {side = 8; vehicle = "Land_CncBlock_D"; rank = ""; position[] = {12.741,16.9924,0}; dir = 0;};
class Object83 {side = 8; vehicle = "Land_CncBlock_D"; rank = ""; position[] = {9.74097,16.9924,0}; dir = 0;};
class Object84 {side = 8; vehicle = "Land_CncBlock_Stripes"; rank = ""; position[] = {12.7622,19.9448,0}; dir = 0;};
class Object85 {side = 8; vehicle = "Land_CncBlock_Stripes"; rank = ""; position[] = {9.76221,19.9448,0}; dir = 0;};
class Object86 {side = 8; vehicle = "Land_BagFence_Short_F"; rank = ""; position[] = {17.6294,-9.99048,0}; dir = 225;};
class Object87 {side = 8; vehicle = "Land_BagFence_Short_F"; rank = ""; position[] = {13.9951,-10.0029,0}; dir = 135;};
class Object88 {side = 8; vehicle = "Land_Pneu"; rank = ""; position[] = {18.25,18.375,0}; dir = 0;};
class Object89 {side = 8; vehicle = "CUP_A2_ohrada_popelnice"; rank = ""; position[] = {5.4231,-5.93555,0}; dir = 90;};
class Object90 {side = 8; vehicle = "CUP_A2_ohrada_popelnice"; rank = ""; position[] = {5.41309,-5.78564,0}; dir = 270;};
class Object91 {side = 8; vehicle = "CUP_A2_ohrada_popelnice"; rank = ""; position[] = {4.4231,-5.93555,0}; dir = 90;};
class Object92 {side = 8; vehicle = "CUP_A2_ohrada_popelnice"; rank = ""; position[] = {3.4231,-5.93555,0}; dir = 90;};
class Object93 {side = 8; vehicle = "Land_BagFence_End_F"; rank = ""; position[] = {10.7432,-9.56909,0}; dir = 255;};
class Object94 {side = 8; vehicle = "Land_BagFence_End_F"; rank = ""; position[] = {21.4202,-9.85254,0}; dir = 315;};
class Object95 {side = 8; vehicle = "Land_BagFenceEnd"; rank = ""; position[] = {9.18823,-9.51782,0}; dir = 0;};
class Object97 {side = 8; vehicle = "Land_fort_rampart_EP1"; rank = ""; position[] = {5.52441,28.875,0}; dir = 270;};
class Object98 {side = 8; vehicle = "Land_fort_bagfence_round"; rank = ""; position[] = {3.63647,22.2454,0}; dir = 0;};
class Object99 {side = 8; vehicle = "Land_GarbageBags_F"; rank = ""; position[] = {16.8347,30.9905,0}; dir = 0;};
class Object100 {side = 8; vehicle = "Land_Garbage_square5_F"; rank = ""; position[] = {17.1624,31.7021,0}; dir = 0;};
class Object101 {side = 8; vehicle = "Land_Garbage_square5_F"; rank = ""; position[] = {16.9124,25.9521,0}; dir = 0;};
class Object102 {side = 8; vehicle = "Land_GarbageWashingMachine_F"; rank = ""; position[] = {16.8801,25.7026,0}; dir = 0;};
class Object103 {side = 8; vehicle = "CUP_A2_windbreak"; rank = ""; position[] = {11.1621,21.8574,0}; dir = 180;};
class Object104 {side = 8; vehicle = "Hedgehog"; rank = ""; position[] = {10.9116,28.7188,0}; dir = 30;};
class Object105 {side = 8; vehicle = "Hedgehog"; rank = ""; position[] = {11.8438,24.9634,0}; dir = 120;};
class Object106 {side = 8; vehicle = "Hedgehog"; rank = ""; position[] = {12.4961,32.4963,0}; dir = 255;};
class Object107 {side = 8; vehicle = "Land_fort_rampart"; rank = ""; position[] = {1.97559,28.875,0}; dir = 90;};
class Object108 {side = 8; vehicle = "Land_Pneu"; rank = ""; position[] = {15.5,24.375,0}; dir = 0;};
};
class Walls {
name = $STR_ZECCUP_MilitaryDesert_ConstructionSuppliesLarge_Walls; // Credit: 2600K
icon = "\a3\Ui_f\data\Map\Markers\Military\unknown_ca.paa";
side = 8;
class Object1 {side = 8; vehicle = "Hhedgehog_concreteBig"; rank = ""; position[] = {-17,-10,0}; dir = 0;};
class Object2 {side = 8; vehicle = "Hhedgehog_concreteBig"; rank = ""; position[] = {-27,-10,0}; dir = 0;};
class Object3 {side = 8; vehicle = "Hhedgehog_concreteBig"; rank = ""; position[] = {-37,-10,0}; dir = 0;};
class Object4 {side = 8; vehicle = "Hhedgehog_concrete"; rank = ""; position[] = {-28.002,-2,0}; dir = 0;};
class Object5 {side = 8; vehicle = "Hhedgehog_concrete"; rank = ""; position[] = {-37.002,-2,0}; dir = 0;};
class Object6 {side = 8; vehicle = "Hhedgehog_concrete"; rank = ""; position[] = {-19.002,-2,0}; dir = 0;};
class Object7 {side = 8; vehicle = "Land_Razorwire_F"; rank = ""; position[] = {-22.7288,2.06738,0}; dir = 0;};
class Object8 {side = 8; vehicle = "Land_Razorwire_F"; rank = ""; position[] = {-30.7288,2.06738,0}; dir = 0;};
class Object9 {side = 8; vehicle = "Land_Razorwire_F"; rank = ""; position[] = {-38.7288,2.06738,0}; dir = 0;};
class Object10 {side = 8; vehicle = "Fort_RazorWire"; rank = ""; position[] = {-38.7288,6.06738,0}; dir = 0;};
class Object11 {side = 8; vehicle = "Fort_RazorWire"; rank = ""; position[] = {-30.7288,6.06738,0}; dir = 0;};
class Object12 {side = 8; vehicle = "Fort_RazorWire"; rank = ""; position[] = {-22.7288,6.06738,0}; dir = 0;};
class Object13 {side = 8; vehicle = "Wire"; rank = ""; position[] = {-30.2173,-5.93457,0}; dir = 0;};
class Object14 {side = 8; vehicle = "Wire"; rank = ""; position[] = {-37.2173,-5.93457,0}; dir = 0;};
class Object15 {side = 8; vehicle = "CUP_A2_pletivo_wired_hole"; rank = ""; position[] = {-30.9827,10.1724,0}; dir = 0;};
class Object16 {side = 8; vehicle = "CUP_A2_pletivo_wired"; rank = ""; position[] = {-24.9827,10.1147,0}; dir = 0;};
class Object17 {side = 8; vehicle = "CUP_A2_pletivo_wired"; rank = ""; position[] = {-36.9827,10.1147,0}; dir = 0;};
class Object18 {side = 8; vehicle = "CUP_A2_pletivo_wired_branap"; rank = ""; position[] = {-19.5208,10.1147,0}; dir = 0;};
class Object19 {side = 8; vehicle = "CUP_A2_pletivo_wired_slope"; rank = ""; position[] = {-14.9897,10.1147,0}; dir = 0;};
class Object20 {side = 8; vehicle = "Wire"; rank = ""; position[] = {-22.2173,-5.93457,0}; dir = 0;};
class Object21 {side = 8; vehicle = "Land_IndFnc_9_F"; rank = ""; position[] = {-34.4976,17.9402,0}; dir = 0;};
class Object22 {side = 8; vehicle = "Land_Net_FenceD_8m_F"; rank = ""; position[] = {-15.0178,20.8816,0}; dir = 0;};
class Object23 {side = 8; vehicle = "Land_Net_Fence_8m_F"; rank = ""; position[] = {-33.0137,21,0}; dir = 0;};
class Object24 {side = 8; vehicle = "Land_Net_Fence_Gate_F"; rank = ""; position[] = {-25,21,0}; dir = 0;};
class Object25 {side = 8; vehicle = "Land_IndFnc_Corner_F"; rank = ""; position[] = {-21.0022,16.4192,0}; dir = 90;};
class Object26 {side = 8; vehicle = "Land_IndFnc_3_Hole_F"; rank = ""; position[] = {-22.4971,17.9683,0}; dir = 0;};
class Object27 {side = 8; vehicle = "Land_IndFnc_3_F"; rank = ""; position[] = {-37.4976,17.9978,0}; dir = 0;};
class Object28 {side = 8; vehicle = "Land_IndFnc_3_F"; rank = ""; position[] = {-25.4976,17.9978,0}; dir = 0;};
class Object29 {side = 8; vehicle = "Fence_Ind"; rank = ""; position[] = {-36.9976,13.9978,0}; dir = 0;};
class Object30 {side = 8; vehicle = "Land_Net_Fence_4m_F"; rank = ""; position[] = {-23.012,21,0}; dir = 0;};
class Object31 {side = 8; vehicle = "Fence_Ind_long"; rank = ""; position[] = {-32.4976,13.9368,0}; dir = 0;};
class Object32 {side = 8; vehicle = "Land_fort_rampart_EP1"; rank = ""; position[] = {16.2256,-8,0}; dir = 90;};
class Object33 {side = 8; vehicle = "Base_WarfareBBarrier10x"; rank = ""; position[] = {0.0441895,11.0581,0}; dir = 0;};
class Object34 {side = 8; vehicle = "Land_HBarrier_large"; rank = ""; position[] = {5.9873,-4.08545,0}; dir = 0;};
class Object35 {side = 8; vehicle = "Land_HBarrier_Big_F"; rank = ""; position[] = {-6.03516,-4.08228,0}; dir = 0;};
class Object36 {side = 8; vehicle = "Land_HBarrier5"; rank = ""; position[] = {3.74365,-7.92456,0}; dir = 0;};
class Object37 {side = 8; vehicle = "Land_HBarrier_5_F"; rank = ""; position[] = {-8.24878,-8.00391,0}; dir = 0;};
class Object38 {side = 8; vehicle = "Land_HBarrier3"; rank = ""; position[] = {4.84326,-12.0356,0}; dir = 0;};
class Object39 {side = 8; vehicle = "zed_kamenna"; rank = ""; position[] = {-0.44043,5.83081,0}; dir = 0;};
class Object40 {side = 8; vehicle = "zed_kamenna"; rank = ""; position[] = {-4.44043,5.83081,0}; dir = 0;};
class Object41 {side = 8; vehicle = "zed_kamenna"; rank = ""; position[] = {7.55957,5.83081,0}; dir = 0;};
class Object42 {side = 8; vehicle = "zed_kamenna"; rank = ""; position[] = {-8.44043,5.83081,0}; dir = 0;};
class Object43 {side = 8; vehicle = "zed_kamenna"; rank = ""; position[] = {3.55957,5.83081,0}; dir = 0;};
class Object44 {side = 8; vehicle = "zed_kamenna_desert"; rank = ""; position[] = {3.55957,1.83081,0}; dir = 0;};
class Object45 {side = 8; vehicle = "zed_kamenna_desert"; rank = ""; position[] = {-0.44043,1.83081,0}; dir = 0;};
class Object46 {side = 8; vehicle = "zed_kamenna_desert"; rank = ""; position[] = {7.55957,1.83081,0}; dir = 0;};
class Object47 {side = 8; vehicle = "zed_kamenna_desert"; rank = ""; position[] = {-8.44043,1.83081,0}; dir = 0;};
class Object48 {side = 8; vehicle = "zed_kamenna_desert"; rank = ""; position[] = {-4.44043,1.83081,0}; dir = 0;};
class Object50 {side = 8; vehicle = "Land_HBarrier_3_F"; rank = ""; position[] = {-7.11401,-12.0229,0}; dir = 0;};
class Object51 {side = 8; vehicle = "Land_HBarrier1"; rank = ""; position[] = {6.00879,-15.0037,0}; dir = 0;};
class Object52 {side = 8; vehicle = "Land_HBarrier_1_F"; rank = ""; position[] = {-6,-15.0076,0}; dir = 0;};
class Object53 {side = 8; vehicle = "Land_fort_rampart"; rank = ""; position[] = {16.2256,8,0}; dir = 90;};
class Object54 {side = 8; vehicle = "Base_WarfareBBarrier5x"; rank = ""; position[] = {-9.94189,14.0061,0}; dir = 90;};
class Object55 {side = 8; vehicle = "Base_WarfareBBarrier10xTall"; rank = ""; position[] = {0.0761719,15.3994,0}; dir = 0;};
class Object56 {side = 8; vehicle = "zed_civil_dira"; rank = ""; position[] = {33.9893,6.05103,0}; dir = 0;};
class Object57 {side = 8; vehicle = "zed_dira_desert"; rank = ""; position[] = {33.9893,1.97681,0}; dir = 0;};
class Object58 {side = 8; vehicle = "zed_dira"; rank = ""; position[] = {33.9893,9.97681,0}; dir = 0;};
class Object59 {side = 8; vehicle = "zed2_civil"; rank = ""; position[] = {24.9033,-2.06885,0}; dir = 0;};
class Object60 {side = 8; vehicle = "zed2_civil"; rank = ""; position[] = {18.9033,-2.06885,0}; dir = 0;};
class Object61 {side = 8; vehicle = "zed2_civil"; rank = ""; position[] = {30.9033,-2.06885,0}; dir = 0;};
class Object62 {side = 8; vehicle = "zed_desert"; rank = ""; position[] = {21.9856,1.93115,0}; dir = 0;};
class Object63 {side = 8; vehicle = "zed"; rank = ""; position[] = {21.9893,9.93115,0}; dir = 0;};
class Object64 {side = 8; vehicle = "zed_podplaz"; rank = ""; position[] = {27.9893,9.93115,0}; dir = 0;};
class Object65 {side = 8; vehicle = "zed_podplaz_desert"; rank = ""; position[] = {27.9893,1.93115,0}; dir = 0;};
class Object66 {side = 8; vehicle = "zed_civil"; rank = ""; position[] = {21.9893,5.93115,0}; dir = 0;};
class Object67 {side = 8; vehicle = "zed_podplaz_civil"; rank = ""; position[] = {27.9893,5.93115,0}; dir = 0;};
class Object68 {side = 8; vehicle = "Land_Wall_IndCnc_2deco_F"; rank = ""; position[] = {24,-6,0}; dir = 0;};
class Object69 {side = 8; vehicle = "Land_Wall_IndCnc_2deco_F"; rank = ""; position[] = {29.5,-6,0}; dir = 165;};
class Object70 {side = 8; vehicle = "Land_Wall_IndCnc_2deco_F"; rank = ""; position[] = {21,-6,0}; dir = 0;};
class Object71 {side = 8; vehicle = "Land_Wall_IndCnc_2deco_F"; rank = ""; position[] = {32.375,-5.875,0}; dir = 0;};
class Object72 {side = 8; vehicle = "Land_Wall_IndCnc_2deco_F"; rank = ""; position[] = {26.75,-5.875,0}; dir = 190;};
class Object73 {side = 8; vehicle = "Land_Wall_IndCnc_2deco_F"; rank = ""; position[] = {35.375,-5.875,0}; dir = 0;};
class Object74 {side = 8; vehicle = "Land_Wall_IndCnc_4_D_F"; rank = ""; position[] = {26.958,17.9934,0}; dir = 0;};
class Object75 {side = 8; vehicle = "Land_Wall_IndCnc_4_F"; rank = ""; position[] = {20.9856,17.9939,0}; dir = 0;};
class Object76 {side = 8; vehicle = "Land_Wall_IndCnc_4_F"; rank = ""; position[] = {32.9858,17.9939,0}; dir = 0;};
class Object77 {side = 8; vehicle = "zed2"; rank = ""; position[] = {24.9028,13.9312,0}; dir = 0;};
class Object78 {side = 8; vehicle = "zed2"; rank = ""; position[] = {18.9028,13.9312,0}; dir = 0;};
class Object79 {side = 8; vehicle = "Land_Wall_IndCnc_End_2_F"; rank = ""; position[] = {38.9893,17.9856,0}; dir = 0;};
class Object80 {side = 8; vehicle = "zed2"; rank = ""; position[] = {30.9028,13.9312,0}; dir = 0;};
};
class Sandbags_CUP_O_TK {
name = $STR_ZECCUP_MilitaryDesert_ConstructionSuppliesLarge_Sandbags_CUP_O_TK; // Credit: 2600K
icon = "\ca\data\flag_rus_co.paa";
side = 8;
class Object0 {side = 8; vehicle = "Land_fort_bagfence_long"; rank = ""; position[] = {-16.6403,-17.3892,0}; dir = 0;};
class Object1 {side = 8; vehicle = "Land_fort_bagfence_long"; rank = ""; position[] = {-19.6403,-17.3892,0}; dir = 0;};
class Object2 {side = 8; vehicle = "Land_fort_bagfence_corner"; rank = ""; position[] = {-7.34546,-15.2134,0}; dir = 270;};
class Object3 {side = 8; vehicle = "Land_fort_bagfence_corner"; rank = ""; position[] = {-22.8383,-16.7793,0}; dir = 0;};
class Object4 {side = 8; vehicle = "Land_fort_bagfence_corner"; rank = ""; position[] = {-12.9705,-16.2134,0}; dir = 270;};
class Object5 {side = 8; vehicle = "Land_fort_bagfence_round"; rank = ""; position[] = {3.31976,-19.5498,0}; dir = 225;};
class Object6 {side = 8; vehicle = "Land_fort_bagfence_long"; rank = ""; position[] = {3.8717,-14.8921,0}; dir = 135;};
class Object7 {side = 8; vehicle = "Land_fort_bagfence_long"; rank = ""; position[] = {-9.01392,13.7651,0}; dir = 90;};
class Object8 {side = 8; vehicle = "Land_fort_bagfence_long"; rank = ""; position[] = {-5.01532,9.61084,0}; dir = 0;};
class Object9 {side = 8; vehicle = "Land_fort_bagfence_long"; rank = ""; position[] = {-18.2347,13.1392,0}; dir = 180;};
class Object10 {side = 8; vehicle = "Land_fort_bagfence_long"; rank = ""; position[] = {-18.2347,-10.6108,0}; dir = 180;};
class Object11 {side = 8; vehicle = "Land_fort_bagfence_long"; rank = ""; position[] = {-16.7347,15.8892,0}; dir = 180;};
class Object12 {side = 8; vehicle = "Land_fort_bagfence_long"; rank = ""; position[] = {-18.1097,7.51416,0}; dir = 180;};
class Object13 {side = 8; vehicle = "Land_fort_bagfence_long"; rank = ""; position[] = {-19.4847,15.8892,0}; dir = 180;};
class Object14 {side = 8; vehicle = "Land_fort_bagfence_long"; rank = ""; position[] = {-0.763916,13.8901,0}; dir = 90;};
class Object15 {side = 8; vehicle = "Land_fort_bagfence_long"; rank = ""; position[] = {-3.38892,5.51514,0}; dir = 90;};
class Object16 {side = 8; vehicle = "Land_fort_bagfence_long"; rank = ""; position[] = {-4.13892,-3.48486,0}; dir = 90;};
class Object17 {side = 8; vehicle = "Land_fort_bagfence_long"; rank = ""; position[] = {-0.763916,16.7651,0}; dir = 90;};
class Object18 {side = 8; vehicle = "Land_fort_bagfence_corner"; rank = ""; position[] = {-8.19177,5.68359,0}; dir = 90;};
class Object19 {side = 8; vehicle = "Land_fort_bagfence_corner"; rank = ""; position[] = {-8.15454,-3.28662,0}; dir = 90;};
class Object20 {side = 8; vehicle = "Land_fort_bagfence_corner"; rank = ""; position[] = {-4.72046,-5.21338,0}; dir = 270;};
class Object21 {side = 8; vehicle = "Land_fort_bagfence_corner"; rank = ""; position[] = {-4.84546,-12.2134,0}; dir = 270;};
class Object22 {side = 8; vehicle = "Land_fort_bagfence_corner"; rank = ""; position[] = {-7.96332,10.2202,0}; dir = 0;};
class Object23 {side = 8; vehicle = "Land_fort_bagfence_corner"; rank = ""; position[] = {-7.71332,1.84521,0}; dir = 0;};
class Object24 {side = 8; vehicle = "Land_fort_bagfence_corner"; rank = ""; position[] = {-3.97046,2.41162,0}; dir = 270;};
class Object25 {side = 8; vehicle = "Land_fort_bagfence_corner"; rank = ""; position[] = {-1.34546,10.7866,0}; dir = 270;};
class Object26 {side = 8; vehicle = "Land_fort_bagfence_corner"; rank = ""; position[] = {-7.58832,-5.77979,0}; dir = 0;};
class Object27 {side = 8; vehicle = "Land_fort_bagfence_corner"; rank = ""; position[] = {-8.40454,16.8384,0}; dir = 90;};
class Object28 {side = 8; vehicle = "Land_fort_bagfence_round"; rank = ""; position[] = {-15.2892,1.12256,0}; dir = 90;};
class Object29 {side = 8; vehicle = "Land_fort_bagfence_round"; rank = ""; position[] = {-13.9518,-8.5332,0}; dir = 105;};
class Object30 {side = 8; vehicle = "Land_fort_bagfence_round"; rank = ""; position[] = {-14.4142,10.2476,0}; dir = 90;};
class Object31 {side = 8; vehicle = "Land_fort_bagfence_round"; rank = ""; position[] = {-21.9608,10.2524,0}; dir = 270;};
class Object32 {side = 8; vehicle = "Land_fort_bagfence_round"; rank = ""; position[] = {-22.6744,-8.52881,0}; dir = 255;};
class Object33 {side = 8; vehicle = "Land_fort_bagfence_round"; rank = ""; position[] = {1.67041,-3.18555,0}; dir = 300;};
class Object34 {side = 8; vehicle = "Land_fort_bagfence_round"; rank = ""; position[] = {-21.5858,1.12744,0}; dir = 270;};
class Object36 {side = 8; vehicle = "Land_fort_bagfence_long"; rank = ""; position[] = {3.47546,-7.54199,0}; dir = 30;};
class Object37 {side = 8; vehicle = "Land_fort_bagfence_long"; rank = ""; position[] = {-19.6097,21.5142,0}; dir = 180;};
class Object38 {side = 8; vehicle = "Land_fort_bagfence_long"; rank = ""; position[] = {-16.8597,21.5142,0}; dir = 180;};
class Object39 {side = 8; vehicle = "Land_fort_bagfence_round"; rank = ""; position[] = {-23.3358,18.6274,0}; dir = 270;};
class Object40 {side = 8; vehicle = "Land_fort_bagfence_round"; rank = ""; position[] = {-13.0392,18.6226,0}; dir = 90;};
class Object41 {side = 8; vehicle = "Land_fort_bagfence_long"; rank = ""; position[] = {-4.85968,17.8892,0}; dir = 180;};
class Object42 {side = 8; vehicle = "Land_fort_bagfence_long"; rank = ""; position[] = {15.6512,-18.8218,0}; dir = 45;};
class Object43 {side = 8; vehicle = "Land_fort_bagfence_long"; rank = ""; position[] = {19.6925,-14.6987,0}; dir = 225;};
class Object44 {side = 8; vehicle = "Land_fort_bagfence_round"; rank = ""; position[] = {11.8774,-15.6641,0}; dir = 0;};
class Object45 {side = 8; vehicle = "Land_fort_bagfence_round"; rank = ""; position[] = {20.3086,-19.374,0}; dir = 135;};
class Object46 {side = 8; vehicle = "Land_fort_bagfence_long"; rank = ""; position[] = {7.99457,-18.9331,0}; dir = 315;};
class Object47 {side = 8; vehicle = "Land_fort_bagfence_long"; rank = ""; position[] = {11.5153,2.63916,0}; dir = 180;};
class Object48 {side = 8; vehicle = "Land_fort_bagfence_long"; rank = ""; position[] = {21.2121,-7.49658,0}; dir = 330;};
class Object49 {side = 8; vehicle = "Land_fort_bagfence_long"; rank = ""; position[] = {6.11108,8.14014,0}; dir = 90;};
class Object50 {side = 8; vehicle = "Land_fort_bagfence_long"; rank = ""; position[] = {18.2755,-2.52637,0}; dir = 150;};
class Object51 {side = 8; vehicle = "Land_fort_bagfence_long"; rank = ""; position[] = {16.8889,8.10986,0}; dir = 270;};
class Object52 {side = 8; vehicle = "Land_fort_bagfence_long"; rank = ""; position[] = {11.4847,13.6108,0}; dir = 0;};
class Object53 {side = 8; vehicle = "Land_fort_bagfence_round"; rank = ""; position[] = {6.60553,3.10889,0}; dir = 225;};
class Object54 {side = 8; vehicle = "Land_fort_bagfence_round"; rank = ""; position[] = {22.9509,-3.14063,0}; dir = 60;};
class Object55 {side = 8; vehicle = "Land_fort_bagfence_round"; rank = ""; position[] = {16.5161,3.10547,0}; dir = 135;};
class Object56 {side = 8; vehicle = "Land_fort_bagfence_round"; rank = ""; position[] = {6.48389,13.1445,0}; dir = 315;};
class Object57 {side = 8; vehicle = "Land_fort_bagfence_round"; rank = ""; position[] = {16.3945,13.1411,0}; dir = 45;};
class Object58 {side = 8; vehicle = "Land_fort_bagfence_round"; rank = ""; position[] = {17.147,-10.2661,0}; dir = 285;};
class Object59 {side = 8; vehicle = "Land_fort_bagfence_round"; rank = ""; position[] = {7.08154,-11.165,0}; dir = 90;};
class Object60 {side = 8; vehicle = "Land_fort_bagfence_long"; rank = ""; position[] = {6.46771,-2.21631,0}; dir = 195;};
class Object61 {side = 8; vehicle = "Land_fort_bagfence_long"; rank = ""; position[] = {16.8611,27.7651,0}; dir = 90;};
class Object62 {side = 8; vehicle = "Land_fort_bagfence_long"; rank = ""; position[] = {10.2347,20.7358,0}; dir = 0;};
class Object63 {side = 8; vehicle = "Land_fort_bagfence_corner"; rank = ""; position[] = {15.7133,31.2798,0}; dir = 180;};
class Object64 {side = 8; vehicle = "Land_fort_bagfence_corner"; rank = ""; position[] = {10.7795,27.4116,0}; dir = 270;};
class Object65 {side = 8; vehicle = "Land_fort_bagfence_corner"; rank = ""; position[] = {11.9705,30.7134,0}; dir = 90;};
class Object66 {side = 8; vehicle = "Land_fort_bagfence_corner"; rank = ""; position[] = {7.03668,21.3452,0}; dir = 0;};
class Object67 {side = 8; vehicle = "Land_fort_bagfence_corner"; rank = ""; position[] = {6.47046,25.2134,0}; dir = 90;};
class Object68 {side = 8; vehicle = "Land_fort_bagfence_round"; rank = ""; position[] = {14.2524,23.3359,0}; dir = 0;};
class Object69 {side = 8; vehicle = "Land_fort_bagfence_long"; rank = ""; position[] = {16.9861,19.5151,0}; dir = 90;};
};
class Sandbags_CUP_B_USMC {
name = $STR_ZECCUP_MilitaryDesert_ConstructionSuppliesLarge_Sandbags_CUP_B_USMC; // Credit: 2600K
icon = "\ca\data\flag_usa_co.paa";
side = 8;
class Object0 {side = 8; vehicle = "Land_BagFence_Corner_F"; rank = ""; position[] = {0.269531,6.55518,0}; dir = 270;};
class Object1 {side = 8; vehicle = "Land_BagFence_Corner_F"; rank = ""; position[] = {0.290527,3.23438,0}; dir = 180;};
class Object2 {side = 8; vehicle = "Land_BagFence_Corner_F"; rank = ""; position[] = {3.61145,3.25537,0}; dir = 90;};
class Object3 {side = 8; vehicle = "Land_BagFence_Corner_F"; rank = ""; position[] = {3.69055,10.7056,0}; dir = 90;};
class Object4 {side = 8; vehicle = "Land_BagFence_Corner_F"; rank = ""; position[] = {1.34448,-15.3276,0}; dir = 90;};
class Object5 {side = 8; vehicle = "Land_BagFence_Corner_F"; rank = ""; position[] = {-5.93024,-15.27,0}; dir = 180;};
class Object6 {side = 8; vehicle = "Land_BagFence_Corner_F"; rank = ""; position[] = {-0.555176,10.73,0}; dir = 180;};
class Object7 {side = 8; vehicle = "Land_BagFence_End_F"; rank = ""; position[] = {-7.10608,2.69287,0}; dir = 0;};
class Object8 {side = 8; vehicle = "Land_BagFence_End_F"; rank = ""; position[] = {-5.77173,5.2793,0}; dir = 270;};
class Object9 {side = 8; vehicle = "Land_BagFence_End_F"; rank = ""; position[] = {-6.1684,-12.1089,0}; dir = 255;};
class Object10 {side = 8; vehicle = "Land_BagFence_End_F"; rank = ""; position[] = {-1.75159,-6.74561,0}; dir = 285;};
class Object11 {side = 8; vehicle = "Land_BagFence_End_F"; rank = ""; position[] = {-11.1684,-6.60889,0}; dir = 255;};
class Object12 {side = 8; vehicle = "Land_BagFence_End_F"; rank = ""; position[] = {-8.35858,6.73877,0}; dir = 180;};
class Object13 {side = 8; vehicle = "Land_BagFence_End_F"; rank = ""; position[] = {1.62341,-10.7456,0}; dir = 285;};
class Object14 {side = 8; vehicle = "Land_BagFence_End_F"; rank = ""; position[] = {-9.69299,4.15234,0}; dir = 90;};
class Object15 {side = 8; vehicle = "Land_BagFence_Long_F"; rank = ""; position[] = {1.70117,10.7314,0}; dir = 0;};
class Object16 {side = 8; vehicle = "Land_BagFence_Long_F"; rank = ""; position[] = {1.31451,-13.0381,0}; dir = 270;};
class Object17 {side = 8; vehicle = "Land_BagFence_Long_F"; rank = ""; position[] = {-7.84082,-0.932617,0}; dir = 0;};
class Object18 {side = 8; vehicle = "Land_BagFence_Long_F"; rank = ""; position[] = {-8.08289,-4.46387,0}; dir = 180;};
class Object19 {side = 8; vehicle = "Land_BagFence_Long_F"; rank = ""; position[] = {-3.54102,-15.2998,0}; dir = 180;};
class Object20 {side = 8; vehicle = "Land_BagFence_Long_F"; rank = ""; position[] = {-5.04102,-9.2998,0}; dir = 180;};
class Object21 {side = 8; vehicle = "Land_BagFence_Long_F"; rank = ""; position[] = {-0.791016,-15.2998,0}; dir = 180;};
class Object22 {side = 8; vehicle = "Land_BagFence_Long_F"; rank = ""; position[] = {-7.91589,-9.2998,0}; dir = 180;};
class Object23 {side = 8; vehicle = "Land_BagFence_Short_F"; rank = ""; position[] = {3.62653,5.08203,0}; dir = 270;};
class Object24 {side = 8; vehicle = "Land_BagFence_Short_F"; rank = ""; position[] = {2.11749,3.21924,0}; dir = 0;};
class Object25 {side = 8; vehicle = "Land_BagFence_Short_F"; rank = ""; position[] = {-7.62762,10.228,0}; dir = 0;};
class Object26 {side = 8; vehicle = "Land_BagFence_Short_F"; rank = ""; position[] = {1.76349,6.59131,0}; dir = 180;};
class Object27 {side = 8; vehicle = "Land_BagFence_Short_F"; rank = ""; position[] = {0.254456,4.72803,0}; dir = 90;};
class Object28 {side = 8; vehicle = "Land_BagFence_Short_F"; rank = ""; position[] = {1.95361,-3.79492,0}; dir = 270;};
class Object29 {side = 8; vehicle = "Land_BagFence_Short_F"; rank = ""; position[] = {-5.92139,-13.7949,0}; dir = 270;};
class Object30 {side = 8; vehicle = "Land_BagFence_Round_F"; rank = ""; position[] = {-9.71832,10.7681,0}; dir = 45;};
class Object31 {side = 8; vehicle = "Land_BagFence_Round_F"; rank = ""; position[] = {5.03448,-1.0332,0}; dir = 315;};
class Object32 {side = 8; vehicle = "Land_BagFence_Round_F"; rank = ""; position[] = {-10.5413,-1.32422,0}; dir = 135;};
class Object33 {side = 8; vehicle = "Land_BagFence_Round_F"; rank = ""; position[] = {5.45593,-9.48828,0}; dir = 45;};
class Object34 {side = 8; vehicle = "Land_BagFence_Round_F"; rank = ""; position[] = {-2.46552,-8.9082,0}; dir = 315;};
class Object35 {side = 8; vehicle = "Land_BagFence_Round_F"; rank = ""; position[] = {4.70422,-6.82959,0}; dir = 225;};
class Object36 {side = 8; vehicle = "Land_BagFence_Round_F"; rank = ""; position[] = {2.33093,-5.86377,0}; dir = 45;};
class Object37 {side = 8; vehicle = "Land_BagFence_Round_F"; rank = ""; position[] = {-10.628,-3.94141,0}; dir = 45;};
class Object38 {side = 8; vehicle = "Land_BagFence_Round_F"; rank = ""; position[] = {-5.38239,-4.07227,0}; dir = 315;};
class Object39 {side = 8; vehicle = "Land_BagFence_Round_F"; rank = ""; position[] = {-6.21552,3.0918,0}; dir = 315;};
class Object40 {side = 8; vehicle = "Land_BagFence_Round_F"; rank = ""; position[] = {-6.17084,6.17041,0}; dir = 225;};
class Object41 {side = 8; vehicle = "Land_BagFence_Round_F"; rank = ""; position[] = {-9.29401,3.26172,0}; dir = 45;};
class Object42 {side = 8; vehicle = "Land_BagFence_Round_F"; rank = ""; position[] = {-10.544,-8.73828,0}; dir = 45;};
class Object43 {side = 8; vehicle = "Land_BagFence_Round_F"; rank = ""; position[] = {2.37567,-1.78516,0}; dir = 135;};
class Object44 {side = 8; vehicle = "Land_BagFence_Round_F"; rank = ""; position[] = {-5.29584,-1.45459,0}; dir = 225;};
class Object45 {side = 8; vehicle = "Land_BagFence_Round_F"; rank = ""; position[] = {-9.12433,6.33984,0}; dir = 135;};
class Object46 {side = 8; vehicle = "Land_BagFence_Round_F"; rank = ""; position[] = {-5.46112,10.6147,0}; dir = 315;};
class Object48 {side = 8; vehicle = "Land_BagFence_Corner_F"; rank = ""; position[] = {3.59033,6.57666,0}; dir = 0;};
class Object49 {side = 8; vehicle = "Land_BagFence_Corner_F"; rank = ""; position[] = {-1.77209,24.7383,0}; dir = 270;};
class Object50 {side = 8; vehicle = "Land_BagFence_Corner_F"; rank = ""; position[] = {4.30536,18.5786,0}; dir = 90;};
class Object51 {side = 8; vehicle = "Land_BagFence_Corner_F"; rank = ""; position[] = {4.34033,24.7012,0}; dir = 0;};
class Object52 {side = 8; vehicle = "Land_BagFence_Corner_F"; rank = ""; position[] = {-1.80707,18.6157,0}; dir = 180;};
class Object53 {side = 8; vehicle = "Land_BagFence_Long_F"; rank = ""; position[] = {-7.67383,18.6064,0}; dir = 0;};
class Object54 {side = 8; vehicle = "Land_BagFence_Long_F"; rank = ""; position[] = {0.19928,24.7417,0}; dir = 0;};
class Object55 {side = 8; vehicle = "Land_BagFence_Long_F"; rank = ""; position[] = {2.32617,18.6064,0}; dir = 0;};
class Object56 {side = 8; vehicle = "Land_BagFence_Long_F"; rank = ""; position[] = {-1.81049,20.7119,0}; dir = 270;};
class Object57 {side = 8; vehicle = "Land_BagFence_Long_F"; rank = ""; position[] = {3.68951,13.0869,0}; dir = 270;};
class Object58 {side = 8; vehicle = "Land_BagFence_Long_F"; rank = ""; position[] = {-4.43549,21.5869,0}; dir = 270;};
class Object59 {side = 8; vehicle = "Land_BagFence_Long_F"; rank = ""; position[] = {-0.529358,12.7197,0}; dir = 90;};
class Object60 {side = 8; vehicle = "Land_BagFence_Long_F"; rank = ""; position[] = {-7.54089,24.7002,0}; dir = 180;};
class Object61 {side = 8; vehicle = "Land_BagFence_Long_F"; rank = ""; position[] = {-10.7793,21.7197,0}; dir = 90;};
class Object62 {side = 8; vehicle = "Land_BagFence_Long_F"; rank = ""; position[] = {4.31451,22.7119,0}; dir = 270;};
class Object63 {side = 8; vehicle = "Land_BagFence_Short_F"; rank = ""; position[] = {4.33154,20.3511,0}; dir = 90;};
class Object64 {side = 8; vehicle = "Land_BagFence_Short_F"; rank = ""; position[] = {-1.79346,22.9761,0}; dir = 90;};
class Object65 {side = 8; vehicle = "Land_BagFence_Short_F"; rank = ""; position[] = {-4.92139,12.7051,0}; dir = 270;};
class Object66 {side = 8; vehicle = "Land_BagFence_Short_F"; rank = ""; position[] = {-0.0344238,18.5894,0}; dir = 180;};
class Object67 {side = 8; vehicle = "Land_BagFence_Short_F"; rank = ""; position[] = {-7.45868,15.3457,0}; dir = 180;};
class Object68 {side = 8; vehicle = "Land_BagFence_Short_F"; rank = ""; position[] = {0.992493,15.0942,0}; dir = 0;};
class Object69 {side = 8; vehicle = "Land_BagFence_Short_F"; rank = ""; position[] = {-10.165,12.8691,0}; dir = 90;};
class Object70 {side = 8; vehicle = "Land_BagFence_Round_F"; rank = ""; position[] = {-4.79578,24.2954,0}; dir = 225;};
class Object71 {side = 8; vehicle = "Land_BagFence_Round_F"; rank = ""; position[] = {-4.88879,18.9463,0}; dir = 315;};
class Object72 {side = 8; vehicle = "Land_BagFence_Round_F"; rank = ""; position[] = {-5.36798,14.8062,0}; dir = 225;};
class Object73 {side = 8; vehicle = "Land_BagFence_Round_F"; rank = ""; position[] = {-10.419,19.0117,0}; dir = 45;};
class Object74 {side = 8; vehicle = "Land_BagFence_Round_F"; rank = ""; position[] = {-9.62518,14.9595,0}; dir = 135;};
class Object75 {side = 8; vehicle = "Land_BagFence_Round_F"; rank = ""; position[] = {-10.3259,24.3608,0}; dir = 135;};
class Object76 {side = 8; vehicle = "Land_BagFence_Corner_F"; rank = ""; position[] = {-0.530396,15.1011,0}; dir = 270;};
class Object77 {side = 8; vehicle = "Land_BagFence_End_F"; rank = ""; position[] = {17.1306,-9.28564,0}; dir = 345;};
class Object78 {side = 8; vehicle = "Land_BagFence_End_F"; rank = ""; position[] = {11.9045,-14.6577,0}; dir = 165;};
class Object79 {side = 8; vehicle = "Land_BagFence_Long_F"; rank = ""; position[] = {13.334,-1.9248,0}; dir = 180;};
class Object80 {side = 8; vehicle = "Land_BagFence_Long_F"; rank = ""; position[] = {8.47064,9.46973,0}; dir = 90;};
class Object81 {side = 8; vehicle = "Land_BagFence_Long_F"; rank = ""; position[] = {13.2012,-6.76855,0}; dir = 0;};
class Object82 {side = 8; vehicle = "Land_BagFence_Short_F"; rank = ""; position[] = {7.46558,-9.91064,0}; dir = 180;};
class Object83 {side = 8; vehicle = "Land_BagFence_Short_F"; rank = ""; position[] = {14.5815,-12.0239,0}; dir = 90;};
class Object84 {side = 8; vehicle = "Land_BagFence_Short_F"; rank = ""; position[] = {10.9446,6.34229,0}; dir = 0;};
class Object85 {side = 8; vehicle = "Land_BagFence_Short_F"; rank = ""; position[] = {8.06958,1.71729,0}; dir = 0;};
class Object86 {side = 8; vehicle = "Land_BagFence_Short_F"; rank = ""; position[] = {16.4536,-4.29492,0}; dir = 270;};
class Object87 {side = 8; vehicle = "Land_BagFence_Round_F"; rank = ""; position[] = {10.8309,-1.36377,0}; dir = 45;};
class Object88 {side = 8; vehicle = "Land_BagFence_Round_F"; rank = ""; position[] = {15.9139,-6.38525,0}; dir = 315;};
class Object89 {side = 8; vehicle = "Land_BagFence_Round_F"; rank = ""; position[] = {14.99,-9.85742,0}; dir = 135;};
class Object90 {side = 8; vehicle = "Land_BagFence_Round_F"; rank = ""; position[] = {9.53448,-9.5332,0}; dir = 315;};
class Object91 {side = 8; vehicle = "Land_BagFence_Round_F"; rank = ""; position[] = {14.1127,-14.0039,0}; dir = 315;};
class Object92 {side = 8; vehicle = "Land_BagFence_Round_F"; rank = ""; position[] = {10.5007,-7.16016,0}; dir = 135;};
class Object93 {side = 8; vehicle = "Land_BagFence_Round_F"; rank = ""; position[] = {16.0792,-2.32959,0}; dir = 225;};
class Object94 {side = 8; vehicle = "Land_BagFence_Round_F"; rank = ""; position[] = {10.0792,1.29541,0}; dir = 225;};
class Object95 {side = 8; vehicle = "Land_BagFence_Round_F"; rank = ""; position[] = {6.00067,1.33984,0}; dir = 135;};
class Object96 {side = 8; vehicle = "Land_BagFence_Round_F"; rank = ""; position[] = {8.77826,6.75049,0}; dir = 45;};
class Object97 {side = 8; vehicle = "Land_BagFence_Round_F"; rank = ""; position[] = {13.0345,6.7168,0}; dir = 315;};
class Object98 {side = 8; vehicle = "Land_BagFence_Round_F"; rank = ""; position[] = {14.0007,9.21484,0}; dir = 135;};
class Object99 {side = 8; vehicle = "Land_BagFence_Round_F"; rank = ""; position[] = {9.00067,12.2148,0}; dir = 135;};
class Object100 {side = 8; vehicle = "Land_BagFence_Corner_F"; rank = ""; position[] = {8.44482,16.355,0}; dir = 180;};
class Object101 {side = 8; vehicle = "Land_BagFence_Corner_F"; rank = ""; position[] = {13.2153,16.3262,0}; dir = 0;};
class Object102 {side = 8; vehicle = "Land_BagFence_Corner_F"; rank = ""; position[] = {15.3156,20.7056,0}; dir = 90;};
class Object103 {side = 8; vehicle = "Land_BagFence_Corner_F"; rank = ""; position[] = {8.4696,20.7261,0}; dir = 270;};
class Object104 {side = 8; vehicle = "Land_BagFence_Corner_F"; rank = ""; position[] = {15.3446,25.3511,0}; dir = 270;};
class Object105 {side = 8; vehicle = "Land_BagFence_Long_F"; rank = ""; position[] = {11.8306,12.6294,0}; dir = 0;};
class Object106 {side = 8; vehicle = "Land_BagFence_Long_F"; rank = ""; position[] = {14.7012,12.6064,0}; dir = 0;};
class Object107 {side = 8; vehicle = "Land_BagFence_Long_F"; rank = ""; position[] = {15.3145,23.0869,0}; dir = 270;};
class Object108 {side = 8; vehicle = "Land_BagFence_Long_F"; rank = ""; position[] = {8.47064,18.3447,0}; dir = 90;};
class Object109 {side = 8; vehicle = "Land_BagFence_Long_F"; rank = ""; position[] = {13.3262,20.7314,0}; dir = 0;};
class Object110 {side = 8; vehicle = "Land_BagFence_Long_F"; rank = ""; position[] = {10.459,20.7002,0}; dir = 180;};
class Object111 {side = 8; vehicle = "Land_BagFence_Long_F"; rank = ""; position[] = {10.834,16.3252,0}; dir = 180;};
class Object112 {side = 8; vehicle = "Land_BagFence_Long_F"; rank = ""; position[] = {17.3341,25.3252,0}; dir = 180;};
class Object113 {side = 8; vehicle = "Land_BagFence_Long_F"; rank = ""; position[] = {19.7207,23.3447,0}; dir = 90;};
class Object114 {side = 8; vehicle = "Land_BagFence_Corner_F"; rank = ""; position[] = {19.7155,25.3262,0}; dir = 0;};
};
class FillerSupplies {
name = $STR_ZECCUP_MilitaryDesert_ConstructionSuppliesLarge_FillerSupplies; // Credit: 2600K
icon = "\a3\Ui_f\data\Map\Markers\Military\unknown_ca.paa";
side = 8;
class Object0 {side = 8; vehicle = "Land_fort_rampart_EP1"; rank = ""; position[] = {-17.8438,-14.4604,0}; dir = 180;};
class Object1 {side = 8; vehicle = "Land_fort_rampart_EP1"; rank = ""; position[] = {-17.818,-6.28662,0}; dir = 180;};
class Object2 {side = 8; vehicle = "Land_WaterTank_F"; rank = ""; position[] = {-19.0786,-15.6218,0}; dir = 359.847;};
class Object3 {side = 8; vehicle = "Land_Pallet_MilBoxes_F"; rank = ""; position[] = {-21.2394,-15.6226,0}; dir = 270;};
class Object4 {side = 8; vehicle = "Land_PaperBox_open_empty_F"; rank = ""; position[] = {-17.4996,-7.625,0}; dir = 105;};
class Object5 {side = 8; vehicle = "Land_Pallet_MilBoxes_F"; rank = ""; position[] = {-19.2394,-7.49756,0}; dir = 270;};
class Object6 {side = 8; vehicle = "Barrel1"; rank = ""; position[] = {-18,-16.75,0}; dir = 345;};
class Object7 {side = 8; vehicle = "Barrel1"; rank = ""; position[] = {-19.5,-16.75,0}; dir = 180;};
class Object8 {side = 8; vehicle = "Land_MetalBarrel_F"; rank = ""; position[] = {-20.4424,-7.50537,0}; dir = 298.759;};
class Object9 {side = 8; vehicle = "Land_MetalBarrel_F"; rank = ""; position[] = {-21.2797,-7.19653,0}; dir = 134.998;};
class Object10 {side = 8; vehicle = "Land_BarrelWater_grey_F"; rank = ""; position[] = {-22.4063,-16.001,0}; dir = 359.884;};
class Object11 {side = 8; vehicle = "Land_BarrelTrash_grey_F"; rank = ""; position[] = {-22.4336,-15.25,0}; dir = 0.0141838;};
class Object12 {side = 8; vehicle = "Land_fort_rampart_EP1"; rank = ""; position[] = {-18.625,18.3994,0}; dir = 180;};
class Object13 {side = 8; vehicle = "Land_fort_rampart_EP1"; rank = ""; position[] = {-17.8094,5.59692,0}; dir = 180;};
class Object14 {side = 8; vehicle = "Land_GarbagePallet_F"; rank = ""; position[] = {-18.9601,17.1973,0}; dir = 330;};
class Object15 {side = 8; vehicle = "Land_CratesShabby_F"; rank = ""; position[] = {-22.0632,4.44312,0}; dir = 180;};
class Object16 {side = 8; vehicle = "Land_CratesWooden_F"; rank = ""; position[] = {-20.5,4.25,0}; dir = 0;};
class Object17 {side = 8; vehicle = "Misc_concrete_High"; rank = ""; position[] = {-22.75,16.25,0}; dir = 180;};
class Object18 {side = 8; vehicle = "Barrel1"; rank = ""; position[] = {-21.125,16.5,0}; dir = 255;};
class Object19 {side = 8; vehicle = "Barrel1"; rank = ""; position[] = {-17.294,3.91479,0}; dir = 270;};
class Object20 {side = 8; vehicle = "Barrel1"; rank = ""; position[] = {-21.125,17.5,0}; dir = 45;};
class Object21 {side = 8; vehicle = "Barrel1"; rank = ""; position[] = {-17.9399,4.93506,0}; dir = 300;};
class Object22 {side = 8; vehicle = "Barrel1"; rank = ""; position[] = {-18.6776,4.63892,0}; dir = 120;};
class Object23 {side = 8; vehicle = "Land_Pallets_stack_F"; rank = ""; position[] = {-16.726,16.459,0}; dir = 163.226;};
class Object24 {side = 8; vehicle = "Barrel4"; rank = ""; position[] = {-22.875,4.875,0}; dir = 0;};
class Object25 {side = 8; vehicle = "Barrel4"; rank = ""; position[] = {-17.125,4.75,0}; dir = 105;};
class Object26 {side = 8; vehicle = "Barrel4"; rank = ""; position[] = {-18,4.125,0}; dir = 0;};
class Object27 {side = 8; vehicle = "Fort_Crate_wood"; rank = ""; position[] = {-15.9994,4.4978,0}; dir = 195;};
class Object28 {side = 8; vehicle = "Land_BagFence_Long_F"; rank = ""; position[] = {-2.50391,-2.23438,0}; dir = 360;};
class Object29 {side = 8; vehicle = "Land_BagFence_Long_F"; rank = ""; position[] = {3.49609,-13.2344,0}; dir = 360;};
class Object30 {side = 8; vehicle = "Land_BagFence_Long_F"; rank = ""; position[] = {3.24609,-2.23438,0}; dir = 360;};
class Object31 {side = 8; vehicle = "Land_BagFence_Long_F"; rank = ""; position[] = {0.621094,-13.2344,0}; dir = 360;};
class Object32 {side = 8; vehicle = "Land_BagFence_Long_F"; rank = ""; position[] = {0.371094,-2.23438,0}; dir = 360;};
class Object33 {side = 8; vehicle = "Land_BagFence_Long_F"; rank = ""; position[] = {-2.25391,-13.2344,0}; dir = 360;};
class Object34 {side = 8; vehicle = "Land_BagFence_Round_F"; rank = ""; position[] = {-5.32941,-2.62598,0}; dir = 135;};
class Object35 {side = 8; vehicle = "Land_BagFence_Round_F"; rank = ""; position[] = {6.12415,-13.7957,0}; dir = 225;};
class Object36 {side = 8; vehicle = "Land_BagFence_Round_F"; rank = ""; position[] = {5.87415,-2.79565,0}; dir = 225;};
class Object37 {side = 8; vehicle = "Land_BagFence_Round_F"; rank = ""; position[] = {-5.07941,-13.626,0}; dir = 135;};
class Object38 {side = 8; vehicle = "Land_GarbagePallet_F"; rank = ""; position[] = {4.1283,-4.20264,0}; dir = 30;};
class Object39 {side = 8; vehicle = "Land_fort_bagfence_corner"; rank = ""; position[] = {13.7205,-14.5366,0}; dir = 90;};
class Object40 {side = 8; vehicle = "Land_fort_bagfence_corner"; rank = ""; position[] = {13.5955,-3.53662,0}; dir = 90;};
class Object41 {side = 8; vehicle = "Land_Pipes_large_F"; rank = ""; position[] = {-15.0734,-15.4971,0}; dir = 359.995;};
class Object42 {side = 8; vehicle = "Land_Pipes_small_F"; rank = ""; position[] = {0.493347,-16.1328,0}; dir = 344.999;};
class Object43 {side = 8; vehicle = "Land_Pipes_small_F"; rank = ""; position[] = {-13.3817,-7.13721,0}; dir = 165.006;};
class Object44 {side = 8; vehicle = "Land_Sack_F"; rank = ""; position[] = {15.7451,-15.252,0}; dir = 285;};
class Object45 {side = 8; vehicle = "Land_Sack_F"; rank = ""; position[] = {4.37115,-15.1282,0}; dir = 270;};
class Object46 {side = 8; vehicle = "Land_Sacks_heap_F"; rank = ""; position[] = {15.25,-14.5,0}; dir = 0;};
class Object47 {side = 8; vehicle = "Land_Sacks_heap_F"; rank = ""; position[] = {14.3103,-14.6897,0}; dir = 270;};
class Object48 {side = 8; vehicle = "Land_CratesShabby_F"; rank = ""; position[] = {2.61719,-15.3757,0}; dir = 75;};
class Object49 {side = 8; vehicle = "Land_CratesWooden_F"; rank = ""; position[] = {0.75,-14.75,0}; dir = 0;};
class Object50 {side = 8; vehicle = "Land_PaperBox_open_full_F"; rank = ""; position[] = {-1.37506,-14.6343,0}; dir = 0;};
class Object51 {side = 8; vehicle = "Oil_Spill_F"; rank = ""; position[] = {1.41296,-4.01221,0}; dir = 0;};
class Object52 {side = 8; vehicle = "Land_Sack_EP1"; rank = ""; position[] = {15.126,-15.3696,0}; dir = 75;};
class Object53 {side = 8; vehicle = "PowerGenerator_EP1"; rank = ""; position[] = {14,-4.125,0}; dir = 0;};
class Object54 {side = 8; vehicle = "PowerGenerator_EP1"; rank = ""; position[] = {3.375,-14.375,0}; dir = 90;};
class Object55 {side = 8; vehicle = "Gunrack1"; rank = ""; position[] = {0.316406,-3.4751,0}; dir = 0;};
class Object56 {side = 8; vehicle = "Gunrack1"; rank = ""; position[] = {-1.05859,-3.4751,0}; dir = 0;};
class Object57 {side = 8; vehicle = "Barrel3"; rank = ""; position[] = {-3.25,-3.375,0}; dir = 210;};
class Object58 {side = 8; vehicle = "Barrel3"; rank = ""; position[] = {-2.375,-3.375,0}; dir = 150;};
class Object59 {side = 8; vehicle = "Barrel3"; rank = ""; position[] = {-3.625,-14.25,0}; dir = 60;};
class Object60 {side = 8; vehicle = "Barrel3"; rank = ""; position[] = {-2.875,-4,0}; dir = 0;};
class Object61 {side = 8; vehicle = "Barrel3"; rank = ""; position[] = {-3.625,-4.375,0}; dir = 210;};
class Object62 {side = 8; vehicle = "Land_WaterBarrel_F"; rank = ""; position[] = {-4.625,-14.5,0}; dir = 359.994;};
class Object63 {side = 8; vehicle = "Barrel4"; rank = ""; position[] = {1.875,-3.875,0}; dir = 105;};
class Object64 {side = 8; vehicle = "Barrel4"; rank = ""; position[] = {-2.625,-15.125,0}; dir = 0;};
class Object65 {side = 8; vehicle = "Barrel4"; rank = ""; position[] = {1.375,-3.25,0}; dir = 315;};
class Object66 {side = 8; vehicle = "Barrel4"; rank = ""; position[] = {-2.625,-14.25,0}; dir = 270;};
class Object67 {side = 8; vehicle = "Fort_Crate_wood"; rank = ""; position[] = {15.1256,-4.7522,0}; dir = 195;};
class Object68 {side = 8; vehicle = "Fort_Crate_wood"; rank = ""; position[] = {5.12384,-14.498,0}; dir = 0;};
class Object69 {side = 8; vehicle = "Fort_Crate_wood"; rank = ""; position[] = {-4.12384,-3.37695,0}; dir = 180;};
class Object70 {side = 8; vehicle = "Fort_Crate_wood"; rank = ""; position[] = {15.0012,-3.37695,0}; dir = 180;};
class Object72 {side = 8; vehicle = "Land_PaperBox_closed_F"; rank = ""; position[] = {-15.7375,-7.49756,0}; dir = 90;};
class Object73 {side = 8; vehicle = "Land_BarrelWater_grey_F"; rank = ""; position[] = {-5.00006,-3.25,0}; dir = 359.978;};
class Object74 {side = 8; vehicle = "Land_BarrelSand_grey_F"; rank = ""; position[] = {-5.00006,-15.375,0}; dir = 359.978;};
class Object75 {side = 8; vehicle = "Land_BarrelTrash_grey_F"; rank = ""; position[] = {14.1249,-15.75,0}; dir = 359.978;};
class Object76 {side = 8; vehicle = "Land_BagFence_Long_F"; rank = ""; position[] = {2.99609,7.76563,0}; dir = 360;};
class Object77 {side = 8; vehicle = "Land_BagFence_Long_F"; rank = ""; position[] = {2.99609,19.2656,0}; dir = 360;};
class Object78 {side = 8; vehicle = "Land_BagFence_Long_F"; rank = ""; position[] = {-2.75391,19.2656,0}; dir = 360;};
class Object79 {side = 8; vehicle = "Land_BagFence_Long_F"; rank = ""; position[] = {0.121094,7.76563,0}; dir = 360;};
class Object80 {side = 8; vehicle = "Land_BagFence_Long_F"; rank = ""; position[] = {-2.75391,7.76563,0}; dir = 360;};
class Object81 {side = 8; vehicle = "Land_BagFence_Long_F"; rank = ""; position[] = {0.121094,19.2656,0}; dir = 360;};
class Object82 {side = 8; vehicle = "Land_BagFence_Round_F"; rank = ""; position[] = {-5.57941,18.874,0}; dir = 135;};
class Object83 {side = 8; vehicle = "Land_BagFence_Round_F"; rank = ""; position[] = {5.62415,18.7043,0}; dir = 225;};
class Object84 {side = 8; vehicle = "Land_BagFence_Round_F"; rank = ""; position[] = {5.62415,7.20435,0}; dir = 225;};
class Object85 {side = 8; vehicle = "Land_BagFence_Round_F"; rank = ""; position[] = {-5.57941,7.37402,0}; dir = 135;};
class Object86 {side = 8; vehicle = "Land_fort_bagfence_corner"; rank = ""; position[] = {13.5955,17.9634,0}; dir = 90;};
class Object87 {side = 8; vehicle = "Land_fort_bagfence_corner"; rank = ""; position[] = {13.5955,6.96338,0}; dir = 90;};
class Object88 {side = 8; vehicle = "Land_Pipes_small_F"; rank = ""; position[] = {-4.13165,17.2422,0}; dir = 89.9994;};
class Object89 {side = 8; vehicle = "Land_WoodenBox_F"; rank = ""; position[] = {-4.73853,17.5017,0}; dir = 90;};
class Object90 {side = 8; vehicle = "Land_PaperBox_closed_F"; rank = ""; position[] = {-1.36249,17.8774,0}; dir = 90;};
class Object91 {side = 8; vehicle = "Oil_Spill_F"; rank = ""; position[] = {0.537964,17.7378,0}; dir = 0;};
class Object92 {side = 8; vehicle = "Barrel5"; rank = ""; position[] = {-0.125,18.375,0}; dir = 195;};
class Object93 {side = 8; vehicle = "Barrel5"; rank = ""; position[] = {0.189697,17.5647,0}; dir = 0;};
class Object94 {side = 8; vehicle = "Barrel5"; rank = ""; position[] = {0.75,18.375,0}; dir = 330;};
class Object95 {side = 8; vehicle = "PowerGenerator"; rank = ""; position[] = {14.625,7,0}; dir = 90;};
class Object96 {side = 8; vehicle = "PowerGenerator"; rank = ""; position[] = {2.25,18.125,0}; dir = 270;};
class Object97 {side = 8; vehicle = "Land_WheelCart_F"; rank = ""; position[] = {4.12787,17.3777,0}; dir = 45.0077;};
class Object98 {side = 8; vehicle = "Misc_cargo_cont_tiny"; rank = ""; position[] = {15.7458,17.5,0}; dir = 0;};
class Object99 {side = 8; vehicle = "Gunrack1"; rank = ""; position[] = {-2.80859,7.0249,0}; dir = 0;};
class Object100 {side = 8; vehicle = "Gunrack1"; rank = ""; position[] = {-1.80859,7.0249,0}; dir = 0;};
class Object101 {side = 8; vehicle = "Barrel3"; rank = ""; position[] = {-3.625,7.125,0}; dir = 15;};
class Object102 {side = 8; vehicle = "Barrel1"; rank = ""; position[] = {2.75,7.125,0}; dir = 0;};
class Object103 {side = 8; vehicle = "Barrel1"; rank = ""; position[] = {3.46027,7.08105,0}; dir = 180;};
class Object104 {side = 8; vehicle = "Barrel1"; rank = ""; position[] = {3.25,6.375,0}; dir = 255;};
class Object105 {side = 8; vehicle = "Land_WaterBarrel_F"; rank = ""; position[] = {4.5,6.875,0}; dir = 359.995;};
class Object106 {side = 8; vehicle = "Land_PaperBox_open_empty_F"; rank = ""; position[] = {-2.99963,17.875,0}; dir = 90;};
class Object107 {side = 8; vehicle = "Land_Pallets_stack_F"; rank = ""; position[] = {-15.125,17.125,0}; dir = 359.999;};
class Object108 {side = 8; vehicle = "Land_Pallets_stack_F"; rank = ""; position[] = {1.5,6.75,0}; dir = 3.95778e-005;};
class Object109 {side = 8; vehicle = "Land_Pallets_stack_F"; rank = ""; position[] = {14.375,5.75,0}; dir = 360;};
class Object110 {side = 8; vehicle = "Land_Pallets_stack_F"; rank = ""; position[] = {-0.125,6.5,0}; dir = 255.001;};
class Object111 {side = 8; vehicle = "Misc_Backpackheap"; rank = ""; position[] = {-4.50531,6.07959,0}; dir = 210;};
class Object112 {side = 8; vehicle = "Land_BarrelTrash_F"; rank = ""; position[] = {2.62506,17.375,0}; dir = 359.976;};
class Object113 {side = 8; vehicle = "Land_BarrelWater_F"; rank = ""; position[] = {15.5001,6.25,0}; dir = 359.976;};
class Object114 {side = 8; vehicle = "Land_BarrelSand_F"; rank = ""; position[] = {14.4999,18.25,0}; dir = 359.978;};
class Object115 {side = 8; vehicle = "Land_BarrelEmpty_F"; rank = ""; position[] = {5.24994,6.125,0}; dir = 359.978;};
class Object116 {side = 8; vehicle = "Land_BarrelEmpty_grey_F"; rank = ""; position[] = {-15.0001,4.625,0}; dir = 359.978;};
class Object117 {side = 8; vehicle = "Land_BarrelSand_grey_F"; rank = ""; position[] = {-14.3751,4.875,0}; dir = 359.978;};
class Object118 {side = 8; vehicle = "Land_fort_bagfence_long"; rank = ""; position[] = {17.2653,-2.36108,0}; dir = 180;};
class Object119 {side = 8; vehicle = "Land_fort_bagfence_long"; rank = ""; position[] = {20.3903,-13.3611,0}; dir = 180;};
class Object120 {side = 8; vehicle = "Land_fort_bagfence_long"; rank = ""; position[] = {20.2653,-2.36108,0}; dir = 180;};
class Object121 {side = 8; vehicle = "Land_fort_bagfence_long"; rank = ""; position[] = {17.3903,-13.3611,0}; dir = 180;};
class Object122 {side = 8; vehicle = "Land_fort_bagfence_corner"; rank = ""; position[] = {23.4633,-2.97046,0}; dir = 180;};
class Object123 {side = 8; vehicle = "Land_fort_bagfence_corner"; rank = ""; position[] = {23.5883,-13.9705,0}; dir = 180;};
class Object124 {side = 8; vehicle = "Land_Pipes_small_F"; rank = ""; position[] = {23.3683,-15.7578,0}; dir = 89.9994;};
class Object125 {side = 8; vehicle = "Land_Pipes_small_F"; rank = ""; position[] = {22.4933,-15.5078,0}; dir = 285;};
class Object126 {side = 8; vehicle = "Land_WoodenBox_F"; rank = ""; position[] = {19.0115,-15.8733,0}; dir = 195;};
class Object127 {side = 8; vehicle = "Land_PaperBox_closed_F"; rank = ""; position[] = {19.6375,-14.7476,0}; dir = 90;};
class Object128 {side = 8; vehicle = "Land_PaperBox_closed_F"; rank = ""; position[] = {21.1275,-14.7625,0}; dir = 180;};
class Object129 {side = 8; vehicle = "Land_PaperBox_closed_F"; rank = ""; position[] = {18.3875,-3.62256,0}; dir = 90;};
class Object130 {side = 8; vehicle = "GunrackTK_EP1"; rank = ""; position[] = {16.2053,-3.35596,0}; dir = 90;};
class Object131 {side = 8; vehicle = "GunrackTK_EP1"; rank = ""; position[] = {18.2053,-14.481,0}; dir = 90;};
class Object132 {side = 8; vehicle = "GunrackTK_EP1"; rank = ""; position[] = {16.9553,-14.481,0}; dir = 90;};
class Object133 {side = 8; vehicle = "GunrackTK_EP1"; rank = ""; position[] = {22.9553,-3.48096,0}; dir = 90;};
class Object134 {side = 8; vehicle = "Land_WaterBarrel_F"; rank = ""; position[] = {21.75,-3.375,0}; dir = 359.994;};
class Object135 {side = 8; vehicle = "Barrel4"; rank = ""; position[] = {20.25,-3.25,0}; dir = 315;};
class Object136 {side = 8; vehicle = "Barrel4"; rank = ""; position[] = {20.75,-3.875,0}; dir = 105;};
class Object137 {side = 8; vehicle = "Land_Sack_F"; rank = ""; position[] = {17.2504,-3.37012,0}; dir = 45;};
class Object138 {side = 8; vehicle = "Land_BarrelEmpty_grey_F"; rank = ""; position[] = {19.4999,-3.25,0}; dir = 359.978;};
class Object139 {side = 8; vehicle = "Land_fort_bagfence_long"; rank = ""; position[] = {20.2653,19.1389,0}; dir = 180;};
class Object140 {side = 8; vehicle = "Land_fort_bagfence_long"; rank = ""; position[] = {17.2653,8.13892,0}; dir = 180;};
class Object141 {side = 8; vehicle = "Land_fort_bagfence_long"; rank = ""; position[] = {17.2653,19.1389,0}; dir = 180;};
class Object142 {side = 8; vehicle = "Land_fort_bagfence_long"; rank = ""; position[] = {20.2653,8.13892,0}; dir = 180;};
class Object143 {side = 8; vehicle = "Land_fort_bagfence_corner"; rank = ""; position[] = {23.4633,7.52954,0}; dir = 180;};
class Object144 {side = 8; vehicle = "Land_fort_bagfence_corner"; rank = ""; position[] = {23.4633,18.5295,0}; dir = 180;};
class Object145 {side = 8; vehicle = "Land_Pipes_small_F"; rank = ""; position[] = {22.6183,5.74219,0}; dir = 359.999;};
class Object146 {side = 8; vehicle = "Land_WoodenBox_F"; rank = ""; position[] = {21.8865,17.3767,0}; dir = 285;};
class Object147 {side = 8; vehicle = "Land_Sack_F"; rank = ""; position[] = {20.3705,17.1228,0}; dir = 285;};
class Object148 {side = 8; vehicle = "Land_Sack_F"; rank = ""; position[] = {21.1233,18.2454,0}; dir = 240;};
class Object149 {side = 8; vehicle = "Land_PaperBox_closed_F"; rank = ""; position[] = {17.5125,17.8774,0}; dir = 90;};
class Object150 {side = 8; vehicle = "Land_PaperBox_closed_F"; rank = ""; position[] = {21.8875,6.87744,0}; dir = 90;};
class Object151 {side = 8; vehicle = "Land_PaperBox_closed_F"; rank = ""; position[] = {23.3775,6.86255,0}; dir = 180;};
class Object152 {side = 8; vehicle = "Land_PaperBox_closed_F"; rank = ""; position[] = {23.3875,17.8774,0}; dir = 90;};
class Object153 {side = 8; vehicle = "Land_Sacks_goods_F"; rank = ""; position[] = {20.126,18.0129,0}; dir = 0;};
class Object154 {side = 8; vehicle = "GunrackTK_EP1"; rank = ""; position[] = {23.4553,16.644,0}; dir = 90;};
class Object155 {side = 8; vehicle = "GunrackTK_EP1"; rank = ""; position[] = {18.9553,7.14404,0}; dir = 90;};
class Object156 {side = 8; vehicle = "Barrel5"; rank = ""; position[] = {17.375,6.125,0}; dir = 195;};
class Object157 {side = 8; vehicle = "Barrel5"; rank = ""; position[] = {17.75,7.125,0}; dir = 330;};
class Object158 {side = 8; vehicle = "Barrel1"; rank = ""; position[] = {18.875,18,0}; dir = 0;};
class Object159 {side = 8; vehicle = "Barrel1"; rank = ""; position[] = {19,17,0}; dir = 255;};
class Object160 {side = 8; vehicle = "Land_WaterBarrel_F"; rank = ""; position[] = {16.625,7,0}; dir = 359.995;};
class Object161 {side = 8; vehicle = "Land_Pallets_stack_F"; rank = ""; position[] = {17.75,16.125,0}; dir = 255.002;};
class Object162 {side = 8; vehicle = "GunrackTK_EP1"; rank = ""; position[] = {20.3303,7.14404,0}; dir = 90;};
};
};
class ConstructionSuppliesMedium
{
name = $STR_ZECCUP_ConstructionSuppliesMedium;
};
class ConstructionSuppliesSmall
{
name = $STR_ZECCUP_ConstructionSuppliesSmall;
};
| 111.88
| 139
| 0.617597
|
LISTINGS09
|
7360de20d55505eeb7792ff907993656516448fd
| 810
|
hpp
|
C++
|
src/mesh/meshSetup.hpp
|
roystgnr/nekRS
|
280acd21c3088d7658a8a113e544fce05853d7b4
|
[
"BSD-3-Clause"
] | null | null | null |
src/mesh/meshSetup.hpp
|
roystgnr/nekRS
|
280acd21c3088d7658a8a113e544fce05853d7b4
|
[
"BSD-3-Clause"
] | null | null | null |
src/mesh/meshSetup.hpp
|
roystgnr/nekRS
|
280acd21c3088d7658a8a113e544fce05853d7b4
|
[
"BSD-3-Clause"
] | null | null | null |
#if !defined(nekrs_meshsetup_hpp_)
#define nekrs_meshsetup_hpp_
#include "nrs.hpp"
mesh_t* createMeshDummy(MPI_Comm comm,
int N,
int cubN,
setupAide &options,
occa::device device,
occa::properties &kernelInfo);
mesh_t* createMesh(MPI_Comm comm,
int N,
int cubN,
int isMeshT,
setupAide &options,
occa::device device,
occa::properties &kernelInfo);
mesh_t* createMeshV(MPI_Comm comm,
int N,
int cubN,
mesh_t* meshT,
setupAide &options,
occa::properties &kernelInfo);
#endif
| 28.928571
| 54
| 0.455556
|
roystgnr
|
73618c5ca41ce308cb5d7dfecd62df237fbd6307
| 631
|
cpp
|
C++
|
atcoder/abc096/D.cpp
|
SashiRin/protrode
|
c03d0a6e9a5ac87d0f3d3af5d39b05a10f58527c
|
[
"MIT"
] | 1
|
2019-08-03T13:42:16.000Z
|
2019-08-03T13:42:16.000Z
|
atcoder/abc096/D.cpp
|
SashiRin/protrode
|
c03d0a6e9a5ac87d0f3d3af5d39b05a10f58527c
|
[
"MIT"
] | null | null | null |
atcoder/abc096/D.cpp
|
SashiRin/protrode
|
c03d0a6e9a5ac87d0f3d3af5d39b05a10f58527c
|
[
"MIT"
] | null | null | null |
#include <bits/stdc++.h>
using namespace std;
const int maxn = 55555;
int main() {
int n;
cin >> n;
vector<bool> primes(maxn, true);
for (int i = 2; i < maxn; ++i) {
if (primes[i]) {
for (int j = i + i; j < maxn; j += i) {
primes[j] = false;
}
}
}
vector<int> res;
for (int i = 2; i < maxn; ++i) {
if (primes[i] && i % 5 == 1) {
res.push_back(i);
if (res.size() >= n) {
break;
}
}
}
for (int& x : res) {
cout << x << " ";
}
cout << endl;
return 0;
}
| 20.354839
| 51
| 0.37401
|
SashiRin
|
736288df4279cc9a5bb7d7918ae3bb03915977d9
| 4,306
|
cpp
|
C++
|
SimulationTest/gpuTests/CollisionTestGpu.cpp
|
KevinMcGin/Simulation
|
f1dbed05d6024274f6a69e0679f529feaae1e26e
|
[
"MIT"
] | 4
|
2021-12-11T17:59:07.000Z
|
2021-12-24T11:08:55.000Z
|
SimulationTest/gpuTests/CollisionTestGpu.cpp
|
KevinMcGin/Simulation
|
f1dbed05d6024274f6a69e0679f529feaae1e26e
|
[
"MIT"
] | 121
|
2021-12-11T09:20:47.000Z
|
2022-03-13T18:36:48.000Z
|
SimulationTest/gpuTests/CollisionTestGpu.cpp
|
KevinMcGin/Simulation
|
f1dbed05d6024274f6a69e0679f529feaae1e26e
|
[
"MIT"
] | null | null | null |
#include <gtest/gtest.h>
#include "law/collision/Collision.h"
#include "law/collision/detector/CollisionDetectorSimple.cuh"
#include "law/collision/resolver/CollisionResolverCoalesce.cuh"
#include "LawHelper.h"
#include "CollisionTestHelper.h"
TEST(CollisionTest, ParticlesCollideGpu) {
auto law = std::make_shared<Collision>(std::make_shared<CollisionDetectorSimple>(), std::make_shared<CollisionResolverCoalesce>(), true);
std::vector<Particle*> particles = CollisionTestHelper::getParticlesCollideParticles();
LawHelper::runGpuLaw(law, particles);
CollisionTestHelper::testParticlesCollide(particles);
}
TEST(CollisionTest, MultipleParticlesAllCollideGpu) {
auto law = std::make_shared<Collision>(std::make_shared<CollisionDetectorSimple>(), std::make_shared<CollisionResolverCoalesce>(), true);
std::vector<Particle*> particles = CollisionTestHelper::getMultipleParticlesAllCollide();
LawHelper::runGpuLaw(law, particles);
CollisionTestHelper::testMultipleParticlesAllCollide(particles);
}
TEST(CollisionTest, MultipleParticlesPartialCollideGpu) {
auto law = std::make_shared<Collision>(std::make_shared<CollisionDetectorSimple>(), std::make_shared<CollisionResolverCoalesce>(), true);
std::vector<Particle*> particles = CollisionTestHelper::getMultipleParticlesPartialCollide();
LawHelper::runGpuLaw(law, particles);
CollisionTestHelper::testMultipleParticlesPartialCollide(particles);
}
TEST(CollisionTest, MultipleParticlesIndependentlyCollide) {
auto law = std::make_shared<Collision>(std::make_shared<CollisionDetectorSimple>(), std::make_shared<CollisionResolverCoalesce>(), true);
std::vector<Particle*> particles = CollisionTestHelper::getMultipleParticlesIndependentlyCollide();
LawHelper::runGpuLaw(law, particles);
CollisionTestHelper::testMultipleParticlesIndependentlyCollide(particles);
}
TEST(CollisionTest, ParticlesCollideGpuLikeCpuSimple) {
const int particleCount = 75;
const int stepsCount = 1;
auto law = std::make_shared<Collision>(std::make_shared<CollisionDetectorSimple>(), std::make_shared<CollisionResolverCoalesce>(), true);
LawHelper::expectGpuLikeCpuRounded(law, particleCount, stepsCount);
}
TEST(CollisionTest, ParticlesCollideGpuLikeCpuMemoryLow) {
CudaWithError::setMaxMemoryPerEvent(1000 * 1000);
const int particleCount = 75;
const int stepsCount = 1;
auto law = std::make_shared<Collision>(std::make_shared<CollisionDetectorSimple>(), std::make_shared<CollisionResolverCoalesce>(), true);
LawHelper::expectGpuLikeCpuRounded(law, particleCount, stepsCount);
}
TEST(CollisionTest, ParticlesCollideGpuLikeCpuMemoryVeryLow) {
CudaWithError::setMaxMemoryPerEvent(1000);
const int particleCount = 75;
const int stepsCount = 1;
auto law = std::make_shared<Collision>(std::make_shared<CollisionDetectorSimple>(), std::make_shared<CollisionResolverCoalesce>(), true);
LawHelper::expectGpuLikeCpuRounded(law, particleCount, stepsCount);
}
TEST(CollisionTest, ParticlesCollideGpuLikeCpuMemoryTooLow1) {
CudaWithError::setMaxMemoryPerEvent(100);
const int particleCount = 75;
const int stepsCount = 1;
auto law = std::make_shared<Collision>(std::make_shared<CollisionDetectorSimple>(), std::make_shared<CollisionResolverCoalesce>(), true);
try {
LawHelper::expectGpuLikeCpuRounded(law, particleCount, stepsCount);
FAIL() << "No error thrown: expected Max Loops in GpuCollision reached";
} catch(std::runtime_error const &err) {
EXPECT_EQ(err.what(), std::string("Max Loops in GpuCollision reached"));
} catch(...) {
FAIL() << "Wrong error thrown: expected Max Loops in GpuCollision reached";
}
}
TEST(CollisionTest, ParticlesCollideGpuLikeCpuMemoryTooLow2) {
CudaWithError::setMaxMemoryPerEvent(10);
const int particleCount = 75;
const int stepsCount = 1;
auto law = std::make_shared<Collision>(std::make_shared<CollisionDetectorSimple>(), std::make_shared<CollisionResolverCoalesce>(), true);
try {
LawHelper::expectGpuLikeCpuRounded(law, particleCount, stepsCount);
FAIL() << "No error thrown: expected Ran out of GPU memory";
} catch(std::runtime_error const &err) {
EXPECT_EQ(err.what(), std::string("Ran out of GPU memory"));
} catch(...) {
FAIL() << "Wrong error thrown: expected Ran out of GPU memory";
}
}
| 44.391753
| 138
| 0.774268
|
KevinMcGin
|
736877c8b40a7cdb42de867111f7b7484a4c1df6
| 357
|
cpp
|
C++
|
2.1 Pointer/array.cpp
|
arryaaas/Programming-Algorithms
|
f469431830cbe528feb297abd47d2d6c08e0781a
|
[
"MIT"
] | null | null | null |
2.1 Pointer/array.cpp
|
arryaaas/Programming-Algorithms
|
f469431830cbe528feb297abd47d2d6c08e0781a
|
[
"MIT"
] | null | null | null |
2.1 Pointer/array.cpp
|
arryaaas/Programming-Algorithms
|
f469431830cbe528feb297abd47d2d6c08e0781a
|
[
"MIT"
] | null | null | null |
#include <iostream>
using namespace std;
int main(){
//Pointer declaration
int *p;
//Array declaration
int arr[]={1, 2, 3, 4, 5, 6};
//Assignment
p = arr;
for(int i=0; i<6;i++){
cout<<*p<<endl;
// cout<<sizeof(p)<<endl;
//++ moves the pointer to next int position
p++;
}
return 0;
}
| 14.875
| 51
| 0.498599
|
arryaaas
|
736a350791245f317f077731db992826be4c9aa1
| 6,502
|
cpp
|
C++
|
FMU/Source/Model_ExternalShading.cpp
|
kwabenantim/No-MASS
|
843ccaa461923e227a8e854daaa6952d14cb8bed
|
[
"MIT"
] | null | null | null |
FMU/Source/Model_ExternalShading.cpp
|
kwabenantim/No-MASS
|
843ccaa461923e227a8e854daaa6952d14cb8bed
|
[
"MIT"
] | 1
|
2020-08-28T18:11:26.000Z
|
2020-08-28T18:11:26.000Z
|
FMU/Source/Model_ExternalShading.cpp
|
kwabenantim/No-MASS
|
843ccaa461923e227a8e854daaa6952d14cb8bed
|
[
"MIT"
] | 2
|
2020-02-05T10:49:42.000Z
|
2020-08-28T08:23:28.000Z
|
// Copyright 2015 Jacob Chapman
#include <cmath>
#include <algorithm>
#include "Utility.hpp"
#include "Model_ExternalShading.hpp"
Model_ExternalShading::Model_ExternalShading() {
a01arr = -7.41;
b01inarr = 0.001035;
b01sarr = 2.17;
// Probability of raising on arrival
a10arr = -1.520;
b10inarr = -0.000654;
b10sarr = -3.139;
// Probability of lowering during presence
a01int = -8.013;
b01inint = 0.000841;
b01sint = 1.270;
// Probability of raising during presence
a10int = -3.625;
b10inint = -0.000276;
b10sint = -2.683;
// Probability of full raising
afullraise = 0.435;
boutfullraise = 1.95;
bsfullraise = -0.0000231;
// Choice of new unshaded fraction
aSFlower = -2.294;
bSFlower = 1.522;
shapelower = 1.708;
bsfulllower = 0.00000091;
boutfulllower = -2.23;
afulllower = -0.27;
}
void Model_ExternalShading::setFullVars(float afullraise, float boutfullraise,
float bsfullraise, float bsfulllower, float boutfulllower,
float afulllower) {
this->afullraise = afullraise;
this->boutfullraise = boutfullraise;
this->bsfullraise = bsfullraise;
this->bsfulllower = bsfulllower;
this->boutfulllower = boutfulllower;
this->afulllower = afulllower;
}
void Model_ExternalShading::setDurationVars(float aSFlower, float bSFlower,
float shapelower) {
this->aSFlower = aSFlower;
this->bSFlower = bSFlower;
this->shapelower = shapelower;
}
void Model_ExternalShading::setArrivalVars(float a01arr, float b01inarr,
float b01sarr, float a10arr, float b10inarr, float b10sarr) {
this->a01arr = a01arr;
this->b01inarr = b01inarr;
this->b01sarr = b01sarr;
// Probability of raising on arrival
this->a10arr = a10arr;
this->b10inarr = b10inarr;
this->b10sarr = b10sarr;
}
void Model_ExternalShading::setInterVars(float a01int, float b01inint,
float b01sint, float a10int, float b10inint, float b10sint) {
// Probability of lowering during presence
this->a01int = a01int;
this->b01inint = b01inint;
this->b01sint = b01sint;
// Probability of raising during presence
this->a10int = a10int;
this->b10inint = b10inint;
this->b10sint = b10sint;
}
double Model_ExternalShading::arrival(double state, double Lumint, double Evg) {
double currentShadingState;
double probraise = 0.f;
if (state != 1.f) {
double m_raise = a10arr + b10inarr * Lumint + b10sarr * (state);
probraise = probability(m_raise);
}
double problower = 0.f;
if (state != 0.f) {
double m_lower = a01arr + b01inarr * Lumint + b01sarr * (state);
problower = probability(m_lower);
}
if (problower >= probraise) {
if (randomDouble() < problower) {
currentShadingState = arrivalLowering(state, Evg);
} else if (randomDouble() < probraise) {
currentShadingState = arrivalRaising(state, Evg);
} else {
currentShadingState = state;
}
} else {
if (randomDouble() < probraise) {
currentShadingState = arrivalRaising(state, Evg);
} else if (randomDouble() < problower) {
currentShadingState = arrivalLowering(state, Evg);
} else {
currentShadingState = state;
}
}
return currentShadingState;
}
double Model_ExternalShading::intermediate(bool state, double Lumint,
double Evg) {
return departure(state, Lumint, Evg);
}
double Model_ExternalShading::departure(double state, double Lumint,
double Evg) {
double currentShadingState;
float problower = 0.f;
float probraise = 0.f;
if (state != 1.f) {
double m_probraise = a10int + b10inint * Lumint + b10sint * (state);
probraise = probability(m_probraise);
}
if (state != 0.f) {
double m_problower = a01int + b01inint * Lumint + b01sint * (state);
problower = probability(m_problower);
}
if (problower >= probraise) {
if (randomDouble() < problower) {
currentShadingState = departureLowering(state, Evg);
} else if (randomDouble() < probraise) {
currentShadingState = departureRaising(state, Evg);
} else {
currentShadingState = state;
}
} else {
if (randomDouble() < probraise) {
currentShadingState = departureRaising(state, Evg);
} else if (randomDouble() < problower) {
currentShadingState = departureLowering(state, Evg);
} else {
currentShadingState = state;
}
}
return currentShadingState;
}
double Model_ExternalShading::arrivalRaising(double state, double Evg) {
double currentShadingState;
double m_totraise = afullraise + boutfullraise * Evg + bsfullraise * (state);
float ptotraise = probability(m_totraise);
double r = randomDouble();
if (r < ptotraise) {
currentShadingState = 1.f;
} else {
currentShadingState = 0.01f * round(100.f * randomDouble((state), 1.f));
}
return currentShadingState;
}
double Model_ExternalShading::arrivalLowering(double state,
double Evg) {
double currentShadingState;
double m_totlow = afulllower + boutfulllower * Evg + bsfulllower * (state);
float ptotlow = probability(m_totlow);
if (randomDouble() < ptotlow) {
currentShadingState = 0.f;
} else {
float Reduction =
randomWeibull(exp(aSFlower + bSFlower * (state)), shapelower);
currentShadingState =
0.01f * round(100.f * std::max((state) - Reduction, 0.01));
}
return currentShadingState;
}
double Model_ExternalShading::departureLowering(double state, double Evg) {
double currentShadingState;
double m_ptotlow = afulllower + boutfulllower * Evg + bsfulllower * (state);
float ptotlow = probability(m_ptotlow);
if (randomDouble() < ptotlow) {
currentShadingState = (0.f);
} else {
float Reduction =
randomWeibull(exp(aSFlower + bSFlower * (state)), shapelower);
currentShadingState =
0.01f * round(100.f * std::max((state) - Reduction, 0.01));
}
return currentShadingState;
}
double Model_ExternalShading::departureRaising(double state, double Evg) {
double currentShadingState;
double m_totraise = afullraise + boutfullraise * Evg + bsfullraise * (state);
float ptotraise = probability(m_totraise);
if (randomDouble(0.f, 1.f) < ptotraise) {
currentShadingState = (1.f);
} else {
currentShadingState = 0.01f * round(100.f * randomDouble((state), 1.f));
}
return currentShadingState;
}
| 30.961905
| 80
| 0.665488
|
kwabenantim
|
736d4f8ad7401c2184db476974f1f418f1285784
| 908
|
hpp
|
C++
|
ExternalLibraries/NvGameworksFramework/externals/include/Cg/determinant.hpp
|
centauroWaRRIor/VulkanSamples
|
5a7c58de820207cc0931a9db8c90f00453e31631
|
[
"MIT"
] | null | null | null |
ExternalLibraries/NvGameworksFramework/externals/include/Cg/determinant.hpp
|
centauroWaRRIor/VulkanSamples
|
5a7c58de820207cc0931a9db8c90f00453e31631
|
[
"MIT"
] | null | null | null |
ExternalLibraries/NvGameworksFramework/externals/include/Cg/determinant.hpp
|
centauroWaRRIor/VulkanSamples
|
5a7c58de820207cc0931a9db8c90f00453e31631
|
[
"MIT"
] | null | null | null |
/*
* Copyright 2005 by NVIDIA Corporation. All rights reserved. All
* information contained herein is proprietary and confidential to NVIDIA
* Corporation. Any use, reproduction, or disclosure without the written
* permission of NVIDIA Corporation is prohibited.
*/
#ifndef __Cg_determinant_hpp__
#define __Cg_determinant_hpp__
#ifdef __Cg_stdlib_hpp__
#pragma message("error: include this header file (" __FILE__ ") before <Cg/stdlib.hpp>")
#endif
#include <Cg/matrix.hpp>
namespace Cg {
extern float1 determinant(float1x1 A);
extern float1 determinant(float2x2 A);
extern float1 determinant(float3x3 A);
extern float1 determinant(float4x4 A);
#ifdef __Cg_double_hpp__
extern double1 determinant(double1x1 A);
extern double1 determinant(double2x2 A);
extern double1 determinant(double3x3 A);
extern double1 determinant(double4x4 A);
#endif
} // namespace Cg
#endif // __Cg_determinant_hpp__
| 27.515152
| 88
| 0.790749
|
centauroWaRRIor
|
736dc38180ef41f17243d9ce252f186d6be1eafc
| 656
|
h++
|
C++
|
clauses/select_clause.h++
|
snawaz/tagsql
|
1b6d6c9eb9aa2d01ff3276414d714f3b6e6a9ee3
|
[
"MIT"
] | 4
|
2018-03-03T13:45:35.000Z
|
2021-05-22T12:11:08.000Z
|
clauses/select_clause.h++
|
snawaz/tagsql
|
1b6d6c9eb9aa2d01ff3276414d714f3b6e6a9ee3
|
[
"MIT"
] | 1
|
2018-03-03T13:49:40.000Z
|
2019-01-22T07:58:47.000Z
|
clauses/select_clause.h++
|
snawaz/tagsql
|
1b6d6c9eb9aa2d01ff3276414d714f3b6e6a9ee3
|
[
"MIT"
] | 1
|
2018-03-03T13:45:36.000Z
|
2018-03-03T13:45:36.000Z
|
#pragma once
#include <memory>
#include <pqxx/pqxx>
#include <tagsql/anatomy/table.h++>
namespace tagsql
{
template<typename SelectQuery>
class composite_table;
template<typename SelectQuery>
class select_clause
{
public:
select_clause(std::shared_ptr<pqxx::connection> & connection) : _connection(connection) {}
template<typename Table>
auto from(Table) -> composite_table<typename SelectQuery::template add_from<table_tag_t<Table>>::type>
{
return { _connection, "FROM " + metaspace::meta_table<table_tag_t<Table>>::name() };
}
private:
std::shared_ptr<pqxx::connection> _connection;
};
} //tagsql
| 21.16129
| 105
| 0.705793
|
snawaz
|
7371c310a8c120485d865d36fbc6a0f87475027e
| 9,589
|
cc
|
C++
|
common/unit_test/CryptoCNGMultithreadTest.cc
|
liuxiang88/core-alljoyn
|
549c966482d9b89da84aa528117584e7049916cb
|
[
"Apache-2.0"
] | 33
|
2018-01-12T00:37:43.000Z
|
2022-03-24T02:31:36.000Z
|
common/unit_test/CryptoCNGMultithreadTest.cc
|
liuxiang88/core-alljoyn
|
549c966482d9b89da84aa528117584e7049916cb
|
[
"Apache-2.0"
] | 1
|
2020-01-05T05:51:27.000Z
|
2020-01-05T05:51:27.000Z
|
common/unit_test/CryptoCNGMultithreadTest.cc
|
liuxiang88/core-alljoyn
|
549c966482d9b89da84aa528117584e7049916cb
|
[
"Apache-2.0"
] | 30
|
2017-12-13T23:24:00.000Z
|
2022-01-25T02:11:19.000Z
|
/******************************************************************************
* Copyright (c) Open Connectivity Foundation (OCF), AllJoyn Open Source
* Project (AJOSP) Contributors and others.
*
* SPDX-License-Identifier: Apache-2.0
*
* All rights reserved. This program and the accompanying materials are
* made available under the terms of the Apache License, Version 2.0
* which accompanies this distribution, and is available at
* http://www.apache.org/licenses/LICENSE-2.0
*
* Copyright (c) Open Connectivity Foundation and Contributors to AllSeen
* Alliance. All rights reserved.
*
* Permission to use, copy, modify, and/or distribute this software for
* any purpose with or without fee is hereby granted, provided that the
* above copyright notice and this permission notice appear in all
* copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
* WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
* AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
******************************************************************************/
/* These tests apply only to CNG on Windows. */
#ifdef CRYPTO_CNG
#include <gtest/gtest.h>
#include <qcc/Crypto.h>
#include "../crypto/Crypto.h"
#include <qcc/CngCache.h>
#include <qcc/Thread.h>
#include <qcc/Util.h>
#include <memory>
#include <vector>
using namespace qcc;
/*
* These tests have multiple threads that all attempt to initialize provider handles at the same
* time. No matter what, when everything is done, all the threads should come away with the
* same provider handles as all the other threads.
*/
static const int trials = 20;
static const int numThreads = 100;
typedef struct {
BCRYPT_ALG_HANDLE handles[CngCache::ALGORITHM_COUNT][2];
} MultipleOpenHashHandleTestResult;
static ThreadReturn STDCALL MultipleOpenHashHandleThreadRun(void* arg)
{
QStatus status;
MultipleOpenHashHandleTestResult* result = reinterpret_cast<MultipleOpenHashHandleTestResult*>(arg);
for (int algorithm = 0; algorithm < CngCache::ALGORITHM_COUNT; algorithm++) {
status = cngCache.OpenHashHandle(static_cast<Crypto_Hash::Algorithm>(algorithm), false);
if (ER_OK != status) {
return reinterpret_cast<ThreadReturn>(status);
}
result->handles[algorithm][0] = cngCache.algHandles[algorithm][0];
status = cngCache.OpenHashHandle(static_cast<Crypto_Hash::Algorithm>(algorithm), true);
if (ER_OK != status) {
return reinterpret_cast<ThreadReturn>(status);
}
result->handles[algorithm][1] = cngCache.algHandles[algorithm][1];
}
return reinterpret_cast<ThreadReturn>(ER_OK);
}
TEST(CryptoCNGMultithreadTest, MultipleOpenHashHandle)
{
MultipleOpenHashHandleTestResult results[numThreads];
std::vector<std::unique_ptr<Thread> > threads(numThreads);
for (uint8_t trial = 0; trial < trials; trial++) {
memset(results, 0, sizeof(results));
Crypto::Shutdown();
ASSERT_EQ(ER_OK, Crypto::Init());
for (size_t i = 0; i < threads.size(); i++) {
threads[i].reset(new Thread("", MultipleOpenHashHandleThreadRun, false));
}
for (size_t i = 0; i < threads.size(); i++) {
ASSERT_EQ(ER_OK, threads[i]->Start(&results[i]));
}
for (size_t i = 0; i < threads.size(); i++) {
ASSERT_EQ(ER_OK, threads[i]->Join());
ASSERT_FALSE(threads[i]->IsRunning());
ASSERT_EQ(reinterpret_cast<ThreadReturn>(ER_OK), threads[i]->GetExitValue());
}
for (size_t i = 1; i < ArraySize(results); i++) {
for (int alg = 0; alg < CngCache::ALGORITHM_COUNT; alg++) {
EXPECT_NE(results[i].handles[alg][0], results[i].handles[alg][1]);
EXPECT_EQ(results[0].handles[alg][0], results[i].handles[alg][0]);
EXPECT_EQ(results[0].handles[alg][1], results[i].handles[alg][1]);
}
}
}
Crypto::Shutdown();
}
static ThreadReturn STDCALL MultipleOpenAesHandleThreadRun(void* arg)
{
QStatus status;
BCRYPT_ALG_HANDLE* handles = reinterpret_cast<BCRYPT_ALG_HANDLE*>(arg);
status = cngCache.OpenCcmHandle();
if (ER_OK != status) {
return reinterpret_cast<ThreadReturn>(status);
}
handles[0] = cngCache.ccmHandle;
status = cngCache.OpenEcbHandle();
if (ER_OK != status) {
return reinterpret_cast<ThreadReturn>(status);
}
handles[1] = cngCache.ecbHandle;
return reinterpret_cast<ThreadReturn>(ER_OK);
}
TEST(CryptoCNGMultithreadTest, MultipleOpenAesHandle)
{
BCRYPT_ALG_HANDLE handles[numThreads][2];
std::vector<std::unique_ptr<Thread> > threads(numThreads);
for (uint8_t trial = 0; trial < trials; trial++) {
memset(handles, 0, sizeof(handles));
Crypto::Shutdown();
ASSERT_EQ(ER_OK, Crypto::Init());
for (size_t i = 0; i < threads.size(); i++) {
threads[i].reset(new Thread("", MultipleOpenAesHandleThreadRun, false));
}
for (size_t i = 0; i < threads.size(); i++) {
ASSERT_EQ(ER_OK, threads[i]->Start(&handles[i]));
}
for (size_t i = 0; i < threads.size(); i++) {
ASSERT_EQ(ER_OK, threads[i]->Join());
ASSERT_FALSE(threads[i]->IsRunning());
ASSERT_EQ(reinterpret_cast<ThreadReturn>(ER_OK), threads[i]->GetExitValue());
}
for (size_t i = 1; i < ArraySize(handles); i++) {
for (int alg = 0; alg < CngCache::ALGORITHM_COUNT; alg++) {
EXPECT_NE(handles[i][0], handles[i][1]);
EXPECT_EQ(handles[0][0], handles[i][0]);
EXPECT_EQ(handles[0][1], handles[i][1]);
}
}
}
Crypto::Shutdown();
}
static ThreadReturn STDCALL MultipleOpenEcdsaHandleThreadRun(void* arg)
{
QStatus status;
BCRYPT_ALG_HANDLE* handles = reinterpret_cast<BCRYPT_ALG_HANDLE*>(arg);
for (int algorithm = 0; algorithm < CngCache::ECDSA_ALGORITHM_COUNT; algorithm++) {
status = cngCache.OpenEcdsaHandle(algorithm);
if (ER_OK != status) {
return reinterpret_cast<ThreadReturn>(status);
}
handles[algorithm] = cngCache.ecdsaHandles[algorithm];
}
return reinterpret_cast<ThreadReturn>(ER_OK);
}
TEST(CryptoCNGMultithreadTest, MultipleOpenEcdsaHandle)
{
BCRYPT_ALG_HANDLE handles[numThreads][CngCache::ECDSA_ALGORITHM_COUNT];
std::vector<std::unique_ptr<Thread> > threads(numThreads);
for (uint8_t trial = 0; trial < trials; trial++) {
memset(handles, 0, sizeof(handles));
Crypto::Shutdown();
ASSERT_EQ(ER_OK, Crypto::Init());
for (size_t i = 0; i < threads.size(); i++) {
threads[i].reset(new Thread("", MultipleOpenEcdsaHandleThreadRun, false));
}
for (size_t i = 0; i < threads.size(); i++) {
ASSERT_EQ(ER_OK, threads[i]->Start(&handles[i]));
}
for (size_t i = 0; i < threads.size(); i++) {
ASSERT_EQ(ER_OK, threads[i]->Join());
ASSERT_FALSE(threads[i]->IsRunning());
ASSERT_EQ(reinterpret_cast<ThreadReturn>(ER_OK), threads[i]->GetExitValue());
}
for (size_t i = 1; i < ArraySize(handles); i++) {
for (int alg = 0; alg < CngCache::ECDSA_ALGORITHM_COUNT; alg++) {
EXPECT_EQ(handles[0][alg], handles[i][alg]);
}
}
}
Crypto::Shutdown();
}
static ThreadReturn STDCALL MultipleOpenEcdhHandleThreadRun(void* arg)
{
QStatus status;
BCRYPT_ALG_HANDLE* handles = reinterpret_cast<BCRYPT_ALG_HANDLE*>(arg);
for (int algorithm = 0; algorithm < CngCache::ECDH_ALGORITHM_COUNT; algorithm++) {
status = cngCache.OpenEcdhHandle(algorithm);
if (ER_OK != status) {
return reinterpret_cast<ThreadReturn>(status);
}
handles[algorithm] = cngCache.ecdhHandles[algorithm];
}
return reinterpret_cast<ThreadReturn>(ER_OK);
}
TEST(CryptoCNGMultithreadTest, MultipleOpenEcdhHandle)
{
BCRYPT_ALG_HANDLE handles[numThreads][CngCache::ECDH_ALGORITHM_COUNT];
std::vector<std::unique_ptr<Thread> > threads(numThreads);
for (uint8_t trial = 0; trial < trials; trial++) {
memset(handles, 0, sizeof(handles));
Crypto::Shutdown();
ASSERT_EQ(ER_OK, Crypto::Init());
for (size_t i = 0; i < threads.size(); i++) {
threads[i].reset(new Thread("", MultipleOpenEcdhHandleThreadRun, false));
}
for (size_t i = 0; i < threads.size(); i++) {
ASSERT_EQ(ER_OK, threads[i]->Start(&handles[i]));
}
for (size_t i = 0; i < threads.size(); i++) {
ASSERT_EQ(ER_OK, threads[i]->Join());
ASSERT_FALSE(threads[i]->IsRunning());
ASSERT_EQ(reinterpret_cast<ThreadReturn>(ER_OK), threads[i]->GetExitValue());
}
for (size_t i = 1; i < ArraySize(handles); i++) {
for (int alg = 0; alg < CngCache::ECDH_ALGORITHM_COUNT; alg++) {
EXPECT_EQ(handles[0][alg], handles[i][alg]);
}
}
}
Crypto::Shutdown();
}
#endif /* CRYPTO_CNG */
| 34.369176
| 104
| 0.623318
|
liuxiang88
|
73727144668884127305509b827327cd8d9a14b5
| 8,636
|
cpp
|
C++
|
third_party/WebKit/Source/bindings/core/v8/ExceptionState.cpp
|
metux/chromium-deb
|
3c08e9b89a1b6f95f103a61ff4f528dbcd57fc42
|
[
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | null | null | null |
third_party/WebKit/Source/bindings/core/v8/ExceptionState.cpp
|
metux/chromium-deb
|
3c08e9b89a1b6f95f103a61ff4f528dbcd57fc42
|
[
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | null | null | null |
third_party/WebKit/Source/bindings/core/v8/ExceptionState.cpp
|
metux/chromium-deb
|
3c08e9b89a1b6f95f103a61ff4f528dbcd57fc42
|
[
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | null | null | null |
/*
* Copyright (C) 2013 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 "bindings/core/v8/ExceptionState.h"
#include "bindings/core/v8/ExceptionMessages.h"
#include "bindings/core/v8/ScriptPromiseResolver.h"
#include "bindings/core/v8/V8ThrowDOMException.h"
namespace blink {
void ExceptionState::ThrowDOMException(ExceptionCode ec, const char* message) {
ThrowDOMException(ec, String(message));
}
void ExceptionState::ThrowRangeError(const char* message) {
ThrowRangeError(String(message));
}
void ExceptionState::ThrowSecurityError(const char* sanitized_message,
const char* unsanitized_message) {
ThrowSecurityError(String(sanitized_message), String(unsanitized_message));
}
void ExceptionState::ThrowTypeError(const char* message) {
ThrowTypeError(String(message));
}
void ExceptionState::ThrowDOMException(ExceptionCode ec,
const String& message) {
// SecurityError is thrown via ::throwSecurityError, and _careful_
// consideration must be given to the data exposed to JavaScript via the
// 'sanitizedMessage'.
DCHECK(ec != kSecurityError);
const String& processed_message = AddExceptionContext(message);
SetException(
ec, processed_message,
V8ThrowDOMException::CreateDOMException(isolate_, ec, processed_message));
}
void ExceptionState::ThrowRangeError(const String& message) {
SetException(kV8RangeError, message,
V8ThrowException::CreateRangeError(
isolate_, AddExceptionContext(message)));
}
void ExceptionState::ThrowSecurityError(const String& sanitized_message,
const String& unsanitized_message) {
const String& final_sanitized = AddExceptionContext(sanitized_message);
const String& final_unsanitized = AddExceptionContext(unsanitized_message);
SetException(
kSecurityError, final_sanitized,
V8ThrowDOMException::CreateDOMException(
isolate_, kSecurityError, final_sanitized, final_unsanitized));
}
void ExceptionState::ThrowTypeError(const String& message) {
SetException(kV8TypeError, message,
V8ThrowException::CreateTypeError(isolate_,
AddExceptionContext(message)));
}
void ExceptionState::RethrowV8Exception(v8::Local<v8::Value> value) {
SetException(kRethrownException, String(), value);
}
void ExceptionState::ClearException() {
code_ = 0;
message_ = String();
exception_.Clear();
}
ScriptPromise ExceptionState::Reject(ScriptState* script_state) {
ScriptPromise promise = ScriptPromise::Reject(script_state, GetException());
ClearException();
return promise;
}
void ExceptionState::Reject(ScriptPromiseResolver* resolver) {
resolver->Reject(GetException());
ClearException();
}
void ExceptionState::SetException(ExceptionCode ec,
const String& message,
v8::Local<v8::Value> exception) {
CHECK(ec);
code_ = ec;
message_ = message;
if (exception.IsEmpty()) {
exception_.Clear();
} else {
DCHECK(isolate_);
exception_.Set(isolate_, exception);
}
}
String ExceptionState::AddExceptionContext(const String& message) const {
if (message.IsEmpty())
return message;
String processed_message = message;
if (PropertyName() && InterfaceName() && context_ != kUnknownContext) {
if (context_ == kDeletionContext)
processed_message = ExceptionMessages::FailedToDelete(
PropertyName(), InterfaceName(), message);
else if (context_ == kExecutionContext)
processed_message = ExceptionMessages::FailedToExecute(
PropertyName(), InterfaceName(), message);
else if (context_ == kGetterContext)
processed_message = ExceptionMessages::FailedToGet(
PropertyName(), InterfaceName(), message);
else if (context_ == kSetterContext)
processed_message = ExceptionMessages::FailedToSet(
PropertyName(), InterfaceName(), message);
} else if (!PropertyName() && InterfaceName()) {
if (context_ == kConstructionContext)
processed_message =
ExceptionMessages::FailedToConstruct(InterfaceName(), message);
else if (context_ == kEnumerationContext)
processed_message =
ExceptionMessages::FailedToEnumerate(InterfaceName(), message);
else if (context_ == kIndexedDeletionContext)
processed_message =
ExceptionMessages::FailedToDeleteIndexed(InterfaceName(), message);
else if (context_ == kIndexedGetterContext)
processed_message =
ExceptionMessages::FailedToGetIndexed(InterfaceName(), message);
else if (context_ == kIndexedSetterContext)
processed_message =
ExceptionMessages::FailedToSetIndexed(InterfaceName(), message);
}
return processed_message;
}
NonThrowableExceptionState::NonThrowableExceptionState()
: ExceptionState(nullptr,
ExceptionState::kUnknownContext,
nullptr,
nullptr),
file_(""),
line_(0) {}
NonThrowableExceptionState::NonThrowableExceptionState(const char* file,
int line)
: ExceptionState(nullptr,
ExceptionState::kUnknownContext,
nullptr,
nullptr),
file_(file),
line_(line) {}
void NonThrowableExceptionState::ThrowDOMException(ExceptionCode ec,
const String& message) {
DCHECK_AT(false, file_, line_) << "DOMExeption should not be thrown.";
}
void NonThrowableExceptionState::ThrowRangeError(const String& message) {
DCHECK_AT(false, file_, line_) << "RangeError should not be thrown.";
}
void NonThrowableExceptionState::ThrowSecurityError(
const String& sanitized_message,
const String&) {
DCHECK_AT(false, file_, line_) << "SecurityError should not be thrown.";
}
void NonThrowableExceptionState::ThrowTypeError(const String& message) {
DCHECK_AT(false, file_, line_) << "TypeError should not be thrown.";
}
void NonThrowableExceptionState::RethrowV8Exception(v8::Local<v8::Value>) {
DCHECK_AT(false, file_, line_) << "An exception should not be rethrown.";
}
void DummyExceptionStateForTesting::ThrowDOMException(ExceptionCode ec,
const String& message) {
SetException(ec, message, v8::Local<v8::Value>());
}
void DummyExceptionStateForTesting::ThrowRangeError(const String& message) {
SetException(kV8RangeError, message, v8::Local<v8::Value>());
}
void DummyExceptionStateForTesting::ThrowSecurityError(
const String& sanitized_message,
const String&) {
SetException(kSecurityError, sanitized_message, v8::Local<v8::Value>());
}
void DummyExceptionStateForTesting::ThrowTypeError(const String& message) {
SetException(kV8TypeError, message, v8::Local<v8::Value>());
}
void DummyExceptionStateForTesting::RethrowV8Exception(v8::Local<v8::Value>) {
SetException(kRethrownException, String(), v8::Local<v8::Value>());
}
} // namespace blink
| 37.71179
| 80
| 0.704724
|
metux
|
737448c247448c9b272305bbc67b3dde1ebbe09c
| 7,037
|
cpp
|
C++
|
src/modeler/UpdateRulesHandler/update_rules_editor.cpp
|
rff255/Genesis
|
d87ff57e2c36f39bf62b4953f5f99190e82588f8
|
[
"MIT"
] | 7
|
2017-08-08T17:10:58.000Z
|
2020-10-02T04:33:03.000Z
|
src/modeler/UpdateRulesHandler/update_rules_editor.cpp
|
rff255/Genesis
|
d87ff57e2c36f39bf62b4953f5f99190e82588f8
|
[
"MIT"
] | 1
|
2017-05-02T01:50:22.000Z
|
2017-05-02T01:50:22.000Z
|
src/modeler/UpdateRulesHandler/update_rules_editor.cpp
|
rff255/Genesis
|
d87ff57e2c36f39bf62b4953f5f99190e82588f8
|
[
"MIT"
] | 3
|
2017-09-01T08:04:44.000Z
|
2020-08-21T01:38:24.000Z
|
#include "update_rules_editor.h"
#include "nodes_editor/imguinodegrapheditor.h"
#include "UpdateRulesHandler/node_graph_instance.h"
#include "JSON_nlohmann/json.hpp"
#include <vector>
#include <string>
using json = nlohmann::json;
UpdateRulesEditor::UpdateRulesEditor(){
mEditor = ImGui::NodeGraphEditor();
mEditor.show_node_copy_paste_buttons = false;
mEditor.show_style_editor = false;
mEditor.show_top_pane = true;
InitNGE(mEditor);
}
void UpdateRulesEditor::InitFromSerializedData(json rules_editor) {
// Restore editor setup
// TODO()
// Restore Nodes
json nodes_list = rules_editor[serialization_tags::kNodesList];
std::unordered_map<int, int> old_to_new_node_id;
for (auto& node_json : nodes_list) {
const int node_old_id = node_json[serialization_tags::kNodeId];
const int node_type = node_json[serialization_tags::kNodeType];
const float node_pos[2] = {node_json[serialization_tags::kNodePos][0],
node_json[serialization_tags::kNodePos][1]};
const string node_data = node_json[serialization_tags::kNodeData];
const json node_meta_data = node_json[serialization_tags::kNodeMetaData];
auto new_node = mEditor.addNode(node_type, ImVec2(node_pos[0], node_pos[1]));
if(node_data.size()>0) new_node->SetupFromSerializedData(node_data);
if(node_meta_data.size()>0) new_node->SetupFromSerializedMetaData(node_meta_data);
const int new_id = new_node->mNodeId;
old_to_new_node_id[node_old_id] = new_id;
}
// Restore Links
json links_list = rules_editor[serialization_tags::kLinksList];
for (auto& link_json : links_list) {
const int in_node_id_old = link_json[serialization_tags::kLinkInNode];
const int out_node_id_old = link_json[serialization_tags::kLinkOutNode];
const int in_port = link_json[serialization_tags::kLinkInPort];
const int out_port = link_json[serialization_tags::kLinkOutPort];
const int in_node_id_new = old_to_new_node_id[in_node_id_old];
const int out_node_id_new = old_to_new_node_id[out_node_id_old];
mEditor.addLink(mEditor.getNodeById(in_node_id_new), in_port,
mEditor.getNodeById(out_node_id_new), out_port);
}
// Restore Nodes model configuration
}
json UpdateRulesEditor::GetSerializedData() {
// Json = {
// {kEditorSetup:{}},
// {kNodesList:['Node', 'Node', ...]},
// {kLinksList:['Link', 'Link', 'Link', ...]}
// }
// 'Node' = {<kNodeId>:1, <kNodeType>: 2, <kNodePos>:[200,500]}
// 'Link' = {<kLinkInNode>:1, <kLinkOutNode>:2, <kLinkInPort>:0, <kLinkOutPort>:0}
// Get editor options
json editor_setup;
// TODO(): Pan, zoom, style, selected nodes, and so on..
// Get nodes data
json nodes_list;
for(int i=0; i<mEditor.getNumNodes(); ++i) {
const ImGui::Node* node = mEditor.getNode(i);
const int node_id = node->mNodeId;
const int node_type = node->getType();
const float node_pos[2] = {node->GetPos().x, node->GetPos().y};
const string node_data = node->GetSerializedData();
const json node_meta_data = node->GetSerializedMetaData();
nodes_list.push_back({{serialization_tags::kNodeId, node_id},
{serialization_tags::kNodeType, node_type},
{serialization_tags::kNodePos, node_pos},
{serialization_tags::kNodeData, node_data},
{serialization_tags::kNodeMetaData, node_meta_data}});
}
// Get links data
json links_list;
for (int i=0; i<mEditor.getNumLinks();++i) {
const ImGui::NodeLink* link = mEditor.getLink(i);
const int in_node_id = link->InputNode->mNodeId;
const int out_node_id = link->OutputNode->mNodeId;
const int in_port = link->InputSlot;
const int out_port = link->OutputSlot;
links_list.push_back({{serialization_tags::kLinkInNode, in_node_id},
{serialization_tags::kLinkOutNode, out_node_id},
{serialization_tags::kLinkInPort, in_port},
{serialization_tags::kLinkOutPort, out_port},
});
}
// Join everything
json data = {{serialization_tags::kEditorSetup, editor_setup},
{serialization_tags::kNodesList, nodes_list},
{serialization_tags::kLinksList, links_list}};
return data;
}
std::string UpdateRulesEditor::EvalGraphEditorStep() {
// Get the step node, for initiate the code generation
ImVector<ImGui::Node*> stepNodes = ImVector<ImGui::Node*>(); // There is only one step node, but the function is generic
mEditor.getAllNodesOfType(ImGui::NodeTypes::kStepNode, &stepNodes);
// By calling the step Eval(), all the reachable nodes will be also called recursively
if(stepNodes.size() > 0)
return stepNodes[0]->Eval(mEditor, 0);
return "void CACell::Step(){}\n";
}
std::string UpdateRulesEditor::EvalGraphEditorDefaultInit()
{
// Get the DefaultInit node, for initiate the code generation
ImVector<ImGui::Node*> defaultInitNodes = ImVector<ImGui::Node*>(); // There is only one default initialization node at most, but the function is generic
mEditor.getAllNodesOfType(ImGui::NodeTypes::kDefaultInitializationNode, &defaultInitNodes);
// By calling the step Eval(), all the reachable nodes will be also called recursively
if(defaultInitNodes.size() > 0)
return defaultInitNodes[0]->Eval(mEditor, 0);
else { // No default has been defined. The function does nothing.
return "void CACell::DefaultInit(){}\n";
}
}
std::string UpdateRulesEditor::EvalGraphEditorInputColorNodes()
{
// Get the InputColor nodes, for initiate the code generation
ImVector<ImGui::Node*> InputColorNodes = ImVector<ImGui::Node*>();
mEditor.getAllNodesOfType(ImGui::NodeTypes::kInputColorNode, &InputColorNodes);
std::string inputColorNodesCode = "";
// By calling the step Eval(), all the reachable nodes will be also called recursively
for(auto node: InputColorNodes)
inputColorNodesCode += node->Eval(mEditor, 0);
return inputColorNodesCode;
}
void UpdateRulesEditor::UpdateComboBoxes(std::vector<std::string> cellAttrNames,
std::vector<std::string> modelAttrNames,
std::vector<std::string> neighborhoodNames,
std::vector<std::string> colAttrMappingNames,
std::vector<std::string> attrColMappingNames,
std::vector<int> neighborhoodSizes) {
gCellAttrNames = cellAttrNames;
gModelAttrNames = modelAttrNames;
gNeighborhoodNames = neighborhoodNames;
gColAttrMappingsNames = colAttrMappingNames;
gAttrColMappingsNames = attrColMappingNames;
gNeighborhoodSizes = neighborhoodSizes;
UpdateEnumNames();
}
void UpdateModelAttrNames(std::vector<std::string> names) {
gModelAttrNames = names;
}
void UpdateNeighborhoodNames(std::vector<std::string> names) {
gNeighborhoodNames = names;
}
| 38.453552
| 155
| 0.68623
|
rff255
|
73748955ce3f0f2a433ed54e4ef630ed4017c670
| 10,852
|
hh
|
C++
|
EnergyPlus/PoweredInductionUnits.hh
|
yurigabrich/EnergyPlusShadow
|
396ca83aa82b842e6b177ba35c91b3f481dfbbf9
|
[
"BSD-3-Clause"
] | null | null | null |
EnergyPlus/PoweredInductionUnits.hh
|
yurigabrich/EnergyPlusShadow
|
396ca83aa82b842e6b177ba35c91b3f481dfbbf9
|
[
"BSD-3-Clause"
] | 1
|
2020-07-08T13:32:09.000Z
|
2020-07-08T13:32:09.000Z
|
EnergyPlus/PoweredInductionUnits.hh
|
yurigabrich/EnergyPlusShadow
|
396ca83aa82b842e6b177ba35c91b3f481dfbbf9
|
[
"BSD-3-Clause"
] | null | null | null |
// EnergyPlus, Copyright (c) 1996-2018, The Board of Trustees of the University of Illinois,
// The Regents of the University of California, through Lawrence Berkeley National Laboratory
// (subject to receipt of any required approvals from the U.S. Dept. of Energy), Oak Ridge
// National Laboratory, managed by UT-Battelle, Alliance for Sustainable Energy, LLC, and other
// contributors. All rights reserved.
//
// NOTICE: This Software was developed under funding from the U.S. Department of Energy and the
// U.S. Government consequently retains certain rights. As such, the U.S. Government has been
// granted for itself and others acting on its behalf a paid-up, nonexclusive, irrevocable,
// worldwide license in the Software to reproduce, distribute copies to the public, prepare
// derivative works, and perform publicly and display publicly, and to permit others to do so.
//
// Redistribution and use in source and binary forms, with or without modification, are permitted
// provided that the following conditions are met:
//
// (1) Redistributions of source code must retain the above copyright notice, this list of
// conditions and the following disclaimer.
//
// (2) Redistributions in binary form must reproduce the above copyright notice, this list of
// conditions and the following disclaimer in the documentation and/or other materials
// provided with the distribution.
//
// (3) Neither the name of the University of California, Lawrence Berkeley National Laboratory,
// the University of Illinois, U.S. Dept. of Energy nor the names of its contributors may be
// used to endorse or promote products derived from this software without specific prior
// written permission.
//
// (4) Use of EnergyPlus(TM) Name. If Licensee (i) distributes the software in stand-alone form
// without changes from the version obtained under this License, or (ii) Licensee makes a
// reference solely to the software portion of its product, Licensee must refer to the
// software as "EnergyPlus version X" software, where "X" is the version number Licensee
// obtained under this License and may not use a different name for the software. Except as
// specifically required in this Section (4), Licensee shall not use in a company name, a
// product name, in advertising, publicity, or other promotional activities any name, trade
// name, trademark, logo, or other designation of "EnergyPlus", "E+", "e+" or confusingly
// similar designation, without the U.S. Department of Energy's prior written consent.
//
// 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.
#ifndef PoweredInductionUnits_hh_INCLUDED
#define PoweredInductionUnits_hh_INCLUDED
// ObjexxFCL Headers
#include <ObjexxFCL/Array1D.hh>
// EnergyPlus Headers
#include <DataGlobals.hh>
#include <EnergyPlus.hh>
namespace EnergyPlus {
namespace PoweredInductionUnits {
// Using/Aliasing
// Data
// MODULE PARAMETER DEFINITIONS
extern int const SingleDuct_SeriesPIU_Reheat;
extern int const SingleDuct_ParallelPIU_Reheat;
// coil types in this module
extern int const HCoilType_Gas;
extern int const HCoilType_Electric;
extern int const HCoilType_SimpleHeating;
extern int const HCoilType_SteamAirHeating;
// DERIVED TYPE DEFINITIONS
// MODULE VARIABLE DECLARATIONS:
extern Array1D_bool CheckEquipName;
extern int NumPIUs;
extern int NumSeriesPIUs;
extern int NumParallelPIUs;
// SUBROUTINE SPECIFICATIONS FOR MODULE
// PRIVATE UpdatePIU
// Types
struct PowIndUnitData
{
// Members
// input data
std::string Name; // name of unit
std::string UnitType; // type of unit
int UnitType_Num; // index for type of unit
std::string Sched; // availability schedule
int SchedPtr; // index to schedule
Real64 MaxTotAirVolFlow; // m3/s (series)
Real64 MaxTotAirMassFlow; // kg/s (series)
Real64 MaxPriAirVolFlow; // m3/s
Real64 MaxPriAirMassFlow; // kg/s
Real64 MinPriAirFlowFrac; // minimum primary air flow fraction
Real64 MinPriAirMassFlow; // kg/s
Real64 MaxSecAirVolFlow; // m3/s (parallel)
Real64 MaxSecAirMassFlow; // kg/s (parallel)
Real64 FanOnFlowFrac; // frac of primary air flow at which fan turns on (parallel)
Real64 FanOnAirMassFlow; // primary air mass flow rate at which fan turns on (parallel)
int PriAirInNode; // unit primary air inlet node number
int SecAirInNode; // unit secondary air inlet node number
int OutAirNode; // unit air outlet node number
int HCoilInAirNode; // unit mixed air node number
int ControlCompTypeNum;
int CompErrIndex;
std::string MixerName; // name of air mixer component
int Mixer_Num; // index for type of mixer
std::string FanName; // name of fan component
int Fan_Num; // index for fan type
int Fan_Index; // store index for this fan
int FanAvailSchedPtr; // index to fan availability schedule
std::string HCoilType; // type of heating coil component
int HCoilType_Num; // index for heating coil type
int HCoil_PlantTypeNum;
std::string HCoil; // name of heating coil component
int HCoil_Index; // index to this heating coil
int HCoil_FluidIndex;
Real64 MaxVolHotWaterFlow; // m3/s
Real64 MaxVolHotSteamFlow; // m3/s
Real64 MaxHotWaterFlow; // kg/s
Real64 MaxHotSteamFlow; // kg/s
Real64 MinVolHotWaterFlow; // m3/s
Real64 MinHotSteamFlow; // kg/s
Real64 MinVolHotSteamFlow; // m3/s
Real64 MinHotWaterFlow; // kg/s
int HotControlNode; // hot water control node
int HotCoilOutNodeNum; // outlet of coil
Real64 HotControlOffset; // control tolerance
int HWLoopNum; // index for plant loop with hot plant coil
int HWLoopSide; // index for plant loop side for hot plant coil
int HWBranchNum; // index for plant branch for hot plant coil
int HWCompNum; // index for plant component for hot plant coil
int ADUNum; // index of corresponding air distribution unit
bool InducesPlenumAir; // True if secondary air comes from the plenum
// Report data
Real64 HeatingRate; // unit heat addition rate to zone [W]
Real64 HeatingEnergy; // unit heat addition to zone [J]
Real64 SensCoolRate; // unit sensible heat removal rate from zone [W]
Real64 SensCoolEnergy; // unit sensible heat removal from zone [J]
int CtrlZoneNum; // index to control zone
int ctrlZoneInNodeIndex; // index to the control zone inlet node
int AirLoopNum; // index for the air loop that this terminal is connected to.
// Default Constructor
PowIndUnitData()
: UnitType_Num(0), SchedPtr(0), MaxTotAirVolFlow(0.0), MaxTotAirMassFlow(0.0), MaxPriAirVolFlow(0.0), MaxPriAirMassFlow(0.0),
MinPriAirFlowFrac(0.0), MinPriAirMassFlow(0.0), MaxSecAirVolFlow(0.0), MaxSecAirMassFlow(0.0), FanOnFlowFrac(0.0),
FanOnAirMassFlow(0.0), PriAirInNode(0), SecAirInNode(0), OutAirNode(0), HCoilInAirNode(0), ControlCompTypeNum(0), CompErrIndex(0),
Mixer_Num(0), Fan_Num(0), Fan_Index(0), FanAvailSchedPtr(0), HCoilType_Num(0), HCoil_PlantTypeNum(0), HCoil_Index(0),
HCoil_FluidIndex(0), MaxVolHotWaterFlow(0.0), MaxVolHotSteamFlow(0.0), MaxHotWaterFlow(0.0), MaxHotSteamFlow(0.0),
MinVolHotWaterFlow(0.0), MinHotSteamFlow(0.0), MinVolHotSteamFlow(0.0), MinHotWaterFlow(0.0), HotControlNode(0), HotCoilOutNodeNum(0),
HotControlOffset(0.0), HWLoopNum(0), HWLoopSide(0), HWBranchNum(0), HWCompNum(0), ADUNum(0), InducesPlenumAir(false), HeatingRate(0.0),
HeatingEnergy(0.0), SensCoolRate(0.0), SensCoolEnergy(0.0), CtrlZoneNum(0), AirLoopNum(0)
{
}
};
// Object Data
extern Array1D<PowIndUnitData> PIU;
// Functions
void clear_state();
void SimPIU(std::string const &CompName, // name of the PIU
bool const FirstHVACIteration, // TRUE if first HVAC iteration in time step
int const ZoneNum, // index of zone served by PIU
int const ZoneNodeNum, // zone node number of zone served by PIU
int &CompIndex // PIU Index in PIU names
);
void GetPIUs();
void InitPIU(int const PIUNum, // number of the current fan coil unit being simulated
bool const FirstHVACIteration // TRUE if first zone equip this HVAC step
);
void SizePIU(int const PIUNum);
void CalcSeriesPIU(int const PIUNum, // number of the current PIU being simulated
int const ZoneNum, // number of zone being served
int const ZoneNode, // zone node number
bool const FirstHVACIteration // TRUE if 1st HVAC simulation of system timestep
);
void CalcParallelPIU(int const PIUNum, // number of the current PIU being simulated
int const ZoneNum, // number of zone being served
int const ZoneNode, // zone node number
bool const FirstHVACIteration // TRUE if 1st HVAC simulation of system timestep
);
void ReportPIU(int const PIUNum); // number of the current fan coil unit being simulated
// ===================== Utilities =====================================
bool PIUnitHasMixer(std::string const &CompName); // component (mixer) name
void PIUInducesPlenumAir(int const NodeNum); // induced air node number
} // namespace PoweredInductionUnits
} // namespace EnergyPlus
#endif
| 50.948357
| 149
| 0.670015
|
yurigabrich
|
73751a821a3b85f14535d9c5723cb31f2a0d422a
| 9,260
|
cpp
|
C++
|
src/foundation/third_party/agg/examples/gouraud.cpp
|
airgiser/gona
|
4b81cbf8daacfca46a6bdec56935318a06f7e804
|
[
"MIT"
] | 31
|
2017-06-28T09:50:03.000Z
|
2021-08-11T14:09:35.000Z
|
src/foundation/third_party/agg/examples/gouraud.cpp
|
airgiser/gona
|
4b81cbf8daacfca46a6bdec56935318a06f7e804
|
[
"MIT"
] | null | null | null |
src/foundation/third_party/agg/examples/gouraud.cpp
|
airgiser/gona
|
4b81cbf8daacfca46a6bdec56935318a06f7e804
|
[
"MIT"
] | 5
|
2017-06-29T13:43:23.000Z
|
2020-09-01T02:47:11.000Z
|
#include <stdio.h>
#include "agg_basics.h"
#include "agg_rendering_buffer.h"
#include "agg_rasterizer_scanline_aa.h"
#include "agg_scanline_u.h"
#include "agg_scanline_p.h"
#include "agg_renderer_scanline.h"
#include "agg_span_allocator.h"
#include "agg_span_gouraud_rgba.h"
#include "agg_span_gouraud_gray.h"
#include "agg_span_solid.h"
#include "platform/agg_platform_support.h"
#include "ctrl/agg_slider_ctrl.h"
//#define AGG_GRAY8
#define AGG_BGR24
//#define AGG_RGB24
//#define AGG_BGRA32
//#define AGG_RGBA32
//#define AGG_ARGB32
//#define AGG_ABGR32
//#define AGG_RGB565
//#define AGG_RGB555
#include "pixel_formats.h"
enum flip_y_e { flip_y = true };
#include "agg_math.h"
#include "agg_dda_line.h"
class the_application : public agg::platform_support
{
double m_x[3];
double m_y[3];
double m_dx;
double m_dy;
int m_idx;
agg::slider_ctrl<agg::rgba> m_dilation;
agg::slider_ctrl<agg::rgba> m_gamma;
agg::slider_ctrl<agg::rgba> m_alpha;
public:
the_application(agg::pix_format_e format, bool flip_y) :
agg::platform_support(format, flip_y),
m_idx(-1),
m_dilation(5, 5, 400-5, 11, !flip_y),
m_gamma (5, 5+15, 400-5, 11+15, !flip_y),
m_alpha (5, 5+30, 400-5, 11+30, !flip_y)
{
m_x[0] = 57; m_y[0] = 60;
m_x[1] = 369; m_y[1] = 170;
m_x[2] = 143; m_y[2] = 310;
add_ctrl(m_dilation);
add_ctrl(m_gamma);
add_ctrl(m_alpha);
m_dilation.label("Dilation=%3.2f");
m_gamma.label("Linear gamma=%3.2f");
m_alpha.label("Opacity=%3.2f");
m_dilation.value(0.175);
m_gamma.value(0.809);
m_alpha.value(1.0);
}
template<class Scanline, class Ras>
void render_gouraud(Scanline& sl, Ras& ras)
{
double alpha = m_alpha.value();
double brc = 1;
typedef agg::renderer_base<pixfmt> base_ren_type;
#ifdef AGG_GRAY8
typedef agg::span_gouraud_gray<color_type> span_gen_type;
#else
typedef agg::span_gouraud_rgba<color_type> span_gen_type;
#endif
typedef agg::span_allocator<color_type> span_alloc_type;
pixfmt pf(rbuf_window());
base_ren_type ren_base(pf);
span_alloc_type span_alloc;
span_gen_type span_gen;
ras.gamma(agg::gamma_linear(0.0, m_gamma.value()));
double d = m_dilation.value();
// Single triangle
//span_gen.colors(agg::rgba(1, 0, 0, alpha),
// agg::rgba(0, 1, 0, alpha),
// agg::rgba(0, 0, 1, alpha));
//span_gen.triangle(m_x[0], m_y[0], m_x[1], m_y[1], m_x[2], m_y[2], d);
//ras.add_path(span_gen);
//agg::render_scanlines_aa(ras, sl, ren_base, span_alloc, span_gen);
// Six triangles
double xc = (m_x[0] + m_x[1] + m_x[2]) / 3.0;
double yc = (m_y[0] + m_y[1] + m_y[2]) / 3.0;
double x1 = (m_x[1] + m_x[0]) / 2 - (xc - (m_x[1] + m_x[0]) / 2);
double y1 = (m_y[1] + m_y[0]) / 2 - (yc - (m_y[1] + m_y[0]) / 2);
double x2 = (m_x[2] + m_x[1]) / 2 - (xc - (m_x[2] + m_x[1]) / 2);
double y2 = (m_y[2] + m_y[1]) / 2 - (yc - (m_y[2] + m_y[1]) / 2);
double x3 = (m_x[0] + m_x[2]) / 2 - (xc - (m_x[0] + m_x[2]) / 2);
double y3 = (m_y[0] + m_y[2]) / 2 - (yc - (m_y[0] + m_y[2]) / 2);
span_gen.colors(agg::rgba(1, 0, 0, alpha),
agg::rgba(0, 1, 0, alpha),
agg::rgba(brc, brc, brc, alpha));
span_gen.triangle(m_x[0], m_y[0], m_x[1], m_y[1], xc, yc, d);
ras.add_path(span_gen);
agg::render_scanlines_aa(ras, sl, ren_base, span_alloc, span_gen);
span_gen.colors(agg::rgba(0, 1, 0, alpha),
agg::rgba(0, 0, 1, alpha),
agg::rgba(brc, brc, brc, alpha));
span_gen.triangle(m_x[1], m_y[1], m_x[2], m_y[2], xc, yc, d);
ras.add_path(span_gen);
agg::render_scanlines_aa(ras, sl, ren_base, span_alloc, span_gen);
span_gen.colors(agg::rgba(0, 0, 1, alpha),
agg::rgba(1, 0, 0, alpha),
agg::rgba(brc, brc, brc, alpha));
span_gen.triangle(m_x[2], m_y[2], m_x[0], m_y[0], xc, yc, d);
ras.add_path(span_gen);
agg::render_scanlines_aa(ras, sl, ren_base, span_alloc, span_gen);
brc = 1-brc;
span_gen.colors(agg::rgba(1, 0, 0, alpha),
agg::rgba(0, 1, 0, alpha),
agg::rgba(brc, brc, brc, alpha));
span_gen.triangle(m_x[0], m_y[0], m_x[1], m_y[1], x1, y1, d);
ras.add_path(span_gen);
agg::render_scanlines_aa(ras, sl, ren_base, span_alloc, span_gen);
span_gen.colors(agg::rgba(0, 1, 0, alpha),
agg::rgba(0, 0, 1, alpha),
agg::rgba(brc, brc, brc, alpha));
span_gen.triangle(m_x[1], m_y[1], m_x[2], m_y[2], x2, y2, d);
ras.add_path(span_gen);
agg::render_scanlines_aa(ras, sl, ren_base, span_alloc, span_gen);
span_gen.colors(agg::rgba(0, 0, 1, alpha),
agg::rgba(1, 0, 0, alpha),
agg::rgba(brc, brc, brc, alpha));
span_gen.triangle(m_x[2], m_y[2], m_x[0], m_y[0], x3, y3, d);
ras.add_path(span_gen);
agg::render_scanlines_aa(ras, sl, ren_base, span_alloc, span_gen);
}
virtual void on_draw()
{
typedef agg::renderer_base<pixfmt> base_ren_type;
pixfmt pf(rbuf_window());
base_ren_type ren_base(pf);
ren_base.clear(agg::rgba(1,1,1));
agg::scanline_u8 sl;
agg::rasterizer_scanline_aa<> ras;
render_gouraud(sl, ras);
ras.gamma(agg::gamma_none());
agg::render_ctrl(ras, sl, ren_base, m_dilation);
agg::render_ctrl(ras, sl, ren_base, m_gamma);
agg::render_ctrl(ras, sl, ren_base, m_alpha);
}
virtual void on_mouse_button_down(int x, int y, unsigned flags)
{
unsigned i;
if(flags & agg::mouse_right)
{
agg::scanline_u8 sl;
agg::rasterizer_scanline_aa<> ras;
start_timer();
for(i = 0; i < 100; i++)
{
render_gouraud(sl, ras);
}
char buf[100];
sprintf(buf, "Time=%2.2f ms", elapsed_time());
message(buf);
}
if(flags & agg::mouse_left)
{
for (i = 0; i < 3; i++)
{
if(sqrt( (x-m_x[i]) * (x-m_x[i]) + (y-m_y[i]) * (y-m_y[i]) ) < 10.0)
{
m_dx = x - m_x[i];
m_dy = y - m_y[i];
m_idx = i;
break;
}
}
if(i == 3)
{
if(agg::point_in_triangle(m_x[0], m_y[0],
m_x[1], m_y[1],
m_x[2], m_y[2],
x, y))
{
m_dx = x - m_x[0];
m_dy = y - m_y[0];
m_idx = 3;
}
}
}
}
virtual void on_mouse_move(int x, int y, unsigned flags)
{
if(flags & agg::mouse_left)
{
if(m_idx == 3)
{
double dx = x - m_dx;
double dy = y - m_dy;
m_x[1] -= m_x[0] - dx;
m_y[1] -= m_y[0] - dy;
m_x[2] -= m_x[0] - dx;
m_y[2] -= m_y[0] - dy;
m_x[0] = dx;
m_y[0] = dy;
force_redraw();
return;
}
if(m_idx >= 0)
{
m_x[m_idx] = x - m_dx;
m_y[m_idx] = y - m_dy;
force_redraw();
}
}
else
{
on_mouse_button_up(x, y, flags);
}
}
virtual void on_mouse_button_up(int x, int y, unsigned flags)
{
m_idx = -1;
}
virtual void on_key(int x, int y, unsigned key, unsigned flags)
{
double dx = 0;
double dy = 0;
switch(key)
{
case agg::key_left: dx = -0.1; break;
case agg::key_right: dx = 0.1; break;
case agg::key_up: dy = 0.1; break;
case agg::key_down: dy = -0.1; break;
}
m_x[0] += dx;
m_y[0] += dy;
m_x[1] += dx;
m_y[1] += dy;
force_redraw();
}
};
int agg_main(int argc, char* argv[])
{
the_application app(pix_format, flip_y);
app.caption("AGG Example. Gouraud Shading");
if(app.init(400, 320, agg::window_resize))
{
return app.run();
}
return 1;
}
| 29.396825
| 85
| 0.47203
|
airgiser
|
737916aa21b542adcc8c48d41953b70d67589cfb
| 499
|
cpp
|
C++
|
test/doc/all_of.cpp
|
jfalcou/kumi
|
09116696274bd38254d89636ea3d0d4b5eb43103
|
[
"MIT"
] | 14
|
2021-11-20T15:21:08.000Z
|
2022-03-14T21:47:22.000Z
|
test/doc/all_of.cpp
|
jfalcou/kumi
|
09116696274bd38254d89636ea3d0d4b5eb43103
|
[
"MIT"
] | 6
|
2021-11-27T17:50:48.000Z
|
2022-02-01T18:17:38.000Z
|
test/doc/all_of.cpp
|
jfalcou/kumi
|
09116696274bd38254d89636ea3d0d4b5eb43103
|
[
"MIT"
] | 1
|
2022-02-21T23:06:03.000Z
|
2022-02-21T23:06:03.000Z
|
//==================================================================================================
/*
KUMI - Compact Tuple Tools
Copyright : KUMI Contributors & Maintainers
SPDX-License-Identifier: MIT
*/
//==================================================================================================
#include <kumi/tuple.hpp>
#include <iostream>
int main()
{
auto t = kumi::tuple{1,2.,3.f};
std::cout << std::boolalpha << kumi::all_of( t, [](auto e) { return e < 5; }) << "\n";
}
| 31.1875
| 100
| 0.368737
|
jfalcou
|
737bc5fdb150874db26ef66845c907de6bca77f2
| 14,426
|
cpp
|
C++
|
inference-engine/src/mkldnn_plugin/nodes/priorbox.cpp
|
fujunwei/dldt
|
09497b7724de4be92629f7799b8538b483d809a2
|
[
"Apache-2.0"
] | 1
|
2021-07-30T17:03:50.000Z
|
2021-07-30T17:03:50.000Z
|
inference-engine/src/mkldnn_plugin/nodes/priorbox.cpp
|
fujunwei/dldt
|
09497b7724de4be92629f7799b8538b483d809a2
|
[
"Apache-2.0"
] | null | null | null |
inference-engine/src/mkldnn_plugin/nodes/priorbox.cpp
|
fujunwei/dldt
|
09497b7724de4be92629f7799b8538b483d809a2
|
[
"Apache-2.0"
] | null | null | null |
// Copyright (C) 2018-2020 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//
#include "list.hpp"
#include "base.hpp"
#include <vector>
#include <string>
#include <cmath>
#include <limits>
#include "ie_parallel.hpp"
namespace InferenceEngine {
namespace Extensions {
namespace Cpu {
class PriorBoxImpl: public ExtLayerBase {
static inline float clip_great(float x, float threshold) {
return x < threshold ? x : threshold;
}
static inline float clip_less(float x, float threshold) {
return x > threshold ? x : threshold;
}
public:
explicit PriorBoxImpl(const CNNLayer *layer) {
try {
if (layer->insData.size() != 2 || layer->outData.empty())
THROW_IE_EXCEPTION << "Incorrect number of input/output edges!";
if (layer->insData[0].lock()->getTensorDesc().getDims().size() != 4 ||
layer->insData[1].lock()->getTensorDesc().getDims().size() != 4)
THROW_IE_EXCEPTION << "PriorBox supports only 4D blobs!";
_offset = layer->GetParamAsFloat("offset");
_step = layer->GetParamAsFloat("step", 0);
_min_sizes = layer->GetParamAsFloats("min_size", {});
_max_sizes = layer->GetParamAsFloats("max_size", {});
_flip = layer->GetParamAsBool("flip", false);
_clip = layer->GetParamAsBool("clip", false);
_scale_all_sizes = layer->GetParamAsBool("scale_all_sizes", true);
_fixed_sizes = layer->GetParamAsFloats("fixed_size", {});
_fixed_ratios = layer->GetParamAsFloats("fixed_ratio", {});
_densitys = layer->GetParamAsFloats("density", {});
bool exist;
_aspect_ratios.push_back(1.0f);
const std::vector<float> aspect_ratios = layer->GetParamAsFloats("aspect_ratio", {});
for (float aspect_ratio : aspect_ratios) {
exist = false;
if (std::fabs(aspect_ratio) < std::numeric_limits<float>::epsilon()) {
THROW_IE_EXCEPTION << "aspect_ratio param can't be equal to zero";
}
for (float _aspect_ratio : _aspect_ratios) {
if (fabs(aspect_ratio - _aspect_ratio) < 1e-6) {
exist = true;
break;
}
}
if (exist) {
continue;
}
_aspect_ratios.push_back(aspect_ratio);
if (_flip) {
_aspect_ratios.push_back(1.0f / aspect_ratio);
}
}
if (_scale_all_sizes) {
_num_priors = static_cast<int>(_aspect_ratios.size() * _min_sizes.size());
} else {
_num_priors = static_cast<int>(_aspect_ratios.size() + _min_sizes.size() - 1);
}
if (_fixed_sizes.size() > 0) {
_num_priors = static_cast<int>(_aspect_ratios.size() * _fixed_sizes.size());
}
if (_densitys.size() > 0) {
for (size_t i = 0; i < _densitys.size(); ++i) {
if (_fixed_ratios.size() > 0) {
_num_priors += (_fixed_ratios.size()) * (static_cast<size_t>(pow(_densitys[i], 2)) - 1);
} else {
_num_priors += (_aspect_ratios.size()) * (static_cast<size_t>(pow(_densitys[i], 2)) - 1);
}
}
}
for (auto it = _max_sizes.begin(); it != _max_sizes.end(); it++) {
_num_priors += 1;
}
const std::vector<float> variance = layer->GetParamAsFloats("variance", {});
if (variance.size() == 1 || variance.size() == 4) {
for (float i : variance) {
if (i < 0) {
THROW_IE_EXCEPTION << "Variance must be > 0.";
}
_variance.push_back(i);
}
} else if (variance.empty()) {
_variance.push_back(0.1f);
} else {
THROW_IE_EXCEPTION << "Wrong number of variance values. Not less than 1 and more than 4 variance values.";
}
addConfig(layer, {{ConfLayout::ANY, true}, {ConfLayout::ANY, true}}, {{ConfLayout::PLN, true}});
} catch (InferenceEngine::details::InferenceEngineException &ex) {
errorMsg = ex.what();
}
}
StatusCode init(LayerConfig& config, ResponseDesc *resp) noexcept override {
return OK;
}
StatusCode execute(std::vector<Blob::Ptr>& inputs, std::vector<Blob::Ptr>& outputs,
ResponseDesc *resp) noexcept override {
if (inputs.size() != 2 || outputs.empty()) {
if (resp) {
std::string errorMsg = "Incorrect number of input or output edges!";
errorMsg.copy(resp->msg, sizeof(resp->msg) - 1);
}
return GENERAL_ERROR;
}
auto& dataMemPtr = inputs[0];
auto& imageMemPtr = inputs[1];
auto& dstMemPtr = outputs[0];
SizeVector _data_dims = dataMemPtr->getTensorDesc().getDims();
SizeVector _image_dims = imageMemPtr->getTensorDesc().getDims();
const int W = _data_dims[3];
const int H = _data_dims[2];
const int IW = _image_dims[3];
const int IH = _image_dims[2];
const int OH = dstMemPtr->getTensorDesc().getDims()[2];
const int OW = (dstMemPtr->getTensorDesc().getDims().size() == 3) ? 1 : dstMemPtr->getTensorDesc().getDims()[3];
float step_x = 0.0f;
float step_y = 0.0f;
if (_step == 0) {
step_x = static_cast<float>(IW) / W;
step_y = static_cast<float>(IH) / H;
} else {
step_x = _step;
step_y = _step;
}
float IWI = 1.0f / static_cast<float>(IW);
float IHI = 1.0f / static_cast<float>(IH);
float* dst_data = dstMemPtr->buffer();
int idx = 0;
float center_x = 0.0f;
float center_y = 0.0f;
float box_width;
float box_height;
for (int h = 0; h < H; ++h) {
for (int w = 0; w < W; ++w) {
if (_step == 0) {
center_x = (w + 0.5f) * step_x;
center_y = (h + 0.5f) * step_y;
} else {
center_x = (_offset + w) * _step;
center_y = (_offset + h) * _step;
}
for (size_t s = 0; s < _fixed_sizes.size(); ++s) {
size_t fixed_size_ = static_cast<size_t>(_fixed_sizes[s]);
box_width = box_height = fixed_size_ * 0.5f;
if (_fixed_ratios.size() > 0) {
for (float ar : _fixed_ratios) {
size_t density_ = static_cast<size_t>(_densitys[s]);
int shift = static_cast<int>(_fixed_sizes[s] / density_);
ar = sqrt(ar);
float box_width_ratio = _fixed_sizes[s] * 0.5f * ar;
float box_height_ratio = _fixed_sizes[s] * 0.5f / ar;
for (size_t r = 0; r < density_; ++r) {
for (size_t c = 0; c < density_; ++c) {
float center_x_temp = center_x - fixed_size_ / 2 + shift / 2.f + c * shift;
float center_y_temp = center_y - fixed_size_ / 2 + shift / 2.f + r * shift;
// xmin
dst_data[idx++] = clip_less((center_x_temp - box_width_ratio) * IWI, 0);
// ymin
dst_data[idx++] = clip_less((center_y_temp - box_height_ratio) * IHI, 0);
// xmax
dst_data[idx++] = clip_great((center_x_temp + box_width_ratio) * IWI, 1);
// ymax
dst_data[idx++] = clip_great((center_y_temp + box_height_ratio) * IHI, 1);
}
}
}
} else {
if (_densitys.size() > 0) {
int density_ = static_cast<int>(_densitys[s]);
int shift = static_cast<int>(_fixed_sizes[s] / density_);
for (int r = 0; r < density_; ++r) {
for (int c = 0; c < density_; ++c) {
float center_x_temp = center_x - fixed_size_ / 2 + shift / 2.f + c * shift;
float center_y_temp = center_y - fixed_size_ / 2 + shift / 2.f + r * shift;
// xmin
dst_data[idx++] = clip_less((center_x_temp - box_width) * IWI, 0);
// ymin
dst_data[idx++] = clip_less((center_y_temp - box_height) * IHI, 0);
// xmax
dst_data[idx++] = clip_great((center_x_temp + box_width) * IWI, 1);
// ymax
dst_data[idx++] = clip_great((center_y_temp + box_height) * IHI, 1);
}
}
}
// Rest of priors
for (float ar : _aspect_ratios) {
if (fabs(ar - 1.) < 1e-6) {
continue;
}
int density_ = static_cast<int>(_densitys[s]);
int shift = static_cast<int>(_fixed_sizes[s] / density_);
ar = sqrt(ar);
float box_width_ratio = _fixed_sizes[s] * 0.5f * ar;
float box_height_ratio = _fixed_sizes[s] * 0.5f / ar;
for (int r = 0; r < density_; ++r) {
for (int c = 0; c < density_; ++c) {
float center_x_temp = center_x - fixed_size_ / 2 + shift / 2.f + c * shift;
float center_y_temp = center_y - fixed_size_ / 2 + shift / 2.f + r * shift;
// xmin
dst_data[idx++] = clip_less((center_x_temp - box_width_ratio) * IWI, 0);
// ymin
dst_data[idx++] = clip_less((center_y_temp - box_height_ratio) * IHI, 0);
// xmax
dst_data[idx++] = clip_great((center_x_temp + box_width_ratio) * IWI, 1);
// ymax
dst_data[idx++] = clip_great((center_y_temp + box_height_ratio) * IHI, 1);
}
}
}
}
}
for (size_t msIdx = 0; msIdx < _min_sizes.size(); msIdx++) {
box_width = _min_sizes[msIdx] * 0.5f;
box_height = _min_sizes[msIdx] * 0.5f;
dst_data[idx++] = (center_x - box_width) * IWI;
dst_data[idx++] = (center_y - box_height) * IHI;
dst_data[idx++] = (center_x + box_width) * IWI;
dst_data[idx++] = (center_y + box_height) * IHI;
if (_max_sizes.size() > msIdx) {
box_width = box_height = sqrt(_min_sizes[msIdx] * _max_sizes[msIdx]) * 0.5f;
dst_data[idx++] = (center_x - box_width) * IWI;
dst_data[idx++] = (center_y - box_height) * IHI;
dst_data[idx++] = (center_x + box_width) * IWI;
dst_data[idx++] = (center_y + box_height) * IHI;
}
if (_scale_all_sizes || (!_scale_all_sizes && (msIdx == _min_sizes.size() - 1))) {
size_t sIdx = _scale_all_sizes ? msIdx : 0;
for (float ar : _aspect_ratios) {
if (fabs(ar - 1.0f) < 1e-6) {
continue;
}
ar = sqrt(ar);
box_width = _min_sizes[sIdx] * 0.5f * ar;
box_height = _min_sizes[sIdx] * 0.5f / ar;
dst_data[idx++] = (center_x - box_width) * IWI;
dst_data[idx++] = (center_y - box_height) * IHI;
dst_data[idx++] = (center_x + box_width) * IWI;
dst_data[idx++] = (center_y + box_height) * IHI;
}
}
}
}
}
if (_clip) {
parallel_for((H * W * _num_priors * 4), [&](size_t i) {
dst_data[i] = (std::min)((std::max)(dst_data[i], 0.0f), 1.0f);
});
}
size_t channel_size = OH * OW;
dst_data += channel_size;
if (_variance.size() == 1) {
parallel_for(channel_size, [&](size_t i) {
dst_data[i] = _variance[0];
});
} else {
parallel_for((H * W * _num_priors), [&](size_t i) {
for (size_t j = 0; j < 4; ++j) {
dst_data[i * 4 + j] = _variance[j];
}
});
}
return OK;
}
private:
float _offset = 0;
float _step = 0;
std::vector<float> _min_sizes;
std::vector<float> _max_sizes;
bool _flip = false;
bool _clip = false;
bool _scale_all_sizes = true;
std::vector<float> _fixed_sizes;
std::vector<float> _fixed_ratios;
std::vector<float> _densitys;
std::vector<float> _aspect_ratios;
std::vector<float> _variance;
int _num_priors = 0;
};
REG_FACTORY_FOR(ImplFactory<PriorBoxImpl>, PriorBox);
} // namespace Cpu
} // namespace Extensions
} // namespace InferenceEngine
| 41.693642
| 122
| 0.449674
|
fujunwei
|
737be9cd1d1475cf0bcf3826189369c0bf03ac8f
| 2,091
|
cpp
|
C++
|
Sample/Sample/CustomFilter.cpp
|
timtianyang/PCL_region_growing
|
b138d257ca836bdd4d960014944d4991bfa12e79
|
[
"MIT"
] | null | null | null |
Sample/Sample/CustomFilter.cpp
|
timtianyang/PCL_region_growing
|
b138d257ca836bdd4d960014944d4991bfa12e79
|
[
"MIT"
] | null | null | null |
Sample/Sample/CustomFilter.cpp
|
timtianyang/PCL_region_growing
|
b138d257ca836bdd4d960014944d4991bfa12e79
|
[
"MIT"
] | null | null | null |
#include "stdafx.h"
#include "CustomFilter.h"
/*
CustomFilter::CustomFilter(pcl::PointCloud<pcl::PointXYZRGB>::Ptr *input, double xmin, double xmax, double ymin, double ymax){
input_cloud_XYZRGB = input;
std::cout << xmin << xmax << ymin << ymax <<std::endl;
std::cout << "before filtering " << (*input)->points.size() << std::endl;
filtered_cloud_XYZRGB = pcl::PointCloud<pcl::PointXYZRGB>::Ptr(new pcl::PointCloud<pcl::PointXYZRGB>);
pcl::PointCloud<pcl::PointXYZRGB>::Ptr temp_cloud_XYZRGB(new pcl::PointCloud<pcl::PointXYZRGB>);
pcl::PassThrough<pcl::PointXYZRGB> pass;
pass.setInputCloud((*input_cloud_XYZRGB));//x direction
pass.setFilterFieldName("x");
pass.setFilterLimits(xmin, xmax);
pass.filter(*temp_cloud_XYZRGB);
pass.setInputCloud(temp_cloud_XYZRGB);//y direction
pass.setFilterFieldName("y");
pass.setFilterLimits(ymin, ymax);
pass.filter(*filtered_cloud_XYZRGB);
std::cout << "after filtering " << filtered_cloud_XYZRGB->points.size();
}
CustomFilter::CustomFilter(pcl::PointCloud<pcl::PointXYZI>::Ptr *input, double xmin, double xmax, double ymin, double ymax){
input_cloud_XYZI = input;
std::cout << xmin << xmax << ymin << ymax << std::endl;
std::cout << "before filtering " << (*input)->points.size() << std::endl;
filtered_cloud_XYZI = pcl::PointCloud<pcl::PointXYZI>::Ptr(new pcl::PointCloud<pcl::PointXYZI>);
pcl::PointCloud<pcl::PointXYZI>::Ptr temp_cloud_XYZI(new pcl::PointCloud<pcl::PointXYZI>);
pcl::PassThrough<pcl::PointXYZI> pass;
pass.setInputCloud((*input_cloud_XYZI));//x direction
pass.setFilterFieldName("x");
pass.setFilterLimits(xmin, xmax);
pass.filter(*temp_cloud_XYZI);
pass.setInputCloud(temp_cloud_XYZI);//y direction
pass.setFilterFieldName("y");
pass.setFilterLimits(ymin, ymax);
pass.filter(*filtered_cloud_XYZI);
std::cout << "after filtering " << filtered_cloud_XYZI->points.size();
}
*/
/*
pcl::PointCloud<pcl::PointXYZI>::Ptr *CustomFilter::getOutputXYZI(){
return &filtered_cloud_XYZI;
}
pcl::PointCloud<pcl::PointXYZRGB>::Ptr *CustomFilter::getOutputXYZRGB(){
return &filtered_cloud_XYZRGB;
}*/
| 37.339286
| 126
| 0.735533
|
timtianyang
|
737dfe0c0182de10ed7688dffdc44ba3035911cf
| 595
|
cc
|
C++
|
src/broker/broker_main.cc
|
iot-dsa-v2/sdk-dslink-cpp
|
d7734fba02237bd11bc887058f4d9573aac598d8
|
[
"Apache-2.0"
] | 1
|
2018-02-09T21:20:31.000Z
|
2018-02-09T21:20:31.000Z
|
src/broker/broker_main.cc
|
iot-dsa-v2/sdk-dslink-cpp
|
d7734fba02237bd11bc887058f4d9573aac598d8
|
[
"Apache-2.0"
] | 7
|
2017-11-20T22:22:12.000Z
|
2018-03-21T13:00:06.000Z
|
src/broker/broker_main.cc
|
iot-dsa-v2/sdk-dslink-cpp
|
d7734fba02237bd11bc887058f4d9573aac598d8
|
[
"Apache-2.0"
] | null | null | null |
#include "dsa_common.h"
#include "broker.h"
#include "module/default/simple_security.h"
#include "module/default/simple_session_manager.h"
#include "config/broker_config.h"
#include "module/default/console_logger.h"
#include "module/client/broker_client_manager.h"
#include "module/authorizer/broker_authorizer.h"
#include "module/module_broker_default.h"
using namespace dsa;
int main(int argc, const char* argv[]) {
ref_<BrokerConfig> broker_config = make_ref_<BrokerConfig>(argc, argv);
auto broker = make_ref_<DsBroker>(std::move(broker_config));
broker->run();
return 0;
}
| 22.884615
| 73
| 0.764706
|
iot-dsa-v2
|
737f32c7f1f444d613d4345d25985acd5d111aff
| 1,277
|
cpp
|
C++
|
Driver/src/AlephManager.cpp
|
gganis/AlphappLite
|
e52a184c2d39a3acdd6ff09d1d61bcfca7807460
|
[
"Apache-2.0"
] | null | null | null |
Driver/src/AlephManager.cpp
|
gganis/AlphappLite
|
e52a184c2d39a3acdd6ff09d1d61bcfca7807460
|
[
"Apache-2.0"
] | null | null | null |
Driver/src/AlephManager.cpp
|
gganis/AlphappLite
|
e52a184c2d39a3acdd6ff09d1d61bcfca7807460
|
[
"Apache-2.0"
] | null | null | null |
//////////////////////////////////////////////////////
//
// Implementation of class AlephManager
//
// The Base Class for an AlephManager (IO, DB, EXE,...)
//
// Author : G. Dissertori , 02.11.98
//
//////////////////////////////////////////////////////
#include <string>
#include <iostream>
#include <fstream>
#include "AlephManager.h"
extern ofstream fout;
//
// the "constructor" sets the managerType and initializes other
// private members
//
void AlephManager::AlephManagerSetup(const string& aManagerType)
{
// store the manager type
_thisManagerType.assign(aManagerType);
// set the pointer to the session
_theSession = AlephSession::TheAlephSession();
// set the status
_theStatus = CREATED;
}
//
// the "destructor" frees the heap
//
void AlephManager::AlephManagerShutDown()
{
_theStatus = DELETED;
}
//
// get the pointer to the session
//
AlephSession* AlephManager::alephSession() const
{
return _theSession;
}
//
// get the managerType
//
string AlephManager::managerType() const
{
return _thisManagerType;
}
//
// set the status
//
void AlephManager::setStatus(const AlephStatus& statusNow)
{
_theStatus = statusNow;
}
//
// get the status
//
AlephStatus AlephManager::status() const
{
return _theStatus;
}
| 14.678161
| 64
| 0.638215
|
gganis
|
73827b17a72e04d33f721ea7b3992759cbb79cfe
| 1,850
|
cpp
|
C++
|
ios/versioned-react-native/ABI44_0_0/ReactNative/ReactCommon/react/renderer/components/text/tests/ABI44_0_0ParagraphLocalDataTest.cpp
|
zakharchenkoAndrii/expo
|
f6b009d204b9124d43df59b75eb6affc2f0ba5bd
|
[
"Apache-2.0",
"MIT"
] | 1
|
2022-01-18T23:59:15.000Z
|
2022-01-18T23:59:15.000Z
|
ios/versioned-react-native/ABI44_0_0/ReactNative/ReactCommon/react/renderer/components/text/tests/ABI44_0_0ParagraphLocalDataTest.cpp
|
zakharchenkoAndrii/expo
|
f6b009d204b9124d43df59b75eb6affc2f0ba5bd
|
[
"Apache-2.0",
"MIT"
] | 6
|
2020-08-06T12:31:23.000Z
|
2021-02-05T12:47:10.000Z
|
ios/versioned-react-native/ABI44_0_0/ReactNative/ReactCommon/react/renderer/components/text/tests/ABI44_0_0ParagraphLocalDataTest.cpp
|
zakharchenkoAndrii/expo
|
f6b009d204b9124d43df59b75eb6affc2f0ba5bd
|
[
"Apache-2.0",
"MIT"
] | 1
|
2020-05-27T08:06:46.000Z
|
2020-05-27T08:06:46.000Z
|
/*
* 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 <memory>
#include <assert.h>
#include <gtest/gtest.h>
#include <ABI44_0_0React/ABI44_0_0renderer/attributedstring/AttributedString.h>
#include <ABI44_0_0React/ABI44_0_0renderer/attributedstring/TextAttributes.h>
#include <ABI44_0_0React/ABI44_0_0renderer/attributedstring/primitives.h>
#include <ABI44_0_0React/ABI44_0_0renderer/components/text/ParagraphState.h>
#include <ABI44_0_0React/ABI44_0_0renderer/components/text/conversions.h>
namespace ABI44_0_0facebook {
namespace ABI44_0_0React {
#ifdef ANDROID
TEST(ParagraphLocalDataTest, testSomething) {
auto attributedString = AttributedString();
auto fragment = AttributedString::Fragment();
fragment.string = "test";
auto text = TextAttributes();
text.foregroundColor = {
colorFromComponents({100 / 255.0, 153 / 255.0, 253 / 255.0, 1.0})};
text.opacity = 0.5;
text.fontStyle = FontStyle::Italic;
text.fontWeight = FontWeight::Thin;
text.fontVariant = FontVariant::TabularNums;
fragment.textAttributes = text;
attString.prependFragment(fragment);
auto paragraphState = ParagraphState{};
paragraphLocalData.attributedString = attributedString;
auto result = toDynamic(paragraphState)["attributedString"];
assert(result["string"] == fragment.string);
auto textAttribute = result["fragments"][0]["textAttributes"];
assert(textAttribute["foregroundColor"] == toDynamic(text.foregroundColor));
assert(textAttribute["opacity"] == text.opacity);
assert(textAttribute["fontStyle"] == toString(*text.fontStyle));
assert(textAttribute["fontWeight"] == toString(*text.fontWeight));
}
#endif
} // namespace ABI44_0_0React
} // namespace ABI44_0_0facebook
| 33.636364
| 79
| 0.764865
|
zakharchenkoAndrii
|
7383b64784e5cd275669abc164dd5559126314d3
| 90
|
cpp
|
C++
|
src/examples/06_module/02_shapes/circle.cpp
|
acc-cosc-1337-fall-2020/acc-cosc-1337-fall-2020-boscojohn-ship
|
7b050c896252bd7c32972728e4a0792bdf1f0fa0
|
[
"MIT"
] | null | null | null |
src/examples/06_module/02_shapes/circle.cpp
|
acc-cosc-1337-fall-2020/acc-cosc-1337-fall-2020-boscojohn-ship
|
7b050c896252bd7c32972728e4a0792bdf1f0fa0
|
[
"MIT"
] | null | null | null |
src/examples/06_module/02_shapes/circle.cpp
|
acc-cosc-1337-fall-2020/acc-cosc-1337-fall-2020-boscojohn-ship
|
7b050c896252bd7c32972728e4a0792bdf1f0fa0
|
[
"MIT"
] | null | null | null |
//circle.cpp
#include "circle.h"
void Circle::draw()
{
std::cout<<"draw circle\n";
};
| 12.857143
| 31
| 0.611111
|
acc-cosc-1337-fall-2020
|
738444c763d99b815c36c54f5de9a0a9c327c89c
| 12,802
|
cc
|
C++
|
src/yb/master/sys_catalog_initialization.cc
|
eliahburns/yugabyte-db
|
570d28dde28d6a0e6a689274b5e319de9a81b707
|
[
"Apache-2.0",
"CC0-1.0"
] | null | null | null |
src/yb/master/sys_catalog_initialization.cc
|
eliahburns/yugabyte-db
|
570d28dde28d6a0e6a689274b5e319de9a81b707
|
[
"Apache-2.0",
"CC0-1.0"
] | null | null | null |
src/yb/master/sys_catalog_initialization.cc
|
eliahburns/yugabyte-db
|
570d28dde28d6a0e6a689274b5e319de9a81b707
|
[
"Apache-2.0",
"CC0-1.0"
] | null | null | null |
// Copyright (c) YugaByte, 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 "yb/master/sys_catalog_initialization.h"
#include "yb/util/countdown_latch.h"
#include "yb/util/pb_util.h"
#include "yb/util/env_util.h"
#include "yb/util/path_util.h"
#include "yb/util/flag_tags.h"
#include "yb/master/sys_catalog_constants.h"
#include "yb/master/catalog_entity_info.h"
#include "yb/master/sys_catalog.h"
#include "yb/tablet/tablet.h"
#include "yb/tablet/tablet_peer.h"
#include "yb/tablet/operations/operation.h"
#include "yb/tablet/operations/snapshot_operation.h"
#include "yb/tablet/operations/change_metadata_operation.h"
DEFINE_string(initial_sys_catalog_snapshot_path, "",
"If this is specified, system catalog RocksDB is checkpointed at this location after initdb "
"is done.");
DEFINE_bool(use_initial_sys_catalog_snapshot, false,
"DEPRECATED: use --enable_ysql instead. "
"Initialize sys catalog tablet from a pre-existing snapshot instead of running initdb. "
"Only takes effect if --initial_sys_catalog_snapshot_path is specified or can be "
"auto-detected.");
DEFINE_bool(enable_ysql, true,
"Enable YSQL on cluster. This will initialize sys catalog tablet from a pre-existing snapshot "
"and start YSQL proxy. "
"Only takes effect if --initial_sys_catalog_snapshot_path is specified or can be auto-detected."
);
DEFINE_bool(create_initial_sys_catalog_snapshot, false,
"Run initdb and create an initial sys catalog data snapshot");
DEFINE_bool(
// TODO: switch the default to true after updating all external callers (yb-ctl, YugaWare)
// and unit tests.
master_auto_run_initdb, false,
"Automatically run initdb on master leader initialization");
TAG_FLAG(create_initial_sys_catalog_snapshot, advanced);
TAG_FLAG(create_initial_sys_catalog_snapshot, hidden);
using yb::CountDownLatch;
using yb::tserver::TabletSnapshotOpRequestPB;
using yb::tserver::TabletSnapshotOpResponsePB;
using yb::tablet::SnapshotOperationState;
using yb::pb_util::ReadPBContainerFromPath;
namespace yb {
namespace master {
namespace {
const char* kDefaultInitialSysCatalogSnapshotDir = "initial_sys_catalog_snapshot";
const char* kSysCatalogSnapshotRocksDbSubDir = "rocksdb";
const char* kSysCatalogSnapshotTabletMetadataChangesFile =
"exported_tablet_metadata_changes";
const char* kUseInitialSysCatalogSnapshotEnvVar = "YB_USE_INITIAL_SYS_CATALOG_SNAPSHOT";
} // anonymous namespace
// ------------------------------------------------------------------------------------------------
// InitialSysCatalogSnapshotWriter
// ------------------------------------------------------------------------------------------------
void InitialSysCatalogSnapshotWriter::AddMetadataChange(
tserver::ChangeMetadataRequestPB metadata_change) {
initdb_metadata_changes_.push_back(std::move(metadata_change));
}
Status InitialSysCatalogSnapshotWriter::WriteSnapshot(
tablet::Tablet* sys_catalog_tablet,
const std::string& dest_path) {
RETURN_NOT_OK(sys_catalog_tablet->Flush(yb::tablet::FlushMode::kSync));
RETURN_NOT_OK(Env::Default()->CreateDir(dest_path));
RETURN_NOT_OK(sys_catalog_tablet->CreateCheckpoint(
JoinPathSegments(dest_path, kSysCatalogSnapshotRocksDbSubDir)));
tserver::ExportedTabletMetadataChanges exported_tablet_metadata_changes;
for (int i = 0; i < initdb_metadata_changes_.size(); ++i) {
*exported_tablet_metadata_changes.add_metadata_changes() = std::move(
initdb_metadata_changes_[i]);
}
const string metadata_changes_file = JoinPathSegments(
dest_path,
kSysCatalogSnapshotTabletMetadataChangesFile);
RETURN_NOT_OK(WritePBContainerToPath(
Env::Default(),
metadata_changes_file,
exported_tablet_metadata_changes,
pb_util::CreateMode::NO_OVERWRITE,
pb_util::SyncMode::NO_SYNC));
LOG(INFO) << "Wrote " << initdb_metadata_changes_.size() << " tablet metadata changes to file "
<< metadata_changes_file;
LOG(INFO) << "Created initial sys catalog snapshot at " << dest_path;
return Status::OK();
}
// ------------------------------------------------------------------------------------------------
// End of InitialSysCatalogSnapshotWriter
// ------------------------------------------------------------------------------------------------
Status RestoreInitialSysCatalogSnapshot(
const std::string& initial_snapshot_path,
tablet::TabletPeer* sys_catalog_tablet_peer,
int64_t term) {
TabletSnapshotOpRequestPB tablet_snapshot_req;
tablet_snapshot_req.set_operation(yb::tserver::TabletSnapshotOpRequestPB::RESTORE);
tablet_snapshot_req.set_tablet_id(kSysCatalogTabletId);
tablet_snapshot_req.set_snapshot_dir_override(
JoinPathSegments(initial_snapshot_path, kSysCatalogSnapshotRocksDbSubDir));
TabletSnapshotOpResponsePB tablet_snapshot_resp;
auto tx_state = std::make_unique<SnapshotOperationState>(
sys_catalog_tablet_peer->tablet(), &tablet_snapshot_req);
CountDownLatch latch(1);
tx_state->set_completion_callback(
tablet::MakeLatchOperationCompletionCallback(&latch, &tablet_snapshot_resp));
sys_catalog_tablet_peer->Submit(
std::make_unique<tablet::SnapshotOperation>(std::move(tx_state)),
term);
// Now restore tablet metadata.
tserver::ExportedTabletMetadataChanges tablet_metadata_changes;
RETURN_NOT_OK(ReadPBContainerFromPath(
Env::Default(),
JoinPathSegments(initial_snapshot_path, kSysCatalogSnapshotTabletMetadataChangesFile),
&tablet_metadata_changes));
for (const tserver::ChangeMetadataRequestPB& change_metadata_req :
tablet_metadata_changes.metadata_changes()) {
RETURN_NOT_OK(tablet::SyncReplicateChangeMetadataOperation(
&change_metadata_req,
sys_catalog_tablet_peer,
term));
}
LOG(INFO) << "Imported " << tablet_metadata_changes.metadata_changes_size()
<< " tablet metadata changes";
latch.Wait();
return Status::OK();
}
void SetDefaultInitialSysCatalogSnapshotFlags() {
// Allowing to turn off the use of initial catalog snapshot with an env variable -- useful in
// tests.
const char* env_var_value = getenv(kUseInitialSysCatalogSnapshotEnvVar);
if (env_var_value && strcmp(env_var_value, "0") == 0) {
LOG(INFO) << "Disabling the use of initial sys catalog snapshot: env var "
<< kUseInitialSysCatalogSnapshotEnvVar << " is set to 0";
FLAGS_use_initial_sys_catalog_snapshot = 0;
FLAGS_enable_ysql = 0;
}
if (FLAGS_initial_sys_catalog_snapshot_path.empty() &&
!FLAGS_create_initial_sys_catalog_snapshot &&
(FLAGS_use_initial_sys_catalog_snapshot || FLAGS_enable_ysql)) {
const char* kStaticDataParentDir = "share";
const std::string search_for_dir = JoinPathSegments(
kStaticDataParentDir, kDefaultInitialSysCatalogSnapshotDir,
kSysCatalogSnapshotRocksDbSubDir);
VLOG(1) << "Searching for directory containing subdirectory " << search_for_dir;
const string candidate_dir =
JoinPathSegments(
env_util::GetRootDir(search_for_dir),
kStaticDataParentDir,
kDefaultInitialSysCatalogSnapshotDir);
VLOG(1) << "candidate_dir=" << candidate_dir;
// The metadata changes file is written last, so its presence indicates that the snapshot
// was successful.
const string candidate_metadata_changes_path =
JoinPathSegments(candidate_dir, kSysCatalogSnapshotTabletMetadataChangesFile);
VLOG(1) << "candidate_metadata_changes_path=" << candidate_metadata_changes_path;
if (Env::Default()->FileExists(candidate_metadata_changes_path)) {
VLOG(1) << "Found initial sys catalog snapshot directory: " << candidate_dir;
FLAGS_initial_sys_catalog_snapshot_path = candidate_dir;
return;
} else {
VLOG(1) << "File " << candidate_metadata_changes_path << " does not exist";
}
} else {
VLOG(1)
<< "Not attempting initial sys catalog snapshot auto-detection: "
<< "FLAGS_initial_sys_catalog_snapshot_path="
<< FLAGS_initial_sys_catalog_snapshot_path << ", "
<< "FLAGS_create_initial_sys_catalog_snapshot="
<< FLAGS_create_initial_sys_catalog_snapshot << ", "
<< "FLAGS_use_initial_sys_catalog_snapshot="
<< FLAGS_use_initial_sys_catalog_snapshot << ", "
<< "FLAGS_enable_ysql="
<< FLAGS_enable_ysql;
}
}
bool ShouldAutoRunInitDb(SysConfigInfo* ysql_catalog_config, bool pg_proc_exists) {
if (pg_proc_exists) {
LOG(INFO) << "Table pg_proc exists, assuming initdb has already been run";
return false;
}
if (!FLAGS_master_auto_run_initdb) {
LOG(INFO) << "--master_auto_run_initdb is set to false, not running initdb";
return false;
}
{
auto l = ysql_catalog_config->LockForRead();
if (l->data().pb.ysql_catalog_config().initdb_done()) {
LOG(INFO) << "Cluster configuration indicates that initdb has already completed";
return false;
}
}
LOG(INFO) << "initdb has never been run on this cluster, running it";
return true;
}
Status MakeYsqlSysCatalogTablesTransactional(
TableInfoMap* table_ids_map,
SysCatalogTable* sys_catalog,
SysConfigInfo* ysql_catalog_config,
int64_t term) {
{
auto ysql_catalog_config_lock = ysql_catalog_config->LockForRead();
const auto& ysql_catalog_config_pb = ysql_catalog_config_lock->data().pb.ysql_catalog_config();
if (ysql_catalog_config_pb.transactional_sys_catalog_enabled()) {
LOG(INFO) << "YSQL catalog tables are already transactional";
return Status::OK();
}
}
int num_updated_tables = 0;
for (const auto& iter : *table_ids_map) {
const auto& table_id = iter.first;
auto& table_info = *iter.second;
if (!IsPgsqlId(table_id)) {
continue;
}
{
TabletInfos tablet_infos;
table_info.GetAllTablets(&tablet_infos);
if (tablet_infos.size() != 1 || tablet_infos.front()->tablet_id() != kSysCatalogTabletId) {
continue;
}
}
auto table_lock = table_info.LockForWrite();
auto& schema = *table_lock->mutable_data()->mutable_schema();
auto& table_properties = *schema.mutable_table_properties();
bool should_modify = false;
if (!table_properties.is_ysql_catalog_table()) {
table_properties.set_is_ysql_catalog_table(true);
should_modify = true;
}
if (!table_properties.is_transactional()) {
table_properties.set_is_transactional(true);
should_modify = true;
}
if (!should_modify) {
continue;
}
num_updated_tables++;
LOG(INFO) << "Making YSQL system catalog table transactional: " << table_info.ToString();
// Change table properties in tablet metadata.
tserver::ChangeMetadataRequestPB change_req;
change_req.set_tablet_id(kSysCatalogTabletId);
auto& add_table = *change_req.mutable_add_table();
VERIFY_RESULT(sys_catalog->tablet_peer()->tablet_metadata()->GetTableInfo(table_id))->ToPB(
&add_table);
auto& metadata_table_properties = *add_table.mutable_schema()->mutable_table_properties();
metadata_table_properties.set_is_ysql_catalog_table(true);
metadata_table_properties.set_is_transactional(true);
RETURN_NOT_OK(tablet::SyncReplicateChangeMetadataOperation(
&change_req, sys_catalog->tablet_peer().get(), term));
// Change table properties in the sys catalog. We do this after updating tablet metadata, so
// that if a restart happens before this step succeeds, we'll retry updating both next time.
RETURN_NOT_OK(sys_catalog->UpdateItem(&table_info, term));
table_lock->Commit();
}
if (num_updated_tables > 0) {
LOG(INFO) << "Made " << num_updated_tables << " YSQL sys catalog tables transactional";
}
LOG(INFO) << "Marking YSQL system catalog as transactional in YSQL catalog config";
{
auto ysql_catalog_lock = ysql_catalog_config->LockForWrite();
auto* ysql_catalog_config_pb =
ysql_catalog_lock->mutable_data()->pb.mutable_ysql_catalog_config();
ysql_catalog_config_pb->set_transactional_sys_catalog_enabled(true);
RETURN_NOT_OK(sys_catalog->UpdateItem(ysql_catalog_config, term));
ysql_catalog_lock->Commit();
}
return Status::OK();
}
} // namespace master
} // namespace yb
| 39.030488
| 100
| 0.718403
|
eliahburns
|