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
109
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
48.5k
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
0e39d7bed8caff08a494c329fd309d991dd0dbdf
2,580
cpp
C++
programs/chapter_11/pruebas/ldr_sensor_con_average.cpp
epernia/arm_book
ffdd17618c2c7372cef338fc743f517bf6f0f42b
[ "BSD-3-Clause" ]
2
2021-05-03T17:21:37.000Z
2021-06-08T08:32:07.000Z
programs/chapter_11/pruebas/ldr_sensor_con_average.cpp
epernia/arm_book
ffdd17618c2c7372cef338fc743f517bf6f0f42b
[ "BSD-3-Clause" ]
null
null
null
programs/chapter_11/pruebas/ldr_sensor_con_average.cpp
epernia/arm_book
ffdd17618c2c7372cef338fc743f517bf6f0f42b
[ "BSD-3-Clause" ]
2
2020-10-14T19:06:24.000Z
2021-06-08T08:32:09.000Z
//=====[Libraries]============================================================= #include "arm_book_lib.h" #include "smart_home_system.h" #include "ldr_sensor.h" //=====[Declaration of private defines]====================================== #define LDR_SAMPLE_TIME 100 #define LDR_NUMBER_OF_AVG_SAMPLES 10 //=====[Declaration of private data types]===================================== //=====[Declaration and initialization of public global objects]=============== AnalogIn LDR(A4); //=====[Declaration of external public global variables]======================= //=====[Declaration and initialization of public global variables]============= //=====[Declaration and initialization of private global variables]============ static float LDRReadingsMovingAverage = 0.0; float LDRAvgReadingsArray[LDR_NUMBER_OF_AVG_SAMPLES]; //=====[Declarations (prototypes) of private functions]======================== static void shiftLDRAvgReadingsArray(); //=====[Implementations of public functions]=================================== void LDRSensorInit() { return; } void LDRSensorUpdate() { static int accumulatedTimeLDR = 0; static int LDRSampleIndex = 0; accumulatedTimeLDR = accumulatedTimeLDR + SYSTEM_TIME_INCREMENT_MS; if ( accumulatedTimeLDR >= LDR_SAMPLE_TIME ) { if ( LDRSampleIndex < LDR_NUMBER_OF_AVG_SAMPLES ) { LDRAvgReadingsArray[LDRSampleIndex] = LDR.read() / LDR_NUMBER_OF_AVG_SAMPLES; LDRReadingsMovingAverage = LDRReadingsMovingAverage + LDRAvgReadingsArray[LDRSampleIndex]; LDRSampleIndex++; } else { LDRReadingsMovingAverage = LDRReadingsMovingAverage - LDRAvgReadingsArray[0]; shiftLDRAvgReadingsArray(); LDRAvgReadingsArray[LDR_NUMBER_OF_AVG_SAMPLES-1] = LDR.read() / LDR_NUMBER_OF_AVG_SAMPLES; LDRReadingsMovingAverage = LDRReadingsMovingAverage + LDRAvgReadingsArray[LDR_NUMBER_OF_AVG_SAMPLES-1]; } accumulatedTimeLDR = 0; } } float LDRSensorRead() { return LDRReadingsMovingAverage; } //=====[Implementations of private functions]================================== static void shiftLDRAvgReadingsArray() { int i = 0; for( i=1; i<LDR_NUMBER_OF_AVG_SAMPLES; i++ ) { LDRAvgReadingsArray[i-1] = LDRAvgReadingsArray[i]; } LDRAvgReadingsArray[LDR_NUMBER_OF_AVG_SAMPLES-1] = 0.0; }
30.352941
79
0.581008
epernia
0e3a60ed0c26684ee8208e40b558c18677e0a534
309
cpp
C++
CollinsJustin_MidtermProject/CollinsJustin_MidtermProject/Reshape.cpp
justcollins/SolarSystem
66ebb11961afe4723ac7431b268a8ecad1ec4d0d
[ "MIT" ]
null
null
null
CollinsJustin_MidtermProject/CollinsJustin_MidtermProject/Reshape.cpp
justcollins/SolarSystem
66ebb11961afe4723ac7431b268a8ecad1ec4d0d
[ "MIT" ]
null
null
null
CollinsJustin_MidtermProject/CollinsJustin_MidtermProject/Reshape.cpp
justcollins/SolarSystem
66ebb11961afe4723ac7431b268a8ecad1ec4d0d
[ "MIT" ]
null
null
null
#include "globals.h" void reshape(int w, int h) { glViewport (0, 0, (GLsizei) w, (GLsizei) h); glMatrixMode (GL_PROJECTION); glLoadIdentity (); gluPerspective(60.0, (GLfloat) w/(GLfloat) h, 1.0, 201.0); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); gluLookAt (x, y, z, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0); }
25.75
59
0.653722
justcollins
0e4095fc790d74504815b3a645e19452dd1767ba
2,895
inl
C++
Code/Engine/System/Window/Implementation/SFML/Window_SFML.inl
Manuzor/ezEngine
876ad33ef21c6b986bb9bb333b2a3cbfed2be5ef
[ "CC-BY-3.0" ]
null
null
null
Code/Engine/System/Window/Implementation/SFML/Window_SFML.inl
Manuzor/ezEngine
876ad33ef21c6b986bb9bb333b2a3cbfed2be5ef
[ "CC-BY-3.0" ]
null
null
null
Code/Engine/System/Window/Implementation/SFML/Window_SFML.inl
Manuzor/ezEngine
876ad33ef21c6b986bb9bb333b2a3cbfed2be5ef
[ "CC-BY-3.0" ]
1
2020-03-08T04:55:16.000Z
2020-03-08T04:55:16.000Z
#include <System/PCH.h> #include <System/Window/Window.h> #include <Foundation/Math/Size.h> ezResult ezWindow::Initialize() { EZ_LOG_BLOCK("ezWindow"); if (m_bInitialized) Destroy(); EZ_ASSERT_RELEASE(m_CreationDescription.m_ClientAreaSize.HasNonZeroArea(), "The client area size can't be zero sized!"); m_WindowHandle = EZ_DEFAULT_NEW(sf::Window); sf::VideoMode Mode; Mode.bitsPerPixel = 32; Mode.width = m_CreationDescription.m_ClientAreaSize.width; Mode.height = m_CreationDescription.m_ClientAreaSize.height; sf::Uint32 uiStyle = 0; if (m_CreationDescription.m_bFullscreenWindow) uiStyle |= sf::Style::Fullscreen; else if (m_CreationDescription.m_bResizable) uiStyle |= sf::Style::Resize; else uiStyle |= sf::Style::Titlebar; sf::ContextSettings context; context.depthBits = 24; context.stencilBits = 8; context.majorVersion = 4; context.minorVersion = 0; context.antialiasingLevel = 0; m_WindowHandle->create(Mode, m_CreationDescription.m_Title.GetData(), uiStyle, context); m_bInitialized = true; ezLog::Success("Created window successfully."); m_pInputDevice = EZ_DEFAULT_NEW(ezStandardInputDevice)(m_WindowHandle, m_CreationDescription.m_uiWindowNumber); // make sure the system knows about the actual window dimensions (especially for fullscreen windows) OnResizeMessage(ezSizeU32(m_WindowHandle->getSize().x, m_WindowHandle->getSize().y)); return CreateGraphicsContext(); } ezResult ezWindow::Destroy() { EZ_DEFAULT_DELETE(m_pInputDevice); DestroyGraphicsContext(); m_WindowHandle->close(); EZ_DEFAULT_DELETE(m_WindowHandle); m_WindowHandle = INVALID_WINDOW_HANDLE_VALUE; m_bInitialized = false; ezLog::Success("Window destroyed."); return EZ_SUCCESS; } void ezWindow::ProcessWindowMessages() { if (!m_bInitialized) return; sf::Event event; while (m_WindowHandle->pollEvent(event)) { switch (event.type) { case sf::Event::Closed: OnClickCloseMessage(); break; case sf::Event::Resized: OnResizeMessage(ezSizeU32(event.size.width, event.size.height)); break; case sf::Event::LostFocus: OnFocusMessage(false); break; case sf::Event::GainedFocus: OnFocusMessage(true); break; } m_pInputDevice->WindowMessage(event); } } void ezWindow::PresentFrame() { m_WindowHandle->display(); } ezResult ezWindow::CreateGraphicsContext() { switch (m_CreationDescription.m_GraphicsAPI) { case ezGraphicsAPI::OpenGL: return EZ_SUCCESS; default: EZ_REPORT_FAILURE("Unknown Graphics API selected."); } return EZ_FAILURE; } ezResult ezWindow::DestroyGraphicsContext() { switch (m_CreationDescription.m_GraphicsAPI) { case ezGraphicsAPI::OpenGL: return EZ_SUCCESS; default: EZ_REPORT_FAILURE("Unknown Graphics API selected."); } return EZ_FAILURE; }
21.444444
122
0.725734
Manuzor
0e413bf65a7b9d01ec590bba70c4e8594e534b8c
2,174
cpp
C++
src/pose.cpp
criptolot/estatero
20df006e76297b8ba750ad81980d893867e45752
[ "MIT" ]
null
null
null
src/pose.cpp
criptolot/estatero
20df006e76297b8ba750ad81980d893867e45752
[ "MIT" ]
null
null
null
src/pose.cpp
criptolot/estatero
20df006e76297b8ba750ad81980d893867e45752
[ "MIT" ]
null
null
null
#include "pose.h" #include "clientversion.h" #include "chainparams.h" #include "init.h" #include "net.h" #include "utilstrencodings.h" #include "utiltime.h" #include "masternode-sync.h" static int64_t nPoosProcessTime = 0; void ThreadPOOS(CConnman& connman) { SyncSideChain(0); int nIterations = 0; while (1 == 1) { if (ShutdownRequested()) return; try { double nOrphanBanning = GetSporkDouble("EnableOrphanSanctuaryBanning", 0); bool fConnectivity = POOSOrphanTest("status", 60 * 60); bool fPOOSEnabled = nOrphanBanning == 1 && fConnectivity; int64_t nElapsed = GetAdjustedTime() - nPoosProcessTime; if (nElapsed > (60 * 60 * 8)) { // Once every 8 hours we clear the POOS statuses and start over (in case sanctuaries dropped out or added, or if the entire POOS system was disabled etc). mapPOOSStatus.clear(); nPoosProcessTime = GetAdjustedTime(); } if (nOrphanBanning != 1) { mapPOOSStatus.clear(); } if (fPOOSEnabled) { // 9-15-2020 - R Andrews auto mnList = deterministicMNManager->GetListAtChainTip(); std::vector<uint256> toBan; mnList.ForEachMN(false, [&](const CDeterministicMNCPtr& dmn) { if (!ShutdownRequested()) { std::string sPubKey = dmn->pdmnState->pubKeyOperator.Get().ToString(); bool fOK = POOSOrphanTest(sPubKey, 60 * 60); int nStatus = fOK ? 1 : 255; mapPOOSStatus[sPubKey] = nStatus; if (!fOK) { toBan.emplace_back(dmn->proTxHash); } MilliSleep(1000); } }); // Ban for (const auto& proTxHash : toBan) { mnList.PoSePunish(proTxHash, mnList.CalcPenalty(100), false); } } nIterations++; int64_t nTipAge = GetAdjustedTime() - chainActive.Tip()->GetBlockTime(); if (nTipAge < (60 * 60 * 4) && chainActive.Tip()->nHeight % 10 == 0) { SyncSideChain(chainActive.Tip()->nHeight); } } catch(...) { LogPrintf("Error encountered in POOS main loop. %f \n", 0); } int nSleepLength = nIterations < 5 ? 60*5 : 60*30; for (int i = 0; i < nSleepLength; i++) { if (ShutdownRequested()) break; MilliSleep(1000); } } }
24.426966
158
0.632015
criptolot
0e41a8974b7b9a3a3739e22d9457b8221b8d4a66
57,583
cc
C++
xic/src/gtkxic/gtkcmp.cc
bernardventer/xictools
4ea72c118679caed700dab3d49a8d36445acaec3
[ "Apache-2.0" ]
3
2020-01-26T14:18:52.000Z
2020-12-09T20:07:22.000Z
xic/src/gtkxic/gtkcmp.cc
chris-ayala/xictools
4ea72c118679caed700dab3d49a8d36445acaec3
[ "Apache-2.0" ]
null
null
null
xic/src/gtkxic/gtkcmp.cc
chris-ayala/xictools
4ea72c118679caed700dab3d49a8d36445acaec3
[ "Apache-2.0" ]
2
2020-01-26T14:19:02.000Z
2021-08-14T16:33:28.000Z
/*========================================================================* * * * Distributed by Whiteley Research Inc., Sunnyvale, California, USA * * http://wrcad.com * * Copyright (C) 2017 Whiteley Research Inc., all rights reserved. * * Author: Stephen R. Whiteley, except as indicated. * * * * As fully as possible recognizing licensing terms and conditions * * imposed by earlier work from which this work was derived, if any, * * this work is released under the Apache License, Version 2.0 (the * * "License"). You may not use this file except in compliance with * * the License, and compliance with inherited licenses which are * * specified in a sub-header below this one if applicable. A copy * * of the License is provided with this distribution, or you may * * obtain a copy of the License at * * * * http://www.apache.org/licenses/LICENSE-2.0 * * * * See the License for the specific language governing permissions * * and limitations under the License. * * * * 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 NON- * * INFRINGEMENT. IN NO EVENT SHALL WHITELEY RESEARCH INCORPORATED * * OR STEPHEN R. WHITELEY 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. * * * *========================================================================* * XicTools Integrated Circuit Design System * * * * Xic Integrated Circuit Layout and Schematic Editor * * * *========================================================================* $Id:$ *========================================================================*/ #include "main.h" #include "fio.h" #include "fio_compare.h" #include "cvrt.h" #include "dsp_inlines.h" #include "promptline.h" #include "errorlog.h" #include "gtkmain.h" #include "gtkinlines.h" #include "gtkinterf/gtkspinbtn.h" //----------------------------------------------------------------------------- // The Compare Layers pop-up // // Help system keywords used: // xic:diff namespace { // Drag/drop stuff. // GtkTargetEntry target_table[] = { { (char*)"TWOSTRING", 0, 0 }, { (char*)"CELLNAME", 0, 1 }, { (char*)"STRING", 0, 2 }, { (char*)"text/plain", 0, 3 } }; guint n_targets = sizeof(target_table) / sizeof(target_table[0]); namespace gtkcmp { struct sCmp { friend struct sCmp_store; sCmp(GRobject); ~sCmp(); void update(); GtkWidget *shell() { return (cmp_popup); } private: void per_cell_obj_page(); void per_cell_geom_page(); void flat_geom_page(); void p1_sens(); char *compose_arglist(); bool get_bb(BBox*); void set_bb(const BBox*); static void cmp_cancel_proc(GtkWidget*, void*); static void cmp_action(GtkWidget*, void*); static void cmp_p1_action(GtkWidget*, void*); static void cmp_p1_fltr_proc(GtkWidget*, void*); static int cmp_popup_btn_proc(GtkWidget*, GdkEvent*, void*); static void cmp_sto_menu_proc(GtkWidget*, void*); static void cmp_rcl_menu_proc(GtkWidget*, void*); static void cmp_drag_data_received(GtkWidget*, GdkDragContext*, gint, gint, GtkSelectionData*, guint, guint); GRobject cmp_caller; GtkWidget *cmp_popup; GtkWidget *cmp_mode; GtkWidget *cmp_fname1; GtkWidget *cmp_fname2; GtkWidget *cmp_cnames1; GtkWidget *cmp_cnames2; GtkWidget *cmp_diff_only; GtkWidget *cmp_layer_list; GtkWidget *cmp_layer_use; GtkWidget *cmp_layer_skip; GTKspinBtn sb_max_errs; GtkWidget *cmp_p1_expand_arrays; GtkWidget *cmp_p1_slop; GtkWidget *cmp_p1_dups; GtkWidget *cmp_p1_boxes; GtkWidget *cmp_p1_polys; GtkWidget *cmp_p1_wires; GtkWidget *cmp_p1_labels; GtkWidget *cmp_p1_insta; GtkWidget *cmp_p1_boxes_prp; GtkWidget *cmp_p1_polys_prp; GtkWidget *cmp_p1_wires_prp; GtkWidget *cmp_p1_labels_prp; GtkWidget *cmp_p1_insta_prp; GtkWidget *cmp_p1_recurse; GtkWidget *cmp_p1_phys; GtkWidget *cmp_p1_elec; GtkWidget *cmp_p1_cell_prp; GtkWidget *cmp_p1_fltr; GtkWidget *cmp_p1_setup; PrpFltMode cmp_p1_fltr_mode; GtkWidget *cmp_p2_expand_arrays; GtkWidget *cmp_p2_recurse; GtkWidget *cmp_p2_insta; GtkWidget *cmp_p3_aoi_use; GtkWidget *cmp_p3_s_btn; GtkWidget *cmp_p3_r_btn; GtkWidget *cmp_p3_s_menu; GtkWidget *cmp_p3_r_menu; GTKspinBtn sb_p3_aoi_left; GTKspinBtn sb_p3_aoi_bottom; GTKspinBtn sb_p3_aoi_right; GTKspinBtn sb_p3_aoi_top; GTKspinBtn sb_p3_fine_grid; GTKspinBtn sb_p3_coarse_mult; }; sCmp *Cmp; // Entry storage, all entries are persistent. // struct sCmp_store { sCmp_store(); ~sCmp_store(); void save(); void recall(); void recall_p1(); void recall_p2(); void recall_p3(); char *cs_file1; char *cs_file2; char *cs_cells1; char *cs_cells2; char *cs_layers; int cs_mode; bool cs_layer_only; bool cs_layer_skip; bool cs_differ; int cs_max_errs; bool cs_p1_recurse; bool cs_p1_expand_arrays; bool cs_p1_slop; bool cs_p1_dups; bool cs_p1_boxes; bool cs_p1_polys; bool cs_p1_wires; bool cs_p1_labels; bool cs_p1_insta; bool cs_p1_boxes_prp; bool cs_p1_polys_prp; bool cs_p1_wires_prp; bool cs_p1_labels_prp; bool cs_p1_insta_prp; bool cs_p1_elec; bool cs_p1_cell_prp; unsigned char cs_p1_fltr; bool cs_p2_recurse; bool cs_p2_expand_arrays; bool cs_p2_insta; bool cs_p3_use_window; double cs_p3_left; double cs_p3_bottom; double cs_p3_right; double cs_p3_top; int cs_p3_fine_grid; int cs_p3_coarse_mult; }; sCmp_store cmp_storage; } } using namespace gtkcmp; void cConvert::PopUpCompare(GRobject caller, ShowMode mode) { if (!GRX || !mainBag()) return; if (mode == MODE_OFF) { delete Cmp; return; } if (mode == MODE_UPD) { if (Cmp) Cmp->update(); return; } if (Cmp) return; new sCmp(caller); if (!Cmp->shell()) { delete Cmp; return; } gtk_window_set_transient_for(GTK_WINDOW(Cmp->shell()), GTK_WINDOW(mainBag()->Shell())); GRX->SetPopupLocation(GRloc(LW_UR), Cmp->shell(), mainBag()->Viewport()); gtk_widget_show(Cmp->shell()); } sCmp::sCmp(GRobject c) { Cmp = this; cmp_caller = c; cmp_popup = 0; cmp_mode = 0; cmp_fname1 = 0; cmp_fname2 = 0; cmp_cnames1 = 0; cmp_cnames2 = 0; cmp_diff_only = 0; cmp_layer_list = 0; cmp_layer_use = 0; cmp_layer_skip = 0; cmp_p1_expand_arrays = 0; cmp_p1_slop = 0; cmp_p1_dups = 0; cmp_p1_boxes = 0; cmp_p1_polys = 0; cmp_p1_wires = 0; cmp_p1_labels = 0; cmp_p1_insta = 0; cmp_p1_boxes_prp = 0; cmp_p1_polys_prp = 0; cmp_p1_wires_prp = 0; cmp_p1_labels_prp = 0; cmp_p1_insta_prp = 0; cmp_p1_recurse = 0; cmp_p1_phys = 0; cmp_p1_elec = 0; cmp_p1_cell_prp = 0; cmp_p1_fltr = 0; cmp_p1_setup = 0; cmp_p1_fltr_mode = PrpFltDflt; cmp_p2_expand_arrays = 0; cmp_p2_recurse = 0; cmp_p2_insta = 0; cmp_p3_aoi_use = 0; cmp_p3_s_btn = 0; cmp_p3_r_btn = 0; cmp_p3_s_menu = 0; cmp_p3_r_menu = 0; cmp_popup = gtk_NewPopup(0, "Compare Layouts", cmp_cancel_proc, 0); if (!cmp_popup) return; // Without this, spin entries sometimes freeze up for some reason. gtk_object_set_data(GTK_OBJECT(cmp_popup), "no_prop_key", (void*)1); GtkWidget *form = gtk_table_new(2, 1, false); gtk_widget_show(form); gtk_container_set_border_width(GTK_CONTAINER(form), 2); gtk_container_add(GTK_CONTAINER(cmp_popup), form); int rowcnt = 0; // // Label in frame plus help btn // GtkWidget *row = gtk_hbox_new(false, 2); gtk_widget_show(row); GtkWidget *label = gtk_label_new( "Compare Cells/Geometry Between Layouts"); gtk_widget_show(label); gtk_misc_set_padding(GTK_MISC(label), 2, 2); GtkWidget *frame = gtk_frame_new(0); gtk_widget_show(frame); gtk_container_add(GTK_CONTAINER(frame), label); gtk_box_pack_start(GTK_BOX(row), frame, true, true, 0); GtkWidget *button = gtk_button_new_with_label("Help"); gtk_widget_set_name(button, "Help"); gtk_widget_show(button); gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(cmp_action), 0); gtk_box_pack_end(GTK_BOX(row), button, false, false, 0); gtk_table_attach(GTK_TABLE(form), row, 0, 2, rowcnt, rowcnt+1, (GtkAttachOptions)(GTK_EXPAND | GTK_FILL | GTK_SHRINK), (GtkAttachOptions)0, 2, 2); rowcnt++; // // Comparison mode selection notebook // cmp_mode = gtk_notebook_new(); gtk_widget_show(cmp_mode); gtk_table_attach(GTK_TABLE(form), cmp_mode, 0, 2, rowcnt, rowcnt+1, (GtkAttachOptions)(GTK_EXPAND | GTK_FILL | GTK_SHRINK), (GtkAttachOptions)0, 2, 2); rowcnt++; per_cell_obj_page(); per_cell_geom_page(); flat_geom_page(); // // Left file/cell entries // GtkWidget *rc = gtk_table_new(2, 2, false); gtk_widget_show(rc); label = gtk_label_new("Source"); gtk_widget_show(label); gtk_table_attach(GTK_TABLE(rc), label, 0, 1, 0, 1, (GtkAttachOptions)0, (GtkAttachOptions)0, 2, 2); cmp_fname1 = gtk_entry_new(); gtk_widget_show(cmp_fname1); gtk_table_attach(GTK_TABLE(rc), cmp_fname1, 1, 2, 0, 1, (GtkAttachOptions)(GTK_EXPAND | GTK_FILL | GTK_SHRINK), (GtkAttachOptions)0, 2, 2); label = gtk_label_new("Cells"); gtk_widget_show(label); gtk_table_attach(GTK_TABLE(rc), label, 0, 1, 1, 2, (GtkAttachOptions)0, (GtkAttachOptions)0, 2, 2); cmp_cnames1 = gtk_entry_new(); gtk_widget_show(cmp_cnames1); gtk_table_attach(GTK_TABLE(rc), cmp_cnames1, 1, 2, 1, 2, (GtkAttachOptions)(GTK_EXPAND | GTK_FILL | GTK_SHRINK), (GtkAttachOptions)0, 2, 2); frame = gtk_frame_new("<<<"); gtk_widget_show(frame); gtk_container_add(GTK_CONTAINER(frame), rc); gtk_table_attach(GTK_TABLE(form), frame, 0, 2, rowcnt, rowcnt+1, (GtkAttachOptions)(GTK_EXPAND | GTK_FILL | GTK_SHRINK), (GtkAttachOptions)0, 2, 2); rowcnt++; GtkDestDefaults DD = (GtkDestDefaults) (GTK_DEST_DEFAULT_MOTION | GTK_DEST_DEFAULT_HIGHLIGHT); // drop site gtk_drag_dest_set(cmp_fname1, DD, target_table, n_targets, GDK_ACTION_COPY); gtk_signal_connect_after(GTK_OBJECT(cmp_fname1), "drag-data-received", GTK_SIGNAL_FUNC(cmp_drag_data_received), 0); gtk_drag_dest_set(cmp_cnames1, DD, target_table, n_targets, GDK_ACTION_COPY); // Don't use connect_after here, see note in cmp_drag_data_received. gtk_signal_connect(GTK_OBJECT(cmp_cnames1), "drag-data-received", GTK_SIGNAL_FUNC(cmp_drag_data_received), 0); // // Right file/cell entries // rc = gtk_table_new(2, 2, false); gtk_widget_show(rc); label = gtk_label_new("Source"); gtk_widget_show(label); gtk_table_attach(GTK_TABLE(rc), label, 0, 1, 0, 1, (GtkAttachOptions)0, (GtkAttachOptions)0, 2, 2); cmp_fname2 = gtk_entry_new(); gtk_widget_show(cmp_fname2); gtk_table_attach(GTK_TABLE(rc), cmp_fname2, 1, 2, 0, 1, (GtkAttachOptions)(GTK_EXPAND | GTK_FILL | GTK_SHRINK), (GtkAttachOptions)0, 2, 2); label = gtk_label_new("Equiv"); gtk_widget_show(label); gtk_table_attach(GTK_TABLE(rc), label, 0, 1, 1, 2, (GtkAttachOptions)0, (GtkAttachOptions)0, 2, 2); cmp_cnames2 = gtk_entry_new(); gtk_widget_show(cmp_cnames2); gtk_table_attach(GTK_TABLE(rc), cmp_cnames2, 1, 2, 1, 2, (GtkAttachOptions)(GTK_EXPAND | GTK_FILL | GTK_SHRINK), (GtkAttachOptions)0, 2, 2); frame = gtk_frame_new(">>>"); gtk_widget_show(frame); gtk_container_add(GTK_CONTAINER(frame), rc); gtk_table_attach(GTK_TABLE(form), frame, 0, 2, rowcnt, rowcnt+1, (GtkAttachOptions)(GTK_EXPAND | GTK_FILL | GTK_SHRINK), (GtkAttachOptions)0, 2, 2); rowcnt++; // drop site gtk_drag_dest_set(cmp_fname2, DD, target_table, n_targets, GDK_ACTION_COPY); gtk_signal_connect_after(GTK_OBJECT(cmp_fname2), "drag-data-received", GTK_SIGNAL_FUNC(cmp_drag_data_received), 0); gtk_drag_dest_set(cmp_cnames2, DD, target_table, n_targets, GDK_ACTION_COPY); // Don't use connect_after here, see note in cmp_drag_data_received. gtk_signal_connect(GTK_OBJECT(cmp_cnames2), "drag-data-received", GTK_SIGNAL_FUNC(cmp_drag_data_received), 0); // // Layer list and associated buttons // rc = gtk_table_new(2, 2, false); gtk_widget_show(rc); cmp_layer_use = gtk_check_button_new_with_label("Layers Only"); gtk_widget_show(cmp_layer_use); gtk_signal_connect(GTK_OBJECT(cmp_layer_use), "clicked", GTK_SIGNAL_FUNC(cmp_action), this); gtk_table_attach(GTK_TABLE(rc), cmp_layer_use, 0, 1, 0, 1, (GtkAttachOptions)(GTK_EXPAND | GTK_FILL | GTK_SHRINK), (GtkAttachOptions)0, 2, 2); cmp_layer_skip = gtk_check_button_new_with_label("Skip Layers"); gtk_widget_show(cmp_layer_skip); gtk_signal_connect(GTK_OBJECT(cmp_layer_skip), "clicked", GTK_SIGNAL_FUNC(cmp_action), this); gtk_table_attach(GTK_TABLE(rc), cmp_layer_skip, 1, 2, 0, 1, (GtkAttachOptions)(GTK_EXPAND | GTK_FILL | GTK_SHRINK), (GtkAttachOptions)0, 2, 2); cmp_layer_list = gtk_entry_new(); gtk_widget_show(cmp_layer_list); gtk_table_attach(GTK_TABLE(rc), cmp_layer_list, 0, 2, 1, 2, (GtkAttachOptions)(GTK_EXPAND | GTK_FILL | GTK_SHRINK), (GtkAttachOptions)0, 2, 2); frame = gtk_frame_new("Layer List"); gtk_widget_show(frame); gtk_container_add(GTK_CONTAINER(frame), rc); gtk_table_attach(GTK_TABLE(form), frame, 0, 2, rowcnt, rowcnt+1, (GtkAttachOptions)(GTK_EXPAND | GTK_FILL | GTK_SHRINK), (GtkAttachOptions)0, 2, 2); rowcnt++; // // Diff only and max differences spin button // GtkWidget *hbox = gtk_hbox_new(false, 2); gtk_widget_show(hbox); cmp_diff_only = gtk_check_button_new_with_label("Differ Only"); gtk_widget_show(cmp_diff_only); gtk_box_pack_start(GTK_BOX(hbox), cmp_diff_only, true, true, 0); label = gtk_label_new("Maximum Differences"); gtk_widget_show(label); gtk_misc_set_padding(GTK_MISC(label), 2, 2); gtk_box_pack_start(GTK_BOX(hbox), label, false, false, 0); GtkWidget *sb = sb_max_errs.init(0.0, 0.0, 1e6, 0); gtk_widget_set_usize(sb, 80, -1); gtk_box_pack_start(GTK_BOX(hbox), sb, false, false, 0); gtk_table_attach(GTK_TABLE(form), hbox, 0, 2, rowcnt, rowcnt+1, (GtkAttachOptions)(GTK_EXPAND | GTK_FILL | GTK_SHRINK), (GtkAttachOptions)0, 2, 2); rowcnt++; GtkWidget *hsep = gtk_hseparator_new(); gtk_widget_show(hsep); gtk_table_attach(GTK_TABLE(form), hsep, 0, 2, rowcnt, rowcnt+1, (GtkAttachOptions)(GTK_EXPAND | GTK_FILL | GTK_SHRINK), (GtkAttachOptions)0, 2, 2); rowcnt++; // // Go and Dismiss buttons // button = gtk_button_new_with_label("Go"); gtk_widget_set_name(button, "Go"); gtk_widget_show(button); gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(cmp_action), 0); gtk_table_attach(GTK_TABLE(form), button, 0, 1, rowcnt, rowcnt+1, (GtkAttachOptions)(GTK_EXPAND | GTK_FILL | GTK_SHRINK), (GtkAttachOptions)(GTK_EXPAND | GTK_FILL | GTK_SHRINK), 2, 2); button = gtk_button_new_with_label("Dismiss"); gtk_widget_set_name(button, "Dismiss"); gtk_widget_show(button); gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(cmp_cancel_proc), 0); gtk_table_attach(GTK_TABLE(form), button, 1, 2, rowcnt, rowcnt+1, (GtkAttachOptions)(GTK_EXPAND | GTK_FILL | GTK_SHRINK), (GtkAttachOptions)(GTK_EXPAND | GTK_FILL | GTK_SHRINK), 2, 2); gtk_window_set_focus(GTK_WINDOW(cmp_popup), button); cmp_storage.recall(); p1_sens(); } sCmp::~sCmp() { if (GRX->GetStatus(cmp_p1_setup)) GRX->CallCallback(cmp_p1_setup); cmp_storage.save(); Cmp = 0; if (cmp_caller) GRX->Deselect(cmp_caller); if (cmp_p3_s_menu) { g_object_ref(cmp_p3_s_menu); gtk_object_ref(GTK_OBJECT(cmp_p3_s_menu)); gtk_widget_destroy(cmp_p3_s_menu); g_object_unref(cmp_p3_s_menu); } if (cmp_p3_r_menu) { g_object_ref(cmp_p3_r_menu); gtk_object_ref(GTK_OBJECT(cmp_p3_r_menu)); gtk_widget_destroy(cmp_p3_r_menu); g_object_unref(cmp_p3_r_menu); } if (cmp_popup) gtk_widget_destroy(cmp_popup); } void sCmp::update() { } void sCmp::per_cell_obj_page() { int rcnt = 0; GtkWidget *table = gtk_table_new(3, 1, false); gtk_widget_show(table); // // Expand arrays and Recurse buttons // cmp_p1_recurse = gtk_check_button_new_with_label( "Recurse Into Hierarchy"); gtk_widget_show(cmp_p1_recurse); gtk_table_attach(GTK_TABLE(table), cmp_p1_recurse, 0, 2, rcnt, rcnt+1, (GtkAttachOptions)(GTK_EXPAND | GTK_FILL | GTK_SHRINK), (GtkAttachOptions)0, 2, 2); cmp_p1_expand_arrays = gtk_check_button_new_with_label("Expand Arrays"); gtk_widget_show(cmp_p1_expand_arrays); gtk_table_attach(GTK_TABLE(table), cmp_p1_expand_arrays, 2, 3, rcnt, rcnt+1, (GtkAttachOptions)(GTK_EXPAND | GTK_FILL | GTK_SHRINK), (GtkAttachOptions)0, 2, 2); rcnt++; cmp_p1_slop = gtk_check_button_new_with_label("Box to Wire/Poly Check"); gtk_widget_show(cmp_p1_slop); gtk_table_attach(GTK_TABLE(table), cmp_p1_slop, 0, 2, rcnt, rcnt+1, (GtkAttachOptions)(GTK_EXPAND | GTK_FILL | GTK_SHRINK), (GtkAttachOptions)0, 2, 2); cmp_p1_dups = gtk_check_button_new_with_label("Ignore Duplicate Objects"); gtk_widget_show(cmp_p1_dups); gtk_table_attach(GTK_TABLE(table), cmp_p1_dups, 2, 3, rcnt, rcnt+1, (GtkAttachOptions)(GTK_EXPAND | GTK_FILL | GTK_SHRINK), (GtkAttachOptions)0, 2, 2); rcnt++; // // Object Types group // GtkWidget *vbox = gtk_vbox_new(false, 2); gtk_widget_show(vbox); cmp_p1_boxes = gtk_check_button_new_with_label("Boxes"); gtk_widget_show(cmp_p1_boxes); gtk_signal_connect(GTK_OBJECT(cmp_p1_boxes), "clicked", GTK_SIGNAL_FUNC(cmp_p1_action), 0); gtk_box_pack_start(GTK_BOX(vbox), cmp_p1_boxes, false, false, 0); cmp_p1_polys = gtk_check_button_new_with_label("Polygons"); gtk_widget_show(cmp_p1_polys); gtk_signal_connect(GTK_OBJECT(cmp_p1_polys), "clicked", GTK_SIGNAL_FUNC(cmp_p1_action), 0); gtk_box_pack_start(GTK_BOX(vbox), cmp_p1_polys, false, false, 0); cmp_p1_wires = gtk_check_button_new_with_label("Wires"); gtk_widget_show(cmp_p1_wires); gtk_signal_connect(GTK_OBJECT(cmp_p1_wires), "clicked", GTK_SIGNAL_FUNC(cmp_p1_action), 0); gtk_box_pack_start(GTK_BOX(vbox), cmp_p1_wires, false, false, 0); cmp_p1_labels = gtk_check_button_new_with_label("Labels"); gtk_widget_show(cmp_p1_labels); gtk_signal_connect(GTK_OBJECT(cmp_p1_labels), "clicked", GTK_SIGNAL_FUNC(cmp_p1_action), 0); gtk_box_pack_start(GTK_BOX(vbox), cmp_p1_labels, false, false, 0); cmp_p1_insta = gtk_check_button_new_with_label("Cell Instances"); gtk_widget_show(cmp_p1_insta); gtk_signal_connect(GTK_OBJECT(cmp_p1_insta), "clicked", GTK_SIGNAL_FUNC(cmp_p1_action), 0); gtk_box_pack_start(GTK_BOX(vbox), cmp_p1_insta, false, false, 0); GtkWidget *frame = gtk_frame_new("Object Types"); gtk_widget_show(frame); gtk_container_add(GTK_CONTAINER(frame), vbox); gtk_table_attach(GTK_TABLE(table), frame, 0, 1, rcnt, rcnt+1, (GtkAttachOptions)(GTK_EXPAND | GTK_FILL | GTK_SHRINK), (GtkAttachOptions)0, 2, 2); // // Properties group // vbox = gtk_vbox_new(false, 2); gtk_widget_show(vbox); cmp_p1_boxes_prp = gtk_check_button_new_with_label(""); gtk_widget_show(cmp_p1_boxes_prp); gtk_box_pack_start(GTK_BOX(vbox), cmp_p1_boxes_prp, false, false, 0); cmp_p1_polys_prp = gtk_check_button_new_with_label(""); gtk_widget_show(cmp_p1_polys_prp); gtk_box_pack_start(GTK_BOX(vbox), cmp_p1_polys_prp, false, false, 0); cmp_p1_wires_prp = gtk_check_button_new_with_label(""); gtk_widget_show(cmp_p1_wires_prp); gtk_box_pack_start(GTK_BOX(vbox), cmp_p1_wires_prp, false, false, 0); cmp_p1_labels_prp = gtk_check_button_new_with_label(""); gtk_widget_show(cmp_p1_labels_prp); gtk_box_pack_start(GTK_BOX(vbox), cmp_p1_labels_prp, false, false, 0); cmp_p1_insta_prp = gtk_check_button_new_with_label(""); gtk_widget_show(cmp_p1_insta_prp); gtk_box_pack_start(GTK_BOX(vbox), cmp_p1_insta_prp, false, false, 0); frame = gtk_frame_new("Properties"); gtk_widget_show(frame); gtk_container_add(GTK_CONTAINER(frame), vbox); gtk_table_attach(GTK_TABLE(table), frame, 1, 2, rcnt, rcnt+1, (GtkAttachOptions)(GTK_EXPAND | GTK_FILL | GTK_SHRINK), (GtkAttachOptions)0, 2, 2); vbox = gtk_vbox_new(false, 2); gtk_widget_show(vbox); cmp_p1_phys = gtk_radio_button_new_with_label(0, "Physical"); gtk_widget_show(cmp_p1_phys); gtk_signal_connect(GTK_OBJECT(cmp_p1_phys), "clicked", GTK_SIGNAL_FUNC(cmp_p1_action), 0); gtk_box_pack_start(GTK_BOX(vbox), cmp_p1_phys, false, false, 0); GSList *group = gtk_radio_button_group(GTK_RADIO_BUTTON(cmp_p1_phys)); cmp_p1_elec = gtk_radio_button_new_with_label(group, "Electrical"); gtk_widget_show(cmp_p1_elec); gtk_box_pack_start(GTK_BOX(vbox), cmp_p1_elec, false, false, 0); cmp_p1_cell_prp = gtk_check_button_new_with_label("Structure Properties"); gtk_widget_show(cmp_p1_cell_prp); gtk_box_pack_start(GTK_BOX(vbox), cmp_p1_cell_prp, false, false, 0); GtkWidget *hbox = gtk_hbox_new(false, 2); gtk_widget_show(hbox); GtkWidget *label = gtk_label_new("Property Filtering:"); gtk_widget_show(label); gtk_misc_set_padding(GTK_MISC(label), 2, 2); gtk_box_pack_start(GTK_BOX(vbox), label, false, false, 0); cmp_p1_fltr = gtk_option_menu_new(); gtk_widget_set_name(cmp_p1_fltr, "Filter"); gtk_widget_show(cmp_p1_fltr); GtkWidget *menu = gtk_menu_new(); gtk_widget_set_name(menu, "fltmenu"); GtkWidget *mi = gtk_menu_item_new_with_label("Default"); gtk_widget_set_name(mi, "default"); gtk_widget_show(mi); gtk_menu_append(GTK_MENU(menu), mi); gtk_signal_connect(GTK_OBJECT(mi), "activate", GTK_SIGNAL_FUNC(cmp_p1_fltr_proc), (void*)0L); mi = gtk_menu_item_new_with_label("None"); gtk_widget_set_name(mi, "none"); gtk_widget_show(mi); gtk_menu_append(GTK_MENU(menu), mi); gtk_signal_connect(GTK_OBJECT(mi), "activate", GTK_SIGNAL_FUNC(cmp_p1_fltr_proc), (void*)1L); mi = gtk_menu_item_new_with_label("Custom"); gtk_widget_set_name(mi, "custom"); gtk_widget_show(mi); gtk_menu_append(GTK_MENU(menu), mi); gtk_signal_connect(GTK_OBJECT(mi), "activate", GTK_SIGNAL_FUNC(cmp_p1_fltr_proc), (void*)2L); gtk_option_menu_set_menu(GTK_OPTION_MENU(cmp_p1_fltr), menu); gtk_box_pack_start(GTK_BOX(hbox), cmp_p1_fltr, true, true, 0); cmp_p1_setup = gtk_toggle_button_new_with_label("Setup"); gtk_widget_show(cmp_p1_setup); gtk_box_pack_start(GTK_BOX(hbox), cmp_p1_setup, false, false, 0); gtk_signal_connect(GTK_OBJECT(cmp_p1_setup), "clicked", GTK_SIGNAL_FUNC(cmp_p1_action), (void*)1L); gtk_box_pack_start(GTK_BOX(vbox), hbox, false, false, 0); gtk_table_attach(GTK_TABLE(table), vbox, 2, 3, rcnt, rcnt+1, (GtkAttachOptions)(GTK_EXPAND | GTK_FILL | GTK_SHRINK), (GtkAttachOptions)0, 2, 2); GtkWidget *tab_label = gtk_label_new("Per-Cell Objects"); gtk_widget_show(tab_label); gtk_notebook_append_page(GTK_NOTEBOOK(cmp_mode), table, tab_label); cmp_storage.recall_p1(); } void sCmp::per_cell_geom_page() { int rcnt = 0; GtkWidget *table = gtk_table_new(2, 1, false); gtk_widget_show(table); // // Expand arrays and Recurse buttons // cmp_p2_recurse = gtk_check_button_new_with_label( "Recurse Into Hierarchy"); gtk_widget_show(cmp_p2_recurse); gtk_table_attach(GTK_TABLE(table), cmp_p2_recurse, 0, 1, rcnt, rcnt+1, (GtkAttachOptions)(GTK_EXPAND | GTK_FILL | GTK_SHRINK), (GtkAttachOptions)0, 2, 2); cmp_p2_expand_arrays = gtk_check_button_new_with_label("Expand Arrays"); gtk_widget_show(cmp_p2_expand_arrays); gtk_table_attach(GTK_TABLE(table), cmp_p2_expand_arrays, 1, 2, rcnt, rcnt+1, (GtkAttachOptions)(GTK_EXPAND | GTK_FILL | GTK_SHRINK), (GtkAttachOptions)0, 2, 2); rcnt++; cmp_p2_insta = gtk_check_button_new_with_label("Compare Cell Instances"); gtk_widget_show(cmp_p2_insta); gtk_table_attach(GTK_TABLE(table), cmp_p2_insta, 0, 1, rcnt, rcnt+1, (GtkAttachOptions)(GTK_EXPAND | GTK_FILL | GTK_SHRINK), (GtkAttachOptions)0, 2, 2); rcnt++; GtkWidget *label = gtk_label_new("Physical Cells Only"); gtk_widget_show(label); gtk_misc_set_padding(GTK_MISC(label), 2, 2); gtk_table_attach(GTK_TABLE(table), label, 0, 2, rcnt, rcnt+1, (GtkAttachOptions)(GTK_EXPAND | GTK_FILL | GTK_SHRINK), (GtkAttachOptions)(GTK_EXPAND | GTK_FILL | GTK_SHRINK), 2, 2); GtkWidget *tab_label = gtk_label_new("Per-Cell Geometry"); gtk_widget_show(tab_label); gtk_notebook_append_page(GTK_NOTEBOOK(cmp_mode), table, tab_label); cmp_storage.recall_p2(); } void sCmp::flat_geom_page() { int rcnt = 0; GtkWidget *table = gtk_table_new(2, 1, false); gtk_widget_show(table); GtkWidget *row = gtk_hbox_new(false, 2); gtk_widget_show(row); cmp_p3_aoi_use = gtk_check_button_new_with_label("Use Window"); gtk_widget_set_name(cmp_p3_aoi_use, "Window"); gtk_widget_show(cmp_p3_aoi_use); gtk_signal_connect(GTK_OBJECT(cmp_p3_aoi_use), "clicked", GTK_SIGNAL_FUNC(cmp_action), this); gtk_box_pack_start(GTK_BOX(row), cmp_p3_aoi_use, false, false, 0); gtk_table_attach(GTK_TABLE(table), row, 0, 4, rcnt, rcnt+1, (GtkAttachOptions)(GTK_EXPAND | GTK_FILL | GTK_SHRINK), (GtkAttachOptions)0, 2, 2); rcnt++; cmp_p3_s_btn = gtk_button_new_with_label("S"); gtk_widget_set_name(cmp_p3_s_btn, "SaveWin"); gtk_widget_show(cmp_p3_s_btn); gtk_widget_set_usize(cmp_p3_s_btn, 30, -1); char buf[64]; cmp_p3_s_menu = gtk_menu_new(); gtk_widget_set_name(cmp_p3_s_menu, "Smenu"); for (int i = 0; i < FIO_NUM_BB_STORE; i++) { sprintf(buf, "Reg %d", i); GtkWidget *mi = gtk_menu_item_new_with_label(buf); gtk_widget_set_name(mi, buf); gtk_widget_show(mi); gtk_menu_append(GTK_MENU(cmp_p3_s_menu), mi); gtk_signal_connect(GTK_OBJECT(mi), "activate", GTK_SIGNAL_FUNC(cmp_sto_menu_proc), this); } gtk_signal_connect(GTK_OBJECT(cmp_p3_s_btn), "button-press-event", GTK_SIGNAL_FUNC(cmp_popup_btn_proc), cmp_p3_s_menu); GtkWidget *wnd_l_label = gtk_label_new("Left"); gtk_widget_show(wnd_l_label); gtk_misc_set_padding(GTK_MISC(wnd_l_label), 2, 2); GtkWidget *hbox = gtk_hbox_new(false, 2); gtk_widget_show(hbox); gtk_box_pack_start(GTK_BOX(hbox), cmp_p3_s_btn, false, false, 0); gtk_box_pack_start(GTK_BOX(hbox), wnd_l_label, true, true, 0); gtk_table_attach(GTK_TABLE(table), hbox, 0, 1, rcnt, rcnt+1, (GtkAttachOptions)(GTK_EXPAND | GTK_FILL | GTK_SHRINK), (GtkAttachOptions)0, 2, 2); int ndgt = CD()->numDigits(); GtkWidget *sb = sb_p3_aoi_left.init(MICRONS(FIO()->CvtWindow()->left), -1e6, 1e6, ndgt); gtk_widget_set_usize(sb, 100, -1); gtk_table_attach(GTK_TABLE(table), sb, 1, 2, rcnt, rcnt+1, (GtkAttachOptions)(GTK_EXPAND | GTK_FILL | GTK_SHRINK), (GtkAttachOptions)0, 2, 2); GtkWidget *wnd_b_label = gtk_label_new("Bottom"); gtk_widget_show(wnd_b_label); gtk_misc_set_padding(GTK_MISC(wnd_b_label), 2, 2); gtk_table_attach(GTK_TABLE(table), wnd_b_label, 2, 3, rcnt, rcnt+1, (GtkAttachOptions)(GTK_EXPAND | GTK_FILL | GTK_SHRINK), (GtkAttachOptions)0, 2, 2); sb = sb_p3_aoi_bottom.init(MICRONS(FIO()->CvtWindow()->bottom), -1e6, 1e6, ndgt); gtk_widget_set_usize(sb, 100, -1); gtk_table_attach(GTK_TABLE(table), sb, 3, 4, rcnt, rcnt+1, (GtkAttachOptions)(GTK_EXPAND | GTK_FILL | GTK_SHRINK), (GtkAttachOptions)0, 2, 2); rcnt++; cmp_p3_r_btn = gtk_button_new_with_label("R"); gtk_widget_set_name(cmp_p3_r_btn, "RclWin"); gtk_widget_show(cmp_p3_r_btn); gtk_widget_set_usize(cmp_p3_r_btn, 30, -1); cmp_p3_r_menu = gtk_menu_new(); gtk_widget_set_name(cmp_p3_r_menu, "Rmenu"); for (int i = 0; i < FIO_NUM_BB_STORE; i++) { sprintf(buf, "Reg %d", i); GtkWidget *mi = gtk_menu_item_new_with_label(buf); gtk_widget_set_name(mi, buf); gtk_widget_show(mi); gtk_menu_append(GTK_MENU(cmp_p3_r_menu), mi); gtk_signal_connect(GTK_OBJECT(mi), "activate", GTK_SIGNAL_FUNC(cmp_rcl_menu_proc), this); } gtk_signal_connect(GTK_OBJECT(cmp_p3_r_btn), "button-press-event", GTK_SIGNAL_FUNC(cmp_popup_btn_proc), cmp_p3_r_menu); GtkWidget *wnd_r_label = gtk_label_new("Right"); gtk_widget_show(wnd_r_label); gtk_misc_set_padding(GTK_MISC(wnd_r_label), 2, 2); hbox = gtk_hbox_new(false, 2); gtk_widget_show(hbox); gtk_box_pack_start(GTK_BOX(hbox), cmp_p3_r_btn, false, false, 0); gtk_box_pack_start(GTK_BOX(hbox), wnd_r_label, true, true, 0); gtk_table_attach(GTK_TABLE(table), hbox, 0, 1, rcnt, rcnt+1, (GtkAttachOptions)(GTK_EXPAND | GTK_FILL | GTK_SHRINK), (GtkAttachOptions)0, 2, 2); sb = sb_p3_aoi_right.init(MICRONS(FIO()->CvtWindow()->right), -1e6, 1e6, ndgt); gtk_widget_set_usize(sb, 100, -1); gtk_table_attach(GTK_TABLE(table), sb, 1, 2, rcnt, rcnt+1, (GtkAttachOptions)(GTK_EXPAND | GTK_FILL | GTK_SHRINK), (GtkAttachOptions)0, 2, 2); GtkWidget *wnd_t_label = gtk_label_new("Top"); gtk_widget_show(wnd_t_label); gtk_misc_set_padding(GTK_MISC(wnd_t_label), 2, 2); gtk_table_attach(GTK_TABLE(table), wnd_t_label, 2, 3, rcnt, rcnt+1, (GtkAttachOptions)(GTK_EXPAND | GTK_FILL | GTK_SHRINK), (GtkAttachOptions)0, 2, 2); sb = sb_p3_aoi_top.init(MICRONS(FIO()->CvtWindow()->top), -1e6, 1e6, ndgt); gtk_widget_set_usize(sb, 100, -1); gtk_table_attach(GTK_TABLE(table), sb, 3, 4, rcnt, rcnt+1, (GtkAttachOptions)(GTK_EXPAND | GTK_FILL | GTK_SHRINK), (GtkAttachOptions)0, 2, 2); rcnt++; GtkWidget *hsep = gtk_hseparator_new(); gtk_widget_show(hsep); gtk_widget_set_usize(hsep, -1, 20); gtk_table_attach(GTK_TABLE(table), hsep, 0, 4, rcnt, rcnt+1, (GtkAttachOptions)(GTK_EXPAND | GTK_FILL | GTK_SHRINK), (GtkAttachOptions)0, 2, 2); rcnt++; GtkWidget *label = gtk_label_new("Fine Grid"); gtk_widget_show(label); gtk_misc_set_padding(GTK_MISC(label), 2, 2); gtk_table_attach(GTK_TABLE(table), label, 0, 1, rcnt, rcnt+1, (GtkAttachOptions)(GTK_EXPAND | GTK_FILL | GTK_SHRINK), (GtkAttachOptions)0, 2, 2); sb = sb_p3_fine_grid.init(20.0, 1.0, 100.0, 0); gtk_widget_set_usize(sb, 100, -1); gtk_table_attach(GTK_TABLE(table), sb, 1, 2, rcnt, rcnt+1, (GtkAttachOptions)(GTK_EXPAND | GTK_FILL | GTK_SHRINK), (GtkAttachOptions)0, 2, 2); label = gtk_label_new("Coarse Mult"); gtk_widget_show(label); gtk_misc_set_padding(GTK_MISC(label), 2, 2); gtk_table_attach(GTK_TABLE(table), label, 2, 3, rcnt, rcnt+1, (GtkAttachOptions)(GTK_EXPAND | GTK_FILL | GTK_SHRINK), (GtkAttachOptions)0, 2, 2); sb = sb_p3_coarse_mult.init(20.0, 1.0, 100.0, 0); gtk_widget_set_usize(sb, 100, -1); gtk_table_attach(GTK_TABLE(table), sb, 3, 4, rcnt, rcnt+1, (GtkAttachOptions)(GTK_EXPAND | GTK_FILL | GTK_SHRINK), (GtkAttachOptions)0, 2, 2); rcnt++; GtkWidget *wnd_frame = gtk_frame_new(0); gtk_widget_show(wnd_frame); gtk_container_add(GTK_CONTAINER(wnd_frame), table); label = gtk_label_new("Physical Cells Only"); gtk_widget_show(label); gtk_misc_set_padding(GTK_MISC(label), 2, 2); gtk_table_attach(GTK_TABLE(table), label, 0, 4, rcnt, rcnt+1, (GtkAttachOptions)(GTK_EXPAND | GTK_FILL | GTK_SHRINK), (GtkAttachOptions)(GTK_EXPAND | GTK_FILL | GTK_SHRINK), 2, 2); GtkWidget *tab_label = gtk_label_new("Flat Geometry"); gtk_widget_show(tab_label); gtk_notebook_append_page(GTK_NOTEBOOK(cmp_mode), wnd_frame, tab_label); cmp_storage.recall_p3(); } namespace { char * strip_sp(const char *str) { if (!str) return (0); while (isspace(*str)) str++; if (!*str) return (0); bool qtd = false; if (*str == '"') { str++; qtd = true; } char *sret = lstring::copy(str); char *t = sret + strlen(sret) - 1; while (isspace(*t) && t >= sret) *t-- = 0; if (qtd && *t == '"') *t = 0; if (!*sret) { delete [] sret; return (0); } return (sret); } } // Sensitivity logic for the properties check boxes. // void sCmp::p1_sens() { bool b_ok = GRX->GetStatus(cmp_p1_boxes); bool p_ok = GRX->GetStatus(cmp_p1_polys); bool w_ok = GRX->GetStatus(cmp_p1_wires); bool l_ok = GRX->GetStatus(cmp_p1_labels); bool c_ok = GRX->GetStatus(cmp_p1_insta); gtk_widget_set_sensitive(cmp_p1_boxes_prp, b_ok); gtk_widget_set_sensitive(cmp_p1_polys_prp, p_ok); gtk_widget_set_sensitive(cmp_p1_wires_prp, w_ok); gtk_widget_set_sensitive(cmp_p1_labels_prp, l_ok); gtk_widget_set_sensitive(cmp_p1_insta_prp, c_ok); } char * sCmp::compose_arglist() { sLstr lstr; const char *s = gtk_entry_get_text(GTK_ENTRY(cmp_fname1)); char *tok = strip_sp(s); if (tok) { lstr.add(" -f1 \""); lstr.add(tok); lstr.add_c('"'); delete [] tok; } s = gtk_entry_get_text(GTK_ENTRY(cmp_fname2)); tok = strip_sp(s); if (tok) { lstr.add(" -f2 \""); lstr.add(tok); lstr.add_c('"'); delete [] tok; } s = gtk_entry_get_text(GTK_ENTRY(cmp_cnames1)); tok = strip_sp(s); if (tok) { lstr.add(" -c1 \""); lstr.add(tok); lstr.add_c('"'); delete [] tok; } s = gtk_entry_get_text(GTK_ENTRY(cmp_cnames2)); tok = strip_sp(s); if (tok) { lstr.add(" -c2 \""); lstr.add(tok); lstr.add_c('"'); delete [] tok; } if (GRX->GetStatus(cmp_layer_use) || GRX->GetStatus(cmp_layer_skip)) { s = gtk_entry_get_text(GTK_ENTRY(cmp_layer_list)); tok = strip_sp(s); if (tok) { lstr.add(" -l \""); lstr.add(tok); lstr.add_c('"'); if (GRX->GetStatus(cmp_layer_skip)) lstr.add(" -s"); delete [] tok; } } if (GRX->GetStatus(cmp_diff_only)) lstr.add(" -d"); s = sb_max_errs.get_string(); tok = strip_sp(s); if (tok) { if (atoi(tok) > 0) { lstr.add(" -r "); lstr.add(tok); } delete [] tok; } int page = gtk_notebook_current_page(GTK_NOTEBOOK(cmp_mode)); if (page == 0) { if (GRX->GetStatus(cmp_p1_recurse)) lstr.add(" -h"); if (GRX->GetStatus(cmp_p1_expand_arrays)) lstr.add(" -x"); if (GRX->GetStatus(cmp_p1_elec)) lstr.add(" -e"); if (GRX->GetStatus(cmp_p1_slop)) lstr.add(" -b"); if (GRX->GetStatus(cmp_p1_dups)) lstr.add(" -n"); bool has_b = false; bool has_p = false; bool has_w = false; bool has_l = false; bool has_c = false; char typ[8]; int cnt = 0; if (GRX->GetStatus(cmp_p1_boxes)) { typ[cnt++] = 'b'; has_b = true; } if (GRX->GetStatus(cmp_p1_polys)) { typ[cnt++] = 'p'; has_p = true; } if (GRX->GetStatus(cmp_p1_wires)) { typ[cnt++] = 'w'; has_w = true; } if (GRX->GetStatus(cmp_p1_labels)) { typ[cnt++] = 'l'; has_l = true; } if (GRX->GetStatus(cmp_p1_insta)) { typ[cnt++] = 'c'; has_c = true; } typ[cnt] = 0; if (typ[0] && strcmp(typ, "bpwc")) { lstr.add(" -t "); lstr.add(typ); } else { has_b = true; has_p = true; has_w = true; has_c = true; } cnt = 0; if (has_b && GRX->GetStatus(cmp_p1_boxes_prp)) typ[cnt++] = 'b'; if (has_p && GRX->GetStatus(cmp_p1_polys_prp)) typ[cnt++] = 'p'; if (has_w && GRX->GetStatus(cmp_p1_wires_prp)) typ[cnt++] = 'w'; if (has_l && GRX->GetStatus(cmp_p1_labels_prp)) typ[cnt++] = 'l'; if (has_c && GRX->GetStatus(cmp_p1_insta_prp)) typ[cnt++] = 'c'; if (GRX->GetStatus(cmp_p1_cell_prp)) typ[cnt++] = 's'; if (cmp_p1_fltr_mode == PrpFltCstm) typ[cnt++] = 'u'; else if (cmp_p1_fltr_mode == PrpFltNone) typ[cnt++] = 'n'; typ[cnt] = 0; if (typ[0]) { lstr.add(" -p "); lstr.add(typ); } } else if (page == 1) { lstr.add(" -g"); if (GRX->GetStatus(cmp_p2_recurse)) lstr.add(" -h"); if (GRX->GetStatus(cmp_p2_expand_arrays)) lstr.add(" -x"); if (GRX->GetStatus(cmp_p2_insta)) lstr.add(" -t c"); } else if (page == 2) { lstr.add(" -f"); if (GRX->GetStatus(cmp_p3_aoi_use)) { s = sb_p3_aoi_left.get_string(); char *tokl = lstring::gettok(&s); s = sb_p3_aoi_bottom.get_string(); char *tokb = lstring::gettok(&s); s = sb_p3_aoi_right.get_string(); char *tokr = lstring::gettok(&s); s = sb_p3_aoi_top.get_string(); char *tokt = lstring::gettok(&s); if (tokl && tokb && tokr && tokt) { lstr.add(" -a "); lstr.add(tokl); lstr.add_c(','); lstr.add(tokb); lstr.add_c(','); lstr.add(tokr); lstr.add_c(','); lstr.add(tokt); } delete [] tokl; delete [] tokb; delete [] tokr; delete [] tokt; } s = sb_p3_fine_grid.get_string(); tok = strip_sp(s); if (tok) { lstr.add(" -i "); lstr.add(tok); delete [] tok; } s = sb_p3_coarse_mult.get_string(); tok = strip_sp(s); if (tok) { lstr.add(" -m "); lstr.add(tok); delete [] tok; } } return (lstr.string_trim()); } bool sCmp::get_bb(BBox *BB) { if (!BB) return (false); double l, b, r, t; int i = 0; i += sscanf(sb_p3_aoi_left.get_string(), "%lf", &l); i += sscanf(sb_p3_aoi_bottom.get_string(), "%lf", &b); i += sscanf(sb_p3_aoi_right.get_string(), "%lf", &r); i += sscanf(sb_p3_aoi_top.get_string(), "%lf", &t); if (i != 4) return (false); BB->left = INTERNAL_UNITS(l); BB->bottom = INTERNAL_UNITS(b); BB->right = INTERNAL_UNITS(r); BB->top = INTERNAL_UNITS(t); if (BB->right < BB->left) { int tmp = BB->left; BB->left = BB->right; BB->right = tmp; } if (BB->top < BB->bottom) { int tmp = BB->bottom; BB->bottom = BB->top; BB->top = tmp; } if (BB->left == BB->right || BB->bottom == BB->top) return (false);; return (true); } void sCmp::set_bb(const BBox *BB) { int ndgt = CD()->numDigits(); if (!BB) return; sb_p3_aoi_left.set_digits(ndgt); sb_p3_aoi_left.set_value(MICRONS(BB->left)); sb_p3_aoi_bottom.set_digits(ndgt); sb_p3_aoi_bottom.set_value(MICRONS(BB->bottom)); sb_p3_aoi_right.set_digits(ndgt); sb_p3_aoi_right.set_value(MICRONS(BB->right)); sb_p3_aoi_top.set_digits(ndgt); sb_p3_aoi_top.set_value(MICRONS(BB->top)); } // Static function. void sCmp::cmp_cancel_proc(GtkWidget*, void*) { Cvt()->PopUpCompare(0, MODE_OFF); } // Static function. void sCmp::cmp_action(GtkWidget *caller, void*) { if (!Cmp) return; const char *name = gtk_widget_get_name(caller); if (!strcmp(name, "Help")) { DSPmainWbag(PopUpHelp("xic:diff")) return; } if (!strcmp(name, "Go")) { // If the prompt to view output is still active, kill it. PL()->AbortEdit(); char *str = Cmp->compose_arglist(); cCompare cmp; if (!cmp.parse(str)) { Log()->ErrorLog(mh::Processing, Errs()->get_error()); delete [] str; return; } if (!cmp.setup()) { Log()->ErrorLog(mh::Processing, Errs()->get_error()); delete [] str; return; } dspPkgIf()->SetWorking(true); DFtype df = cmp.compare(); dspPkgIf()->SetWorking(false); if (df == DFabort) PL()->ShowPrompt("Comparison aborted."); else if (df == DFerror) PL()->ShowPromptV("Comparison failed: %s", Errs()->get_error()); else { char buf[256]; if (df == DFsame) { sprintf(buf, "No differences found, see file \"%s\".", DIFF_LOG_FILE); PL()->ShowPrompt(buf); } else { sprintf(buf, "Differences found, data written to " "file \"%s\", view file? [y] ", DIFF_LOG_FILE); char *in = PL()->EditPrompt(buf, "y"); in = lstring::strip_space(in); if (in && (*in == 'y' || *in == 'Y')) DSPmainWbag(PopUpFileBrowser(DIFF_LOG_FILE)) PL()->ErasePrompt(); } } delete [] str; return; } if (caller == Cmp->cmp_layer_use) { if (GRX->GetStatus(caller)) GRX->SetStatus(Cmp->cmp_layer_skip, false); if (GRX->GetStatus(Cmp->cmp_layer_use) || GRX->GetStatus(Cmp->cmp_layer_skip)) gtk_widget_set_sensitive(Cmp->cmp_layer_list, true); else gtk_widget_set_sensitive(Cmp->cmp_layer_list, false); return; } if (caller == Cmp->cmp_layer_skip) { if (GRX->GetStatus(caller)) GRX->SetStatus(Cmp->cmp_layer_use, false); if (GRX->GetStatus(Cmp->cmp_layer_use) || GRX->GetStatus(Cmp->cmp_layer_skip)) gtk_widget_set_sensitive(Cmp->cmp_layer_list, true); else gtk_widget_set_sensitive(Cmp->cmp_layer_list, false); return; } if (caller == Cmp->cmp_p3_aoi_use) { if (GRX->GetStatus(caller)) { Cmp->sb_p3_aoi_left.set_sensitive(true); Cmp->sb_p3_aoi_bottom.set_sensitive(true); Cmp->sb_p3_aoi_right.set_sensitive(true); Cmp->sb_p3_aoi_top.set_sensitive(true); } else { Cmp->sb_p3_aoi_left.set_sensitive(false); Cmp->sb_p3_aoi_bottom.set_sensitive(false); Cmp->sb_p3_aoi_right.set_sensitive(false); Cmp->sb_p3_aoi_top.set_sensitive(false); } } } // Static function. void sCmp::cmp_p1_action(GtkWidget *caller, void *arg) { if (Cmp) { if (arg == (void*)1L) { if (GRX->GetStatus(caller)) Cvt()->PopUpPropertyFilter(caller, MODE_ON); else Cvt()->PopUpPropertyFilter(caller, MODE_OFF); return; } Cmp->p1_sens(); } } // Static function. void sCmp::cmp_p1_fltr_proc(GtkWidget*, void *arg) { if (!Cmp) return; long n = (long)arg; if (n == 1) Cmp->cmp_p1_fltr_mode = PrpFltNone; else if (n == 2) Cmp->cmp_p1_fltr_mode = PrpFltCstm; else Cmp->cmp_p1_fltr_mode = PrpFltDflt; } namespace { // Positioning function for pop-up menus. // void pos_func(GtkMenu*, int *x, int *y, gboolean *pushin, void *data) { *pushin = true; GtkWidget *btn = GTK_WIDGET(data); GRX->Location(btn, x, y); } } // Static function. // Button-press handler to produce pop-up menu. // int sCmp::cmp_popup_btn_proc(GtkWidget *widget, GdkEvent *event, void *arg) { gtk_menu_popup(GTK_MENU(arg), 0, 0, pos_func, widget, event->button.button, event->button.time); return (true); } // Static function. void sCmp::cmp_sto_menu_proc(GtkWidget *widget, void *arg) { sCmp *cmp = (sCmp*)arg; const char *name = gtk_widget_get_name(widget); if (name && cmp) { while (*name) { if (isdigit(*name)) break; name++; } if (isdigit(*name)) cmp->get_bb(FIO()->savedBB(*name - '0')); } } // Static function. void sCmp::cmp_rcl_menu_proc(GtkWidget *widget, void *arg) { sCmp *cmp = (sCmp*)arg; const char *name = gtk_widget_get_name(widget); if (name && cmp) { while (*name) { if (isdigit(*name)) break; name++; } if (isdigit(*name)) cmp->set_bb(FIO()->savedBB(*name - '0')); } } // Private static GTK signal handler. // Drag data received in entry area, deal accordingly. // void sCmp::cmp_drag_data_received(GtkWidget *entry, GdkDragContext *context, gint, gint, GtkSelectionData *data, guint, guint time) { if (Cmp && data->length >= 0 && data->format == 8 && data->data) { char *src = (char*)data->data; char *t = 0; if (data->target == gdk_atom_intern("TWOSTRING", true)) { // Drops from content lists may be in the form // "fname_or_chd\ncellname". t = strchr(src, '\n'); } if (entry == Cmp->cmp_fname1 || entry == Cmp->cmp_fname2) { if (t) *t = 0; gtk_entry_set_text(GTK_ENTRY(entry), src); } else if (entry == Cmp->cmp_cnames1 || entry == Cmp->cmp_cnames2) { if (t) src = t+1; // Add new cell name to end of existing text. sLstr lstr; lstr.add(gtk_entry_get_text(GTK_ENTRY(entry))); if (lstr.string() && *lstr.string()) lstr.add_c(' '); lstr.add(src); gtk_entry_set_text(GTK_ENTRY(entry), lstr.string()); } gtk_drag_finish(context, true, false, time); // The concatenation behavior above is unique, and opened a // can of worms in GTK-2. The problem is that the GtkEntry // will call its own data-received handler before calling // this one, or call this one twice, if this handler is // connect-after. Various changes were made to fight this: // // 1. Don't set GTK_DEST_DEFAULT_DROP. This avoids a // double call of this handler for targets not handled by // the internal handler. The internal handler takes only // the plain text targets. // // 2. Use local targets preferentially by putting such // targets as TWOSTRING and CELLNAME at the beginning of // the targets lists. // // 3. Still, a plain text drop would cause trouble. This // was finally resolved by not using connect-after, and // adding the emit_stop call below. // gtk_signal_emit_stop_by_name(GTK_OBJECT(entry), "drag-data-received"); return; } gtk_drag_finish(context, false, false, time); } // End of sCmp functions. sCmp_store::sCmp_store() { cs_file1 = 0; cs_file2 = 0; cs_cells1 = 0; cs_cells2 = 0; cs_layers = 0; cs_mode = 0; cs_layer_only = false; cs_layer_skip = false; cs_differ = false; cs_max_errs = 0; cs_p1_recurse = false; cs_p1_expand_arrays = false; cs_p1_slop = false; cs_p1_dups = false; cs_p1_boxes = true; cs_p1_polys = true; cs_p1_wires = true; cs_p1_labels = false; cs_p1_insta = true; cs_p1_boxes_prp = false; cs_p1_polys_prp = false; cs_p1_wires_prp = false; cs_p1_labels_prp = false; cs_p1_insta_prp = false; cs_p1_elec = false; cs_p1_cell_prp = false; cs_p1_fltr = 0; cs_p2_recurse = false; cs_p2_expand_arrays = false; cs_p2_insta = false; cs_p3_use_window = false; cs_p3_left = 0.0; cs_p3_bottom = 0.0; cs_p3_right = 0.0; cs_p3_top = 0.0; cs_p3_fine_grid = 20; cs_p3_coarse_mult = 20; } sCmp_store::~sCmp_store() { delete [] cs_file1; delete [] cs_file2; delete [] cs_cells1; delete [] cs_cells2; delete [] cs_layers; } void sCmp_store::save() { if (!Cmp) return; delete [] cs_file1; cs_file1 = lstring::copy(gtk_entry_get_text(GTK_ENTRY(Cmp->cmp_fname1))); delete [] cs_file2; cs_file2 = lstring::copy(gtk_entry_get_text(GTK_ENTRY(Cmp->cmp_fname2))); delete [] cs_cells1; cs_cells1 = lstring::copy(gtk_entry_get_text(GTK_ENTRY(Cmp->cmp_cnames1))); delete [] cs_cells2; cs_cells2 = lstring::copy(gtk_entry_get_text(GTK_ENTRY(Cmp->cmp_cnames2))); delete [] cs_layers; cs_layers = lstring::copy( gtk_entry_get_text(GTK_ENTRY(Cmp->cmp_layer_list))); cs_mode = gtk_notebook_current_page(GTK_NOTEBOOK(Cmp->cmp_mode)); cs_layer_only = GRX->GetStatus(Cmp->cmp_layer_use); cs_layer_skip = GRX->GetStatus(Cmp->cmp_layer_skip); cs_differ = GRX->GetStatus(Cmp->cmp_diff_only); cs_max_errs = Cmp->sb_max_errs.get_value_as_int(); if (Cmp->cmp_p1_recurse) { cs_p1_recurse = GRX->GetStatus(Cmp->cmp_p1_recurse); cs_p1_expand_arrays = GRX->GetStatus(Cmp->cmp_p1_expand_arrays); cs_p1_slop = GRX->GetStatus(Cmp->cmp_p1_slop); cs_p1_dups = GRX->GetStatus(Cmp->cmp_p1_dups); cs_p1_boxes = GRX->GetStatus(Cmp->cmp_p1_boxes); cs_p1_polys = GRX->GetStatus(Cmp->cmp_p1_polys); cs_p1_wires = GRX->GetStatus(Cmp->cmp_p1_wires); cs_p1_labels = GRX->GetStatus(Cmp->cmp_p1_labels); cs_p1_insta = GRX->GetStatus(Cmp->cmp_p1_insta); cs_p1_boxes_prp = GRX->GetStatus(Cmp->cmp_p1_boxes_prp); cs_p1_polys_prp = GRX->GetStatus(Cmp->cmp_p1_polys_prp); cs_p1_wires_prp = GRX->GetStatus(Cmp->cmp_p1_wires_prp); cs_p1_labels_prp = GRX->GetStatus(Cmp->cmp_p1_labels_prp); cs_p1_insta_prp = GRX->GetStatus(Cmp->cmp_p1_insta_prp); cs_p1_elec = GRX->GetStatus(Cmp->cmp_p1_elec); cs_p1_cell_prp = GRX->GetStatus(Cmp->cmp_p1_cell_prp); cs_p1_fltr = Cmp->cmp_p1_fltr_mode; } if (Cmp->cmp_p2_recurse) { cs_p2_recurse = GRX->GetStatus(Cmp->cmp_p2_recurse); cs_p2_expand_arrays = GRX->GetStatus(Cmp->cmp_p2_expand_arrays); cs_p2_insta = GRX->GetStatus(Cmp->cmp_p2_insta); } if (Cmp->cmp_p3_aoi_use) { cs_p3_use_window = GRX->GetStatus(Cmp->cmp_p3_aoi_use); cs_p3_left = Cmp->sb_p3_aoi_left.get_value(); cs_p3_bottom = Cmp->sb_p3_aoi_bottom.get_value(); cs_p3_right = Cmp->sb_p3_aoi_right.get_value(); cs_p3_top = Cmp->sb_p3_aoi_top.get_value(); cs_p3_fine_grid = Cmp->sb_p3_fine_grid.get_value_as_int(); cs_p3_coarse_mult = Cmp->sb_p3_coarse_mult.get_value_as_int(); } } void sCmp_store::recall() { if (!Cmp) return; gtk_entry_set_text(GTK_ENTRY(Cmp->cmp_fname1), cs_file1 ? cs_file1 : ""); gtk_entry_set_text(GTK_ENTRY(Cmp->cmp_fname2), cs_file2 ? cs_file2 : ""); gtk_entry_set_text(GTK_ENTRY(Cmp->cmp_cnames1), cs_cells1 ? cs_cells1 : ""); gtk_entry_set_text(GTK_ENTRY(Cmp->cmp_cnames2), cs_cells2 ? cs_cells2 : ""); gtk_entry_set_text(GTK_ENTRY(Cmp->cmp_layer_list), cs_layers ? cs_layers : ""); gtk_notebook_set_page(GTK_NOTEBOOK(Cmp->cmp_mode), cs_mode); GRX->SetStatus(Cmp->cmp_layer_use, cs_layer_only); GRX->SetStatus(Cmp->cmp_layer_skip, cs_layer_skip); GRX->SetStatus(Cmp->cmp_diff_only, cs_differ); Cmp->sb_max_errs.set_value(cs_max_errs); gtk_widget_set_sensitive(Cmp->cmp_layer_list, cs_layer_only || cs_layer_skip); } void sCmp_store::recall_p1() { if (!Cmp) return; if (Cmp->cmp_p1_recurse) { GRX->SetStatus(Cmp->cmp_p1_recurse, cs_p1_recurse); GRX->SetStatus(Cmp->cmp_p1_expand_arrays, cs_p1_expand_arrays); GRX->SetStatus(Cmp->cmp_p1_slop, cs_p1_slop); GRX->SetStatus(Cmp->cmp_p1_dups, cs_p1_dups); GRX->SetStatus(Cmp->cmp_p1_boxes, cs_p1_boxes); GRX->SetStatus(Cmp->cmp_p1_polys, cs_p1_polys); GRX->SetStatus(Cmp->cmp_p1_wires, cs_p1_wires); GRX->SetStatus(Cmp->cmp_p1_labels, cs_p1_labels); GRX->SetStatus(Cmp->cmp_p1_insta, cs_p1_insta); GRX->SetStatus(Cmp->cmp_p1_boxes_prp, cs_p1_boxes_prp); GRX->SetStatus(Cmp->cmp_p1_polys_prp, cs_p1_polys_prp); GRX->SetStatus(Cmp->cmp_p1_wires_prp, cs_p1_wires_prp); GRX->SetStatus(Cmp->cmp_p1_labels_prp, cs_p1_labels_prp); GRX->SetStatus(Cmp->cmp_p1_insta_prp, cs_p1_insta_prp); GRX->SetStatus(Cmp->cmp_p1_phys, !cs_p1_elec); GRX->SetStatus(Cmp->cmp_p1_elec, cs_p1_elec); GRX->SetStatus(Cmp->cmp_p1_cell_prp, cs_p1_cell_prp); gtk_option_menu_set_history(GTK_OPTION_MENU(Cmp->cmp_p1_fltr), cs_p1_fltr); } } void sCmp_store::recall_p2() { if (!Cmp) return; if (Cmp->cmp_p2_recurse) { GRX->SetStatus(Cmp->cmp_p2_recurse, cs_p2_recurse); GRX->SetStatus(Cmp->cmp_p2_expand_arrays, cs_p2_expand_arrays); GRX->SetStatus(Cmp->cmp_p2_insta, cs_p2_insta); } } void sCmp_store::recall_p3() { if (!Cmp) return; if (Cmp->cmp_p3_aoi_use) { GRX->SetStatus(Cmp->cmp_p3_aoi_use, cs_p3_use_window); Cmp->sb_p3_aoi_left.set_value(cs_p3_left); Cmp->sb_p3_aoi_bottom.set_value(cs_p3_bottom); Cmp->sb_p3_aoi_right.set_value(cs_p3_right); Cmp->sb_p3_aoi_top.set_value(cs_p3_top); Cmp->sb_p3_fine_grid.set_value(cs_p3_fine_grid); Cmp->sb_p3_coarse_mult.set_value(cs_p3_coarse_mult); Cmp->sb_p3_aoi_left.set_sensitive(cs_p3_use_window); Cmp->sb_p3_aoi_bottom.set_sensitive(cs_p3_use_window); Cmp->sb_p3_aoi_right.set_sensitive(cs_p3_use_window); Cmp->sb_p3_aoi_top.set_sensitive(cs_p3_use_window); } } // End of sCmp_store functions.
33.556527
80
0.610979
bernardventer
0e443c012b83e9cc6616a6217d523238a588954e
3,572
cpp
C++
rs_gl.cpp
darkedge/rasterizer
c0384e97afb847173d446d6ad499c6d5d6f055e6
[ "MIT" ]
null
null
null
rs_gl.cpp
darkedge/rasterizer
c0384e97afb847173d446d6ad499c6d5d6f055e6
[ "MIT" ]
null
null
null
rs_gl.cpp
darkedge/rasterizer
c0384e97afb847173d446d6ad499c6d5d6f055e6
[ "MIT" ]
null
null
null
#include <malloc.h> #include "glad/glad.h" #include <GLFW/glfw3.h> #include <stdio.h> #include <assert.h> #include "rs_gl.h" static unsigned int framebufferTexID[2]; static GLuint fbPBO[2]; static Texture texture; static int index; void CheckOpenGLError(const char* expr, const char* fname, int line) { GLenum err = glGetError(); if (err != GL_NO_ERROR) { printf("OpenGL error %08x, at %s:%i - for %s\n", err, fname, line, expr); } } #ifdef _DEBUG #define GL_TRY(expr) do { \ expr; \ CheckOpenGLError(#expr, __FILE__, __LINE__); \ } while (0) #else #define GL_TRY(expr) expr #endif Texture gl::GetTexture() { return texture; } unsigned char* ResizeTexturesAndBuffers(int width, int height) { glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0); for (int i = 0; i < 2; i++) { GL_TRY(glBindTexture(GL_TEXTURE_2D, framebufferTexID[i])); GL_TRY(glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL)); } GL_TRY(glBindTexture(GL_TEXTURE_2D, 0)); const int sizeMemory = 4 * width * height; GL_TRY(glBindBuffer(GL_PIXEL_UNPACK_BUFFER, fbPBO[0])); GL_TRY(glBufferData(GL_PIXEL_UNPACK_BUFFER, sizeMemory, NULL, GL_STREAM_DRAW)); GL_TRY(glBindBuffer(GL_PIXEL_UNPACK_BUFFER, fbPBO[1])); GL_TRY(glBufferData(GL_PIXEL_UNPACK_BUFFER, sizeMemory, NULL, GL_STREAM_DRAW)); GL_TRY(glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0)); GL_TRY(glBindTexture(GL_TEXTURE_2D, framebufferTexID[0])); GL_TRY(glBindBuffer(GL_PIXEL_UNPACK_BUFFER, fbPBO[0])); unsigned char* framedata = (unsigned char*)glMapBuffer(GL_PIXEL_UNPACK_BUFFER, GL_WRITE_ONLY); if (!framedata) return NULL; return framedata; } bool gl::Init(int width, int height) { if (!gladLoadGLLoader((GLADloadproc)glfwGetProcAddress)) { return false; } // TODO: Destroy glGenTextures(2, framebufferTexID); for (int i = 0; i < 2; i++) { glBindTexture(GL_TEXTURE_2D, framebufferTexID[i]); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP); glBindTexture(GL_TEXTURE_2D, 0); if (glGetError()) return false; } glGenBuffers(2, fbPBO); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(0, 1, 0, 1, -1, 1); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glEnable(GL_TEXTURE_2D); Resize(width, height); return true; } bool gl::Resize(int width, int height) { texture.width = width; texture.height = height; texture.numComponents = 4; texture.data = ResizeTexturesAndBuffers(width, height); glViewport(0, 0, width, height); return true; } void gl::Render() { glUnmapBuffer(GL_PIXEL_UNPACK_BUFFER); glBindTexture(GL_TEXTURE_2D, framebufferTexID[index]); glBindBuffer(GL_PIXEL_UNPACK_BUFFER, fbPBO[index]); glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, texture.width, texture.height, GL_BGRA, GL_UNSIGNED_BYTE, 0); index ^= 1; glBindBuffer(GL_PIXEL_UNPACK_BUFFER, fbPBO[index]); texture.data = (unsigned char*)glMapBuffer(GL_PIXEL_UNPACK_BUFFER, GL_WRITE_ONLY); glBegin(GL_QUADS); glTexCoord2f(0.0f, 0.0f); glVertex2f(0.0f, 1.0f); glTexCoord2f(1.0f, 0.0f); glVertex2f(1.0f, 1.0f); glTexCoord2f(1.0f, 1.0f); glVertex2f(1.0f, 0.0f); glTexCoord2f(0.0f, 1.0f); glVertex2f(0.0f, 0.0f); glEnd(); }
31.06087
107
0.694289
darkedge
0e44f3266eaf12d191036ed2058a925a74a07a94
188
cpp
C++
Array1.cpp
csdeptku/Python-for-cpp-programmers
6fcca9afc6df1e40a1554d5fa4c4d57dbc50b7e6
[ "Apache-2.0" ]
null
null
null
Array1.cpp
csdeptku/Python-for-cpp-programmers
6fcca9afc6df1e40a1554d5fa4c4d57dbc50b7e6
[ "Apache-2.0" ]
null
null
null
Array1.cpp
csdeptku/Python-for-cpp-programmers
6fcca9afc6df1e40a1554d5fa4c4d57dbc50b7e6
[ "Apache-2.0" ]
null
null
null
//Arrays #include <iostream> using namespace std; int main() { int A[10] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9} ; for(int i = 0; i < 10; i++){ cout<<A[i]<<endl; } return 0; }
15.666667
48
0.478723
csdeptku
0e4b40e2a6f1f4e277827bad64996e31326a798a
619
cpp
C++
source/tvision/nmdirbox.cpp
gpaulsen/tvision
638f963fe4f6c84854f60f1e9c5772bf6603e4b2
[ "MIT" ]
1,202
2020-05-10T18:43:45.000Z
2022-03-31T18:23:27.000Z
source/tvision/nmdirbox.cpp
skywind3000/tvision
7ab5f195c572de0d496e92f4e3f7b3b0771ac699
[ "MIT" ]
54
2020-05-10T17:36:55.000Z
2022-03-15T12:22:07.000Z
source/tvision/nmdirbox.cpp
skywind3000/tvision
7ab5f195c572de0d496e92f4e3f7b3b0771ac699
[ "MIT" ]
90
2020-06-28T13:51:47.000Z
2022-03-26T21:00:17.000Z
/*------------------------------------------------------------*/ /* filename - nmdirbox.cpp */ /* */ /* defines the streamable name for class TDirListBox */ /*------------------------------------------------------------*/ /* * Turbo Vision - Version 2.0 * * Copyright (c) 1994 by Borland International * All Rights Reserved. * */ #if !defined(NO_STREAMABLE) #define Uses_TDirListBox #include <tvision/tv.h> const char * const _NEAR TDirListBox::name = "TDirListBox"; #endif
30.95
65
0.397415
gpaulsen
0e4dad05a7cedca437ee435d7a51599354d686cb
657
cpp
C++
Game winkel & Autohuur/Autohuur/Main.cpp
hassoonsy2/High-Performance-Programming
7407da7f53546bd136b313d9055505ad0848d19b
[ "MIT" ]
null
null
null
Game winkel & Autohuur/Autohuur/Main.cpp
hassoonsy2/High-Performance-Programming
7407da7f53546bd136b313d9055505ad0848d19b
[ "MIT" ]
null
null
null
Game winkel & Autohuur/Autohuur/Main.cpp
hassoonsy2/High-Performance-Programming
7407da7f53546bd136b313d9055505ad0848d19b
[ "MIT" ]
null
null
null
#include <iostream> #include "AutoHuur.hpp" #include "Auto.hpp" #include "Klant.hpp" int main() { Klant k("Mijnheer de Vries"); k.set_korting_percentage(10.0); Auto a1("Peugeot 207", 50); AutoHuur ah1(a1, k, 4); std::cout << "Eerste autohuur:"<< ah1 <<endl; std::cout << endl; Auto a2("Ferrari", 3500); AutoHuur ah2(a1, k, 10); ah2.set_gehuurde_auto(a2); ah2.set_aantal_dagen(1); std::cout << "Tweede autohuur: "<< ah2 << endl; std::cout << endl; std::cout << "Gehuurd: " << ah1.get_gehuurde_auto()<< endl; std::cout << "Gehuurd: " << ah2.get_gehuurde_auto()<< endl; return 0; };
24.333333
63
0.585997
hassoonsy2
0e559ebeb552dc9bcaf053bf1111f032533f7ead
5,717
cpp
C++
Engine/Terrain/TerrainData.cpp
gaspardpetit/INF740-GameEngine
075b6563204fb3d1cf7531599f30dd296c2c9239
[ "Apache-2.0" ]
null
null
null
Engine/Terrain/TerrainData.cpp
gaspardpetit/INF740-GameEngine
075b6563204fb3d1cf7531599f30dd296c2c9239
[ "Apache-2.0" ]
null
null
null
Engine/Terrain/TerrainData.cpp
gaspardpetit/INF740-GameEngine
075b6563204fb3d1cf7531599f30dd296c2c9239
[ "Apache-2.0" ]
1
2015-09-25T22:24:16.000Z
2015-09-25T22:24:16.000Z
#include "Precompiled.h" #include "TerrainData.h" #include "Import/Images/OLEImageImporter.h" #include "Core/GameManagers/IRenderManager.h" #include "Core/GameManagers/ISimulationManager.h" #include "Core/Game/Game.h" #include "Core/Logging/Logger.h" #include <d3d9.h> using namespace physx; namespace engine { //----------------------------------------------------------------------------- // unsigned char LinearInterpolate(int val, int iMin, int iMax, int oMin, int oMax) { return (val-iMin)*(oMax-oMin)/(iMax-iMin) + oMin; } //----------------------------------------------------------------------------- // unsigned int ColorForHeight(unsigned char height) { int r, g, b; if (height > 235) { r = g = b = height; } else if (height > 200) { r = LinearInterpolate(height, 200, 235, 150, 235); g = 235; b = LinearInterpolate(height, 200, 235, 150, 235); } else if (height > 160) { r = 150; g = LinearInterpolate(height, 160, 200, 150, 235); b = 150; } else if (height > 80) { r = LinearInterpolate(height, 80, 160, 200, 150); g = LinearInterpolate(height, 80, 160, 200, 150); b = LinearInterpolate(height, 80, 160, 80, 150); } else { r = LinearInterpolate(height, 0, 80, 32, 200); g = LinearInterpolate(height, 0, 80, 32, 200); b = LinearInterpolate(height, 0, 80, 16, 80); } return D3DCOLOR_XRGB(r, g, b); } int TerrainData::load() { static const TCHAR *kHeightPixMapFile = heightMapFile(); _renderData._scale = heightMapScale(); // Load the image file std::unique_ptr<unsigned char[]> buffer; OLEImageImporter imgLoader(kHeightPixMapFile); imgLoader.getNativeSize(&_renderData._width, &_renderData._height); buffer.reset(new unsigned char [_renderData._width*_renderData._height]); imgLoader.draw(buffer.get(), OLEImageImporter::PixelFormat::FORMAT_L8); LOG_INFO("loaded %TS\n", kHeightPixMapFile); LPDIRECT3DDEVICE9 d3ddev = Game<IRenderManager>()->d3dDevice(); int verticeCount = _renderData._width*_renderData._height; // create a vertex buffer interface called _vbuffer LPDIRECT3DVERTEXBUFFER9 vbuffer; d3ddev->CreateVertexBuffer(verticeCount*sizeof(CUSTOMVERTEX), 0, CUSTOMVERTEX::FORMAT, D3DPOOL_MANAGED, &vbuffer, NULL); _renderData._vbuffer = d3d9::unique_ptr<IDirect3DVertexBuffer9>(vbuffer); CUSTOMVERTEX* pVoid; // a void pointer _heightMap = std::make_unique<physx::PxHeightFieldSample[]>(_renderData._width*_renderData._height); // lock _vbuffer and load the vertices into it _renderData._vbuffer->Lock(0, 0, (void**)&pVoid, 0); for (int y = 0; y < _renderData._height; ++y) { for (int x = 0; x < _renderData._width; ++x) { pVoid[x+y*_renderData._width].p.x = (x-_renderData._width/2.0f)/(_renderData._width-1) * _renderData._scale.x; pVoid[x+y*_renderData._width].p.y = (buffer[x+y*_renderData._width]-255.0f/2)/255.0f * _renderData._scale.y; pVoid[x+y*_renderData._width].p.z = (y-_renderData._height/2.0f)/(_renderData._height-1) * _renderData._scale.z; pVoid[x+y*_renderData._width].COLOR = ColorForHeight(buffer[x+y*_renderData._width]); } } buffer.reset(); // compute normals for (int y = 0; y < _renderData._height; ++y) { for (int x = 0; x < _renderData._width; ++x) { PxVec3 vx; if (x > 0 && x < _renderData._width-1) { vx = pVoid[(x+1)+y*_renderData._width].p - pVoid[(x-1)+y*_renderData._width].p; } else if (x > 0) { vx = pVoid[(x)+y*_renderData._width].p-pVoid[(x-1)+y*_renderData._width].p; } else if (x < _renderData._width-1) { vx = pVoid[(x+1)+y*_renderData._width].p-pVoid[(x)+y*_renderData._width].p; } PxVec3 vy; if (y > 0 && y < _renderData._height-1) { vy = pVoid[x+(y+1)*_renderData._width].p - pVoid[x+(y-1)*_renderData._width].p; } else if (y > 0) { vy = pVoid[x+(y)*_renderData._width].p - pVoid[x+(y-1)*_renderData._width].p; } else if (y < _renderData._height-1) { vy = pVoid[x+(y+1)*_renderData._width].p - pVoid[x+(y)*_renderData._width].p; } pVoid[x+y*_renderData._width].n = vy.cross(vx).getNormalized(); } } for (int y = 0; y < _renderData._height; ++y) { for (int x = 0; x < _renderData._width; ++x) { _heightMap[x*_renderData._height+y].height = PxI16(65535*pVoid[x+y*_renderData._width].p.y/_renderData._scale.y); _heightMap[x*_renderData._height+y].materialIndex0 = 0; _heightMap[x*_renderData._height+y].materialIndex1 = 0; _heightMap[x*_renderData._height+y].clearTessFlag(); } } _renderData._vbuffer->Unlock(); LPDIRECT3DINDEXBUFFER9 ibuffer; d3ddev->CreateIndexBuffer(2*_renderData._width*(_renderData._height-1)*sizeof(int), D3DUSAGE_WRITEONLY, D3DFMT_INDEX32, D3DPOOL_DEFAULT, &ibuffer, NULL); _renderData._ibuffer = d3d9::unique_ptr<IDirect3DIndexBuffer9>(ibuffer); int* pIdx; // a void pointer _renderData._ibuffer->Lock(0, 0, (VOID**)&pIdx, NULL); int i = 0; for (int y = 0; y < _renderData._height-1; ++y) { for (int x = 0; x < _renderData._width; ++x) { pIdx[i++] = x+y*_renderData._width; pIdx[i++] = x+(y+1)*_renderData._width; } } _renderData._ibuffer->Unlock(); PxPhysics &physics = Game<ISimulationManager>()->physics(); _material = physx::unique_ptr<physx::PxMaterial>(physics.createMaterial(0.5f, 0.5f, 0.1f)); //static friction, dynamic friction, restitution PxHeightFieldDesc heightMapDesc; heightMapDesc.format = PxHeightFieldFormat::eS16_TM; heightMapDesc.nbColumns = _renderData._width; heightMapDesc.nbRows = _renderData._height; heightMapDesc.samples.data = _heightMap.get(); heightMapDesc.samples.stride = sizeof(PxHeightFieldSample); _heightField = physx::unique_ptr<physx::PxHeightField>(physics.createHeightField(heightMapDesc)); return 0; } } // namespace engine
31.761111
154
0.676054
gaspardpetit
0e565285e586b0148324fd6da6155022ba25f2b3
11,663
cpp
C++
OrionUO/Target.cpp
alerdenisov/OrionUO
d0bb54ce62af68a0152edd02d94fdf92eef90d4d
[ "MIT" ]
25
2018-10-30T01:19:10.000Z
2021-06-02T15:35:49.000Z
OrionUO/Target.cpp
alerdenisov/OrionUO
d0bb54ce62af68a0152edd02d94fdf92eef90d4d
[ "MIT" ]
74
2018-10-13T00:41:32.000Z
2021-09-04T20:00:12.000Z
OrionUO/Target.cpp
alerdenisov/OrionUO
d0bb54ce62af68a0152edd02d94fdf92eef90d4d
[ "MIT" ]
20
2018-10-09T17:42:32.000Z
2022-03-26T05:57:47.000Z
// MIT License // Copyright (C) August 2016 Hotride #include "Target.h" #include "Config.h" #include "OrionUO.h" #include "Multi.h" #include "plugin/mulstruct.h" #include "plugin/commoninterfaces.h" #include "Network/Packets.h" #include "Managers/FileManager.h" #include "Managers/MouseManager.h" #include "Managers/MapManager.h" #include "Managers/CustomHousesManager.h" #include "GameObjects/GameCharacter.h" #include "GameObjects/CustomHouseMultiObject.h" #include "Gumps/GumpCustomHouse.h" CTarget g_Target; CTarget::CTarget() { //Чистимся memset(m_Data, 0, sizeof(m_Data)); memset(m_LastData, 0, sizeof(m_LastData)); } void CTarget::Reset() { DEBUG_TRACE_FUNCTION; //Чистимся memset(m_Data, 0, sizeof(m_Data)); memset(m_LastData, 0, sizeof(m_LastData)); if (m_Multi != nullptr) { delete m_Multi; m_Multi = nullptr; } Type = 0; CursorType = 0; CursorID = 0; Targeting = false; MultiGraphic = 0; } void CTarget::RequestFromCustomHouse() { Type = 2; CursorID = 0; CursorType = 0; Targeting = true; MultiGraphic = 0; if (g_CustomHouseGump != nullptr) { g_CustomHouseGump->Erasing = false; g_CustomHouseGump->SeekTile = false; g_CustomHouseGump->SelectedGraphic = 0; g_CustomHouseGump->CombinedStair = false; g_CustomHouseGump->WantUpdateContent = true; } } void CTarget::SetLastTargetObject(int serial) { Type = 0; pack32(m_LastData + 7, serial); } void CTarget::SetData(Wisp::CDataReader &reader) { DEBUG_TRACE_FUNCTION; //Копируем буффер memcpy(&m_Data[0], reader.Start, reader.Size); //И устанавливаем соответствующие значения Type = reader.ReadUInt8(); CursorID = reader.ReadUInt32BE(); CursorType = reader.ReadUInt8(); Targeting = (CursorType < 3); MultiGraphic = 0; } void CTarget::SetMultiData(Wisp::CDataReader &reader) { DEBUG_TRACE_FUNCTION; //Устанавливаем соответствующие значения Type = 1; CursorType = 0; Targeting = true; CursorID = reader.ReadUInt32BE(1); //Копируем буффер memset(&m_Data[0], 0, 19); m_Data[0] = 0x6C; m_Data[1] = 1; //Таргет на ландшафт memcpy(m_Data + 2, reader.Start + 2, 4); //Копируем ID курсора (ID дида) reader.ResetPtr(); reader.Move(18); MultiGraphic = reader.ReadUInt16BE() + 1; MultiX = reader.ReadUInt16BE(); MultiY = reader.ReadUInt16BE(); } void CTarget::SendTargetObject(int serial) { DEBUG_TRACE_FUNCTION; if (!Targeting) { return; //Если в клиенте нет таргета - выход } //Пишем серийник объекта, на который ткнули прицелом, остальное - затираем pack32(m_Data + 7, serial); m_Data[1] = 0; CGameObject *obj = (g_World != nullptr ? g_World->FindWorldObject(serial) : nullptr); if (obj != nullptr) { pack16(m_Data + 11, obj->GetX()); pack16(m_Data + 13, obj->GetY()); m_Data[15] = 0xFF; m_Data[16] = obj->GetZ(); pack16(m_Data + 17, obj->Graphic); } else { pack32(m_Data + 11, 0); pack32(m_Data + 15, 0); } if (serial != g_PlayerSerial) { g_LastTargetObject = serial; //Скопируем для LastTarget memcpy(m_LastData, m_Data, sizeof(m_Data)); if (obj != nullptr && obj->NPC && ((CGameCharacter *)obj)->MaxHits == 0) { CPacketStatusRequest(serial).Send(); } } SendTarget(); } void CTarget::SendTargetTile(uint16_t tileID, short x, short y, char z) { DEBUG_TRACE_FUNCTION; if (!Targeting) { return; //Если в клиенте нет таргета - выход } m_Data[1] = 1; //Пишем координаты и индекс тайла, на который ткнули, остальное трем pack32(m_Data + 7, 0); pack16(m_Data + 11, x); pack16(m_Data + 13, y); //m_Data[15] = 0xFF; //m_Data[16] = z; pack16(m_Data + 15, (short)z); pack16(m_Data + 17, tileID); //Скопируем для LastTarget memcpy(m_LastData, m_Data, sizeof(m_Data)); SendTarget(); } void CTarget::SendCancelTarget() { DEBUG_TRACE_FUNCTION; if (!Targeting) { return; //Если в клиенте нет таргета - выход } //Уходят только нули pack32(m_Data + 7, 0); pack32(m_Data + 11, 0xFFFFFFFF); pack32(m_Data + 15, 0); SendTarget(); if (g_CustomHouseGump != nullptr) { g_CustomHouseGump->Erasing = false; g_CustomHouseGump->SeekTile = false; g_CustomHouseGump->SelectedGraphic = 0; g_CustomHouseGump->CombinedStair = false; g_CustomHouseGump->WantUpdateContent = true; } } void CTarget::Plugin_SendTargetObject(int serial) { DEBUG_TRACE_FUNCTION; if (!Targeting) { return; //Если в клиенте нет таргета - выход } //Пишем серийник объекта, на который ткнули прицелом, остальное - затираем pack32(m_Data + 7, serial); m_Data[1] = 0; CGameObject *obj = (g_World != nullptr ? g_World->FindWorldObject(serial) : nullptr); if (obj != nullptr) { pack16(m_Data + 11, obj->GetX()); pack16(m_Data + 13, obj->GetY()); m_Data[15] = 0xFF; m_Data[16] = obj->GetZ(); pack16(m_Data + 17, obj->Graphic); } else { pack32(m_Data + 11, 0); pack32(m_Data + 15, 0); } if (serial != g_PlayerSerial) { g_LastTargetObject = serial; //Скопируем для LastTarget memcpy(m_LastData, m_Data, sizeof(m_Data)); if (obj != nullptr && obj->NPC && ((CGameCharacter *)obj)->MaxHits == 0) { CPacketStatusRequest packet(serial); UOMsg_Send(packet.Data().data(), packet.Data().size()); } } Plugin_SendTarget(); } void CTarget::Plugin_SendTargetTile(uint16_t tileID, short x, short y, char z) { DEBUG_TRACE_FUNCTION; if (!Targeting) { return; //Если в клиенте нет таргета - выход } m_Data[1] = 1; //Пишем координаты и индекс тайла, на который ткнули, остальное трем pack32(m_Data + 7, 0); pack16(m_Data + 11, x); pack16(m_Data + 13, y); //m_Data[15] = 0xFF; //m_Data[16] = z; pack16(m_Data + 15, (short)z); pack16(m_Data + 17, tileID); //Скопируем для LastTarget memcpy(m_LastData, m_Data, sizeof(m_Data)); Plugin_SendTarget(); } void CTarget::Plugin_SendCancelTarget() { DEBUG_TRACE_FUNCTION; if (!Targeting) { return; //Если в клиенте нет таргета - выход } //Уходят только нули pack32(m_Data + 7, 0); pack32(m_Data + 11, 0xFFFFFFFF); pack32(m_Data + 15, 0); Plugin_SendTarget(); } void CTarget::SendLastTarget() { DEBUG_TRACE_FUNCTION; if (!Targeting) { return; //Если в клиенте нет таргета - выход } //Восстановим пакет последнего актуального таргета memcpy(m_Data, m_LastData, sizeof(m_Data)); m_Data[0] = 0x6C; m_Data[1] = Type; m_Data[6] = CursorType; pack32(m_Data + 2, CursorID); SendTarget(); } void CTarget::SendTarget() { DEBUG_TRACE_FUNCTION; if (Type != 2) { g_Orion.Send(m_Data, sizeof(m_Data)); } memset(m_Data, 0, sizeof(m_Data)); Targeting = false; MultiGraphic = 0; g_MouseManager.CancelDoubleClick = true; } void CTarget::Plugin_SendTarget() { DEBUG_TRACE_FUNCTION; UOMsg_Send(m_Data, sizeof(m_Data)); memset(m_Data, 0, sizeof(m_Data)); Targeting = false; MultiGraphic = 0; g_MouseManager.CancelDoubleClick = true; } void CTarget::UnloadMulti() { DEBUG_TRACE_FUNCTION; if (m_Multi != nullptr) { delete m_Multi; m_Multi = nullptr; } } void CTarget::LoadMulti(int offsetX, int offsetY, char offsetZ) { DEBUG_TRACE_FUNCTION; UnloadMulti(); CIndexMulti &index = g_Orion.m_MultiDataIndex[MultiGraphic - 1]; int count = (int)index.Count; if (index.UopBlock != nullptr) { vector<uint8_t> data = g_FileManager.m_MultiCollection.GetData(*index.UopBlock); if (data.empty()) { return; } Wisp::CDataReader reader(&data[0], data.size()); reader.Move(8); //ID + Count for (int i = 0; i < count; i++) { uint16_t graphic = reader.ReadUInt16LE(); short x = reader.ReadInt16LE(); short y = reader.ReadInt16LE(); short z = reader.ReadInt16LE(); uint16_t flags = reader.ReadUInt16LE(); uint32_t clilocsCount = reader.ReadUInt32LE(); if (clilocsCount != 0u) { reader.Move(clilocsCount * 4); } CMultiObject *mo = new CMultiObject(graphic, x + offsetX, y + offsetY, (char)z + (char)offsetZ, 2); g_MapManager.AddRender(mo); AddMultiObject(mo); } } else if (index.Address != 0) { int itemOffset = sizeof(MULTI_BLOCK); if (g_Config.ClientVersion >= CV_7090) { itemOffset = sizeof(MULTI_BLOCK_NEW); } for (int j = 0; j < count; j++) { MULTI_BLOCK *pmb = (MULTI_BLOCK *)(index.Address + (j * itemOffset)); CMultiObject *mo = new CMultiObject( pmb->ID, offsetX + pmb->X, offsetY + pmb->Y, offsetZ + (char)pmb->Z, 2); g_MapManager.AddRender(mo); AddMultiObject(mo); } } } void CTarget::AddMultiObject(CMultiObject *obj) { DEBUG_TRACE_FUNCTION; if (m_Multi == nullptr) { m_Multi = new CMulti(obj->GetX(), obj->GetY()); m_Multi->m_Next = nullptr; m_Multi->m_Prev = nullptr; m_Multi->m_Items = obj; obj->m_Next = nullptr; obj->m_Prev = nullptr; } else { CMulti *multi = GetMultiAtXY(obj->GetX(), obj->GetY()); if (multi != nullptr) { QFOR(multiobj, multi->m_Items, CMultiObject *) { if (obj->GetZ() < multiobj->GetZ()) { if (multiobj->m_Prev == nullptr) { multi->Insert(multiobj->m_Prev, obj); } else { multi->Insert(multiobj, obj); } return; } if (multiobj->m_Next == nullptr) { multiobj->m_Next = obj; obj->m_Prev = multiobj; obj->m_Next = nullptr; return; } } //Если пришли сюда - что-то пошло не так } else { // FIXME: potential leak, validate CMulti *newmulti = new CMulti(obj->GetX(), obj->GetY()); newmulti->m_Next = nullptr; newmulti->m_Items = obj; obj->m_Next = nullptr; obj->m_Prev = nullptr; multi = m_Multi; while (multi != nullptr) { if (multi->m_Next == nullptr) { multi->m_Next = newmulti; newmulti->m_Prev = multi; break; } multi = (CMulti *)multi->m_Next; } } } } CMulti *CTarget::GetMultiAtXY(short x, short y) { DEBUG_TRACE_FUNCTION; CMulti *multi = m_Multi; while (multi != nullptr) { if (multi->X == x && multi->Y == y) { break; } multi = (CMulti *)multi->m_Next; } return multi; }
23.466801
96
0.564606
alerdenisov
0e569d184eb0be9e8e7d3fb5caad65fa55994e77
3,573
hpp
C++
X11/context.hpp
beProsto/OWL
8fbb64a65eebd5c51395a646695ed4ea5e4e82a5
[ "BSD-2-Clause-FreeBSD" ]
2
2021-05-23T05:56:19.000Z
2021-08-17T11:40:00.000Z
X11/context.hpp
beProsto/OWL
8fbb64a65eebd5c51395a646695ed4ea5e4e82a5
[ "BSD-2-Clause-FreeBSD" ]
2
2020-01-04T14:18:04.000Z
2021-11-26T06:47:16.000Z
X11/context.hpp
beProsto/OWL
8fbb64a65eebd5c51395a646695ed4ea5e4e82a5
[ "BSD-2-Clause-FreeBSD" ]
null
null
null
#ifndef _OWL_X11_CONTEXT_HPP_HEADER_FILE_GUARD #define _OWL_X11_CONTEXT_HPP_HEADER_FILE_GUARD #include "X11.hpp" namespace OWL { namespace X11 { #define OWL_X11_WINDOW_EVENT_MASKS ExposureMask | ButtonPressMask | ButtonReleaseMask | EnterWindowMask | LeaveWindowMask | PointerMotionMask | PointerMotionHintMask | Button1MotionMask | Button2MotionMask | Button3MotionMask | Button4MotionMask | Button5MotionMask | ButtonMotionMask | KeymapStateMask | KeyPressMask | KeyReleaseMask class Context { public: Context() { } ~Context() { } public: virtual unsigned int GetType() const { return ContextType_Unknown; } protected: virtual bool Create(::Display* _display, int* _screenID, ::Window* _section, const Vec2<int>& _position, const Vec2<unsigned int>& _size) { return false; } virtual void Destroy() { } friend class Window; }; class SoftwareContext: public Context { public: SoftwareContext() { m_Created = false; } ~SoftwareContext() { if(m_Created) { delete[] m_Data; } } public: SoftwareContext& Resize(const Vec2<unsigned int>& _newSize) { if(m_Size != _newSize) { m_Size = _newSize; delete[] m_Data; m_Data = new char[m_Size.x * m_Size.y * 4]; XFree(m_Image); m_Image = XCreateImage(m_Display, m_Visual, DefaultDepth(m_Display, *m_ScreenID), ZPixmap, 0, m_Data, m_Size.x, m_Size.y, 32, 0); } return *this; } SoftwareContext& Clear(const Vec4<char>& _color = Vec4<char>(0)) { for(size_t i = 0; i < m_Size.x * m_Size.y * 4; i+=4) { m_Data[i] = _color.r; /* red */ m_Data[i+1] = _color.g; /* green */ m_Data[i+2] = _color.b; /* blue */ m_Data[i+3] = _color.a; /* alpha */ } return *this; } SoftwareContext& BlitToScreen() { /* Our data is in RGBA format, but Xlib requires BGRA format for some reason */ /* We have to swap red and blue */ for(size_t i = 0; i < m_Size.x * m_Size.y * 4; i += 4) { char red = m_Data[i]; m_Data[i] = m_Data[i+2]; /* blue */ m_Data[i+2] = red; /* red */ } XPutImage(m_Display, *m_Section, DefaultGC(m_Display, *m_ScreenID), m_Image, 0, 0, 0, 0, m_Size.x, m_Size.y); return *this; } Vec4<char>* GetPixelData() { return (Vec4<char>*)m_Data; } const Vec2<unsigned int>& GetSize() const { return m_Size; } unsigned int GetType() const { return ContextType_Software; } protected: bool Create(::Display* _display, int* _screenID, ::Window* _section, const Vec2<int>& _position, const Vec2<unsigned int>& _size) { if(!m_Created) { m_Display = _display; m_ScreenID = _screenID; m_Section = _section; m_Size = _size; m_Visual = DefaultVisual(m_Display, *m_ScreenID); m_Data = new char[m_Size.x * m_Size.y * 4]; m_Image = XCreateImage(m_Display, m_Visual, DefaultDepth(m_Display, *m_ScreenID), ZPixmap, 0, m_Data, m_Size.x, m_Size.y, 32, 0); *m_Section = XCreateSimpleWindow(m_Display, RootWindow(m_Display, *m_ScreenID), _position.x, _position.y, m_Size.x, m_Size.y, 1, 0, 0); XSelectInput(m_Display, *m_Section, OWL_X11_WINDOW_EVENT_MASKS); XMapWindow(m_Display, *m_Section); m_Created = true; return true; } else { Debug::Out::Print("Context being created when it already was!\n", Debug::Out::Type::ERR); return false; } } void Destroy() { if(m_Created) { XFree(m_Image); } } friend class Window; protected: ::Visual* m_Visual; ::XImage* m_Image; char* m_Data; bool m_Created; ::Display* m_Display; int* m_ScreenID; ::Window* m_Section; Vec2<unsigned int> m_Size; friend class Window; }; } } #endif/*_OWL_X11_CONTEXT_HPP_HEADER_FILE_GUARD*/
25.340426
334
0.687098
beProsto
0e61f46ba4dc28116f1ac24dfda96567d302d2a6
4,792
cc
C++
src/pks/flow/Darcy_TI.cc
ajkhattak/amanzi
fed8cae6af3f9dfa5984381d34b98401c3b47655
[ "RSA-MD" ]
1
2021-02-23T18:34:47.000Z
2021-02-23T18:34:47.000Z
src/pks/flow/Darcy_TI.cc
ajkhattak/amanzi
fed8cae6af3f9dfa5984381d34b98401c3b47655
[ "RSA-MD" ]
null
null
null
src/pks/flow/Darcy_TI.cc
ajkhattak/amanzi
fed8cae6af3f9dfa5984381d34b98401c3b47655
[ "RSA-MD" ]
null
null
null
/* Flow PK Copyright 2010-201x held jointly by LANS/LANL, LBNL, and PNNL. Amanzi is released under the three-clause BSD License. The terms of use and "as is" disclaimer for this license are provided in the top-level COPYRIGHT file. Author: Konstantin Lipnikov (lipnikov@lanl.gov) */ #include "Darcy_PK.hh" namespace Amanzi { namespace Flow { /* ****************************************************************** * Calculate f(u, du/dt) = A*u - rhs. ****************************************************************** */ void Darcy_PK::FunctionalResidual( double t_old, double t_new, Teuchos::RCP<TreeVector> u_old, Teuchos::RCP<TreeVector> u_new, Teuchos::RCP<TreeVector> f) { dt_ = t_new - t_old; // refresh data UpdateSourceBoundaryData(t_old, t_new, *u_new->Data()); // calculate and assemble elemental stiffness matrices double factor = 1.0 / g_; const CompositeVector& ss = *S_->GetFieldData(specific_storage_key_); CompositeVector ss_g(ss); ss_g.Update(0.0, ss, factor); factor = 1.0 / (g_ * dt_); CompositeVector sy_g(*specific_yield_copy_); sy_g.Scale(factor); op_->RestoreCheckPoint(); op_acc_->AddAccumulationDelta(*u_old->Data(), ss_g, ss_g, dt_, "cell"); op_acc_->AddAccumulationDeltaNoVolume(*u_old->Data(), sy_g, "cell"); // Peaceman model if (S_->HasField("well_index")) { const CompositeVector& wi = *S_->GetFieldData("well_index"); op_acc_->AddAccumulationTerm(wi, "cell"); } op_diff_->ApplyBCs(true, true, true); CompositeVector& rhs = *op_->rhs(); AddSourceTerms(rhs); op_->ComputeNegativeResidual(*u_new->Data(), *f->Data()); } /* ****************************************************************** * Apply preconditioner inv(B) * X. ****************************************************************** */ int Darcy_PK::ApplyPreconditioner(Teuchos::RCP<const TreeVector> X, Teuchos::RCP<TreeVector> Y) { num_itrs_++; Y->PutScalar(0.0); return op_->ApplyInverse(*X->Data(), *Y->Data()); } /* ****************************************************************** * Update preconditioner for the interval (tp-dtp, tp]. ****************************************************************** */ void Darcy_PK::UpdatePreconditioner(double tp, Teuchos::RCP<const TreeVector> u, double dtp) { op_->ComputeInverse(); } /* ****************************************************************** * Check difference du between the predicted and converged solutions. ****************************************************************** */ double Darcy_PK::ErrorNorm(Teuchos::RCP<const TreeVector> u, Teuchos::RCP<const TreeVector> du) { const Epetra_MultiVector& uc = *u->Data()->ViewComponent("cell"); const Epetra_MultiVector& duc = *du->Data()->ViewComponent("cell"); double error(0.0); for (int c = 0; c < ncells_owned; c++) { double tmp = fabs(duc[0][c]) / (fabs(uc[0][c] - atm_pressure_) + atm_pressure_); error = std::max(error, tmp); } /* const Epetra_MultiVector& uf = *u->Data()->ViewComponent("face"); const Epetra_MultiVector& duf = *du->Data()->ViewComponent("face"); for (int f = 0; f < nfaces_owned; f++) { double tmp = fabs(duf[0][f]) / (fabs(uf[0][f] - atm_pressure_) + atm_pressure_); error = std::max(error, tmp); } */ #ifdef HAVE_MPI double tmp = error; u->Comm()->MaxAll(&tmp, &error, 1); #endif return error; } /* ****************************************************************** * Estimate dT increase factor by comparing the 1st and 2nd order * time approximations. ****************************************************************** */ double Darcy_PK::ErrorEstimate_(double* dt_factor) { double tol, atol(1.0), rtol(1e-5), error, error_max(0.0), p(101325.0); double dt_factor_cell; *dt_factor = 100.0; for (int c = 0; c < ncells_owned; c++) { error = fabs((*pdot_cells)[c] - (*pdot_cells_prev)[c]) * dt_ / 2; // tol = rtol * fabs(p_cell[0][c]) + atol; tol = rtol * p + atol; dt_factor_cell = sqrt(tol / std::max(error, FLOW_DT_ADAPTIVE_ERROR_TOLERANCE)); *dt_factor = std::min(*dt_factor, dt_factor_cell); error_max = std::max(error_max, error - tol); } *dt_factor *= FLOW_DT_ADAPTIVE_SAFETY_FACTOR; *dt_factor = std::min(*dt_factor, FLOW_DT_ADAPTIVE_INCREASE); *dt_factor = std::max(*dt_factor, FLOW_DT_ADAPTIVE_REDUCTION); #ifdef HAVE_MPI double dt_tmp = *dt_factor; solution->Comm()->MinAll(&dt_tmp, dt_factor, 1); // find the global minimum double error_tmp = error_max; solution->Comm()->MaxAll(&error_tmp, &error_max, 1); // find the global maximum #endif return error_max; } } // namespace Flow } // namespace Amanzi
30.522293
92
0.563022
ajkhattak
0e628df487b729debc1bf78daf600e06a3eb6955
40,045
cc
C++
src/dialogs.cc
snmsts/xyzzy
3291c7898d17f90b1a50c3de1aeb5f9a446d9061
[ "RSA-MD" ]
1
2015-06-03T18:11:12.000Z
2015-06-03T18:11:12.000Z
src/dialogs.cc
snmsts/xyzzy
3291c7898d17f90b1a50c3de1aeb5f9a446d9061
[ "RSA-MD" ]
null
null
null
src/dialogs.cc
snmsts/xyzzy
3291c7898d17f90b1a50c3de1aeb5f9a446d9061
[ "RSA-MD" ]
null
null
null
#include "stdafx.h" #include "ed.h" #include "conf.h" #include "privctrl.h" #include "dialogs.h" #include "ofn.h" #include "thread.h" #include "xstrlist.h" #include "version.h" #include "monitor.h" void set_window_icon (HWND hwnd) { SendMessage (hwnd, WM_SETICON, 1, LPARAM (LoadIcon (app.hinst, MAKEINTRESOURCE (IDI_XYZZY)))); } void center_window (HWND hwnd) { HWND owner = GetWindow (hwnd, GW_OWNER); if (!owner) owner = GetParent (hwnd); if (!owner) owner = app.toplev; RECT dr, or; GetWindowRect (hwnd, &dr); GetWindowRect (owner, &or); LONG left = (or.left + (or.right - or.left) / 3 - (dr.right - dr.left) / 3); LONG top = (or.top + (or.bottom - or.top) / 3 - (dr.bottom - dr.top) / 3); RECT work; monitor.get_workarea_from_window (owner, &work); left = min (max (left, work.left), work.right - (dr.right - dr.left)); top = min (max (top, work.top), work.bottom - (dr.bottom - dr.top)); SetWindowPos (hwnd, 0, left, top, 0, 0, SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE); } void init_list_column (HWND list, int ncolumns, const int *width, const int *fmts, int id_start, const char *entry, const char *key) { int *v = (int *)alloca (sizeof *v * ncolumns); if (read_conf (entry, key, v, ncolumns)) width = v; LV_COLUMN lvc; lvc.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM; for (int i = 0; i < ncolumns; i++) { char buf[64]; lvc.cx = width[i]; LoadString (app.hinst, id_start + i, buf, sizeof buf); lvc.pszText = buf; lvc.iSubItem = i; lvc.fmt = fmts[i]; ListView_InsertColumn (list, i, &lvc); } } void save_list_column_width (HWND list, int ncolumns, const char *entry, const char *key) { if (!IsWindow (list)) return; int *v = (int *)alloca (sizeof *v * ncolumns); int good = 0; for (int i = 0; i < ncolumns; i++) { v[i] = ListView_GetColumnWidth (list, i); if (v[i] > 0) good = 1; } if (good) write_conf (entry, key, v, ncolumns); flush_conf (); } static void set_list_char (HWND hwnd, int type, lisp lc) { lc = xsymbol_value (lc); ListView_SetMoverChar (hwnd, type, (charp (lc) ? xchar_code (lc) : -1)); } static void set_list_chars (HWND hwnd) { set_list_char (hwnd, LVMC_UP, Vstd_control_up_char); set_list_char (hwnd, LVMC_DOWN, Vstd_control_down_char); set_list_char (hwnd, LVMC_DEF, Vstd_control_default_char); set_list_char (hwnd, LVMC_PAGEUP, Vstd_control_prior_char); set_list_char (hwnd, LVMC_PAGEDOWN, Vstd_control_next_char); } static inline void buffer_list_init_column (HWND list) { static const int width[] = {117, 65, 100, 320}; static const int fmts[] = {LVCFMT_LEFT, LVCFMT_RIGHT, LVCFMT_LEFT, LVCFMT_LEFT}; init_list_column (list, 4, width, fmts, IDS_SELECT_BUFFER1, cfgBufferSelector, cfgColumn); HIMAGELIST hil = ImageList_LoadBitmap (app.hinst, MAKEINTRESOURCE (IDB_BUFSEL), 17, 1, RGB (255, 255, 255)); ListView_SetImageList (list, hil, LVSIL_SMALL); } static inline void buffer_list_save_column (HWND list) { save_list_column_width (list, 4, cfgBufferSelector, cfgColumn); } static int store_buffer_name (HWND list, const Buffer *bp, LV_ITEM *lvi) { int l = xstring_length (bp->lbuffer_name) * 2 + 32; char *b = (char *)alloca (l + 1); bp->buffer_name (b, b + l); lvi->pszText = b; return ListView_InsertItem (list, lvi); } static void store_buffer_size (HWND list, const Buffer *bp, LV_ITEM *lvi) { char b[32]; sprintf (b, "%d", bp->b_nchars); lvi->pszText = b; ListView_SetItem (list, lvi); } static void store_string (HWND list, lisp string, LV_ITEM *lvi) { if (stringp (string)) { char *b = (char *)alloca (xstring_length (string) * 2 + 1); w2s (b, string); lvi->pszText = b; } else lvi->pszText = ""; ListView_SetItem (list, lvi); } static void buffer_list_init_item (HWND list) { int nbuffers = 0; for (const Buffer *bp = Buffer::b_blist; bp; bp = bp->b_next) if (!bp->internal_buffer_p ()) nbuffers++; ListView_SetItemCount (list, nbuffers); int i = 0, cur = 0; for (const Buffer *bp = Buffer::b_blist; bp; bp = bp->b_next) if (!bp->internal_buffer_p ()) { if (bp == selected_buffer ()) cur = i; LV_ITEM lvi; lvi.mask = LVIF_TEXT | LVIF_PARAM | LVIF_IMAGE; lvi.iItem = i++; lvi.iSubItem = 0; lvi.lParam = LPARAM (bp); lvi.iImage = (bp->b_modified ? 1 : 0) + (bp->read_only_p () ? 2 : 0); lvi.iItem = store_buffer_name (list, bp, &lvi); lvi.mask = LVIF_TEXT; lvi.iSubItem = 1; store_buffer_size (list, bp, &lvi); lvi.iSubItem = 2; store_string (list, symbol_value (Vmode_name, bp), &lvi); lvi.iSubItem = 3; store_string (list, (stringp (bp->lfile_name) ? bp->lfile_name : bp->lalternate_file_name), &lvi); } ListView_SetItemState (list, cur, LVIS_SELECTED | LVIS_FOCUSED, UINT (-1)); ListView_EnsureVisible (list, cur, 0); } static void buffer_list_init (HWND list) { ListView_SetExStyle (list, LVS_EXREPORTEX); ListView_SetPathEllipse (list, 3, 1); set_list_chars (list); buffer_list_init_column (list); buffer_list_init_item (list); } int lv_find_selected_item (HWND list) { return ListView_GetNextItem (list, -1, LVNI_SELECTED); } int lv_find_focused_item (HWND list) { return ListView_GetNextItem (list, -1, LVNI_FOCUSED); } static Buffer * get_selected_item (HWND list) { int i = lv_find_selected_item (list); if (i >= 0) { LV_ITEM lvi; lvi.iItem = i; lvi.iSubItem = 0; lvi.mask = LVIF_PARAM; if (ListView_GetItem (list, &lvi)) return (Buffer *)lvi.lParam; } return 0; } static int CALLBACK compare_buffer (LPARAM p1, LPARAM p2, LPARAM param) { Buffer *b1 = (Buffer *)p1; Buffer *b2 = (Buffer *)p2; if (xsymbol_value (Vsort_buffer_list_by_created_order) != Qnil) return b1->b_create_count - b2->b_create_count; for (int item = param, next = 0; item < 4; item = next++) { if (item == param && next) continue; lisp n1, n2; switch (item) { case 0: n1 = b1->lbuffer_name; n2 = b2->lbuffer_name; break; case 1: if (b1->b_nchars == b2->b_nchars) continue; return b1->b_nchars - b2->b_nchars; case 2: n1 = symbol_value (Vmode_name, b1); n2 = symbol_value (Vmode_name, b2); break; default: n1 = stringp (b1->lfile_name) ? b1->lfile_name : b1->lalternate_file_name; n2 = stringp (b2->lfile_name) ? b2->lfile_name : b2->lalternate_file_name; break; } if (!stringp (n1)) { if (!stringp (n2)) continue; return -1; } if (!stringp (n2)) return 1; int d = (item == 2 || xsymbol_value (Vbuffer_list_sort_ignore_case) == Qnil ? bcmp (xstring_contents (n1), xstring_contents (n2), min (xstring_length (n1), xstring_length (n2))) : memicmp (xstring_contents (n1), xstring_contents (n2), sizeof (Char) * min (xstring_length (n1), xstring_length (n2)))); if (!d) { d = xstring_length (n1) - xstring_length (n2); if (!d && !item) d = b1->b_version - b2->b_version; } if (d) return d; } return 0; } static void sort_items (HWND list, int param) { if (xsymbol_value (Vsort_buffer_list_by_created_order) == Qnil) ListView_SetSortMark (list, param, LVSM_DOWN); ListView_SortItems (list, compare_buffer, param); int i = lv_find_selected_item (list); if (i >= 0) ListView_EnsureVisible (list, i, 0); } static void offset_child_window (HWND dlg, UINT id, int dx, int dy) { HWND hwnd = GetDlgItem (dlg, id); RECT r; GetWindowRect (hwnd, &r); MapWindowPoints (HWND_DESKTOP, dlg, (POINT *)&r, 2); OffsetRect (&r, dx, dy); SetWindowPos (hwnd, 0, r.left, r.top, r.right - r.left, r.bottom - r.top, SWP_NOACTIVATE | SWP_NOZORDER); } static void resize_child_window (HWND dlg, UINT id, int dx, int dy) { HWND hwnd = GetDlgItem (dlg, IDC_LIST); RECT r; GetWindowRect (hwnd, &r); SetWindowPos (hwnd, 0, 0, 0, r.right - r.left + dx, r.bottom - r.top + dy, SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOZORDER); } static BOOL CALLBACK select_buffer_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam) { static const char cfgBufferSelector[] = "BufferSelector"; static RECT init_rect; static RECT last_rect; switch (msg) { case WM_INITDIALOG: GetWindowRect (dlg, &init_rect); last_rect = init_rect; if (!conf_load_geometry (dlg, cfgBufferSelector)) center_window (dlg); set_window_icon (dlg); SetWindowLong (dlg, DWL_USER, lparam); buffer_list_init (GetDlgItem (dlg, IDC_LIST)); sort_items (GetDlgItem (dlg, IDC_LIST), 0); ImmAssociateContext (GetDlgItem (dlg, IDC_LIST), 0); return 1; case WM_DESTROY: buffer_list_save_column (GetDlgItem (dlg, IDC_LIST)); conf_save_geometry (dlg, cfgBufferSelector); return 1; case WM_NOTIFY: { NMHDR *nm = (NMHDR *)lparam; switch (nm->idFrom) { case IDC_LIST: switch (nm->code) { case LVN_COLUMNCLICK: if (xsymbol_value (Vsort_buffer_list_by_created_order) == Qnil) sort_items (nm->hwndFrom, ((NM_LISTVIEW *)nm)->iSubItem); return 1; case NM_DBLCLK: PostMessage (dlg, WM_COMMAND, IDOK, 0); return 1; } break; } return 0; } case WM_COMMAND: switch (LOWORD (wparam)) { case IDOK: { Buffer *bp = get_selected_item (GetDlgItem (dlg, IDC_LIST)); if (!bp) return 1; *(Buffer **)GetWindowLong (dlg, DWL_USER) = bp; EndDialog (dlg, IDOK); return 1; } case IDCANCEL: EndDialog (dlg, IDCANCEL); return 1; } return 0; case WM_PRIVATE_QUIT: EndDialog (dlg, IDCANCEL); return 1; case WM_ACTIVATEAPP: PostThreadMessage (app.quit_thread_id, WM_PRIVATE_ACTIVATEAPP, wparam, lparam); return 0; case WM_GETMINMAXINFO: { MINMAXINFO *mmi = (MINMAXINFO *)lparam; mmi->ptMinTrackSize.x = init_rect.right - init_rect.left; mmi->ptMinTrackSize.y = init_rect.bottom - init_rect.top; return 1; } case WM_SIZE: { RECT r; GetWindowRect (dlg, &r); int dx = (r.right - r.left) - (last_rect.right - last_rect.left); int dy = (r.bottom - r.top) - (last_rect.bottom - last_rect.top); last_rect = r; offset_child_window (dlg, IDCANCEL, dx, dy); offset_child_window (dlg, IDOK, dx, dy); resize_child_window (dlg, IDC_LIST, dx, dy); return 1; } default: return 0; } } lisp Fbuffer_selector () { Buffer *bp = 0; int r = DialogBoxParam (app.hinst, MAKEINTRESOURCE (IDD_SELECT_BUFFER), get_active_window (), select_buffer_proc, LPARAM (&bp)); Fdo_events (); if (r != IDOK) QUIT; return r == IDOK ? bp->lbp : Qnil; } static int count_filter_size (lisp filters) { int size = 0; for (; consp (filters); filters = xcdr (filters)) { lisp f = xcar (filters); check_cons (f); lisp a = xcar (f), d = xcdr (f); check_string (a); check_string (d); size += w2sl (a) + w2sl (d) + 2; } if (size) size++; return size; } static void make_filter_string (char *b, lisp filters) { for (; consp (filters); filters = xcdr (filters)) { lisp f = xcar (filters); lisp a = xcar (f), d = xcdr (f); b = w2s (b, a) + 1; b = w2s (b, d) + 1; } *b = 0; } static const UINT MSGFILEOK = RegisterWindowMessage (FILEOKSTRING); static const UINT MSGLBSELCH = RegisterWindowMessage (LBSELCHSTRING); struct OFN: public tagOFN { HWND ofn_hwnd; int ofn_save; int ofn_encoding_req; lisp ofn_encoding; int ofn_eol_req; eol_code ofn_eol_code; int ofn_done; int ofn_ok_button; UINT wndproc (UINT, WPARAM, LPARAM); void init_dialog (); void on_size (); struct ids {int id; int code;}; static const ids eol_list[]; void init_eol_list (); void init_encoding_list (); void move_child (int, int, int); void get_result (); void *get_result (int, void *); }; const OFN::ids OFN::eol_list[] = { {IDS_EOL_LF, eol_lf}, {IDS_EOL_CRLF, eol_crlf}, {IDS_EOL_CR, eol_cr}, {IDS_EOL_AUTO, eol_guess}, {-1}, }; void OFN::init_eol_list () { int index = 0; for (int i = 0; eol_list[i].id >= 0; i++) if (!ofn_save || eol_list[i].id != IDS_EOL_AUTO) { char b[64]; LoadString (app.hinst, eol_list[i].id, b, sizeof b); int j = SendDlgItemMessage (ofn_hwnd, IDC_EOL_CODE, CB_ADDSTRING, 0, LPARAM (b)); if (j != CB_ERR) { SendDlgItemMessage (ofn_hwnd, IDC_EOL_CODE, CB_SETITEMDATA, j, eol_list[i].code); if (eol_list[i].code == ofn_eol_code) index = j; } } SendDlgItemMessage (ofn_hwnd, IDC_EOL_CODE, CB_SETCURSEL, index, 0); } void OFN::init_encoding_list () { int index = 0; for (lisp p = xsymbol_value (Vchar_encoding_list); consp (p); p = xcdr (p)) { lisp encoding = xcar (p); if (char_encoding_p (encoding) && (!ofn_save || xchar_encoding_type (encoding) != encoding_auto_detect)) { char b[256]; w2s (b, b + sizeof b, xchar_encoding_display_name (encoding)); int j = SendDlgItemMessage (ofn_hwnd, IDC_CHAR_ENCODING, CB_ADDSTRING, 0, LPARAM (b)); if (j != CB_ERR) { SendDlgItemMessage (ofn_hwnd, IDC_CHAR_ENCODING, CB_SETITEMDATA, j, LPARAM (encoding)); if (encoding == ofn_encoding) index = j; } } } SendDlgItemMessage (ofn_hwnd, IDC_CHAR_ENCODING, CB_SETCURSEL, index, 0); } void OFN::init_dialog () { if (ofn_encoding_req) init_encoding_list (); else { if (Flags & OFN_EXPLORER) { EnableWindow (GetDlgItem (ofn_hwnd, IDC_STATIC_CHAR_ENCODING), 0); EnableWindow (GetDlgItem (ofn_hwnd, IDC_CHAR_ENCODING), 0); } else { ShowWindow (GetDlgItem (ofn_hwnd, IDC_STATIC_CHAR_ENCODING), SW_HIDE); ShowWindow (GetDlgItem (ofn_hwnd, IDC_CHAR_ENCODING), SW_HIDE); } } if (ofn_eol_req) init_eol_list (); else { if (Flags & OFN_EXPLORER) { EnableWindow (GetDlgItem (ofn_hwnd, IDC_STATIC_EOL_CODE), 0); EnableWindow (GetDlgItem (ofn_hwnd, IDC_EOL_CODE), 0); } else { ShowWindow (GetDlgItem (ofn_hwnd, IDC_STATIC_EOL_CODE), SW_HIDE); ShowWindow (GetDlgItem (ofn_hwnd, IDC_EOL_CODE), SW_HIDE); } } } void OFN::move_child (int id, int x, int y) { HWND hwnd = GetDlgItem (ofn_hwnd, id); RECT r; GetWindowRect (hwnd, &r); MoveWindow (hwnd, x, y, r.right - r.left, r.bottom - r.top, 1); } void OFN::on_size () { if (Flags & OFN_EXPLORER) { HWND hwnd = GetParent (ofn_hwnd); if (ofn_encoding_req || ofn_eol_req) { RECT redt1, rcmb1, rstc3, rstc2; HWND h = GetDlgItem (hwnd, edt1); if (!h) h = GetDlgItem (hwnd, cmb13); GetWindowRect (h, &redt1); GetWindowRect (GetDlgItem (hwnd, cmb1), &rcmb1); GetWindowRect (GetDlgItem (hwnd, stc3), &rstc3); GetWindowRect (GetDlgItem (hwnd, stc2), &rstc2); MapWindowPoints (HWND_DESKTOP, ofn_hwnd, (POINT *)&redt1, 2); MapWindowPoints (HWND_DESKTOP, ofn_hwnd, (POINT *)&rcmb1, 2); MapWindowPoints (HWND_DESKTOP, ofn_hwnd, (POINT *)&rstc3, 2); MapWindowPoints (HWND_DESKTOP, ofn_hwnd, (POINT *)&rstc2, 2); int cmb_h = rcmb1.bottom - rcmb1.top; int cmb_dy = rcmb1.top - redt1.bottom; int stc_dy = rstc2.top - rcmb1.top; if (!(Flags & OFN_HIDEREADONLY)) { GetWindowRect (GetDlgItem (hwnd, chx1), &rcmb1); MapWindowPoints (HWND_DESKTOP, ofn_hwnd, (POINT *)&rcmb1, 2); } move_child (IDC_CHAR_ENCODING, rcmb1.left, rcmb1.bottom + cmb_dy); move_child (IDC_STATIC_CHAR_ENCODING, rstc2.left, rcmb1.bottom + cmb_dy + stc_dy); move_child (IDC_EOL_CODE, rcmb1.left, rcmb1.bottom + cmb_h + cmb_dy * 2); move_child (IDC_STATIC_EOL_CODE, rstc2.left, rcmb1.bottom + cmb_h + cmb_dy * 2 + stc_dy); } } } void * OFN::get_result (int id, void *defalt) { HWND hwnd = GetDlgItem (ofn_hwnd, id); int n = SendMessage (hwnd, CB_GETCURSEL, 0, 0); if (n == CB_ERR) return defalt; return (void *)SendMessage (hwnd, CB_GETITEMDATA, n, 0); } void OFN::get_result () { if (ofn_encoding_req) { lisp x = (lisp)get_result (IDC_CHAR_ENCODING, ofn_encoding); for (lisp p = xsymbol_value (Vchar_encoding_list); consp (p); p = xcdr (p)) if (x == xcar (p)) { ofn_encoding = x; break; } } if (ofn_eol_req) ofn_eol_code = (eol_code)(int)get_result (IDC_EOL_CODE, (void *)ofn_eol_code); } UINT OFN::wndproc (UINT msg, WPARAM wparam, LPARAM lparam) { switch (msg) { case WM_INITDIALOG: init_dialog (); return 1; case WM_SIZE: if (lparam) { if (!ofn_done) { HWND hwnd; if (Flags & OFN_EXPLORER) { hwnd = GetParent (ofn_hwnd); if (ofn_ok_button) CommDlg_OpenSave_SetControlText (hwnd, IDOK, "OK"); } else hwnd = ofn_hwnd; center_window (hwnd); set_window_icon (hwnd); ofn_done = 1; } PostMessage (ofn_hwnd, WM_PRIVATE_SIZE, 0, 0); } return 0; case WM_PRIVATE_SIZE: on_size (); return 0; case WM_DESTROY: get_result (); return 0; default: return 0; } } static UINT CALLBACK file_name_dialog_hook (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { OFN *ofn; if (msg == WM_INITDIALOG) { lparam = ((OPENFILENAME *)lparam)->lCustData; SetWindowLong (hwnd, DWL_USER, lparam); ofn = (OFN *)lparam; ofn->ofn_hwnd = hwnd; } else { ofn = (OFN *)GetWindowLong (hwnd, DWL_USER); if (!ofn) return 0; } return ofn->wndproc (msg, wparam, lparam); } lisp Ffile_name_dialog (lisp keys) { lisp lfilters = find_keyword (Kfilter, keys); int filter_size = count_filter_size (lfilters); int filter_index = find_keyword_int (Kfilter_index, keys, 1); lisp ltitle = find_keyword (Ktitle, keys); if (ltitle != Qnil) check_string (ltitle); lisp ldefault = find_keyword (Kdefault, keys); if (ldefault != Qnil) ldefault = Fnamestring (ldefault); lisp lext = find_keyword (Kextension, keys); if (lext != Qnil) check_string (lext); int save = find_keyword_bool (Ksave, keys); int multiple = find_keyword_bool (Kmultiple, keys); int must_exist = find_keyword_bool (Kmust_exist, keys); int explorer = sysdep.Win4p () && find_keyword_bool (Kexplorer, keys, 1); int hide_read_only = find_keyword_bool (Khide_read_only, keys, 1); int overwrite = find_keyword_bool (Koverwrite, keys); int read_only = find_keyword_bool (Kread_only, keys); lisp char_encoding = find_keyword (Kchar_encoding, keys); lisp leol_code = find_keyword (Keol_code, keys, 0); if (!leol_code) leol_code = find_keyword (Knewline_code, keys); char dir[PATH_MAX + 1]; *dir = 0; lisp ldir = find_keyword (Kinitial_directory, keys); if (ldir != Qnil) { pathname2cstr (ldir, dir); DWORD a = WINFS::GetFileAttributes (dir); if (a == DWORD (-1) || !(a & FILE_ATTRIBUTE_DIRECTORY)) *dir = 0; } if (!*dir) pathname2cstr (selected_buffer ()->ldirectory, dir); map_sl_to_backsl (dir); OFN ofn; bzero (&ofn, sizeof ofn); ofn.lStructSize = (sysdep.Win5p () ? OPENFILENAME_SIZE_VERSION_500 : OPENFILENAME_SIZE_VERSION_400); ofn.hwndOwner = get_active_window (); ofn.hInstance = app.hinst; ofn.lCustData = DWORD (&ofn); char buf[1024 * 32]; if (stringp (ldefault) && xstring_length (ldefault) < sizeof buf / 2 - 1) { w2s (buf, ldefault); map_sl_to_backsl (buf); } else if (!filter_size) strcpy (buf, "*.*"); else *buf = 0; ofn.lpstrFile = buf; ofn.nMaxFile = sizeof buf; ofn.Flags = (OFN_NOCHANGEDIR | OFN_PATHMUSTEXIST | OFN_LONGNAMES | OFN_ENABLEHOOK | OFN_ENABLESIZING | OFN_SHAREAWARE); ofn.lpfnHook = file_name_dialog_hook; if (multiple) ofn.Flags |= OFN_ALLOWMULTISELECT; if (must_exist) ofn.Flags |= OFN_FILEMUSTEXIST; if (explorer) ofn.Flags |= OFN_EXPLORER; if (hide_read_only) ofn.Flags |= OFN_HIDEREADONLY; if (overwrite) ofn.Flags |= OFN_OVERWRITEPROMPT; if (read_only) ofn.Flags |= OFN_READONLY; if (sysdep.Win5p ()) ofn.Flags |= OFN_DONTADDTORECENT | OFN_FORCESHOWHIDDEN; char *filter = 0; if (filter_size) { filter = (char *)alloca (filter_size); make_filter_string (filter, lfilters); } ofn.lpstrFilter = filter; ofn.nFilterIndex = filter_index; ofn.lpstrInitialDir = dir; int l = strlen (dir); if (!memicmp (dir, buf, l)) { if (buf[l] == '\\') l++; strcpy (buf, buf + l); } char *title = 0; if (stringp (ltitle)) { ofn.ofn_ok_button = 1; title = (char *)alloca (xstring_length (ltitle) * 2 + 1); w2s (title, ltitle); } ofn.lpstrTitle = title; char *ext = 0; if (stringp (lext)) { ext = (char *)alloca (xstring_length (lext) * 2 + 1); w2s (ext, lext); } ofn.lpstrDefExt = ext; ofn.ofn_save = save; if (leol_code == Qnil) { ofn.ofn_eol_code = eol_code (-1); ofn.ofn_eol_req = 0; } else { long n; if (!safe_fixnum_value (leol_code, &n) || !valid_eol_code_p (n)) n = eol_guess; if (save && n == eol_guess) n = eol_crlf; ofn.ofn_eol_code = eol_code (n); ofn.ofn_eol_req = 1; } if (char_encoding == Qnil) { ofn.ofn_encoding = Qnil; ofn.ofn_encoding_req = 0; } else { if (!char_encoding_p (char_encoding)) char_encoding = xsymbol_value (save ? Qencoding_sjis : Qencoding_auto); ofn.ofn_encoding = char_encoding; ofn.ofn_encoding_req = 1; } if (!explorer) { ofn.Flags |= OFN_ENABLETEMPLATE; ofn.lpTemplateName = (multiple ? MAKEINTRESOURCE (MULTIFILEOPENORD) : MAKEINTRESOURCE (FILEOPENORD)); if (!ofn.lpstrTitle && save) { title = (char *)alloca (256); LoadString (app.hinst, IDS_SAVE_AS, title, 256); ofn.lpstrTitle = title; } } else if (ofn.ofn_eol_req || ofn.ofn_encoding_req) { ofn.Flags |= OFN_ENABLETEMPLATE; ofn.lpTemplateName = MAKEINTRESOURCE (IDD_CUST_EXPLORER); } if (save ? !GetSaveFileName (&ofn) : !GetOpenFileName (&ofn)) return Qnil; multiple_value::count () = 4; multiple_value::value (1) = make_fixnum (ofn.nFilterIndex); multiple_value::value (2) = ofn.ofn_encoding_req ? ofn.ofn_encoding : Qnil; multiple_value::value (3) = ((ofn.ofn_eol_req && valid_eol_code_p (ofn.ofn_eol_code) && ofn.ofn_eol_code != eol_guess) ? make_fixnum (ofn.ofn_eol_code) : Qnil); if (!multiple) { map_backsl_to_sl (buf); return make_string (buf); } lisp result = Qnil; if (ofn.Flags & OFN_EXPLORER) { char *b = buf + strlen (buf); map_backsl_to_sl (buf); if (!b[1]) return xcons (make_string (buf), Qnil); char *e = b++; if (jrindex (buf, '/') != e - 1) *e++ = '/'; while (*b) { char *p = stpcpy (e, b); b += p - e + 1; result = xcons (make_string (buf), result); } } else { char *b = jindex (buf, ' '); if (!b) { map_backsl_to_sl (buf); return xcons (make_string (buf), Qnil); } char *e = b++; *e = 0; if (jrindex (buf, '/') != e - 1) *e++ = '/'; while (1) { char *b2 = jindex (b, ' '); if (b2) *b2 = 0; strcpy (e, b); char path[PATH_MAX], *name; if (WINFS::GetFullPathName (buf, sizeof path, path, &name)) strcpy (e, name); map_backsl_to_sl (buf); result = xcons (make_string (buf), result); if (!b2) break; b = b2 + 1; } } return result; } struct ODN: public tagOFNA { char odn_result[PATH_MAX + 1]; void store_dirname (HWND); void selch (HWND, int); int ok (HWND); static int error (HWND, int); }; void ODN::store_dirname (HWND hwnd) { SetDlgItemText (hwnd, IDC_PATH, odn_result); } void ODN::selch (HWND hwnd, int id) { char path[PATH_MAX]; GetCurrentDirectory (sizeof path, path); if (!strcmp (path, odn_result)) { if (id == lst2) PostMessage (hwnd, WM_COMMAND, IDOK, 0); } else { strcpy (odn_result, path); store_dirname (hwnd); } } int ODN::error (HWND hwnd, int e) { char buf[1024]; FormatMessage ((FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS | FORMAT_MESSAGE_MAX_WIDTH_MASK), 0, e, GetUserDefaultLangID (), buf, sizeof buf, 0); MsgBox (hwnd, buf, TitleBarString, MB_OK | MB_ICONEXCLAMATION, xsymbol_value (Vbeep_on_error) != Qnil); return 1; } int ODN::ok (HWND hwnd) { char path[PATH_MAX]; GetDlgItemText (hwnd, IDC_PATH, path, sizeof path); if (!*path) return 1; DWORD atr = WINFS::GetFileAttributes (path); if (atr == -1) return error (hwnd, GetLastError ()); if (!(atr & FILE_ATTRIBUTE_DIRECTORY)) return error (hwnd, ERROR_DIRECTORY); HWND drive = GetDlgItem (hwnd, cmb2); int l = strlen (path); strcpy (path + l, " "); int i = SendMessage (drive, CB_FINDSTRING, WPARAM (-1), LPARAM (path)); path[l] = 0; if (i != CB_ERR) { if (SendMessage (drive, CB_GETCURSEL, 0, 0) == i) return 1; SendMessage (drive, CB_SETCURSEL, i, 0); PostMessage (hwnd, WM_COMMAND, MAKEWPARAM (cmb2, CBN_SELCHANGE), LPARAM (drive)); return 1; } char *tem; WINFS::GetFullPathName (path, sizeof odn_result, odn_result, &tem); return 0; } static UINT CALLBACK directory_name_dialog_hook (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { if (msg == WM_INITDIALOG) { lparam = ((OPENFILENAME *)lparam)->lCustData; SetWindowLong (hwnd, DWL_USER, lparam); ((ODN *)lparam)->store_dirname (hwnd); center_window (hwnd); set_window_icon (hwnd); return 1; } ODN *odn = (ODN *)GetWindowLong (hwnd, DWL_USER); if (!odn) return 0; if (msg == MSGFILEOK) return odn->ok (hwnd); if (msg == MSGLBSELCH && HIWORD (lparam) == CD_LBSELCHANGE && (wparam == lst2 || wparam == cmb2)) { odn->selch (hwnd, wparam); return 1; } return 0; } lisp Fdirectory_name_dialog (lisp keys) { lisp ltitle = find_keyword (Ktitle, keys); if (ltitle != Qnil) check_string (ltitle); lisp ldefault = find_keyword (Kdefault, keys); if (ldefault != Qnil) ldefault = Fnamestring (ldefault); else ldefault = selected_buffer ()->ldirectory; ODN odn; bzero (&odn, sizeof odn); odn.lStructSize = OPENFILENAME_SIZE_VERSION_400; odn.hwndOwner = get_active_window (); odn.hInstance = app.hinst; char buf[PATH_MAX]; strcpy (buf, "FOO"); odn.lpstrFile = buf; odn.nMaxFile = sizeof buf; odn.Flags = (OFN_NOCHANGEDIR | OFN_PATHMUSTEXIST | OFN_LONGNAMES | OFN_ENABLEHOOK | OFN_HIDEREADONLY | OFN_ENABLETEMPLATE | OFN_NOVALIDATE); if (sysdep.Win5p ()) odn.Flags |= OFN_DONTADDTORECENT | OFN_FORCESHOWHIDDEN; odn.lpfnHook = directory_name_dialog_hook; odn.lpTemplateName = MAKEINTRESOURCE (IDD_DIRECTORY); if (xstring_length (ldefault) < sizeof odn.odn_result / 2 - 1) { w2s (odn.odn_result, ldefault); map_sl_to_backsl (odn.odn_result); odn.lpstrInitialDir = odn.odn_result; } else strcpy (odn.odn_result, sysdep.curdir); char *title = 0; if (stringp (ltitle)) { title = (char *)alloca (xstring_length (ltitle) * 2 + 1); w2s (title, ltitle); } odn.lpstrTitle = title; odn.lCustData = DWORD (&odn); if (!GetOpenFileName (&odn)) return Qnil; map_backsl_to_sl (odn.odn_result); return make_string (odn.odn_result); } BOOL CALLBACK IdleDialog::WndProc (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { IdleDialog *d; if (msg == WM_INITDIALOG) { d = (IdleDialog *)lparam; d->id_hwnd = hwnd; SetWindowLong (hwnd, DWL_USER, lparam); } else { d = (IdleDialog *)GetWindowLong (hwnd, DWL_USER); if (!d) return 0; if (msg == WM_NCDESTROY) { d->WndProc (msg, wparam, lparam); if (d->id_end == IE_ALIVE) d->id_end = IE_DEAD; if (d->id_auto_delete) delete d; else d->id_hwnd = 0; return 1; } } d->id_wndproc_depth++; BOOL f = d->WndProc (msg, wparam, lparam); d->id_wndproc_depth--; if (!d->id_wndproc_depth && d->id_end == IE_DEAD && d->id_modeless && IsWindow (d->id_hwnd)) { d->id_end = IE_DELETE; DestroyWindow (d->id_hwnd); } return f; } void IdleDialog::EndDialog (int r) { id_result = r; id_end = IE_DEAD; } void IdleDialog::process () { while (id_end == IE_ALIVE) { MSG msg; while (id_idle && id_end == IE_ALIVE) { while (id_end == IE_ALIVE && PeekMessage (&msg, 0, 0, 0, PM_REMOVE)) if (!IsDialogMessage (&msg)) { XyzzyTranslateMessage (&msg); DispatchMessage (&msg); } IdleProc (); } while (id_end == IE_ALIVE && !id_idle && GetMessage (&msg, 0, 0, 0)) if (!IsDialogMessage (&msg)) { XyzzyTranslateMessage (&msg); DispatchMessage (&msg); } } } int IdleDialog::DoModal (HWND owner, UINT id) { id_modeless = 0; int enable_owner = 0; if (owner && IsWindowEnabled (owner)) { EnableWindow (owner, 0); enable_owner = 1; } id_hwnd = CreateDialogParam (app.hinst, MAKEINTRESOURCE (id), owner, WndProc, LPARAM (this)); if (id_hwnd) { ShowWindow (id_hwnd, SW_SHOW); process (); SetWindowPos (id_hwnd, 0, 0, 0, 0, 0, (SWP_HIDEWINDOW | SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE | SWP_NOZORDER)); } if (enable_owner) EnableWindow (owner, 1); if (owner && GetActiveWindow () == id_hwnd) SetActiveWindow (owner); if (id_hwnd) DestroyWindow (id_hwnd); return id_result; } int IdleDialog::Create (HWND owner, UINT id) { id_modeless = 1; id_hwnd = CreateDialogParam (app.hinst, MAKEINTRESOURCE (id), owner, WndProc, LPARAM (this)); if (!id_hwnd) return 0; ShowWindow (id_hwnd, SW_SHOW); return 1; } IdleDialog::~IdleDialog () { if (IsWindow (id_hwnd)) { DestroyWindow (id_hwnd); id_hwnd = 0; } id_end = IE_DEAD; } class list_volume_name: public worker_thread { protected: virtual void thread_main (); private: xstring_list m_list; HWND m_hwnd; DWORD m_drives; public: list_volume_name (HWND hwnd, DWORD drives) : m_hwnd (hwnd), m_drives (drives) {} ~list_volume_name () {} void interrupt () { m_hwnd = 0; worker_thread::interrupt (); } const xstring_list &list () const {return m_list;} }; void list_volume_name::thread_main () { try { for (int c = 'a'; c <= 'z' && m_hwnd; c++) if (m_drives & (1 << (c - 'a'))) { char name[5]; sprintf (name, "%c:\\", c); int type = GetDriveType (name); char volname[1024]; if (type != DRIVE_REMOVABLE && GetVolumeInformation (name, volname + 1, sizeof volname - 1, 0, 0, 0, 0, 0) && volname[1]) { *volname = c; m_list.add (volname); } } if (m_hwnd) PostMessage (m_hwnd, WM_PRIVATE_END_LIST_DRIVE, 0, 0); } catch (nonlocal_jump &) { } } class DriveDialog: public IdleDialog { Char dd_defalt; DWORD dd_drives; LONG dd_maxw; worker_thread_helper <list_volume_name> dd_thread; int dd_indexes['z' - 'a' + 1]; void setup_list (HWND); void insert_drives (HWND); void insert_volnames (); void init_dialog (); virtual BOOL WndProc (UINT, WPARAM, LPARAM); void result (int); virtual void IdleProc () {set_idle (0);} public: int DoModal (HWND owner) {return IdleDialog::DoModal (owner, IDD_SELECT_DRIVE);} DriveDialog (Char d) : dd_defalt (d), dd_drives (0), dd_maxw (0) {} Char get_result () const {return dd_defalt;} }; void DriveDialog::setup_list (HWND hwnd) { ImmAssociateContext (hwnd, 0); ListView_SetExStyle (hwnd, LVS_EXREPORTEX); set_list_chars (hwnd); LV_COLUMN lvc; lvc.mask = LVCF_FMT | LVCF_SUBITEM; for (int i = 0; i < 2; i++) { lvc.iSubItem = i; lvc.fmt = LVCFMT_LEFT; ListView_InsertColumn (hwnd, i, &lvc); } HIMAGELIST hil = ImageList_LoadBitmap (app.hinst, MAKEINTRESOURCE (IDB_FILESEL), 16, 1, RGB (0, 0, 255)); ListView_SetImageList (hwnd, hil, LVSIL_SMALL); } void DriveDialog::insert_drives (HWND hwnd) { HDC hdc = GetDC (hwnd); HGDIOBJ of = SelectObject (hdc, HFONT (SendMessage (hwnd, WM_GETFONT, 0, 0))); int cur = 0, item = 0; for (int c = 'a'; c <= 'z'; c++) { int i = c - 'a'; if (dd_drives & (1 << i)) { dd_indexes[i] = item; if (c == dd_defalt) cur = item; char name[5]; sprintf (name, "%c:\\", c); int type = GetDriveType (name); LV_ITEM lvi; lvi.mask = LVIF_TEXT | LVIF_PARAM | LVIF_IMAGE; lvi.iItem = item++; lvi.iSubItem = 0; lvi.lParam = c; if (type >= DRIVE_REMOVABLE && type <= DRIVE_RAMDISK) lvi.iImage = type + 4 - DRIVE_REMOVABLE; else lvi.mask &= ~LVIF_IMAGE; name[2] = 0; lvi.pszText = name; ListView_InsertItem (hwnd, &lvi); SIZE sz; GetTextExtentPoint32 (hdc, name, 2, &sz); dd_maxw = max (dd_maxw, sz.cx); } else dd_indexes[i] = -1; } SelectObject (hdc, of); ReleaseDC (hwnd, hdc); ListView_SetColumnWidth (hwnd, 0, dd_maxw * 2 + 20); ListView_SetItemState (hwnd, cur, LVIS_SELECTED | LVIS_FOCUSED, UINT (-1)); ListView_EnsureVisible (hwnd, cur, 0); } void DriveDialog::insert_volnames () { HWND hwnd = GetDlgItem (id_hwnd, IDC_LIST); HDC hdc = GetDC (hwnd); HGDIOBJ of = SelectObject (hdc, HFONT (SendMessage (hwnd, WM_GETFONT, 0, 0))); LONG maxw = 0; for (const xstring_node *p = dd_thread->list ().head (); p; p = p->next ()) { const char *volname = *p; if (lower_char_p (*volname & 255)) { int i = dd_indexes[*volname - 'a']; if (i >= 0) { volname++; ListView_SetItemText (hwnd, i, 1, (char *)volname); SIZE sz; GetTextExtentPoint32 (hdc, volname, strlen (volname), &sz); maxw = max (maxw, sz.cx); } } } if (maxw) ListView_SetColumnWidth (hwnd, 1, maxw + dd_maxw + 20); SelectObject (hdc, of); ReleaseDC (hwnd, hdc); } void DriveDialog::init_dialog () { center_window (id_hwnd); set_window_icon (id_hwnd); if (dd_defalt > 0) dd_defalt = alpha_char_p (dd_defalt) ? char_downcase (dd_defalt) : Char (-1); dd_drives = GetLogicalDrives (); HWND hwnd = GetDlgItem (id_hwnd, IDC_LIST); setup_list (hwnd); insert_drives (hwnd); try { dd_thread.attach (new list_volume_name (id_hwnd, dd_drives)); dd_thread->start (); } catch (nonlocal_jump &) { } } void DriveDialog::result (int drive) { if (dd_drives & (1 << (drive - 'a'))) { dd_defalt = char_upcase (Char (drive)); EndDialog (IDOK); } } BOOL DriveDialog::WndProc (UINT msg, WPARAM wparam, LPARAM lparam) { switch (msg) { case WM_INITDIALOG: init_dialog (); return 1; case WM_NOTIFY: { NMHDR *nm = (NMHDR *)lparam; switch (nm->idFrom) { case IDC_LIST: switch (nm->code) { case NM_DBLCLK: PostMessage (id_hwnd, WM_COMMAND, IDOK, 0); return 1; case LVN_KEYDOWN: if (GetKeyState (VK_CONTROL) >= 0 && GetKeyState (VK_SHIFT) >= 0 && GetKeyState (VK_MENU) >= 0) { int c = ((LV_KEYDOWN *)nm)->wVKey; if (c >= 'A' && c <= 'Z') result (char_downcase (c)); return 1; } break; } break; } return 0; } case WM_COMMAND: switch (LOWORD (wparam)) { case IDOK: { HWND list = GetDlgItem (id_hwnd, IDC_LIST); int i = lv_find_selected_item (list); if (i == -1) return 1; LV_ITEM lvi; lvi.iItem = i; lvi.iSubItem = 0; lvi.mask = LVIF_PARAM; if (ListView_GetItem (list, &lvi)) result (lvi.lParam); return 1; } case IDCANCEL: EndDialog (IDCANCEL); return 1; } return 0; case WM_PRIVATE_END_LIST_DRIVE: if (dd_thread) insert_volnames (); return 1; case WM_PRIVATE_QUIT: EndDialog (IDCANCEL); return 1; case WM_ACTIVATEAPP: PostThreadMessage (app.quit_thread_id, WM_PRIVATE_ACTIVATEAPP, wparam, lparam); return 0; case WM_DESTROY: if (dd_thread) dd_thread->interrupt (); return 1; default: return 0; } } lisp Fdrive_dialog (lisp drive) { Char d = Char (-1); if (drive && drive != Qnil) { check_char (drive); d = xchar_code (drive); } DriveDialog dlg (d); int r = dlg.DoModal (get_active_window ()); Fdo_events (); if (r != IDOK) QUIT; return r == IDOK ? make_char (dlg.get_result ()) : Qnil; }
25.360988
99
0.572006
snmsts
0e6465a8bb720131beaf1acc32a2f024448bd283
1,114
cpp
C++
algorithm/poj3704.cpp
chtld/Programming-and-Algorithm-Course
669f266fc97db9050013ffbb388517667de33433
[ "MIT" ]
2
2019-06-10T11:50:06.000Z
2019-10-14T08:00:41.000Z
algorithm/poj3704.cpp
chtld/Programming-and-Algorithm-Course
669f266fc97db9050013ffbb388517667de33433
[ "MIT" ]
null
null
null
algorithm/poj3704.cpp
chtld/Programming-and-Algorithm-Course
669f266fc97db9050013ffbb388517667de33433
[ "MIT" ]
null
null
null
#include<iostream> #include<cstring> using namespace std; char str[101]; int len; int match(int pos){ int i; i = pos + 1; while (1) { while (str[i] != '(' && str[i] != ')' && str[i] != 0) i++; if (str[i] == '(') { i = match(i); } else if (str[i] == ')') { str[pos] = ' '; str[i] = ' '; return i + 1; } else { str[pos] = '$'; return len; } } } int main(){ while (cin.getline(str, 101)) { cout << str << endl; len = strlen(str); int i; for (i = 0; i < len; ++i) { if (str[i] != '(' && str[i] != ')') str[i] = ' '; } i = 0; while (str[i] != 0) { while(str[i] != 0 && str[i] != '(') i++; if (str[i] == '(') i = match(i); } i = 0; while(str[i] != 0) { if (str[i] == ')') str[i] = '?'; i++; } cout << str << endl; } return 0; }
21.018868
61
0.29623
chtld
0e6b265c3ec6f26828883e502425f3a32c9bba44
223
hpp
C++
include/sywu/api_defs.hpp
bzeller/sywu
a0eeffcd46d74e68dc4115c31a7aaedc2a5be830
[ "MIT" ]
null
null
null
include/sywu/api_defs.hpp
bzeller/sywu
a0eeffcd46d74e68dc4115c31a7aaedc2a5be830
[ "MIT" ]
null
null
null
include/sywu/api_defs.hpp
bzeller/sywu
a0eeffcd46d74e68dc4115c31a7aaedc2a5be830
[ "MIT" ]
null
null
null
#ifndef API_DEFS_HPP #define API_DEFS_HPP #include <config.hpp> #ifdef CONFIG_LIBRARY # define SYWU_API DECL_EXPORT #else # define SYWU_API DECL_IMPORT #endif #define SYWU_TEMPLATE_API #endif // API_DEFS_HPP
15.928571
35
0.762332
bzeller
0e6bbbf6a77e9886aa751de3338ba8f62d1630b7
38,276
cpp
C++
src/refdb.cpp
overcookedpanda/merit
5fb1604ae69aae71f746d018fd86f1e4b9c60ccc
[ "MIT" ]
null
null
null
src/refdb.cpp
overcookedpanda/merit
5fb1604ae69aae71f746d018fd86f1e4b9c60ccc
[ "MIT" ]
null
null
null
src/refdb.cpp
overcookedpanda/merit
5fb1604ae69aae71f746d018fd86f1e4b9c60ccc
[ "MIT" ]
null
null
null
// Copyright (c) 2017-2020 The Merit Foundation // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #include "refdb.h" #include "base58.h" #include <boost/rational.hpp> #include <boost/multiprecision/cpp_int.hpp> #include <limits> namespace pog { extern bool IsValidAmbassadorDestination(char type); } namespace referral { namespace { const char DB_CHILDREN = 'c'; const char DB_REFERRALS = 'r'; const char DB_HASH = 'h'; const char DB_PARENT_ADDRESS = 'p'; const char DB_ANV = 'a'; const char DB_PUBKEY = 'k'; const char DB_LOT_SIZE = 's'; const char DB_LOT_VAL = 'v'; const char DB_CONFIRMATION = 'i'; const char DB_CONFIRMATION_IDX = 'n'; const char DB_CONFIRMATION_TOTAL = 'u'; const char DB_PRE_DAEDALUS_CONFIRMED = 'd'; const char DB_ALIAS = 'l'; const char DB_HEIGHT = 'b'; const char DB_LOT_INV = 'L'; const char DB_NEW_INVITE_REWARD = 'N'; const size_t MAX_LEVELS = std::numeric_limits<size_t>::max(); bool comp(const LotteryEntrant& a, const LotteryEntrant& b) { return std::get<0>(a) < std::get<0>(b); } } //stores ANV internally as a rational number with numerator/denominator using int128_t = boost::multiprecision::int128_t; using AnvInternal = std::pair<int128_t, int128_t>; using ANVTuple = std::tuple<char, Address, AnvInternal>; using AnvRat = boost::rational<int128_t>; using TransactionOutIndex = int; using ConfirmationVal = std::pair<char, Address>; namespace { class ReferralIdVisitor : public boost::static_visitor<MaybeReferral> { private: const ReferralsViewDB *db; const bool normalize_alias; public: ReferralIdVisitor( const ReferralsViewDB *db_in, bool normalize_alias_in) : db{db_in}, normalize_alias{normalize_alias_in} {} MaybeReferral operator()(const std::string &id) const { return db->GetReferral(id, normalize_alias); } template <typename T> MaybeReferral operator()(const T &id) const { return db->GetReferral(id); } }; } ReferralsViewDB::ReferralsViewDB( size_t cache_size, bool memory, bool wipe, const std::string& db_name) : m_db(GetDataDir() / db_name, cache_size, memory, wipe, true) {} MaybeReferral ReferralsViewDB::GetReferral(const Address& address) const { MutableReferral referral; return m_db.Read(std::make_pair(DB_REFERRALS, address), referral) ? MaybeReferral{referral} : MaybeReferral{}; } MaybeReferral ReferralsViewDB::GetReferral(const uint256& hash) const { Address address; if (m_db.Read(std::make_pair(DB_HASH, hash), address)) { return GetReferral(address); } return {}; } MaybeReferral ReferralsViewDB::GetReferral( const std::string& alias, bool normalize_alias) const { auto maybe_normalized = alias; if (normalize_alias) { NormalizeAlias(maybe_normalized); } if (maybe_normalized.empty() || maybe_normalized.size() > MAX_ALIAS_LENGTH) { return {}; } Address address; if (m_db.Read(std::make_pair(DB_ALIAS, maybe_normalized), address)) { return IsConfirmed(address) ? GetReferral(address) : MaybeReferral{}; } return {}; } MaybeReferral ReferralsViewDB::GetReferral( const ReferralId& referral_id, bool normalize_alias) const { return boost::apply_visitor( ReferralIdVisitor{this, normalize_alias}, referral_id); } MaybeAddress ReferralsViewDB::GetAddressByPubKey(const CPubKey& pubkey) const { Address address; return m_db.Read(std::make_pair(DB_PUBKEY, pubkey), address) ? MaybeAddress{address} : MaybeAddress{}; } MaybeAddressPair ReferralsViewDB::GetParentAddress(const Address& address) const { AddressPair parent; return m_db.Read(std::make_pair(DB_PARENT_ADDRESS, address), parent) ? MaybeAddressPair{parent} : MaybeAddressPair{}; } ChildAddresses ReferralsViewDB::GetChildren(const Address& address) const { ChildAddresses children; m_db.Read(std::make_pair(DB_CHILDREN, address), children); return children; } bool ReferralsViewDB::InsertReferral( int height, const Referral& referral, bool allow_no_parent, bool normalize_alias) { assert(height >= 0); LogPrint(BCLog::BEACONS, "Inserting referral %s parent %s\n", CMeritAddress{referral.addressType, referral.GetAddress()}.ToString(), referral.parentAddress.GetHex()); if (referral.alias.size() > MAX_ALIAS_LENGTH) { return false; } if (Exists(referral.GetAddress())) { return true; } //write referral by code hash if (!m_db.Write(std::make_pair(DB_REFERRALS, referral.GetAddress()), referral)) { return false; } //write referral height by code hash if (!m_db.Write(std::make_pair(DB_HEIGHT, referral.GetAddress()), height)) { return false; } ANVTuple anv{referral.addressType, referral.GetAddress(), AnvInternal{0, 1}}; if (!m_db.Write(std::make_pair(DB_ANV, referral.GetAddress()), anv)) { return false; } // write referral address by hash if (!m_db.Write(std::make_pair(DB_HASH, referral.GetHash()), referral.GetAddress())) return false; // write referral address by pubkey if (!m_db.Write(std::make_pair(DB_PUBKEY, referral.pubkey), referral.GetAddress())) return false; if (referral.version >= Referral::INVITE_VERSION && referral.alias.size() > 0) { // write referral referral address by alias auto maybe_normalized = referral.alias; if (normalize_alias) { NormalizeAlias(maybe_normalized); } if (!m_db.Write(std::make_pair(DB_ALIAS, maybe_normalized), referral.GetAddress())) { return false; } } // Typically because the referral should be written in order we should // be able to find the parent referral. We can then write the child->parent // mapping of public addresses if (auto parent_referral = GetReferral(referral.parentAddress)) { LogPrint(BCLog::BEACONS, "\tInserting parent reference %s parent %s\n", CMeritAddress{referral.addressType, referral.GetAddress()}.ToString(), CMeritAddress{parent_referral->addressType, parent_referral->GetAddress()}.ToString()); const auto parent_address = parent_referral->GetAddress(); AddressPair parent_addr_pair{parent_referral->addressType, parent_address}; if (!m_db.Write(std::make_pair(DB_PARENT_ADDRESS, referral.GetAddress()), parent_addr_pair)) return false; // Now we update the children of the parent address by inserting into the // child address array for the parent. ChildAddresses children; m_db.Read(std::make_pair(DB_CHILDREN, referral.parentAddress), children); children.push_back(referral.GetAddress()); if (!m_db.Write(std::make_pair(DB_CHILDREN, referral.parentAddress), children)) return false; LogPrint(BCLog::BEACONS, "Inserted referral %s parent %s\n", CMeritAddress{referral.addressType, referral.GetAddress()}.ToString(), CMeritAddress{parent_referral->addressType, referral.parentAddress}.ToString()); } else if (!allow_no_parent) { assert(false && "parent referral missing"); return false; } else { LogPrint(BCLog::BEACONS, "\tWarning Parent missing for address %s. Parent: %s\n", CMeritAddress{referral.addressType, referral.GetAddress()}.ToString(), referral.parentAddress.GetHex()); } return true; } bool ReferralsViewDB::RemoveReferral(const Referral& referral) { LogPrint(BCLog::BEACONS, "Removing Referral %d\n", CMeritAddress{referral.addressType, referral.GetAddress()}.ToString()); if (!m_db.Erase(std::make_pair(DB_REFERRALS, referral.GetAddress()))) { return false; } if (!m_db.Erase(std::make_pair(DB_HEIGHT, referral.GetAddress()))) { return false; } if (!m_db.Erase(std::make_pair(DB_HASH, referral.GetHash()))) { return false; } if (!m_db.Erase(std::make_pair(DB_PUBKEY, referral.pubkey))) { return false; } if (!m_db.Erase(std::make_pair(DB_PARENT_ADDRESS, referral.GetAddress()))) { return false; } ChildAddresses children; m_db.Read(std::make_pair(DB_CHILDREN, referral.parentAddress), children); children.erase(std::remove(std::begin(children), std::end(children), referral.GetAddress()), std::end(children)); if (!m_db.Write(std::make_pair(DB_CHILDREN, referral.parentAddress), children)) { return false; } return true; } int ReferralsViewDB::GetReferralHeight(const Address& address) { int height = -1; m_db.Read(std::make_pair(DB_HEIGHT, address), height); return height; } bool ReferralsViewDB::SetReferralHeight(int height, const Address& address) { assert(height >= 0); return m_db.Write(std::make_pair(DB_HEIGHT, address), height); } /** * Updates ANV for the address and all parents. Note change can be negative if * there was a debit. * * Internally ANV values are stored as rational numbers because as ANV values * bubble up, they get halved each step along the way and we need to make sure * to account for values at the sub-micro level. This design discourages * creating long chains of referrals and rewards those who grow wider trees. */ bool ReferralsViewDB::UpdateANV( char address_type, const Address& start_address, CAmount change) { AnvRat change_rat = int128_t{change}; LogPrint(BCLog::BEACONS, "\tUpdateANV: %s + %d\n", CMeritAddress(address_type, start_address).ToString(), change); MaybeAddress address = start_address; size_t level = 0; //MAX_LEVELS guards against cycles in DB while (address && change != 0 && level < MAX_LEVELS) { //it's possible address didn't exist yet so an ANV of 0 is assumed. ANVTuple anv; if (!m_db.Read(std::make_pair(DB_ANV, *address), anv)) { LogPrint(BCLog::BEACONS, "\tFailed to read ANV for %s\n", address->GetHex()); return false; } assert(std::get<0>(anv) != 0); assert(!std::get<1>(anv).IsNull()); LogPrint(BCLog::BEACONS, "\t\t %d %s %d/%d + %d\n", level, CMeritAddress(std::get<0>(anv), std::get<1>(anv)).ToString(), std::get<0>((std::get<2>(anv))), std::get<1>((std::get<2>(anv))), change); auto& anv_in = std::get<2>(anv); AnvRat anv_rat{anv_in.first, anv_in.second}; anv_rat += change_rat; //boost rational stores the values in normalized form and these sould not overflow anv_in.first = anv_rat.numerator(); anv_in.second = anv_rat.denominator(); assert(anv_in.first >= 0); assert(anv_in.second > 0); if (!m_db.Write(std::make_pair(DB_ANV, *address), anv)) { //TODO: Do we rollback anv computation for already processed address? // likely if we can't write then rollback will fail too. // figure out how to mark database as corrupt. return false; } const auto parent = GetParentAddress(*address); if (parent) { address_type = parent->first; address = parent->second; } else { address.reset(); } level++; change_rat /= 2; } // We should never have cycles in the DB. // Hacked? Bug? assert(level < MAX_LEVELS && "reached max levels. Referral DB cycle detected"); return true; } CAmount AnvInToAnvPub(const AnvInternal& in) { AnvRat anv_rat{in.first, in.second}; return boost::rational_cast<CAmount>(anv_rat); } MaybeAddressANV ReferralsViewDB::GetANV(const Address& address) const { ANVTuple anv; if (!m_db.Read(std::make_pair(DB_ANV, address), anv)) { return MaybeAddressANV{}; } const auto anv_pub = AnvInToAnvPub(std::get<2>(anv)); return MaybeAddressANV({ std::get<0>(anv), std::get<1>(anv), anv_pub }); } AddressANVs ReferralsViewDB::GetAllANVs() const { std::unique_ptr<CDBIterator> iter{m_db.NewIterator()}; iter->SeekToFirst(); AddressANVs anvs; auto address = std::make_pair(DB_ANV, Address{}); while (iter->Valid()) { //filter non ANV addresss if (!iter->GetKey(address)) { iter->Next(); continue; } if (address.first != DB_ANV) { iter->Next(); continue; } ANVTuple anv; if (!iter->GetValue(anv)) { iter->Next(); continue; } const auto anv_pub = AnvInToAnvPub(std::get<2>(anv)); anvs.push_back({std::get<0>(anv), std::get<1>(anv), anv_pub}); iter->Next(); } return anvs; } void ReferralsViewDB::GetAllRewardableANVs( const Consensus::Params& params, int height, referral::AddressANVs& entrants) const { const auto heap_size = GetLotteryHeapSize(); bool found_genesis = false; for (uint64_t i = 0; i < heap_size; i++) { LotteryEntrant v; if (!m_db.Read(std::make_pair(DB_LOT_VAL, i), v)) { break; } auto maybe_anv = GetANV(std::get<2>(v)); if (!maybe_anv) { break; } if (maybe_anv->address_type != 1 && maybe_anv->address_type != 2) { continue; } /* * After block 13499 the genesis address does not participate in the lottery. * So don't include the genesis address as an entrant. */ if (!found_genesis && height >= 13500 && maybe_anv->address == params.genesis_address) { found_genesis = true; continue; } entrants.push_back(*maybe_anv); } } bool ReferralsViewDB::FindLotteryPos(const Address& address, uint64_t& pos) const { if (m_db.Read(std::make_pair(DB_LOT_INV, address), pos)) { return true; } const auto heap_size = GetLotteryHeapSize(); for (uint64_t i = 0; i < heap_size; i++) { LotteryEntrant v; if (!m_db.Read(std::make_pair(DB_LOT_VAL, i), v)) { return false; } if (std::get<2>(v) == address) { pos = i; if (!m_db.Write(std::make_tuple(DB_LOT_INV, address), pos)) { return false; } return true; } } pos = heap_size; return true; } /** * This function uses a modified version of the weighted random sampling algorithm * by Efraimidis and Spirakis * (https://www.sciencedirect.com/science/article/pii/S002001900500298X). * * Instead of computing R=rand^(1/W) where rand is some uniform random value * between [0,1] and W is the ANV, we will compute log(R). * * See pog::WeightedKeyForSampling for more details. * * A MinHeap is maintained in the DB and this function, once it decides if * it wants to add the address, it uses InsertLotteryEntrant to insert and * maintain the heap. */ bool ReferralsViewDB::AddAddressToLottery( int height, uint256 rand_value, char address_type, MaybeAddress address, const uint64_t max_reservoir_size, LotteryUndos& undos) { auto maybe_anv = GetANV(*address); if (!maybe_anv) return false; //Don't include non key or script addresses. //parameterized addresses are not allowed. if (!pog::IsValidAmbassadorDestination(address_type)) { //return true here because false means bad error. return true; } size_t levels = 0; while (address && levels < MAX_LEVELS) { /** * Fix for the sampling algorithm before the reservoir is full. * The bug has little impact when the reservoir is not full. */ if (height >= 16000) { maybe_anv = GetANV(*address); if (!maybe_anv) return false; //combine hashes and hash to get next sampling value CHashWriter hasher{SER_DISK, CLIENT_VERSION}; hasher << rand_value << *address; rand_value = hasher.GetHash(); } const auto weighted_key = pog::WeightedKeyForSampling(rand_value, maybe_anv->anv); const auto heap_size = GetLotteryHeapSize(); LogPrint(BCLog::BEACONS, "Lottery: Attempting to add %s with weighted Key %d\n", CMeritAddress(address_type, *address).ToString(), static_cast<double>(weighted_key)); // Note we are duplicating FindLotterPos inside both if conditions because // once the reservoir is full, we won't be attempting to add every time // so it is silly to check for duplicates if we aren't going to add anyway. if (heap_size < max_reservoir_size) { uint64_t pos; if (!FindLotteryPos(*address, pos)) { return false; } //Only add entrants that are not already participating. if (pos == heap_size) { if (!InsertLotteryEntrant( weighted_key, address_type, *address, max_reservoir_size)) { return false; } LotteryUndo undo{ weighted_key, address_type, *address, *address}; undos.emplace_back(undo); } else { LogPrint(BCLog::BEACONS, "\tLottery: %s is already in the lottery.\n", CMeritAddress(address_type, *address).ToString()); } } else { const auto maybe_min_entrant = GetMinLotteryEntrant(); if (!maybe_min_entrant) { return false; } const auto min_weighted_key = std::get<0>(*maybe_min_entrant); //Insert into reservoir only if the new key is bigger //than the smallest key already there. Over time as the currency //grows in amount there should always be a key greater than the //smallest at some point as time goes on. if (min_weighted_key < weighted_key) { uint64_t pos; if (!FindLotteryPos(*address, pos)) { return false; } //Only add entrants that are not already participating. if (pos == heap_size) { if (!PopMinFromLotteryHeap()) { return false; } if (!InsertLotteryEntrant( weighted_key, address_type, *address, max_reservoir_size)) { return false; } LotteryUndo undo{ std::get<0>(*maybe_min_entrant), std::get<1>(*maybe_min_entrant), std::get<2>(*maybe_min_entrant), *address}; undos.emplace_back(undo); } else { LogPrint(BCLog::BEACONS, "\tLottery: %s is already in the lottery.\n", CMeritAddress(address_type, *address).ToString()); } } else { LogPrint(BCLog::BEACONS, "\tLottery: %s didn't make the cut with key %d, min %d\n", CMeritAddress(address_type, *address).ToString(), static_cast<double>(weighted_key), static_cast<double>(min_weighted_key)); } } const auto parent = GetParentAddress(*address); if (parent) { address_type = parent->first; address = parent->second; } else { address.reset(); } levels++; } return true; } bool ReferralsViewDB::UndoLotteryEntrant( const LotteryUndo& undo, const uint64_t max_reservoir_size) { if (!RemoveFromLottery(undo.replaced_with)) { return false; } //Undo where the replaced address is the same as replaced_with are considered //add only and we just remove the entry and not try to add it. if (undo.replaced_with == undo.replaced_address) { return true; } if (!InsertLotteryEntrant( undo.replaced_key, undo.replaced_address_type, undo.replaced_address, max_reservoir_size)) { return false; } return true; } uint64_t ReferralsViewDB::GetLotteryHeapSize() const { uint64_t size = 0; m_db.Read(DB_LOT_SIZE, size); return size; } MaybeLotteryEntrant ReferralsViewDB::GetMinLotteryEntrant() const { LotteryEntrant v; const uint64_t first = 0; return m_db.Read(std::make_pair(DB_LOT_VAL, first), v) ? MaybeLotteryEntrant{v} : MaybeLotteryEntrant{}; } /** * The addresses in a lottery are kept in a MinHeap. This function inserts * the address at the end and bubbles it up to the correct spot swapping with * parents until the right spot is found. If this function returns false, then * some bad things happened. You must not call this function when the heap is * full. You first must pop an element off the heap using PopMinFromLotteryHeap */ bool ReferralsViewDB::InsertLotteryEntrant( const pog::WeightedKey& key, char address_type, const Address& address, const uint64_t max_reservoir_size) { auto heap_size = GetLotteryHeapSize(); assert(heap_size < max_reservoir_size); auto new_entry = std::make_tuple(key, address_type, address); auto pos = heap_size; while (pos != 0) { const auto parent_pos = (pos - 1) / 2; LotteryEntrant parent_value; if (!m_db.Read(std::make_pair(DB_LOT_VAL, parent_pos), parent_value)) { return false; } //We found our spot if (comp(parent_value, new_entry)) { break; } //Push our parent down since we are moving up. if (!m_db.Write(std::make_tuple(DB_LOT_VAL, pos), parent_value)) { return false; } if (!m_db.Write(std::make_tuple(DB_LOT_INV, std::get<2>(parent_value)), pos)) { return false; } pos = parent_pos; } //write final value LogPrint(BCLog::BEACONS, "\tAdding to Reservoir %s at pos %d\n", CMeritAddress(address_type, address).ToString(), pos); if (!m_db.Write(std::make_pair(DB_LOT_VAL, pos), new_entry)) { return false; } if (!m_db.Write(std::make_tuple(DB_LOT_INV, address), pos)) { return false; } uint64_t new_size = heap_size + 1; if (!m_db.Write(DB_LOT_SIZE, new_size)) return false; assert(new_size <= max_reservoir_size); return true; } bool ReferralsViewDB::PopMinFromLotteryHeap() { return RemoveFromLottery(0); } bool ReferralsViewDB::RemoveFromLottery(const Address& to_remove) { uint64_t pos; if (!FindLotteryPos(to_remove, pos)) { return false; } return RemoveFromLottery(pos); } bool ReferralsViewDB::RemoveFromLottery(uint64_t current) { LogPrint(BCLog::BEACONS, "\tPopping from lottery reservoir position %d\n", current); auto heap_size = GetLotteryHeapSize(); if (heap_size == 0) return false; LotteryEntrant last; if (!m_db.Read(std::make_pair(DB_LOT_VAL, heap_size - 1), last)) { return false; } LotteryEntrant current_val; if (!m_db.Read(std::make_pair(DB_LOT_VAL, current), current_val)) { return false; } if (!m_db.Erase(std::make_tuple(DB_LOT_INV, std::get<2>(current_val)))) { return false; } LotteryEntrant smallest_val = last; //Walk down heap and bubble down the last value until we find the correct spot. while (true) { uint64_t smallest = current; uint64_t left = 2 * current + 1; uint64_t right = 2 * current + 2; if (left < heap_size) { LotteryEntrant left_val; if (!m_db.Read(std::make_pair(DB_LOT_VAL, left), left_val)) { return false; } if (comp(left_val, smallest_val)) { smallest = left; smallest_val = left_val; } } if (right < heap_size) { LotteryEntrant right_val; if (!m_db.Read(std::make_pair(DB_LOT_VAL, right), right_val)) { return false; } if (comp(right_val, smallest_val)) { smallest = right; smallest_val = right_val; } } if (smallest != current) { //write the current element with the smallest if (!m_db.Write(std::make_pair(DB_LOT_VAL, current), smallest_val)) { return false; } if (!m_db.Write(std::make_tuple(DB_LOT_INV, std::get<2>(smallest_val)), current)) { return false; } //now go down the smallest path current = smallest; } else { break; } } //finally write the value in the correct spot and reduce the heap //size by 1 if (!m_db.Write(std::make_pair(DB_LOT_VAL, current), last)) { return false; } if (!m_db.Write(std::make_tuple(DB_LOT_INV, std::get<2>(last)), current)) { return false; } uint64_t new_size = heap_size - 1; if (!m_db.Write(DB_LOT_SIZE, new_size)) { return false; } LogPrint(BCLog::BEACONS, "\tPopped from lottery reservoir, last ended up at %d\n", current); return true; } /* * Orders referrals by constructing a dependency graph and doing a breath * first walk through the forrest. */ bool ReferralsViewDB::OrderReferrals(referral::ReferralRefs& refs) { if (refs.empty()) { return true; } auto end_roots = std::partition(refs.begin(), refs.end(), [this](const referral::ReferralRef& ref) -> bool { return static_cast<bool>(GetReferral(ref->parentAddress)); }); //If we don't have any roots, we have an invalid block. if (end_roots == refs.begin()) { return false; } std::map<uint160, referral::ReferralRefs> graph; //insert roots of trees into graph std::for_each( refs.begin(), end_roots, [&graph](const referral::ReferralRef& ref) { graph[ref->GetAddress()] = referral::ReferralRefs{}; }); //Insert disconnected referrals std::for_each(end_roots, refs.end(), [&graph](const referral::ReferralRef& ref) { graph[ref->parentAddress].push_back(ref); }); //copy roots to work queue std::deque<referral::ReferralRef> to_process(std::distance(refs.begin(), end_roots)); std::copy(refs.begin(), end_roots, to_process.begin()); //do breath first walk through the trees to create correct referral //ordering auto replace = refs.begin(); while (!to_process.empty() && replace != refs.end()) { const auto& ref = to_process.front(); *replace = ref; to_process.pop_front(); replace++; const auto& children = graph[ref->GetAddress()]; to_process.insert(to_process.end(), children.begin(), children.end()); } //If any of these conditions are not met, it means we have an invalid block if (replace != refs.end() || !to_process.empty()) { return false; } return true; } //Confirmation pair is an index plus count using ConfirmationPair = std::pair<uint64_t, int>; bool ReferralsViewDB::UpdateConfirmation( char address_type, const Address& address, CAmount amount, CAmount &updated_amount) { uint64_t total_confirmations = 0; m_db.Read(DB_CONFIRMATION_TOTAL, total_confirmations); ConfirmationPair confirmation; if (!m_db.Read( std::make_pair(DB_CONFIRMATION, address), confirmation)) { confirmation.first = total_confirmations; confirmation.second = amount; updated_amount = confirmation.second; //We have a new confirmed address so add it to the end of the invite lottery //and index it. if (!m_db.Write( std::make_pair(DB_CONFIRMATION_IDX, total_confirmations), std::make_pair( address_type, address))) { return false; } if (!m_db.Write(DB_CONFIRMATION_TOTAL, total_confirmations + 1)) { return false; } } else { confirmation.second += amount; updated_amount = confirmation.second; //We delete the last confirmation only if amount of invites reaches //0 and it is the last confirmation in the array. This is to handle //DisconnectBlock correctly. assert(total_confirmations > 0); if (confirmation.second == 0 && confirmation.first == total_confirmations - 1) { if (!m_db.Write(DB_CONFIRMATION_TOTAL, total_confirmations - 1)) { return false; } if (!m_db.Erase(std::make_pair(DB_CONFIRMATION, address))) { return false; } if (!m_db.Erase(std::make_pair(DB_CONFIRMATION_IDX, confirmation.first))) { return false; } return true; } if (confirmation.second < 0) { return false; } } if (!m_db.Write( std::make_pair(DB_CONFIRMATION, address), confirmation)) { return false; } return true; } bool ReferralsViewDB::Exists(const referral::Address& address) const { return m_db.Exists(std::make_pair(DB_REFERRALS, address)); } bool ReferralsViewDB::Exists( const std::string& alias, bool normalize_alias) const { auto maybe_normalized = alias; if (normalize_alias) { NormalizeAlias(maybe_normalized); } return maybe_normalized.size() > 0 && m_db.Exists(std::make_pair(DB_ALIAS, maybe_normalized)); } bool ReferralsViewDB::IsConfirmed(const referral::Address& address) const { ConfirmationPair confirmation; if (!m_db.Read( std::make_pair(DB_CONFIRMATION, address), confirmation)) { return false; } return confirmation.second > 0; } bool ReferralsViewDB::IsConfirmed(const std::string& alias, bool normalize_alias) const { auto ref = GetReferral(alias, normalize_alias); return ref ? true : false; } using AddressPairs = std::vector<AddressPair>; bool ReferralsViewDB::ConfirmAllPreDaedalusAddresses() { //Check to see if addresses have already been confirmed. if (m_db.Exists(DB_PRE_DAEDALUS_CONFIRMED)) { return true; } std::unique_ptr<CDBIterator> iter{m_db.NewIterator()}; iter->SeekToFirst(); AddressPairs addresses; auto address = std::make_pair(DB_REFERRALS, Address{}); while (iter->Valid()) { // filter non ANV addresses if (!iter->GetKey(address)) { iter->Next(); continue; } if (address.first != DB_REFERRALS) { iter->Next(); continue; } MutableReferral referral; if (!iter->GetValue(referral)) { return false; } addresses.push_back({referral.addressType, referral.GetAddress()}); iter->Next(); } LogPrint(BCLog::BEACONS, "Confirming %d pre daedalus addresses\n", addresses.size()); std::sort(addresses.begin(), addresses.end(), [](const AddressPair& a, const AddressPair& b) { return a.second < b.second; }); CAmount dummy; for(const auto& addr : addresses) { LogPrint(BCLog::BEACONS, "\tConfirming %s address\n", CMeritAddress{addr.first, addr.second}.ToString()); if (!UpdateConfirmation(addr.first, addr.second, 1, dummy)) { return false; } } //Mark state in DB that all addresses before daedalus have been confirmed. if (!m_db.Write(DB_PRE_DAEDALUS_CONFIRMED, true)) { return false; } return true; } bool ReferralsViewDB::AreAllPreDaedalusAddressesConfirmed() const { return m_db.Exists(DB_PRE_DAEDALUS_CONFIRMED); } uint64_t ReferralsViewDB::GetTotalConfirmations() const { uint64_t total = 0; m_db.Read(DB_CONFIRMATION_TOTAL, total); return total; } MaybeConfirmedAddress ReferralsViewDB::GetConfirmation(uint64_t idx) const { ConfirmationVal val; if (!m_db.Read(std::make_pair(DB_CONFIRMATION_IDX, idx), val)) { return MaybeConfirmedAddress{}; } ConfirmationPair pair{0,0}; if (!m_db.Read( std::make_pair(DB_CONFIRMATION, val.second), pair)) { return MaybeConfirmedAddress{}; } return MaybeConfirmedAddress{{val.first, val.second, pair.second}}; } MaybeConfirmedAddress ReferralsViewDB::GetConfirmation(char address_type, const Address& address) const { ConfirmationPair pair{0,0}; if (!m_db.Read( std::make_pair(DB_CONFIRMATION, address), pair)) { return MaybeConfirmedAddress{}; } return MaybeConfirmedAddress{{address_type, address, pair.second}}; } bool ReferralsViewDB::SetNewInviteRewardedHeight(const Address& a, int height) { return height > 0 ? m_db.Write(std::make_pair(DB_NEW_INVITE_REWARD, a), height) : m_db.Erase(std::make_pair(DB_NEW_INVITE_REWARD, a)); } int ReferralsViewDB::GetNewInviteRewardedHeight(const Address& a) const { int height = 0; m_db.Read(std::make_pair(DB_NEW_INVITE_REWARD, a), height); return height; } } //namespace referral
33.753086
130
0.547811
overcookedpanda
0e6dac03d70187a0f4efe4b044d70be27d1542b6
2,522
cpp
C++
cube/HashFunctions.cpp
ypavlou/LSH-HYPERCUBE
fda86a704a215d03593e0f0c0506a2d9308cf3b1
[ "MIT" ]
null
null
null
cube/HashFunctions.cpp
ypavlou/LSH-HYPERCUBE
fda86a704a215d03593e0f0c0506a2d9308cf3b1
[ "MIT" ]
null
null
null
cube/HashFunctions.cpp
ypavlou/LSH-HYPERCUBE
fda86a704a215d03593e0f0c0506a2d9308cf3b1
[ "MIT" ]
null
null
null
#include "HashFunctions.h" double generateNumber(double const& range_from,double const& range_to){ //https://en.cppreference.com/w/cpp/numeric/random/uniform_real_distribution random_device rand_dev; mt19937 generator(rand_dev()); uniform_real_distribution<> distr(range_from, range_to); return distr(generator); } template <class inputData> void HashFunctions<inputData>::calculateSi(unsigned int const& d,int const& k,double const& w){ for(int i=0; i<k; i++){ s[i].resize(d); for(unsigned int j=0; j<d; j++){ s[i][j]=generateNumber(0,w); } } } template <class inputData> inline int HashFunctions<inputData>::calculate_ai(inputData const& x,double const& s,double const& w){ int a = (int)floor((x - s) / w) ; //floors down the integer return a; } int mod(int a, int b) { return (a % b + b) % b; } int modular_power(int x, unsigned int y, int p) { int res = 1; // Initialize result x = x % p; // Update x if it is more than or // equal to p while (y > 0) { // If y is odd, multiply x with result if (y & 1) res = (res*x) % p; // y must be even now y = y>>1; // y = y/2 x = (x*x) % p; } return res; } template <class inputData> void HashFunctions<inputData>::calculate_mi(unsigned int const& d){ m.resize(d); m[0]=1; m[1]=modular_power(2,32,M)-5; for(unsigned int i=2; i<d; i++){ m[i]=modular_power(modular_power(2,32,M)-5,i,M);//(m[i-1]*value)%M; } } template <class inputData> inline int HashFunctions<inputData>::calculateH(vector<inputData> const& x,unsigned int whichHashFunction,double const& w,unsigned int const& k){ auto d=(unsigned int)x.size(); int h = 0; int power=d-1; for(unsigned int i=0;i<d;i++){ h +=calculate_ai(x.at(i),s[whichHashFunction].at(i),w)*m[power]; power--; } return mod(h,M); } template <class inputData> inline unsigned int HashFunctions<inputData>::gCalculator(const vector<inputData>& x,unsigned int const& k,double const& w){ unsigned int g=0; for(unsigned int i=0; i<k; i++){ int h=calculateH(x,i,w,k); g +=h; g <<=32/k; } return g; } template class HashFunctions<int>; //In order to not fail the compile as the compiler wants to see the data that the templated class will have.
29.670588
154
0.587629
ypavlou
0e75f6eb1d62984bd07fa6cf810d40273bdc64eb
10,086
cpp
C++
AVNA8main/src/SerialCommandR2/SerialCommandR2.cpp
boblark/AudioTestInstrument
43400f271bcdefbb0105e1abd5152480e207b871
[ "MIT" ]
2
2021-03-04T06:38:31.000Z
2021-09-13T17:17:36.000Z
AVNA8main/src/SerialCommandR2/SerialCommandR2.cpp
boblark/AudioTestInstrument
43400f271bcdefbb0105e1abd5152480e207b871
[ "MIT" ]
1
2021-05-03T23:46:48.000Z
2021-05-04T16:29:17.000Z
AVNA8main/src/SerialCommandR2/SerialCommandR2.cpp
boblark/AudioTestInstrument
43400f271bcdefbb0105e1abd5152480e207b871
[ "MIT" ]
1
2021-05-03T23:07:04.000Z
2021-05-03T23:07:04.000Z
/******************************************************************************* SerialCommandR - Modified from Steven Cogswell Llibrary noted below. Bob Larkin 21 Jan 2017 - See .h file for notes. * SerialCommand - An Arduino library to tokenize and parse commands received over a serial port. Copyright (C) 2011-2013 Steven Cogswell <steven.cogswell@gmail.com> http://awtfy.com See SerialCommand.h for version history. This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ***********************************************************************************/ #if defined(ARDUINO) && ARDUINO >= 100 #include "Arduino.h" #else #include "WProgram.h" #endif #include "SerialCommandR2.h" #include <string.h> #ifndef SERIALCOMMAND_HARDWAREONLY #include <SoftwareSerial.h> #endif // #define SERIALCOMMANDDEBUG 1 // Constructor makes sure some things are set. Untested by RSL SerialCommand::SerialCommand() { usingSoftwareSerial=false; // term was '\r' but that was not received from Serial Monitor---Why? term = DEFAULT_TERM; // '#' return character, default terminator for command, programmable delim[0]= DEFAULT_TERM; // for finding tokens delim[1] = ' '; // Space always available delim[2] = ','; // Comma delim[3] = '\n'; // newline doesn't appear for me, but here for safety delim[4] = '\r'; // same for CR response = NO_RESPONSE; numCommand=0; // Number of callback handlers installed clearBuffer(); } #ifndef SERIALCOMMAND_HARDWAREONLY // Constructor to use a SoftwareSerial object SerialCommand::SerialCommand(SoftwareSerial &_SoftSer) { usingSoftwareSerial=true; SoftSerial = &_SoftSer; strncpy(delim," ",MAXDELIMETER); // strtok_r needs a null-terminated string term = DEFAULT_TERM; // '#' return character, default terminator for command, programmable delim[0]= DEFAULT_TERM; // for finding tokens delim[1] = ' '; // Space always available delim[2] = ','; // Comma delim[3] = '\n'; // newline doesn't appear for me, but here for safety delim[4] = '\r'; // same for CR numCommand=0; // Number of callback handlers installed clearBuffer(); } #endif // Set command termination character, term, to over-ride DEFAULT_TERM void SerialCommand::setTerm(char t) { term = t; // Change terminator character delim[0] = t; // All endings should also be deliminators } // Set command response, response, to over-ride NO_RESPONSE void SerialCommand::setResponse(uint16_t r) { response = r; // Change serial response to commands } // // Initialize the command buffer being processed to all null characters // void SerialCommand::clearBuffer() { for (int i=0; i<SERIALCOMMANDBUFFER; i++) buffer[i]='\0'; bufPos=0; } // Retrieve the next token ("word" or "argument") from the Command buffer. // returns a NULL if no more tokens exist. char *SerialCommand::next() { char *nextToken; nextToken = strtok_r(NULL, delim, &last); return nextToken; } // This checks the Serial stream for characters, and assembles them into a buffer. // When the terminator character (default '\r') is seen, it starts parsing the // buffer for a prefix command, and calls handlers setup by addCommand() member void SerialCommand::readSerial() { // If we're using the Hardware port, check it. Otherwise check the user-created SoftwareSerial Port #ifdef SERIALCOMMAND_HARDWAREONLY while (Serial.available() > 0) #else while ((usingSoftwareSerial && Serial.available() > 0) || (usingSoftwareSerial && SoftSerial->available() > 0) ) #endif { if (!usingSoftwareSerial) { // Hardware serial port inChar=Serial.read(); // Read single available character, there may be more waiting } else { #ifndef SERIALCOMMAND_HARDWAREONLY // SoftwareSerial port inChar = SoftSerial->read(); // Read single available character, there may be more waiting #endif } processCh(inChar); } } // Alternate for readSerial() whith character already read Rev Jan 2020 // This checks the Serial stream for characters, and assembles them into a buffer. // When the terminator character (default '\r') is seen, it starts parsing the // buffer for a prefix command, and calls handlers setup by addCommand() member. // Returns 0=still filling buffer, 1=invalid command found 2=valid command found int16_t SerialCommand::processCh(char ccc) { char *c; int16_t returnValue; uint16_t i; boolean matched; inChar = ccc; // <<<WOULD SEEM THAT inChar could be local returnValue = 0; #ifdef SERIALCOMMANDDEBUG // Echo back to serial stream Serial.print("0x"); if ((uint8_t)inChar<0x10) {Serial.print("0");} Serial.print((uint8_t)inChar, HEX); Serial.print(" term="); Serial.print("0x"); Serial.print((uint8_t)term, HEX); Serial.println(""); #endif if (inChar==term) { // Check for the terminator, meaning end of command #ifdef SERIALCOMMANDDEBUG Serial.print("Received: "); Serial.println(buffer); #endif if (response==ECHO_FULL_COMMAND) Serial.println(buffer); // Look for any leading spaces or blank commands c = buffer; bufPos=0; // Reset to start of buffer while (*c==' ' || *c==term || *c=='\n' || *c=='\r') { c++; bufPos++; } token = strtok_r(buffer,delim,&last); // Search for command at start of buffer if (token == NULL) return 0; // End of command delimiter not found yet matched=false; for (i=0; i<numCommand; i++) // Try all commands { #ifdef SERIALCOMMANDDEBUG Serial.print("Comparing ["); Serial.print(token); Serial.print("] to ["); Serial.print(CommandList[i].command); Serial.println("]"); #endif // Compare the found command against the list of known commands for a match if (strncmp(token,CommandList[i].command,SERIALCOMMANDBUFFER) == 0) { #ifdef SERIALCOMMANDDEBUG Serial.print("Matched Command: "); Serial.println(token); #endif returnValue = 2; if(response==ECHO_COMMAND) Serial.println(token); else if (response==ECHO_OK) Serial.println("OK"); else if (response==ECHO_ONE) Serial.print(1); // Execute the stored handler function for the command (*CommandList[i].function)(); clearBuffer(); matched=true; break; } } if (matched==false) { returnValue = 1; (*defaultHandler)(); clearBuffer(); if (response==ECHO_ONE) Serial.print(0); } } // printable includes space, tab, \n, \r, etc. Excludes control ch. if (isprint(inChar)) // Only "printable" characters into the buffer { buffer[bufPos++]=inChar; // Put character into buffer buffer[bufPos]='\0'; // Null terminate if (bufPos > SERIALCOMMANDBUFFER-1) bufPos=0; // wrap buffer around if full } return returnValue; } // Adds a "command" and a handler function to the list of available commands. // This is used for matching a found token in the buffer, and gives the pointer // to the handler function to deal with it. void SerialCommand::addCommand(const char *command, void (*function)()) { if (numCommand < MAXSERIALCOMMANDS) { #ifdef SERIALCOMMANDDEBUG Serial.print(numCommand); Serial.print("-"); Serial.print("Adding command for "); Serial.println(command); #endif strncpy(CommandList[numCommand].command,command,SERIALCOMMANDBUFFER); CommandList[numCommand].function = function; numCommand++; } else { // In this case, you tried to push more commands into the buffer than it is compiled to hold. // Not much we can do since there is no real visible error assertion, we just ignore adding // the command #ifdef SERIALCOMMANDDEBUG Serial.println("Too many handlers - recompile changing MAXSERIALCOMMANDS"); #endif } } // This sets up a handler to be called in the event that the receveived command string // isn't in the list of things with handlers. void SerialCommand::addDefaultHandler(void (*function)()) { defaultHandler = function; }
37.217712
116
0.586556
boblark
0e76ec6683b5828ad682fa300250f7ef9fe7655b
1,281
cpp
C++
vteffect/goto.cpp
LegalizeAdulthood/vteffect
36ecb0d166ba9d88c2681975c1c6c8a867b5702e
[ "MIT" ]
3
2019-09-22T13:10:54.000Z
2021-12-21T14:01:53.000Z
vteffect/goto.cpp
LegalizeAdulthood/vteffect
36ecb0d166ba9d88c2681975c1c6c8a867b5702e
[ "MIT" ]
null
null
null
vteffect/goto.cpp
LegalizeAdulthood/vteffect
36ecb0d166ba9d88c2681975c1c6c8a867b5702e
[ "MIT" ]
null
null
null
#include "goto.h" #include <cstdio> void goto_coord(const coord &c, coord &last) { if (last.row == c.row) { if (last.col == c.col-1) { } else if (last.col == c.col+1) { std::printf("\010\010"); } else if (last.col > c.col) { const int amount = last.col-c.col+1; if (amount > 1) std::printf("\033[%dD", amount); else std::printf("\033[D"); } else { const int amount = c.col-last.col-1; if (amount > 1) std::printf("\033[%dC", amount); else std::printf("\033[C"); } } else if (last.col == c.col && last.row == c.row+1) { std::printf("\033M\010"); } else if (last.col == c.col && last.row == c.row-1) { std::printf("\n\010"); } else if (c.row == 1) { if (c.col == 1) { std::printf("\033[H"); } else { std::printf("\033[;%dH", c.col); } } else if (c.col == 1) { std::printf("\033[%dH", c.row); } else { std::printf("\033[%d;%dH", c.row, c.col); } last = c; }
20.66129
54
0.37861
LegalizeAdulthood
0e7b09abd246cc1e53a6a638265b822f31287ff8
1,350
cpp
C++
cmdstan/stan/lib/stan_math/test/unit/math/prim/arr/fun/rep_array_test.cpp
yizhang-cae/torsten
dc82080ca032325040844cbabe81c9a2b5e046f9
[ "BSD-3-Clause" ]
null
null
null
cmdstan/stan/lib/stan_math/test/unit/math/prim/arr/fun/rep_array_test.cpp
yizhang-cae/torsten
dc82080ca032325040844cbabe81c9a2b5e046f9
[ "BSD-3-Clause" ]
null
null
null
cmdstan/stan/lib/stan_math/test/unit/math/prim/arr/fun/rep_array_test.cpp
yizhang-cae/torsten
dc82080ca032325040844cbabe81c9a2b5e046f9
[ "BSD-3-Clause" ]
null
null
null
#include <stan/math/prim/arr.hpp> #include <gtest/gtest.h> TEST(MathMatrix,rep_array) { using stan::math::rep_array; std::vector<double> x = rep_array(2.0, 3); EXPECT_EQ(3U,x.size()); for (size_t i = 0; i < x.size(); ++i) EXPECT_FLOAT_EQ(2.0, x[i]); EXPECT_THROW(rep_array(2.0,-2), std::domain_error); } TEST(MathMatrix,rep_array2D) { using stan::math::rep_array; using std::vector; vector<vector<double> > x = rep_array(2.0, 3, 4); EXPECT_EQ(3U,x.size()); for (size_t i = 0; i < x.size(); ++i) { EXPECT_EQ(4U,x[i].size()); for (size_t j = 0; j < x[i].size(); ++j) EXPECT_FLOAT_EQ(2.0, x[i][j]); } EXPECT_THROW(rep_array(2.0,-2,3), std::domain_error); EXPECT_THROW(rep_array(2.0,2,-3), std::domain_error); } TEST(MathMatrix,rep_array3D) { using stan::math::rep_array; using std::vector; vector<vector<vector<int> > > x = rep_array(13, 3, 4, 5); EXPECT_EQ(3U,x.size()); for (size_t i = 0; i < x.size(); ++i) { EXPECT_EQ(4U,x[i].size()); for (size_t j = 0; j < x[i].size(); ++j) { EXPECT_EQ(5U,x[i][j].size()); for (size_t k = 0; k < x[i][j].size(); ++k) EXPECT_EQ(13, x[i][j][k]); } } EXPECT_THROW(rep_array(2.0,-2,3,4), std::domain_error); EXPECT_THROW(rep_array(2.0,2,-3,4), std::domain_error); EXPECT_THROW(rep_array(2.0,2,3,-4), std::domain_error); }
31.395349
59
0.602963
yizhang-cae
0e821f4253f5b94e92e6b7dc8ecae170f231f224
1,197
cpp
C++
files/soko1/qutim_0.1.1/protocol/oscar/icq/readawaydialog.cpp
truebsdorg/truebsdorg.github.io
8663d8f6fae3b1bb1e2fb29614677f2863521951
[ "BSD-4-Clause-UC" ]
null
null
null
files/soko1/qutim_0.1.1/protocol/oscar/icq/readawaydialog.cpp
truebsdorg/truebsdorg.github.io
8663d8f6fae3b1bb1e2fb29614677f2863521951
[ "BSD-4-Clause-UC" ]
null
null
null
files/soko1/qutim_0.1.1/protocol/oscar/icq/readawaydialog.cpp
truebsdorg/truebsdorg.github.io
8663d8f6fae3b1bb1e2fb29614677f2863521951
[ "BSD-4-Clause-UC" ]
null
null
null
/* readAwayDialog Copyright (c) 2008 by Rustam Chakin <qutim.develop@gmail.com> *************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * *************************************************************************** */ #include "readawaydialog.h" readAwayDialog::readAwayDialog(QWidget *parent) : QWidget(parent) { ui.setupUi(this); setFixedSize(size()); move(desktopCenter()); } readAwayDialog::~readAwayDialog() { } QPoint readAwayDialog::desktopCenter() { QDesktopWidget desktop; return QPoint(desktop.width() / 2 - size().width() / 2, desktop.height() / 2 - size().height() / 2); } void readAwayDialog::addMessage(QString &t) { ui.awayMessage->setPlainText(t.replace("\n", "<br>")); }
27.837209
101
0.492899
truebsdorg
0e8229737beb80be7ecc1bf3d732de3952df12cd
4,433
cpp
C++
src/network_manager.cpp
hsrob/BBCF-Improvement-Mod-GGPO
2d327b942c3b58190078afb235e2c83a7c390784
[ "MIT" ]
1
2020-09-15T10:45:06.000Z
2020-09-15T10:45:06.000Z
src/network_manager.cpp
hsrob/BBCF-Improvement-Mod-GGPO
2d327b942c3b58190078afb235e2c83a7c390784
[ "MIT" ]
null
null
null
src/network_manager.cpp
hsrob/BBCF-Improvement-Mod-GGPO
2d327b942c3b58190078afb235e2c83a7c390784
[ "MIT" ]
null
null
null
#include "../include/network_manager.h" #include "../include/ImGui/ImGuiSystem.h" #include "../include/custom_palette.h" #include "../include/utils.h" #include "../include/bbcf_im_networking.h" #include "../include/containers.h" NetworkManager::NetworkManager(SteamNetworkingWrapper *SteamNetworking) { pSteamNetworking = SteamNetworking; } NetworkManager::~NetworkManager() { } int NetworkManager::FillInternalPacket(im_packet_internal_t *internal_packet, im_packet_t *packet) { LOG(2, "NetworkManager::FillInternalPacket\n"); internal_packet->code = 0x98; internal_packet->type = packet->type; internal_packet->playernum = packet->playernum; internal_packet->part = packet->part; internal_packet->datalen = packet->datalen; memcpy(internal_packet->data, packet->data, packet->datalen); internal_packet->length1 = packet->datalen + // could just use GetFinalTransferSizeOfPacket here??? sizeof(internal_packet->datalen) + sizeof(internal_packet->part) + sizeof(internal_packet->type) + sizeof(internal_packet->playernum) + sizeof(internal_packet->code) + (2 * sizeof(internal_packet->length1)); internal_packet->length2 = internal_packet->length1; return internal_packet->length1; } bool NetworkManager::SendPacket(CSteamID *playerID, im_packet_t *packet) { LOG(2, "NetworkManager::SendPacket\n"); if (packet->playernum == 0) { LOG(2, "Not sending packet as spectator...\n"); return false; } EP2PSend sendtype = k_EP2PSendUnreliable; im_packet_internal_t internal_packet; FillInternalPacket(&internal_packet, *&packet); LOG(2, "\tSending packet: \n"); LOG(2, "\tlength1: %s\n", RawMemoryArrayToString((unsigned char*)&internal_packet.length1, sizeof(internal_packet.length1))); LOG(2, "\tlength2: %s\n", RawMemoryArrayToString((unsigned char*)&internal_packet.length2, sizeof(internal_packet.length2))); LOG(2, "\tcode: %s\n", RawMemoryArrayToString((unsigned char*)&internal_packet.code, sizeof(internal_packet.code))); LOG(2, "\ttype: %s\n", RawMemoryArrayToString((unsigned char*)&internal_packet.type, sizeof(internal_packet.type))); LOG(2, "\tplayernum: %s\n", RawMemoryArrayToString((unsigned char*)&internal_packet.playernum, sizeof(internal_packet.playernum))); LOG(2, "\tpart: %s\n", RawMemoryArrayToString((unsigned char*)&internal_packet.part, sizeof(internal_packet.part))); LOG(2, "\tdatalen: %s\n", RawMemoryArrayToString((unsigned char*)&internal_packet.datalen, sizeof(internal_packet.datalen))); LOG(2, "\tdata: %s\n", RawMemoryArrayToString((unsigned char*)&internal_packet.data, internal_packet.datalen)); bool ret = false; //sending to a single person if (packet->type == packetType_IMID) { ret = pSteamNetworking->SendP2PPacket(*playerID, &internal_packet, internal_packet.length1, sendtype, 0); return ret; } for (int i = 0; i < Containers::gameVals.playersInMatch.size(); i++) { LOG(2, "Sending packet to: 0x%x\n", Containers::gameVals.playersInMatch[i]); ret = pSteamNetworking->SendP2PPacket(Containers::gameVals.playersInMatch[i], &internal_packet, internal_packet.length1, sendtype, 0); } return ret; } void NetworkManager::PacketProcesser(im_packet_internal_t* packet) { LOG(2, "NetworkManager::PacketProcesser\n"); if (packet->code != 0x98) //do not compare with '\x98', it doesnt work { LOG(2, "Opponent is using incompatible version of BBCFIM\n"); ImGuiSystem::AddLog("[error] Opponent is using incompatible version of BBCFIM\n"); return; } if (packet->playernum == 0) { LOG(2, "Packet received from spectator\n"); return; } switch (packet->type) { case packetType_IMID: Receive_BBCFIM_ID(packet); break; case packetType_palette: LoadPalettePacket(packet); break; case packetType_effect: LoadEffectPacket(packet); break; case packetType_bloom: LoadBloomPacket(packet); break; case packetType_gamemode: Receive_customGamemode_request(packet); break; default: LOG(2, "packet type not found\n"); ImGuiSystem::AddLog("[error] Packet type not found\n"); } } int NetworkManager::GetFinalTransferSizeOfPacket(im_packet_t *packet) { if (!packet) return 0; im_packet_internal_t internal_packet; int size = packet->datalen + //this is the data sizeof(internal_packet.datalen) + sizeof(internal_packet.part) + sizeof(internal_packet.type) + sizeof(internal_packet.playernum) + sizeof(internal_packet.code) + (2 * sizeof(internal_packet.length1)); return size; }
31.892086
136
0.747575
hsrob
0e885bc0cdfc2aaf5b4435dbe04d955d0ef4cf5e
10,917
hpp
C++
src/xpcc/utils/arithmetic_traits.hpp
walmis/xpcc
1d87c4434530c6aeac923f57d379aeaf32e11e1e
[ "BSD-3-Clause" ]
5
2016-02-06T14:57:35.000Z
2018-01-02T23:34:18.000Z
src/xpcc/utils/arithmetic_traits.hpp
walmis/xpcc
1d87c4434530c6aeac923f57d379aeaf32e11e1e
[ "BSD-3-Clause" ]
null
null
null
src/xpcc/utils/arithmetic_traits.hpp
walmis/xpcc
1d87c4434530c6aeac923f57d379aeaf32e11e1e
[ "BSD-3-Clause" ]
1
2020-04-19T13:16:31.000Z
2020-04-19T13:16:31.000Z
// coding: utf-8 // ---------------------------------------------------------------------------- /* Copyright (c) 2009, Roboterclub Aachen e.V. * 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 Roboterclub Aachen e.V. 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 ROBOTERCLUB AACHEN E.V. ''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 ROBOTERCLUB AACHEN E.V. 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 XPCC__ARITHMETIC_TRAITS_HPP #define XPCC__ARITHMETIC_TRAITS_HPP #include <stdint.h> #include <xpcc/architecture/utils.hpp> #include <xpcc/utils/template_metaprogramming.hpp> namespace xpcc { /** * \ingroup utils * \defgroup arithmetic_trais Arithmetic Traits * \brief Traits to give numbers more information then they have by * default in C++ * * \section provides Values provided by these traits * * - \c WideType Type that can holds the doubled length of data. * May be used to hold the result of a multiplication. * - \c SignedType Signed type for the given type. It applies * <i>T == SignedType</i> if T is already signed. * - \c UnsignedType Some as SignedType only for unsigned types * - \c min() smallest value. * - \c max() biggest value * - \c isSigned is this a signed or unsigned type * - \c isFloatingPoint is this a floating point type * - \c isInteger is this a integer type * - \c decimalDigits count of digits to display this type in decimal * * \section usage Usage * \code * typedef typename xpcc::ArithmeticTraits<T>::WideType T_DOUBLE; * * T min = xpcc::ArithmeticTraits<T>::min(); * T max = xpcc::ArithmeticTraits<T>::max(); * \endcode * * \author Martin Rosekeit <martin.rosekeit@rwth-aachen.de> * \author Fabian Greif <fabian.greif@rwth-aachen.de> */ // ------------------------------------------------------------------------ /*\{*/ template<typename T> struct ArithmeticTraits { }; // ------------------------------------------------------------------------ template<> struct ArithmeticTraits<char> { typedef int16_t WideType; typedef signed char SignedType; typedef unsigned char UnsignedType; static const unsigned char decimalDigits = 4; // inc sign static const bool isFloatingPoint = false; static const bool isInteger = true; }; // ------------------------------------------------------------------------ template<> struct ArithmeticTraits<signed char> { typedef int16_t WideType; typedef int8_t SignedType; typedef uint8_t UnsignedType; static const unsigned char decimalDigits = 4; // inc sign static const bool isSigned = true; static const bool isFloatingPoint = false; static const bool isInteger = true; static ALWAYS_INLINE signed char min() { return -127 - 1; } static ALWAYS_INLINE signed char max() { return 127; } }; // ------------------------------------------------------------------------ template<> struct ArithmeticTraits<unsigned char> { typedef uint16_t WideType; typedef int8_t SignedType; typedef uint8_t UnsignedType; static const uint8_t decimalDigits = 3; static const bool isSigned = false; static const bool isFloatingPoint = false; static const bool isInteger = true; static ALWAYS_INLINE unsigned char min() { return 0; } static ALWAYS_INLINE unsigned char max() { return 255; } }; // ------------------------------------------------------------------------ template<> struct ArithmeticTraits<int16_t> { typedef int32_t WideType; typedef int16_t SignedType; typedef uint16_t UnsignedType; static const uint8_t decimalDigits = 6; // inc. sign static const bool isSigned = true; static const bool isFloatingPoint = false; static const bool isInteger = true; static ALWAYS_INLINE int16_t min() { return -32767 - 1; } static ALWAYS_INLINE int16_t max() { return 32767; } }; // ------------------------------------------------------------------------ template<> struct ArithmeticTraits<uint16_t> { typedef uint32_t WideType; typedef int16_t SignedType; typedef uint16_t UnsignedType; static const uint8_t decimalDigits = 6; static const bool isSigned = false; static const bool isFloatingPoint = false; static const bool isInteger = true; static ALWAYS_INLINE uint16_t min() { return 0; } static ALWAYS_INLINE uint16_t max() { return 65535; } }; // ------------------------------------------------------------------------ template<> struct ArithmeticTraits<int32_t> { #if defined(XPCC__CPU_AVR) typedef float WideType; // int64_t is on AVRs only a int32_t #else typedef int64_t WideType; #endif typedef int32_t SignedType; typedef uint32_t UnsignedType; static const uint8_t decimalDigits = 11; // inc. sign static const bool isSigned = true; static const bool isFloatingPoint = false; static const bool isInteger = true; static ALWAYS_INLINE int32_t min() { return -2147483647L - 1; } static ALWAYS_INLINE int32_t max() { return 2147483647L; } }; // ------------------------------------------------------------------------ template<> struct ArithmeticTraits<uint32_t> { #if defined(XPCC__CPU_AVR) typedef float WideType; // int64_t is on AVRs only a int32_t #else typedef uint64_t WideType; #endif typedef int32_t SignedType; typedef uint32_t UnsignedType; static const uint8_t decimalDigits = 10; static const bool isSigned = false; static const bool isFloatingPoint = false; static const bool isInteger = true; static ALWAYS_INLINE uint32_t min() { return 0; } static ALWAYS_INLINE uint32_t max() { return 4294967295UL; } }; #if defined(XPCC__CPU_ARM) // ------------------------------------------------------------------------ // For ARM 'int32_t' is of type 'long'. Therefore there is no // class here for the default type 'int'. template<> struct ArithmeticTraits<int> { typedef int64_t WideType; typedef int32_t SignedType; typedef uint32_t UnsignedType; static const uint8_t decimalDigits = 11; // inc. sign static const bool isSigned = true; static const bool isFloatingPoint = false; static const bool isInteger = true; static ALWAYS_INLINE int32_t min() { return -2147483647L - 1; } static ALWAYS_INLINE int32_t max() { return 2147483647L; } }; template<> struct ArithmeticTraits<unsigned int> { typedef uint64_t WideType; typedef int32_t SignedType; typedef uint32_t UnsignedType; static const uint8_t decimalDigits = 10; static const bool isSigned = false; static const bool isFloatingPoint = false; static const bool isInteger = true; static ALWAYS_INLINE uint32_t min() { return 0; } static ALWAYS_INLINE uint32_t max() { return 4294967295UL; } }; #endif // ------------------------------------------------------------------------ template<> struct ArithmeticTraits<int64_t> { typedef double WideType; typedef int64_t SignedType; typedef uint64_t UnsignedType; static const uint8_t decimalDigits = 20; // inc. sign static const bool isSigned = true; static const bool isFloatingPoint = false; static const bool isInteger = true; static ALWAYS_INLINE int64_t min() { return -9223372036854775807LL - 1; } static ALWAYS_INLINE uint64_t max() { return 9223372036854775807LL; } }; // ------------------------------------------------------------------------ template<> struct ArithmeticTraits<uint64_t> { typedef double WideType; typedef int64_t SignedType; typedef uint64_t UnsignedType; static const uint8_t decimalDigits = 20; static const bool isSigned = false; static const bool isFloatingPoint = false; static const bool isInteger = true; static ALWAYS_INLINE uint64_t min() { return 0; } static ALWAYS_INLINE uint64_t max() { return 18446744073709551615ULL; } }; // ------------------------------------------------------------------------ template<> struct ArithmeticTraits<float> { typedef float WideType; typedef float SignedType; typedef float UnsignedType; static const bool isSigned = true; static const bool isFloatingPoint = true; static const bool isInteger = false; static ALWAYS_INLINE float min() { return __FLT_MIN__; } static ALWAYS_INLINE float max() { return __FLT_MAX__; } static ALWAYS_INLINE float epsilon() { return __FLT_EPSILON__; } }; // ------------------------------------------------------------------------ template<> struct ArithmeticTraits<double> { typedef double WideType; typedef double SignedType; typedef double UnsignedType; static const bool isSigned = true; static const bool isFloatingPoint = true; static const bool isInteger = false; static ALWAYS_INLINE double min() { return __DBL_MIN__; } static ALWAYS_INLINE double max() { return __DBL_MAX__; } static ALWAYS_INLINE double epsilon() { return __DBL_EPSILON__; } }; /*\}*/ } #endif // XPCC__ARITHMETIC_TRAITS_HPP
25.388372
80
0.608226
walmis
0e89635f1a94d8ab082928f111b26a716568fc71
2,477
hxx
C++
opencascade/math_FunctionSetWithDerivatives.hxx
mgreminger/OCP
92eacb99497cd52b419c8a4a8ab0abab2330ed42
[ "Apache-2.0" ]
null
null
null
opencascade/math_FunctionSetWithDerivatives.hxx
mgreminger/OCP
92eacb99497cd52b419c8a4a8ab0abab2330ed42
[ "Apache-2.0" ]
null
null
null
opencascade/math_FunctionSetWithDerivatives.hxx
mgreminger/OCP
92eacb99497cd52b419c8a4a8ab0abab2330ed42
[ "Apache-2.0" ]
null
null
null
// Created on: 1991-05-13 // Created by: Laurent PAINNOT // Copyright (c) 1991-1999 Matra Datavision // Copyright (c) 1999-2014 OPEN CASCADE SAS // // This file is part of Open CASCADE Technology software library. // // This library is free software; you can redistribute it and/or modify it under // the terms of the GNU Lesser General Public License version 2.1 as published // by the Free Software Foundation, with special exception defined in the file // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT // distribution for complete text of the license and disclaimer of any warranty. // // Alternatively, this file may be used under the terms of Open CASCADE // commercial license or contractual agreement. #ifndef _math_FunctionSetWithDerivatives_HeaderFile #define _math_FunctionSetWithDerivatives_HeaderFile #include <Standard.hxx> #include <Standard_DefineAlloc.hxx> #include <Standard_Handle.hxx> #include <math_FunctionSet.hxx> #include <Standard_Integer.hxx> #include <Standard_Boolean.hxx> #include <math_Vector.hxx> class math_Matrix; //! This abstract class describes the virtual functions associated //! with a set of N Functions each of M independent variables. class math_FunctionSetWithDerivatives : public math_FunctionSet { public: DEFINE_STANDARD_ALLOC //! Returns the number of variables of the function. Standard_EXPORT virtual Standard_Integer NbVariables() const = 0; //! Returns the number of equations of the function. Standard_EXPORT virtual Standard_Integer NbEquations() const = 0; //! Computes the values <F> of the Functions for the //! variable <X>. //! Returns True if the computation was done successfully, //! False otherwise. Standard_EXPORT virtual Standard_Boolean Value (const math_Vector& X, math_Vector& F) = 0; //! Returns the values <D> of the derivatives for the //! variable <X>. //! Returns True if the computation was done successfully, //! False otherwise. Standard_EXPORT virtual Standard_Boolean Derivatives (const math_Vector& X, math_Matrix& D) = 0; //! returns the values <F> of the functions and the derivatives //! <D> for the variable <X>. //! Returns True if the computation was done successfully, //! False otherwise. Standard_EXPORT virtual Standard_Boolean Values (const math_Vector& X, math_Vector& F, math_Matrix& D) = 0; protected: private: }; #endif // _math_FunctionSetWithDerivatives_HeaderFile
28.147727
109
0.757771
mgreminger
0e8c2db1c9f9cd5120ac2d359ed11dfbf2248683
1,378
cpp
C++
src/gl/hqnx/init.cpp
351ELEC/lzdoom
2ee3ea91bc9c052b3143f44c96d85df22851426f
[ "RSA-MD" ]
5
2021-07-31T03:34:09.000Z
2021-08-31T21:43:50.000Z
source/common/textures/hires/hqnx/init.cpp
Quake-Backup/Raze
16c81f0b1f409436ebf576d2c23f2459a29b34b4
[ "RSA-MD" ]
4
2021-09-02T00:05:17.000Z
2021-09-07T14:56:12.000Z
source/common/textures/hires/hqnx/init.cpp
Quake-Backup/Raze
16c81f0b1f409436ebf576d2c23f2459a29b34b4
[ "RSA-MD" ]
1
2021-09-28T19:03:39.000Z
2021-09-28T19:03:39.000Z
/* * Copyright (C) 2010 Cameron Zemek ( grom@zeminvaders.net) * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "hqx.h" uint32_t *RGBtoYUV; uint32_t YUV1, YUV2; HQX_API void HQX_CALLCONV hqxInit(void) { /* Initalize RGB to YUV lookup table */ uint32_t c, r, g, b, y, u, v; RGBtoYUV = new uint32_t[16777216]; for (c = 0; c < 16777215; c++) { r = (c & 0xFF0000) >> 16; g = (c & 0x00FF00) >> 8; b = c & 0x0000FF; y = (uint32_t)(0.299*r + 0.587*g + 0.114*b); u = (uint32_t)(-0.169*r - 0.331*g + 0.5*b) + 128; v = (uint32_t)(0.5*r - 0.419*g - 0.081*b) + 128; RGBtoYUV[c] = (y << 16) + (u << 8) + v; } }
35.333333
74
0.642235
351ELEC
0e8edae199014bbf286010cf02974041d6f5dd07
5,286
cpp
C++
src/UT_Base/StringTest.cpp
CronosTs/phobos3d
c0336456d946f3a9e62fb9b7815831ad32820da5
[ "Zlib" ]
2
2015-01-14T20:20:51.000Z
2015-09-08T15:49:18.000Z
src/UT_Base/StringTest.cpp
CronosTs/phobos3d
c0336456d946f3a9e62fb9b7815831ad32820da5
[ "Zlib" ]
null
null
null
src/UT_Base/StringTest.cpp
CronosTs/phobos3d
c0336456d946f3a9e62fb9b7815831ad32820da5
[ "Zlib" ]
1
2015-11-03T13:58:58.000Z
2015-11-03T13:58:58.000Z
/* Phobos 3d January 2010 Copyright (c) 2005-2011 Bruno Sanches http://code.google.com/p/phobos3d This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ #include <boost/test/unit_test.hpp> #include <Phobos/String.h> #define TRIM_STR "a b c" #define RIGHT_TRIM_STR "a b c " #define LEFT_TRIM_STR " a b c" #define BOTH_TRIM_STR " a b c " #define BLANK_STRING " " using namespace Phobos; BOOST_AUTO_TEST_CASE(string_trim) { String_t str(RIGHT_TRIM_STR); StringTrim(str, STRING_TRIM_LEFT); BOOST_REQUIRE(str.compare(RIGHT_TRIM_STR) == 0); StringTrim(str, STRING_TRIM_RIGHT); BOOST_REQUIRE(str.compare(TRIM_STR) == 0); StringTrim(str, STRING_TRIM_BOTH); BOOST_CHECK(str.compare(TRIM_STR) == 0); str = ""; StringTrim(str, STRING_TRIM_BOTH); BOOST_CHECK(str.compare("") == 0); str = LEFT_TRIM_STR; StringTrim(str, STRING_TRIM_RIGHT); BOOST_REQUIRE(str.compare(LEFT_TRIM_STR) == 0); StringTrim(str, STRING_TRIM_LEFT); BOOST_REQUIRE(str.compare(TRIM_STR) == 0); StringTrim(str, STRING_TRIM_BOTH); BOOST_CHECK(str.compare(TRIM_STR) == 0); str = BOTH_TRIM_STR; StringTrim(str, STRING_TRIM_RIGHT); BOOST_REQUIRE(str.compare(LEFT_TRIM_STR) == 0); //str.Trim(IM_STRING_TRIM_LEFT); StringTrim(str, STRING_TRIM_LEFT); BOOST_CHECK(str.compare(TRIM_STR) == 0); str = BOTH_TRIM_STR; //str.Trim(IM_STRING_TRIM_BOTH); StringTrim(str, STRING_TRIM_BOTH); BOOST_CHECK(str.compare(TRIM_STR) == 0); str = BLANK_STRING; //str.Trim(IM_STRING_TRIM_LEFT); StringTrim(str, STRING_TRIM_LEFT); BOOST_CHECK(str.compare("") == 0); str = BLANK_STRING; //str.Trim(IM_STRING_TRIM_RIGHT); StringTrim(str, STRING_TRIM_RIGHT); BOOST_CHECK(str.compare("") == 0); } BOOST_AUTO_TEST_CASE(string_empty) { String_t str; BOOST_CHECK(StringIsBlank(str)); str = " a"; BOOST_CHECK(!StringIsBlank(str)); str = ""; BOOST_CHECK(StringIsBlank(str)); str = "bcs"; BOOST_CHECK(!StringIsBlank(str)); str = BLANK_STRING; BOOST_CHECK(StringIsBlank(str)); } BOOST_AUTO_TEST_CASE(string_split) { /* "bla\nbla" (split by \n) "" (splut by \n) "\nbla\n" (split by \n) "bla\n\nbla" "\n\n" "bla" "\nbla" */ String_t str("bla\nblu"); String_t split; size_t it = 0; BOOST_REQUIRE(StringSplitBy(split, str, '\n', it, &it)); BOOST_REQUIRE(split.compare("bla") == 0); BOOST_REQUIRE(it == 4); BOOST_REQUIRE(StringSplitBy(split, str, '\n', it, &it)); BOOST_REQUIRE(split.compare("blu")==0); BOOST_REQUIRE(it == 7); BOOST_CHECK(!StringSplitBy(split, str, '\n', it, &it)); str.clear(); it = 0; BOOST_CHECK(!StringSplitBy(split, str, '\n', it, &it)); str = "\nbla\n"; it = 0; BOOST_REQUIRE(StringSplitBy(split, str, '\n', it, &it)); BOOST_REQUIRE(it == 5); BOOST_REQUIRE(split.compare("bla")==0); BOOST_CHECK(!StringSplitBy(split, str, '\n', it, &it)); str = "bla\n\nblu"; it = 0; BOOST_REQUIRE(StringSplitBy(split, str, '\n', it, &it)); BOOST_REQUIRE(it == 4); BOOST_REQUIRE(split.compare("bla") == 0); BOOST_REQUIRE(StringSplitBy(split, str, '\n', it, &it)); BOOST_REQUIRE(it == 8); BOOST_REQUIRE(split.compare("blu")==0); BOOST_CHECK(!StringSplitBy(split, str, '\n', it, &it)); str = "\n\n"; it = 0; BOOST_CHECK(!StringSplitBy(split, str, '\n', it, &it)); str = "bla"; it = 0; BOOST_REQUIRE(StringSplitBy(split, str, '\n', it, &it)); BOOST_REQUIRE(it == 3); BOOST_REQUIRE(split.compare("bla")==0); BOOST_CHECK(!StringSplitBy(split, str, '\n', it, &it)); str = "\nbla"; it = 0; BOOST_REQUIRE(StringSplitBy(split, str, '\n', it, &it)); BOOST_REQUIRE(it == 4); BOOST_REQUIRE(split.compare("bla") == 0); BOOST_CHECK(!StringSplitBy(split, str, '\n', it, &it)); str = "\nbla"; it = 1024*1024; BOOST_CHECK(!StringSplitBy(split, str, '\n', it, &it)); } BOOST_AUTO_TEST_CASE(string_replace_all) { String_t str("teste\\bla"); String_t tmp; //replace on dest StringReplaceAll(tmp, str, '\\', '/'); BOOST_REQUIRE(tmp.compare("teste/bla") == 0); BOOST_REQUIRE(str.compare("teste\\bla") == 0); //replace in place StringReplaceAll(str, 'e', '3'); BOOST_REQUIRE(str.compare("t3st3\\bla") == 0); //test no replace, but string should be copied StringReplaceAll(tmp, str, 'e', '/'); BOOST_REQUIRE(tmp.compare("t3st3\\bla") == 0); } BOOST_AUTO_TEST_CASE(string_to_boolean) { String_t str("0"); BOOST_CHECK(StringToBoolean(str) == false); str = "1"; BOOST_CHECK(StringToBoolean(str) == true); str = "true"; BOOST_CHECK(StringToBoolean(str) == true); str = "false"; BOOST_CHECK(StringToBoolean(str) == false); }
24.933962
243
0.695233
CronosTs
0e915123ca572f6ea04d3034f4e498cf90597f67
2,312
cpp
C++
engine/mono/src/managed_interface/resources/filesystem_collection_provider.cpp
aeon-engine/aeon-engine
9efcf83985110c36ebf0964bd4f76b261f2f6717
[ "MIT" ]
12
2017-02-25T17:14:15.000Z
2021-08-02T13:39:18.000Z
engine/mono/src/managed_interface/resources/filesystem_collection_provider.cpp
aeon-engine/aeon-engine
9efcf83985110c36ebf0964bd4f76b261f2f6717
[ "MIT" ]
31
2017-02-23T06:59:44.000Z
2017-05-21T11:49:10.000Z
engine/mono/src/managed_interface/resources/filesystem_collection_provider.cpp
aeon-engine/aeon-engine
9efcf83985110c36ebf0964bd4f76b261f2f6717
[ "MIT" ]
5
2017-05-02T05:34:53.000Z
2020-05-19T06:57:50.000Z
/* * Copyright (c) 2012-2018 Robin Degen * * 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 <managed_interface/resources/filesystem_collection_provider.h> #include <aeon/resources/providers/filesystem_collection_provider.h> #include <managed_interface/mono_object_wrapper.h> #include <aeon/mono/mono_jit.h> #include <aeon/mono/mono_string.h> #include <aeon/mono/mono_jit_manager.h> #include <memory> namespace aeon { namespace mono { namespace managed_interface { void filesystem_collection_provider::register_internal_calls() { mono_jit::add_internal_call("AeonEngineMono.Resources.FilesystemCollectionProvider::.ctor(string)", aeon_mono_auto_wrap(filesystem_collection_provider::ctor)); } void filesystem_collection_provider::ctor(MonoObject *this_ptr, std::string base_path) { auto provider = std::make_unique<resources::filesystem_collection_provider>( mono_jit_manager::get_application().get_io_interface(), base_path); mono_object_wrapper<std::unique_ptr<resources::resource_collection_provider>>::create(this_ptr, std::move(provider)); } } // namespace managed_interface } // namespace mono } // namespace aeon
39.862069
111
0.740052
aeon-engine
0e92670f7af3cdc722448aef82c3396557643c5c
1,309
hpp
C++
src/umpire/util/AllocationRecord.hpp
PhilipDeegan/Umpire
3f047822380435131a00a0c7e356c9e845bbfef3
[ "MIT-0", "MIT" ]
229
2018-03-12T19:16:04.000Z
2022-03-25T15:21:39.000Z
src/umpire/util/AllocationRecord.hpp
PhilipDeegan/Umpire
3f047822380435131a00a0c7e356c9e845bbfef3
[ "MIT-0", "MIT" ]
504
2018-07-03T23:37:14.000Z
2022-03-23T20:15:26.000Z
src/umpire/util/AllocationRecord.hpp
PhilipDeegan/Umpire
3f047822380435131a00a0c7e356c9e845bbfef3
[ "MIT-0", "MIT" ]
53
2018-06-29T23:37:19.000Z
2022-03-28T17:39:20.000Z
////////////////////////////////////////////////////////////////////////////// // Copyright (c) 2016-21, Lawrence Livermore National Security, LLC and Umpire // project contributors. See the COPYRIGHT file for details. // // SPDX-License-Identifier: (MIT) ////////////////////////////////////////////////////////////////////////////// #ifndef UMPIRE_AllocationRecord_HPP #define UMPIRE_AllocationRecord_HPP #include <cstddef> #include <memory> #include <string> #include "umpire/util/backtrace.hpp" namespace umpire { namespace strategy { class AllocationStrategy; } namespace util { struct AllocationRecord { AllocationRecord(void* p, std::size_t s, strategy::AllocationStrategy* strat) : ptr{p}, size{s}, strategy{strat}, name{} { } AllocationRecord(void* p, std::size_t s, strategy::AllocationStrategy* strat, const std::string& _name) : ptr{p}, size{s}, strategy{strat}, name{_name} { } AllocationRecord() : ptr{nullptr}, size{0}, strategy{nullptr}, name{} { } void* ptr; std::size_t size; strategy::AllocationStrategy* strategy; std::string name; #if defined(UMPIRE_ENABLE_BACKTRACE) util::backtrace allocation_backtrace; #endif // UMPIRE_ENABLE_BACKTRACE }; } // end of namespace util } // end of namespace umpire #endif // UMPIRE_AllocationRecord_HPP
25.173077
105
0.640183
PhilipDeegan
0e934556ea4c1539cba78495c5ac7be0aaf7fb1e
6,379
cpp
C++
tool_kits/ui_component/av_kit/gui/local_video_player/local_video_player_form_ui.cpp
stephenzhj/NIM_PC_Demo
0d2933955e079afa5c9e4df196ee017fad6c79af
[ "BSD-2-Clause", "OpenSSL" ]
161
2016-01-24T13:55:15.000Z
2021-06-01T03:48:56.000Z
tool_kits/ui_component/av_kit/gui/local_video_player/local_video_player_form_ui.cpp
stephenzhj/NIM_PC_Demo
0d2933955e079afa5c9e4df196ee017fad6c79af
[ "BSD-2-Clause", "OpenSSL" ]
49
2016-01-24T14:06:52.000Z
2021-06-01T07:14:53.000Z
tool_kits/ui_component/av_kit/gui/local_video_player/local_video_player_form_ui.cpp
xiejiulong/NIM_PC_Demo
47f74270b200bb365035209c9734723f1cb7efea
[ "BSD-2-Clause", "OpenSSL" ]
140
2016-02-22T09:42:07.000Z
2021-05-26T01:15:12.000Z
#include "stdafx.h" #include "local_video_player_form.h" #include "shared/modal_wnd/file_dialog_ex.h" #ifdef SUPPORTLOCALPLAYER const LPTSTR LocalVideoPlayerForm::kClassName = L"LocalVideoPlayerForm"; unsigned int LocalVideoPlayerForm::InstanceNum = 0; using namespace ui; LocalVideoPlayerForm::LocalVideoPlayerForm(const std::function<void()>& close_cb, const std::wstring& path) : close_cb_(close_cb),path_(path) { LocalVideoPlayerForm::InstanceNum++; } LocalVideoPlayerForm::~LocalVideoPlayerForm() { } ui::Control* LocalVideoPlayerForm::CreateControl(const std::wstring& pstrClass) { if (pstrClass == _T("BitmapControl")) { return new ui::VideoPlayerBitmapControl(); } return NULL; } std::wstring LocalVideoPlayerForm::GetSkinFolder() { return L"local_video_player"; } std::wstring LocalVideoPlayerForm::GetSkinFile() { return L"local_video_player.xml"; } ui::UILIB_RESOURCETYPE LocalVideoPlayerForm::GetResourceType() const { return ui::UILIB_RESOURCETYPE::UILIB_FILE; } std::wstring LocalVideoPlayerForm::GetZIPFileName() const { return L""; } std::wstring LocalVideoPlayerForm::GetWindowClassName() const { return kClassName; } UINT LocalVideoPlayerForm::GetClassStyle() const { return (UI_CLASSSTYLE_FRAME | CS_DBLCLKS); } void LocalVideoPlayerForm::InitWindow() { m_pRoot->AttachBubbledEvent(ui::kEventAll, nbase::Bind(&LocalVideoPlayerForm::Notify, this, std::placeholders::_1)); m_pRoot->AttachBubbledEvent(ui::kEventClick, nbase::Bind(&LocalVideoPlayerForm::OnClicked, this, std::placeholders::_1)); volume_box_ = (ui::VBox*)FindControl(L"volume_box"); canvas_ = (ui::VideoPlayerBitmapControl*)FindControl(L"video_display"); play_pause_box_ = (ui::TabBox*)FindControl(L"start_or_pause_box"); btn_start_ = (ui::Button*)FindControl(L"start"); playing_progress_ = (ui::Slider*)FindControl(L"playing_progress"); label_duration_ = (ui::Label*)FindControl(L"duration"); btn_volume_ = (ui::Button*)FindControl(L"volume_btn"); btn_mute_ = (ui::Button*)FindControl(L"volume_mute_btn"); if (!path_.empty()) nbase::ThreadManager::PostTask(ToWeakCallback([this](){ StartPlay(); })); } LRESULT LocalVideoPlayerForm::HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam) { if (uMsg == WM_SIZE) { if (wParam == SIZE_RESTORED) { if (is_max_window_) OnMaxWindow(false); } else if (wParam == SIZE_MAXIMIZED) { if (!is_max_window_) OnMaxWindow(true); } } return __super::HandleMessage(uMsg, wParam, lParam); } LRESULT LocalVideoPlayerForm::OnClose(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) { if (close_cb_ != nullptr) close_cb_(); auto post_close_cb = ToWeakCallback([this]() { while (playing_) Sleep(100); ::DestroyWindow(m_hWnd); //确保播放器实例销毁之后再真正关闭窗口 LocalVideoPlayerForm::InstanceNum--; }); ShowWindow(false); if (playing_) { Shutdown(); nbase::ThreadManager::PostDelayedTask(post_close_cb, nbase::TimeDelta::FromSeconds(1)); //等待shudown完成再关闭窗口 } else post_close_cb(); //直接关闭窗口 bHandled = true; return 0; } bool LocalVideoPlayerForm::Notify(ui::EventArgs * msg) { std::wstring name = msg->pSender->GetName(); if (msg->Type == ui::kEventValueChange) { if (name == L"playing_progress") { if (nelp_handle_) { double frac = playing_progress_->GetValue() / playing_progress_->GetMaxValue(); long long seek_pos = (long long)(total_duration_ * frac); Nelp_SeekTo(nelp_handle_, seek_pos); } } } else if (msg->Type == ui::kEventKillFocus) { if (name == L"volume_slider") { volume_box_->SetVisible(false); } } return true; } bool LocalVideoPlayerForm::OnClicked(ui::EventArgs * msg) { std::wstring name = msg->pSender->GetName(); if (name == L"volume_btn") { muted_ = true; Nelp_SetMute(nelp_handle_, true); btn_volume_->SetVisible(false); btn_mute_->SetVisible(true); } else if (name == L"volume_mute_btn") { muted_ = false; Nelp_SetMute(nelp_handle_, false); btn_volume_->SetVisible(true); btn_mute_->SetVisible(false); } else if (name == L"start" ) { ChangePlayerState(PlayerStateStarting); if (!StartPlay()) //这里只处理失败情况,收到NELP_MSG_PREPARED消息才算播放成功 ChangePlayerState(PlayerStateError); } else if (name == L"pause") { if (playing_) { Nelp_Pause(nelp_handle_); ChangePlayerState(PlayerStatePaused); } } else if (name == L"resume") { if (playing_) { Nelp_Resume(nelp_handle_); ChangePlayerState(PlayerStatePlaying); } } return false; } void LocalVideoPlayerForm::OnEsc(BOOL &bHandled) { Close(); } void LocalVideoPlayerForm::OnMaxWindow(bool _max) { if (is_max_window_ == _max) return; is_max_window_ = _max; if (_max) { FindControl(L"maxbtn")->SetVisible(false); FindControl(L"restorebtn")->SetVisible(true); } else { FindControl(L"maxbtn")->SetVisible(true); FindControl(L"restorebtn")->SetVisible(false); } } void LocalVideoPlayerForm::ChangePlayerState(PlayerState new_state) { state_ = new_state; switch (new_state) { case PlayerStateStarting: { play_pause_box_->SelectItem(L"start"); //显示开始按钮 btn_start_->SetEnabled(false); //disable开始按钮 break; } case PlayerStatePlaying: //Nelp_Start成功或Nelp_Resume之后 { play_pause_box_->SelectItem(L"pause"); //点播显示暂停按钮 btn_start_->SetEnabled(false); //disable开始按钮 playing_progress_->SetEnabled(true); playing_progress_->SetVisible(true); if (!refresh_time_flag_.HasUsed()) { auto refresh_time_cb = refresh_time_flag_.ToWeakCallback([this]() { RefreshPlayTime(); //开始刷新播放时间 }); nbase::ThreadManager::PostRepeatedTask(refresh_time_cb, nbase::TimeDelta::FromMilliseconds(500)); } break; } case PlayerStatePaused: { play_pause_box_->SelectItem(L"resume"); //显示继续播放按钮 btn_start_->SetEnabled(false); //disable开始按钮 break; } case PlayerStateStopping: { play_pause_box_->SelectItem(L"start"); //显示开始按钮 btn_start_->SetEnabled(false); //disable开始按钮 break; } case PlayerStateCompleted: case PlayerStateStopped: case PlayerStateError: { play_pause_box_->SelectItem(L"start"); //显示开始按钮 refresh_time_flag_.Cancel(); //取消刷新时间任务 btn_start_->SetEnabled(true); //disable开始按钮 playing_progress_->SetEnabled(false); if (new_state != PlayerStateCompleted) { playing_progress_->SetVisible(false); //隐藏进度条 playing_progress_->SetValue(0); label_duration_->SetText(L""); //重置播放时间 canvas_->Clear(); } break; } } } #endif
23.981203
141
0.726446
stephenzhj
0e968553b2656d4f10819f4e7227e479db0c27a2
503
hpp
C++
northstar/include/mock/MockIEnvironmentSensor.hpp
BryanChrisBrown/project_northstar_openvr_driver
cf16e98e24804aee699805dca766b8153f4e52e5
[ "Unlicense" ]
null
null
null
northstar/include/mock/MockIEnvironmentSensor.hpp
BryanChrisBrown/project_northstar_openvr_driver
cf16e98e24804aee699805dca766b8153f4e52e5
[ "Unlicense" ]
null
null
null
northstar/include/mock/MockIEnvironmentSensor.hpp
BryanChrisBrown/project_northstar_openvr_driver
cf16e98e24804aee699805dca766b8153f4e52e5
[ "Unlicense" ]
null
null
null
#pragma once #include <doctest/doctest.h> #include <doctest/trompeloeil.hpp> #include <ST/XRSession.h> #include <openvr_driver.h> #include "driver/IEnvironmentSensor.hpp" namespace northstar { namespace driver { class MockIEnvironmentSensor: public IEnvironmentSensor{ public: MAKE_MOCK2(GetPose, bool(vr::DriverPose_t&, EPoseRetrievalError&), override); MAKE_MOCK0(SessionStartWasSuccessful, bool(), override); }; } }
25.15
93
0.662028
BryanChrisBrown
0e98a2ce70cbd34d6e69579e94a6690563bf4c2b
571
cpp
C++
cpp/template_debugging/runtime.cpp
jl-wynen/code_stuffs
91ee6cd9075a7bc8697b03ce2eec13cb4fffb3ad
[ "MIT" ]
null
null
null
cpp/template_debugging/runtime.cpp
jl-wynen/code_stuffs
91ee6cd9075a7bc8697b03ce2eec13cb4fffb3ad
[ "MIT" ]
null
null
null
cpp/template_debugging/runtime.cpp
jl-wynen/code_stuffs
91ee6cd9075a7bc8697b03ce2eec13cb4fffb3ad
[ "MIT" ]
null
null
null
// gcc and clang only // Jonathan O'Connor // https://www.youtube.com/watch?v=83fMx7Grxys #include <iostream> #include <string> template <typename T> auto name_of_type(T* = nullptr) { std::string const pretty_func{__PRETTY_FUNCTION__}; auto const pos = pretty_func.find('='); if (pos == std::string::npos) { return std::string{"*failed to parse type* "} + pretty_func; } return pretty_func.substr(pos+2, pretty_func.length() - pos - 3); } int main() { std::cout << name_of_type<std::string>() << '\n'; }
22.84
68
0.61296
jl-wynen
0e9accd60c5b2fc640ba3c5e76b28e269666fff3
8,394
cpp
C++
segmentation/segmentation_common.cpp
ayghor/video_segment
c930c4555ff171e5013d525e218a4d8201ed0d51
[ "BSD-3-Clause" ]
159
2015-01-14T21:24:12.000Z
2021-08-29T19:38:27.000Z
segmentation/segmentation_common.cpp
Robotertechnik/video_segment
c930c4555ff171e5013d525e218a4d8201ed0d51
[ "BSD-3-Clause" ]
21
2015-01-06T15:51:10.000Z
2020-06-21T18:58:01.000Z
segmentation/segmentation_common.cpp
Robotertechnik/video_segment
c930c4555ff171e5013d525e218a4d8201ed0d51
[ "BSD-3-Clause" ]
86
2015-01-14T21:25:29.000Z
2020-06-21T18:52:19.000Z
// Copyright (c) 2010-2014, The Video Segmentation Project // All rights reserved. // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are met: // * 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 The Video Segmentation Project 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 "segmentation/segmentation_common.h" #include "base/base_impl.h" #include "segment_util/segmentation_util.h" namespace segmentation { std::unique_ptr<RegionInformation> RegionInformation::BasicCopy( bool with_rasterization) const { std::unique_ptr<RegionInformation> result(new RegionInformation()); result->size = size; result->neighbor_idx = neighbor_idx; result->MergeDescriptorsFrom(*this); if (with_rasterization) { result->raster.reset(new Rasterization3D(*raster)); } return std::move(result); } void RegionInformation::DescriptorDistances(const RegionInformation& rhs, vector<float>* distances) const { DCHECK_EQ(region_descriptors_.size(), rhs.region_descriptors_.size()); DCHECK_EQ(distances->size(), region_descriptors_.size()); for (int idx = 0; idx < region_descriptors_.size(); ++idx) { (*distances)[idx] = region_descriptors_[idx]->RegionDistance(*rhs.region_descriptors_[idx]); } } void RegionInformation::AddRegionDescriptor(std::unique_ptr<RegionDescriptor> desc) { desc->SetParent(this); region_descriptors_.push_back(std::move(desc)); } void RegionInformation::PopulatingDescriptorsFinished() { for (auto& descriptor_ptr : region_descriptors_) { descriptor_ptr->PopulatingDescriptorFinished(); } } void RegionInformation::MergeDescriptorsFrom(const RegionInformation& rhs) { // This could be a new super-region (empty descriptors). Allocate in that case. const int num_descriptors = rhs.region_descriptors_.size(); if (region_descriptors_.empty()) { region_descriptors_.resize(num_descriptors); } for (int descriptor_idx = 0; descriptor_idx < num_descriptors; ++descriptor_idx) { DCHECK(rhs.region_descriptors_[descriptor_idx] != nullptr); if (region_descriptors_[descriptor_idx] == nullptr) { region_descriptors_[descriptor_idx].reset( rhs.region_descriptors_[descriptor_idx]->Clone()); // Update parent. region_descriptors_[descriptor_idx]->SetParent(this); } else { region_descriptors_[descriptor_idx]->MergeWithDescriptor( *rhs.region_descriptors_[descriptor_idx]); } } } void RegionInformation::UpdateDescriptors(const DescriptorUpdaterList& updater_list) { DCHECK_EQ(updater_list.size(), region_descriptors_.size()); for (int desc_idx = 0, desc_num = region_descriptors_.size(); desc_idx < desc_num; ++desc_idx) { region_descriptors_[desc_idx]->UpdateDescriptor(*updater_list[desc_idx]); } } void RegionInformation::OutputRegionFeatures( RegionFeatures* features) const { for (const auto& descriptor_ptr : region_descriptors_) { descriptor_ptr->AddToRegionFeatures(features); } } void MergeRegionInfoInto(const RegionInformation* src, RegionInformation* dst) { // Update area. dst->size += src->size; // Merge neighbor ids, avoid duplicates. vector<int> merged_neighbors; merged_neighbors.reserve(src->neighbor_idx.size() + dst->neighbor_idx.size()); std::set_union(src->neighbor_idx.begin(), src->neighbor_idx.end(), dst->neighbor_idx.begin(), dst->neighbor_idx.end(), std::back_inserter(merged_neighbors)); // Avoid adding dst->region_id to merged_neighbors. vector<int>::iterator dst_id_location = std::lower_bound(merged_neighbors.begin(), merged_neighbors.end(), dst->index); if (dst_id_location != merged_neighbors.end() && *dst_id_location == dst->index) { merged_neighbors.erase(dst_id_location); } dst->neighbor_idx.swap(merged_neighbors); // Merge scanline representation. if (src->raster != nullptr) { // Both RegionInfo's need to have rasterization present. DCHECK(dst->raster != nullptr); std::unique_ptr<Rasterization3D> merged_raster(new Rasterization3D()); MergeRasterization3D(*src->raster, *dst->raster, merged_raster.get()); dst->raster.swap(merged_raster); } // Merge children. if (src->child_idx != nullptr) { DCHECK(dst->child_idx != nullptr); vector<int> merged_children; merged_children.reserve(src->child_idx->size() + dst->child_idx->size()); std::set_union(src->child_idx->begin(), src->child_idx->end(), dst->child_idx->begin(), dst->child_idx->end(), back_inserter(merged_children)); dst->child_idx->swap(merged_children); } // Merge histograms. dst->MergeDescriptorsFrom(*src); } void CompleteRegionTreeIndexChange( int current_idx, int at_level, int new_idx, std::vector<std::unique_ptr<RegionInfoList>>* region_tree) { // Fetch RegionInformation from region_tree. CHECK(region_tree); CHECK_LT(at_level, region_tree->size()); CHECK_LT(current_idx, (*region_tree)[at_level]->size()); RegionInformation* region_info = (*region_tree)[at_level]->at(current_idx).get(); // Notify neighbor's of id change. for (int neighbor_idx : region_info->neighbor_idx) { RegionInformation* neighbor_info = (*region_tree)[at_level]->at(neighbor_idx).get(); // Find current_idx. auto idx_pos = std::lower_bound(neighbor_info->neighbor_idx.begin(), neighbor_info->neighbor_idx.end(), current_idx); DCHECK_EQ(*idx_pos, current_idx); // Erase and insert new_id, except if new_id and neighbor's id are identical // (no region should be neighbor of itself). In this case only erase. neighbor_info->neighbor_idx.erase(idx_pos); if (neighbor_info->index != new_idx) { InsertSortedUniquely(new_idx, &neighbor_info->neighbor_idx); } } // Notify children of id change. if (region_info->child_idx != nullptr) { for (int child_idx : *region_info->child_idx) { RegionInformation* child_info = (*region_tree)[at_level - 1]->at(child_idx).get(); DCHECK_EQ(child_info->parent_idx, current_idx); child_info->parent_idx = new_idx; } } // Notify parent of id change. if (region_info->parent_idx >= 0) { RegionInformation* parent_info = (*region_tree)[at_level + 1]->at(region_info->parent_idx).get(); // Find current id in parent's children. DCHECK(parent_info->child_idx); auto child_pos = std::lower_bound(parent_info->child_idx->begin(), parent_info->child_idx->end(), current_idx); DCHECK_EQ(*child_pos, current_idx); // Erase and insert new id. parent_info->child_idx->erase(child_pos); InsertSortedUniquely(new_idx, parent_info->child_idx.get()); } // Isolate region, after propagating merge to all adjacent regions. region_info->index = -1; } } // namespace segmentation.
38.682028
88
0.704313
ayghor
0e9bbff8a77f5c38b1e1a480ea1a84b99b417eae
4,750
cpp
C++
build/luadbg/luadbg.cpp
oceancx/xLua
cba692cc63d1748d876ab7eb3b292d15fd796468
[ "BSD-3-Clause" ]
null
null
null
build/luadbg/luadbg.cpp
oceancx/xLua
cba692cc63d1748d876ab7eb3b292d15fd796468
[ "BSD-3-Clause" ]
null
null
null
build/luadbg/luadbg.cpp
oceancx/xLua
cba692cc63d1748d876ab7eb3b292d15fd796468
[ "BSD-3-Clause" ]
null
null
null
#include "luadbg.h" #include "lua_net.h" #include "net_thread_queue.h" #include <functional> #include <thread> #include "buffer.h" #include "luadbg.inl" #include "lua_bind.h" #include "asio.hpp" using namespace cxezio; using asio::ip::tcp; std::string LUADBG_LINES_ENDING = ""; bool check_lua_error(lua_State* L, int res, const char* func) { if (res != LUA_OK) { luaL_traceback(L, L, lua_tostring(L, -1), 0); const char* errmsg = lua_tostring(L, -1); printf("%s\npcall error:\t[func]%s\n", errmsg, func); return false; } return true; } int debugger_send_message(lua_State* L); void luadbg_set_line_ending_in_c(const char* le) { LUADBG_LINES_ENDING = le; } const char* luadbg_get_line_ending_in_c() { return LUADBG_LINES_ENDING.c_str(); } std::thread* debuggee_thread; NetThreadQueue g_DebugAdapterQueue; class DebugSession { public: DebugSession(asio::io_context& io_context, lua_State* L, tcp::socket socket) :m_IOContext(io_context), m_L(L), m_Socket(std::move(socket)) { m_Buffer.resize(1); read_msg(); }; void read_msg() { asio::async_read(m_Socket, asio::buffer(m_Buffer.data(), m_Buffer.size()), [this](std::error_code ec, std::size_t /*length*/) { if (!ec) { ezBuf.Write(m_Buffer.data(), m_Buffer.size()); lua_getglobal(m_L, "debuggee_on_message"); lua_push_cxezio_buffer(m_L, ezBuf); lua_push_net_thread_queue(m_L, &g_DebugAdapterQueue); int res = lua_pcall(m_L, 2, 0, 0); check_lua_error(m_L, res); read_msg(); } else { } }); } void Send(const char* data, size_t len) { Buffer sendBuff; sendBuff.Write(data, len); asio::write(m_Socket, asio::buffer(sendBuff.Peek(), sendBuff.readable_size())); } private: asio::io_context& m_IOContext; Buffer ezBuf; tcp::socket m_Socket; std::vector<char> m_Buffer; lua_State* m_L; }; DebugSession* _DbgSession; void do_accept(tcp::acceptor& acceptor, lua_State* L, asio::io_context& iocontext) { acceptor.async_accept( [&acceptor, L, &iocontext](std::error_code ec, tcp::socket socket) { if (!ec) { _DbgSession = new DebugSession(iocontext, L, std::move(socket)); do_accept(acceptor, L, iocontext); } }); } #define luaL_requirelib(L,name,fn) (luaL_requiref(L, name, fn, 1),lua_pop(L, 1)) extern "C" int luaopen_cjson(lua_State * L); void DebuggeeThreadFunc(int port) { lua_State* L = luaL_newstate(); luaL_openlibs(L); luaL_requirelib(L, "cjson", luaopen_cjson); luaopen_netlib(L); luaopen_net_thread_queue(L); script_system_register_function(L, luadbg_set_line_ending_in_c); script_system_register_function(L, luadbg_get_line_ending_in_c); int res = luaL_loadbuffer(L, debuggee_code, strlen(debuggee_code), "__debuggee__"); check_lua_error(L, res); lua_pushstring(L, "debuggee"); res = lua_pcall(L, 1, LUA_MULTRET, 0); check_lua_error(L, res); asio::io_context iocontext; tcp::endpoint endpoint(tcp::v4(), port); tcp::acceptor acceptor(iocontext, endpoint); do_accept(acceptor, L, iocontext); iocontext.run(); lua_close(L); } int luadbg_listen(lua_State* L) { int port = (int)lua_tointeger(L, 1); if (port > 0) { debuggee_thread = new std::thread(DebuggeeThreadFunc, port); int res = luaL_loadbuffer(L, debugger_code, strlen(debugger_code), "@__debugger__"); check_lua_error(L, res); lua_pushstring(L, "debugger"); res = lua_pcall(L, 1, LUA_MULTRET, 0); check_lua_error(L, res); } printf("luadbg_listen %d\n", port); return 0; } void luadbg_stop() { if (debuggee_thread) { debuggee_thread->join(); delete debuggee_thread; debuggee_thread = nullptr; } } void debugger_sleep(int s) { #if defined(_WIN32) Sleep(s); #else sleep(s); #endif } const char* debugger_fetch_message() { if (!g_DebugAdapterQueue.Empty(NetThreadQueue::Read)) { static std::string msgstr; auto& msg = g_DebugAdapterQueue.Front(NetThreadQueue::Read); msgstr = std::string(msg.Peek(), msg.readable_size()); g_DebugAdapterQueue.PopFront(NetThreadQueue::Read); return msgstr.c_str(); } return ""; } int debugger_send_message(lua_State* L) { size_t len = 0; const char* data = luaL_tolstring(L, 1, &len); _DbgSession->Send(data, len); return 0; } bool debugger_is_connected() { return _DbgSession != nullptr; } extern "C" LUA_API int luaopen_luadbg(lua_State* L) { script_system_register_luac_function(L, luadbg_listen); script_system_register_function(L, luadbg_stop); script_system_register_function(L, debugger_sleep); script_system_register_function(L, debugger_fetch_message); script_system_register_function(L, debugger_is_connected); script_system_register_luac_function(L, debugger_send_message); script_system_register_function(L, luadbg_get_line_ending_in_c); return 1; }
22.511848
86
0.717895
oceancx
0e9da5e0721ec9c5c076fabe698ab814ad922c4f
2,799
cpp
C++
math/modular_inverse_fermat_little_theorem.cpp
dvijaymanohar/C-Plus-Plus
c987381c25858f08d0fe9301712ab6c1a10b433f
[ "MIT" ]
null
null
null
math/modular_inverse_fermat_little_theorem.cpp
dvijaymanohar/C-Plus-Plus
c987381c25858f08d0fe9301712ab6c1a10b433f
[ "MIT" ]
null
null
null
math/modular_inverse_fermat_little_theorem.cpp
dvijaymanohar/C-Plus-Plus
c987381c25858f08d0fe9301712ab6c1a10b433f
[ "MIT" ]
null
null
null
/** * @file * @brief C++ Program to find the modular inverse using [Fermat's Little * Theorem](https://en.wikipedia.org/wiki/Fermat%27s_little_theorem) * * Fermat's Little Theorem state that \f[ϕ(m) = m-1\f] * where \f$m\f$ is a prime number. * \f{eqnarray*}{ * a \cdot x &≡& 1 \;\text{mod}\; m\\ * x &≡& a^{-1} \;\text{mod}\; m * \f} * Using Euler's theorem we can modify the equation. *\f[ * a^{ϕ(m)} ≡ 1 \;\text{mod}\; m * \f] * (Where '^' denotes the exponent operator) * * Here 'ϕ' is Euler's Totient Function. For modular inverse existence 'a' and * 'm' must be relatively primes numbers. To apply Fermat's Little Theorem is * necessary that 'm' must be a prime number. Generally in many competitive * programming competitions 'm' is either 1000000007 (1e9+7) or 998244353. * * We considered m as large prime (1e9+7). * \f$a^{ϕ(m)} ≡ 1 \;\text{mod}\; m\f$ (Using Euler's Theorem) * \f$ϕ(m) = m-1\f$ using Fermat's Little Theorem. * \f$a^{m-1} ≡ 1 \;\text{mod}\; m\f$ * Now multiplying both side by \f$a^{-1}\f$. * \f{eqnarray*}{ * a^{m-1} \cdot a^{-1} &≡& a^{-1} \;\text{mod}\; m\\ * a^{m-2} &≡& a^{-1} \;\text{mod}\; m * \f} * * We will find the exponent using binary exponentiation. Such that the * algorithm works in \f$O(\log m)\f$ time. * * Examples: - * * a = 3 and m = 7 * * \f$a^{-1} \;\text{mod}\; m\f$ is equivalent to * \f$a^{m-2} \;\text{mod}\; m\f$ * * \f$3^5 \;\text{mod}\; 7 = 243 \;\text{mod}\; 7 = 5\f$ * <br/>Hence, \f$3^{-1} \;\text{mod}\; 7 = 5\f$ * or \f$3 \times 5 \;\text{mod}\; 7 = 1 \;\text{mod}\; 7\f$ * (as \f$a\times a^{-1} = 1\f$) */ #include <iostream> #include <vector> /** Recursive function to calculate exponent in \f$O(\log n)\f$ using binary * exponent. */ int64_t binExpo(int64_t a, int64_t b, int64_t m) { a %= m; int64_t res = 1; while (b > 0) { if (b % 2) { res = res * a % m; } a = a * a % m; // Dividing b by 2 is similar to right shift. b >>= 1; } return res; } /** Prime check in \f$O(\sqrt{m})\f$ time. */ bool isPrime(int64_t m) { if (m <= 1) { return false; } else { for (int64_t i = 2; i * i <= m; i++) { if (m % i == 0) { return false; } } } return true; } /** * Main function */ int main() { int64_t a, m; // Take input of a and m. std::cout << "Computing ((a^(-1))%(m)) using Fermat's Little Theorem"; std::cout << std::endl << std::endl; std::cout << "Give input 'a' and 'm' space separated : "; std::cin >> a >> m; if (isPrime(m)) { std::cout << "The modular inverse of a with mod m is (a^(m-2)) : "; std::cout << binExpo(a, m - 2, m) << std::endl; } else { std::cout << "m must be a prime number."; std::cout << std::endl; } }
23.923077
78
0.538049
dvijaymanohar
0e9db0a3bfc04e857dadce1d7c4bbe6121f1f642
5,754
hpp
C++
include/eve/function/fuzzy.hpp
the-moisrex/eve
80b52663eefee11460abb0aedf4158a5067cf7dc
[ "MIT" ]
340
2020-09-16T21:12:48.000Z
2022-03-28T15:40:33.000Z
third-party/eve/function/fuzzy.hpp
aguinet/ecsimd
cba9e7fe76601b98cbaeea317b6c4e671272e70b
[ "Apache-2.0" ]
383
2020-09-17T06:56:35.000Z
2022-03-13T15:58:53.000Z
third-party/eve/function/fuzzy.hpp
aguinet/ecsimd
cba9e7fe76601b98cbaeea317b6c4e671272e70b
[ "Apache-2.0" ]
28
2021-02-27T23:11:23.000Z
2022-03-25T12:31:29.000Z
//================================================================================================== /* EVE - Expressive Vector Engine Copyright : EVE Contributors & Maintainers SPDX-License-Identifier: MIT */ //================================================================================================== #pragma once #include <eve/detail/overload.hpp> #include <eve/detail/abi.hpp> namespace eve { //================================================================================================ // Function decorators mark-up used in function overloads struct almost_type : decorator_ { template<typename Function> constexpr EVE_FORCEINLINE auto operator()(Function f) const noexcept { return [f](auto&&... args) { return f(almost_type{}, EVE_FWD(args)...); }; } }; //================================================================================================ //! @addtogroup decorator //! @{ //! @var almost //! //! @brief Higher-order @callable imbuing a tolerant to little errors semantic onto other @callable{s}. //! //! @groupheader{Synopsis} //! //! if almost(eve::fname) is to be called then //! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp} //! #include <eve/function/fuzzy/fname.hpp> //! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //! must be included. //! //! @groupheader{Members Functions} //! //! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp} //! auto operator()(eve::callable auto const& f ) const noexcept; //! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //! @param f //! An instance of eve::callable //! //! @return //! A @callable performing the same kind of operation but while insuring that a small error on the //! parameters will not affect the result. //! //! almost is currently supported by eve::is_greater_equal, eve::is_less_equal, //! eve::is_not_greater, eve::is_not_less and eve::is_equal //! object functions. //! @} //================================================================================================ inline constexpr almost_type const almost = {}; //================================================================================================ // Function decorators mark-up used in function overloads struct definitely_type : decorator_ { template<typename Function> constexpr EVE_FORCEINLINE auto operator()(Function f) const noexcept { return [f](auto&&... args) { return f(definitely_type{}, EVE_FWD(args)...); }; } }; //================================================================================================ //! @addtogroup decorator //! @{ //! @var definitely //! //! @brief Higher-order @callable imbuing a tolerant to small errors semantic onto other @callable{s}. //! //! @groupheader{Synopsis} //! //! if definitely(eve::fname) is to be called then //! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp} //! #include <eve/function/fuzzy/fname.hpp> //! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //! must be included. //! //! @groupheader{Members Functions} //! //! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp} //! auto operator()(eve::callable auto const& f ) const noexcept; //! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //! @param f //! An instance of eve::callable //! //! @return //! A @callable performing the same kind of operation but while insuring that a small error on the //! parameters will not affect the result. //! //! eve::definitely is currently supported by eve::is_greater, eve::is_less, //! eve::is_not_greater_equal, eve::is_not_less_equal and eve::is_not_equal //! object functions. //! //! @} //================================================================================================ inline constexpr definitely_type const definitely = {}; //================================================================================================ // Function decorators mark-up used in function overloads struct tolerant_type : decorator_ { template<typename Function> constexpr EVE_FORCEINLINE auto operator()(Function f) const noexcept { return [f](auto&&... args) { return f(tolerant_type{}, EVE_FWD(args)...); }; } }; //================================================================================================ //! @addtogroup decorator //! @{ //! @var tolerant //! //! @brief Higher-order @callable imbuing a less strict semantic onto other @callable{s}. //! //! @groupheader{Synopsis} //! //! if tolerant(eve::fname) is to be called then //! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp} //! #include <eve/function/fuzzy/fname.hpp> //! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //! must be included. //! //! @groupheader{Members Functions} //! //! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp} //! auto operator()(eve::callable auto const& f ) const noexcept; //! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //! @param f //! An instance of eve::callable //! //! @return //! A @callable performing the same kind of operation but while insuring that a small error on the //! parameters will not affect the result. //! //! eve::tolerant is currently supported by eve::ceil, eve::floor and eve::trunc object functions. //! //! @} //================================================================================================ inline constexpr tolerant_type const tolerant = {}; }
36.188679
106
0.434654
the-moisrex
0e9f82aa4cf1defb1eea7821dd5e3e66bfa4c2d9
1,342
cpp
C++
src/voronoi/src/mp_sample_generator.cpp
frmr/gs
b9721ad27f59ca2e19f637bccd9eba32b663b6a3
[ "MIT" ]
2
2016-12-06T17:51:30.000Z
2018-06-21T08:52:58.000Z
src/voronoi/src/mp_sample_generator.cpp
frmr/gs
b9721ad27f59ca2e19f637bccd9eba32b663b6a3
[ "MIT" ]
null
null
null
src/voronoi/src/mp_sample_generator.cpp
frmr/gs
b9721ad27f59ca2e19f637bccd9eba32b663b6a3
[ "MIT" ]
null
null
null
#include "mp_sample_generator.h" #include <iostream> #include <cstdlib> #include <time.h> MPSampleGenerator::MPSampleGenerator() : seed(time(NULL)), re(seed) { //std::cout << "seed = " << seed << "\n"; unif = std::uniform_real_distribution<long double>(0.0,1.0); } MPSampleGenerator::MPSampleGenerator(unsigned int seed) : seed(seed), re(seed) { unif = std::uniform_real_distribution<long double>(0.0,1.0); } // Generates n * n jittered samples in the range [0,1) x [0,1) mpvec3* MPSampleGenerator::getJitteredSamplesMP(int n) { mpvec3* samples = new mpvec3[n*n]; const long double minBound = 0.0; const long double maxBound = 1.0; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { long double x = minBound + unif(re) * maxBound; long double y = minBound + unif(re) * maxBound; samples[i*n + j] = mpvec3((x+i)/n, (y+j)/n, 0.0); } } return samples; } // Generates n * n random samples in the range [0,1) x [0,1) mpvec3* MPSampleGenerator::getRandomSamplesMP(int n) { mpvec3* samples = new mpvec3[n*n]; for (int i = 0; i < n*n; i++) { long double x = unif(re); long double y = unif(re); samples[i] = mpvec3(x, y, 0.0); } return samples; }
22
64
0.568554
frmr
0ea387cb3bde12039b48aeb0e7caf36c8c8b6f94
11,752
cpp
C++
src/executor/update_executor.cpp
xinzhang1234/peloton
9b11d92dd5a2a0b32d5c39a9ba0b1aa45fe0b654
[ "Apache-2.0" ]
7
2017-03-12T01:57:48.000Z
2022-03-16T12:44:07.000Z
src/executor/update_executor.cpp
xinzhang1234/peloton
9b11d92dd5a2a0b32d5c39a9ba0b1aa45fe0b654
[ "Apache-2.0" ]
null
null
null
src/executor/update_executor.cpp
xinzhang1234/peloton
9b11d92dd5a2a0b32d5c39a9ba0b1aa45fe0b654
[ "Apache-2.0" ]
2
2017-03-30T00:43:50.000Z
2021-07-21T06:27:44.000Z
//===----------------------------------------------------------------------===// // // Peloton // // update_executor.cpp // // Identification: src/executor/update_executor.cpp // // Copyright (c) 2015-16, Carnegie Mellon University Database Group // //===----------------------------------------------------------------------===// #include "executor/update_executor.h" #include "planner/update_plan.h" #include "common/logger.h" #include "catalog/manager.h" #include "executor/logical_tile.h" #include "executor/executor_context.h" #include "common/container_tuple.h" #include "concurrency/transaction.h" #include "concurrency/transaction_manager_factory.h" #include "storage/data_table.h" #include "storage/tile_group_header.h" #include "storage/tile.h" namespace peloton { namespace executor { /** * @brief Constructor for update executor. * @param node Update node corresponding to this executor. */ UpdateExecutor::UpdateExecutor(const planner::AbstractPlan *node, ExecutorContext *executor_context) : AbstractExecutor(node, executor_context) {} /** * @brief Nothing to init at the moment. * @return true on success, false otherwise. */ bool UpdateExecutor::DInit() { PL_ASSERT(children_.size() == 1); PL_ASSERT(target_table_ == nullptr); PL_ASSERT(project_info_ == nullptr); // Grab settings from node const planner::UpdatePlan &node = GetPlanNode<planner::UpdatePlan>(); target_table_ = node.GetTable(); project_info_ = node.GetProjectInfo(); PL_ASSERT(target_table_); PL_ASSERT(project_info_); return true; } bool UpdateExecutor::PerformUpdatePrimaryKey(bool is_owner, oid_t tile_group_id, oid_t physical_tuple_id, ItemPointer &old_location, storage::TileGroup *tile_group) { auto &transaction_manager = concurrency::TransactionManagerFactory::GetInstance(); auto current_txn = executor_context_->GetTransaction(); /////////////////////////////////////// // Delete tuple/version chain /////////////////////////////////////// ItemPointer new_location = target_table_->InsertEmptyVersion(); // PerformUpdate() will not be executed if the insertion failed. // There is a write lock acquired, but since it is not in the write // set, // because we haven't yet put them into the write set. // the acquired lock can't be released when the txn is aborted. // the YieldOwnership() function helps us release the acquired write // lock. if (new_location.IsNull() == true) { LOG_TRACE("Fail to insert new tuple. Set txn failure."); if (is_owner == false) { // If the ownership is acquire inside this update executor, we // release it here transaction_manager.YieldOwnership(current_txn, tile_group_id, physical_tuple_id); } transaction_manager.SetTransactionResult(current_txn, ResultType::FAILURE); return false; } transaction_manager.PerformDelete(current_txn, old_location, new_location); //////////////////////////////////////////// // Insert tuple rather than install version //////////////////////////////////////////// auto target_table_schema = target_table_->GetSchema(); storage::Tuple new_tuple(target_table_schema, true); expression::ContainerTuple<storage::TileGroup> old_tuple(tile_group, physical_tuple_id); project_info_->Evaluate(&new_tuple, &old_tuple, nullptr, executor_context_); // insert tuple into the table. ItemPointer *index_entry_ptr = nullptr; peloton::ItemPointer location = target_table_->InsertTuple(&new_tuple, current_txn, &index_entry_ptr); // it is possible that some concurrent transactions have inserted the // same // tuple. // in this case, abort the transaction. if (location.block == INVALID_OID) { transaction_manager.SetTransactionResult(current_txn, peloton::ResultType::FAILURE); return false; } transaction_manager.PerformInsert(current_txn, location, index_entry_ptr); return true; } /** * @brief updates a set of columns * @return true on success, false otherwise. */ bool UpdateExecutor::DExecute() { PL_ASSERT(children_.size() == 1); PL_ASSERT(executor_context_); // We are scanning over a logical tile. LOG_TRACE("Update executor :: 1 child "); if (!children_[0]->Execute()) { return false; } std::unique_ptr<LogicalTile> source_tile(children_[0]->GetOutput()); auto &pos_lists = source_tile.get()->GetPositionLists(); storage::Tile *tile = source_tile->GetBaseTile(0); storage::TileGroup *tile_group = tile->GetTileGroup(); storage::TileGroupHeader *tile_group_header = tile_group->GetHeader(); auto tile_group_id = tile_group->GetTileGroupId(); auto &transaction_manager = concurrency::TransactionManagerFactory::GetInstance(); auto current_txn = executor_context_->GetTransaction(); // Update tuples in a given table for (oid_t visible_tuple_id : *source_tile) { oid_t physical_tuple_id = pos_lists[0][visible_tuple_id]; ItemPointer old_location(tile_group_id, physical_tuple_id); LOG_TRACE("Visible Tuple id : %u, Physical Tuple id : %u ", visible_tuple_id, physical_tuple_id); bool is_owner = transaction_manager.IsOwner(current_txn, tile_group_header, physical_tuple_id); bool is_written = transaction_manager.IsWritten( current_txn, tile_group_header, physical_tuple_id); PL_ASSERT((is_owner == false && is_written == true) == false); // Prepare to examine primary key bool ret = false; const planner::UpdatePlan &update_node = GetPlanNode<planner::UpdatePlan>(); if (is_owner == true && is_written == true) { if (update_node.GetUpdatePrimaryKey()) { // Update primary key ret = PerformUpdatePrimaryKey(is_owner, tile_group_id, physical_tuple_id, old_location, tile_group); // Examine the result if (ret == true) { executor_context_->num_processed += 1; // updated one } // When fail, ownership release is done inside PerformUpdatePrimaryKey else { return false; } } // Normal update (no primary key) else { // We have already owned a version // Make a copy of the original tuple and allocate a new tuple expression::ContainerTuple<storage::TileGroup> old_tuple( tile_group, physical_tuple_id); // Execute the projections project_info_->Evaluate(&old_tuple, &old_tuple, nullptr, executor_context_); transaction_manager.PerformUpdate(current_txn, old_location); } } // if we have already got the // ownership else { // Skip the IsOwnable and AcquireOwnership if we have already got the // ownership bool is_ownable = is_owner || transaction_manager.IsOwnable( current_txn, tile_group_header, physical_tuple_id); if (is_ownable == true) { // if the tuple is not owned by any transaction and is visible to // current transaction. bool acquire_ownership_success = is_owner || transaction_manager.AcquireOwnership( current_txn, tile_group_header, physical_tuple_id); if (acquire_ownership_success == false) { LOG_TRACE("Fail to insert new tuple. Set txn failure."); transaction_manager.SetTransactionResult(current_txn, ResultType::FAILURE); return false; } if (update_node.GetUpdatePrimaryKey()) { // Update primary key ret = PerformUpdatePrimaryKey(is_owner, tile_group_id, physical_tuple_id, old_location, tile_group); if (ret == true) { executor_context_->num_processed += 1; // updated one } // When fail, ownership release is done inside PerformUpdatePrimaryKey else { return false; } } // Normal update (no primary key) else { // if it is the latest version and not locked by other threads, then // insert a new version. // acquire a version slot from the table. ItemPointer new_location = target_table_->AcquireVersion(); auto &manager = catalog::Manager::GetInstance(); auto new_tile_group = manager.GetTileGroup(new_location.block); expression::ContainerTuple<storage::TileGroup> new_tuple( new_tile_group.get(), new_location.offset); expression::ContainerTuple<storage::TileGroup> old_tuple( tile_group, physical_tuple_id); // perform projection from old version to new version. // this triggers in-place update, and we do not need to allocate // another // version. project_info_->Evaluate(&new_tuple, &old_tuple, nullptr, executor_context_); // get indirection. ItemPointer *indirection = tile_group_header->GetIndirection(old_location.offset); // finally install new version into the table ret = target_table_->InstallVersion(&new_tuple, &(project_info_->GetTargetList()), current_txn, indirection); // PerformUpdate() will not be executed if the insertion failed. // There is a write lock acquired, but since it is not in the write // set, // because we haven't yet put them into the write set. // the acquired lock can't be released when the txn is aborted. // the YieldOwnership() function helps us release the acquired write // lock. if (ret == false) { LOG_TRACE("Fail to insert new tuple. Set txn failure."); if (is_owner == false) { // If the ownership is acquire inside this update executor, we // release it here transaction_manager.YieldOwnership(current_txn, tile_group_id, physical_tuple_id); } transaction_manager.SetTransactionResult(current_txn, ResultType::FAILURE); return false; } LOG_TRACE("perform update old location: %u, %u", old_location.block, old_location.offset); LOG_TRACE("perform update new location: %u, %u", new_location.block, new_location.offset); transaction_manager.PerformUpdate(current_txn, old_location, new_location); // TODO: Why don't we also do this in the if branch above? executor_context_->num_processed += 1; // updated one } } else { // transaction should be aborted as we cannot update the latest version. LOG_TRACE("Fail to update tuple. Set txn failure."); transaction_manager.SetTransactionResult(current_txn, ResultType::FAILURE); return false; } } } return true; } } // namespace executor } // namespace peloton
36.610592
80
0.604663
xinzhang1234
0ea51f282b2ac2a56f70ddf2af67ec7e664aec40
4,498
cpp
C++
Gems/Terrain/Code/Source/EditorComponents/EditorTerrainSurfaceGradientListComponent.cpp
ComarPers922/o3de
f321789456ceb1bd62405ee647c55900e980b4f8
[ "Apache-2.0", "MIT" ]
1
2022-01-11T14:38:59.000Z
2022-01-11T14:38:59.000Z
Gems/Terrain/Code/Source/EditorComponents/EditorTerrainSurfaceGradientListComponent.cpp
ComarPers922/o3de
f321789456ceb1bd62405ee647c55900e980b4f8
[ "Apache-2.0", "MIT" ]
null
null
null
Gems/Terrain/Code/Source/EditorComponents/EditorTerrainSurfaceGradientListComponent.cpp
ComarPers922/o3de
f321789456ceb1bd62405ee647c55900e980b4f8
[ "Apache-2.0", "MIT" ]
null
null
null
/* * Copyright (c) Contributors to the Open 3D Engine Project. * For complete copyright and license terms please see the LICENSE at the root of this distribution. * * SPDX-License-Identifier: Apache-2.0 OR MIT * */ #include <EditorComponents/EditorTerrainSurfaceGradientListComponent.h> #include <AzCore/Serialization/SerializeContext.h> #include <AzCore/Serialization/EditContext.h> namespace Terrain { void EditorTerrainSurfaceGradientListComponent::Reflect(AZ::ReflectContext* context) { BaseClassType::ReflectSubClass<EditorTerrainSurfaceGradientListComponent, BaseClassType>( context, 1, &LmbrCentral::EditorWrappedComponentBaseVersionConverter<typename BaseClassType::WrappedComponentType, typename BaseClassType::WrappedConfigType, 1> ); if (auto serialize = azrtti_cast<AZ::SerializeContext*>(context)) { if (auto edit = serialize->GetEditContext()) { edit->Class<TerrainSurfaceGradientMapping>("Terrain Surface Gradient Mapping", "Mapping between a gradient and a surface.") ->ClassElement(AZ::Edit::ClassElements::EditorData, "") ->Attribute(AZ::Edit::Attributes::Visibility, AZ::Edit::PropertyVisibility::Show) ->Attribute(AZ::Edit::Attributes::AutoExpand, true) ->DataElement( AZ::Edit::UIHandlers::Default, &TerrainSurfaceGradientMapping::m_gradientEntityId, "Gradient Entity", "ID of Entity providing a gradient.") ->Attribute(AZ::Edit::Attributes::ChangeNotify, AZ::Edit::PropertyRefreshLevels::AttributesAndValues) ->UIElement("GradientPreviewer", "Previewer") ->Attribute(AZ::Edit::Attributes::NameLabelOverride, "") ->Attribute(AZ_CRC_CE("GradientEntity"), &TerrainSurfaceGradientMapping::m_gradientEntityId) ->DataElement( AZ::Edit::UIHandlers::Default, &TerrainSurfaceGradientMapping::m_surfaceTag, "Surface Tag", "Surface type to map to this gradient.") ->Attribute(AZ::Edit::Attributes::EnumValues, &TerrainSurfaceGradientMapping::BuildSelectableTagList) ; edit->Class<TerrainSurfaceGradientListConfig>( "Terrain Surface Gradient List Component", "Provide mapping between gradients and surfaces.") ->ClassElement(AZ::Edit::ClassElements::EditorData, "") ->Attribute(AZ::Edit::Attributes::Visibility, AZ::Edit::PropertyVisibility::Show) ->Attribute(AZ::Edit::Attributes::AutoExpand, true) ->DataElement( AZ::Edit::UIHandlers::Default, &TerrainSurfaceGradientListConfig::m_gradientSurfaceMappings, "Gradient to Surface Mappings", "Maps Gradient Entities to Surfaces.") ; } } } void EditorTerrainSurfaceGradientListComponent::Activate() { UpdateConfigurationTagProvider(); BaseClassType::Activate(); } AZ::u32 EditorTerrainSurfaceGradientListComponent::ConfigurationChanged() { UpdateConfigurationTagProvider(); return BaseClassType::ConfigurationChanged(); } void EditorTerrainSurfaceGradientListComponent::UpdateConfigurationTagProvider() { for (TerrainSurfaceGradientMapping& mapping : m_configuration.m_gradientSurfaceMappings) { mapping.SetTagListProvider(this); } } AZStd::unordered_set<SurfaceData::SurfaceTag> EditorTerrainSurfaceGradientListComponent::GetSurfaceTagsInUse() const { AZStd::unordered_set<SurfaceData::SurfaceTag> tagsInUse; for (const TerrainSurfaceGradientMapping& mapping : m_configuration.m_gradientSurfaceMappings) { tagsInUse.insert(mapping.m_surfaceTag); } return AZStd::move(tagsInUse); } AZStd::vector<AZStd::pair<AZ::u32, AZStd::string>> TerrainSurfaceGradientMapping::BuildSelectableTagList() const { AZ_PROFILE_FUNCTION(Entity); return AZStd::move(Terrain::BuildSelectableTagList(m_tagListProvider, m_surfaceTag)); } void TerrainSurfaceGradientMapping::SetTagListProvider(const EditorSurfaceTagListProvider* tagListProvider) { m_tagListProvider = tagListProvider; } }
44.098039
139
0.656959
ComarPers922
0ea645dc8746ba3c9b1d20f8e3563de325bdb957
10,290
cpp
C++
src/AlienBlob.cpp
gregfriedland/AuroraV6
1199e4f7e4a17cf6fa08063ab9f22d6702a4ec5f
[ "MIT" ]
null
null
null
src/AlienBlob.cpp
gregfriedland/AuroraV6
1199e4f7e4a17cf6fa08063ab9f22d6702a4ec5f
[ "MIT" ]
null
null
null
src/AlienBlob.cpp
gregfriedland/AuroraV6
1199e4f7e4a17cf6fa08063ab9f22d6702a4ec5f
[ "MIT" ]
null
null
null
#include <map> #include <vector> #include "AlienBlob.h" #include "Drawer.h" #include "Util.h" #define DECAY 0.5f #define ALIENBLOB_SPEED_MULTIPLIER 0.07f static void init_noise(void); static float noise(float x, float y, float z, int octaves, float decay); static void alienblob(int width, int height, int numColors, float zoff, int perlinOctaves, float perlinDecay, float zoom, int* indices, float* sineTable); AlienBlobDrawer::AlienBlobDrawer(int width, int height, int palSize, Camera* camera) : Drawer("AlienBlob", width, height, palSize), m_colorIndex(0), m_camera(camera) { m_settings.insert(std::make_pair("speed",3)); m_settings.insert(std::make_pair("colorSpeed",0)); m_settings.insert(std::make_pair("detail",3)); m_settings.insert(std::make_pair("zoom",70)); m_settingsRanges.insert(std::make_pair("speed", std::make_pair(0,100))); m_settingsRanges.insert(std::make_pair("colorSpeed", std::make_pair(0,50))); m_settingsRanges.insert(std::make_pair("detail", std::make_pair(1,4))); m_settingsRanges.insert(std::make_pair("zoom", std::make_pair(0,100))); init_noise(); for (int i = 0; i < 360; i ++) m_sineTable[i] = sin(i * M_PI / 180); reset(); } void AlienBlobDrawer::reset() { m_pos = random2() % 1000; } void AlienBlobDrawer::draw(int* colIndices) { alienblob(m_width, m_height, m_palSize, m_pos, m_settings["detail"], DECAY, m_settings["zoom"]/100.0, colIndices, m_sineTable); for (int x = 0; x < m_width; x++) for (int y = 0; y < m_height; y++) colIndices[x + y * m_width] += m_colorIndex; m_pos += ALIENBLOB_SPEED_MULTIPLIER * m_settings["speed"] / 100.0; m_colorIndex += m_settings["colorSpeed"]; } AlienBlobDrawer::~AlienBlobDrawer() {} static void alienblob(int width, int height, int numColors, float zoff, int perlinOctaves, float perlinDecay, float zoom, int* indices, float* sineTable) { float incr = 0.3125; float noiseMult = 7; float multiplier = (1-zoom) + 0.02; int y, x; float yy = 0; for (y = 0; y < height; y++) { float xx = 0; for (x = 0; x < width; x++) { //float n = pnoise_harmonics(xx*multiplier, yy*multiplier, zoff, // perlinOctaves, perlinDecay); float n = noise(xx*multiplier, yy*multiplier, zoff, perlinOctaves, perlinDecay); // use pre-calculated sine results int deg = (int) ((n * noiseMult + 4 * M_PI) * 180 / M_PI); float h = (sineTable[deg % 360] + 1) / 2; // determine pixel color indices[x + y * width] = (int) (h * numColors); xx += incr; } yy += incr; } } #if 0 /* Ken Perlins improved noise - http://mrl.nyu.edu/~perlin/noise/ C-port: http://www.fundza.com/c4serious/noise/perlin/perlin.html by Malcolm Kesson; arduino port by Peter Chiochetti, Sep 2007 : - make permutation constant byte, obsoletes init(), lookup % 256 */ static const uint8_t p[] = { 151,160,137,91,90, 15,131, 13,201,95,96, 53,194,233, 7,225,140,36,103,30,69,142, 8,99,37,240,21,10,23,190, 6, 148,247,120,234,75, 0,26,197,62,94,252,219,203,117, 35,11,32,57,177, 33,88,237,149,56,87,174,20,125,136,171,168,68,175,74,165,71,134,139, 48,27,166, 77,146,158,231,83,111,229,122, 60,211,133,230,220,105,92, 41,55,46,245,40,244,102,143,54,65,25,63,161, 1,216,80,73,209,76,132, 187,208, 89, 18,169,200,196,135,130,116,188,159, 86,164,100,109,198, 173,186, 3,64,52,217,226,250,124,123,5,202,38,147,118,126,255,82,85, 212,207,206, 59,227, 47,16,58,17,182,189, 28,42,223,183,170,213,119, 248,152,2,44,154,163,70,221,153,101,155,167,43,172, 9,129,22,39,253, 19,98,108,110,79,113,224,232,178,185,112,104,218,246, 97,228,251,34, 242,193,238,210,144,12,191,179,162,241,81,51,145,235,249,14,239,107, 49,192,214, 31,181,199,106,157,184, 84,204,176,115,121,50,45,127, 4, 150,254,138,236,205, 93,222,114, 67,29,24, 72,243,141,128,195,78,66, 215,61,156,180 }; static float fade(float t){ return t * t * t * (t * (t * 6 - 15) + 10); } static float lerp(float t, float a, float b){ return a + t * (b - a); } static float grad(int hash, float x, float y, float z) { int h = hash & 15; /* CONVERT LO 4 BITS OF HASH CODE */ float u = h < 8 ? x : y, /* INTO 12 GRADIENT DIRECTIONS. */ v = h < 4 ? y : h==12||h==14 ? x : z; return ((h&1) == 0 ? u : -u) + ((h&2) == 0 ? v : -v); } #define P(x) p[(x) & 255] static float pnoise(float x, float y, float z) { int X = (int)floor(x) & 255, /* FIND UNIT CUBE THAT */ Y = (int)floor(y) & 255, /* CONTAINS POINT. */ Z = (int)floor(z) & 255; x -= floor(x); /* FIND RELATIVE X,Y,Z */ y -= floor(y); /* OF POINT IN CUBE. */ z -= floor(z); float u = fade(x), /* COMPUTE FADE CURVES */ v = fade(y), /* FOR EACH OF X,Y,Z. */ w = fade(z); //if (X==0 && Y==0 && x==0 && y==0) { // Serial.print(X); Serial.print(" "); Serial.print(x); Serial.print(" "); Serial.print(Y); Serial.print(" "); // Serial.print(y); Serial.print(" "); Serial.print(Z); Serial.print(" "); Serial.print(z); Serial.print(": "); Serial.println(w); //} int A = P(X)+Y, AA = P(A)+Z, AB = P(A+1)+Z, /* HASH COORDINATES OF */ B = P(X+1)+Y, BA = P(B)+Z, BB = P(B+1)+Z; /* THE 8 CUBE CORNERS, */ return lerp(w,lerp(v,lerp(u, grad(P(AA ), x, y, z), /* AND ADD */ grad(P(BA ), x-1, y, z)), /* BLENDED */ lerp(u, grad(P(AB ), x, y-1, z), /* RESULTS */ grad(P(BB ), x-1, y-1, z))), /* FROM 8 */ lerp(v, lerp(u, grad(P(AA+1), x, y, z-1), /* CORNERS */ grad(P(BA+1), x-1, y, z-1)), /* OF CUBE */ lerp(u, grad(P(AB+1), x, y-1, z-1), grad(P(BB+1), x-1, y-1, z-1)))); } // x, y, z, num harmonics, unused, harmonic falloff static float pnoise_harmonics(float x, float y, float z, int octaves, float decay) { float scale = 0; float result = 0; float decay2 = 1; int i; for (i=0; i<octaves; i++ ) { scale += decay2; result += pnoise(x, y, z) * decay2; decay2 *= decay; // x *= freq; // y *= freq; } return result / scale; } #endif /* -*- mode: java; c-basic-offset: 2; indent-tabs-mode: nil -*- */ /* Part of the Processing project - http://processing.org Copyright (c) 2012-13 The Processing Foundation Copyright (c) 2004-12 Ben Fry and Casey Reas Copyright (c) 2001-04 Massachusetts Institute of Technology This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, version 2.1. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ static float noise_fsc(float i); #define RANDOM() (random() / (float)RAND_MAX) #define SINCOS_PRECISION 0.5f #define SINCOS_LENGTH (360*2) #define DEG_TO_RAD (3.14159 / 180) #define PERLIN_YWRAPB 4 #define PERLIN_YWRAP (1<<PERLIN_YWRAPB) #define PERLIN_ZWRAPB 8 #define PERLIN_ZWRAP (1<<PERLIN_ZWRAPB) #define PERLIN_SIZE 4095 static float sinLUT[SINCOS_LENGTH]; static float cosLUT[SINCOS_LENGTH]; static int perlin_TWOPI, perlin_PI; static float *perlin_cosTable; static float perlin[PERLIN_SIZE+1]; static void init_noise(void) { srandom(clock()); perlin_TWOPI = perlin_PI = SINCOS_LENGTH; perlin_PI >>= 1; int i; for (i = 0; i < SINCOS_LENGTH; i++) { sinLUT[i] = (float) sin(i * DEG_TO_RAD * SINCOS_PRECISION); cosLUT[i] = (float) cos(i * DEG_TO_RAD * SINCOS_PRECISION); } perlin_cosTable = cosLUT; for (i = 0; i < PERLIN_SIZE + 1; i++) { perlin[i] = RANDOM(); //perlinRandom.nextFloat(); //(float)Math.random(); } } inline float noise_fsc(float i) { // using bagel's cosine table instead return 0.5f*(1.0f-perlin_cosTable[(int)(i*perlin_PI)%perlin_TWOPI]); } static float noise(float x, float y, float z, int perlin_octaves, float perlin_amp_falloff) { if (x<0) x=-x; if (y<0) y=-y; if (z<0) z=-z; int xi=(int)x, yi=(int)y, zi=(int)z; float xf = x - xi; float yf = y - yi; float zf = z - zi; float rxf, ryf; float r=0; float ampl=0.5f; float n1,n2,n3; int i; for (i=0; i<perlin_octaves; i++) { int of=xi+(yi<<PERLIN_YWRAPB)+(zi<<PERLIN_ZWRAPB); rxf=noise_fsc(xf); ryf=noise_fsc(yf); n1 = perlin[of&PERLIN_SIZE]; n1 += rxf*(perlin[(of+1)&PERLIN_SIZE]-n1); n2 = perlin[(of+PERLIN_YWRAP)&PERLIN_SIZE]; n2 += rxf*(perlin[(of+PERLIN_YWRAP+1)&PERLIN_SIZE]-n2); n1 += ryf*(n2-n1); of += PERLIN_ZWRAP; n2 = perlin[of&PERLIN_SIZE]; n2 += rxf*(perlin[(of+1)&PERLIN_SIZE]-n2); n3 = perlin[(of+PERLIN_YWRAP)&PERLIN_SIZE]; n3 += rxf*(perlin[(of+PERLIN_YWRAP+1)&PERLIN_SIZE]-n3); n2 += ryf*(n3-n2); n1 += noise_fsc(zf)*(n2-n1); r += n1*ampl; ampl *= perlin_amp_falloff; xi<<=1; xf*=2; yi<<=1; yf*=2; zi<<=1; zf*=2; if (xf>=1.0f) { xi++; xf--; } if (yf>=1.0f) { yi++; yf--; } if (zf>=1.0f) { zi++; zf--; } } return r; }
34.072848
135
0.563751
gregfriedland
0ea7001ff1f926124d546459a7d27c79ea3038d4
10,673
cpp
C++
src/world_interface/simulator_interface.cpp
huskyroboticsteam/Resurgence
649f78103b6d76709fdf55bb38d08c0ff50da140
[ "Apache-2.0" ]
3
2021-12-23T23:31:42.000Z
2022-02-16T07:17:41.000Z
src/world_interface/simulator_interface.cpp
huskyroboticsteam/Resurgence
649f78103b6d76709fdf55bb38d08c0ff50da140
[ "Apache-2.0" ]
2
2021-11-22T05:33:43.000Z
2022-01-23T07:01:47.000Z
src/world_interface/simulator_interface.cpp
huskyroboticsteam/Resurgence
649f78103b6d76709fdf55bb38d08c0ff50da140
[ "Apache-2.0" ]
null
null
null
#include "../Constants.h" #include "../Globals.h" #include "../Networking/websocket/WebSocketProtocol.h" #include "../Util.h" #include "../ar/read_landmarks.h" #include "../base64/base64_img.h" #include "../camera/Camera.h" #include "../camera/CameraConfig.h" #include "../kinematics/DiffDriveKinematics.h" #include "../log.h" #include "../navtypes.h" #include "world_interface.h" #include <atomic> #include <condition_variable> #include <mutex> #include <shared_mutex> #include <string> #include <nlohmann/json.hpp> #include <opencv2/core.hpp> using nlohmann::json; using namespace navtypes; using namespace robot::types; namespace { const std::string PROTOCOL_PATH("/simulator"); const std::map<motorid_t, std::string> motorNameMap = { {motorid_t::frontLeftWheel, "frontLeftWheel"}, {motorid_t::frontRightWheel, "frontRightWheel"}, {motorid_t::rearLeftWheel, "rearLeftWheel"}, {motorid_t::rearRightWheel, "rearRightWheel"}, {motorid_t::armBase, "armBase"}, {motorid_t::shoulder, "shoulder"}, {motorid_t::elbow, "elbow"}, {motorid_t::forearm, "forearm"}, {motorid_t::differentialRight, "differentialRight"}, {motorid_t::differentialLeft, "differentialLeft"}, {motorid_t::hand, "hand"}}; DataPoint<double> lastHeading; std::mutex headingMutex; DataPoint<gpscoords_t> lastGPS; std::mutex gpsMutex; DataPoint<points_t> lastLidar; std::mutex lidarMutex; DataPoint<pose_t> lastTruePose; std::mutex truePoseMutex; std::map<std::string, DataPoint<int32_t>> motorPosMap; std::shared_mutex motorPosMapMutex; using lscallback_t = std::function<void(robot::types::DataPoint<LimitSwitchData> limitSwitchData)>; std::map<std::string, std::map<robot::callbackid_t, lscallback_t>> limitSwitchCallbackMap; robot::callbackid_t nextCallbackID = 0; std::map<robot::callbackid_t, motorid_t> lsCallbackToMotorMap; std::mutex limitSwitchCallbackMapMutex; // protects both maps and nextCallbackID // stores the last camera frame for each camera std::map<CameraID, DataPoint<CameraFrame>> cameraFrameMap; // stores the index of the last camera frame for each camera // cameraFrameMap is not guaranteed to have valid data points, // but this one is guaranteed to have indices, if there are any std::map<CameraID, uint32_t> cameraLastFrameIdxMap; std::shared_mutex cameraFrameMapMutex; // protects both of the above maps // not modified after startup, no need to synchronize std::map<CameraID, cam::CameraConfig> cameraConfigMap; std::condition_variable connectionCV; std::mutex connectionMutex; bool simConnected = false; void sendJSON(const json& obj) { Globals::websocketServer.sendJSON(PROTOCOL_PATH, obj); } void initCameras() { auto cfg = cam::readConfigFromFile(Constants::AR_CAMERA_CONFIG_PATH); cameraConfigMap[Constants::AR_CAMERA_ID] = cfg; json msg = {{"type", "simCameraStreamOpenRequest"}, {"camera", Constants::AR_CAMERA_ID}, {"fps", 20}, {"width", 640}, {"height", 480}}; sendJSON(msg); } void handleGPS(json msg) { gpscoords_t coords{msg["latitude"], msg["longitude"]}; std::lock_guard<std::mutex> guard(gpsMutex); lastGPS = {coords}; } void handleLidar(json msg) { points_t lidar; datatime_t now = dataclock::now(); const auto& arr = msg["points"]; for (const auto& point : arr) { double r = point["r"]; double theta = point["theta"]; lidar.push_back({r * std::cos(theta), r * std::sin(theta), 1}); } std::lock_guard<std::mutex> guard(lidarMutex); lastLidar = {now, lidar}; } void handleIMU(json msg) { double qx = msg["x"]; double qy = msg["y"]; double qz = msg["z"]; double qw = msg["w"]; double heading = util::quatToHeading(qw, qx, qy, qz); std::lock_guard<std::mutex> guard(headingMutex); lastHeading = {heading}; } void handleCamFrame(json msg) { std::string cam = msg["camera"]; std::string b64 = msg["data"]; cv::Mat mat = base64::decodeMat(b64); // acquire exclusive lock std::lock_guard<std::shared_mutex> lock(cameraFrameMapMutex); auto entry = cameraLastFrameIdxMap.find(cam); uint32_t idx = 0; if (entry != cameraLastFrameIdxMap.end()) { idx = entry->second + 1; } CameraFrame cf = {mat, idx}; DataPoint<CameraFrame> df(cf); cameraFrameMap[cam] = df; cameraLastFrameIdxMap[cam] = idx; } void handleMotorStatus(json msg) { std::string motorName = msg["motor"]; auto posJson = msg["position"]; DataPoint<int32_t> posData; if (!posJson.is_null()) { int32_t pos = posJson; posData = {pos}; } std::unique_lock lock(motorPosMapMutex); motorPosMap.insert_or_assign(motorName, posData); } void handleLimitSwitch(json msg) { std::string motorName = msg["motor"]; uint8_t data; std::string limit = msg["limit"]; if (limit == "maximum") { data = 1 << LIMIT_SWITCH_LIM_MAX_IDX; } else if (limit == "minimum") { data = 1 << LIMIT_SWITCH_LIM_MIN_IDX; } DataPoint<LimitSwitchData> lsData(data); std::lock_guard lock(limitSwitchCallbackMapMutex); for (const auto& entry : limitSwitchCallbackMap.at(motorName)) { entry.second(lsData); } } void handleTruePose(json msg) { auto pos = msg["position"]; auto rot = msg["rotation"]; double qw = rot["w"]; double qx = rot["x"]; double qy = rot["y"]; double qz = rot["z"]; double heading = util::quatToHeading(qw, qx, qy, qz); pose_t pose = {pos["x"], pos["y"], heading}; std::lock_guard<std::mutex> lock(truePoseMutex); lastTruePose = {pose}; } void clientConnected() { log(LOG_INFO, "Simulator connected!\n"); { std::lock_guard<std::mutex> lock(connectionMutex); simConnected = true; } connectionCV.notify_one(); } void clientDisconnected() { log(LOG_ERROR, "ERROR: Simulator disconnected! World Interface disconnected!\n"); } void initSimServer() { websocket::WebSocketProtocol protocol(PROTOCOL_PATH); protocol.addMessageHandler("simImuOrientationReport", handleIMU); protocol.addMessageHandler("simLidarReport", handleLidar); protocol.addMessageHandler("simGpsPositionReport", handleGPS); protocol.addMessageHandler("simCameraStreamReport", handleCamFrame); protocol.addMessageHandler("simMotorStatusReport", handleMotorStatus); protocol.addMessageHandler("simLimitSwitchAlert", handleLimitSwitch); protocol.addMessageHandler("simRoverTruePoseReport", handleTruePose); protocol.addConnectionHandler(clientConnected); protocol.addDisconnectionHandler(clientDisconnected); Globals::websocketServer.addProtocol(protocol); { // wait for simulator to connect log(LOG_INFO, "Waiting for simulator connection...\n"); std::unique_lock<std::mutex> lock(connectionMutex); connectionCV.wait(lock, [] { return simConnected; }); } } } // namespace namespace robot { namespace { DiffDriveKinematics drive_kinematics(Constants::EFF_WHEEL_BASE); DiffWristKinematics wrist_kinematics; } const DiffDriveKinematics& driveKinematics() { return drive_kinematics; } const DiffWristKinematics& wristKinematics() { return wrist_kinematics; } extern const WorldInterface WORLD_INTERFACE = WorldInterface::sim3d; void world_interface_init() { initSimServer(); initCameras(); AR::initializeLandmarkDetection(); } bool hasNewCameraFrame(CameraID cameraID, uint32_t oldFrameNum) { // acquire shared lock std::shared_lock<std::shared_mutex> lock(cameraFrameMapMutex); auto cfEntry = cameraFrameMap.find(cameraID); if (cfEntry == cameraFrameMap.end() || !cfEntry->second.isValid()) { return false; } return cfEntry->second.getData().second != oldFrameNum; } DataPoint<CameraFrame> readCamera(CameraID cameraID) { // acquire shared lock std::shared_lock<std::shared_mutex> lock(cameraFrameMapMutex); auto cfEntry = cameraFrameMap.find(cameraID); if (cfEntry != cameraFrameMap.end()) { return cfEntry->second; } else { return {}; } } std::optional<cam::CameraParams> getCameraIntrinsicParams(CameraID cameraID) { auto entry = cameraConfigMap.find(cameraID); if (entry != cameraConfigMap.end()) { auto cfg = entry->second; if (cfg.intrinsicParams) { return cfg.intrinsicParams; } else { return {}; } } else { return {}; } } std::optional<cv::Mat> getCameraExtrinsicParams(CameraID cameraID) { auto entry = cameraConfigMap.find(cameraID); if (entry != cameraConfigMap.end()) { auto cfg = entry->second; if (cfg.extrinsicParams) { return cfg.extrinsicParams; } else { return {}; } } else { return {}; } } landmarks_t readLandmarks() { return AR::readLandmarks(); } DataPoint<points_t> readLidarScan() { std::lock_guard<std::mutex> guard(lidarMutex); return lastLidar; } DataPoint<pose_t> readVisualOdomVel() { return DataPoint<pose_t>{}; } DataPoint<double> readIMUHeading() { std::lock_guard<std::mutex> guard(headingMutex); return lastHeading; } DataPoint<pose_t> getTruePose() { std::lock_guard<std::mutex> guard(truePoseMutex); return lastTruePose; } URCLeg getLeg(int index) { return URCLeg{0, -1, {0., 0., 0.}}; } void setMotorPower(motorid_t motor, double normalizedPWM) { std::string name = motorNameMap.at(motor); json msg = {{"type", "simMotorPowerRequest"}, {"motor", name}, {"power", normalizedPWM}}; sendJSON(msg); } void setMotorPos(motorid_t motor, int32_t targetPos) { std::string name = motorNameMap.at(motor); json msg = {{"type", "simMotorPositionRequest"}, {"motor", name}, {"position", targetPos}}; sendJSON(msg); } DataPoint<int32_t> getMotorPos(motorid_t motor) { std::string motorName = motorNameMap.at(motor); std::shared_lock lock(motorPosMapMutex); auto entry = motorPosMap.find(motorName); if (entry != motorPosMap.end()) { return entry->second; } else { return {}; } } callbackid_t addLimitSwitchCallback( robot::types::motorid_t motor, const std::function<void(robot::types::motorid_t motor, robot::types::DataPoint<LimitSwitchData> limitSwitchData)>& callback) { auto func = std::bind(callback, motor, std::placeholders::_1); std::string motorName = motorNameMap.at(motor); std::lock_guard lock(limitSwitchCallbackMapMutex); limitSwitchCallbackMap.insert({motorName, {}}); callbackid_t nextID = nextCallbackID++; limitSwitchCallbackMap.at(motorName).insert({nextID, func}); lsCallbackToMotorMap.insert({nextID, motor}); return nextID; } void removeLimitSwitchCallback(callbackid_t id) { std::lock_guard lock(limitSwitchCallbackMapMutex); std::string motorName = motorNameMap.at(lsCallbackToMotorMap.at(id)); limitSwitchCallbackMap.at(motorName).erase(id); if (limitSwitchCallbackMap.at(motorName).empty()) { limitSwitchCallbackMap.erase(motorName); } } void setIndicator(indication_t signal) { if (signal == indication_t::arrivedAtDest) { log(LOG_INFO, "Robot arrived at destination!\n"); } } } // namespace robot DataPoint<gpscoords_t> gps::readGPSCoords() { std::lock_guard<std::mutex> guard(gpsMutex); return lastGPS; }
27.794271
92
0.733908
huskyroboticsteam
0ea7b29eb1781cfdd6af250e64ceda5b604f54dc
6,562
hpp
C++
ql/experimental/commodities/commodityindex.hpp
haozhangphd/QuantLib-noBoost
ddded069868161099843c04840454f00816113ad
[ "BSD-3-Clause" ]
76
2017-06-28T21:24:38.000Z
2021-12-19T18:07:37.000Z
ql/experimental/commodities/commodityindex.hpp
haozhangphd/QuantLib-noBoost
ddded069868161099843c04840454f00816113ad
[ "BSD-3-Clause" ]
2
2017-07-05T09:20:13.000Z
2019-10-31T12:06:51.000Z
ql/experimental/commodities/commodityindex.hpp
haozhangphd/QuantLib-noBoost
ddded069868161099843c04840454f00816113ad
[ "BSD-3-Clause" ]
34
2017-07-02T14:49:21.000Z
2021-11-26T15:32:04.000Z
/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* Copyright (C) 2008 J. Erik Radmall This file is part of QuantLib, a free-software/open-source library for financial quantitative analysts and developers - http://quantlib.org/ QuantLib is free software: you can redistribute it and/or modify it under the terms of the QuantLib license. You should have received a copy of the license along with this program; if not, please email <quantlib-dev@lists.sf.net>. The license is also available online at <http://quantlib.org/license.shtml>. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the license for more details. */ /*! \file commodityindex.hpp \brief Commodity index */ #ifndef quantlib_commodity_index_hpp #define quantlib_commodity_index_hpp #include <ql/experimental/commodities/commoditycurve.hpp> #include <ql/indexes/indexmanager.hpp> namespace QuantLib { class TermStructure; //! base class for commodity indexes class CommodityIndex : public Observable, public Observer { public: CommodityIndex( const std::string& name, const CommodityType& commodityType, const Currency& currency, const UnitOfMeasure& unitOfMeasure, const Calendar& calendar, Real lotQuantity, const std::shared_ptr<CommodityCurve>& forwardCurve, const std::shared_ptr<ExchangeContracts>& exchangeContracts, int nearbyOffset); //! \name Index interface //@{ std::string name() const; //@} //! \name Observer interface //@{ void update(); //@} //! \name Inspectors //@{ const CommodityType& commodityType() const; const Currency& currency() const; const UnitOfMeasure& unitOfMeasure() const; const Calendar& calendar() const; const std::shared_ptr<CommodityCurve>& forwardCurve() const; Real lotQuantity() const; Real price(const Date& date); Real forwardPrice(const Date& date) const; Date lastQuoteDate() const; //@} void addQuote(const Date& quoteDate, Real quote); void addQuotes(const std::map<Date, Real>& quotes) { std::string tag = name(); quotes_ = IndexManager::instance().getHistory(tag); for (std::map<Date, Real>::const_iterator ii = quotes.begin(); ii != quotes.end (); ++ii) { quotes_[ii->first] = ii->second; } IndexManager::instance().setHistory(tag, quotes_); } void clearQuotes(); //! returns TRUE if the quote date is valid bool isValidQuoteDate(const Date& quoteDate) const; bool empty() const; bool forwardCurveEmpty() const; const TimeSeries<Real>& quotes() const; friend std::ostream& operator<<(std::ostream&, const CommodityIndex&); protected: std::string name_; CommodityType commodityType_; UnitOfMeasure unitOfMeasure_; Currency currency_; Calendar calendar_; Real lotQuantity_; TimeSeries<Real> quotes_; std::shared_ptr<CommodityCurve> forwardCurve_; Real forwardCurveUomConversionFactor_; std::shared_ptr<ExchangeContracts> exchangeContracts_; Integer nearbyOffset_; }; // inline definitions inline bool operator==(const CommodityIndex& i1, const CommodityIndex& i2) { return i1.name() == i2.name(); } inline void CommodityIndex::update() { notifyObservers(); } inline std::string CommodityIndex::name() const { return name_; } inline const CommodityType& CommodityIndex::commodityType() const { return commodityType_; } inline const UnitOfMeasure& CommodityIndex::unitOfMeasure() const { return unitOfMeasure_; } inline const Currency& CommodityIndex::currency() const { return currency_; } inline const Calendar& CommodityIndex::calendar() const { return calendar_; } inline Real CommodityIndex::lotQuantity() const { return lotQuantity_; } inline const std::shared_ptr<CommodityCurve>& CommodityIndex::forwardCurve() const { return forwardCurve_; } inline const TimeSeries<Real>& CommodityIndex::quotes() const { return quotes_; } inline Real CommodityIndex::price(const Date& date) { std::map<Date, Real>::const_iterator hq = quotes_.find(date); if (hq->second == Null<Real>()) { ++hq; if (hq == quotes_.end()) //if (hq->second == Null<Real>()) return Null<Real>(); } return hq->second; } inline Real CommodityIndex::forwardPrice(const Date& date) const { try { Real forwardPrice = forwardCurve_->price(date, exchangeContracts_, nearbyOffset_); return forwardPrice * forwardCurveUomConversionFactor_; } catch (const std::exception& e) { QL_FAIL("error fetching forward price for index " << name_ << ": " << e.what()); } } inline Date CommodityIndex::lastQuoteDate() const { if (quotes_.empty()) return Date::minDate(); return quotes_.lastDate(); } inline bool CommodityIndex::empty() const { return quotes_.empty(); } inline bool CommodityIndex::forwardCurveEmpty() const { if (forwardCurve_ != 0) return forwardCurve_->empty(); return false; } inline void CommodityIndex::addQuote(const Date& quoteDate, Real quote) { //QL_REQUIRE(isValidQuoteDate(quoteDate), // "Quote date " << quoteDate.weekday() << ", " << // quoteDate << " is not valid"); std::string tag = name(); quotes_ = IndexManager::instance().getHistory(tag); quotes_[quoteDate] = quote; IndexManager::instance().setHistory(tag, quotes_); } inline void CommodityIndex::clearQuotes() { IndexManager::instance().clearHistory(name()); } inline bool CommodityIndex::isValidQuoteDate(const Date& quoteDate) const { return calendar().isBusinessDay(quoteDate); } } #endif
31.854369
80
0.615666
haozhangphd
0ea829a616240ef4014e96462dd5fb036c3e06c9
981
cpp
C++
leetcode/problemset-algorithms/two-sum-iv-input-is-a-bst.cpp
riteshkumar99/coding-for-placement
b45f90f662808bf4bf038ff98a016d49b9d71f71
[ "MIT" ]
null
null
null
leetcode/problemset-algorithms/two-sum-iv-input-is-a-bst.cpp
riteshkumar99/coding-for-placement
b45f90f662808bf4bf038ff98a016d49b9d71f71
[ "MIT" ]
null
null
null
leetcode/problemset-algorithms/two-sum-iv-input-is-a-bst.cpp
riteshkumar99/coding-for-placement
b45f90f662808bf4bf038ff98a016d49b9d71f71
[ "MIT" ]
null
null
null
/** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode() : val(0), left(nullptr), right(nullptr) {} * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {} * TreeNode(int x, TreeNode *left, TreeNode *right) : val(x), left(left), right(right) {} * }; */ class Solution { void inorder(TreeNode *node, vector<int> &arr) { if(node == nullptr) { return; } inorder(node->left, arr); arr.push_back(node->val); inorder(node->right, arr); } public: bool findTarget(TreeNode* root, int k) { vector<int> arr; inorder(root, arr); int l = 0, r = arr.size() - 1; while(l < r) { int sum = arr[l] + arr[r]; if(sum == k) return true; if(sum < k) l++; else r--; } return false; } };
25.815789
93
0.474006
riteshkumar99
0ea90a6de5944af6d2a9c1010401ee43e522f1f0
32,135
hpp
C++
example/GHAME6/class_hierarchy.hpp
SwaggyTyrion/CADAC
f5405b82fedfbc9fc9bdacfb0dfd83eb0a46fa41
[ "MIT" ]
5
2020-04-12T10:00:49.000Z
2022-01-25T05:29:24.000Z
example/GHAME6/class_hierarchy.hpp
SwaggyTyrion/CADAC
f5405b82fedfbc9fc9bdacfb0dfd83eb0a46fa41
[ "MIT" ]
null
null
null
example/GHAME6/class_hierarchy.hpp
SwaggyTyrion/CADAC
f5405b82fedfbc9fc9bdacfb0dfd83eb0a46fa41
[ "MIT" ]
2
2022-01-13T19:56:19.000Z
2022-02-07T20:13:05.000Z
/////////////////////////////////////////////////////////////////////////////// //FILE: class_hierarchy.hpp // //Contains the classes of the hierarchy of base class 'Cadac' // //011128 Created by Peter H Zipfel //030415 Adapted to HYPER simulation, PZi /////////////////////////////////////////////////////////////////////////////// #define _CRT_SECURE_NO_DEPRECATE #ifndef cadac_class_hierarchy__HPP #define cadac_class_hierarchy__HPP #include "global_header.hpp" using namespace std; /////////////////////////////////////////////////////////////////////////////// //Abstract base class: Cadac // //011128 Created by Peter H Zipfel //030415 Adapted to HYPER simulation, PZi /////////////////////////////////////////////////////////////////////////////// class Cadac { private: //vehicle object name char name[CHARN]; protected: //module-variable array of class 'Round6' //first 10 locations reserved for time and 'com' variables Variable *round6; //module-variable array of class 'Round3' //first 10 locations reserved for time and 'com' variables Variable *round3; //module-variable array of class 'Ground0' //first 10 locations reserved for time and 'com' variables Variable *ground0; //Array of module-variables as defined in class 'Hyper' //first ten locations are reserved for 'com' variables Variable *hyper; //Array of module-variables as defined in class 'Satellite' //first ten locations are reserved for 'com' variables Variable *satellite; //Array of module-variables as defined in class 'Radar' //first ten locations are reserved for 'com' variables Variable *radar; public: //flag indicating an 'event' has occured bool event_epoch; //time elapsed in event double event_time; //event_time virtual~Cadac(){}; /////////////////////////////////////////////////////////////////////////// //Constructor of class 'Cadac' // //010703 Created by Peter H Zipfel /////////////////////////////////////////////////////////////////////////// Cadac(){} /////////////////////////////////////////////////////////////////////////// //Setting vehicle object name // //010703 Created by Peter H Zipfel /////////////////////////////////////////////////////////////////////////// void set_name(char *vehicle_name) {strcpy(name,vehicle_name);} /////////////////////////////////////////////////////////////////////////// //Getting vehicle object name // //010703 Created by Peter H Zipfel /////////////////////////////////////////////////////////////////////////// char *get_vname() {return name;} //////////////////////////executive functions ///////////////////////////// virtual void sizing_arrays()=0; virtual void vehicle_array()=0; virtual void scrn_array()=0; virtual void plot_array()=0; virtual void scrn_banner()=0; virtual void tabout_banner(ofstream &ftabout,char *title,int &nmonte,int &nmc)=0; virtual void tabout_data(ofstream &ftabout)=0; virtual void vehicle_data(fstream &input,int nmonte)=0; virtual void read_tables(char *file_name,Datadeck &datatable)=0; virtual void scrn_index_arrays()=0; virtual void scrn_data()=0; virtual void plot_banner(ofstream &fplot,char *title)=0; virtual void plot_index_arrays()=0; virtual void plot_data(ofstream &fplot,bool merge)=0; virtual void stat_data(ofstream &fstat,int nmc,int vehicle_slot)=0; virtual void event(char *options)=0; virtual void document(ostream &fdoc,char *title,Document *doc_vehicle)=0; virtual void com_index_arrays()=0; virtual Packet loading_packet_init(int num_hyper,int num_satellite,int num_radar)=0; virtual Packet loading_packet(int num_hyper,int num_satellite,int num_radar)=0; virtual void markov_noise(double sim_time,double int_step,int nmonte)=0; //module functions -MOD virtual void def_newton()=0; virtual void init_newton()=0; virtual void newton(double int_step)=0; virtual void def_kinematics()=0; virtual void init_kinematics(double sim_time,double event_time)=0; virtual void kinematics(double sim_time,double event_time,double &int_step,double &out_fact)=0; virtual void init_euler()=0; virtual void def_euler()=0; virtual void euler(double int_step)=0; virtual void def_environment()=0; virtual void init_environment()=0; virtual void environment(double int_step)=0; virtual void def_aerodynamics()=0; virtual void init_aerodynamics()=0; virtual void aerodynamics()=0; virtual void def_forces()=0; virtual void forces()=0; virtual void def_propulsion()=0; virtual void init_propulsion()=0; virtual void propulsion(double int_step)=0; virtual void def_actuator()=0; virtual void actuator(double int_step)=0; virtual void def_control()=0; virtual void control(double int_step)=0; virtual void def_ins()=0; virtual void init_ins()=0; virtual void ins(double int_step)=0; virtual void def_guidance()=0; virtual void guidance(double int_step)=0; virtual void def_gps()=0; virtual void gps(double int_step)=0; virtual void def_startrack()=0; virtual void startrack()=0; virtual void def_rcs()=0; virtual void rcs()=0; virtual void def_intercept()=0; virtual void intercept(Packet *combus,int vehicle_slot,double int_step,char *title)=0; virtual void def_seeker()=0; virtual void seeker(Packet *combus,int num_vehicles,double sim_time,double int_step)=0; virtual void def_datalink()=0; virtual void datalink(Packet *combus,int num_vehicles)=0; }; /////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////// //Derived class: Round6 // //First derived class in the 'Cadac' hierarchy //Models atmosphere, gravitaional acceleration and equations of motions //Contains modules: 'environment', 'kinematics', 'newton', 'euler' // //011128 Created by Peter H Zipfel //030415 Adapted to HYPER simulation, PZi /////////////////////////////////////////////////////////////////////////////// class Round6:public Cadac { protected: //Indicator array pointing to the module-variable which are to //be written to the screen int *round6_scrn_ind; int round6_scrn_count; //Indicator-array pointing to the module-variable which are to //be written to the 'ploti.asc' files int *round6_plot_ind; int round6_plot_count; //Indicator-array pointing to the module-variable which are to //be written to 'combus' 'packets' int *round6_com_ind; int round6_com_count; public: Round6(); virtual~Round6(){}; //executive functions virtual void sizing_arrays()=0; virtual void vehicle_array()=0; virtual void scrn_array()=0; virtual void plot_array()=0; virtual void scrn_banner()=0; virtual void tabout_banner(ofstream &ftabout,char *title,int &nmonte,int &nmc)=0; virtual void tabout_data(ofstream &ftabout)=0; virtual void vehicle_data(fstream &input,int nmonte)=0; virtual void read_tables(char *file_name,Datadeck &datatable)=0; virtual void scrn_index_arrays()=0; virtual void scrn_data()=0; virtual void plot_banner(ofstream &fplot,char *title)=0; virtual void plot_index_arrays()=0; virtual void plot_data(ofstream &fplot,bool merge)=0; virtual void stat_data(ofstream &fstat,int nmc,int vehicle_slot)=0; virtual void event(char *options)=0; virtual void document(ostream &fdoc,char *title,Document *doc_vehicle)=0; virtual void com_index_arrays()=0; virtual Packet loading_packet_init(int num_hyper,int num_satellite,int num_radar)=0; virtual Packet loading_packet(int num_hyper,int num_satellite,int num_radar)=0; virtual void markov_noise(double sim_time,double int_step,int nmonte)=0; //module functions -MOD virtual void def_aerodynamics()=0; virtual void init_aerodynamics()=0; virtual void aerodynamics()=0; virtual void def_forces()=0; virtual void forces()=0; virtual void def_propulsion()=0; virtual void init_propulsion()=0; virtual void propulsion(double int_step)=0; virtual void def_actuator()=0; virtual void actuator(double int_step)=0; virtual void def_control()=0; virtual void control(double int_step)=0; virtual void def_ins()=0; virtual void init_ins()=0; virtual void ins(double int_step)=0; virtual void def_guidance()=0; virtual void guidance(double int_step)=0; virtual void def_intercept()=0; virtual void intercept(Packet *combus,int vehicle_slot,double int_step,char *title)=0; virtual void def_gps()=0; virtual void gps(double int_step)=0; virtual void def_startrack()=0; virtual void startrack()=0; virtual void def_rcs()=0; virtual void rcs()=0; virtual void def_seeker()=0; virtual void seeker(Packet *combus,int num_vehicles,double sim_time,double int_step)=0; virtual void def_datalink()=0; virtual void datalink(Packet *combus,int num_vehicles)=0; //virtual functions to be declared in this class virtual void def_newton(); virtual void init_newton(); virtual void newton(double int_step); virtual void def_kinematics(); virtual void init_kinematics(double sim_time,double int_step); virtual void kinematics(double sim_time,double event_time,double &int_step,double &out_fact); virtual void def_euler(); virtual void init_euler(); virtual void euler(double int_step); virtual void def_environment(); virtual void init_environment(); virtual void environment(double int_step); //functions in respective modules Matrix environment_dryden(double dvba,double int_step); }; /////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////// //Derived class: Hyper // //Second level of derived class of the 'Cadac' hierarchy //Models aerodynamics, propulsion, guidance and control //Contains Modules: 'aerodynamics', 'forces', 'propulsion', 'actuator', 'control', // 'ins', 'guidance', 'gps', 'startrack', 'seeker', 'rcs', 'datalink' // //011128 Created by Peter H Zipfel //030415 Adapted to HYPER simulation, PZi /////////////////////////////////////////////////////////////////////////////// class Hyper:public Round6 { protected: //name of HYPER6 vehicle object char hyper6_name[CHARL]; //Event list of 'Event' object pointers and actual number of events Event *event_ptr_list[NEVENT];int nevent; //total number of envents for a vehicle object int event_total; //Compacted array of all module-variables of vehicle object 'Hyper' Variable *hyper6;int nhyper6; //Screen ouput array of module-variables of vehicle object 'Hyper' Variable *scrn_hyper6;int nscrn_hyper6; //Plot ouput array of module-variables of vehicle object 'Hyper' Variable *plot_hyper6;int nplot_hyper6; //Communications ouput array of module-variables of vehicle object 'Hyper' Variable *com_hyper6;int ncom_hyper6; //Packet of data for each hyper vehicle Packet packet; //Indicator array pointing to the module-variable which are to //be written to the screen int *hyper_scrn_ind; int hyper_scrn_count; //Indicator array pointing to the module-variable which are to //be written to the 'ploti.asc' files int *hyper_plot_ind; int hyper_plot_count; //Indicator array pointing to the module-variable which are to //be written to 'combus' 'packets' int *hyper_com_ind; int hyper_com_count; //array of ground distances of 'Hyper' object from all 'Satellite' objects double *grnd_range; //array of module-variables that carry Markov process random values Markov markov_list[NMARKOV]; int nmarkov; //declaring Table pointer as temporary storage of a single table Table *table; // declaring Datadeck 'aerotable' that stores all aero tables Datadeck aerotable; // declaring Datadeck 'proptable' that stores all aero tables Datadeck proptable; public: Hyper(){}; Hyper(Module *module_list,int num_modules,int num_satellite,int num_radar); virtual~Hyper(); //executive functions virtual void sizing_arrays(); virtual void vehicle_array(); virtual void scrn_array(); virtual void plot_array(); virtual void scrn_banner(); virtual void tabout_banner(ofstream &ftabout,char *title,int &nmonte,int &nmc); virtual void tabout_data(ofstream &ftabout); virtual void vehicle_data(fstream &input,int nmonte); virtual void read_tables(char *file_name,Datadeck &datatable); virtual void scrn_index_arrays(); virtual void scrn_data(); virtual void plot_banner(ofstream &fplot,char *title); virtual void plot_index_arrays(); virtual void plot_data(ofstream &fplot,bool merge); virtual void stat_data(ofstream &fstat,int nmc,int vehicle_slot); virtual void event(char *options); virtual void document(ostream &fdoc,char *title,Document *doc_vehicle); virtual void com_index_arrays(); virtual Packet loading_packet_init(int num_hyper,int num_satellite,int num_radar); virtual Packet loading_packet(int num_hyper,int num_satellite,int num_radar); virtual void markov_noise(double sim_time,double int_step,int nmonte); //module functions -MOD virtual void def_aerodynamics(); virtual void init_aerodynamics(); virtual void aerodynamics(); virtual void def_forces(); virtual void forces(); virtual void def_propulsion(); virtual void init_propulsion(); virtual void propulsion(double int_step); virtual void def_actuator(); virtual void actuator(double int_step); virtual void def_control(); virtual void control(double int_step); virtual void def_ins(); virtual void init_ins(); virtual void ins(double int_step); virtual void def_guidance(); virtual void guidance(double int_step); virtual void def_intercept(); virtual void intercept(Packet *combus,int vehicle_slot,double int_step,char *title); virtual void def_gps(); virtual void gps(double int_step); virtual void def_startrack(); virtual void startrack(); virtual void def_rcs(); virtual void rcs(); virtual void def_seeker(); virtual void seeker(Packet *combus,int num_vehicles,double sim_time,double int_step); virtual void def_datalink(); virtual void datalink(Packet *combus,int num_vehicles); //functions in respective modules void aerodynamics_der(); Matrix actuator_scnd(Matrix ACTCX,double int_step); double control_roll(double phicomx); double control_roll_rate(double pcomx); double control_yaw_rate(double rcomx); double control_pitch_rate(double qcomx); double control_lateral_accel(double alcomx); double control_normal_accel(double ancomx,double int_step); double control_gamma(double thtvdcomx); double control_heading(double psivdcomx); double control_altitude(double altcom); Matrix ins_gyro(Matrix &WBECB, double int_step); Matrix ins_accl(); Matrix ins_grav(Matrix ESBI,Matrix SBIIC); double guidance_arc(double wp_lonx,double wp_latx,double wp_alt); Matrix guidance_line(double wp_lonx,double wp_latx,double wp_alt,double psifdx,double thtfdx); Matrix guidance_ltg(int &mprop,double int_step,double time_ltg); void guidance_ltg_tgo(double &tgo, int &nst,int &num_stages, Matrix TAUN ,Matrix VEXN,Matrix BOTN,double delay_ignition,double vgom ,double amag1,double amin,double time_ltg); void guidance_ltg_tgo(double &tgop,Matrix &BURNTN,Matrix &L_IGRLN,Matrix &TGON,double &l_igrl,int &nstmax ,double &tgo,int &nst,Matrix &TAUN ,Matrix VEXN,Matrix BOTN,double delay_ignition,double vgom ,double amag1,double amin,double time_ltg,int num_stages); void guidance_ltg_igrl(double &s_igrl,double &j_igrl,double &q_igrl,double &h_igrl ,double &p_igrl,double &j_over_l,double &tlam,double &qprime ,int nst,int nstmax,Matrix BURNTN,Matrix L_IGRLN,Matrix TGON ,Matrix TAUN,Matrix VEXN,double l_igrl,double time_ltg); void guidance_ltg_trate(Matrix &ULAM,Matrix &LAMD,Matrix &RGO ,int &ipas2 ,Matrix VGO,double s_igrl,double q_igrl ,double j_over_l,double lamd_limit,double vgom,double time_ltg ,double tgo, double tgop,Matrix SDII,Matrix SBIIC,Matrix VBIIC,Matrix RBIAS ,Matrix UD,Matrix UY,Matrix UZ,Matrix &RGRAV); void guidance_ltg_trate_rtgo(Matrix &RGO ,Matrix &RGRAV ,double tgo, double tgop ,Matrix SDII,Matrix SBIIC,Matrix VBIIC,Matrix RBIAS ,Matrix ULAM,Matrix UD,Matrix UY,Matrix UZ,double s_igrl); void guidance_ltg_pdct(Matrix &SPII,Matrix &VPII,Matrix &RGRAV,Matrix &RBIAS ,Matrix LAMD,Matrix ULAM,double l_igrl,double s_igrl,double j_igrl ,double q_igrl,double h_igrl,double p_igrl,double j_over_l,double qprime ,Matrix SBIIC,Matrix VBIIC,Matrix RGO,double tgo); void guidance_ltg_crct(Matrix &SDII,Matrix &UD,Matrix &UY,Matrix &UZ,Matrix &VMISS ,Matrix &VGO ,double dbi_desired,double dvbi_desired,double thtvdx_desired ,Matrix SPII,Matrix VPII,Matrix SBIIC,Matrix VBIIC); Matrix guidance_glideslope(int &mprop,int &gs_flag,int mseek); Matrix guidance_pronav(Matrix &UTBBC, Matrix STBIK,Matrix VTBIK); Matrix guidance_AGL(Matrix &UTBBC, Matrix STBIK,Matrix VTBIK); void gps_sv_init(double *sv_init_data,double &rsi,double &wsi,double &incl); void gps_quadriga(double *ssii_quad,double *vsii_quad,double &gdop,int &mgps ,const double *sv_init_data,const double &rsi,const double &wsi ,const double &incl,double almanac_time,double del_rearth ,double time,Matrix SBII); void startrack_init(double *star_data,string *star_names); void star_triad(double *usii_triad,double star_volume, double *star_data,double star_el_min,Matrix SBII); double rcs_prop(double input,double limiter); int rcs_schmitt(double input_new,double input,double dead_zone,double hysteresis); void seeker_rf(double &azab,double &elab,double &dab,double &ddab,int &mseek, int &mguid, double fovlimx,Matrix SBTL,double int_step); Matrix seeker_glint(); void seeker_kin(double &azob,double &elob,double &dab,double &ddab,Matrix SBTL); void seeker_filter(Matrix &STBIK,Matrix &VTBIK ,double azab,double elabx,double dab,double ddab,int mseek,double int_step); }; /////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////// //Derived class: Round3 // //First derived class in the 'Cadac' hierarchy //Models atmosphere, gravitaional acceleration and equations of motions //Contains modules: 'environment' and 'newton' // //010116 Created by Peter H Zipfel //030415 Adapted to HYPER simulation, PZi /////////////////////////////////////////////////////////////////////////////// class Round3:public Cadac { protected: //Indicator array pointing to the module-variable which are to //be written to 'combus' 'packets' int *round3_com_ind; int round3_com_count; public: Round3(); virtual~Round3(){}; //executive functions virtual void sizing_arrays()=0; virtual void vehicle_array()=0; virtual void scrn_array()=0; virtual void plot_array()=0; virtual void scrn_banner()=0; virtual void tabout_banner(ofstream &ftabout,char *title,int &nmonte,int &nmc)=0; virtual void tabout_data(ofstream &ftabout)=0; virtual void vehicle_data(fstream &input,int nmonte)=0; virtual void read_tables(char *file_name,Datadeck &datatable)=0; virtual void scrn_index_arrays()=0; virtual void scrn_data()=0; virtual void plot_banner(ofstream &fplot,char *title)=0; virtual void plot_index_arrays()=0; virtual void plot_data(ofstream &fplot,bool merge)=0; virtual void stat_data(ofstream &fstat,int nmc,int vehicle_slot)=0; virtual void event(char *options)=0; virtual void document(ostream &fdoc,char *title,Document *doc_vehicle)=0; virtual void com_index_arrays()=0; virtual Packet loading_packet_init(int num_hyper,int num_satellite,int num_radar)=0; virtual Packet loading_packet(int num_hyper,int num_satellite,int num_radar)=0; virtual void markov_noise(double sim_time,double int_step,int nmonte)=0; //module functions -MOD virtual void def_aerodynamics()=0; virtual void init_aerodynamics()=0; virtual void aerodynamics()=0; virtual void def_forces()=0; virtual void forces()=0; virtual void def_propulsion()=0; virtual void init_propulsion()=0; virtual void propulsion(double int_step)=0; virtual void def_actuator()=0; virtual void actuator(double int_step)=0; virtual void def_control()=0; virtual void control(double int_step)=0; virtual void init_ins()=0; virtual void ins(double int_step)=0; virtual void def_intercept()=0; virtual void intercept(Packet *combus,int vehicle_slot,double int_step,char *title)=0; virtual void def_seeker()=0; virtual void seeker(Packet *combus,int num_vehicles,double sim_time,double int_step)=0; virtual void def_datalink()=0; virtual void datalink(Packet *combus,int num_vehicles)=0; //dummy returns of unused modules virtual void def_euler(){}; virtual void init_euler(){}; virtual void euler(double int_step){}; //virtual functions to be declared in this class virtual void def_kinematics(); virtual void init_kinematics(double sim_time,double int_step); virtual void kinematics(double sim_time,double event_time,double &int_step,double &out_fact); virtual void def_newton(); virtual void init_newton(); virtual void newton(double int_step); virtual void def_environment(); virtual void init_environment(){}; virtual void environment(double int_step); }; /////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////// //Derived class: Satellite // //Second level of derived class of the 'Cadac' hierarchy, branching from 'Round3' //Models satellite accelerations //Contains Module 'forces' // //010205 Created by Peter H Zipfel //030415 Adapted to HYPER simulation, PZi /////////////////////////////////////////////////////////////////////////////// class Satellite:public Round3 { protected: //name of SAT3 vehicle object char satellite3_name[CHARL]; //Communications ouput array of module-variables of vehicle object 'Satellite' Variable *com_satellite3;int ncom_satellite3; //Packet of data for each satellite vehicle Packet packet; //Indicator array pointing to the module-variable which are to //be written to 'combus' 'packets' int *satellite_com_ind; int satellite_com_count; public: Satellite(){}; Satellite(Module *module_list,int num_modules); virtual~Satellite(); //executive functions dummy returns virtual void vehicle_array(){}; virtual void scrn_array(){}; virtual void plot_array(){}; virtual void scrn_banner(){}; virtual void tabout_banner(ofstream &ftabout,char *title,int &nmonte,int &nmc){}; virtual void tabout_data(ofstream &ftabout){}; virtual void scrn_index_arrays(){}; virtual void scrn_data(){}; virtual void plot_banner(ofstream &fplot,char *title){}; virtual void plot_index_arrays(){}; virtual void plot_data(ofstream &fplot,bool merge){}; virtual void stat_data(ofstream &fstat,int nmc,int vehicle_slot){}; virtual void event(char *options){}; virtual void markov_noise(double sim_time,double int_step,int nmonte){}; //executive functions active virtual void sizing_arrays(); virtual void vehicle_data(fstream &input,int nmonte); virtual void read_tables(char *file_name,Datadeck &datatable){}; virtual void com_index_arrays(); virtual void document(ostream &fdoc,char *title,Document *doc_vehicle); virtual Packet loading_packet_init(int num_hyper,int num_satellite,int num_radar); virtual Packet loading_packet(int num_hyper,int num_satellite,int num_radar); //module function dummy returns -MOD virtual void def_aerodynamics(){}; virtual void init_aerodynamics(){}; virtual void aerodynamics(){}; virtual void def_propulsion(){}; virtual void init_propulsion(){}; virtual void propulsion(double int_step){}; virtual void def_actuator(){}; virtual void actuator(double int_step){}; virtual void def_control(){}; virtual void control(double int_step){}; virtual void def_ins(){}; virtual void init_ins(){}; virtual void ins(double int_step){}; virtual void def_guidance(){}; virtual void guidance(double int_step){}; virtual void def_gps(){}; virtual void gps(double int_step){}; virtual void def_startrack(){}; virtual void startrack(){}; virtual void def_rcs(){}; virtual void rcs(){}; virtual void def_intercept(){}; virtual void intercept(Packet *combus,int vehicle_slot,double int_step,char *title){}; virtual void def_datalink(){}; virtual void datalink(Packet *combus,int num_vehicles){}; virtual void def_seeker(){}; virtual void seeker(Packet *combus,int num_vehicles,double sim_time,double int_step){}; virtual void def_filter(){}; virtual void filter(double int_step){}; //module functions -MOD virtual void def_forces(); virtual void forces(); }; /////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////// //Derived class: Ground0 // //First derived class in the 'Cadac' hierarchy //Places Earth-fixed points //Contains only the 'kinematics' module // //040517 Created by Peter H Zipfel //030415 Adapted to HYPER simulation, PZi /////////////////////////////////////////////////////////////////////////////// class Ground0:public Cadac { protected: //Indicator array pointing to the module-variable which are to //be written to 'combus' 'packets' int *ground0_com_ind; int ground0_com_count; public: Ground0(); virtual~Ground0(){}; //executive functions virtual void sizing_arrays()=0; virtual void vehicle_array()=0; virtual void scrn_array()=0; virtual void plot_array()=0; virtual void scrn_banner()=0; virtual void tabout_banner(ofstream &ftabout,char *title,int &nmonte,int &nmc)=0; virtual void tabout_data(ofstream &ftabout)=0; virtual void vehicle_data(fstream &input,int nmonte)=0; virtual void read_tables(char *file_name,Datadeck &datatable)=0; virtual void scrn_index_arrays()=0; virtual void scrn_data()=0; virtual void plot_banner(ofstream &fplot,char *title)=0; virtual void plot_index_arrays()=0; virtual void plot_data(ofstream &fplot,bool merge)=0; virtual void stat_data(ofstream &fstat,int nmc,int vehicle_slot)=0; virtual void event(char *options)=0; virtual void document(ostream &fdoc,char *title,Document *doc_vehicle)=0; virtual void com_index_arrays()=0; virtual Packet loading_packet_init(int num_hyper,int num_satellite,int num_radar)=0; virtual Packet loading_packet(int num_hyper,int num_satellite,int num_radar)=0; virtual void markov_noise(double sim_time,double int_step,int nmonte)=0; //module functions -MOD virtual void def_aerodynamics()=0; virtual void init_aerodynamics()=0; virtual void aerodynamics()=0; virtual void def_forces()=0; virtual void forces()=0; virtual void def_propulsion()=0; virtual void init_propulsion()=0; virtual void propulsion(double int_step)=0; virtual void def_actuator()=0; virtual void actuator(double int_step)=0; virtual void def_control()=0; virtual void control(double int_step)=0; virtual void init_ins()=0; virtual void ins(double int_step)=0; virtual void def_seeker()=0; virtual void seeker(Packet *combus,int num_vehicles,double sim_time,double int_step)=0; virtual void def_intercept()=0; virtual void intercept(Packet *combus,int vehicle_slot,double int_step,char *title)=0; virtual void def_datalink()=0; virtual void datalink(Packet *combus,int num_vehicles)=0; //dummy returns of unused modules virtual void def_newton(){}; virtual void init_newton(){}; virtual void newton(double int_step){}; virtual void def_environment(){}; virtual void init_environment(){}; virtual void environment(double int_step){}; virtual void def_euler(){}; virtual void init_euler(){}; virtual void euler(double int_step){}; //virtual functions to be declared in this class virtual void def_kinematics(); virtual void init_kinematics(double sim_time,double int_step); virtual void kinematics(double sim_time,double event_time,double &int_step,double &out_fact); }; /////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////// //Derived class: Radar // //Second level of derived class of the 'Cadac' hierarchy, branching from 'Ground0' //Models radar on ground //Contains module 'seeker' // //040505 Created by Peter H Zipfel //030415 Adapted to HYPER simulation, PZi /////////////////////////////////////////////////////////////////////////////// class Radar:public Ground0 { protected: //name of RADAR3 vehicle object char radar0_name[CHARL]; //Communications ouput array of module-variables of vehicle object 'Radar' Variable *com_radar0;int ncom_radar0; //Packet of data for each radar vehicle Packet packet; //Indicator array pointing to the module-variable which are to //be written to 'combus' 'packets' int *radar_com_ind; int radar_com_count; public: Radar(){}; Radar(Module *module_list,int num_modules); virtual~Radar(); //executive functions dummy returns virtual void vehicle_array(){}; virtual void scrn_array(){}; virtual void plot_array(){}; virtual void scrn_banner(){}; virtual void tabout_banner(ofstream &ftabout,char *title,int &nmonte,int &nmc){}; virtual void tabout_data(ofstream &ftabout){}; virtual void scrn_index_arrays(){}; virtual void scrn_data(){}; virtual void plot_banner(ofstream &fplot,char *title){}; virtual void plot_index_arrays(){}; virtual void plot_data(ofstream &fplot,bool merge){}; virtual void stat_data(ofstream &fstat,int nmc,int vehicle_slot){}; virtual void event(char *options){}; virtual void markov_noise(double sim_time,double int_step,int nmonte){}; //executive functions active virtual void sizing_arrays(); virtual void vehicle_data(fstream &input,int nmonte); virtual void read_tables(char *file_name,Datadeck &datatable){}; virtual void com_index_arrays(); virtual void document(ostream &fdoc,char *title,Document *doc_vehicle); virtual Packet loading_packet_init(int num_hyper,int num_satellite,int num_radar); virtual Packet loading_packet(int num_hyper,int num_satellite,int num_radar); //module function dummy returns -MOD virtual void def_aerodynamics(){}; virtual void init_aerodynamics(){}; virtual void aerodynamics(){}; virtual void def_propulsion(){}; virtual void init_propulsion(){}; virtual void propulsion(double int_step){}; virtual void def_forces(){}; virtual void forces(){}; virtual void def_actuator(){}; virtual void actuator(double int_step){}; virtual void def_control(){}; virtual void control(double int_step){}; virtual void def_ins(){}; virtual void init_ins(){}; virtual void ins(double int_step){}; virtual void def_guidance(){}; virtual void guidance(double int_step){}; virtual void def_gps(){}; virtual void gps(double int_step){}; virtual void def_startrack(){}; virtual void startrack(){}; virtual void def_rcs(){}; virtual void rcs(){}; virtual void def_intercept(){}; virtual void intercept(Packet *combus,int vehicle_slot,double int_step,char *title){}; virtual void def_datalink(){}; virtual void datalink(Packet *combus,int num_vehicles){}; virtual void def_filter(){}; virtual void filter(double int_step){}; //module functions -MOD virtual void def_seeker(); virtual void seeker(Packet *combus,int num_vehicles,double sim_time,double int_step); }; /////////////////////////////////////////////////////////////////////////////// ////////////////////////// Global class 'Vehicle'////////////////////////////// ///////////// must be located after 'Cadac' hierarchy in this file //////////// /////////////////////////////////////////////////////////////////////////////// //Class 'Vehicle' // //Global class for typifying the array of vehicle pointers // //010629 Created by Peter Zipfel /////////////////////////////////////////////////////////////////////////////// class Vehicle { private: int capacity; //max number of vehicles permitted in vehicle list int howmany; //actual number of vehicles in vehicle list Cadac **vehicle_ptr; public: Vehicle(int number=1); //constructor, setting capacity, allocating dynamic memory virtual ~Vehicle(); //destructor, de-allocating dynamic memory void add_vehicle(Cadac &ptr); //adding vehicle to list Cadac *operator[](int position); //[] operator returns vehicle pointer int size(); //returning 'howmany' vehicles are stored in vehicle list }; #endif
38.716867
114
0.704466
SwaggyTyrion
0ea964c76e00a1d9122e688fd902adf71ab32509
716,061
cpp
C++
test/bidi_character_test_022.cpp
eightysquirrels/text
d935545648777786dc196a75346cde8906da846a
[ "BSL-1.0" ]
null
null
null
test/bidi_character_test_022.cpp
eightysquirrels/text
d935545648777786dc196a75346cde8906da846a
[ "BSL-1.0" ]
1
2021-03-05T12:56:59.000Z
2021-03-05T13:11:53.000Z
test/bidi_character_test_022.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> TEST(bidi_character, bidi_character_022_000) { { // line 15401 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0029, 0x2681, 0x05D0, 0x005B, 0x0061, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 2, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15402 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0029, 0x2681, 0x05D0, 0x005B, 0x005D, 0x0061 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 1, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15403 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0029, 0x2681, 0x05D0, 0x005B, 0x005D, 0x0061 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 1, 2 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15404 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0029, 0x2681, 0x005B, 0x05D0, 0x0061, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 1, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15405 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0029, 0x2681, 0x005B, 0x05D0, 0x0061, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 2, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15406 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0029, 0x2681, 0x005B, 0x05D0, 0x005D, 0x0061 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 1, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15407 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0029, 0x2681, 0x005B, 0x05D0, 0x005D, 0x0061 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 1, 2 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15408 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0029, 0x005B, 0x2681, 0x05D0, 0x0061, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 1, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15409 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0029, 0x005B, 0x2681, 0x05D0, 0x0061, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 2, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15410 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0029, 0x005B, 0x2681, 0x05D0, 0x005D, 0x0061 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 1, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } } TEST(bidi_character, bidi_character_022_001) { { // line 15411 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0029, 0x005B, 0x2681, 0x05D0, 0x005D, 0x0061 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 1, 2 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15412 std::vector<uint32_t> const cps = { 0x0028, 0x0029, 0x2680, 0x005B, 0x2681, 0x05D0, 0x0061, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 1, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15413 std::vector<uint32_t> const cps = { 0x0028, 0x0029, 0x2680, 0x005B, 0x2681, 0x05D0, 0x0061, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 2, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15414 std::vector<uint32_t> const cps = { 0x0028, 0x0029, 0x2680, 0x005B, 0x2681, 0x05D0, 0x005D, 0x0061 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 1, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15415 std::vector<uint32_t> const cps = { 0x0028, 0x0029, 0x2680, 0x005B, 0x2681, 0x05D0, 0x005D, 0x0061 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 1, 2 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15418 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x2681, 0x05D0, 0x0029, 0x05D1, 0x005B, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 1, 0, 1, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15419 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x2681, 0x05D0, 0x0029, 0x05D1, 0x005B, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15420 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x2681, 0x05D0, 0x0029, 0x005B, 0x05D1, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 1, 0, 0, 1, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15421 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x2681, 0x05D0, 0x0029, 0x005B, 0x05D1, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15422 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x2681, 0x05D0, 0x0029, 0x005B, 0x005D, 0x05D1 }; std::vector<int> const expected_levels = { 0, 0, 0, 1, 0, 0, 0, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } } TEST(bidi_character, bidi_character_022_002) { { // line 15423 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x2681, 0x05D0, 0x0029, 0x005B, 0x005D, 0x05D1 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15424 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x2681, 0x0029, 0x05D0, 0x005B, 0x05D1, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 7, 6, 5, 4 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15425 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x2681, 0x0029, 0x05D0, 0x005B, 0x05D1, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15426 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x2681, 0x0029, 0x05D0, 0x005B, 0x005D, 0x05D1 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 7, 6, 5, 4 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15427 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x2681, 0x0029, 0x05D0, 0x005B, 0x005D, 0x05D1 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15428 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x2681, 0x0029, 0x005B, 0x05D0, 0x005D, 0x05D1 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 1, 0, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15429 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x2681, 0x0029, 0x005B, 0x05D0, 0x005D, 0x05D1 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15430 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0029, 0x2681, 0x05D0, 0x005B, 0x05D1, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 7, 6, 5, 4 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15431 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0029, 0x2681, 0x05D0, 0x005B, 0x05D1, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15432 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0029, 0x2681, 0x05D0, 0x005B, 0x005D, 0x05D1 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 7, 6, 5, 4 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } } TEST(bidi_character, bidi_character_022_003) { { // line 15433 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0029, 0x2681, 0x05D0, 0x005B, 0x005D, 0x05D1 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15434 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0029, 0x2681, 0x005B, 0x05D0, 0x005D, 0x05D1 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 1, 0, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15435 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0029, 0x2681, 0x005B, 0x05D0, 0x005D, 0x05D1 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15436 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0029, 0x005B, 0x2681, 0x05D0, 0x005D, 0x05D1 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 1, 0, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15437 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0029, 0x005B, 0x2681, 0x05D0, 0x005D, 0x05D1 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15438 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0029, 0x2681, 0x05D0, 0x005B, 0x05D1, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 7, 6, 5, 4 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15439 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0029, 0x2681, 0x05D0, 0x005B, 0x05D1, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15440 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0029, 0x2681, 0x05D0, 0x005B, 0x005D, 0x05D1 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 7, 6, 5, 4 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15441 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0029, 0x2681, 0x05D0, 0x005B, 0x005D, 0x05D1 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15442 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0029, 0x2681, 0x005B, 0x05D0, 0x005D, 0x05D1 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 1, 0, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } } TEST(bidi_character, bidi_character_022_004) { { // line 15443 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0029, 0x2681, 0x005B, 0x05D0, 0x005D, 0x05D1 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15444 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0029, 0x005B, 0x2681, 0x05D0, 0x005D, 0x05D1 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 1, 0, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15445 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0029, 0x005B, 0x2681, 0x05D0, 0x005D, 0x05D1 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15446 std::vector<uint32_t> const cps = { 0x0028, 0x0029, 0x2680, 0x005B, 0x2681, 0x05D0, 0x005D, 0x05D1 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 1, 0, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15447 std::vector<uint32_t> const cps = { 0x0028, 0x0029, 0x2680, 0x005B, 0x2681, 0x05D0, 0x005D, 0x05D1 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15450 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0061, 0x2681, 0x0029, 0x2682, 0x005B, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15451 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0061, 0x2681, 0x0029, 0x2682, 0x005B, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 2, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15452 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0061, 0x2681, 0x0029, 0x005B, 0x2682, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15453 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0061, 0x2681, 0x0029, 0x005B, 0x2682, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 2, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15454 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0061, 0x2681, 0x0029, 0x005B, 0x005D, 0x2682 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } } TEST(bidi_character, bidi_character_022_005) { { // line 15455 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0061, 0x2681, 0x0029, 0x005B, 0x005D, 0x2682 }; std::vector<int> const expected_levels = { 1, 1, 2, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15456 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0061, 0x0029, 0x2681, 0x005B, 0x2682, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15457 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0061, 0x0029, 0x2681, 0x005B, 0x2682, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 2, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15458 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0061, 0x0029, 0x2681, 0x005B, 0x005D, 0x2682 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15459 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0061, 0x0029, 0x2681, 0x005B, 0x005D, 0x2682 }; std::vector<int> const expected_levels = { 1, 1, 2, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15460 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0061, 0x0029, 0x005B, 0x2681, 0x005D, 0x2682 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15461 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0061, 0x0029, 0x005B, 0x2681, 0x005D, 0x2682 }; std::vector<int> const expected_levels = { 1, 1, 2, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15462 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0029, 0x0061, 0x2681, 0x005B, 0x2682, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15463 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0029, 0x0061, 0x2681, 0x005B, 0x2682, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 2, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15464 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0029, 0x0061, 0x2681, 0x005B, 0x005D, 0x2682 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } } TEST(bidi_character, bidi_character_022_006) { { // line 15465 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0029, 0x0061, 0x2681, 0x005B, 0x005D, 0x2682 }; std::vector<int> const expected_levels = { 1, 1, 1, 2, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15466 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0029, 0x0061, 0x005B, 0x2681, 0x005D, 0x2682 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15467 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0029, 0x0061, 0x005B, 0x2681, 0x005D, 0x2682 }; std::vector<int> const expected_levels = { 1, 1, 1, 2, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15468 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0029, 0x005B, 0x0061, 0x2681, 0x005D, 0x2682 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15469 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0029, 0x005B, 0x0061, 0x2681, 0x005D, 0x2682 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 2, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15470 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0061, 0x2681, 0x0029, 0x2682, 0x005B, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15471 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0061, 0x2681, 0x0029, 0x2682, 0x005B, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 2, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15472 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0061, 0x2681, 0x0029, 0x005B, 0x2682, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15473 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0061, 0x2681, 0x0029, 0x005B, 0x2682, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 2, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15474 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0061, 0x2681, 0x0029, 0x005B, 0x005D, 0x2682 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } } TEST(bidi_character, bidi_character_022_007) { { // line 15475 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0061, 0x2681, 0x0029, 0x005B, 0x005D, 0x2682 }; std::vector<int> const expected_levels = { 1, 1, 2, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15476 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0061, 0x0029, 0x2681, 0x005B, 0x2682, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15477 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0061, 0x0029, 0x2681, 0x005B, 0x2682, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 2, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15478 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0061, 0x0029, 0x2681, 0x005B, 0x005D, 0x2682 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15479 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0061, 0x0029, 0x2681, 0x005B, 0x005D, 0x2682 }; std::vector<int> const expected_levels = { 1, 1, 2, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15480 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0061, 0x0029, 0x005B, 0x2681, 0x005D, 0x2682 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15481 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0061, 0x0029, 0x005B, 0x2681, 0x005D, 0x2682 }; std::vector<int> const expected_levels = { 1, 1, 2, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15482 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0029, 0x0061, 0x2681, 0x005B, 0x2682, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15483 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0029, 0x0061, 0x2681, 0x005B, 0x2682, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 2, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15484 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0029, 0x0061, 0x2681, 0x005B, 0x005D, 0x2682 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } } TEST(bidi_character, bidi_character_022_008) { { // line 15485 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0029, 0x0061, 0x2681, 0x005B, 0x005D, 0x2682 }; std::vector<int> const expected_levels = { 1, 1, 1, 2, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15486 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0029, 0x0061, 0x005B, 0x2681, 0x005D, 0x2682 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15487 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0029, 0x0061, 0x005B, 0x2681, 0x005D, 0x2682 }; std::vector<int> const expected_levels = { 1, 1, 1, 2, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15488 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0029, 0x005B, 0x0061, 0x2681, 0x005D, 0x2682 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15489 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0029, 0x005B, 0x0061, 0x2681, 0x005D, 0x2682 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 2, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15490 std::vector<uint32_t> const cps = { 0x0028, 0x0029, 0x2680, 0x0061, 0x2681, 0x005B, 0x2682, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15491 std::vector<uint32_t> const cps = { 0x0028, 0x0029, 0x2680, 0x0061, 0x2681, 0x005B, 0x2682, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 2, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15492 std::vector<uint32_t> const cps = { 0x0028, 0x0029, 0x2680, 0x0061, 0x2681, 0x005B, 0x005D, 0x2682 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15493 std::vector<uint32_t> const cps = { 0x0028, 0x0029, 0x2680, 0x0061, 0x2681, 0x005B, 0x005D, 0x2682 }; std::vector<int> const expected_levels = { 1, 1, 1, 2, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15494 std::vector<uint32_t> const cps = { 0x0028, 0x0029, 0x2680, 0x0061, 0x005B, 0x2681, 0x005D, 0x2682 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } } TEST(bidi_character, bidi_character_022_009) { { // line 15495 std::vector<uint32_t> const cps = { 0x0028, 0x0029, 0x2680, 0x0061, 0x005B, 0x2681, 0x005D, 0x2682 }; std::vector<int> const expected_levels = { 1, 1, 1, 2, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15496 std::vector<uint32_t> const cps = { 0x0028, 0x0029, 0x2680, 0x005B, 0x0061, 0x2681, 0x005D, 0x2682 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15497 std::vector<uint32_t> const cps = { 0x0028, 0x0029, 0x2680, 0x005B, 0x0061, 0x2681, 0x005D, 0x2682 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 2, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15498 std::vector<uint32_t> const cps = { 0x0028, 0x0029, 0x005B, 0x2680, 0x0061, 0x2681, 0x005D, 0x2682 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15499 std::vector<uint32_t> const cps = { 0x0028, 0x0029, 0x005B, 0x2680, 0x0061, 0x2681, 0x005D, 0x2682 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 2, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15502 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0061, 0x2681, 0x0062, 0x0029, 0x005B, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15503 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0061, 0x2681, 0x0062, 0x0029, 0x005B, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 2, 2, 2, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 2, 3, 4, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15504 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0061, 0x2681, 0x0029, 0x0062, 0x005B, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15505 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0061, 0x2681, 0x0029, 0x0062, 0x005B, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 2, 1, 1, 2, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15506 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0061, 0x2681, 0x0029, 0x005B, 0x0062, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } } TEST(bidi_character, bidi_character_022_010) { { // line 15507 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0061, 0x2681, 0x0029, 0x005B, 0x0062, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 2, 1, 1, 1, 2, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15508 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0061, 0x2681, 0x0029, 0x005B, 0x005D, 0x0062 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15509 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0061, 0x2681, 0x0029, 0x005B, 0x005D, 0x0062 }; std::vector<int> const expected_levels = { 1, 1, 2, 1, 1, 1, 1, 2 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15510 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0061, 0x0029, 0x2681, 0x0062, 0x005B, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15511 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0061, 0x0029, 0x2681, 0x0062, 0x005B, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 2, 1, 1, 2, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15512 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0061, 0x0029, 0x2681, 0x005B, 0x0062, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15513 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0061, 0x0029, 0x2681, 0x005B, 0x0062, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 2, 1, 1, 1, 2, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15514 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0061, 0x0029, 0x2681, 0x005B, 0x005D, 0x0062 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15515 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0061, 0x0029, 0x2681, 0x005B, 0x005D, 0x0062 }; std::vector<int> const expected_levels = { 1, 1, 2, 1, 1, 1, 1, 2 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15516 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0061, 0x0029, 0x005B, 0x2681, 0x0062, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } } TEST(bidi_character, bidi_character_022_011) { { // line 15517 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0061, 0x0029, 0x005B, 0x2681, 0x0062, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 2, 1, 1, 1, 2, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15518 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0061, 0x0029, 0x005B, 0x2681, 0x005D, 0x0062 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15519 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0061, 0x0029, 0x005B, 0x2681, 0x005D, 0x0062 }; std::vector<int> const expected_levels = { 1, 1, 2, 1, 1, 1, 1, 2 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15520 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0061, 0x0029, 0x005B, 0x005D, 0x2681, 0x0062 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15521 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0061, 0x0029, 0x005B, 0x005D, 0x2681, 0x0062 }; std::vector<int> const expected_levels = { 1, 1, 2, 1, 1, 1, 1, 2 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15522 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0029, 0x0061, 0x2681, 0x0062, 0x005B, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15523 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0029, 0x0061, 0x2681, 0x0062, 0x005B, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 2, 2, 2, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 3, 4, 5, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15524 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0029, 0x0061, 0x2681, 0x005B, 0x0062, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15525 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0029, 0x0061, 0x2681, 0x005B, 0x0062, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 2, 2, 2, 2, 2 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 3, 4, 5, 6, 7, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15526 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0029, 0x0061, 0x2681, 0x005B, 0x005D, 0x0062 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } } TEST(bidi_character, bidi_character_022_012) { { // line 15527 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0029, 0x0061, 0x2681, 0x005B, 0x005D, 0x0062 }; std::vector<int> const expected_levels = { 1, 1, 1, 2, 2, 2, 2, 2 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 3, 4, 5, 6, 7, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15528 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0029, 0x0061, 0x005B, 0x2681, 0x0062, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15529 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0029, 0x0061, 0x005B, 0x2681, 0x0062, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 2, 2, 2, 2, 2 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 3, 4, 5, 6, 7, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15530 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0029, 0x0061, 0x005B, 0x2681, 0x005D, 0x0062 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15531 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0029, 0x0061, 0x005B, 0x2681, 0x005D, 0x0062 }; std::vector<int> const expected_levels = { 1, 1, 1, 2, 2, 2, 2, 2 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 3, 4, 5, 6, 7, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15532 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0029, 0x0061, 0x005B, 0x005D, 0x2681, 0x0062 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15533 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0029, 0x0061, 0x005B, 0x005D, 0x2681, 0x0062 }; std::vector<int> const expected_levels = { 1, 1, 1, 2, 2, 2, 2, 2 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 3, 4, 5, 6, 7, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15534 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0029, 0x005B, 0x0061, 0x2681, 0x0062, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15535 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0029, 0x005B, 0x0061, 0x2681, 0x0062, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 2, 2, 2, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 4, 5, 6, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15536 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0029, 0x005B, 0x0061, 0x2681, 0x005D, 0x0062 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } } TEST(bidi_character, bidi_character_022_013) { { // line 15537 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0029, 0x005B, 0x0061, 0x2681, 0x005D, 0x0062 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 2, 1, 1, 2 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15538 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0029, 0x005B, 0x0061, 0x005D, 0x2681, 0x0062 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15539 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0029, 0x005B, 0x0061, 0x005D, 0x2681, 0x0062 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 2, 1, 1, 2 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15540 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0061, 0x2681, 0x0062, 0x0029, 0x005B, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15541 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0061, 0x2681, 0x0062, 0x0029, 0x005B, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 2, 2, 2, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 2, 3, 4, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15542 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0061, 0x2681, 0x0029, 0x0062, 0x005B, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15543 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0061, 0x2681, 0x0029, 0x0062, 0x005B, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 2, 1, 1, 2, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15544 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0061, 0x2681, 0x0029, 0x005B, 0x0062, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15545 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0061, 0x2681, 0x0029, 0x005B, 0x0062, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 2, 1, 1, 1, 2, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15546 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0061, 0x2681, 0x0029, 0x005B, 0x005D, 0x0062 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } } TEST(bidi_character, bidi_character_022_014) { { // line 15547 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0061, 0x2681, 0x0029, 0x005B, 0x005D, 0x0062 }; std::vector<int> const expected_levels = { 1, 1, 2, 1, 1, 1, 1, 2 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15548 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0061, 0x0029, 0x2681, 0x0062, 0x005B, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15549 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0061, 0x0029, 0x2681, 0x0062, 0x005B, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 2, 1, 1, 2, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15550 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0061, 0x0029, 0x2681, 0x005B, 0x0062, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15551 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0061, 0x0029, 0x2681, 0x005B, 0x0062, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 2, 1, 1, 1, 2, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15552 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0061, 0x0029, 0x2681, 0x005B, 0x005D, 0x0062 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15553 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0061, 0x0029, 0x2681, 0x005B, 0x005D, 0x0062 }; std::vector<int> const expected_levels = { 1, 1, 2, 1, 1, 1, 1, 2 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15554 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0061, 0x0029, 0x005B, 0x2681, 0x0062, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15555 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0061, 0x0029, 0x005B, 0x2681, 0x0062, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 2, 1, 1, 1, 2, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15556 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0061, 0x0029, 0x005B, 0x2681, 0x005D, 0x0062 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } } TEST(bidi_character, bidi_character_022_015) { { // line 15557 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0061, 0x0029, 0x005B, 0x2681, 0x005D, 0x0062 }; std::vector<int> const expected_levels = { 1, 1, 2, 1, 1, 1, 1, 2 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15558 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0061, 0x0029, 0x005B, 0x005D, 0x2681, 0x0062 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15559 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0061, 0x0029, 0x005B, 0x005D, 0x2681, 0x0062 }; std::vector<int> const expected_levels = { 1, 1, 2, 1, 1, 1, 1, 2 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15560 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0029, 0x0061, 0x2681, 0x0062, 0x005B, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15561 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0029, 0x0061, 0x2681, 0x0062, 0x005B, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 2, 2, 2, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 3, 4, 5, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15562 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0029, 0x0061, 0x2681, 0x005B, 0x0062, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15563 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0029, 0x0061, 0x2681, 0x005B, 0x0062, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 2, 2, 2, 2, 2 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 3, 4, 5, 6, 7, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15564 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0029, 0x0061, 0x2681, 0x005B, 0x005D, 0x0062 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15565 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0029, 0x0061, 0x2681, 0x005B, 0x005D, 0x0062 }; std::vector<int> const expected_levels = { 1, 1, 1, 2, 2, 2, 2, 2 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 3, 4, 5, 6, 7, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15566 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0029, 0x0061, 0x005B, 0x2681, 0x0062, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } } TEST(bidi_character, bidi_character_022_016) { { // line 15567 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0029, 0x0061, 0x005B, 0x2681, 0x0062, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 2, 2, 2, 2, 2 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 3, 4, 5, 6, 7, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15568 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0029, 0x0061, 0x005B, 0x2681, 0x005D, 0x0062 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15569 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0029, 0x0061, 0x005B, 0x2681, 0x005D, 0x0062 }; std::vector<int> const expected_levels = { 1, 1, 1, 2, 2, 2, 2, 2 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 3, 4, 5, 6, 7, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15570 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0029, 0x0061, 0x005B, 0x005D, 0x2681, 0x0062 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15571 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0029, 0x0061, 0x005B, 0x005D, 0x2681, 0x0062 }; std::vector<int> const expected_levels = { 1, 1, 1, 2, 2, 2, 2, 2 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 3, 4, 5, 6, 7, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15572 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0029, 0x005B, 0x0061, 0x2681, 0x0062, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15573 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0029, 0x005B, 0x0061, 0x2681, 0x0062, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 2, 2, 2, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 4, 5, 6, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15574 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0029, 0x005B, 0x0061, 0x2681, 0x005D, 0x0062 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15575 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0029, 0x005B, 0x0061, 0x2681, 0x005D, 0x0062 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 2, 1, 1, 2 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15576 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0029, 0x005B, 0x0061, 0x005D, 0x2681, 0x0062 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } } TEST(bidi_character, bidi_character_022_017) { { // line 15577 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0029, 0x005B, 0x0061, 0x005D, 0x2681, 0x0062 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 2, 1, 1, 2 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15578 std::vector<uint32_t> const cps = { 0x0028, 0x0029, 0x2680, 0x0061, 0x2681, 0x0062, 0x005B, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15579 std::vector<uint32_t> const cps = { 0x0028, 0x0029, 0x2680, 0x0061, 0x2681, 0x0062, 0x005B, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 2, 2, 2, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 3, 4, 5, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15580 std::vector<uint32_t> const cps = { 0x0028, 0x0029, 0x2680, 0x0061, 0x2681, 0x005B, 0x0062, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15581 std::vector<uint32_t> const cps = { 0x0028, 0x0029, 0x2680, 0x0061, 0x2681, 0x005B, 0x0062, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 2, 2, 2, 2, 2 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 3, 4, 5, 6, 7, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15582 std::vector<uint32_t> const cps = { 0x0028, 0x0029, 0x2680, 0x0061, 0x2681, 0x005B, 0x005D, 0x0062 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15583 std::vector<uint32_t> const cps = { 0x0028, 0x0029, 0x2680, 0x0061, 0x2681, 0x005B, 0x005D, 0x0062 }; std::vector<int> const expected_levels = { 1, 1, 1, 2, 2, 2, 2, 2 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 3, 4, 5, 6, 7, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15584 std::vector<uint32_t> const cps = { 0x0028, 0x0029, 0x2680, 0x0061, 0x005B, 0x2681, 0x0062, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15585 std::vector<uint32_t> const cps = { 0x0028, 0x0029, 0x2680, 0x0061, 0x005B, 0x2681, 0x0062, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 2, 2, 2, 2, 2 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 3, 4, 5, 6, 7, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15586 std::vector<uint32_t> const cps = { 0x0028, 0x0029, 0x2680, 0x0061, 0x005B, 0x2681, 0x005D, 0x0062 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } } TEST(bidi_character, bidi_character_022_018) { { // line 15587 std::vector<uint32_t> const cps = { 0x0028, 0x0029, 0x2680, 0x0061, 0x005B, 0x2681, 0x005D, 0x0062 }; std::vector<int> const expected_levels = { 1, 1, 1, 2, 2, 2, 2, 2 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 3, 4, 5, 6, 7, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15588 std::vector<uint32_t> const cps = { 0x0028, 0x0029, 0x2680, 0x0061, 0x005B, 0x005D, 0x2681, 0x0062 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15589 std::vector<uint32_t> const cps = { 0x0028, 0x0029, 0x2680, 0x0061, 0x005B, 0x005D, 0x2681, 0x0062 }; std::vector<int> const expected_levels = { 1, 1, 1, 2, 2, 2, 2, 2 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 3, 4, 5, 6, 7, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15590 std::vector<uint32_t> const cps = { 0x0028, 0x0029, 0x2680, 0x005B, 0x0061, 0x2681, 0x0062, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15591 std::vector<uint32_t> const cps = { 0x0028, 0x0029, 0x2680, 0x005B, 0x0061, 0x2681, 0x0062, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 2, 2, 2, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 4, 5, 6, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15592 std::vector<uint32_t> const cps = { 0x0028, 0x0029, 0x2680, 0x005B, 0x0061, 0x2681, 0x005D, 0x0062 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15593 std::vector<uint32_t> const cps = { 0x0028, 0x0029, 0x2680, 0x005B, 0x0061, 0x2681, 0x005D, 0x0062 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 2, 1, 1, 2 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15594 std::vector<uint32_t> const cps = { 0x0028, 0x0029, 0x2680, 0x005B, 0x0061, 0x005D, 0x2681, 0x0062 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15595 std::vector<uint32_t> const cps = { 0x0028, 0x0029, 0x2680, 0x005B, 0x0061, 0x005D, 0x2681, 0x0062 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 2, 1, 1, 2 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15596 std::vector<uint32_t> const cps = { 0x0028, 0x0029, 0x005B, 0x2680, 0x0061, 0x2681, 0x0062, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } } TEST(bidi_character, bidi_character_022_019) { { // line 15597 std::vector<uint32_t> const cps = { 0x0028, 0x0029, 0x005B, 0x2680, 0x0061, 0x2681, 0x0062, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 2, 2, 2, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 4, 5, 6, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15598 std::vector<uint32_t> const cps = { 0x0028, 0x0029, 0x005B, 0x2680, 0x0061, 0x2681, 0x005D, 0x0062 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15599 std::vector<uint32_t> const cps = { 0x0028, 0x0029, 0x005B, 0x2680, 0x0061, 0x2681, 0x005D, 0x0062 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 2, 1, 1, 2 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15600 std::vector<uint32_t> const cps = { 0x0028, 0x0029, 0x005B, 0x2680, 0x0061, 0x005D, 0x2681, 0x0062 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15601 std::vector<uint32_t> const cps = { 0x0028, 0x0029, 0x005B, 0x2680, 0x0061, 0x005D, 0x2681, 0x0062 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 2, 1, 1, 2 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15604 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0061, 0x2681, 0x05D0, 0x0029, 0x005B, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 1, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15605 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0061, 0x2681, 0x05D0, 0x0029, 0x005B, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 2, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15606 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0061, 0x2681, 0x0029, 0x05D0, 0x005B, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 1, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15607 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0061, 0x2681, 0x0029, 0x05D0, 0x005B, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 2, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15608 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0061, 0x2681, 0x0029, 0x005B, 0x05D0, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 1, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } } TEST(bidi_character, bidi_character_022_020) { { // line 15609 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0061, 0x2681, 0x0029, 0x005B, 0x05D0, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 2, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15610 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0061, 0x2681, 0x0029, 0x005B, 0x005D, 0x05D0 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15611 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0061, 0x2681, 0x0029, 0x005B, 0x005D, 0x05D0 }; std::vector<int> const expected_levels = { 1, 1, 2, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15612 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0061, 0x0029, 0x2681, 0x05D0, 0x005B, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 1, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15613 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0061, 0x0029, 0x2681, 0x05D0, 0x005B, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 2, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15614 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0061, 0x0029, 0x2681, 0x005B, 0x05D0, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 1, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15615 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0061, 0x0029, 0x2681, 0x005B, 0x05D0, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 2, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15616 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0061, 0x0029, 0x2681, 0x005B, 0x005D, 0x05D0 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15617 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0061, 0x0029, 0x2681, 0x005B, 0x005D, 0x05D0 }; std::vector<int> const expected_levels = { 1, 1, 2, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15618 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0061, 0x0029, 0x005B, 0x2681, 0x05D0, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 1, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } } TEST(bidi_character, bidi_character_022_021) { { // line 15619 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0061, 0x0029, 0x005B, 0x2681, 0x05D0, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 2, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15620 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0061, 0x0029, 0x005B, 0x2681, 0x005D, 0x05D0 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15621 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0061, 0x0029, 0x005B, 0x2681, 0x005D, 0x05D0 }; std::vector<int> const expected_levels = { 1, 1, 2, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15622 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0061, 0x0029, 0x005B, 0x005D, 0x2681, 0x05D0 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15623 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0061, 0x0029, 0x005B, 0x005D, 0x2681, 0x05D0 }; std::vector<int> const expected_levels = { 1, 1, 2, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15624 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0029, 0x0061, 0x2681, 0x05D0, 0x005B, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 1, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15625 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0029, 0x0061, 0x2681, 0x05D0, 0x005B, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 2, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15626 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0029, 0x0061, 0x2681, 0x005B, 0x05D0, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 1, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15627 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0029, 0x0061, 0x2681, 0x005B, 0x05D0, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 2, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15628 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0029, 0x0061, 0x2681, 0x005B, 0x005D, 0x05D0 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } } TEST(bidi_character, bidi_character_022_022) { { // line 15629 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0029, 0x0061, 0x2681, 0x005B, 0x005D, 0x05D0 }; std::vector<int> const expected_levels = { 1, 1, 1, 2, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15630 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0029, 0x0061, 0x005B, 0x2681, 0x05D0, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 1, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15631 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0029, 0x0061, 0x005B, 0x2681, 0x05D0, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 2, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15632 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0029, 0x0061, 0x005B, 0x2681, 0x005D, 0x05D0 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15633 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0029, 0x0061, 0x005B, 0x2681, 0x005D, 0x05D0 }; std::vector<int> const expected_levels = { 1, 1, 1, 2, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15634 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0029, 0x0061, 0x005B, 0x005D, 0x2681, 0x05D0 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15635 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0029, 0x0061, 0x005B, 0x005D, 0x2681, 0x05D0 }; std::vector<int> const expected_levels = { 1, 1, 1, 2, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15636 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0029, 0x005B, 0x0061, 0x2681, 0x05D0, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 1, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15637 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0029, 0x005B, 0x0061, 0x2681, 0x05D0, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 2, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15638 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0029, 0x005B, 0x0061, 0x2681, 0x005D, 0x05D0 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } } TEST(bidi_character, bidi_character_022_023) { { // line 15639 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0029, 0x005B, 0x0061, 0x2681, 0x005D, 0x05D0 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 2, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15640 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0029, 0x005B, 0x0061, 0x005D, 0x2681, 0x05D0 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15641 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0029, 0x005B, 0x0061, 0x005D, 0x2681, 0x05D0 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 2, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15642 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0061, 0x2681, 0x05D0, 0x0029, 0x005B, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 1, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15643 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0061, 0x2681, 0x05D0, 0x0029, 0x005B, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 2, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15644 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0061, 0x2681, 0x0029, 0x05D0, 0x005B, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 1, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15645 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0061, 0x2681, 0x0029, 0x05D0, 0x005B, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 2, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15646 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0061, 0x2681, 0x0029, 0x005B, 0x05D0, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 1, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15647 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0061, 0x2681, 0x0029, 0x005B, 0x05D0, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 2, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15648 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0061, 0x2681, 0x0029, 0x005B, 0x005D, 0x05D0 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } } TEST(bidi_character, bidi_character_022_024) { { // line 15649 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0061, 0x2681, 0x0029, 0x005B, 0x005D, 0x05D0 }; std::vector<int> const expected_levels = { 1, 1, 2, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15650 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0061, 0x0029, 0x2681, 0x05D0, 0x005B, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 1, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15651 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0061, 0x0029, 0x2681, 0x05D0, 0x005B, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 2, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15652 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0061, 0x0029, 0x2681, 0x005B, 0x05D0, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 1, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15653 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0061, 0x0029, 0x2681, 0x005B, 0x05D0, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 2, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15654 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0061, 0x0029, 0x2681, 0x005B, 0x005D, 0x05D0 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15655 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0061, 0x0029, 0x2681, 0x005B, 0x005D, 0x05D0 }; std::vector<int> const expected_levels = { 1, 1, 2, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15656 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0061, 0x0029, 0x005B, 0x2681, 0x05D0, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 1, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15657 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0061, 0x0029, 0x005B, 0x2681, 0x05D0, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 2, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15658 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0061, 0x0029, 0x005B, 0x2681, 0x005D, 0x05D0 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } } TEST(bidi_character, bidi_character_022_025) { { // line 15659 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0061, 0x0029, 0x005B, 0x2681, 0x005D, 0x05D0 }; std::vector<int> const expected_levels = { 1, 1, 2, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15660 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0061, 0x0029, 0x005B, 0x005D, 0x2681, 0x05D0 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15661 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0061, 0x0029, 0x005B, 0x005D, 0x2681, 0x05D0 }; std::vector<int> const expected_levels = { 1, 1, 2, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15662 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0029, 0x0061, 0x2681, 0x05D0, 0x005B, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 1, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15663 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0029, 0x0061, 0x2681, 0x05D0, 0x005B, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 2, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15664 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0029, 0x0061, 0x2681, 0x005B, 0x05D0, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 1, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15665 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0029, 0x0061, 0x2681, 0x005B, 0x05D0, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 2, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15666 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0029, 0x0061, 0x2681, 0x005B, 0x005D, 0x05D0 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15667 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0029, 0x0061, 0x2681, 0x005B, 0x005D, 0x05D0 }; std::vector<int> const expected_levels = { 1, 1, 1, 2, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15668 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0029, 0x0061, 0x005B, 0x2681, 0x05D0, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 1, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } } TEST(bidi_character, bidi_character_022_026) { { // line 15669 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0029, 0x0061, 0x005B, 0x2681, 0x05D0, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 2, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15670 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0029, 0x0061, 0x005B, 0x2681, 0x005D, 0x05D0 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15671 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0029, 0x0061, 0x005B, 0x2681, 0x005D, 0x05D0 }; std::vector<int> const expected_levels = { 1, 1, 1, 2, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15672 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0029, 0x0061, 0x005B, 0x005D, 0x2681, 0x05D0 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15673 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0029, 0x0061, 0x005B, 0x005D, 0x2681, 0x05D0 }; std::vector<int> const expected_levels = { 1, 1, 1, 2, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15674 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0029, 0x005B, 0x0061, 0x2681, 0x05D0, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 1, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15675 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0029, 0x005B, 0x0061, 0x2681, 0x05D0, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 2, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15676 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0029, 0x005B, 0x0061, 0x2681, 0x005D, 0x05D0 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15677 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0029, 0x005B, 0x0061, 0x2681, 0x005D, 0x05D0 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 2, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15678 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0029, 0x005B, 0x0061, 0x005D, 0x2681, 0x05D0 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } } TEST(bidi_character, bidi_character_022_027) { { // line 15679 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0029, 0x005B, 0x0061, 0x005D, 0x2681, 0x05D0 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 2, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15680 std::vector<uint32_t> const cps = { 0x0028, 0x0029, 0x2680, 0x0061, 0x2681, 0x05D0, 0x005B, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 1, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15681 std::vector<uint32_t> const cps = { 0x0028, 0x0029, 0x2680, 0x0061, 0x2681, 0x05D0, 0x005B, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 2, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15682 std::vector<uint32_t> const cps = { 0x0028, 0x0029, 0x2680, 0x0061, 0x2681, 0x005B, 0x05D0, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 1, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15683 std::vector<uint32_t> const cps = { 0x0028, 0x0029, 0x2680, 0x0061, 0x2681, 0x005B, 0x05D0, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 2, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15684 std::vector<uint32_t> const cps = { 0x0028, 0x0029, 0x2680, 0x0061, 0x2681, 0x005B, 0x005D, 0x05D0 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15685 std::vector<uint32_t> const cps = { 0x0028, 0x0029, 0x2680, 0x0061, 0x2681, 0x005B, 0x005D, 0x05D0 }; std::vector<int> const expected_levels = { 1, 1, 1, 2, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15686 std::vector<uint32_t> const cps = { 0x0028, 0x0029, 0x2680, 0x0061, 0x005B, 0x2681, 0x05D0, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 1, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15687 std::vector<uint32_t> const cps = { 0x0028, 0x0029, 0x2680, 0x0061, 0x005B, 0x2681, 0x05D0, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 2, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15688 std::vector<uint32_t> const cps = { 0x0028, 0x0029, 0x2680, 0x0061, 0x005B, 0x2681, 0x005D, 0x05D0 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } } TEST(bidi_character, bidi_character_022_028) { { // line 15689 std::vector<uint32_t> const cps = { 0x0028, 0x0029, 0x2680, 0x0061, 0x005B, 0x2681, 0x005D, 0x05D0 }; std::vector<int> const expected_levels = { 1, 1, 1, 2, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15690 std::vector<uint32_t> const cps = { 0x0028, 0x0029, 0x2680, 0x0061, 0x005B, 0x005D, 0x2681, 0x05D0 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15691 std::vector<uint32_t> const cps = { 0x0028, 0x0029, 0x2680, 0x0061, 0x005B, 0x005D, 0x2681, 0x05D0 }; std::vector<int> const expected_levels = { 1, 1, 1, 2, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15692 std::vector<uint32_t> const cps = { 0x0028, 0x0029, 0x2680, 0x005B, 0x0061, 0x2681, 0x05D0, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 1, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15693 std::vector<uint32_t> const cps = { 0x0028, 0x0029, 0x2680, 0x005B, 0x0061, 0x2681, 0x05D0, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 2, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15694 std::vector<uint32_t> const cps = { 0x0028, 0x0029, 0x2680, 0x005B, 0x0061, 0x2681, 0x005D, 0x05D0 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15695 std::vector<uint32_t> const cps = { 0x0028, 0x0029, 0x2680, 0x005B, 0x0061, 0x2681, 0x005D, 0x05D0 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 2, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15696 std::vector<uint32_t> const cps = { 0x0028, 0x0029, 0x2680, 0x005B, 0x0061, 0x005D, 0x2681, 0x05D0 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15697 std::vector<uint32_t> const cps = { 0x0028, 0x0029, 0x2680, 0x005B, 0x0061, 0x005D, 0x2681, 0x05D0 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 2, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15698 std::vector<uint32_t> const cps = { 0x0028, 0x0029, 0x005B, 0x2680, 0x0061, 0x2681, 0x05D0, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 1, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } } TEST(bidi_character, bidi_character_022_029) { { // line 15699 std::vector<uint32_t> const cps = { 0x0028, 0x0029, 0x005B, 0x2680, 0x0061, 0x2681, 0x05D0, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 2, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15700 std::vector<uint32_t> const cps = { 0x0028, 0x0029, 0x005B, 0x2680, 0x0061, 0x2681, 0x005D, 0x05D0 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15701 std::vector<uint32_t> const cps = { 0x0028, 0x0029, 0x005B, 0x2680, 0x0061, 0x2681, 0x005D, 0x05D0 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 2, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15702 std::vector<uint32_t> const cps = { 0x0028, 0x0029, 0x005B, 0x2680, 0x0061, 0x005D, 0x2681, 0x05D0 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15703 std::vector<uint32_t> const cps = { 0x0028, 0x0029, 0x005B, 0x2680, 0x0061, 0x005D, 0x2681, 0x05D0 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 2, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15706 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0061, 0x0029, 0x0062, 0x2681, 0x005B, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15707 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0061, 0x0029, 0x0062, 0x2681, 0x005B, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 2, 1, 2, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15708 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0061, 0x0029, 0x0062, 0x005B, 0x2681, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15709 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0061, 0x0029, 0x0062, 0x005B, 0x2681, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 2, 1, 2, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15710 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0061, 0x0029, 0x0062, 0x005B, 0x005D, 0x2681 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } } TEST(bidi_character, bidi_character_022_030) { { // line 15711 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0061, 0x0029, 0x0062, 0x005B, 0x005D, 0x2681 }; std::vector<int> const expected_levels = { 1, 1, 2, 1, 2, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15712 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0061, 0x0029, 0x005B, 0x0062, 0x2681, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15713 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0061, 0x0029, 0x005B, 0x0062, 0x2681, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 2, 1, 1, 2, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15714 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0061, 0x0029, 0x005B, 0x0062, 0x005D, 0x2681 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15715 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0061, 0x0029, 0x005B, 0x0062, 0x005D, 0x2681 }; std::vector<int> const expected_levels = { 1, 1, 2, 1, 1, 2, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15716 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0029, 0x0061, 0x005B, 0x0062, 0x2681, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15717 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0029, 0x0061, 0x005B, 0x0062, 0x2681, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 2, 2, 2, 2, 2 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 3, 4, 5, 6, 7, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15718 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0029, 0x0061, 0x005B, 0x0062, 0x005D, 0x2681 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15719 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0029, 0x0061, 0x005B, 0x0062, 0x005D, 0x2681 }; std::vector<int> const expected_levels = { 1, 1, 1, 2, 2, 2, 2, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 3, 4, 5, 6, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15720 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0061, 0x0029, 0x0062, 0x2681, 0x005B, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } } TEST(bidi_character, bidi_character_022_031) { { // line 15721 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0061, 0x0029, 0x0062, 0x2681, 0x005B, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 2, 1, 2, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15722 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0061, 0x0029, 0x0062, 0x005B, 0x2681, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15723 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0061, 0x0029, 0x0062, 0x005B, 0x2681, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 2, 1, 2, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15724 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0061, 0x0029, 0x0062, 0x005B, 0x005D, 0x2681 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15725 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0061, 0x0029, 0x0062, 0x005B, 0x005D, 0x2681 }; std::vector<int> const expected_levels = { 1, 1, 2, 1, 2, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15726 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0061, 0x0029, 0x005B, 0x0062, 0x2681, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15727 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0061, 0x0029, 0x005B, 0x0062, 0x2681, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 2, 1, 1, 2, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15728 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0061, 0x0029, 0x005B, 0x0062, 0x005D, 0x2681 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15729 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0061, 0x0029, 0x005B, 0x0062, 0x005D, 0x2681 }; std::vector<int> const expected_levels = { 1, 1, 2, 1, 1, 2, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15730 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0029, 0x0061, 0x005B, 0x0062, 0x2681, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } } TEST(bidi_character, bidi_character_022_032) { { // line 15731 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0029, 0x0061, 0x005B, 0x0062, 0x2681, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 2, 2, 2, 2, 2 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 3, 4, 5, 6, 7, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15732 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0029, 0x0061, 0x005B, 0x0062, 0x005D, 0x2681 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15733 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0029, 0x0061, 0x005B, 0x0062, 0x005D, 0x2681 }; std::vector<int> const expected_levels = { 1, 1, 1, 2, 2, 2, 2, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 3, 4, 5, 6, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15734 std::vector<uint32_t> const cps = { 0x0028, 0x0029, 0x2680, 0x0061, 0x005B, 0x0062, 0x2681, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15735 std::vector<uint32_t> const cps = { 0x0028, 0x0029, 0x2680, 0x0061, 0x005B, 0x0062, 0x2681, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 2, 2, 2, 2, 2 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 3, 4, 5, 6, 7, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15736 std::vector<uint32_t> const cps = { 0x0028, 0x0029, 0x2680, 0x0061, 0x005B, 0x0062, 0x005D, 0x2681 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15737 std::vector<uint32_t> const cps = { 0x0028, 0x0029, 0x2680, 0x0061, 0x005B, 0x0062, 0x005D, 0x2681 }; std::vector<int> const expected_levels = { 1, 1, 1, 2, 2, 2, 2, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 3, 4, 5, 6, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15740 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0061, 0x0029, 0x0062, 0x005B, 0x0063, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15741 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0061, 0x0029, 0x0062, 0x005B, 0x0063, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 2, 1, 2, 2, 2, 2 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 4, 5, 6, 7, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15742 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0061, 0x0029, 0x0062, 0x005B, 0x005D, 0x0063 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } } TEST(bidi_character, bidi_character_022_033) { { // line 15743 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0061, 0x0029, 0x0062, 0x005B, 0x005D, 0x0063 }; std::vector<int> const expected_levels = { 1, 1, 2, 1, 2, 2, 2, 2 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 4, 5, 6, 7, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15744 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0061, 0x0029, 0x005B, 0x0062, 0x005D, 0x0063 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15745 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0061, 0x0029, 0x005B, 0x0062, 0x005D, 0x0063 }; std::vector<int> const expected_levels = { 1, 1, 2, 1, 1, 2, 1, 2 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15746 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0029, 0x0061, 0x005B, 0x0062, 0x005D, 0x0063 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15747 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0029, 0x0061, 0x005B, 0x0062, 0x005D, 0x0063 }; std::vector<int> const expected_levels = { 1, 1, 1, 2, 2, 2, 2, 2 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 3, 4, 5, 6, 7, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15748 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0061, 0x0029, 0x0062, 0x005B, 0x0063, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15749 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0061, 0x0029, 0x0062, 0x005B, 0x0063, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 2, 1, 2, 2, 2, 2 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 4, 5, 6, 7, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15750 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0061, 0x0029, 0x0062, 0x005B, 0x005D, 0x0063 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15751 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0061, 0x0029, 0x0062, 0x005B, 0x005D, 0x0063 }; std::vector<int> const expected_levels = { 1, 1, 2, 1, 2, 2, 2, 2 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 4, 5, 6, 7, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15752 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0061, 0x0029, 0x005B, 0x0062, 0x005D, 0x0063 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } } TEST(bidi_character, bidi_character_022_034) { { // line 15753 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0061, 0x0029, 0x005B, 0x0062, 0x005D, 0x0063 }; std::vector<int> const expected_levels = { 1, 1, 2, 1, 1, 2, 1, 2 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15754 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0029, 0x0061, 0x005B, 0x0062, 0x005D, 0x0063 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15755 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0029, 0x0061, 0x005B, 0x0062, 0x005D, 0x0063 }; std::vector<int> const expected_levels = { 1, 1, 1, 2, 2, 2, 2, 2 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 3, 4, 5, 6, 7, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15756 std::vector<uint32_t> const cps = { 0x0028, 0x0029, 0x2680, 0x0061, 0x005B, 0x0062, 0x005D, 0x0063 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15757 std::vector<uint32_t> const cps = { 0x0028, 0x0029, 0x2680, 0x0061, 0x005B, 0x0062, 0x005D, 0x0063 }; std::vector<int> const expected_levels = { 1, 1, 1, 2, 2, 2, 2, 2 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 3, 4, 5, 6, 7, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15760 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0061, 0x0029, 0x0062, 0x05D0, 0x005B, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 1, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15761 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0061, 0x0029, 0x0062, 0x05D0, 0x005B, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 2, 1, 2, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15762 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0061, 0x0029, 0x0062, 0x005B, 0x05D0, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 1, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15763 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0061, 0x0029, 0x0062, 0x005B, 0x05D0, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 2, 1, 2, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15764 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0061, 0x0029, 0x0062, 0x005B, 0x005D, 0x05D0 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } } TEST(bidi_character, bidi_character_022_035) { { // line 15765 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0061, 0x0029, 0x0062, 0x005B, 0x005D, 0x05D0 }; std::vector<int> const expected_levels = { 1, 1, 2, 1, 2, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15766 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0061, 0x0029, 0x005B, 0x0062, 0x05D0, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 1, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15767 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0061, 0x0029, 0x005B, 0x0062, 0x05D0, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 2, 1, 1, 2, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15768 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0061, 0x0029, 0x005B, 0x0062, 0x005D, 0x05D0 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15769 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0061, 0x0029, 0x005B, 0x0062, 0x005D, 0x05D0 }; std::vector<int> const expected_levels = { 1, 1, 2, 1, 1, 2, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15770 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0029, 0x0061, 0x005B, 0x0062, 0x05D0, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 1, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15771 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0029, 0x0061, 0x005B, 0x0062, 0x05D0, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 2, 1, 2, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15772 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0029, 0x0061, 0x005B, 0x0062, 0x005D, 0x05D0 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15773 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0029, 0x0061, 0x005B, 0x0062, 0x005D, 0x05D0 }; std::vector<int> const expected_levels = { 1, 1, 1, 2, 2, 2, 2, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 3, 4, 5, 6, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15774 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0061, 0x0029, 0x0062, 0x05D0, 0x005B, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 1, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } } TEST(bidi_character, bidi_character_022_036) { { // line 15775 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0061, 0x0029, 0x0062, 0x05D0, 0x005B, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 2, 1, 2, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15776 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0061, 0x0029, 0x0062, 0x005B, 0x05D0, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 1, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15777 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0061, 0x0029, 0x0062, 0x005B, 0x05D0, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 2, 1, 2, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15778 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0061, 0x0029, 0x0062, 0x005B, 0x005D, 0x05D0 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15779 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0061, 0x0029, 0x0062, 0x005B, 0x005D, 0x05D0 }; std::vector<int> const expected_levels = { 1, 1, 2, 1, 2, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15780 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0061, 0x0029, 0x005B, 0x0062, 0x05D0, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 1, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15781 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0061, 0x0029, 0x005B, 0x0062, 0x05D0, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 2, 1, 1, 2, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15782 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0061, 0x0029, 0x005B, 0x0062, 0x005D, 0x05D0 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15783 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0061, 0x0029, 0x005B, 0x0062, 0x005D, 0x05D0 }; std::vector<int> const expected_levels = { 1, 1, 2, 1, 1, 2, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15784 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0029, 0x0061, 0x005B, 0x0062, 0x05D0, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 1, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } } TEST(bidi_character, bidi_character_022_037) { { // line 15785 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0029, 0x0061, 0x005B, 0x0062, 0x05D0, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 2, 1, 2, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15786 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0029, 0x0061, 0x005B, 0x0062, 0x005D, 0x05D0 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15787 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0029, 0x0061, 0x005B, 0x0062, 0x005D, 0x05D0 }; std::vector<int> const expected_levels = { 1, 1, 1, 2, 2, 2, 2, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 3, 4, 5, 6, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15788 std::vector<uint32_t> const cps = { 0x0028, 0x0029, 0x2680, 0x0061, 0x005B, 0x0062, 0x05D0, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 1, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15789 std::vector<uint32_t> const cps = { 0x0028, 0x0029, 0x2680, 0x0061, 0x005B, 0x0062, 0x05D0, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 2, 1, 2, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15790 std::vector<uint32_t> const cps = { 0x0028, 0x0029, 0x2680, 0x0061, 0x005B, 0x0062, 0x005D, 0x05D0 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15791 std::vector<uint32_t> const cps = { 0x0028, 0x0029, 0x2680, 0x0061, 0x005B, 0x0062, 0x005D, 0x05D0 }; std::vector<int> const expected_levels = { 1, 1, 1, 2, 2, 2, 2, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 3, 4, 5, 6, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15794 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0061, 0x05D0, 0x2681, 0x0029, 0x005B, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 1, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15795 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0061, 0x05D0, 0x2681, 0x0029, 0x005B, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 2, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15796 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0061, 0x05D0, 0x0029, 0x2681, 0x005B, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 1, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } } TEST(bidi_character, bidi_character_022_038) { { // line 15797 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0061, 0x05D0, 0x0029, 0x2681, 0x005B, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 2, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15798 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0061, 0x05D0, 0x0029, 0x005B, 0x2681, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 1, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15799 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0061, 0x05D0, 0x0029, 0x005B, 0x2681, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 2, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15800 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0061, 0x05D0, 0x0029, 0x005B, 0x005D, 0x2681 }; std::vector<int> const expected_levels = { 0, 0, 0, 1, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15801 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0061, 0x05D0, 0x0029, 0x005B, 0x005D, 0x2681 }; std::vector<int> const expected_levels = { 1, 1, 2, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15802 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0061, 0x0029, 0x05D0, 0x2681, 0x005B, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 1, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15803 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0061, 0x0029, 0x05D0, 0x2681, 0x005B, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 2, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15804 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0061, 0x0029, 0x05D0, 0x005B, 0x2681, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 1, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15805 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0061, 0x0029, 0x05D0, 0x005B, 0x2681, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 2, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15806 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0061, 0x0029, 0x05D0, 0x005B, 0x005D, 0x2681 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 1, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } } TEST(bidi_character, bidi_character_022_039) { { // line 15807 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0061, 0x0029, 0x05D0, 0x005B, 0x005D, 0x2681 }; std::vector<int> const expected_levels = { 1, 1, 2, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15808 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0061, 0x0029, 0x005B, 0x05D0, 0x2681, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 1, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15809 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0061, 0x0029, 0x005B, 0x05D0, 0x2681, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 2, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15810 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0061, 0x0029, 0x005B, 0x05D0, 0x005D, 0x2681 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 1, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15811 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0061, 0x0029, 0x005B, 0x05D0, 0x005D, 0x2681 }; std::vector<int> const expected_levels = { 1, 1, 2, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15812 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0029, 0x0061, 0x05D0, 0x2681, 0x005B, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 1, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15813 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0029, 0x0061, 0x05D0, 0x2681, 0x005B, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 2, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15814 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0029, 0x0061, 0x05D0, 0x005B, 0x2681, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 1, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15815 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0029, 0x0061, 0x05D0, 0x005B, 0x2681, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 2, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15816 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0029, 0x0061, 0x05D0, 0x005B, 0x005D, 0x2681 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 1, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } } TEST(bidi_character, bidi_character_022_040) { { // line 15817 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0029, 0x0061, 0x05D0, 0x005B, 0x005D, 0x2681 }; std::vector<int> const expected_levels = { 1, 1, 1, 2, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15818 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0029, 0x0061, 0x005B, 0x05D0, 0x2681, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 1, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15819 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0029, 0x0061, 0x005B, 0x05D0, 0x2681, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 2, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15820 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0029, 0x0061, 0x005B, 0x05D0, 0x005D, 0x2681 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 1, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15821 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0029, 0x0061, 0x005B, 0x05D0, 0x005D, 0x2681 }; std::vector<int> const expected_levels = { 1, 1, 1, 2, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15822 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0029, 0x005B, 0x0061, 0x05D0, 0x2681, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 1, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15823 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0029, 0x005B, 0x0061, 0x05D0, 0x2681, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 2, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15824 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0029, 0x005B, 0x0061, 0x05D0, 0x005D, 0x2681 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 1, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15825 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0029, 0x005B, 0x0061, 0x05D0, 0x005D, 0x2681 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 2, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15826 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0061, 0x05D0, 0x2681, 0x0029, 0x005B, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 1, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } } TEST(bidi_character, bidi_character_022_041) { { // line 15827 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0061, 0x05D0, 0x2681, 0x0029, 0x005B, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 2, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15828 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0061, 0x05D0, 0x0029, 0x2681, 0x005B, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 1, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15829 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0061, 0x05D0, 0x0029, 0x2681, 0x005B, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 2, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15830 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0061, 0x05D0, 0x0029, 0x005B, 0x2681, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 1, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15831 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0061, 0x05D0, 0x0029, 0x005B, 0x2681, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 2, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15832 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0061, 0x05D0, 0x0029, 0x005B, 0x005D, 0x2681 }; std::vector<int> const expected_levels = { 0, 0, 0, 1, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15833 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0061, 0x05D0, 0x0029, 0x005B, 0x005D, 0x2681 }; std::vector<int> const expected_levels = { 1, 1, 2, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15834 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0061, 0x0029, 0x05D0, 0x2681, 0x005B, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 1, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15835 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0061, 0x0029, 0x05D0, 0x2681, 0x005B, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 2, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15836 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0061, 0x0029, 0x05D0, 0x005B, 0x2681, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 1, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } } TEST(bidi_character, bidi_character_022_042) { { // line 15837 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0061, 0x0029, 0x05D0, 0x005B, 0x2681, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 2, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15838 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0061, 0x0029, 0x05D0, 0x005B, 0x005D, 0x2681 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 1, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15839 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0061, 0x0029, 0x05D0, 0x005B, 0x005D, 0x2681 }; std::vector<int> const expected_levels = { 1, 1, 2, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15840 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0061, 0x0029, 0x005B, 0x05D0, 0x2681, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 1, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15841 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0061, 0x0029, 0x005B, 0x05D0, 0x2681, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 2, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15842 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0061, 0x0029, 0x005B, 0x05D0, 0x005D, 0x2681 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 1, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15843 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0061, 0x0029, 0x005B, 0x05D0, 0x005D, 0x2681 }; std::vector<int> const expected_levels = { 1, 1, 2, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15844 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0029, 0x0061, 0x05D0, 0x2681, 0x005B, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 1, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15845 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0029, 0x0061, 0x05D0, 0x2681, 0x005B, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 2, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15846 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0029, 0x0061, 0x05D0, 0x005B, 0x2681, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 1, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } } TEST(bidi_character, bidi_character_022_043) { { // line 15847 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0029, 0x0061, 0x05D0, 0x005B, 0x2681, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 2, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15848 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0029, 0x0061, 0x05D0, 0x005B, 0x005D, 0x2681 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 1, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15849 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0029, 0x0061, 0x05D0, 0x005B, 0x005D, 0x2681 }; std::vector<int> const expected_levels = { 1, 1, 1, 2, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15850 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0029, 0x0061, 0x005B, 0x05D0, 0x2681, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 1, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15851 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0029, 0x0061, 0x005B, 0x05D0, 0x2681, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 2, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15852 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0029, 0x0061, 0x005B, 0x05D0, 0x005D, 0x2681 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 1, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15853 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0029, 0x0061, 0x005B, 0x05D0, 0x005D, 0x2681 }; std::vector<int> const expected_levels = { 1, 1, 1, 2, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15854 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0029, 0x005B, 0x0061, 0x05D0, 0x2681, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 1, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15855 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0029, 0x005B, 0x0061, 0x05D0, 0x2681, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 2, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15856 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0029, 0x005B, 0x0061, 0x05D0, 0x005D, 0x2681 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 1, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } } TEST(bidi_character, bidi_character_022_044) { { // line 15857 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0029, 0x005B, 0x0061, 0x05D0, 0x005D, 0x2681 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 2, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15858 std::vector<uint32_t> const cps = { 0x0028, 0x0029, 0x2680, 0x0061, 0x05D0, 0x2681, 0x005B, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 1, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15859 std::vector<uint32_t> const cps = { 0x0028, 0x0029, 0x2680, 0x0061, 0x05D0, 0x2681, 0x005B, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 2, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15860 std::vector<uint32_t> const cps = { 0x0028, 0x0029, 0x2680, 0x0061, 0x05D0, 0x005B, 0x2681, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 1, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15861 std::vector<uint32_t> const cps = { 0x0028, 0x0029, 0x2680, 0x0061, 0x05D0, 0x005B, 0x2681, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 2, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15862 std::vector<uint32_t> const cps = { 0x0028, 0x0029, 0x2680, 0x0061, 0x05D0, 0x005B, 0x005D, 0x2681 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 1, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15863 std::vector<uint32_t> const cps = { 0x0028, 0x0029, 0x2680, 0x0061, 0x05D0, 0x005B, 0x005D, 0x2681 }; std::vector<int> const expected_levels = { 1, 1, 1, 2, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15864 std::vector<uint32_t> const cps = { 0x0028, 0x0029, 0x2680, 0x0061, 0x005B, 0x05D0, 0x2681, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 1, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15865 std::vector<uint32_t> const cps = { 0x0028, 0x0029, 0x2680, 0x0061, 0x005B, 0x05D0, 0x2681, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 2, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15866 std::vector<uint32_t> const cps = { 0x0028, 0x0029, 0x2680, 0x0061, 0x005B, 0x05D0, 0x005D, 0x2681 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 1, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } } TEST(bidi_character, bidi_character_022_045) { { // line 15867 std::vector<uint32_t> const cps = { 0x0028, 0x0029, 0x2680, 0x0061, 0x005B, 0x05D0, 0x005D, 0x2681 }; std::vector<int> const expected_levels = { 1, 1, 1, 2, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15868 std::vector<uint32_t> const cps = { 0x0028, 0x0029, 0x2680, 0x005B, 0x0061, 0x05D0, 0x2681, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 1, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15869 std::vector<uint32_t> const cps = { 0x0028, 0x0029, 0x2680, 0x005B, 0x0061, 0x05D0, 0x2681, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 2, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15870 std::vector<uint32_t> const cps = { 0x0028, 0x0029, 0x2680, 0x005B, 0x0061, 0x05D0, 0x005D, 0x2681 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 1, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15871 std::vector<uint32_t> const cps = { 0x0028, 0x0029, 0x2680, 0x005B, 0x0061, 0x05D0, 0x005D, 0x2681 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 2, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15872 std::vector<uint32_t> const cps = { 0x0028, 0x0029, 0x005B, 0x2680, 0x0061, 0x05D0, 0x2681, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 1, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15873 std::vector<uint32_t> const cps = { 0x0028, 0x0029, 0x005B, 0x2680, 0x0061, 0x05D0, 0x2681, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 2, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15874 std::vector<uint32_t> const cps = { 0x0028, 0x0029, 0x005B, 0x2680, 0x0061, 0x05D0, 0x005D, 0x2681 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 1, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15875 std::vector<uint32_t> const cps = { 0x0028, 0x0029, 0x005B, 0x2680, 0x0061, 0x05D0, 0x005D, 0x2681 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 2, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15878 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0061, 0x05D0, 0x0062, 0x0029, 0x005B, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 1, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } } TEST(bidi_character, bidi_character_022_046) { { // line 15879 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0061, 0x05D0, 0x0062, 0x0029, 0x005B, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 2, 1, 2, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15880 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0061, 0x05D0, 0x0029, 0x0062, 0x005B, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 1, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15881 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0061, 0x05D0, 0x0029, 0x0062, 0x005B, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 2, 1, 1, 2, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15882 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0061, 0x05D0, 0x0029, 0x005B, 0x0062, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 1, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15883 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0061, 0x05D0, 0x0029, 0x005B, 0x0062, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 2, 1, 1, 1, 2, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15884 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0061, 0x05D0, 0x0029, 0x005B, 0x005D, 0x0062 }; std::vector<int> const expected_levels = { 0, 0, 0, 1, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15885 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0061, 0x05D0, 0x0029, 0x005B, 0x005D, 0x0062 }; std::vector<int> const expected_levels = { 1, 1, 2, 1, 1, 1, 1, 2 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15886 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0061, 0x0029, 0x05D0, 0x0062, 0x005B, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 1, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15887 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0061, 0x0029, 0x05D0, 0x0062, 0x005B, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 2, 1, 1, 2, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15888 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0061, 0x0029, 0x05D0, 0x005B, 0x0062, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 1, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } } TEST(bidi_character, bidi_character_022_047) { { // line 15889 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0061, 0x0029, 0x05D0, 0x005B, 0x0062, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 2, 1, 1, 1, 2, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15890 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0061, 0x0029, 0x05D0, 0x005B, 0x005D, 0x0062 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 1, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15891 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0061, 0x0029, 0x05D0, 0x005B, 0x005D, 0x0062 }; std::vector<int> const expected_levels = { 1, 1, 2, 1, 1, 1, 1, 2 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15892 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0061, 0x0029, 0x005B, 0x05D0, 0x0062, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 1, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15893 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0061, 0x0029, 0x005B, 0x05D0, 0x0062, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 2, 1, 1, 1, 2, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15894 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0061, 0x0029, 0x005B, 0x05D0, 0x005D, 0x0062 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 1, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15895 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0061, 0x0029, 0x005B, 0x05D0, 0x005D, 0x0062 }; std::vector<int> const expected_levels = { 1, 1, 2, 1, 1, 1, 1, 2 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15896 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0029, 0x0061, 0x05D0, 0x0062, 0x005B, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 1, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15897 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0029, 0x0061, 0x05D0, 0x0062, 0x005B, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 2, 1, 2, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15898 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0029, 0x0061, 0x05D0, 0x005B, 0x0062, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 1, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } } TEST(bidi_character, bidi_character_022_048) { { // line 15899 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0029, 0x0061, 0x05D0, 0x005B, 0x0062, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 2, 1, 1, 2, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15900 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0029, 0x0061, 0x05D0, 0x005B, 0x005D, 0x0062 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 1, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15901 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0029, 0x0061, 0x05D0, 0x005B, 0x005D, 0x0062 }; std::vector<int> const expected_levels = { 1, 1, 1, 2, 1, 1, 1, 2 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15902 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0029, 0x0061, 0x005B, 0x05D0, 0x0062, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 1, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15903 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0029, 0x0061, 0x005B, 0x05D0, 0x0062, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 2, 1, 1, 2, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15904 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0029, 0x0061, 0x005B, 0x05D0, 0x005D, 0x0062 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 1, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15905 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0029, 0x0061, 0x005B, 0x05D0, 0x005D, 0x0062 }; std::vector<int> const expected_levels = { 1, 1, 1, 2, 1, 1, 1, 2 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15906 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0029, 0x005B, 0x0061, 0x05D0, 0x0062, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 1, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15907 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0029, 0x005B, 0x0061, 0x05D0, 0x0062, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 2, 1, 2, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15908 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0029, 0x005B, 0x0061, 0x05D0, 0x005D, 0x0062 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 1, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } } TEST(bidi_character, bidi_character_022_049) { { // line 15909 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0029, 0x005B, 0x0061, 0x05D0, 0x005D, 0x0062 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 2, 1, 1, 2 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15910 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0061, 0x05D0, 0x0062, 0x0029, 0x005B, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 1, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15911 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0061, 0x05D0, 0x0062, 0x0029, 0x005B, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 2, 1, 2, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15912 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0061, 0x05D0, 0x0029, 0x0062, 0x005B, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 1, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15913 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0061, 0x05D0, 0x0029, 0x0062, 0x005B, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 2, 1, 1, 2, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15914 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0061, 0x05D0, 0x0029, 0x005B, 0x0062, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 1, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15915 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0061, 0x05D0, 0x0029, 0x005B, 0x0062, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 2, 1, 1, 1, 2, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15916 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0061, 0x05D0, 0x0029, 0x005B, 0x005D, 0x0062 }; std::vector<int> const expected_levels = { 0, 0, 0, 1, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15917 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0061, 0x05D0, 0x0029, 0x005B, 0x005D, 0x0062 }; std::vector<int> const expected_levels = { 1, 1, 2, 1, 1, 1, 1, 2 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15918 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0061, 0x0029, 0x05D0, 0x0062, 0x005B, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 1, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } } TEST(bidi_character, bidi_character_022_050) { { // line 15919 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0061, 0x0029, 0x05D0, 0x0062, 0x005B, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 2, 1, 1, 2, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15920 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0061, 0x0029, 0x05D0, 0x005B, 0x0062, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 1, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15921 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0061, 0x0029, 0x05D0, 0x005B, 0x0062, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 2, 1, 1, 1, 2, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15922 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0061, 0x0029, 0x05D0, 0x005B, 0x005D, 0x0062 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 1, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15923 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0061, 0x0029, 0x05D0, 0x005B, 0x005D, 0x0062 }; std::vector<int> const expected_levels = { 1, 1, 2, 1, 1, 1, 1, 2 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15924 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0061, 0x0029, 0x005B, 0x05D0, 0x0062, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 1, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15925 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0061, 0x0029, 0x005B, 0x05D0, 0x0062, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 2, 1, 1, 1, 2, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15926 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0061, 0x0029, 0x005B, 0x05D0, 0x005D, 0x0062 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 1, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15927 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0061, 0x0029, 0x005B, 0x05D0, 0x005D, 0x0062 }; std::vector<int> const expected_levels = { 1, 1, 2, 1, 1, 1, 1, 2 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15928 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0029, 0x0061, 0x05D0, 0x0062, 0x005B, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 1, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } } TEST(bidi_character, bidi_character_022_051) { { // line 15929 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0029, 0x0061, 0x05D0, 0x0062, 0x005B, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 2, 1, 2, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15930 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0029, 0x0061, 0x05D0, 0x005B, 0x0062, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 1, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15931 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0029, 0x0061, 0x05D0, 0x005B, 0x0062, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 2, 1, 1, 2, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15932 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0029, 0x0061, 0x05D0, 0x005B, 0x005D, 0x0062 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 1, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15933 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0029, 0x0061, 0x05D0, 0x005B, 0x005D, 0x0062 }; std::vector<int> const expected_levels = { 1, 1, 1, 2, 1, 1, 1, 2 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15934 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0029, 0x0061, 0x005B, 0x05D0, 0x0062, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 1, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15935 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0029, 0x0061, 0x005B, 0x05D0, 0x0062, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 2, 1, 1, 2, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15936 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0029, 0x0061, 0x005B, 0x05D0, 0x005D, 0x0062 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 1, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15937 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0029, 0x0061, 0x005B, 0x05D0, 0x005D, 0x0062 }; std::vector<int> const expected_levels = { 1, 1, 1, 2, 1, 1, 1, 2 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15938 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0029, 0x005B, 0x0061, 0x05D0, 0x0062, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 1, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } } TEST(bidi_character, bidi_character_022_052) { { // line 15939 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0029, 0x005B, 0x0061, 0x05D0, 0x0062, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 2, 1, 2, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15940 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0029, 0x005B, 0x0061, 0x05D0, 0x005D, 0x0062 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 1, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15941 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0029, 0x005B, 0x0061, 0x05D0, 0x005D, 0x0062 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 2, 1, 1, 2 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15942 std::vector<uint32_t> const cps = { 0x0028, 0x0029, 0x2680, 0x0061, 0x05D0, 0x0062, 0x005B, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 1, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15943 std::vector<uint32_t> const cps = { 0x0028, 0x0029, 0x2680, 0x0061, 0x05D0, 0x0062, 0x005B, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 2, 1, 2, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15944 std::vector<uint32_t> const cps = { 0x0028, 0x0029, 0x2680, 0x0061, 0x05D0, 0x005B, 0x0062, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 1, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15945 std::vector<uint32_t> const cps = { 0x0028, 0x0029, 0x2680, 0x0061, 0x05D0, 0x005B, 0x0062, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 2, 1, 1, 2, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15946 std::vector<uint32_t> const cps = { 0x0028, 0x0029, 0x2680, 0x0061, 0x05D0, 0x005B, 0x005D, 0x0062 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 1, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15947 std::vector<uint32_t> const cps = { 0x0028, 0x0029, 0x2680, 0x0061, 0x05D0, 0x005B, 0x005D, 0x0062 }; std::vector<int> const expected_levels = { 1, 1, 1, 2, 1, 1, 1, 2 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15948 std::vector<uint32_t> const cps = { 0x0028, 0x0029, 0x2680, 0x0061, 0x005B, 0x05D0, 0x0062, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 1, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } } TEST(bidi_character, bidi_character_022_053) { { // line 15949 std::vector<uint32_t> const cps = { 0x0028, 0x0029, 0x2680, 0x0061, 0x005B, 0x05D0, 0x0062, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 2, 1, 1, 2, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15950 std::vector<uint32_t> const cps = { 0x0028, 0x0029, 0x2680, 0x0061, 0x005B, 0x05D0, 0x005D, 0x0062 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 1, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15951 std::vector<uint32_t> const cps = { 0x0028, 0x0029, 0x2680, 0x0061, 0x005B, 0x05D0, 0x005D, 0x0062 }; std::vector<int> const expected_levels = { 1, 1, 1, 2, 1, 1, 1, 2 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15952 std::vector<uint32_t> const cps = { 0x0028, 0x0029, 0x2680, 0x005B, 0x0061, 0x05D0, 0x0062, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 1, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15953 std::vector<uint32_t> const cps = { 0x0028, 0x0029, 0x2680, 0x005B, 0x0061, 0x05D0, 0x0062, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 2, 1, 2, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15954 std::vector<uint32_t> const cps = { 0x0028, 0x0029, 0x2680, 0x005B, 0x0061, 0x05D0, 0x005D, 0x0062 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 1, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15955 std::vector<uint32_t> const cps = { 0x0028, 0x0029, 0x2680, 0x005B, 0x0061, 0x05D0, 0x005D, 0x0062 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 2, 1, 1, 2 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15956 std::vector<uint32_t> const cps = { 0x0028, 0x0029, 0x005B, 0x2680, 0x0061, 0x05D0, 0x0062, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 1, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15957 std::vector<uint32_t> const cps = { 0x0028, 0x0029, 0x005B, 0x2680, 0x0061, 0x05D0, 0x0062, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 2, 1, 2, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15958 std::vector<uint32_t> const cps = { 0x0028, 0x0029, 0x005B, 0x2680, 0x0061, 0x05D0, 0x005D, 0x0062 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 1, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } } TEST(bidi_character, bidi_character_022_054) { { // line 15959 std::vector<uint32_t> const cps = { 0x0028, 0x0029, 0x005B, 0x2680, 0x0061, 0x05D0, 0x005D, 0x0062 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 2, 1, 1, 2 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15962 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0061, 0x05D0, 0x0029, 0x05D1, 0x005B, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 1, 0, 1, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15963 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0061, 0x05D0, 0x0029, 0x05D1, 0x005B, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 2, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15964 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0061, 0x05D0, 0x0029, 0x005B, 0x05D1, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 1, 0, 0, 1, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15965 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0061, 0x05D0, 0x0029, 0x005B, 0x05D1, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 2, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15966 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0061, 0x05D0, 0x0029, 0x005B, 0x005D, 0x05D1 }; std::vector<int> const expected_levels = { 0, 0, 0, 1, 0, 0, 0, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15967 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0061, 0x05D0, 0x0029, 0x005B, 0x005D, 0x05D1 }; std::vector<int> const expected_levels = { 1, 1, 2, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15968 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0061, 0x0029, 0x05D0, 0x005B, 0x05D1, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 7, 6, 5, 4 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15969 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0061, 0x0029, 0x05D0, 0x005B, 0x05D1, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 2, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15970 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0061, 0x0029, 0x05D0, 0x005B, 0x005D, 0x05D1 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 7, 6, 5, 4 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } } TEST(bidi_character, bidi_character_022_055) { { // line 15971 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0061, 0x0029, 0x05D0, 0x005B, 0x005D, 0x05D1 }; std::vector<int> const expected_levels = { 1, 1, 2, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15972 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0061, 0x0029, 0x005B, 0x05D0, 0x005D, 0x05D1 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 1, 0, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15973 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0061, 0x0029, 0x005B, 0x05D0, 0x005D, 0x05D1 }; std::vector<int> const expected_levels = { 1, 1, 2, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15974 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0029, 0x0061, 0x05D0, 0x005B, 0x05D1, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 7, 6, 5, 4 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15975 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0029, 0x0061, 0x05D0, 0x005B, 0x05D1, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 2, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15976 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0029, 0x0061, 0x05D0, 0x005B, 0x005D, 0x05D1 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 7, 6, 5, 4 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15977 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0029, 0x0061, 0x05D0, 0x005B, 0x005D, 0x05D1 }; std::vector<int> const expected_levels = { 1, 1, 1, 2, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15978 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0029, 0x0061, 0x005B, 0x05D0, 0x005D, 0x05D1 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 1, 0, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15979 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0029, 0x0061, 0x005B, 0x05D0, 0x005D, 0x05D1 }; std::vector<int> const expected_levels = { 1, 1, 1, 2, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15980 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0029, 0x005B, 0x0061, 0x05D0, 0x005D, 0x05D1 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 1, 0, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } } TEST(bidi_character, bidi_character_022_056) { { // line 15981 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0029, 0x005B, 0x0061, 0x05D0, 0x005D, 0x05D1 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 2, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15982 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0061, 0x05D0, 0x0029, 0x05D1, 0x005B, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 1, 0, 1, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15983 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0061, 0x05D0, 0x0029, 0x05D1, 0x005B, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 2, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15984 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0061, 0x05D0, 0x0029, 0x005B, 0x05D1, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 1, 0, 0, 1, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15985 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0061, 0x05D0, 0x0029, 0x005B, 0x05D1, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 2, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15986 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0061, 0x05D0, 0x0029, 0x005B, 0x005D, 0x05D1 }; std::vector<int> const expected_levels = { 0, 0, 0, 1, 0, 0, 0, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15987 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0061, 0x05D0, 0x0029, 0x005B, 0x005D, 0x05D1 }; std::vector<int> const expected_levels = { 1, 1, 2, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15988 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0061, 0x0029, 0x05D0, 0x005B, 0x05D1, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 7, 6, 5, 4 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15989 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0061, 0x0029, 0x05D0, 0x005B, 0x05D1, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 2, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15990 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0061, 0x0029, 0x05D0, 0x005B, 0x005D, 0x05D1 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 7, 6, 5, 4 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } } TEST(bidi_character, bidi_character_022_057) { { // line 15991 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0061, 0x0029, 0x05D0, 0x005B, 0x005D, 0x05D1 }; std::vector<int> const expected_levels = { 1, 1, 2, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15992 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0061, 0x0029, 0x005B, 0x05D0, 0x005D, 0x05D1 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 1, 0, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15993 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0061, 0x0029, 0x005B, 0x05D0, 0x005D, 0x05D1 }; std::vector<int> const expected_levels = { 1, 1, 2, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15994 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0029, 0x0061, 0x05D0, 0x005B, 0x05D1, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 7, 6, 5, 4 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15995 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0029, 0x0061, 0x05D0, 0x005B, 0x05D1, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 2, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15996 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0029, 0x0061, 0x05D0, 0x005B, 0x005D, 0x05D1 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 7, 6, 5, 4 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15997 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0029, 0x0061, 0x05D0, 0x005B, 0x005D, 0x05D1 }; std::vector<int> const expected_levels = { 1, 1, 1, 2, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15998 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0029, 0x0061, 0x005B, 0x05D0, 0x005D, 0x05D1 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 1, 0, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 15999 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0029, 0x0061, 0x005B, 0x05D0, 0x005D, 0x05D1 }; std::vector<int> const expected_levels = { 1, 1, 1, 2, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 16000 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0029, 0x005B, 0x0061, 0x05D0, 0x005D, 0x05D1 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 1, 0, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } } TEST(bidi_character, bidi_character_022_058) { { // line 16001 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0029, 0x005B, 0x0061, 0x05D0, 0x005D, 0x05D1 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 2, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 16002 std::vector<uint32_t> const cps = { 0x0028, 0x0029, 0x2680, 0x0061, 0x05D0, 0x005B, 0x05D1, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 7, 6, 5, 4 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 16003 std::vector<uint32_t> const cps = { 0x0028, 0x0029, 0x2680, 0x0061, 0x05D0, 0x005B, 0x05D1, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 2, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 16004 std::vector<uint32_t> const cps = { 0x0028, 0x0029, 0x2680, 0x0061, 0x05D0, 0x005B, 0x005D, 0x05D1 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 7, 6, 5, 4 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 16005 std::vector<uint32_t> const cps = { 0x0028, 0x0029, 0x2680, 0x0061, 0x05D0, 0x005B, 0x005D, 0x05D1 }; std::vector<int> const expected_levels = { 1, 1, 1, 2, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 16006 std::vector<uint32_t> const cps = { 0x0028, 0x0029, 0x2680, 0x0061, 0x005B, 0x05D0, 0x005D, 0x05D1 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 1, 0, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 16007 std::vector<uint32_t> const cps = { 0x0028, 0x0029, 0x2680, 0x0061, 0x005B, 0x05D0, 0x005D, 0x05D1 }; std::vector<int> const expected_levels = { 1, 1, 1, 2, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 16008 std::vector<uint32_t> const cps = { 0x0028, 0x0029, 0x2680, 0x005B, 0x0061, 0x05D0, 0x005D, 0x05D1 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 1, 0, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 16009 std::vector<uint32_t> const cps = { 0x0028, 0x0029, 0x2680, 0x005B, 0x0061, 0x05D0, 0x005D, 0x05D1 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 2, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 16010 std::vector<uint32_t> const cps = { 0x0028, 0x0029, 0x005B, 0x2680, 0x0061, 0x05D0, 0x005D, 0x05D1 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 1, 0, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } } TEST(bidi_character, bidi_character_022_059) { { // line 16011 std::vector<uint32_t> const cps = { 0x0028, 0x0029, 0x005B, 0x2680, 0x0061, 0x05D0, 0x005D, 0x05D1 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 2, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 16014 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x05D0, 0x2681, 0x0029, 0x2682, 0x005B, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 1, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 16015 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x05D0, 0x2681, 0x0029, 0x2682, 0x005B, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 16016 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x05D0, 0x2681, 0x0029, 0x005B, 0x2682, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 1, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 16017 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x05D0, 0x2681, 0x0029, 0x005B, 0x2682, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 16018 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x05D0, 0x2681, 0x0029, 0x005B, 0x005D, 0x2682 }; std::vector<int> const expected_levels = { 0, 0, 1, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 16019 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x05D0, 0x2681, 0x0029, 0x005B, 0x005D, 0x2682 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 16020 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x05D0, 0x0029, 0x2681, 0x005B, 0x2682, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 1, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 16021 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x05D0, 0x0029, 0x2681, 0x005B, 0x2682, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 16022 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x05D0, 0x0029, 0x2681, 0x005B, 0x005D, 0x2682 }; std::vector<int> const expected_levels = { 0, 0, 1, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } } TEST(bidi_character, bidi_character_022_060) { { // line 16023 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x05D0, 0x0029, 0x2681, 0x005B, 0x005D, 0x2682 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 16024 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x05D0, 0x0029, 0x005B, 0x2681, 0x005D, 0x2682 }; std::vector<int> const expected_levels = { 0, 0, 1, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 16025 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x05D0, 0x0029, 0x005B, 0x2681, 0x005D, 0x2682 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 16026 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0029, 0x05D0, 0x2681, 0x005B, 0x2682, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 1, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 16027 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0029, 0x05D0, 0x2681, 0x005B, 0x2682, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 16028 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0029, 0x05D0, 0x2681, 0x005B, 0x005D, 0x2682 }; std::vector<int> const expected_levels = { 0, 0, 0, 1, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 16029 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0029, 0x05D0, 0x2681, 0x005B, 0x005D, 0x2682 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 16030 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0029, 0x05D0, 0x005B, 0x2681, 0x005D, 0x2682 }; std::vector<int> const expected_levels = { 0, 0, 0, 1, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 16031 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0029, 0x05D0, 0x005B, 0x2681, 0x005D, 0x2682 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 16032 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0029, 0x005B, 0x05D0, 0x2681, 0x005D, 0x2682 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 1, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } } TEST(bidi_character, bidi_character_022_061) { { // line 16033 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0029, 0x005B, 0x05D0, 0x2681, 0x005D, 0x2682 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 16034 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x05D0, 0x2681, 0x0029, 0x2682, 0x005B, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 1, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 16035 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x05D0, 0x2681, 0x0029, 0x2682, 0x005B, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 16036 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x05D0, 0x2681, 0x0029, 0x005B, 0x2682, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 1, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 16037 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x05D0, 0x2681, 0x0029, 0x005B, 0x2682, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 16038 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x05D0, 0x2681, 0x0029, 0x005B, 0x005D, 0x2682 }; std::vector<int> const expected_levels = { 0, 0, 1, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 16039 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x05D0, 0x2681, 0x0029, 0x005B, 0x005D, 0x2682 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 16040 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x05D0, 0x0029, 0x2681, 0x005B, 0x2682, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 1, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 16041 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x05D0, 0x0029, 0x2681, 0x005B, 0x2682, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 16042 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x05D0, 0x0029, 0x2681, 0x005B, 0x005D, 0x2682 }; std::vector<int> const expected_levels = { 0, 0, 1, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } } TEST(bidi_character, bidi_character_022_062) { { // line 16043 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x05D0, 0x0029, 0x2681, 0x005B, 0x005D, 0x2682 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 16044 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x05D0, 0x0029, 0x005B, 0x2681, 0x005D, 0x2682 }; std::vector<int> const expected_levels = { 0, 0, 1, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 16045 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x05D0, 0x0029, 0x005B, 0x2681, 0x005D, 0x2682 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 16046 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0029, 0x05D0, 0x2681, 0x005B, 0x2682, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 1, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 16047 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0029, 0x05D0, 0x2681, 0x005B, 0x2682, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 16048 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0029, 0x05D0, 0x2681, 0x005B, 0x005D, 0x2682 }; std::vector<int> const expected_levels = { 0, 0, 0, 1, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 16049 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0029, 0x05D0, 0x2681, 0x005B, 0x005D, 0x2682 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 16050 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0029, 0x05D0, 0x005B, 0x2681, 0x005D, 0x2682 }; std::vector<int> const expected_levels = { 0, 0, 0, 1, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 16051 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0029, 0x05D0, 0x005B, 0x2681, 0x005D, 0x2682 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 16052 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0029, 0x005B, 0x05D0, 0x2681, 0x005D, 0x2682 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 1, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } } TEST(bidi_character, bidi_character_022_063) { { // line 16053 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0029, 0x005B, 0x05D0, 0x2681, 0x005D, 0x2682 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 16054 std::vector<uint32_t> const cps = { 0x0028, 0x0029, 0x2680, 0x05D0, 0x2681, 0x005B, 0x2682, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 1, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 16055 std::vector<uint32_t> const cps = { 0x0028, 0x0029, 0x2680, 0x05D0, 0x2681, 0x005B, 0x2682, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 16056 std::vector<uint32_t> const cps = { 0x0028, 0x0029, 0x2680, 0x05D0, 0x2681, 0x005B, 0x005D, 0x2682 }; std::vector<int> const expected_levels = { 0, 0, 0, 1, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 16057 std::vector<uint32_t> const cps = { 0x0028, 0x0029, 0x2680, 0x05D0, 0x2681, 0x005B, 0x005D, 0x2682 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 16058 std::vector<uint32_t> const cps = { 0x0028, 0x0029, 0x2680, 0x05D0, 0x005B, 0x2681, 0x005D, 0x2682 }; std::vector<int> const expected_levels = { 0, 0, 0, 1, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 16059 std::vector<uint32_t> const cps = { 0x0028, 0x0029, 0x2680, 0x05D0, 0x005B, 0x2681, 0x005D, 0x2682 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 16060 std::vector<uint32_t> const cps = { 0x0028, 0x0029, 0x2680, 0x005B, 0x05D0, 0x2681, 0x005D, 0x2682 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 1, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 16061 std::vector<uint32_t> const cps = { 0x0028, 0x0029, 0x2680, 0x005B, 0x05D0, 0x2681, 0x005D, 0x2682 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 16062 std::vector<uint32_t> const cps = { 0x0028, 0x0029, 0x005B, 0x2680, 0x05D0, 0x2681, 0x005D, 0x2682 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 1, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } } TEST(bidi_character, bidi_character_022_064) { { // line 16063 std::vector<uint32_t> const cps = { 0x0028, 0x0029, 0x005B, 0x2680, 0x05D0, 0x2681, 0x005D, 0x2682 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 16066 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x05D0, 0x2681, 0x0061, 0x0029, 0x005B, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 1, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 16067 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x05D0, 0x2681, 0x0061, 0x0029, 0x005B, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 2, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 16068 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x05D0, 0x2681, 0x0029, 0x0061, 0x005B, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 1, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 16069 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x05D0, 0x2681, 0x0029, 0x0061, 0x005B, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 2, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 16070 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x05D0, 0x2681, 0x0029, 0x005B, 0x0061, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 1, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 16071 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x05D0, 0x2681, 0x0029, 0x005B, 0x0061, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 2, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 16072 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x05D0, 0x2681, 0x0029, 0x005B, 0x005D, 0x0061 }; std::vector<int> const expected_levels = { 0, 0, 1, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 16073 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x05D0, 0x2681, 0x0029, 0x005B, 0x005D, 0x0061 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 1, 2 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 16074 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x05D0, 0x0029, 0x2681, 0x0061, 0x005B, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 1, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } } TEST(bidi_character, bidi_character_022_065) { { // line 16075 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x05D0, 0x0029, 0x2681, 0x0061, 0x005B, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 2, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 16076 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x05D0, 0x0029, 0x2681, 0x005B, 0x0061, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 1, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 16077 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x05D0, 0x0029, 0x2681, 0x005B, 0x0061, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 2, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 16078 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x05D0, 0x0029, 0x2681, 0x005B, 0x005D, 0x0061 }; std::vector<int> const expected_levels = { 0, 0, 1, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 16079 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x05D0, 0x0029, 0x2681, 0x005B, 0x005D, 0x0061 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 1, 2 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 16080 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x05D0, 0x0029, 0x005B, 0x2681, 0x0061, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 1, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 16081 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x05D0, 0x0029, 0x005B, 0x2681, 0x0061, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 2, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 16082 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x05D0, 0x0029, 0x005B, 0x2681, 0x005D, 0x0061 }; std::vector<int> const expected_levels = { 0, 0, 1, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 16083 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x05D0, 0x0029, 0x005B, 0x2681, 0x005D, 0x0061 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 1, 2 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 16084 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x05D0, 0x0029, 0x005B, 0x005D, 0x2681, 0x0061 }; std::vector<int> const expected_levels = { 0, 0, 1, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } } TEST(bidi_character, bidi_character_022_066) { { // line 16085 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x05D0, 0x0029, 0x005B, 0x005D, 0x2681, 0x0061 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 1, 2 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 16086 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0029, 0x05D0, 0x2681, 0x0061, 0x005B, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 1, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 16087 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0029, 0x05D0, 0x2681, 0x0061, 0x005B, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 2, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 16088 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0029, 0x05D0, 0x2681, 0x005B, 0x0061, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 1, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 16089 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0029, 0x05D0, 0x2681, 0x005B, 0x0061, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 2, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 16090 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0029, 0x05D0, 0x2681, 0x005B, 0x005D, 0x0061 }; std::vector<int> const expected_levels = { 0, 0, 0, 1, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 16091 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0029, 0x05D0, 0x2681, 0x005B, 0x005D, 0x0061 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 1, 2 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 16092 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0029, 0x05D0, 0x005B, 0x2681, 0x0061, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 1, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 16093 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0029, 0x05D0, 0x005B, 0x2681, 0x0061, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 2, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 16094 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0029, 0x05D0, 0x005B, 0x2681, 0x005D, 0x0061 }; std::vector<int> const expected_levels = { 0, 0, 0, 1, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } } TEST(bidi_character, bidi_character_022_067) { { // line 16095 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0029, 0x05D0, 0x005B, 0x2681, 0x005D, 0x0061 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 1, 2 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 16096 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0029, 0x05D0, 0x005B, 0x005D, 0x2681, 0x0061 }; std::vector<int> const expected_levels = { 0, 0, 0, 1, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 16097 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0029, 0x05D0, 0x005B, 0x005D, 0x2681, 0x0061 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 1, 2 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 16098 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0029, 0x005B, 0x05D0, 0x2681, 0x0061, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 1, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 16099 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0029, 0x005B, 0x05D0, 0x2681, 0x0061, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 2, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 16100 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0029, 0x005B, 0x05D0, 0x2681, 0x005D, 0x0061 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 1, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } }
33.71444
109
0.439169
eightysquirrels
0ea9f4977b18998a9f7903fbc5e90955cc00012c
9,702
cpp
C++
StateMachine/src/GroupDFA.cpp
krystianAndrzejewski/regular_expression
b49a7e0eb0d9ec8e34db3dbd8701d5b186c59784
[ "MIT" ]
null
null
null
StateMachine/src/GroupDFA.cpp
krystianAndrzejewski/regular_expression
b49a7e0eb0d9ec8e34db3dbd8701d5b186c59784
[ "MIT" ]
null
null
null
StateMachine/src/GroupDFA.cpp
krystianAndrzejewski/regular_expression
b49a7e0eb0d9ec8e34db3dbd8701d5b186c59784
[ "MIT" ]
null
null
null
#include "GroupDFA.h" #include "NFA.h" #include <stack> #include <queue> #include <sstream> #include <algorithm> #include <iterator> GroupDFA::GroupDFA() { } GroupDFA::~GroupDFA() { for (auto state : states) { delete state; } } void GroupDFA::createFromInitialDFA(const InitialDFA& initialDfa, RegularDFA &intvertedRegularDfa) { NFA nfa; nfa.createFromInitialDfa(initialDfa); intvertedRegularDfa.createFromBackwardInitialNfa(nfa); finalState = initialDfa.getFinalState(); std::size_t size = initialDfa.getSize(); std::size_t i = 0; states.resize(size + 1); initialState = size; finalState = initialDfa.getFinalState(); createGroupDfa(initialDfa, intvertedRegularDfa); } void GroupDFA::createGroupDfa(const InitialDFA& initialDfa, RegularDFA &regualarDfa) { initialDfa.getGroups(groupsMap); std::size_t size = initialDfa.getSize(); std::stack<std::size_t> statesStack; std::queue<std::size_t> mainQueue; State::StateType type; statesStack.push(initialDfa.getStartState(type)); auto mapConnectedStates = regualarDfa.getMapConectedNFAStates(); for (auto finalState : regualarDfa.getFinalStates()) { std::set<std::size_t> connectedStates; regualarDfa.returnNFAStates(finalState, connectedStates); mapConnectedStates[size].insert(std::set<std::size_t>(connectedStates.begin(), connectedStates.end())); } std::size_t actualState = initialState; std::size_t processedState = size; states[processedState] = new GroupState(); mapStates[states[processedState]] = actualState; std::stack<std::size_t> removingGroup; std::vector<std::size_t> group; std::vector<bool> flags; flags.resize(states.size()); do { std::unordered_map<char, std::pair<std::size_t, State::StateType>> nextStates; if (!statesStack.empty()) { actualState = statesStack.top(); statesStack.pop(); initialDfa.returnMovePossibility(actualState, nextStates); initialDfa.getType(actualState, type); while (!removingGroup.empty() && removingGroup.top() > statesStack.size()) { removingGroup.pop(); group.pop_back(); } if ((type == State::Entry || type == State::Exit) && finalState != actualState) { removingGroup.push(statesStack.size()); } } else { processedState = mainQueue.front(); if (states[processedState] == nullptr) { states[processedState] = new GroupState(); mapStates[states[processedState]] = processedState; initialState = processedState; } mainQueue.pop(); actualState = processedState; initialDfa.returnMovePossibility(processedState, nextStates); for (auto nextState : nextStates) { statesStack.push(nextState.second.first); } group.clear(); flags.clear(); flags.resize(states.size()); continue; } const auto &nextGroupsStates = states[processedState]->getNextStates(); if (finalState == actualState && !flags[actualState]) { if (states[actualState] == nullptr) { states[actualState] = new GroupState(); mapStates[states[actualState]] = actualState; mainQueue.push(actualState); } for (auto connectedStates : mapConnectedStates[actualState]) { if (nextGroupsStates.find(connectedStates) == nextGroupsStates.end()) { states[processedState]->addNextState(connectedStates, states[actualState], group); } } } else if (!flags[actualState]) { switch (type) { case State::Priority: statesStack.push(nextStates['-'].first); statesStack.push(nextStates['+'].first); break; case State::Deterministic: if (states[actualState] == nullptr) { states[actualState] = new GroupState(); mapStates[states[actualState]] = actualState; mainQueue.push(actualState); } for (auto connectedStates : mapConnectedStates[actualState]) { if (nextGroupsStates.find(connectedStates) == nextGroupsStates.end()) { states[processedState]->addNextState(connectedStates, states[actualState], group); } } break; case State::Entry: group.push_back(groupsMap[actualState]); statesStack.push(nextStates[' '].first); break; case State::Exit: group.push_back(groupsMap[actualState]); statesStack.push(nextStates[' '].first); break; default: break; } } flags[actualState] = true; } while (!(mainQueue.empty() && statesStack.empty())); } void GroupDFA::print(std::string &output) const { std::size_t i = 0; std::stringstream stream; std::string intend = " "; std::size_t size = std::count_if(states.begin(), states.end(), [](GroupState* value){ return value != nullptr; }); stream << "The group deterministic finite automata has " << size << " states.\n\n"; stream << "Initial state: " << initialState << "\n\n"; stream << "Final state: " << finalState << "\n\n"; for (auto state : states) { if (state) { stream << i << ". state:\n"; auto nextStates = state->getNextStates(); auto previousStates = state->getPreviousStates(); stream << "\n"; if (!nextStates.empty()) { stream << intend << "Next states:\n"; for (auto partOfNextState : nextStates) { stream << intend << intend << "[ "; for (auto state : partOfNextState.first) { stream << state << ", "; } stream << "] -> { "; stream << mapStates.at(partOfNextState.second.first) << " : "; size = static_cast<std::size_t>(groupsMap.size() / 2) ; for (auto group : partOfNextState.second.second) { if (size > group) { stream << "S" << group << ", "; } else { stream << "M" << group - size << ", "; } } stream << "}\n"; } } if (!previousStates.empty()) { stream << intend << "Previous states:\n"; for (auto partOfPreviousStates : previousStates) { stream << intend << intend << "[ "; for (auto state : partOfPreviousStates.first) { stream << state << ", "; } stream << "] -> "; for (auto previousState : partOfPreviousStates.second) { stream << "{ " << mapStates.at(previousState.first) << " : "; size = static_cast<std::size_t>(groupsMap.size() / 2); for (auto group : previousState.second) { if (size > group) { stream << "S" << group << ", "; } else { stream << "M" << group - size << ", "; } } stream << "}, "; } stream << "\n"; } } stream << "\n"; } i++; } stream << "\n"; output += stream.str(); } void GroupDFA::returnMovePossibility( const std::size_t &number, std::map<const std::set<std::size_t>, std::size_t> &pNextStates, std::vector<std::size_t> &groupNumbers) const { pNextStates.clear(); groupNumbers.clear(); if (number < states.size()) { for (auto state : states[number]->getNextStates()) { pNextStates[state.first] = mapStates.at(state.second.first); std::copy(state.second.second.begin(), state.second.second.end(), std::back_inserter(groupNumbers)); } } } bool GroupDFA::returnNextState( const std::set<std::size_t> &action, std::size_t &nextStateNumber, std::vector<std::size_t> &groupNumbers) { groupNumbers.clear(); auto nextStates = states[actualState]->getNextStates(); if (!nextStates.empty() && nextStates.find(action) != nextStates.end()) { nextStateNumber = mapStates[nextStates[action].first]; actualState = nextStateNumber; std::copy(nextStates[action].second.begin(), nextStates[action].second.end(), std::back_inserter(groupNumbers)); return true; } else { return false; } }
35.28
118
0.502989
krystianAndrzejewski
0eaac8587a2e1ccf18405c65346aa5e87754d22d
1,370
hpp
C++
socket/tcp_socket.hpp
xqq/drawboard
993f0f90c127c51ad5837656fc1383b2d9e7ddde
[ "MIT" ]
10
2020-01-18T09:28:47.000Z
2020-04-28T15:37:42.000Z
socket/tcp_socket.hpp
xqq/drawboard
993f0f90c127c51ad5837656fc1383b2d9e7ddde
[ "MIT" ]
1
2020-04-28T15:29:52.000Z
2020-04-28T15:35:03.000Z
socket/tcp_socket.hpp
xqq/drawboard
993f0f90c127c51ad5837656fc1383b2d9e7ddde
[ "MIT" ]
2
2020-01-20T06:54:26.000Z
2022-01-11T09:01:42.000Z
// // @author magicxqq <xqq@xqq.im> // #ifndef DRAWBOARD_TCP_SOCKET_HPP #define DRAWBOARD_TCP_SOCKET_HPP #include <string> #include <functional> #include "common/noncopyable.hpp" struct sockaddr_in; class ReadWriteBuffer; class TcpSocket : public Noncopyable { public: using OnConnectedCallback = std::function<void(TcpSocket* socket)>; using OnDisconnectCallback = std::function<void(TcpSocket* socket)>; using OnDataArrivalCallback = std::function<void(TcpSocket* socket, ReadWriteBuffer* buffer, size_t nread)>; using OnErrorCallback = std::function<void(TcpSocket* socket, const std::string& msg)>; public: static TcpSocket* Create(); public: explicit TcpSocket() : user_data_(nullptr) {} virtual ~TcpSocket() {} virtual void SetCallback(OnConnectedCallback on_connect, OnDisconnectCallback on_disconnect, OnDataArrivalCallback on_arrival, OnErrorCallback on_error) = 0; virtual bool Connect(std::string connect_addr, uint16_t port) = 0; virtual bool Send(const uint8_t* buffer, size_t length) = 0; virtual bool Shutdown() = 0; void SetUserData(void* data) { user_data_ = data; } void* GetUserData() { return user_data_; } protected: void* user_data_; }; #endif // DRAWBOARD_TCP_SOCKET_HPP
28.541667
112
0.683942
xqq
0eab754810dc17bd1e95ba081e9ff469a0a04b21
630
cpp
C++
ilya_and_queries.cpp
Delfad0r/CompetitiveProgrammingCourse
a986045372138f550e38f6262933ed34f7a57d77
[ "Apache-2.0" ]
null
null
null
ilya_and_queries.cpp
Delfad0r/CompetitiveProgrammingCourse
a986045372138f550e38f6262933ed34f7a57d77
[ "Apache-2.0" ]
null
null
null
ilya_and_queries.cpp
Delfad0r/CompetitiveProgrammingCourse
a986045372138f550e38f6262933ed34f7a57d77
[ "Apache-2.0" ]
null
null
null
/* We build a binary array containing 1 at position n when S[n]==S[n-1], and then compute prefix sums. Then answering the queries is trivial. Time complexity: O(N) Space complexity: O(N) */ #include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); string S; cin >> S; int N = S.length(); vector<int> P(N, 0); for(int n = 1; n < N; ++n) { P[n] = (S[n] == S[n - 1]) + P[n - 1]; } int M; cin >> M; while(M--) { int l, r; cin >> l >> r; cout << (P[r - 1] - P[l - 1]) << '\n'; } }
19.090909
69
0.495238
Delfad0r
0eae0cf7b092d48af1e0f8dc624bd5bb0f1a94a3
650
cpp
C++
Engine/Firework.cpp
AleixBueso/Engine-Project-v.2
6838b18dd508d0404688c5a360706a49acb6c6ac
[ "Apache-2.0" ]
null
null
null
Engine/Firework.cpp
AleixBueso/Engine-Project-v.2
6838b18dd508d0404688c5a360706a49acb6c6ac
[ "Apache-2.0" ]
null
null
null
Engine/Firework.cpp
AleixBueso/Engine-Project-v.2
6838b18dd508d0404688c5a360706a49acb6c6ac
[ "Apache-2.0" ]
null
null
null
#include "Firework.h" #include "Globals.h" #include "OpenGL.h" #include "Application.h" #include "ModuleGOmanager.h" #include "Particle Emitter.h" Firework::Firework() { }; Firework::~Firework() { }; void Firework::CreateFirework() { Particle_Emitter* tmp = new Particle_Emitter(nullptr, true); firework_emitters.push_back(tmp); tmp->gravity[1] = 8 + static_cast <float> (rand()) / (static_cast <float> (RAND_MAX / (8 - 15))); } void Firework::Update(const float3& point, const float3& _up) { for (std::list<Particle_Emitter*>::iterator it = firework_emitters.begin(); it != firework_emitters.end(); it++) (*it)->UpdateNow(point, _up); }
21.666667
113
0.698462
AleixBueso
0eaea8ccaeba5c0b9d1e5fd838e3070230958c47
6,754
hpp
C++
code/vpp/include/vppSampler.hpp
maikebing/vpp
efa6c32f898e103d749764ce3a0b7dc29d6e9a51
[ "BSD-2-Clause" ]
null
null
null
code/vpp/include/vppSampler.hpp
maikebing/vpp
efa6c32f898e103d749764ce3a0b7dc29d6e9a51
[ "BSD-2-Clause" ]
null
null
null
code/vpp/include/vppSampler.hpp
maikebing/vpp
efa6c32f898e103d749764ce3a0b7dc29d6e9a51
[ "BSD-2-Clause" ]
null
null
null
/* Copyright 2016-2019 SOFT-ERG, Przemek Kuczmierczyk (www.softerg.com) All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 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. 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. */ #ifndef INC_VPPSAMPLER_HPP #define INC_VPPSAMPLER_HPP // ----------------------------------------------------------------------------- #ifndef INC_VPPDEVICE_HPP #include "vppDevice.hpp" #endif // ----------------------------------------------------------------------------- namespace vpp { // ----------------------------------------------------------------------------- struct SNormalizedSampler { VPP_DLLAPI SNormalizedSampler ( float maxLod = 1.0f ); VPP_DLLAPI bool operator< ( const SNormalizedSampler& rhs ) const; unsigned int addressModeU : 3; unsigned int addressModeV : 3; unsigned int addressModeW : 3; unsigned int borderColor : 3; unsigned int compareOp : 3; unsigned int compare : 1; unsigned int magFilterMode : 2; unsigned int minFilterMode : 2; unsigned int mipMapMode : 2; unsigned int anisotropy : 1; float mipLodBias; float maxAnisotropy; float minLod; float maxLod; }; // ----------------------------------------------------------------------------- struct SUnnormalizedSampler { /* minFilter and magFilter must be equal. mipmapMode must be VK_SAMPLER_MIPMAP_MODE_NEAREST. minLod and maxLod must be zero. addressModeU and addressModeV must each be either VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE or VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER. anisotropyEnable must be VK_FALSE. compareEnable must be VK_FALSE. */ VPP_DLLAPI SUnnormalizedSampler(); VPP_DLLAPI bool operator< ( const SUnnormalizedSampler& rhs ) const; unsigned int clampToBorderU : 1; unsigned int clampToBorderV : 1; unsigned int filterMode : 2; unsigned int borderColor : 3; float mipLodBias; }; // ----------------------------------------------------------------------------- // ----------------------------------------------------------------------------- class SamplerImpl; // ----------------------------------------------------------------------------- class Sampler : public TSharedReference< SamplerImpl > { public: Sampler(); Sampler ( const Device& hDevice, const SNormalizedSampler& samplerInfo ); Sampler ( const Device& hDevice, const SUnnormalizedSampler& samplerInfo ); ~Sampler(); static const bool isUnnormalized = false; VkSampler handle() const; }; // ----------------------------------------------------------------------------- class SamplerImpl : public TSharedObject< SamplerImpl > { public: VPP_DLLAPI SamplerImpl ( const Device& hDevice, const SNormalizedSampler& samplerInfo ); VPP_DLLAPI SamplerImpl ( const Device& hDevice, const SUnnormalizedSampler& samplerInfo ); VPP_DLLAPI ~SamplerImpl(); bool compareObjects ( const SamplerImpl* pRHS ) const; private: friend class Sampler; Device d_hDevice; VkSampler d_handle; VkResult d_result; }; // ----------------------------------------------------------------------------- VPP_INLINE bool SamplerImpl :: compareObjects ( const SamplerImpl* pRHS ) const { return this < pRHS; } // ----------------------------------------------------------------------------- VPP_INLINE Sampler :: Sampler() { } // ----------------------------------------------------------------------------- VPP_INLINE Sampler :: Sampler ( const Device& hDevice, const SNormalizedSampler& samplerInfo ) : TSharedReference< SamplerImpl > ( new SamplerImpl ( hDevice, samplerInfo ) ) { } // ----------------------------------------------------------------------------- VPP_INLINE Sampler :: Sampler ( const Device& hDevice, const SUnnormalizedSampler& samplerInfo ) : TSharedReference< SamplerImpl > ( new SamplerImpl ( hDevice, samplerInfo ) ) { } // ----------------------------------------------------------------------------- VPP_INLINE Sampler :: ~Sampler() { } // ----------------------------------------------------------------------------- VPP_INLINE VkSampler Sampler :: handle() const { return get()->d_handle; } // ----------------------------------------------------------------------------- // ----------------------------------------------------------------------------- class NormalizedSampler : public Sampler { public: VPP_INLINE NormalizedSampler() { } VPP_INLINE NormalizedSampler ( const Device& hDevice, const SNormalizedSampler& samplerInfo = SNormalizedSampler() ) : Sampler ( hDevice, samplerInfo ) {} static const bool isUnnormalized = false; }; // ----------------------------------------------------------------------------- class UnnormalizedSampler : public Sampler { public: VPP_INLINE UnnormalizedSampler() { } VPP_INLINE UnnormalizedSampler ( const Device& hDevice, const SUnnormalizedSampler& samplerInfo = SUnnormalizedSampler() ) : Sampler ( hDevice, samplerInfo ) {} static const bool isUnnormalized = true; }; // ----------------------------------------------------------------------------- } // namespace vpp // ----------------------------------------------------------------------------- #endif // INC_VPPSAMPLER_HPP
32.946341
140
0.5382
maikebing
0eb30d66785902c6e5e4fdb724e2eeb15cacca07
3,474
cpp
C++
Shiny_Engine/ResourcesMesh.cpp
AleixCas95/Shiny_Engine
a5dca52725ed20c11f929a581e1b442988ec3237
[ "MIT" ]
null
null
null
Shiny_Engine/ResourcesMesh.cpp
AleixCas95/Shiny_Engine
a5dca52725ed20c11f929a581e1b442988ec3237
[ "MIT" ]
null
null
null
Shiny_Engine/ResourcesMesh.cpp
AleixCas95/Shiny_Engine
a5dca52725ed20c11f929a581e1b442988ec3237
[ "MIT" ]
null
null
null
#include "Application.h" #include "ResourcesMesh.h" #include "ModuleFBX.h" #include "Glew/include/glew.h" #include <gl/GL.h> ResourceMesh::ResourceMesh(scriptType uuid) : Resource(uuid, ResourceType::Mesh) { } ResourceMesh::~ResourceMesh() { if (loaded > 0) UnloadInMemory(); //TODO!!! } bool ResourceMesh::LoadInMemory() { if (!IsPrimitive()) { string path = std::to_string(uuid) + "." + "stdtmesh"; App->fbx->LoadMesh(path.c_str(), this); //Bind buffers BindBuffers(); } else { switch (is_primitive) { case PRIMITIVE_CUBE: { par_shapes_mesh* cube = par_shapes_create_cube(); LoadMeshPrimitive(cube); par_shapes_free_mesh(cube); } break; case PRIMITIVE_SPHERE: { par_shapes_mesh* sphere = par_shapes_create_subdivided_sphere(3); LoadMeshPrimitive(sphere); par_shapes_free_mesh(sphere); } break; case PRIMITIVE_PLANE: { par_shapes_mesh* plane = par_shapes_create_plane(5, 5); LoadMeshPrimitive(plane); par_shapes_free_mesh(plane); } break; } BindBuffersPrimitive(); } return true; } bool ResourceMesh::UnloadInMemory() { glDeleteBuffers(1, (GLuint*) & (id_index)); glDeleteBuffers(1, (GLuint*) & (id_vertex)); if (normal) glDeleteBuffers(1, (GLuint*) & (id_normal)); if (uv) glDeleteBuffers(1, (GLuint*) & (id_uv)); RELEASE_ARRAY(index_); RELEASE_ARRAY(vertex_); RELEASE_ARRAY(normal); RELEASE_ARRAY(uv); return true; } void ResourceMesh::LoadMeshPrimitive(par_shapes_mesh* shape) { num_vertex = (uint)shape->npoints; vertex_ = new float[num_vertex * 3]; memcpy(vertex_, shape->points, sizeof(float) * num_vertex * 3); num_index = (uint)shape->ntriangles; index_ = new uint[num_index * 3]; memcpy(index_, shape->triangles, sizeof(PAR_SHAPES_T) * num_index * 3); } void ResourceMesh::BindBuffers() { if (index_ != nullptr && vertex_ != nullptr) { //Vertex glGenBuffers(1, (GLuint*) & (id_vertex)); glBindBuffer(GL_ARRAY_BUFFER, id_vertex); glBufferData(GL_ARRAY_BUFFER, sizeof(float) * 3 * num_vertex, vertex_, GL_STATIC_DRAW); glBindBuffer(GL_ARRAY_BUFFER, 0); //Index glGenBuffers(1, (GLuint*) & (id_index)); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, id_index); glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(uint) * num_index, index_, GL_STATIC_DRAW); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); //Normal if (normal != nullptr) { glGenBuffers(1, (GLuint*) & (id_normal)); glBindBuffer(GL_ARRAY_BUFFER, id_normal); glBufferData(GL_ARRAY_BUFFER, sizeof(float) * 3 * num_normal, normal, GL_STATIC_DRAW); glBindBuffer(GL_ARRAY_BUFFER, 0); } //Texture coordinates if (uv != nullptr) { glGenBuffers(1, (GLuint*) & (id_uv)); glBindBuffer(GL_ARRAY_BUFFER, id_uv); glBufferData(GL_ARRAY_BUFFER, sizeof(float) * 2 * num_uv, uv, GL_STATIC_DRAW); glBindBuffer(GL_ARRAY_BUFFER, 0); } } } void ResourceMesh::BindBuffersPrimitive() { //Vertex glGenBuffers(1, (GLuint*) & (id_vertex)); glBindBuffer(GL_ARRAY_BUFFER, id_vertex); glBufferData(GL_ARRAY_BUFFER, sizeof(float) * 3 * num_vertex, vertex_, GL_STATIC_DRAW); glBindBuffer(GL_ARRAY_BUFFER, 0); //Index glGenBuffers(1, (GLuint*) & (id_index)); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, id_index); glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(PAR_SHAPES_T) * 3 * num_index, index_, GL_STATIC_DRAW); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); } bool ResourceMesh::IsPrimitive() const { if (is_primitive == PRIMITIVE_NONE) return false; return true; }
24.992806
101
0.715314
AleixCas95
0eb77d07718e37ad232d72354ccebf3d61e17068
1,043
cpp
C++
source/oc/ocMain.cpp
mackron/openchernobyl
47c854ce37e1c361b184e29a59e4881a6faa387c
[ "BSD-3-Clause" ]
2
2021-05-24T21:18:13.000Z
2021-12-20T07:21:20.000Z
source/oc/ocMain.cpp
openchernobyl/openchernobyl
47c854ce37e1c361b184e29a59e4881a6faa387c
[ "BSD-3-Clause" ]
null
null
null
source/oc/ocMain.cpp
openchernobyl/openchernobyl
47c854ce37e1c361b184e29a59e4881a6faa387c
[ "BSD-3-Clause" ]
null
null
null
// Copyright (C) 2018 David Reid. See included LICENSE file. // This is main source file for the entire game, and is the only file that needs to be compiled (not including dependencies). #include "ocGame/ocGame.cpp" int ocMain(int argc, char** argv) { (void)argc; (void)argv; // The first thing to do on the Windows build is disable DPI scaling. Not doing this will result in problems with // the resolution of the game due to the operating system automatically scaling the window. #ifdef OC_WIN32 ocMakeDPIAware_Win32(); #endif return ocInitAndRun(argc, argv); // <-- Implemented in ocGame.cpp } int main(int argc, char** argv) { return ocMain(argc, argv); } #if defined(OC_WIN32) int CALLBACK WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { (void)hInstance; (void)hPrevInstance; (void)nCmdShow; char** argv; int argc = ocWinMainToArgv(lpCmdLine, &argv); int result = ocMain(argc, argv); ocFreeArgv(argv); return result; } #endif
24.833333
125
0.703739
mackron
0eb907efa2a1697d173674628b15cd564f9884c9
18,604
cpp
C++
bulletgba/generator/data/code/kotuanzenx/bb04-r7.cpp
pqrs-org/BulletGBA
a294007902970242b496f2528b4762cfef22bc86
[ "Unlicense" ]
5
2020-03-24T07:44:49.000Z
2021-08-30T14:43:31.000Z
bulletgba/generator/data/code/kotuanzenx/bb04-r7.cpp
pqrs-org/BulletGBA
a294007902970242b496f2528b4762cfef22bc86
[ "Unlicense" ]
null
null
null
bulletgba/generator/data/code/kotuanzenx/bb04-r7.cpp
pqrs-org/BulletGBA
a294007902970242b496f2528b4762cfef22bc86
[ "Unlicense" ]
null
null
null
// XXX uniqID XXX 6dfd0e0d2b04618ffe2fdb6da6d4df76 XXX #include <gba_types.h> #include "bullet.hpp" #include "fixed.hpp" #include "kotuanzenx/bb04-r7.hpp" extern const BulletStepFunc bullet_f1f3d5f55c5d318a36d3fbde506fd1af_6dfd0e0d2b04618ffe2fdb6da6d4df76[] = { stepfunc_05798bae9c12d6be89270ea1e2488f81_6dfd0e0d2b04618ffe2fdb6da6d4df76, stepfunc_774d9b10b28042acc8404fd0cd55908b_6dfd0e0d2b04618ffe2fdb6da6d4df76, stepfunc_774d9b10b28042acc8404fd0cd55908b_6dfd0e0d2b04618ffe2fdb6da6d4df76, stepfunc_774d9b10b28042acc8404fd0cd55908b_6dfd0e0d2b04618ffe2fdb6da6d4df76, stepfunc_774d9b10b28042acc8404fd0cd55908b_6dfd0e0d2b04618ffe2fdb6da6d4df76, stepfunc_774d9b10b28042acc8404fd0cd55908b_6dfd0e0d2b04618ffe2fdb6da6d4df76, stepfunc_774d9b10b28042acc8404fd0cd55908b_6dfd0e0d2b04618ffe2fdb6da6d4df76, stepfunc_774d9b10b28042acc8404fd0cd55908b_6dfd0e0d2b04618ffe2fdb6da6d4df76, stepfunc_774d9b10b28042acc8404fd0cd55908b_6dfd0e0d2b04618ffe2fdb6da6d4df76, stepfunc_774d9b10b28042acc8404fd0cd55908b_6dfd0e0d2b04618ffe2fdb6da6d4df76, stepfunc_774d9b10b28042acc8404fd0cd55908b_6dfd0e0d2b04618ffe2fdb6da6d4df76, stepfunc_ae9f735c6401a821cc04ce1cd68278bf_6dfd0e0d2b04618ffe2fdb6da6d4df76, NULL}; extern const BulletStepFunc bullet_9fbac313f406be7f861445d3ee649bde_6dfd0e0d2b04618ffe2fdb6da6d4df76[] = { stepfunc_0c923aebe6319883d63e48accbf96a9e_6dfd0e0d2b04618ffe2fdb6da6d4df76, stepfunc_9b29ea69de8fbbc5ddab19473135df0c_6dfd0e0d2b04618ffe2fdb6da6d4df76, stepfunc_6cd605b946c872a54e4a58d543da53a7_6dfd0e0d2b04618ffe2fdb6da6d4df76, stepfunc_a604f97072875284b6f4bd31aae1a3ca_6dfd0e0d2b04618ffe2fdb6da6d4df76, stepfunc_a604f97072875284b6f4bd31aae1a3ca_6dfd0e0d2b04618ffe2fdb6da6d4df76, stepfunc_a604f97072875284b6f4bd31aae1a3ca_6dfd0e0d2b04618ffe2fdb6da6d4df76, stepfunc_a604f97072875284b6f4bd31aae1a3ca_6dfd0e0d2b04618ffe2fdb6da6d4df76, stepfunc_a604f97072875284b6f4bd31aae1a3ca_6dfd0e0d2b04618ffe2fdb6da6d4df76, stepfunc_a604f97072875284b6f4bd31aae1a3ca_6dfd0e0d2b04618ffe2fdb6da6d4df76, stepfunc_a604f97072875284b6f4bd31aae1a3ca_6dfd0e0d2b04618ffe2fdb6da6d4df76, stepfunc_a604f97072875284b6f4bd31aae1a3ca_6dfd0e0d2b04618ffe2fdb6da6d4df76, stepfunc_a604f97072875284b6f4bd31aae1a3ca_6dfd0e0d2b04618ffe2fdb6da6d4df76, stepfunc_a604f97072875284b6f4bd31aae1a3ca_6dfd0e0d2b04618ffe2fdb6da6d4df76, stepfunc_a604f97072875284b6f4bd31aae1a3ca_6dfd0e0d2b04618ffe2fdb6da6d4df76, stepfunc_a604f97072875284b6f4bd31aae1a3ca_6dfd0e0d2b04618ffe2fdb6da6d4df76, stepfunc_a604f97072875284b6f4bd31aae1a3ca_6dfd0e0d2b04618ffe2fdb6da6d4df76, stepfunc_a604f97072875284b6f4bd31aae1a3ca_6dfd0e0d2b04618ffe2fdb6da6d4df76, stepfunc_a604f97072875284b6f4bd31aae1a3ca_6dfd0e0d2b04618ffe2fdb6da6d4df76, stepfunc_a604f97072875284b6f4bd31aae1a3ca_6dfd0e0d2b04618ffe2fdb6da6d4df76, stepfunc_a604f97072875284b6f4bd31aae1a3ca_6dfd0e0d2b04618ffe2fdb6da6d4df76, stepfunc_a604f97072875284b6f4bd31aae1a3ca_6dfd0e0d2b04618ffe2fdb6da6d4df76, stepfunc_a604f97072875284b6f4bd31aae1a3ca_6dfd0e0d2b04618ffe2fdb6da6d4df76, stepfunc_a604f97072875284b6f4bd31aae1a3ca_6dfd0e0d2b04618ffe2fdb6da6d4df76, stepfunc_a604f97072875284b6f4bd31aae1a3ca_6dfd0e0d2b04618ffe2fdb6da6d4df76, stepfunc_a604f97072875284b6f4bd31aae1a3ca_6dfd0e0d2b04618ffe2fdb6da6d4df76, stepfunc_a604f97072875284b6f4bd31aae1a3ca_6dfd0e0d2b04618ffe2fdb6da6d4df76, stepfunc_a604f97072875284b6f4bd31aae1a3ca_6dfd0e0d2b04618ffe2fdb6da6d4df76, stepfunc_a604f97072875284b6f4bd31aae1a3ca_6dfd0e0d2b04618ffe2fdb6da6d4df76, stepfunc_a604f97072875284b6f4bd31aae1a3ca_6dfd0e0d2b04618ffe2fdb6da6d4df76, stepfunc_a604f97072875284b6f4bd31aae1a3ca_6dfd0e0d2b04618ffe2fdb6da6d4df76, stepfunc_a604f97072875284b6f4bd31aae1a3ca_6dfd0e0d2b04618ffe2fdb6da6d4df76, stepfunc_a604f97072875284b6f4bd31aae1a3ca_6dfd0e0d2b04618ffe2fdb6da6d4df76, stepfunc_a604f97072875284b6f4bd31aae1a3ca_6dfd0e0d2b04618ffe2fdb6da6d4df76, stepfunc_a604f97072875284b6f4bd31aae1a3ca_6dfd0e0d2b04618ffe2fdb6da6d4df76, stepfunc_a604f97072875284b6f4bd31aae1a3ca_6dfd0e0d2b04618ffe2fdb6da6d4df76, stepfunc_a604f97072875284b6f4bd31aae1a3ca_6dfd0e0d2b04618ffe2fdb6da6d4df76, stepfunc_a604f97072875284b6f4bd31aae1a3ca_6dfd0e0d2b04618ffe2fdb6da6d4df76, stepfunc_a604f97072875284b6f4bd31aae1a3ca_6dfd0e0d2b04618ffe2fdb6da6d4df76, stepfunc_a604f97072875284b6f4bd31aae1a3ca_6dfd0e0d2b04618ffe2fdb6da6d4df76, stepfunc_a604f97072875284b6f4bd31aae1a3ca_6dfd0e0d2b04618ffe2fdb6da6d4df76, stepfunc_a604f97072875284b6f4bd31aae1a3ca_6dfd0e0d2b04618ffe2fdb6da6d4df76, stepfunc_a604f97072875284b6f4bd31aae1a3ca_6dfd0e0d2b04618ffe2fdb6da6d4df76, stepfunc_a604f97072875284b6f4bd31aae1a3ca_6dfd0e0d2b04618ffe2fdb6da6d4df76, stepfunc_a604f97072875284b6f4bd31aae1a3ca_6dfd0e0d2b04618ffe2fdb6da6d4df76, stepfunc_a604f97072875284b6f4bd31aae1a3ca_6dfd0e0d2b04618ffe2fdb6da6d4df76, stepfunc_a604f97072875284b6f4bd31aae1a3ca_6dfd0e0d2b04618ffe2fdb6da6d4df76, stepfunc_a604f97072875284b6f4bd31aae1a3ca_6dfd0e0d2b04618ffe2fdb6da6d4df76, stepfunc_a604f97072875284b6f4bd31aae1a3ca_6dfd0e0d2b04618ffe2fdb6da6d4df76, stepfunc_a604f97072875284b6f4bd31aae1a3ca_6dfd0e0d2b04618ffe2fdb6da6d4df76, stepfunc_a604f97072875284b6f4bd31aae1a3ca_6dfd0e0d2b04618ffe2fdb6da6d4df76, stepfunc_a604f97072875284b6f4bd31aae1a3ca_6dfd0e0d2b04618ffe2fdb6da6d4df76, stepfunc_a604f97072875284b6f4bd31aae1a3ca_6dfd0e0d2b04618ffe2fdb6da6d4df76, stepfunc_a604f97072875284b6f4bd31aae1a3ca_6dfd0e0d2b04618ffe2fdb6da6d4df76, stepfunc_a604f97072875284b6f4bd31aae1a3ca_6dfd0e0d2b04618ffe2fdb6da6d4df76, stepfunc_a604f97072875284b6f4bd31aae1a3ca_6dfd0e0d2b04618ffe2fdb6da6d4df76, stepfunc_a604f97072875284b6f4bd31aae1a3ca_6dfd0e0d2b04618ffe2fdb6da6d4df76, stepfunc_a604f97072875284b6f4bd31aae1a3ca_6dfd0e0d2b04618ffe2fdb6da6d4df76, stepfunc_a604f97072875284b6f4bd31aae1a3ca_6dfd0e0d2b04618ffe2fdb6da6d4df76, stepfunc_a604f97072875284b6f4bd31aae1a3ca_6dfd0e0d2b04618ffe2fdb6da6d4df76, stepfunc_a604f97072875284b6f4bd31aae1a3ca_6dfd0e0d2b04618ffe2fdb6da6d4df76, stepfunc_a604f97072875284b6f4bd31aae1a3ca_6dfd0e0d2b04618ffe2fdb6da6d4df76, stepfunc_a604f97072875284b6f4bd31aae1a3ca_6dfd0e0d2b04618ffe2fdb6da6d4df76, stepfunc_a604f97072875284b6f4bd31aae1a3ca_6dfd0e0d2b04618ffe2fdb6da6d4df76, stepfunc_a604f97072875284b6f4bd31aae1a3ca_6dfd0e0d2b04618ffe2fdb6da6d4df76, stepfunc_a604f97072875284b6f4bd31aae1a3ca_6dfd0e0d2b04618ffe2fdb6da6d4df76, stepfunc_a604f97072875284b6f4bd31aae1a3ca_6dfd0e0d2b04618ffe2fdb6da6d4df76, stepfunc_a604f97072875284b6f4bd31aae1a3ca_6dfd0e0d2b04618ffe2fdb6da6d4df76, stepfunc_a604f97072875284b6f4bd31aae1a3ca_6dfd0e0d2b04618ffe2fdb6da6d4df76, stepfunc_a604f97072875284b6f4bd31aae1a3ca_6dfd0e0d2b04618ffe2fdb6da6d4df76, stepfunc_a604f97072875284b6f4bd31aae1a3ca_6dfd0e0d2b04618ffe2fdb6da6d4df76, stepfunc_a604f97072875284b6f4bd31aae1a3ca_6dfd0e0d2b04618ffe2fdb6da6d4df76, stepfunc_a604f97072875284b6f4bd31aae1a3ca_6dfd0e0d2b04618ffe2fdb6da6d4df76, stepfunc_a604f97072875284b6f4bd31aae1a3ca_6dfd0e0d2b04618ffe2fdb6da6d4df76, stepfunc_a604f97072875284b6f4bd31aae1a3ca_6dfd0e0d2b04618ffe2fdb6da6d4df76, stepfunc_a604f97072875284b6f4bd31aae1a3ca_6dfd0e0d2b04618ffe2fdb6da6d4df76, stepfunc_a604f97072875284b6f4bd31aae1a3ca_6dfd0e0d2b04618ffe2fdb6da6d4df76, stepfunc_a604f97072875284b6f4bd31aae1a3ca_6dfd0e0d2b04618ffe2fdb6da6d4df76, stepfunc_a604f97072875284b6f4bd31aae1a3ca_6dfd0e0d2b04618ffe2fdb6da6d4df76, stepfunc_a604f97072875284b6f4bd31aae1a3ca_6dfd0e0d2b04618ffe2fdb6da6d4df76, stepfunc_a604f97072875284b6f4bd31aae1a3ca_6dfd0e0d2b04618ffe2fdb6da6d4df76, stepfunc_a604f97072875284b6f4bd31aae1a3ca_6dfd0e0d2b04618ffe2fdb6da6d4df76, stepfunc_a604f97072875284b6f4bd31aae1a3ca_6dfd0e0d2b04618ffe2fdb6da6d4df76, stepfunc_a604f97072875284b6f4bd31aae1a3ca_6dfd0e0d2b04618ffe2fdb6da6d4df76, stepfunc_a604f97072875284b6f4bd31aae1a3ca_6dfd0e0d2b04618ffe2fdb6da6d4df76, stepfunc_a604f97072875284b6f4bd31aae1a3ca_6dfd0e0d2b04618ffe2fdb6da6d4df76, stepfunc_a604f97072875284b6f4bd31aae1a3ca_6dfd0e0d2b04618ffe2fdb6da6d4df76, stepfunc_a604f97072875284b6f4bd31aae1a3ca_6dfd0e0d2b04618ffe2fdb6da6d4df76, stepfunc_a604f97072875284b6f4bd31aae1a3ca_6dfd0e0d2b04618ffe2fdb6da6d4df76, stepfunc_a604f97072875284b6f4bd31aae1a3ca_6dfd0e0d2b04618ffe2fdb6da6d4df76, stepfunc_a604f97072875284b6f4bd31aae1a3ca_6dfd0e0d2b04618ffe2fdb6da6d4df76, stepfunc_a604f97072875284b6f4bd31aae1a3ca_6dfd0e0d2b04618ffe2fdb6da6d4df76, stepfunc_a604f97072875284b6f4bd31aae1a3ca_6dfd0e0d2b04618ffe2fdb6da6d4df76, stepfunc_a604f97072875284b6f4bd31aae1a3ca_6dfd0e0d2b04618ffe2fdb6da6d4df76, stepfunc_a604f97072875284b6f4bd31aae1a3ca_6dfd0e0d2b04618ffe2fdb6da6d4df76, stepfunc_a604f97072875284b6f4bd31aae1a3ca_6dfd0e0d2b04618ffe2fdb6da6d4df76, stepfunc_a604f97072875284b6f4bd31aae1a3ca_6dfd0e0d2b04618ffe2fdb6da6d4df76, stepfunc_a604f97072875284b6f4bd31aae1a3ca_6dfd0e0d2b04618ffe2fdb6da6d4df76, stepfunc_a604f97072875284b6f4bd31aae1a3ca_6dfd0e0d2b04618ffe2fdb6da6d4df76, stepfunc_a604f97072875284b6f4bd31aae1a3ca_6dfd0e0d2b04618ffe2fdb6da6d4df76, stepfunc_a604f97072875284b6f4bd31aae1a3ca_6dfd0e0d2b04618ffe2fdb6da6d4df76, stepfunc_a604f97072875284b6f4bd31aae1a3ca_6dfd0e0d2b04618ffe2fdb6da6d4df76, stepfunc_a604f97072875284b6f4bd31aae1a3ca_6dfd0e0d2b04618ffe2fdb6da6d4df76, stepfunc_a604f97072875284b6f4bd31aae1a3ca_6dfd0e0d2b04618ffe2fdb6da6d4df76, stepfunc_a604f97072875284b6f4bd31aae1a3ca_6dfd0e0d2b04618ffe2fdb6da6d4df76, stepfunc_a604f97072875284b6f4bd31aae1a3ca_6dfd0e0d2b04618ffe2fdb6da6d4df76, stepfunc_a604f97072875284b6f4bd31aae1a3ca_6dfd0e0d2b04618ffe2fdb6da6d4df76, stepfunc_a604f97072875284b6f4bd31aae1a3ca_6dfd0e0d2b04618ffe2fdb6da6d4df76, stepfunc_a604f97072875284b6f4bd31aae1a3ca_6dfd0e0d2b04618ffe2fdb6da6d4df76, stepfunc_a604f97072875284b6f4bd31aae1a3ca_6dfd0e0d2b04618ffe2fdb6da6d4df76, stepfunc_a604f97072875284b6f4bd31aae1a3ca_6dfd0e0d2b04618ffe2fdb6da6d4df76, stepfunc_a604f97072875284b6f4bd31aae1a3ca_6dfd0e0d2b04618ffe2fdb6da6d4df76, stepfunc_a604f97072875284b6f4bd31aae1a3ca_6dfd0e0d2b04618ffe2fdb6da6d4df76, stepfunc_a604f97072875284b6f4bd31aae1a3ca_6dfd0e0d2b04618ffe2fdb6da6d4df76, stepfunc_a604f97072875284b6f4bd31aae1a3ca_6dfd0e0d2b04618ffe2fdb6da6d4df76, stepfunc_a604f97072875284b6f4bd31aae1a3ca_6dfd0e0d2b04618ffe2fdb6da6d4df76, stepfunc_a604f97072875284b6f4bd31aae1a3ca_6dfd0e0d2b04618ffe2fdb6da6d4df76, stepfunc_a604f97072875284b6f4bd31aae1a3ca_6dfd0e0d2b04618ffe2fdb6da6d4df76, stepfunc_a604f97072875284b6f4bd31aae1a3ca_6dfd0e0d2b04618ffe2fdb6da6d4df76, stepfunc_a604f97072875284b6f4bd31aae1a3ca_6dfd0e0d2b04618ffe2fdb6da6d4df76, stepfunc_a604f97072875284b6f4bd31aae1a3ca_6dfd0e0d2b04618ffe2fdb6da6d4df76, stepfunc_a604f97072875284b6f4bd31aae1a3ca_6dfd0e0d2b04618ffe2fdb6da6d4df76, stepfunc_a604f97072875284b6f4bd31aae1a3ca_6dfd0e0d2b04618ffe2fdb6da6d4df76, stepfunc_a604f97072875284b6f4bd31aae1a3ca_6dfd0e0d2b04618ffe2fdb6da6d4df76, stepfunc_ae9f735c6401a821cc04ce1cd68278bf_6dfd0e0d2b04618ffe2fdb6da6d4df76, NULL}; void stepfunc_a604f97072875284b6f4bd31aae1a3ca_6dfd0e0d2b04618ffe2fdb6da6d4df76(BulletInfo *p) { { BulletInfo *bi; p->lastBulletAngle = SelfPos::getAngle(p) + (FixedPointNum::degree2angle(-40.0+FixedPointNum::random()*80.0)); p->lastBulletSpeed = (0.4+1.0+FixedPointNum::random()*0.6); bi = ListBullets::makeNewBullet(); if (bi != NULL) { bi->initialize(p->getType() << 1, p->getPosX(), p->getPosY(), p->lastBulletAngle, p->lastBulletSpeed, StepFunc::nullStepFuncList); } } { BulletInfo *bi; p->lastBulletAngle = SelfPos::getAngle(p) + (FixedPointNum::degree2angle(-40.0+FixedPointNum::random()*80.0)); p->lastBulletSpeed = (0.4+1.0+FixedPointNum::random()*0.6); bi = ListBullets::makeNewBullet(); if (bi != NULL) { bi->initialize(p->getType() << 1, p->getPosX(), p->getPosY(), p->lastBulletAngle, p->lastBulletSpeed, StepFunc::nullStepFuncList); } } { BulletInfo *bi; p->lastBulletAngle = SelfPos::getAngle(p) + (FixedPointNum::degree2angle(-40.0+FixedPointNum::random()*80.0)); p->lastBulletSpeed = (0.4+1.0+FixedPointNum::random()*0.6); bi = ListBullets::makeNewBullet(); if (bi != NULL) { bi->initialize(p->getType() << 1, p->getPosX(), p->getPosY(), p->lastBulletAngle, p->lastBulletSpeed, StepFunc::nullStepFuncList); } } p->wait = static_cast<u16>(3.0); } void stepfunc_774d9b10b28042acc8404fd0cd55908b_6dfd0e0d2b04618ffe2fdb6da6d4df76(BulletInfo *p) { { BulletInfo *bi; p->lastBulletAngle = SelfPos::getAngle(p) + (FixedPointNum::degree2angle(((0.0)))); p->lastBulletSpeed = ((1.0+1.0)); bi = ListBullets::makeNewBullet(); if (bi != NULL) { bi->initialize(p->getType() << 1, p->getPosX(), p->getPosY(), p->lastBulletAngle, p->lastBulletSpeed, StepFunc::nullStepFuncList); } } { BulletInfo *bi; p->lastBulletAngle = SelfPos::getAngle(p) + (FixedPointNum::degree2angle(((2.0)))); p->lastBulletSpeed = ((1.0+1.0)); bi = ListBullets::makeNewBullet(); if (bi != NULL) { bi->initialize(p->getType() << 1, p->getPosX(), p->getPosY(), p->lastBulletAngle, p->lastBulletSpeed, StepFunc::nullStepFuncList); } } { BulletInfo *bi; p->lastBulletAngle = SelfPos::getAngle(p) + (FixedPointNum::degree2angle(((4.0)))); p->lastBulletSpeed = ((1.0+1.0)); bi = ListBullets::makeNewBullet(); if (bi != NULL) { bi->initialize(p->getType() << 1, p->getPosX(), p->getPosY(), p->lastBulletAngle, p->lastBulletSpeed, StepFunc::nullStepFuncList); } } { BulletInfo *bi; p->lastBulletAngle = SelfPos::getAngle(p) + (FixedPointNum::degree2angle(((6.0)))); p->lastBulletSpeed = ((1.0+1.0)); bi = ListBullets::makeNewBullet(); if (bi != NULL) { bi->initialize(p->getType() << 1, p->getPosX(), p->getPosY(), p->lastBulletAngle, p->lastBulletSpeed, StepFunc::nullStepFuncList); } } { BulletInfo *bi; p->lastBulletAngle = SelfPos::getAngle(p) + (FixedPointNum::degree2angle(((-2.0)))); p->lastBulletSpeed = ((1.0+1.0)); bi = ListBullets::makeNewBullet(); if (bi != NULL) { bi->initialize(p->getType() << 1, p->getPosX(), p->getPosY(), p->lastBulletAngle, p->lastBulletSpeed, StepFunc::nullStepFuncList); } } { BulletInfo *bi; p->lastBulletAngle = SelfPos::getAngle(p) + (FixedPointNum::degree2angle(((-4.0)))); p->lastBulletSpeed = ((1.0+1.0)); bi = ListBullets::makeNewBullet(); if (bi != NULL) { bi->initialize(p->getType() << 1, p->getPosX(), p->getPosY(), p->lastBulletAngle, p->lastBulletSpeed, StepFunc::nullStepFuncList); } } { BulletInfo *bi; p->lastBulletAngle = SelfPos::getAngle(p) + (FixedPointNum::degree2angle(((-6.0)))); p->lastBulletSpeed = ((1.0+1.0)); bi = ListBullets::makeNewBullet(); if (bi != NULL) { bi->initialize(p->getType() << 1, p->getPosX(), p->getPosY(), p->lastBulletAngle, p->lastBulletSpeed, StepFunc::nullStepFuncList); } } p->wait = static_cast<u16>(40.0); } void stepfunc_05798bae9c12d6be89270ea1e2488f81_6dfd0e0d2b04618ffe2fdb6da6d4df76(BulletInfo *p) { { u16 life = static_cast<u16>(5.0); FixedPointNum speed = FixedPointNum(0.0 - p->getSpeed(), life);p->setAccel(speed, life);} p->wait = static_cast<u16>(20.0); } void stepfunc_ae9f735c6401a821cc04ce1cd68278bf_6dfd0e0d2b04618ffe2fdb6da6d4df76(BulletInfo *p) { ListBullets::stepFuncDrop(p);} void stepfunc_0c923aebe6319883d63e48accbf96a9e_6dfd0e0d2b04618ffe2fdb6da6d4df76(BulletInfo *p) { { u16 life = static_cast<u16>(1.0); FixedPointNum speed = 4.0 - p->getSpeed();p->setAccel(speed, life);} { u16 life = static_cast<u16>(1.0); FixedPointNum speed = (FixedPointNum::degree2angle(180.0)) - p->getAngle();p->setRound(speed, life);} p->wait = static_cast<u16>(10.0); } void stepfunc_9b29ea69de8fbbc5ddab19473135df0c_6dfd0e0d2b04618ffe2fdb6da6d4df76(BulletInfo *p) { { u16 life = static_cast<u16>(1.0); FixedPointNum speed = 0.0 - p->getSpeed();p->setAccel(speed, life);} p->wait = static_cast<u16>(60.0); } void stepfunc_6cd605b946c872a54e4a58d543da53a7_6dfd0e0d2b04618ffe2fdb6da6d4df76(BulletInfo *p) { { BulletInfo *bi; p->lastBulletAngle = (FixedPointNum::degree2angle((60.0))); p->lastBulletSpeed = (10.0); bi = ListBullets::makeNewBullet(); if (bi != NULL) { bi->initialize(p->getType() << 1, p->getPosX(), p->getPosY(), p->lastBulletAngle, p->lastBulletSpeed, StepFunc::nullStepFuncList); } } { BulletInfo *bi; p->lastBulletAngle = (SelfPos::getAngle(p)); p->lastBulletSpeed = 1; bi = ListBullets::makeNewBullet(); if (bi != NULL) { bi->initialize(p->getType() << 1, p->getPosX(), p->getPosY(), p->lastBulletAngle, p->lastBulletSpeed, bullet_f1f3d5f55c5d318a36d3fbde506fd1af_6dfd0e0d2b04618ffe2fdb6da6d4df76); } } { BulletInfo *bi; p->lastBulletAngle = (FixedPointNum::degree2angle((300.0))); p->lastBulletSpeed = (10.0); bi = ListBullets::makeNewBullet(); if (bi != NULL) { bi->initialize(p->getType() << 1, p->getPosX(), p->getPosY(), p->lastBulletAngle, p->lastBulletSpeed, StepFunc::nullStepFuncList); } } { BulletInfo *bi; p->lastBulletAngle = (SelfPos::getAngle(p)); p->lastBulletSpeed = 1; bi = ListBullets::makeNewBullet(); if (bi != NULL) { bi->initialize(p->getType() << 1, p->getPosX(), p->getPosY(), p->lastBulletAngle, p->lastBulletSpeed, bullet_f1f3d5f55c5d318a36d3fbde506fd1af_6dfd0e0d2b04618ffe2fdb6da6d4df76); } } { BulletInfo *bi; p->lastBulletAngle = (FixedPointNum::degree2angle((120.0))); p->lastBulletSpeed = (10.0); bi = ListBullets::makeNewBullet(); if (bi != NULL) { bi->initialize(p->getType() << 1, p->getPosX(), p->getPosY(), p->lastBulletAngle, p->lastBulletSpeed, StepFunc::nullStepFuncList); } } { BulletInfo *bi; p->lastBulletAngle = (SelfPos::getAngle(p)); p->lastBulletSpeed = 1; bi = ListBullets::makeNewBullet(); if (bi != NULL) { bi->initialize(p->getType() << 1, p->getPosX(), p->getPosY(), p->lastBulletAngle, p->lastBulletSpeed, bullet_f1f3d5f55c5d318a36d3fbde506fd1af_6dfd0e0d2b04618ffe2fdb6da6d4df76); } } { BulletInfo *bi; p->lastBulletAngle = (FixedPointNum::degree2angle((240.0))); p->lastBulletSpeed = (10.0); bi = ListBullets::makeNewBullet(); if (bi != NULL) { bi->initialize(p->getType() << 1, p->getPosX(), p->getPosY(), p->lastBulletAngle, p->lastBulletSpeed, StepFunc::nullStepFuncList); } } { BulletInfo *bi; p->lastBulletAngle = (SelfPos::getAngle(p)); p->lastBulletSpeed = 1; bi = ListBullets::makeNewBullet(); if (bi != NULL) { bi->initialize(p->getType() << 1, p->getPosX(), p->getPosY(), p->lastBulletAngle, p->lastBulletSpeed, bullet_f1f3d5f55c5d318a36d3fbde506fd1af_6dfd0e0d2b04618ffe2fdb6da6d4df76); } } p->wait = static_cast<u16>(25.0); } BulletInfo *genBulletFunc_6dfd0e0d2b04618ffe2fdb6da6d4df76(FixedPointNum posx, FixedPointNum posy) { BulletInfo * bi; bi = ListBullets::makeNewBullet(); if (bi != NULL) { bi->initialize(BULLET_TYPE_ROOT, posx, posy, BulletInfo::DEFAULT_ANGLE, 0, bullet_9fbac313f406be7f861445d3ee649bde_6dfd0e0d2b04618ffe2fdb6da6d4df76); } return bi;}
72.389105
380
0.851
pqrs-org
0eb991684de26e856fff5254f586f544f15a6ac0
461
cpp
C++
applications/DebugApp/main.cpp
InfiniteInteractive/LimitlessSDK
cb71dde14d8c59cbf8a1ece765989c5787fffefa
[ "MIT" ]
3
2017-05-13T20:36:03.000Z
2021-07-16T17:23:01.000Z
applications/DebugApp/main.cpp
InfiniteInteractive/LimitlessSDK
cb71dde14d8c59cbf8a1ece765989c5787fffefa
[ "MIT" ]
null
null
null
applications/DebugApp/main.cpp
InfiniteInteractive/LimitlessSDK
cb71dde14d8c59cbf8a1ece765989c5787fffefa
[ "MIT" ]
2
2016-08-04T00:16:50.000Z
2017-09-07T14:50:03.000Z
#include "debugapp.h" #include <QtWidgets/QApplication> #include "Media/MediaPluginFactory.h" int main(int argc, char *argv[]) { QApplication a(argc, argv); QCoreApplication::setOrganizationName("Infinite Interactive"); QCoreApplication::setOrganizationDomain("infiniteinteractive.com"); QCoreApplication::setApplicationName("DebugApp"); Limitless::MediaPluginFactory::loadPlugins("./plugins/"); DebugApp w; w.show(); w.init(); return a.exec(); }
21.952381
68
0.754881
InfiniteInteractive
0ebc89a7d0619d64d95806157acd06cea6e38142
3,255
cpp
C++
Source/Diagnostics/ReducedDiags/FieldReduction.cpp
Yin-YinjianZhao/WarpX
a194b909f73c44703b013b39dbcead0f278a8ba6
[ "BSD-3-Clause-LBNL" ]
131
2018-09-29T08:11:40.000Z
2022-03-28T23:24:22.000Z
Source/Diagnostics/ReducedDiags/FieldReduction.cpp
Yin-YinjianZhao/WarpX
a194b909f73c44703b013b39dbcead0f278a8ba6
[ "BSD-3-Clause-LBNL" ]
1,656
2018-10-02T01:49:24.000Z
2022-03-31T21:27:31.000Z
Source/Diagnostics/ReducedDiags/FieldReduction.cpp
Yin-YinjianZhao/WarpX
a194b909f73c44703b013b39dbcead0f278a8ba6
[ "BSD-3-Clause-LBNL" ]
100
2018-10-01T20:41:14.000Z
2022-03-10T10:30:42.000Z
/* Copyright 2021 Neil Zaim * * This file is part of WarpX. * * License: BSD-3-Clause-LBNL */ #include "FieldReduction.H" #include "Utils/IntervalsParser.H" #include "Utils/WarpXAlgorithmSelection.H" #include "Utils/WarpXUtil.H" #include <AMReX_Algorithm.H> #include <AMReX_BLassert.H> #include <AMReX_ParmParse.H> #include <AMReX_Vector.H> #include <algorithm> #include <ostream> #include <regex> // constructor FieldReduction::FieldReduction (std::string rd_name) : ReducedDiags{rd_name} { using namespace amrex::literals; // RZ coordinate is not working #if (defined WARPX_DIM_RZ) AMREX_ALWAYS_ASSERT_WITH_MESSAGE(false, "FieldReduction reduced diagnostics does not work for RZ coordinate."); #endif // read number of levels int nLevel = 0; amrex::ParmParse pp_amr("amr"); pp_amr.query("max_level", nLevel); AMREX_ALWAYS_ASSERT_WITH_MESSAGE(nLevel == 0, "FieldReduction reduced diagnostics does not work with mesh refinement."); constexpr int noutputs = 1; // A single output in the Field reduction diagnostic // resize data array m_data.resize(noutputs, 0.0_rt); amrex::ParmParse pp_rd_name(rd_name); // read reduced function with parser std::string parser_string = ""; Store_parserString(pp_rd_name,"reduced_function(x,y,z,Ex,Ey,Ez,Bx,By,Bz)", parser_string); m_parser = std::make_unique<amrex::Parser>( makeParser(parser_string,{"x","y","z","Ex","Ey","Ez","Bx","By","Bz"})); // Replace all newlines and possible following whitespaces with a single whitespace. This // should avoid weird formatting when the string is written in the header of the output file. parser_string = std::regex_replace(parser_string, std::regex("\n\\s*"), " "); // read reduction type std::string reduction_type_string; pp_rd_name.get("reduction_type", reduction_type_string); m_reduction_type = GetAlgorithmInteger (pp_rd_name, "reduction_type"); if (amrex::ParallelDescriptor::IOProcessor()) { if ( m_IsNotRestart ) { // open file std::ofstream ofs{m_path + m_rd_name + "." + m_extension, std::ofstream::out}; // write header row int c = 0; ofs << "#"; ofs << "[" << c++ << "]step()"; ofs << m_sep; ofs << "[" << c++ << "]time(s)"; ofs << m_sep; ofs << "[" << c++ << "]" + reduction_type_string + " of " + parser_string + " (SI units)"; ofs << std::endl; // close file ofs.close(); } } } // end constructor // function that does an arbitrary reduction of the electromagnetic fields void FieldReduction::ComputeDiags (int step) { // Judge if the diags should be done if (!m_intervals.contains(step+1)) { return; } if (m_reduction_type == ReductionType::Maximum) { ComputeFieldReduction<amrex::ReduceOpMax>(); } else if (m_reduction_type == ReductionType::Minimum) { ComputeFieldReduction<amrex::ReduceOpMin>(); } else if (m_reduction_type == ReductionType::Sum) { ComputeFieldReduction<amrex::ReduceOpSum>(); } } // end void FieldMaximum::ComputeDiags
30.138889
102
0.639324
Yin-YinjianZhao
0ebe27e4d9ee13dd85d4f0332faf6dce9012d6ca
654
hpp
C++
Edge.hpp
opendatasurgeon/DijkstrasShortestPathAlgorithm_cpp
b6cadd89c50762b61fdd868f1ba17bce785400f8
[ "CC0-1.0" ]
null
null
null
Edge.hpp
opendatasurgeon/DijkstrasShortestPathAlgorithm_cpp
b6cadd89c50762b61fdd868f1ba17bce785400f8
[ "CC0-1.0" ]
null
null
null
Edge.hpp
opendatasurgeon/DijkstrasShortestPathAlgorithm_cpp
b6cadd89c50762b61fdd868f1ba17bce785400f8
[ "CC0-1.0" ]
null
null
null
/* Author: Mihir Patel Purpose: Following is a header+source file for the Edge. It keeps the graph's edges, edge's weight. */ #ifndef EDGE_HPP #define EDGE_HPP #include <string> class Edge { private: std::string edge_a; /*Current edge*/ std::string edge_b; /*adjacent edge*/ unsigned long weight; /*Weight associated with an edge*/ protected: public: friend class Graph;/*Friended to give access*/ /*Argument constructor to set the new information about the edge*/ Edge(std::string a = "", std::string b = "", unsigned long w = 0) { edge_a = a; edge_b = b; weight = w; } ~Edge() {} }; #endif //!EDGE_HPP
23.357143
79
0.652905
opendatasurgeon
b1c1cea7701da88498bfeb31236e530ee95a8106
5,527
cpp
C++
src/client/commands/CmdImportCash.cpp
rfree2/opentxs
3f61dd0abe2e35b7bc52008517873174b2f9dfa7
[ "MIT" ]
null
null
null
src/client/commands/CmdImportCash.cpp
rfree2/opentxs
3f61dd0abe2e35b7bc52008517873174b2f9dfa7
[ "MIT" ]
null
null
null
src/client/commands/CmdImportCash.cpp
rfree2/opentxs
3f61dd0abe2e35b7bc52008517873174b2f9dfa7
[ "MIT" ]
null
null
null
/************************************************************ * * OPEN TRANSACTIONS * * Financial Cryptography and Digital Cash * Library, Protocol, API, Server, CLI, GUI * * -- Anonymous Numbered Accounts. * -- Untraceable Digital Cash. * -- Triple-Signed Receipts. * -- Cheques, Vouchers, Transfers, Inboxes. * -- Basket Currencies, Markets, Payment Plans. * -- Signed, XML, Ricardian-style Contracts. * -- Scripted smart contracts. * * EMAIL: * fellowtraveler@opentransactions.org * * WEBSITE: * http://www.opentransactions.org/ * * ----------------------------------------------------- * * LICENSE: * 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/. * * DISCLAIMER: * 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 Mozilla Public License * for more details. * ************************************************************/ #include "CmdImportCash.hpp" #include <opentxs/client/OTAPI.hpp> #include <opentxs/core/Log.hpp> using namespace opentxs; using namespace std; CmdImportCash::CmdImportCash() { command = "importcash"; args[0] = "[--mynym <nym>]"; category = catInstruments; help = "Import a pasted cash purse."; usage = "Specify mynym when a signer nym cannot be deduced."; } CmdImportCash::~CmdImportCash() { } int32_t CmdImportCash::runWithOptions() { return run(getOption("mynym")); } int32_t CmdImportCash::run(string mynym) { if ("" != mynym && !checkNym("mynym", mynym)) { return -1; } string instrument = inputText("a cash purse"); if ("" == instrument) { return -1; } string type = OTAPI_Wrap::Instrmnt_GetType(instrument); if ("" == type) { otOut << "Error: cannot determine instrument type.\n"; return -1; } string server = OTAPI_Wrap::Instrmnt_GetNotaryID(instrument); if ("" == server) { otOut << "Error: cannot determine instrument server.\n"; return -1; } if ("PURSE" != type) { // Todo: case "TOKEN" // // NOTE: This is commented out because since it is guessing the NymID as // MyNym, then it will just create a purse for MyNym and import it into // that purse, and then later when doing a deposit, THAT's when it tries // to DECRYPT that token and re-encrypt it to the SERVER's nym... and // that's when we might find out that it never was encrypted to MyNym in // the first place -- we had just assumed it was here, when we did the // import. Until I can look at that in more detail, it will remain // commented out. // bool bImportedToken = importCashPurse(server, mynym, // instrumentDefinitionID, // userInput, isPurse); // if (importCashPurse(server, mynym, instrumentDefinitionID, userInput, // isPurse)) //{ // otOut << "\n\n Success importing cash token!\nServer: " // << server << "\nAsset Type: " << instrumentDefinitionID // << "\nNym: " << MyNym << "\n\n"; // return 1; //} otOut << "Error: invalid instrument type. Expected PURSE.\n"; return -1; } string purseOwner = ""; if (!OTAPI_Wrap::Purse_HasPassword(server, instrument)) { purseOwner = OTAPI_Wrap::Instrmnt_GetRecipientNymID(instrument); } // Whether the purse was password-protected (and thus had no Nym ID) or // whether it does have a Nym ID (but it wasn't listed on the purse) // Then either way, in those cases purseOwner will still be empty. // // (The third case is that the purse is Nym protected and the ID WAS // available, in which case we'll skip this block, since we already // have it.) // // But even in the case where there's no Nym at all (password protected) // we STILL need to pass a Signer Nym ID into // OTAPI_Wrap::Wallet_ImportPurse. // So if it's still empty here, then we use --mynym to make the call. // And also, even in the case where there IS a Nym but it's not listed, // we must assume the USER knows the appropriate NymID, even if it's not // listed on the purse itself. And in that case as well, the user can // simply specify the Nym using --mynym. // // Bottom line: by this point, if it's still not set, then we just use // MyNym, and if THAT's not set, then we return failure. if ("" == purseOwner) { purseOwner = mynym; if ("" == purseOwner) { otOut << "Error: cannot determine purse owner.\n" "Please specify mynym.\n"; return -1; } } string instrumentDefinitionID = OTAPI_Wrap::Instrmnt_GetInstrumentDefinitionID(instrument); if ("" == instrumentDefinitionID) { otOut << "Error: cannot determine instrument definition ID.\n"; return -1; } if (!OTAPI_Wrap::Wallet_ImportPurse(server, instrumentDefinitionID, purseOwner, instrument)) { otOut << "Error: cannot import purse.\n"; return -1; } return 1; }
33.907975
80
0.590194
rfree2
b1c3e7a7beb28365fe2bd951c652708162801550
229
cpp
C++
src/_281A.cpp
Big-Totoro/codeforces
ccead5e7bbb94c635bb6d6132de2aee26acb9e70
[ "MIT" ]
null
null
null
src/_281A.cpp
Big-Totoro/codeforces
ccead5e7bbb94c635bb6d6132de2aee26acb9e70
[ "MIT" ]
null
null
null
src/_281A.cpp
Big-Totoro/codeforces
ccead5e7bbb94c635bb6d6132de2aee26acb9e70
[ "MIT" ]
null
null
null
// // https://codeforces.com/problemset/problem/281/A // #include <iostream> using namespace std; int main() { string input; cin >> input; input[0] = toupper(input[0]); cout << input << "\n"; return 0; }
12.722222
50
0.580786
Big-Totoro
b1c43c9897709861b945fb5562f85a413e3363a1
9,007
cpp
C++
source/libraries/core.cpp
Ragora/TribalScript
b7f7cc6b311cee1422f1c7dffd58c85c4f29cc1d
[ "MIT" ]
null
null
null
source/libraries/core.cpp
Ragora/TribalScript
b7f7cc6b311cee1422f1c7dffd58c85c4f29cc1d
[ "MIT" ]
1
2021-07-24T16:29:11.000Z
2021-07-26T20:00:17.000Z
source/libraries/core.cpp
Ragora/TribalScript
b7f7cc6b311cee1422f1c7dffd58c85c4f29cc1d
[ "MIT" ]
null
null
null
/** * Copyright 2021 Robert MacGregor * * 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 <assert.h> #include <chrono> #include <tribalscript/libraries/core.hpp> namespace TribalScript { StoredValue EchoBuiltIn(ConsoleObject* thisObject, ExecutionState* state, std::vector<StoredValue>& parameters) { StoredValueStack& stack = state->mExecutionScope.getStack(); std::string outputString = ""; for (unsigned int iteration = 0; iteration < parameters.size(); ++iteration) { // Parameters will flow right to left so we build the string considering this std::string printedPayload = parameters.back().toString(); parameters.pop_back(); outputString = printedPayload + outputString; } state->mInterpreter->mConfig.mPlatform->logEcho(outputString); return StoredValue(0); } StoredValue GetRealTimeBuiltIn(ConsoleObject* thisObject, ExecutionState* state, std::vector<StoredValue>& parameters) { StoredValueStack& stack = state->mExecutionScope.getStack(); typedef std::chrono::duration<float, std::milli> millisecondFloat; auto currentTime = std::chrono::steady_clock::now().time_since_epoch(); auto result = std::chrono::duration_cast<millisecondFloat>(currentTime); return StoredValue(result.count()); } // Precision timer storage typedef std::chrono::duration<float, std::milli> millisecondFloat; static std::vector<millisecondFloat> sPrecisionTimers; static std::vector<size_t> sAvailablePrecisionTimerIndices; StoredValue StartPrecisionTimerBuiltIn(ConsoleObject* thisObject, ExecutionState* state, std::vector<StoredValue>& parameters) { // Retrieve a previously used index first, if available bool newPrecisionTimer = true; size_t nextIndex = sPrecisionTimers.size(); if (sAvailablePrecisionTimerIndices.size()) { newPrecisionTimer = false; nextIndex = sAvailablePrecisionTimerIndices.back(); sAvailablePrecisionTimerIndices.pop_back(); } // Store starting time auto currentTime = std::chrono::steady_clock::now().time_since_epoch(); if (newPrecisionTimer) { sPrecisionTimers.push_back(currentTime); } else { sPrecisionTimers[nextIndex] = currentTime; } return StoredValue((int)nextIndex); } StoredValue StopPrecisionTimerBuiltIn(ConsoleObject* thisObject, ExecutionState* state, std::vector<StoredValue>& parameters) { int precisionTimerID = parameters[0].toInteger(); const millisecondFloat& startTime = sPrecisionTimers[precisionTimerID]; // Load end time as the current time auto currentTime = std::chrono::steady_clock::now().time_since_epoch(); auto result = std::chrono::duration_cast<millisecondFloat>(currentTime); auto deltaTime = result - startTime; return StoredValue(deltaTime.count()); } StoredValue ExecBuiltIn(ConsoleObject* thisObject, ExecutionState* state, std::vector<StoredValue>& parameters) { StoredValueStack& stack = state->mExecutionScope.getStack(); for (unsigned int iteration = 0; iteration < parameters.size(); ++iteration) { std::string executedFile = parameters.back().toString(); parameters.pop_back(); std::ostringstream output; output << "Executing " << executedFile << " ..."; state->mInterpreter->mConfig.mPlatform->logEcho(output.str()); state->mInterpreter->execute(executedFile, nullptr); } return StoredValue(0); } StoredValue ActivatePackageBuiltIn(ConsoleObject* thisObject, ExecutionState* state, std::vector<StoredValue>& parameters) { StoredValueStack& stack = state->mExecutionScope.getStack(); for (unsigned int iteration = 0; iteration < parameters.size(); ++iteration) { std::string activatedPackage = parameters.back().toString(); state->mInterpreter->activateFunctionRegistry(activatedPackage); parameters.pop_back(); } return StoredValue(0); } StoredValue DeactivatePackageBuiltIn(ConsoleObject* thisObject, ExecutionState* state, std::vector<StoredValue>& parameters) { StoredValueStack& stack = state->mExecutionScope.getStack(); for (unsigned int iteration = 0; iteration < parameters.size(); ++iteration) { std::string deactivatedPackage = parameters.back().toString(); state->mInterpreter->deactivateFunctionRegistry(deactivatedPackage); parameters.pop_back(); } return StoredValue(0); } StoredValue DeleteBuiltIn(ConsoleObject* thisObject, ExecutionState* state, std::vector<StoredValue>& parameters) { StoredValueStack& stack = state->mExecutionScope.getStack(); if (thisObject->destroy()) { state->mInterpreter->mConfig.mConsoleObjectRegistry->removeConsoleObject(state->mInterpreter, thisObject); } return StoredValue(0); } StoredValue GetNameBuiltIn(ConsoleObject* thisObject, ExecutionState* state, std::vector<StoredValue>& parameters) { StoredValueStack& stack = state->mExecutionScope.getStack(); const std::string stringData = state->mInterpreter->mConfig.mConsoleObjectRegistry->getConsoleObjectName(state->mInterpreter, thisObject); return StoredValue(stringData.c_str()); } StoredValue GetClassNameBuiltIn(ConsoleObject* thisObject, ExecutionState* state, std::vector<StoredValue>& parameters) { StoredValueStack& stack = state->mExecutionScope.getStack(); const std::string stringData = thisObject->getClassName(); return StoredValue(stringData.c_str()); } StoredValue GetIDBuiltIn(ConsoleObject* thisObject, ExecutionState* state, std::vector<StoredValue>& parameters) { StoredValueStack& stack = state->mExecutionScope.getStack(); const int objectID = state->mInterpreter->mConfig.mConsoleObjectRegistry->getConsoleObjectID(state->mInterpreter, thisObject); return StoredValue(objectID); } void registerCoreLibrary(Interpreter* interpreter) { interpreter->addFunction(std::shared_ptr<Function>(new NativeFunction(EchoBuiltIn, PACKAGE_EMPTY, NAMESPACE_EMPTY, "echo"))); interpreter->addFunction(std::shared_ptr<Function>(new NativeFunction(ExecBuiltIn, PACKAGE_EMPTY, NAMESPACE_EMPTY, "exec"))); interpreter->addFunction(std::shared_ptr<Function>(new NativeFunction(ActivatePackageBuiltIn, PACKAGE_EMPTY, NAMESPACE_EMPTY, "activatePackage"))); interpreter->addFunction(std::shared_ptr<Function>(new NativeFunction(DeactivatePackageBuiltIn, PACKAGE_EMPTY, NAMESPACE_EMPTY, "deactivatePackage"))); interpreter->addFunction(std::shared_ptr<Function>(new NativeFunction(GetRealTimeBuiltIn, PACKAGE_EMPTY, NAMESPACE_EMPTY, "getRealTime"))); interpreter->addFunction(std::shared_ptr<Function>(new NativeFunction(StartPrecisionTimerBuiltIn, PACKAGE_EMPTY, NAMESPACE_EMPTY, "startPrecisionTimer"))); interpreter->addFunction(std::shared_ptr<Function>(new NativeFunction(StopPrecisionTimerBuiltIn, PACKAGE_EMPTY, NAMESPACE_EMPTY, "stopPrecisionTimer"))); interpreter->addFunction(std::shared_ptr<Function>(new NativeFunction(GetClassNameBuiltIn, PACKAGE_EMPTY, "ConsoleObject", "getClassName"))); interpreter->addFunction(std::shared_ptr<Function>(new NativeFunction(GetNameBuiltIn, PACKAGE_EMPTY, "ConsoleObject", "getName"))); interpreter->addFunction(std::shared_ptr<Function>(new NativeFunction(GetIDBuiltIn, PACKAGE_EMPTY, "ConsoleObject", "getID"))); interpreter->addFunction(std::shared_ptr<Function>(new NativeFunction(DeleteBuiltIn, PACKAGE_EMPTY, "ConsoleObject", "delete"))); } }
45.720812
207
0.709115
Ragora
b1c49b3518b299032d8624592aa2ed62f4da5e76
4,602
cc
C++
code/render/animation/animeventserver.cc
gscept/nebula-trifid
e7c0a0acb05eedad9ed37a72c1bdf2d658511b42
[ "BSD-2-Clause" ]
67
2015-03-30T19:56:16.000Z
2022-03-11T13:52:17.000Z
code/render/animation/animeventserver.cc
gscept/nebula-trifid
e7c0a0acb05eedad9ed37a72c1bdf2d658511b42
[ "BSD-2-Clause" ]
5
2015-04-15T17:17:33.000Z
2016-02-11T00:40:17.000Z
code/render/animation/animeventserver.cc
gscept/nebula-trifid
e7c0a0acb05eedad9ed37a72c1bdf2d658511b42
[ "BSD-2-Clause" ]
34
2015-03-30T15:08:00.000Z
2021-09-23T05:55:10.000Z
//------------------------------------------------------------------------------ // audioserver.cc // (C) 2008 Radon Labs GmbH // (C) 2013-2016 Individual contributors, see AUTHORS file //------------------------------------------------------------------------------ #include "stdneb.h" #include "animation/animeventserver.h" namespace Animation { __ImplementClass(Animation::AnimEventServer, 'ANES', Core::RefCounted); __ImplementSingleton(Animation::AnimEventServer); //------------------------------------------------------------------------------ /** */ AnimEventServer::AnimEventServer() : isOpen(false) { __ConstructSingleton; } //------------------------------------------------------------------------------ /** */ AnimEventServer::~AnimEventServer() { this->animEventHandler.Clear(); __DestructSingleton; } //------------------------------------------------------------------------------ /** */ void AnimEventServer::Open() { n_assert(!this->isOpen); // TODO implement this->isOpen = true; } //------------------------------------------------------------------------------ /** */ void AnimEventServer::Close() { n_assert(this->isOpen); // TODO implement this->isOpen = false; } //------------------------------------------------------------------------------ /** */ void AnimEventServer::RegisterAnimEventHandler(const Ptr<AnimEventHandlerBase>& newHandler) { n_assert(newHandler.isvalid()); // check if already a handler for this category if(this->animEventHandler.Contains(newHandler->GetCategoryName())) { n_error("AnimEventServer::RegisterAnimEventHandler -> Handler for category '%s' already registered!", newHandler->GetCategoryName().Value()); } // now open and attach this handler newHandler->Open(); this->animEventHandler.Add(newHandler->GetCategoryName(), newHandler); } //------------------------------------------------------------------------------ /** */ void AnimEventServer::UnregisterAnimEventHandler(const Util::StringAtom& categoryName) { n_assert(categoryName.IsValid()); // check if exists if(!this->animEventHandler.Contains(categoryName)) { n_error("AnimEventServer::UnregisterAnimEventHandler -> No such handler registered '%s'!", categoryName.Value()); } // close and detach IndexT index = this->animEventHandler.FindIndex(categoryName); this->animEventHandler.ValueAtIndex(index)->Close(); this->animEventHandler.EraseAtIndex(index); } //------------------------------------------------------------------------------ /** */ void AnimEventServer::UnregisterAnimEventHandler(const Ptr<AnimEventHandlerBase>& handler) { for(IndexT i = 0 ; i < this->animEventHandler.Size() ; i++) { if(this->animEventHandler.ValueAtIndex(i) == handler) { handler->Close(); this->animEventHandler.EraseAtIndex(i); return; } } n_error("tried to remove unknown animeventhandler"); } //------------------------------------------------------------------------------ /** */ bool AnimEventServer::HandleAnimEvents(const Util::Array<Animation::AnimEventInfo>& eventz) { n_assert(eventz.Size() > 0); bool allHandled = true; IndexT index; for (index = 0; index < eventz.Size(); index++) { const AnimEventInfo& event = eventz[index]; Util::StringAtom category; if(event.GetAnimEvent().HasCategory()) { category = event.GetAnimEvent().GetCategory(); } IndexT indeX = this->animEventHandler.FindIndex(category); if (InvalidIndex == indeX) { allHandled = false; } else { allHandled &= this->animEventHandler.ValueAtIndex(indeX)->HandleEvent(event); } } return allHandled; } //------------------------------------------------------------------------------ /** */ void AnimEventServer::OnFrame(Timing::Time time) { IndexT index; for (index = 0; index < this->animEventHandler.Size(); index++) { this->animEventHandler.ValueAtIndex(index)->OnFrame(time); } } //------------------------------------------------------------------------------ /** */ bool AnimEventServer::HandleMessage(const Ptr<Messaging::Message>& msg) { bool handled = false; IndexT index; for (index = 0; index < this->animEventHandler.Size(); index++) { handled |= this->animEventHandler.ValueAtIndex(index)->HandleMessage(msg); } return handled; } } // namespace Animation
26
149
0.515428
gscept
b1c697629cedc32b9ef2615ab89fb38bfa0c254c
55
cpp
C++
test/autogen/smp@utility@is_specialization_of.cpp
jonathanpoelen/jln.mp
e5f05fc4467f14ac0047e3bdc75a04076e689985
[ "MIT" ]
9
2020-07-04T16:46:13.000Z
2022-01-09T21:59:31.000Z
test/autogen/smp@utility@is_specialization_of.cpp
jonathanpoelen/jln.mp
e5f05fc4467f14ac0047e3bdc75a04076e689985
[ "MIT" ]
null
null
null
test/autogen/smp@utility@is_specialization_of.cpp
jonathanpoelen/jln.mp
e5f05fc4467f14ac0047e3bdc75a04076e689985
[ "MIT" ]
1
2021-05-23T13:37:40.000Z
2021-05-23T13:37:40.000Z
#include "jln/mp/smp/utility/is_specialization_of.hpp"
27.5
54
0.818182
jonathanpoelen
b1c6e9e0d599ff828661c22f8b2f9ee8329bde2a
56,223
inl
C++
DrvApp/StlInclude/afxwin1.inl
jackqk/mystudy
84313c1eaed7351d37b609288d1d32bf3b808859
[ "Apache-2.0" ]
15
2017-05-27T16:02:51.000Z
2018-11-30T07:02:22.000Z
DrvApp/StlInclude/afxwin1.inl
jackqk/mystudy
84313c1eaed7351d37b609288d1d32bf3b808859
[ "Apache-2.0" ]
null
null
null
DrvApp/StlInclude/afxwin1.inl
jackqk/mystudy
84313c1eaed7351d37b609288d1d32bf3b808859
[ "Apache-2.0" ]
11
2017-11-10T01:28:59.000Z
2018-11-15T11:59:33.000Z
// This is a part of the Microsoft Foundation Classes C++ library. // Copyright (C) Microsoft Corporation // All rights reserved. // // This source code is only intended as a supplement to the // Microsoft Foundation Classes Reference and related // electronic documentation provided with the library. // See these sources for detailed information regarding the // Microsoft Foundation Classes product. // Inlines for AFXWIN.H (part 1) #pragma once #ifdef _AFXWIN_INLINE // Global helper functions _AFXWIN_INLINE CWinApp* AFXAPI AfxGetApp() { return afxCurrentWinApp; } _AFXWIN_INLINE HINSTANCE AFXAPI AfxGetInstanceHandle() { ASSERT(afxCurrentInstanceHandle != NULL); return afxCurrentInstanceHandle; } _AFXWIN_INLINE HINSTANCE AFXAPI AfxGetResourceHandle() { ASSERT(afxCurrentResourceHandle != NULL); return afxCurrentResourceHandle; } _AFXWIN_INLINE void AFXAPI AfxSetResourceHandle(HINSTANCE hInstResource) { ASSERT(hInstResource != NULL); afxCurrentResourceHandle = hInstResource; } _AFXWIN_INLINE LPCTSTR AFXAPI AfxGetAppName() { ASSERT(afxCurrentAppName != NULL); return afxCurrentAppName; } _AFXWIN_INLINE COleMessageFilter* AFXAPI AfxOleGetMessageFilter() { ASSERT_VALID(AfxGetThread()); return AfxGetThread()->m_pMessageFilter; } _AFXWIN_INLINE CWnd* AFXAPI AfxGetMainWnd() { CWinThread* pThread = AfxGetThread(); return pThread != NULL ? pThread->GetMainWnd() : NULL; } // CArchive output helpers _AFXWIN_INLINE CArchive& AFXAPI operator<<(CArchive& ar, SIZE size) { ar.Write(&size, sizeof(SIZE)); return ar; } _AFXWIN_INLINE CArchive& AFXAPI operator<<(CArchive& ar, POINT point) { ar.Write(&point, sizeof(POINT)); return ar; } _AFXWIN_INLINE CArchive& AFXAPI operator<<(CArchive& ar, const RECT& rect) { ar.Write(&rect, sizeof(RECT)); return ar; } _AFXWIN_INLINE CArchive& AFXAPI operator>>(CArchive& ar, SIZE& size) { ar.EnsureRead(&size, sizeof(SIZE)); return ar; } _AFXWIN_INLINE CArchive& AFXAPI operator>>(CArchive& ar, POINT& point) { ar.EnsureRead(&point, sizeof(POINT)); return ar; } _AFXWIN_INLINE CArchive& AFXAPI operator>>(CArchive& ar, RECT& rect) { ar.EnsureRead(&rect, sizeof(RECT)); return ar; } // exception support _AFXWIN_INLINE CResourceException::CResourceException() : CSimpleException() { } _AFXWIN_INLINE CResourceException::CResourceException(BOOL bAutoDelete, UINT nResourceID) : CSimpleException(bAutoDelete) { m_nResourceID = nResourceID; } _AFXWIN_INLINE CResourceException::~CResourceException() { } _AFXWIN_INLINE CUserException::CUserException() : CSimpleException() { } _AFXWIN_INLINE CUserException::CUserException(BOOL bAutoDelete, UINT nResourceID) : CSimpleException(bAutoDelete) { m_nResourceID = nResourceID; } _AFXWIN_INLINE CUserException::~CUserException() { } // CGdiObject _AFXWIN_INLINE CGdiObject::operator HGDIOBJ() const { return this == NULL ? NULL : m_hObject; } _AFXWIN_INLINE HGDIOBJ CGdiObject::GetSafeHandle() const { return this == NULL ? NULL : m_hObject; } _AFXWIN_INLINE CGdiObject::CGdiObject() { m_hObject = NULL; } #pragma warning(push) #pragma warning(disable:6271 6273) _AFXWIN_INLINE CGdiObject::~CGdiObject() { AFX_BEGIN_DESTRUCTOR DeleteObject(); AFX_END_DESTRUCTOR } #pragma warning(pop) _AFXWIN_INLINE int CGdiObject::_AFX_FUNCNAME(GetObject)(int nCount, LPVOID lpObject) const { ASSERT(m_hObject != NULL); return ::GetObject(m_hObject, nCount, lpObject); } #pragma push_macro("GetObject") #undef GetObject _AFXWIN_INLINE int CGdiObject::GetObject(int nCount, LPVOID lpObject) const { return _AFX_FUNCNAME(GetObject)(nCount, lpObject); } #pragma pop_macro("GetObject") _AFXWIN_INLINE BOOL CGdiObject::CreateStockObject(int nIndex) { return (m_hObject = ::GetStockObject(nIndex)) != NULL; } _AFXWIN_INLINE BOOL CGdiObject::UnrealizeObject() { ASSERT(m_hObject != NULL); return ::UnrealizeObject(m_hObject); } _AFXWIN_INLINE UINT CGdiObject::GetObjectType() const { return (UINT)::GetObjectType(m_hObject); } _AFXWIN_INLINE BOOL CGdiObject::operator==(const CGdiObject& obj) const { return ((HGDIOBJ) obj) == m_hObject; } _AFXWIN_INLINE BOOL CGdiObject::operator!=(const CGdiObject& obj) const { return ((HGDIOBJ) obj) != m_hObject; } // CPen _AFXWIN_INLINE CPen::operator HPEN() const { return (HPEN)(this == NULL ? NULL : m_hObject); } _AFXWIN_INLINE CPen* PASCAL CPen::FromHandle(HPEN hPen) { return (CPen*) CGdiObject::FromHandle(hPen); } _AFXWIN_INLINE CPen::CPen() { } _AFXWIN_INLINE CPen::~CPen() { } _AFXWIN_INLINE BOOL CPen::CreatePen(int nPenStyle, int nWidth, COLORREF crColor) { return Attach(::CreatePen(nPenStyle, nWidth, crColor)); } _AFXWIN_INLINE BOOL CPen::CreatePenIndirect(LPLOGPEN lpLogPen) { return Attach(::CreatePenIndirect(lpLogPen)); } _AFXWIN_INLINE BOOL CPen::CreatePen(int nPenStyle, int nWidth, const LOGBRUSH* pLogBrush, int nStyleCount, const DWORD* lpStyle) { return Attach(::ExtCreatePen(nPenStyle, nWidth, pLogBrush, nStyleCount, lpStyle)); } _AFXWIN_INLINE int CPen::GetExtLogPen(EXTLOGPEN* pLogPen) { ASSERT(m_hObject != NULL); return ::GetObject(m_hObject, sizeof(EXTLOGPEN), pLogPen); } _AFXWIN_INLINE int CPen::GetLogPen(LOGPEN* pLogPen) { ASSERT(m_hObject != NULL); return ::GetObject(m_hObject, sizeof(LOGPEN), pLogPen); } // CBrush _AFXWIN_INLINE CBrush::operator HBRUSH() const { return (HBRUSH)(this == NULL ? NULL : m_hObject); } _AFXWIN_INLINE CBrush* PASCAL CBrush::FromHandle(HBRUSH hBrush) { return (CBrush*) CGdiObject::FromHandle(hBrush); } _AFXWIN_INLINE CBrush::CBrush() { } _AFXWIN_INLINE CBrush::~CBrush() { } _AFXWIN_INLINE BOOL CBrush::CreateSolidBrush(COLORREF crColor) { return Attach(::CreateSolidBrush(crColor)); } _AFXWIN_INLINE BOOL CBrush::CreateHatchBrush(int nIndex, COLORREF crColor) { return Attach(::CreateHatchBrush(nIndex, crColor)); } _AFXWIN_INLINE BOOL CBrush::CreateBrushIndirect(const LOGBRUSH* lpLogBrush) { return Attach(::CreateBrushIndirect(lpLogBrush)); } _AFXWIN_INLINE BOOL CBrush::CreatePatternBrush(CBitmap* pBitmap) { return Attach(::CreatePatternBrush((HBITMAP)pBitmap->GetSafeHandle())); } _AFXWIN_INLINE BOOL CBrush::CreateDIBPatternBrush(const void* lpPackedDIB, UINT nUsage) { return Attach(::CreateDIBPatternBrushPt(lpPackedDIB, nUsage)); } _AFXWIN_INLINE BOOL CBrush::CreateSysColorBrush(int nIndex) { return Attach(::GetSysColorBrush(nIndex)); } _AFXWIN_INLINE int CBrush::GetLogBrush(LOGBRUSH* pLogBrush) { ASSERT(m_hObject != NULL); return ::GetObject(m_hObject, sizeof(LOGBRUSH), pLogBrush); } // CFont _AFXWIN_INLINE CFont::operator HFONT() const { return (HFONT)(this == NULL ? NULL : m_hObject); } _AFXWIN_INLINE CFont* PASCAL CFont::FromHandle(HFONT hFont) { return (CFont*) CGdiObject::FromHandle(hFont); } _AFXWIN_INLINE CFont::CFont() { } _AFXWIN_INLINE CFont::~CFont() { } _AFXWIN_INLINE BOOL CFont::CreateFontIndirect(const LOGFONT* lpLogFont) { return Attach(::CreateFontIndirect(lpLogFont)); } _AFXWIN_INLINE BOOL CFont::CreateFont(int nHeight, int nWidth, int nEscapement, int nOrientation, int nWeight, BYTE bItalic, BYTE bUnderline, BYTE cStrikeOut, BYTE nCharSet, BYTE nOutPrecision, BYTE nClipPrecision, BYTE nQuality, BYTE nPitchAndFamily, LPCTSTR lpszFacename) { return Attach(::CreateFont(nHeight, nWidth, nEscapement, nOrientation, nWeight, bItalic, bUnderline, cStrikeOut, nCharSet, nOutPrecision, nClipPrecision, nQuality, nPitchAndFamily, lpszFacename)); } _AFXWIN_INLINE int CFont::GetLogFont(LOGFONT* pLogFont) { ASSERT(m_hObject != NULL); return ::GetObject(m_hObject, sizeof(LOGFONT), pLogFont); } // CBitmap _AFXWIN_INLINE CBitmap::operator HBITMAP() const { return (HBITMAP)(this == NULL ? NULL : m_hObject); } _AFXWIN_INLINE CBitmap* PASCAL CBitmap::FromHandle(HBITMAP hBitmap) { return (CBitmap*) CGdiObject::FromHandle(hBitmap); } _AFXWIN_INLINE CBitmap::CBitmap() { } _AFXWIN_INLINE CBitmap::~CBitmap() { } _AFXWIN_INLINE BOOL CBitmap::CreateBitmap(int nWidth, int nHeight, UINT nPlanes, UINT nBitcount, const void* lpBits) { return Attach(::CreateBitmap(nWidth, nHeight, nPlanes, nBitcount, lpBits)); } _AFXWIN_INLINE BOOL CBitmap::CreateBitmapIndirect(LPBITMAP lpBitmap) { return Attach(::CreateBitmapIndirect(lpBitmap)); } _AFXWIN_INLINE DWORD CBitmap::SetBitmapBits(DWORD dwCount, const void* lpBits) { return ::SetBitmapBits((HBITMAP)m_hObject, dwCount, lpBits); } _AFXWIN_INLINE DWORD CBitmap::GetBitmapBits(DWORD dwCount, LPVOID lpBits) const { return ::GetBitmapBits((HBITMAP)m_hObject, dwCount, lpBits); } _AFXWIN_INLINE BOOL CBitmap::LoadBitmap(LPCTSTR lpszResourceName) { return Attach(::LoadBitmap(AfxFindResourceHandle( lpszResourceName, RT_BITMAP), lpszResourceName));} _AFXWIN_INLINE BOOL CBitmap::LoadMappedBitmap(UINT nIDBitmap, UINT nFlags, LPCOLORMAP lpColorMap, int nMapSize) { return Attach(CreateMappedBitmap(AfxFindResourceHandle( MAKEINTRESOURCE(nIDBitmap), RT_BITMAP), nIDBitmap, (WORD)nFlags, lpColorMap, nMapSize)); } _AFXWIN_INLINE CSize CBitmap::SetBitmapDimension(int nWidth, int nHeight) { SIZE size; VERIFY(::SetBitmapDimensionEx((HBITMAP)m_hObject, nWidth, nHeight, &size)); return size; } _AFXWIN_INLINE CSize CBitmap::GetBitmapDimension() const { SIZE size; VERIFY(::GetBitmapDimensionEx((HBITMAP)m_hObject, &size)); return size; } _AFXWIN_INLINE BOOL CBitmap::LoadBitmap(UINT nIDResource) { return Attach(::LoadBitmapW(AfxFindResourceHandle( MAKEINTRESOURCE(nIDResource), RT_BITMAP), MAKEINTRESOURCEW(nIDResource))); } _AFXWIN_INLINE BOOL CBitmap::LoadOEMBitmap(UINT nIDBitmap) { return Attach(::LoadBitmapW(NULL, MAKEINTRESOURCEW(nIDBitmap))); } _AFXWIN_INLINE BOOL CBitmap::CreateCompatibleBitmap(CDC* pDC, int nWidth, int nHeight) { return Attach(::CreateCompatibleBitmap(pDC->m_hDC, nWidth, nHeight)); } _AFXWIN_INLINE BOOL CBitmap::CreateDiscardableBitmap(CDC* pDC, int nWidth, int nHeight) { return Attach(::CreateDiscardableBitmap(pDC->m_hDC, nWidth, nHeight)); } _AFXWIN_INLINE int CBitmap::GetBitmap(BITMAP* pBitMap) { ASSERT(m_hObject != NULL); return ::GetObject(m_hObject, sizeof(BITMAP), pBitMap); } // CPalette _AFXWIN_INLINE CPalette::operator HPALETTE() const { return (HPALETTE)(this == NULL ? NULL : m_hObject); } _AFXWIN_INLINE CPalette* PASCAL CPalette::FromHandle(HPALETTE hPalette) { return (CPalette*) CGdiObject::FromHandle(hPalette); } _AFXWIN_INLINE CPalette::CPalette() { } _AFXWIN_INLINE CPalette::~CPalette() { } _AFXWIN_INLINE BOOL CPalette::CreatePalette(LPLOGPALETTE lpLogPalette) { return Attach(::CreatePalette(lpLogPalette)); } _AFXWIN_INLINE BOOL CPalette::CreateHalftonePalette(CDC* pDC) { ASSERT(pDC != NULL && pDC->m_hDC != NULL); return Attach( ::CreateHalftonePalette(pDC->m_hDC)); } _AFXWIN_INLINE UINT CPalette::GetPaletteEntries(UINT nStartIndex, UINT nNumEntries, LPPALETTEENTRY lpPaletteColors) const { ASSERT(m_hObject != NULL); return ::GetPaletteEntries((HPALETTE)m_hObject, nStartIndex, nNumEntries, lpPaletteColors); } _AFXWIN_INLINE UINT CPalette::SetPaletteEntries(UINT nStartIndex, UINT nNumEntries, LPPALETTEENTRY lpPaletteColors) { ASSERT(m_hObject != NULL); return ::SetPaletteEntries((HPALETTE)m_hObject, nStartIndex, nNumEntries, lpPaletteColors); } _AFXWIN_INLINE void CPalette::AnimatePalette(UINT nStartIndex, UINT nNumEntries, LPPALETTEENTRY lpPaletteColors) { ASSERT(m_hObject != NULL); ::AnimatePalette((HPALETTE)m_hObject, nStartIndex, nNumEntries, lpPaletteColors); } _AFXWIN_INLINE UINT CPalette::GetNearestPaletteIndex(COLORREF crColor) const { ASSERT(m_hObject != NULL); return ::GetNearestPaletteIndex((HPALETTE)m_hObject, crColor); } _AFXWIN_INLINE BOOL CPalette::ResizePalette(UINT nNumEntries) { ASSERT(m_hObject != NULL); return ::ResizePalette((HPALETTE)m_hObject, nNumEntries); } _AFXWIN_INLINE int CPalette::GetEntryCount() { ASSERT(m_hObject != NULL); WORD nEntries; ::GetObject(m_hObject, sizeof(WORD), &nEntries); return (int)nEntries; } // CRgn _AFXWIN_INLINE CRgn::operator HRGN() const { return (HRGN)(this == NULL ? NULL : m_hObject); } _AFXWIN_INLINE CRgn* PASCAL CRgn::FromHandle(HRGN hRgn) { return (CRgn*) CGdiObject::FromHandle(hRgn); } _AFXWIN_INLINE CRgn::CRgn() { } _AFXWIN_INLINE CRgn::~CRgn() { } _AFXWIN_INLINE BOOL CRgn::CreateRectRgn(int x1, int y1, int x2, int y2) { return Attach(::CreateRectRgn(x1, y1, x2, y2)); } _AFXWIN_INLINE BOOL CRgn::CreateRectRgnIndirect(LPCRECT lpRect) { return Attach(::CreateRectRgnIndirect(lpRect)); } _AFXWIN_INLINE BOOL CRgn::CreateEllipticRgn(int x1, int y1, int x2, int y2) { return Attach(::CreateEllipticRgn(x1, y1, x2, y2)); } _AFXWIN_INLINE BOOL CRgn::CreateEllipticRgnIndirect(LPCRECT lpRect) { return Attach(::CreateEllipticRgnIndirect(lpRect)); } _AFXWIN_INLINE BOOL CRgn::CreatePolygonRgn(LPPOINT lpPoints, int nCount, int nMode) { return Attach(::CreatePolygonRgn(lpPoints, nCount, nMode)); } _AFXWIN_INLINE BOOL CRgn::CreatePolyPolygonRgn(LPPOINT lpPoints, LPINT lpPolyCounts, int nCount, int nPolyFillMode) { return Attach(::CreatePolyPolygonRgn(lpPoints, lpPolyCounts, nCount, nPolyFillMode)); } _AFXWIN_INLINE BOOL CRgn::CreateRoundRectRgn(int x1, int y1, int x2, int y2, int x3, int y3) { return Attach(::CreateRoundRectRgn(x1, y1, x2, y2, x3, y3)); } _AFXWIN_INLINE BOOL CRgn::CreateFromPath(CDC* pDC) { ASSERT(pDC != NULL); return Attach(::PathToRegion(pDC->m_hDC)); } _AFXWIN_INLINE BOOL CRgn::CreateFromData(const XFORM* lpXForm, int nCount, const RGNDATA* pRgnData) { return Attach(::ExtCreateRegion(lpXForm, nCount, pRgnData)); } _AFXWIN_INLINE int CRgn::GetRegionData(LPRGNDATA lpRgnData, int nDataSize) const { ASSERT(m_hObject != NULL); return (int)::GetRegionData((HRGN)m_hObject, nDataSize, lpRgnData); } _AFXWIN_INLINE void CRgn::SetRectRgn(int x1, int y1, int x2, int y2) { ASSERT(m_hObject != NULL); ::SetRectRgn((HRGN)m_hObject, x1, y1, x2, y2); } _AFXWIN_INLINE void CRgn::SetRectRgn(LPCRECT lpRect) { ASSERT(m_hObject != NULL); ::SetRectRgn((HRGN)m_hObject, lpRect->left, lpRect->top, lpRect->right, lpRect->bottom); } _AFXWIN_INLINE int CRgn::CombineRgn(const CRgn* pRgn1, const CRgn* pRgn2, int nCombineMode) { ASSERT(m_hObject != NULL); return ::CombineRgn((HRGN)m_hObject, (HRGN)pRgn1->GetSafeHandle(), (HRGN)pRgn2->GetSafeHandle(), nCombineMode); } _AFXWIN_INLINE int CRgn::CopyRgn(const CRgn* pRgnSrc) { ASSERT(m_hObject != NULL); return ::CombineRgn((HRGN)m_hObject, (HRGN)pRgnSrc->GetSafeHandle(), NULL, RGN_COPY); } _AFXWIN_INLINE BOOL CRgn::EqualRgn(const CRgn* pRgn) const { ASSERT(m_hObject != NULL); return ::EqualRgn((HRGN)m_hObject, (HRGN)pRgn->GetSafeHandle()); } _AFXWIN_INLINE int CRgn::OffsetRgn(int x, int y) { ASSERT(m_hObject != NULL); return ::OffsetRgn((HRGN)m_hObject, x, y); } _AFXWIN_INLINE int CRgn::OffsetRgn(POINT point) { ASSERT(m_hObject != NULL); return ::OffsetRgn((HRGN)m_hObject, point.x, point.y); } _AFXWIN_INLINE int CRgn::GetRgnBox(LPRECT lpRect) const { ASSERT(m_hObject != NULL); return ::GetRgnBox((HRGN)m_hObject, lpRect); } _AFXWIN_INLINE BOOL CRgn::PtInRegion(int x, int y) const { ASSERT(m_hObject != NULL); return ::PtInRegion((HRGN)m_hObject, x, y); } _AFXWIN_INLINE BOOL CRgn::PtInRegion(POINT point) const { ASSERT(m_hObject != NULL); return ::PtInRegion((HRGN)m_hObject, point.x, point.y); } _AFXWIN_INLINE BOOL CRgn::RectInRegion(LPCRECT lpRect) const { ASSERT(m_hObject != NULL); return ::RectInRegion((HRGN)m_hObject, lpRect); } // CDC _AFXWIN_INLINE CDC::operator HDC() const { return this == NULL ? NULL : m_hDC; } _AFXWIN_INLINE HDC CDC::GetSafeHdc() const { return this == NULL ? NULL : m_hDC; } _AFXWIN_INLINE CWnd* CDC::GetWindow() const { ASSERT(m_hDC != NULL); return CWnd::FromHandle(::WindowFromDC(m_hDC)); } _AFXWIN_INLINE BOOL CDC::IsPrinting() const { return m_bPrinting; } _AFXWIN_INLINE BOOL CDC::CreateDC(LPCTSTR lpszDriverName, LPCTSTR lpszDeviceName, LPCTSTR lpszOutput, const void* lpInitData) { return Attach(::CreateDC(lpszDriverName, lpszDeviceName, lpszOutput, (const DEVMODE*)lpInitData)); } _AFXWIN_INLINE BOOL CDC::CreateIC(LPCTSTR lpszDriverName, LPCTSTR lpszDeviceName, LPCTSTR lpszOutput, const void* lpInitData) { return Attach(::CreateIC(lpszDriverName, lpszDeviceName, lpszOutput, (const DEVMODE*) lpInitData)); } _AFXWIN_INLINE BOOL CDC::CreateCompatibleDC(CDC* pDC) { return Attach(::CreateCompatibleDC(pDC->GetSafeHdc())); } _AFXWIN_INLINE int CDC::ExcludeUpdateRgn(CWnd* pWnd) { ASSERT(m_hDC != NULL); return ::ExcludeUpdateRgn(m_hDC, pWnd->m_hWnd); } _AFXWIN_INLINE int CDC::GetDeviceCaps(int nIndex) const { ASSERT(m_hAttribDC != NULL); return ::GetDeviceCaps(m_hAttribDC, nIndex); } _AFXWIN_INLINE CPoint CDC::GetBrushOrg() const { ASSERT(m_hDC != NULL); POINT point; VERIFY(::GetBrushOrgEx(m_hDC, &point)); return point; } _AFXWIN_INLINE CPoint CDC::SetBrushOrg(int x, int y) { ASSERT(m_hDC != NULL); POINT point; VERIFY(::SetBrushOrgEx(m_hDC, x, y, &point)); return point; } _AFXWIN_INLINE CPoint CDC::SetBrushOrg(POINT point) { ASSERT(m_hDC != NULL); VERIFY(::SetBrushOrgEx(m_hDC, point.x, point.y, &point)); return point; } _AFXWIN_INLINE int CDC::EnumObjects(int nObjectType, int (CALLBACK* lpfn)(LPVOID, LPARAM), LPARAM lpData) { ASSERT(m_hAttribDC != NULL); return ::EnumObjects(m_hAttribDC, nObjectType, (GOBJENUMPROC)lpfn, lpData); } _AFXWIN_INLINE CBitmap* CDC::SelectObject(CBitmap* pBitmap) { ASSERT(m_hDC != NULL); return (CBitmap*) SelectGdiObject(m_hDC, pBitmap->GetSafeHandle()); } _AFXWIN_INLINE CGdiObject* CDC::SelectObject(CGdiObject* pObject) { ASSERT(m_hDC != NULL); return SelectGdiObject(m_hDC, pObject->GetSafeHandle()); } _AFXWIN_INLINE HGDIOBJ CDC::SelectObject(HGDIOBJ hObject) // Safe for NULL handles { ASSERT(m_hDC == m_hAttribDC); // ASSERT a simple CDC object return (hObject != NULL) ? ::SelectObject(m_hDC, hObject) : NULL; } _AFXWIN_INLINE COLORREF CDC::GetNearestColor(COLORREF crColor) const { ASSERT(m_hAttribDC != NULL); return ::GetNearestColor(m_hAttribDC, crColor); } _AFXWIN_INLINE UINT CDC::RealizePalette() { ASSERT(m_hDC != NULL); return ::RealizePalette(m_hDC); } _AFXWIN_INLINE void CDC::UpdateColors() { ASSERT(m_hDC != NULL); ::UpdateColors(m_hDC); } _AFXWIN_INLINE COLORREF CDC::GetBkColor() const { ASSERT(m_hAttribDC != NULL); return ::GetBkColor(m_hAttribDC); } _AFXWIN_INLINE int CDC::GetBkMode() const { ASSERT(m_hAttribDC != NULL); return ::GetBkMode(m_hAttribDC); } _AFXWIN_INLINE int CDC::GetPolyFillMode() const { ASSERT(m_hAttribDC != NULL); return ::GetPolyFillMode(m_hAttribDC); } _AFXWIN_INLINE int CDC::GetROP2() const { ASSERT(m_hAttribDC != NULL); return ::GetROP2(m_hAttribDC); } _AFXWIN_INLINE int CDC::GetStretchBltMode() const { ASSERT(m_hAttribDC != NULL); return ::GetStretchBltMode(m_hAttribDC); } _AFXWIN_INLINE COLORREF CDC::GetTextColor() const { ASSERT(m_hAttribDC != NULL); return ::GetTextColor(m_hAttribDC); } _AFXWIN_INLINE int CDC::GetMapMode() const { ASSERT(m_hAttribDC != NULL); return ::GetMapMode(m_hAttribDC); } _AFXWIN_INLINE int CDC::GetGraphicsMode() const { ASSERT(m_hAttribDC != NULL); return ::GetGraphicsMode(m_hAttribDC); } _AFXWIN_INLINE BOOL CDC::GetWorldTransform(XFORM* pXform) const { ASSERT(m_hAttribDC != NULL); return ::GetWorldTransform(m_hAttribDC,pXform); } _AFXWIN_INLINE CPoint CDC::GetViewportOrg() const { ASSERT(m_hAttribDC != NULL); POINT point; VERIFY(::GetViewportOrgEx(m_hAttribDC, &point)); return point; } _AFXWIN_INLINE CSize CDC::GetViewportExt() const { ASSERT(m_hAttribDC != NULL); SIZE size; VERIFY(::GetViewportExtEx(m_hAttribDC, &size)); return size; } _AFXWIN_INLINE CPoint CDC::GetWindowOrg() const { ASSERT(m_hAttribDC != NULL); POINT point; VERIFY(::GetWindowOrgEx(m_hAttribDC, &point)); return point; } _AFXWIN_INLINE CSize CDC::GetWindowExt() const { ASSERT(m_hAttribDC != NULL); SIZE size; VERIFY(::GetWindowExtEx(m_hAttribDC, &size)); return size; } // non-virtual helpers calling virtual mapping functions _AFXWIN_INLINE CPoint CDC::SetViewportOrg(POINT point) { ASSERT(m_hDC != NULL); return SetViewportOrg(point.x, point.y); } _AFXWIN_INLINE CSize CDC::SetViewportExt(SIZE size) { ASSERT(m_hDC != NULL); return SetViewportExt(size.cx, size.cy); } _AFXWIN_INLINE CPoint CDC::SetWindowOrg(POINT point) { ASSERT(m_hDC != NULL); return SetWindowOrg(point.x, point.y); } _AFXWIN_INLINE CSize CDC::SetWindowExt(SIZE size) { ASSERT(m_hDC != NULL); return SetWindowExt(size.cx, size.cy); } _AFXWIN_INLINE void CDC::DPtoLP(LPPOINT lpPoints, int nCount) const { ASSERT(m_hAttribDC != NULL); VERIFY(::DPtoLP(m_hAttribDC, lpPoints, nCount)); } _AFXWIN_INLINE void CDC::DPtoLP(LPRECT lpRect) const { ASSERT(m_hAttribDC != NULL); VERIFY(::DPtoLP(m_hAttribDC, (LPPOINT)lpRect, 2)); } _AFXWIN_INLINE void CDC::LPtoDP(LPPOINT lpPoints, int nCount) const { ASSERT(m_hAttribDC != NULL); VERIFY(::LPtoDP(m_hAttribDC, lpPoints, nCount)); } _AFXWIN_INLINE void CDC::LPtoDP(LPRECT lpRect) const { ASSERT(m_hAttribDC != NULL); VERIFY(::LPtoDP(m_hAttribDC, (LPPOINT)lpRect, 2)); } _AFXWIN_INLINE BOOL CDC::FillRgn(CRgn* pRgn, CBrush* pBrush) { ASSERT(m_hDC != NULL); return ::FillRgn(m_hDC, (HRGN)pRgn->GetSafeHandle(), (HBRUSH)pBrush->GetSafeHandle()); } _AFXWIN_INLINE BOOL CDC::FrameRgn(CRgn* pRgn, CBrush* pBrush, int nWidth, int nHeight) { ASSERT(m_hDC != NULL); return ::FrameRgn(m_hDC, (HRGN)pRgn->GetSafeHandle(), (HBRUSH)pBrush->GetSafeHandle(), nWidth, nHeight); } _AFXWIN_INLINE BOOL CDC::InvertRgn(CRgn* pRgn) { ASSERT(m_hDC != NULL); return ::InvertRgn(m_hDC, (HRGN)pRgn->GetSafeHandle()); } _AFXWIN_INLINE BOOL CDC::PaintRgn(CRgn* pRgn) { ASSERT(m_hDC != NULL); return ::PaintRgn(m_hDC, (HRGN)pRgn->GetSafeHandle()); } _AFXWIN_INLINE BOOL CDC::PtVisible(int x, int y) const { ASSERT(m_hDC != NULL); return ::PtVisible(m_hDC, x, y); } _AFXWIN_INLINE BOOL CDC::PtVisible(POINT point) const { ASSERT(m_hDC != NULL); return PtVisible(point.x, point.y); } // call virtual _AFXWIN_INLINE BOOL CDC::RectVisible(LPCRECT lpRect) const { ASSERT(m_hDC != NULL); return ::RectVisible(m_hDC, lpRect); } _AFXWIN_INLINE CPoint CDC::GetCurrentPosition() const { ASSERT(m_hAttribDC != NULL); POINT point; VERIFY(::GetCurrentPositionEx(m_hAttribDC, &point)); return point; } _AFXWIN_INLINE CPoint CDC::MoveTo(POINT point) { ASSERT(m_hDC != NULL); return MoveTo(point.x, point.y); } _AFXWIN_INLINE BOOL CDC::LineTo(POINT point) { ASSERT(m_hDC != NULL); return LineTo(point.x, point.y); } _AFXWIN_INLINE BOOL CDC::Arc(int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4) { ASSERT(m_hDC != NULL); return ::Arc(m_hDC, x1, y1, x2, y2, x3, y3, x4, y4); } _AFXWIN_INLINE BOOL CDC::Arc(LPCRECT lpRect, POINT ptStart, POINT ptEnd) { ASSERT(m_hDC != NULL); return ::Arc(m_hDC, lpRect->left, lpRect->top, lpRect->right, lpRect->bottom, ptStart.x, ptStart.y, ptEnd.x, ptEnd.y); } _AFXWIN_INLINE BOOL CDC::Polyline(const POINT* lpPoints, int nCount) { ASSERT(m_hDC != NULL); return ::Polyline(m_hDC, lpPoints, nCount); } _AFXWIN_INLINE void CDC::FillRect(LPCRECT lpRect, CBrush* pBrush) { ASSERT(m_hDC != NULL); ::FillRect(m_hDC, lpRect, (HBRUSH)pBrush->GetSafeHandle()); } _AFXWIN_INLINE void CDC::FrameRect(LPCRECT lpRect, CBrush* pBrush) { ASSERT(m_hDC != NULL); ::FrameRect(m_hDC, lpRect, (HBRUSH)pBrush->GetSafeHandle()); } _AFXWIN_INLINE void CDC::InvertRect(LPCRECT lpRect) { ASSERT(m_hDC != NULL); ::InvertRect(m_hDC, lpRect); } _AFXWIN_INLINE BOOL CDC::DrawIcon(int x, int y, HICON hIcon) { ASSERT(m_hDC != NULL); return ::DrawIcon(m_hDC, x, y, hIcon); } _AFXWIN_INLINE BOOL CDC::DrawIcon(POINT point, HICON hIcon) { ASSERT(m_hDC != NULL); return ::DrawIcon(m_hDC, point.x, point.y, hIcon); } _AFXWIN_INLINE BOOL CDC::DrawState(CPoint pt, CSize size, HBITMAP hBitmap, UINT nFlags, HBRUSH hBrush) { ASSERT(m_hDC != NULL); return ::DrawState(m_hDC, hBrush, NULL, (LPARAM)hBitmap, 0, pt.x, pt.y, size.cx, size.cy, nFlags|DST_BITMAP); } _AFXWIN_INLINE BOOL CDC::DrawState(CPoint pt, CSize size, CBitmap* pBitmap, UINT nFlags, CBrush* pBrush) { ASSERT(m_hDC != NULL); return ::DrawState(m_hDC, (HBRUSH)pBrush->GetSafeHandle(), NULL, (LPARAM)pBitmap->GetSafeHandle(), 0, pt.x, pt.y, size.cx, size.cy, nFlags|DST_BITMAP); } _AFXWIN_INLINE BOOL CDC::DrawState(CPoint pt, CSize size, HICON hIcon, UINT nFlags, HBRUSH hBrush) { ASSERT(m_hDC != NULL); return ::DrawState(m_hDC, hBrush, NULL, (LPARAM)hIcon, 0, pt.x, pt.y, size.cx, size.cy, nFlags|DST_ICON); } _AFXWIN_INLINE BOOL CDC::DrawState(CPoint pt, CSize size, HICON hIcon, UINT nFlags, CBrush* pBrush) { ASSERT(m_hDC != NULL); return ::DrawState(m_hDC, (HBRUSH)pBrush->GetSafeHandle(), NULL, (LPARAM)hIcon, 0, pt.x, pt.y, size.cx, size.cy, nFlags|DST_ICON); } _AFXWIN_INLINE BOOL CDC::DrawState(CPoint pt, CSize size, LPCTSTR lpszText, UINT nFlags, BOOL bPrefixText, int nTextLen, HBRUSH hBrush) { ASSERT(m_hDC != NULL); return ::DrawState(m_hDC, hBrush, NULL, (LPARAM)lpszText, (WPARAM)nTextLen, pt.x, pt.y, size.cx, size.cy, nFlags|(bPrefixText ? DST_PREFIXTEXT : DST_TEXT)); } _AFXWIN_INLINE BOOL CDC::DrawState(CPoint pt, CSize size, LPCTSTR lpszText, UINT nFlags, BOOL bPrefixText, int nTextLen, CBrush* pBrush) { ASSERT(m_hDC != NULL); return ::DrawState(m_hDC, (HBRUSH)pBrush->GetSafeHandle(), NULL, (LPARAM)lpszText, (WPARAM)nTextLen, pt.x, pt.y, size.cx, size.cy, nFlags|(bPrefixText ? DST_PREFIXTEXT : DST_TEXT)); } _AFXWIN_INLINE BOOL CDC::DrawState(CPoint pt, CSize size, DRAWSTATEPROC lpDrawProc, LPARAM lData, UINT nFlags, HBRUSH hBrush) { ASSERT(m_hDC != NULL); return ::DrawState(m_hDC, hBrush, lpDrawProc, lData, 0, pt.x, pt.y, size.cx, size.cy, nFlags|DST_COMPLEX); } _AFXWIN_INLINE BOOL CDC::DrawState(CPoint pt, CSize size, DRAWSTATEPROC lpDrawProc, LPARAM lData, UINT nFlags, CBrush* pBrush) { ASSERT(m_hDC != NULL); return ::DrawState(m_hDC, (HBRUSH)pBrush->GetSafeHandle(), lpDrawProc, lData, 0, pt.x, pt.y, size.cx, size.cy, nFlags|DST_COMPLEX); } _AFXWIN_INLINE BOOL CDC::DrawEdge(LPRECT lpRect, UINT nEdge, UINT nFlags) { ASSERT(m_hDC != NULL); return ::DrawEdge(m_hDC, lpRect, nEdge, nFlags); } _AFXWIN_INLINE BOOL CDC::DrawFrameControl(LPRECT lpRect, UINT nType, UINT nState) { ASSERT(m_hDC != NULL); return ::DrawFrameControl(m_hDC, lpRect, nType, nState); } _AFXWIN_INLINE BOOL CDC::Chord(int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4) { ASSERT(m_hDC != NULL); return ::Chord(m_hDC, x1, y1, x2, y2, x3, y3, x4, y4); } _AFXWIN_INLINE BOOL CDC::Chord(LPCRECT lpRect, POINT ptStart, POINT ptEnd) { ASSERT(m_hDC != NULL); return ::Chord(m_hDC, lpRect->left, lpRect->top, lpRect->right, lpRect->bottom, ptStart.x, ptStart.y, ptEnd.x, ptEnd.y); } _AFXWIN_INLINE void CDC::DrawFocusRect(LPCRECT lpRect) { ASSERT(m_hDC != NULL); ::DrawFocusRect(m_hDC, lpRect); } _AFXWIN_INLINE BOOL CDC::Ellipse(int x1, int y1, int x2, int y2) { ASSERT(m_hDC != NULL); return ::Ellipse(m_hDC, x1, y1, x2, y2); } _AFXWIN_INLINE BOOL CDC::Ellipse(LPCRECT lpRect) { ASSERT(m_hDC != NULL); return ::Ellipse(m_hDC, lpRect->left, lpRect->top, lpRect->right, lpRect->bottom); } _AFXWIN_INLINE BOOL CDC::Pie(int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4) { ASSERT(m_hDC != NULL); return ::Pie(m_hDC, x1, y1, x2, y2, x3, y3, x4, y4); } _AFXWIN_INLINE BOOL CDC::Pie(LPCRECT lpRect, POINT ptStart, POINT ptEnd) { ASSERT(m_hDC != NULL); return ::Pie(m_hDC, lpRect->left, lpRect->top, lpRect->right, lpRect->bottom, ptStart.x, ptStart.y, ptEnd.x, ptEnd.y); } _AFXWIN_INLINE BOOL CDC::Polygon(const POINT* lpPoints, int nCount) { ASSERT(m_hDC != NULL); return ::Polygon(m_hDC, lpPoints, nCount); } _AFXWIN_INLINE BOOL CDC::PolyPolygon(const POINT* lpPoints, const INT* lpPolyCounts, int nCount) { ASSERT(m_hDC != NULL); return ::PolyPolygon(m_hDC, lpPoints, lpPolyCounts, nCount); } _AFXWIN_INLINE BOOL CDC::Rectangle(int x1, int y1, int x2, int y2) { ASSERT(m_hDC != NULL); return ::Rectangle(m_hDC, x1, y1, x2, y2); } _AFXWIN_INLINE BOOL CDC::Rectangle(LPCRECT lpRect) { ASSERT(m_hDC != NULL); return ::Rectangle(m_hDC, lpRect->left, lpRect->top, lpRect->right, lpRect->bottom); } _AFXWIN_INLINE BOOL CDC::RoundRect(int x1, int y1, int x2, int y2, int x3, int y3) { ASSERT(m_hDC != NULL); return ::RoundRect(m_hDC, x1, y1, x2, y2, x3, y3); } _AFXWIN_INLINE BOOL CDC::RoundRect(LPCRECT lpRect, POINT point) { ASSERT(m_hDC != NULL); return ::RoundRect(m_hDC, lpRect->left, lpRect->top, lpRect->right, lpRect->bottom, point.x, point.y); } _AFXWIN_INLINE BOOL CDC::PatBlt(int x, int y, int nWidth, int nHeight, DWORD dwRop) { ASSERT(m_hDC != NULL); return ::PatBlt(m_hDC, x, y, nWidth, nHeight, dwRop); } _AFXWIN_INLINE BOOL CDC::BitBlt(int x, int y, int nWidth, int nHeight, CDC* pSrcDC, int xSrc, int ySrc, DWORD dwRop) { ASSERT(m_hDC != NULL); return ::BitBlt(m_hDC, x, y, nWidth, nHeight, pSrcDC->GetSafeHdc(), xSrc, ySrc, dwRop); } _AFXWIN_INLINE BOOL CDC::StretchBlt(int x, int y, int nWidth, int nHeight, CDC* pSrcDC, int xSrc, int ySrc, int nSrcWidth, int nSrcHeight, DWORD dwRop) { ASSERT(m_hDC != NULL); return ::StretchBlt(m_hDC, x, y, nWidth, nHeight, pSrcDC->GetSafeHdc(), xSrc, ySrc, nSrcWidth, nSrcHeight, dwRop); } _AFXWIN_INLINE COLORREF CDC::GetPixel(int x, int y) const { ASSERT(m_hDC != NULL); return ::GetPixel(m_hDC, x, y); } _AFXWIN_INLINE COLORREF CDC::GetPixel(POINT point) const { ASSERT(m_hDC != NULL); return ::GetPixel(m_hDC, point.x, point.y); } _AFXWIN_INLINE COLORREF CDC::SetPixel(int x, int y, COLORREF crColor) { ASSERT(m_hDC != NULL); return ::SetPixel(m_hDC, x, y, crColor); } _AFXWIN_INLINE COLORREF CDC::SetPixel(POINT point, COLORREF crColor) { ASSERT(m_hDC != NULL); return ::SetPixel(m_hDC, point.x, point.y, crColor); } _AFXWIN_INLINE BOOL CDC::FloodFill(int x, int y, COLORREF crColor) { ASSERT(m_hDC != NULL); return ::FloodFill(m_hDC, x, y, crColor); } _AFXWIN_INLINE BOOL CDC::ExtFloodFill(int x, int y, COLORREF crColor, UINT nFillType) { ASSERT(m_hDC != NULL); return ::ExtFloodFill(m_hDC, x, y, crColor, nFillType); } _AFXWIN_INLINE BOOL CDC::TextOut(int x, int y, LPCTSTR lpszString, int nCount) { ASSERT(m_hDC != NULL); return ::TextOut(m_hDC, x, y, lpszString, nCount); } _AFXWIN_INLINE BOOL CDC::TextOut(int x, int y, const CString& str) { ASSERT(m_hDC != NULL); return TextOut(x, y, (LPCTSTR)str, (int)str.GetLength()); } // call virtual _AFXWIN_INLINE BOOL CDC::ExtTextOut(int x, int y, UINT nOptions, LPCRECT lpRect, LPCTSTR lpszString, UINT nCount, LPINT lpDxWidths) { ASSERT(m_hDC != NULL); return ::ExtTextOut(m_hDC, x, y, nOptions, lpRect, lpszString, nCount, lpDxWidths); } _AFXWIN_INLINE BOOL CDC::ExtTextOut(int x, int y, UINT nOptions, LPCRECT lpRect, const CString& str, LPINT lpDxWidths) { ASSERT(m_hDC != NULL); return ::ExtTextOut(m_hDC, x, y, nOptions, lpRect, str, (UINT)str.GetLength(), lpDxWidths); } _AFXWIN_INLINE CSize CDC::TabbedTextOut(int x, int y, LPCTSTR lpszString, int nCount, int nTabPositions, LPINT lpnTabStopPositions, int nTabOrigin) { ASSERT(m_hDC != NULL); return ::TabbedTextOut(m_hDC, x, y, lpszString, nCount, nTabPositions, lpnTabStopPositions, nTabOrigin); } _AFXWIN_INLINE CSize CDC::TabbedTextOut(int x, int y, const CString& str, int nTabPositions, LPINT lpnTabStopPositions, int nTabOrigin) { ASSERT(m_hDC != NULL); return ::TabbedTextOut(m_hDC, x, y, str, (int)str.GetLength(), nTabPositions, lpnTabStopPositions, nTabOrigin); } _AFXWIN_INLINE int CDC::_AFX_FUNCNAME(DrawText)(LPCTSTR lpszString, int nCount, LPRECT lpRect, UINT nFormat) { ASSERT(m_hDC != NULL); return ::DrawText(m_hDC, lpszString, nCount, lpRect, nFormat); } _AFXWIN_INLINE int CDC::_AFX_FUNCNAME(DrawText)(const CString& str, LPRECT lpRect, UINT nFormat) { ASSERT(m_hDC != NULL); // these flags would modify the string ASSERT((nFormat & (DT_END_ELLIPSIS | DT_MODIFYSTRING)) != (DT_END_ELLIPSIS | DT_MODIFYSTRING)); ASSERT((nFormat & (DT_PATH_ELLIPSIS | DT_MODIFYSTRING)) != (DT_PATH_ELLIPSIS | DT_MODIFYSTRING)); return _AFX_FUNCNAME(DrawText)((LPCTSTR)str, (int)str.GetLength(), lpRect, nFormat); } _AFXWIN_INLINE int CDC::_AFX_FUNCNAME(DrawTextEx)(LPTSTR lpszString, int nCount, LPRECT lpRect, UINT nFormat, LPDRAWTEXTPARAMS lpDTParams) { ASSERT(m_hDC != NULL); return ::DrawTextEx(m_hDC, lpszString, nCount, lpRect, nFormat, lpDTParams); } _AFXWIN_INLINE int CDC::_AFX_FUNCNAME(DrawTextEx)(const CString& str, LPRECT lpRect, UINT nFormat, LPDRAWTEXTPARAMS lpDTParams) { ASSERT(m_hDC != NULL); // these flags would modify the string ASSERT((nFormat & (DT_END_ELLIPSIS | DT_MODIFYSTRING)) != (DT_END_ELLIPSIS | DT_MODIFYSTRING)); ASSERT((nFormat & (DT_PATH_ELLIPSIS | DT_MODIFYSTRING)) != (DT_PATH_ELLIPSIS | DT_MODIFYSTRING)); return _AFX_FUNCNAME(DrawTextEx)(const_cast<LPTSTR>((LPCTSTR)str), (int)str.GetLength(), lpRect, nFormat, lpDTParams); } #pragma push_macro("DrawText") #pragma push_macro("DrawTextEx") #undef DrawText #undef DrawTextEx _AFXWIN_INLINE int CDC::DrawText(LPCTSTR lpszString, int nCount, LPRECT lpRect, UINT nFormat) { return _AFX_FUNCNAME(DrawText)(lpszString, nCount, lpRect, nFormat); } _AFXWIN_INLINE int CDC::DrawText(const CString& str, LPRECT lpRect, UINT nFormat) { return _AFX_FUNCNAME(DrawText)(str, lpRect, nFormat); } _AFXWIN_INLINE int CDC::DrawTextEx(LPTSTR lpszString, int nCount, LPRECT lpRect, UINT nFormat, LPDRAWTEXTPARAMS lpDTParams) { return _AFX_FUNCNAME(DrawTextEx)(lpszString, nCount, lpRect, nFormat, lpDTParams); } _AFXWIN_INLINE int CDC::DrawTextEx(const CString& str, LPRECT lpRect, UINT nFormat, LPDRAWTEXTPARAMS lpDTParams) { return _AFX_FUNCNAME(DrawTextEx)(str, lpRect, nFormat, lpDTParams); } #pragma pop_macro("DrawText") #pragma pop_macro("DrawTextEx") _AFXWIN_INLINE CSize CDC::GetTextExtent(LPCTSTR lpszString, int nCount) const { ASSERT(m_hAttribDC != NULL); SIZE size; VERIFY(::GetTextExtentPoint32(m_hAttribDC, lpszString, nCount, &size)); return size; } _AFXWIN_INLINE CSize CDC::GetTextExtent(const CString& str) const { ASSERT(m_hAttribDC != NULL); SIZE size; VERIFY(::GetTextExtentPoint32(m_hAttribDC, str, (int)str.GetLength(), &size)); return size; } _AFXWIN_INLINE CSize CDC::GetOutputTextExtent(LPCTSTR lpszString, int nCount) const { ASSERT(m_hDC != NULL); SIZE size; VERIFY(::GetTextExtentPoint32(m_hDC, lpszString, nCount, &size)); return size; } _AFXWIN_INLINE CSize CDC::GetOutputTextExtent(const CString& str) const { ASSERT(m_hDC != NULL); SIZE size; VERIFY(::GetTextExtentPoint32(m_hDC, str, (int)str.GetLength(), &size)); return size; } _AFXWIN_INLINE CSize CDC::GetTabbedTextExtent(LPCTSTR lpszString, int nCount, int nTabPositions, LPINT lpnTabStopPositions) const { ASSERT(m_hAttribDC != NULL); return ::GetTabbedTextExtent(m_hAttribDC, lpszString, nCount, nTabPositions, lpnTabStopPositions); } _AFXWIN_INLINE CSize CDC::GetTabbedTextExtent(const CString& str, int nTabPositions, LPINT lpnTabStopPositions) const { ASSERT(m_hAttribDC != NULL); return ::GetTabbedTextExtent(m_hAttribDC, str, (int)str.GetLength(), nTabPositions, lpnTabStopPositions); } _AFXWIN_INLINE CSize CDC::GetOutputTabbedTextExtent(LPCTSTR lpszString, int nCount, int nTabPositions, LPINT lpnTabStopPositions) const { ASSERT(m_hDC != NULL); return ::GetTabbedTextExtent(m_hDC, lpszString, nCount, nTabPositions, lpnTabStopPositions); } _AFXWIN_INLINE CSize CDC::GetOutputTabbedTextExtent(const CString& str, int nTabPositions, LPINT lpnTabStopPositions) const { ASSERT(m_hDC != NULL); return ::GetTabbedTextExtent(m_hDC, str, (int)str.GetLength(), nTabPositions, lpnTabStopPositions); } _AFXWIN_INLINE BOOL CDC::GrayString(CBrush* pBrush, BOOL (CALLBACK* lpfnOutput)(HDC, LPARAM, int), LPARAM lpData, int nCount, int x, int y, int nWidth, int nHeight) { ASSERT(m_hDC != NULL); return ::GrayString(m_hDC, (HBRUSH)pBrush->GetSafeHandle(), (GRAYSTRINGPROC)lpfnOutput, lpData, nCount, x, y, nWidth, nHeight); } _AFXWIN_INLINE UINT CDC::GetTextAlign() const { ASSERT(m_hAttribDC != NULL); return ::GetTextAlign(m_hAttribDC); } _AFXWIN_INLINE int CDC::GetTextFace(_In_ int nCount, _Out_writes_to_(nCount, return) LPTSTR lpszFacename) const { ASSERT(m_hAttribDC != NULL); return ::GetTextFace(m_hAttribDC, nCount, lpszFacename); } _AFXWIN_INLINE int CDC::GetTextFace(CString& rString) const { ASSERT(m_hAttribDC != NULL); int nResult = ::GetTextFace(m_hAttribDC, 256, rString.GetBuffer(256)); rString.ReleaseBuffer(); return nResult; } _AFXWIN_INLINE BOOL CDC::_AFX_FUNCNAME(GetTextMetrics)(LPTEXTMETRIC lpMetrics) const { ASSERT(m_hAttribDC != NULL); return ::GetTextMetrics(m_hAttribDC, lpMetrics); } #pragma push_macro("GetTextMetrics") #undef GetTextMetrics _AFXWIN_INLINE BOOL CDC::GetTextMetrics(LPTEXTMETRIC lpMetrics) const { return _AFX_FUNCNAME(GetTextMetrics)(lpMetrics); } #pragma pop_macro("GetTextMetrics") _AFXWIN_INLINE BOOL CDC::GetOutputTextMetrics(LPTEXTMETRIC lpMetrics) const { ASSERT(m_hDC != NULL); return ::GetTextMetrics(m_hDC, lpMetrics); } _AFXWIN_INLINE int CDC::GetTextCharacterExtra() const { ASSERT(m_hAttribDC != NULL); return ::GetTextCharacterExtra(m_hAttribDC); } _AFXWIN_INLINE BOOL CDC::GetCharWidth(UINT nFirstChar, UINT nLastChar, LPINT lpBuffer) const { ASSERT(m_hAttribDC != NULL); return ::GetCharWidth(m_hAttribDC, nFirstChar, nLastChar, lpBuffer); } _AFXWIN_INLINE BOOL CDC::GetOutputCharWidth(UINT nFirstChar, UINT nLastChar, LPINT lpBuffer) const { ASSERT(m_hDC != NULL); return ::GetCharWidth(m_hDC, nFirstChar, nLastChar, lpBuffer); } _AFXWIN_INLINE DWORD CDC::GetFontLanguageInfo() const { ASSERT(m_hDC != NULL); return ::GetFontLanguageInfo(m_hDC); } _AFXWIN_INLINE DWORD CDC::GetCharacterPlacement(LPCTSTR lpString, int nCount, int nMaxExtent, LPGCP_RESULTS lpResults, DWORD dwFlags) const { ASSERT(m_hDC != NULL); return ::GetCharacterPlacement(m_hDC, lpString, nCount, nMaxExtent, lpResults, dwFlags); } _AFXWIN_INLINE DWORD CDC::GetCharacterPlacement(CString& str, int nMaxExtent, LPGCP_RESULTS lpResults, DWORD dwFlags) const { ASSERT(m_hDC != NULL); return ::GetCharacterPlacement(m_hDC, (LPCTSTR)str, str.GetLength(), nMaxExtent, lpResults, dwFlags); } _AFXWIN_INLINE CSize CDC::GetAspectRatioFilter() const { ASSERT(m_hAttribDC != NULL); SIZE size; VERIFY(::GetAspectRatioFilterEx(m_hAttribDC, &size)); return size; } _AFXWIN_INLINE BOOL CDC::ScrollDC(int dx, int dy, LPCRECT lpRectScroll, LPCRECT lpRectClip, CRgn* pRgnUpdate, LPRECT lpRectUpdate) { ASSERT(m_hDC != NULL); return ::ScrollDC(m_hDC, dx, dy, lpRectScroll, lpRectClip, (HRGN)pRgnUpdate->GetSafeHandle(), lpRectUpdate); } // Printer Escape Functions _AFXWIN_INLINE int CDC::Escape(_In_ int nEscape, _In_ int nCount, _In_reads_bytes_(nCount) LPCSTR lpszInData, _In_ LPVOID lpOutData) { ASSERT(m_hDC != NULL); return ::Escape(m_hDC, nEscape, nCount, lpszInData, lpOutData);} // CDC 3.1 Specific functions _AFXWIN_INLINE UINT CDC::SetBoundsRect(LPCRECT lpRectBounds, UINT flags) { ASSERT(m_hDC != NULL); return ::SetBoundsRect(m_hDC, lpRectBounds, flags); } _AFXWIN_INLINE UINT CDC::GetBoundsRect(LPRECT lpRectBounds, UINT flags) { ASSERT(m_hAttribDC != NULL); return ::GetBoundsRect(m_hAttribDC, lpRectBounds, flags); } _AFXWIN_INLINE BOOL CDC::ResetDC(const DEVMODE* lpDevMode) { ASSERT(m_hAttribDC != NULL); return ::ResetDC(m_hAttribDC, lpDevMode) != NULL; } _AFXWIN_INLINE UINT CDC::GetOutlineTextMetrics(UINT cbData, LPOUTLINETEXTMETRIC lpotm) const { ASSERT(m_hAttribDC != NULL); return ::GetOutlineTextMetrics(m_hAttribDC, cbData, lpotm); } _AFXWIN_INLINE BOOL CDC::GetCharABCWidths(UINT nFirstChar, UINT nLastChar, LPABC lpabc) const { ASSERT(m_hAttribDC != NULL); return ::GetCharABCWidths(m_hAttribDC, nFirstChar, nLastChar, lpabc); } _AFXWIN_INLINE DWORD CDC::GetFontData(DWORD dwTable, DWORD dwOffset, LPVOID lpData, DWORD cbData) const { ASSERT(m_hAttribDC != NULL); return ::GetFontData(m_hAttribDC, dwTable, dwOffset, lpData, cbData); } _AFXWIN_INLINE int CDC::GetKerningPairs(int nPairs, LPKERNINGPAIR lpkrnpair) const { ASSERT(m_hAttribDC != NULL); return ::GetKerningPairs(m_hAttribDC, nPairs, lpkrnpair); } _AFXWIN_INLINE DWORD CDC::GetGlyphOutline(UINT nChar, UINT nFormat, LPGLYPHMETRICS lpgm, DWORD cbBuffer, LPVOID lpBuffer, const MAT2* lpmat2) const { ASSERT(m_hAttribDC != NULL); return ::GetGlyphOutline(m_hAttribDC, nChar, nFormat, lpgm, cbBuffer, lpBuffer, lpmat2); } // Document handling functions _AFXWIN_INLINE int CDC::StartDoc(LPDOCINFO lpDocInfo) { ASSERT(m_hDC != NULL); return ::StartDoc(m_hDC, lpDocInfo); } _AFXWIN_INLINE int CDC::StartPage() { ASSERT(m_hDC != NULL); return ::StartPage(m_hDC); } _AFXWIN_INLINE int CDC::EndPage() { ASSERT(m_hDC != NULL); return ::EndPage(m_hDC); } _AFXWIN_INLINE int CDC::SetAbortProc(BOOL (CALLBACK* lpfn)(HDC, int)) { ASSERT(m_hDC != NULL); return ::SetAbortProc(m_hDC, (ABORTPROC)lpfn); } _AFXWIN_INLINE int CDC::AbortDoc() { ASSERT(m_hDC != NULL); return ::AbortDoc(m_hDC); } _AFXWIN_INLINE int CDC::EndDoc() { ASSERT(m_hDC != NULL); return ::EndDoc(m_hDC); } _AFXWIN_INLINE BOOL CDC::MaskBlt(int x, int y, int nWidth, int nHeight, CDC* pSrcDC, int xSrc, int ySrc, CBitmap& maskBitmap, int xMask, int yMask, DWORD dwRop) { ASSERT(m_hDC != NULL); return ::MaskBlt(m_hDC, x, y, nWidth, nHeight, pSrcDC->GetSafeHdc(), xSrc, ySrc, (HBITMAP)maskBitmap.m_hObject, xMask, yMask, dwRop); } _AFXWIN_INLINE BOOL CDC::PlgBlt(LPPOINT lpPoint, CDC* pSrcDC, int xSrc, int ySrc, int nWidth, int nHeight, CBitmap& maskBitmap, int xMask, int yMask) { ASSERT(m_hDC != NULL); return ::PlgBlt(m_hDC, lpPoint, pSrcDC->GetSafeHdc(), xSrc, ySrc, nWidth, nHeight, (HBITMAP)maskBitmap.m_hObject, xMask, yMask); } _AFXWIN_INLINE BOOL CDC::SetPixelV(int x, int y, COLORREF crColor) { ASSERT(m_hDC != NULL); return ::SetPixelV(m_hDC, x, y, crColor); } _AFXWIN_INLINE BOOL CDC::SetPixelV(POINT point, COLORREF crColor) { ASSERT(m_hDC != NULL); return ::SetPixelV(m_hDC, point.x, point.y, crColor); } _AFXWIN_INLINE BOOL CDC::AngleArc(int x, int y, int nRadius, float fStartAngle, float fSweepAngle) { ASSERT(m_hDC != NULL); return ::AngleArc(m_hDC, x, y, nRadius, fStartAngle, fSweepAngle); } _AFXWIN_INLINE BOOL CDC::ArcTo(LPCRECT lpRect, POINT ptStart, POINT ptEnd) { ASSERT(m_hDC != NULL); return ArcTo(lpRect->left, lpRect->top, lpRect->right, lpRect->bottom, ptStart.x, ptStart.y, ptEnd.x, ptEnd.y); } _AFXWIN_INLINE int CDC::GetArcDirection() const { ASSERT(m_hAttribDC != NULL); return ::GetArcDirection(m_hAttribDC); } _AFXWIN_INLINE BOOL CDC::PolyPolyline(const POINT* lpPoints, const DWORD* lpPolyPoints, int nCount) { ASSERT(m_hDC != NULL); return ::PolyPolyline(m_hDC, lpPoints, lpPolyPoints, nCount); } _AFXWIN_INLINE BOOL CDC::GetColorAdjustment(LPCOLORADJUSTMENT lpColorAdjust) const { ASSERT(m_hAttribDC != NULL); return ::GetColorAdjustment(m_hAttribDC, lpColorAdjust); } _AFXWIN_INLINE CPen* CDC::GetCurrentPen() const { ASSERT(m_hAttribDC != NULL); return CPen::FromHandle((HPEN)::GetCurrentObject(m_hAttribDC, OBJ_PEN)); } _AFXWIN_INLINE CBrush* CDC::GetCurrentBrush() const { ASSERT(m_hAttribDC != NULL); return CBrush::FromHandle((HBRUSH)::GetCurrentObject(m_hAttribDC, OBJ_BRUSH)); } _AFXWIN_INLINE CPalette* CDC::GetCurrentPalette() const { ASSERT(m_hAttribDC != NULL); return CPalette::FromHandle((HPALETTE)::GetCurrentObject(m_hAttribDC, OBJ_PAL)); } _AFXWIN_INLINE CFont* CDC::GetCurrentFont() const { ASSERT(m_hAttribDC != NULL); return CFont::FromHandle((HFONT)::GetCurrentObject(m_hAttribDC, OBJ_FONT)); } _AFXWIN_INLINE CBitmap* CDC::GetCurrentBitmap() const { ASSERT(m_hAttribDC != NULL); return CBitmap::FromHandle((HBITMAP)::GetCurrentObject(m_hAttribDC, OBJ_BITMAP)); } _AFXWIN_INLINE BOOL CDC::PolyBezier(const POINT* lpPoints, int nCount) { ASSERT(m_hDC != NULL); return ::PolyBezier(m_hDC, lpPoints, nCount); } _AFXWIN_INLINE int CDC::DrawEscape(int nEscape, int nInputSize, LPCSTR lpszInputData) { ASSERT(m_hDC != NULL); return ::DrawEscape(m_hDC, nEscape, nInputSize, lpszInputData); } _AFXWIN_INLINE int CDC::Escape(_In_ int nEscape, _In_ int nInputSize, _In_reads_bytes_(nInputSize) LPCSTR lpszInputData, _In_ int nOutputSize, _Out_writes_bytes_(nOutputSize) LPSTR lpszOutputData) { ASSERT(m_hDC != NULL); return ::ExtEscape(m_hDC, nEscape, nInputSize, lpszInputData, nOutputSize, lpszOutputData); } _AFXWIN_INLINE BOOL CDC::GetCharABCWidths(UINT nFirstChar, UINT nLastChar, LPABCFLOAT lpABCF) const { ASSERT(m_hAttribDC != NULL); return ::GetCharABCWidthsFloat(m_hAttribDC, nFirstChar, nLastChar, lpABCF); } _AFXWIN_INLINE BOOL CDC::GetCharWidth(UINT nFirstChar, UINT nLastChar, float* lpFloatBuffer) const { ASSERT(m_hAttribDC != NULL); return ::GetCharWidthFloat(m_hAttribDC, nFirstChar, nLastChar, lpFloatBuffer); } _AFXWIN_INLINE BOOL CDC::AbortPath() { ASSERT(m_hDC != NULL); return ::AbortPath(m_hDC); } _AFXWIN_INLINE BOOL CDC::BeginPath() { ASSERT(m_hDC != NULL); return ::BeginPath(m_hDC); } _AFXWIN_INLINE BOOL CDC::CloseFigure() { ASSERT(m_hDC != NULL); return ::CloseFigure(m_hDC); } _AFXWIN_INLINE BOOL CDC::EndPath() { ASSERT(m_hDC != NULL); return ::EndPath(m_hDC); } _AFXWIN_INLINE BOOL CDC::FillPath() { ASSERT(m_hDC != NULL); return ::FillPath(m_hDC); } _AFXWIN_INLINE BOOL CDC::FlattenPath() { ASSERT(m_hDC != NULL); return ::FlattenPath(m_hDC); } _AFXWIN_INLINE float CDC::GetMiterLimit() const { ASSERT(m_hDC != NULL); float fMiterLimit; VERIFY(::GetMiterLimit(m_hDC, &fMiterLimit)); return fMiterLimit; } _AFXWIN_INLINE int CDC::GetPath(LPPOINT lpPoints, LPBYTE lpTypes, int nCount) const { ASSERT(m_hDC != NULL); return ::GetPath(m_hDC, lpPoints, lpTypes, nCount); } _AFXWIN_INLINE BOOL CDC::SetMiterLimit(float fMiterLimit) { ASSERT(m_hDC != NULL); return ::SetMiterLimit(m_hDC, fMiterLimit, NULL); } _AFXWIN_INLINE BOOL CDC::StrokeAndFillPath() { ASSERT(m_hDC != NULL); return ::StrokeAndFillPath(m_hDC); } _AFXWIN_INLINE BOOL CDC::StrokePath() { ASSERT(m_hDC != NULL); return ::StrokePath(m_hDC); } _AFXWIN_INLINE BOOL CDC::WidenPath() { ASSERT(m_hDC != NULL); return ::WidenPath(m_hDC); } _AFXWIN_INLINE BOOL CDC::AddMetaFileComment(UINT nDataSize, const BYTE* pCommentData) { ASSERT(m_hDC != NULL); return ::GdiComment(m_hDC, nDataSize, pCommentData); } _AFXWIN_INLINE BOOL CDC::PlayMetaFile(HENHMETAFILE hEnhMF, LPCRECT lpBounds) { ASSERT(m_hDC != NULL); return ::PlayEnhMetaFile(m_hDC, hEnhMF, lpBounds); } ///////////////////////////////////////////////////////////////////////////// // CImageList _AFXWIN_INLINE CImageList::operator HIMAGELIST() const { return m_hImageList;} _AFXWIN_INLINE HIMAGELIST CImageList::GetSafeHandle() const { return (this == NULL) ? NULL : m_hImageList; } _AFXWIN_INLINE int CImageList::GetImageCount() const { ASSERT(m_hImageList != NULL); return ImageList_GetImageCount(m_hImageList); } _AFXWIN_INLINE int CImageList::Add(CBitmap* pbmImage, CBitmap* pbmMask) { ASSERT(m_hImageList != NULL); return ImageList_Add(m_hImageList, (HBITMAP)pbmImage->GetSafeHandle(), (HBITMAP)pbmMask->GetSafeHandle()); } _AFXWIN_INLINE int CImageList::Add(CBitmap* pbmImage, COLORREF crMask) { ASSERT(m_hImageList != NULL); return ImageList_AddMasked(m_hImageList, (HBITMAP)pbmImage->GetSafeHandle(), crMask); } _AFXWIN_INLINE BOOL CImageList::Remove(int nImage) { ASSERT(m_hImageList != NULL); return ImageList_Remove(m_hImageList, nImage); } _AFXWIN_INLINE BOOL CImageList::Replace(int nImage, CBitmap* pbmImage, CBitmap* pbmMask) { ASSERT(m_hImageList != NULL); return ImageList_Replace(m_hImageList, nImage, (HBITMAP)pbmImage->GetSafeHandle(), (HBITMAP)pbmMask->GetSafeHandle()); } _AFXWIN_INLINE int CImageList::Add(HICON hIcon) { ASSERT(m_hImageList != NULL); return ImageList_AddIcon(m_hImageList, hIcon); } _AFXWIN_INLINE int CImageList::Replace(int nImage, HICON hIcon) { ASSERT(m_hImageList != NULL); return ImageList_ReplaceIcon(m_hImageList, nImage, hIcon); } _AFXWIN_INLINE HICON CImageList::ExtractIcon(int nImage) { ASSERT(m_hImageList != NULL); return ImageList_ExtractIcon(NULL, m_hImageList, nImage); } _AFXWIN_INLINE BOOL CImageList::Draw(CDC* pDC, int nImage, POINT pt, UINT nStyle) { ASSERT(m_hImageList != NULL); ASSERT(pDC != NULL); return ImageList_Draw(m_hImageList, nImage, pDC->GetSafeHdc(), pt.x, pt.y, nStyle); } _AFXWIN_INLINE BOOL CImageList::DrawEx(CDC* pDC, int nImage, POINT pt, SIZE sz, COLORREF clrBk, COLORREF clrFg, UINT nStyle) { ASSERT(m_hImageList != NULL); ASSERT(pDC != NULL); return ImageList_DrawEx(m_hImageList, nImage, pDC->GetSafeHdc(), pt.x, pt.y, sz.cx, sz.cy, clrBk, clrFg, nStyle); } _AFXWIN_INLINE COLORREF CImageList::SetBkColor(COLORREF cr) { ASSERT(m_hImageList != NULL); return ImageList_SetBkColor(m_hImageList, cr); } _AFXWIN_INLINE COLORREF CImageList::GetBkColor() const { ASSERT(m_hImageList != NULL); return ImageList_GetBkColor(m_hImageList); } _AFXWIN_INLINE BOOL CImageList::SetOverlayImage(int nImage, int nOverlay) { ASSERT(m_hImageList != NULL); return ImageList_SetOverlayImage(m_hImageList, nImage, nOverlay); } _AFXWIN_INLINE BOOL CImageList::GetImageInfo(int nImage, IMAGEINFO* pImageInfo) const { ASSERT(m_hImageList != NULL); return ImageList_GetImageInfo(m_hImageList, nImage, pImageInfo); } _AFXWIN_INLINE BOOL CImageList::BeginDrag(int nImage, CPoint ptHotSpot) { ASSERT(m_hImageList != NULL); return ImageList_BeginDrag(m_hImageList, nImage, ptHotSpot.x, ptHotSpot.y); } _AFXWIN_INLINE void PASCAL CImageList::EndDrag() { ImageList_EndDrag(); } _AFXWIN_INLINE BOOL PASCAL CImageList::DragMove(CPoint pt) { return ImageList_DragMove(pt.x, pt.y); } _AFXWIN_INLINE BOOL CImageList::SetDragCursorImage(int nDrag, CPoint ptHotSpot) { ASSERT(m_hImageList != NULL); return ImageList_SetDragCursorImage(m_hImageList, nDrag, ptHotSpot.x, ptHotSpot.y); } _AFXWIN_INLINE BOOL PASCAL CImageList::DragShowNolock(BOOL bShow) {return ImageList_DragShowNolock(bShow);} _AFXWIN_INLINE CImageList* PASCAL CImageList::GetDragImage(LPPOINT lpPoint, LPPOINT lpPointHotSpot) {return CImageList::FromHandle(ImageList_GetDragImage(lpPoint, lpPointHotSpot));} _AFXWIN_INLINE BOOL PASCAL CImageList::DragEnter(CWnd* pWndLock, CPoint point) { return ImageList_DragEnter(pWndLock->GetSafeHwnd(), point.x, point.y); } _AFXWIN_INLINE BOOL PASCAL CImageList::DragLeave(CWnd* pWndLock) { return ImageList_DragLeave(pWndLock->GetSafeHwnd()); } ///////////////////////////////////////////////////////////////////////////// // CMenu _AFXWIN_INLINE CMenu::CMenu() { m_hMenu = NULL; } _AFXWIN_INLINE CMenu::~CMenu() { DestroyMenu(); } _AFXWIN_INLINE BOOL CMenu::CreateMenu() { return Attach(::CreateMenu()); } _AFXWIN_INLINE BOOL CMenu::CreatePopupMenu() { return Attach(::CreatePopupMenu()); } _AFXWIN_INLINE CMenu::operator HMENU() const { ASSERT(this == NULL || m_hMenu == NULL || ::IsMenu(m_hMenu)); return this == NULL ? NULL : m_hMenu; } _AFXWIN_INLINE BOOL CMenu::operator==(const CMenu& menu) const { return ((HMENU) menu) == m_hMenu; } _AFXWIN_INLINE BOOL CMenu::operator!=(const CMenu& menu) const { return ((HMENU) menu) != m_hMenu; } _AFXWIN_INLINE HMENU CMenu::GetSafeHmenu() const { ASSERT(this == NULL || m_hMenu == NULL || ::IsMenu(m_hMenu)); return this == NULL ? NULL : m_hMenu; } _AFXWIN_INLINE BOOL CMenu::DeleteMenu(UINT nPosition, UINT nFlags) { ASSERT(::IsMenu(m_hMenu)); return ::DeleteMenu(m_hMenu, nPosition, nFlags); } _AFXWIN_INLINE BOOL CMenu::AppendMenu(UINT nFlags, UINT_PTR nIDNewItem, LPCTSTR lpszNewItem) { ASSERT(::IsMenu(m_hMenu)); return ::AppendMenu(m_hMenu, nFlags, nIDNewItem, lpszNewItem); } _AFXWIN_INLINE BOOL CMenu::AppendMenu(UINT nFlags, UINT_PTR nIDNewItem, const CBitmap* pBmp) { ASSERT(::IsMenu(m_hMenu)); return ::AppendMenu(m_hMenu, nFlags | MF_BITMAP, nIDNewItem, (LPCTSTR)pBmp->GetSafeHandle()); } _AFXWIN_INLINE UINT CMenu::CheckMenuItem(UINT nIDCheckItem, UINT nCheck) { ASSERT(::IsMenu(m_hMenu)); return (UINT)::CheckMenuItem(m_hMenu, nIDCheckItem, nCheck); } _AFXWIN_INLINE UINT CMenu::EnableMenuItem(UINT nIDEnableItem, UINT nEnable) { ASSERT(::IsMenu(m_hMenu)); return ::EnableMenuItem(m_hMenu, nIDEnableItem, nEnable); } _AFXWIN_INLINE BOOL CMenu::SetDefaultItem(UINT uItem, BOOL fByPos) { ASSERT(::IsMenu(m_hMenu)); return ::SetMenuDefaultItem(m_hMenu, uItem, fByPos); } _AFXWIN_INLINE UINT CMenu::GetDefaultItem(UINT gmdiFlags, BOOL fByPos) { ASSERT(::IsMenu(m_hMenu)); return ::GetMenuDefaultItem(m_hMenu, fByPos, gmdiFlags); } _AFXWIN_INLINE int CMenu::GetMenuItemCount() const { ASSERT(::IsMenu(m_hMenu)); return ::GetMenuItemCount(m_hMenu); } _AFXWIN_INLINE UINT CMenu::GetMenuItemID(int nPos) const { ASSERT(::IsMenu(m_hMenu)); return ::GetMenuItemID(m_hMenu, nPos); } _AFXWIN_INLINE UINT CMenu::GetMenuState(UINT nID, UINT nFlags) const { ASSERT(::IsMenu(m_hMenu)); return ::GetMenuState(m_hMenu, nID, nFlags); } _AFXWIN_INLINE int CMenu::GetMenuString(_In_ UINT nIDItem, _Out_writes_z_(nMaxCount) LPTSTR lpString, _In_ int nMaxCount, _In_ UINT nFlags) const { ASSERT(::IsMenu(m_hMenu)); return ::GetMenuString(m_hMenu, nIDItem, lpString, nMaxCount, nFlags); } _AFXWIN_INLINE BOOL CMenu::GetMenuItemInfo(UINT uItem, LPMENUITEMINFO lpMenuItemInfo, BOOL fByPos) { ASSERT(::IsMenu(m_hMenu)); ASSERT_POINTER(lpMenuItemInfo, MENUITEMINFO); return ::GetMenuItemInfo(m_hMenu, uItem, fByPos, lpMenuItemInfo); } _AFXWIN_INLINE BOOL CMenu::SetMenuItemInfo(UINT uItem, LPMENUITEMINFO lpMenuItemInfo, BOOL fByPos) { ASSERT(::IsMenu(m_hMenu)); ASSERT_POINTER(lpMenuItemInfo, MENUITEMINFO); return ::SetMenuItemInfo(m_hMenu, uItem, fByPos, lpMenuItemInfo); } _AFXWIN_INLINE CMenu* CMenu::GetSubMenu(int nPos) const { ASSERT(::IsMenu(m_hMenu)); return CMenu::FromHandle(::GetSubMenu(m_hMenu, nPos)); } _AFXWIN_INLINE BOOL CMenu::InsertMenu(UINT nPosition, UINT nFlags, UINT_PTR nIDNewItem, LPCTSTR lpszNewItem) { ASSERT(::IsMenu(m_hMenu)); return ::InsertMenu(m_hMenu, nPosition, nFlags, nIDNewItem, lpszNewItem); } _AFXWIN_INLINE BOOL CMenu::InsertMenu(UINT nPosition, UINT nFlags, UINT_PTR nIDNewItem, const CBitmap* pBmp) { ASSERT(::IsMenu(m_hMenu)); return ::InsertMenu(m_hMenu, nPosition, nFlags | MF_BITMAP, nIDNewItem, (LPCTSTR)pBmp->GetSafeHandle()); } _AFXWIN_INLINE BOOL CMenu::InsertMenuItem(UINT uItem, LPMENUITEMINFO lpMenuItemInfo, BOOL fByPos) { ASSERT(::IsMenu(m_hMenu)); ASSERT_POINTER(lpMenuItemInfo, MENUITEMINFO); return ::InsertMenuItem(m_hMenu, uItem, fByPos, lpMenuItemInfo); } _AFXWIN_INLINE BOOL CMenu::ModifyMenu(UINT nPosition, UINT nFlags, UINT_PTR nIDNewItem, LPCTSTR lpszNewItem) { ASSERT(::IsMenu(m_hMenu)); return ::ModifyMenu(m_hMenu, nPosition, nFlags, nIDNewItem, lpszNewItem); } _AFXWIN_INLINE BOOL CMenu::ModifyMenu(UINT nPosition, UINT nFlags, UINT_PTR nIDNewItem, const CBitmap* pBmp) { ASSERT(::IsMenu(m_hMenu)); return ::ModifyMenu(m_hMenu, nPosition, nFlags | MF_BITMAP, nIDNewItem, (LPCTSTR)pBmp->GetSafeHandle()); } _AFXWIN_INLINE BOOL CMenu::RemoveMenu(UINT nPosition, UINT nFlags) { ASSERT(::IsMenu(m_hMenu)); return ::RemoveMenu(m_hMenu, nPosition, nFlags); } _AFXWIN_INLINE BOOL CMenu::SetMenuItemBitmaps(UINT nPosition, UINT nFlags, const CBitmap* pBmpUnchecked, const CBitmap* pBmpChecked) { ASSERT(::IsMenu(m_hMenu)); return ::SetMenuItemBitmaps(m_hMenu, nPosition, nFlags, (HBITMAP)pBmpUnchecked->GetSafeHandle(), (HBITMAP)pBmpChecked->GetSafeHandle()); } _AFXWIN_INLINE BOOL CMenu::LoadMenu(LPCTSTR lpszResourceName) { return Attach(::LoadMenu(AfxFindResourceHandle(lpszResourceName, RT_MENU), lpszResourceName)); } _AFXWIN_INLINE BOOL CMenu::LoadMenu(UINT nIDResource) { return Attach(::LoadMenuW(AfxFindResourceHandle( MAKEINTRESOURCE(nIDResource), RT_MENU), MAKEINTRESOURCEW(nIDResource))); } _AFXWIN_INLINE BOOL CMenu::LoadMenuIndirect(const void* lpMenuTemplate) { return Attach(::LoadMenuIndirect(lpMenuTemplate)); } // Win4 _AFXWIN_INLINE BOOL CMenu::SetMenuContextHelpId(DWORD dwContextHelpId) { return ::SetMenuContextHelpId(m_hMenu, dwContextHelpId); } _AFXWIN_INLINE DWORD CMenu::GetMenuContextHelpId() const { return ::GetMenuContextHelpId(m_hMenu); } _AFXWIN_INLINE BOOL CMenu::CheckMenuRadioItem(UINT nIDFirst, UINT nIDLast, UINT nIDItem, UINT nFlags) { return ::CheckMenuRadioItem(m_hMenu, nIDFirst, nIDLast, nIDItem, nFlags); } // CCmdUI _AFXWIN_INLINE void CCmdUI::ContinueRouting() { m_bContinueRouting = TRUE; } ///////////////////////////////////////////////////////////////////////////// #endif //_AFXWIN_INLINE
56.448795
169
0.754318
jackqk
b1c8689301f4fa2d10a66fd7f998595402734ebc
12,882
cpp
C++
src/d3d12/d3d12-constants.cpp
Impulse21/nvrhi
f272a6595dd0768a8e3419f0075f0edf40d00391
[ "MIT" ]
null
null
null
src/d3d12/d3d12-constants.cpp
Impulse21/nvrhi
f272a6595dd0768a8e3419f0075f0edf40d00391
[ "MIT" ]
null
null
null
src/d3d12/d3d12-constants.cpp
Impulse21/nvrhi
f272a6595dd0768a8e3419f0075f0edf40d00391
[ "MIT" ]
null
null
null
/* * Copyright (c) 2014-2021, NVIDIA CORPORATION. All rights reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ #include "d3d12-backend.h" namespace nvrhi::d3d12 { DXGI_FORMAT convertFormat(nvrhi::Format format) { return getDxgiFormatMapping(format).srvFormat; } D3D12_SHADER_VISIBILITY convertShaderStage(ShaderType s) { switch (s) // NOLINT(clang-diagnostic-switch-enum) { case ShaderType::Vertex: return D3D12_SHADER_VISIBILITY_VERTEX; case ShaderType::Hull: return D3D12_SHADER_VISIBILITY_HULL; case ShaderType::Domain: return D3D12_SHADER_VISIBILITY_DOMAIN; case ShaderType::Geometry: return D3D12_SHADER_VISIBILITY_GEOMETRY; case ShaderType::Pixel: return D3D12_SHADER_VISIBILITY_PIXEL; case ShaderType::Amplification: // TODO: PUTBACK->return D3D12_SHADER_VISIBILITY_AMPLIFICATION; case ShaderType::Mesh: // TODO: PUTBACK->return D3D12_SHADER_VISIBILITY_MESH; default: // catch-all case - actually some of the bitfield combinations are unrepresentable in DX12 return D3D12_SHADER_VISIBILITY_ALL; } } D3D12_BLEND convertBlendValue(BlendFactor value) { switch (value) { case BlendFactor::Zero: return D3D12_BLEND_ZERO; case BlendFactor::One: return D3D12_BLEND_ONE; case BlendFactor::SrcColor: return D3D12_BLEND_SRC_COLOR; case BlendFactor::InvSrcColor: return D3D12_BLEND_INV_SRC_COLOR; case BlendFactor::SrcAlpha: return D3D12_BLEND_SRC_ALPHA; case BlendFactor::InvSrcAlpha: return D3D12_BLEND_INV_SRC_ALPHA; case BlendFactor::DstAlpha: return D3D12_BLEND_DEST_ALPHA; case BlendFactor::InvDstAlpha: return D3D12_BLEND_INV_DEST_ALPHA; case BlendFactor::DstColor: return D3D12_BLEND_DEST_COLOR; case BlendFactor::InvDstColor: return D3D12_BLEND_INV_DEST_COLOR; case BlendFactor::SrcAlphaSaturate: return D3D12_BLEND_SRC_ALPHA_SAT; case BlendFactor::ConstantColor: return D3D12_BLEND_BLEND_FACTOR; case BlendFactor::InvConstantColor: return D3D12_BLEND_INV_BLEND_FACTOR; case BlendFactor::Src1Color: return D3D12_BLEND_SRC1_COLOR; case BlendFactor::InvSrc1Color: return D3D12_BLEND_INV_SRC1_COLOR; case BlendFactor::Src1Alpha: return D3D12_BLEND_SRC1_ALPHA; case BlendFactor::InvSrc1Alpha: return D3D12_BLEND_INV_SRC1_ALPHA; default: utils::InvalidEnum(); return D3D12_BLEND_ZERO; } } D3D12_BLEND_OP convertBlendOp(BlendOp value) { switch (value) { case BlendOp::Add: return D3D12_BLEND_OP_ADD; case BlendOp::Subrtact: return D3D12_BLEND_OP_SUBTRACT; case BlendOp::ReverseSubtract: return D3D12_BLEND_OP_REV_SUBTRACT; case BlendOp::Min: return D3D12_BLEND_OP_MIN; case BlendOp::Max: return D3D12_BLEND_OP_MAX; default: utils::InvalidEnum(); return D3D12_BLEND_OP_ADD; } } D3D12_STENCIL_OP convertStencilOp(StencilOp value) { switch (value) { case StencilOp::Keep: return D3D12_STENCIL_OP_KEEP; case StencilOp::Zero: return D3D12_STENCIL_OP_ZERO; case StencilOp::Replace: return D3D12_STENCIL_OP_REPLACE; case StencilOp::IncrementAndClamp: return D3D12_STENCIL_OP_INCR_SAT; case StencilOp::DecrementAndClamp: return D3D12_STENCIL_OP_DECR_SAT; case StencilOp::Invert: return D3D12_STENCIL_OP_INVERT; case StencilOp::IncrementAndWrap: return D3D12_STENCIL_OP_INCR; case StencilOp::DecrementAndWrap: return D3D12_STENCIL_OP_DECR; default: utils::InvalidEnum(); return D3D12_STENCIL_OP_KEEP; } } D3D12_COMPARISON_FUNC convertComparisonFunc(ComparisonFunc value) { switch (value) { case ComparisonFunc::Never: return D3D12_COMPARISON_FUNC_NEVER; case ComparisonFunc::Less: return D3D12_COMPARISON_FUNC_LESS; case ComparisonFunc::Equal: return D3D12_COMPARISON_FUNC_EQUAL; case ComparisonFunc::LessOrEqual: return D3D12_COMPARISON_FUNC_LESS_EQUAL; case ComparisonFunc::Greater: return D3D12_COMPARISON_FUNC_GREATER; case ComparisonFunc::NotEqual: return D3D12_COMPARISON_FUNC_NOT_EQUAL; case ComparisonFunc::GreaterOrEqual: return D3D12_COMPARISON_FUNC_GREATER_EQUAL; case ComparisonFunc::Always: return D3D12_COMPARISON_FUNC_ALWAYS; default: utils::InvalidEnum(); return D3D12_COMPARISON_FUNC_NEVER; } } D3D_PRIMITIVE_TOPOLOGY convertPrimitiveType(PrimitiveType pt, uint32_t controlPoints) { switch (pt) { case PrimitiveType::PointList: return D3D_PRIMITIVE_TOPOLOGY_POINTLIST; case PrimitiveType::LineList: return D3D11_PRIMITIVE_TOPOLOGY_LINELIST; case PrimitiveType::TriangleList: return D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST; case PrimitiveType::TriangleStrip: return D3D_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP; case PrimitiveType::TriangleFan: utils::NotSupported(); return D3D_PRIMITIVE_TOPOLOGY_UNDEFINED; case PrimitiveType::TriangleListWithAdjacency: return D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST_ADJ; case PrimitiveType::TriangleStripWithAdjacency: return D3D_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP_ADJ; case PrimitiveType::PatchList: if (controlPoints == 0 || controlPoints > 32) { utils::InvalidEnum(); return D3D_PRIMITIVE_TOPOLOGY_UNDEFINED; } return D3D_PRIMITIVE_TOPOLOGY(D3D_PRIMITIVE_TOPOLOGY_1_CONTROL_POINT_PATCHLIST + (controlPoints - 1)); default: return D3D_PRIMITIVE_TOPOLOGY_UNDEFINED; } } D3D12_TEXTURE_ADDRESS_MODE convertSamplerAddressMode(SamplerAddressMode mode) { switch (mode) { case SamplerAddressMode::Clamp: return D3D12_TEXTURE_ADDRESS_MODE_CLAMP; case SamplerAddressMode::Wrap: return D3D12_TEXTURE_ADDRESS_MODE_WRAP; case SamplerAddressMode::Border: return D3D12_TEXTURE_ADDRESS_MODE_BORDER; case SamplerAddressMode::Mirror: return D3D12_TEXTURE_ADDRESS_MODE_MIRROR; case SamplerAddressMode::MirrorOnce: return D3D12_TEXTURE_ADDRESS_MODE_MIRROR_ONCE; default: utils::InvalidEnum(); return D3D12_TEXTURE_ADDRESS_MODE_CLAMP; } } UINT convertSamplerReductionType(SamplerReductionType reductionType) { switch (reductionType) { case SamplerReductionType::Standard: return D3D12_FILTER_REDUCTION_TYPE_STANDARD; case SamplerReductionType::Comparison: return D3D12_FILTER_REDUCTION_TYPE_COMPARISON; case SamplerReductionType::Minimum: return D3D12_FILTER_REDUCTION_TYPE_MINIMUM; case SamplerReductionType::Maximum: return D3D12_FILTER_REDUCTION_TYPE_MAXIMUM; default: utils::InvalidEnum(); return D3D12_FILTER_REDUCTION_TYPE_STANDARD; } } D3D12_RESOURCE_STATES convertResourceStates(ResourceStates stateBits) { if (stateBits == ResourceStates::Common) return D3D12_RESOURCE_STATE_COMMON; D3D12_RESOURCE_STATES result = D3D12_RESOURCE_STATE_COMMON; // also 0 if ((stateBits & ResourceStates::ConstantBuffer) != 0) result |= D3D12_RESOURCE_STATE_VERTEX_AND_CONSTANT_BUFFER; if ((stateBits & ResourceStates::VertexBuffer) != 0) result |= D3D12_RESOURCE_STATE_VERTEX_AND_CONSTANT_BUFFER; if ((stateBits & ResourceStates::IndexBuffer) != 0) result |= D3D12_RESOURCE_STATE_INDEX_BUFFER; if ((stateBits & ResourceStates::IndirectArgument) != 0) result |= D3D12_RESOURCE_STATE_INDIRECT_ARGUMENT; if ((stateBits & ResourceStates::ShaderResource) != 0) result |= D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE | D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE; if ((stateBits & ResourceStates::UnorderedAccess) != 0) result |= D3D12_RESOURCE_STATE_UNORDERED_ACCESS; if ((stateBits & ResourceStates::RenderTarget) != 0) result |= D3D12_RESOURCE_STATE_RENDER_TARGET; if ((stateBits & ResourceStates::DepthWrite) != 0) result |= D3D12_RESOURCE_STATE_DEPTH_WRITE; if ((stateBits & ResourceStates::DepthRead) != 0) result |= D3D12_RESOURCE_STATE_DEPTH_READ; if ((stateBits & ResourceStates::StreamOut) != 0) result |= D3D12_RESOURCE_STATE_STREAM_OUT; if ((stateBits & ResourceStates::CopyDest) != 0) result |= D3D12_RESOURCE_STATE_COPY_DEST; if ((stateBits & ResourceStates::CopySource) != 0) result |= D3D12_RESOURCE_STATE_COPY_SOURCE; if ((stateBits & ResourceStates::ResolveDest) != 0) result |= D3D12_RESOURCE_STATE_RESOLVE_DEST; if ((stateBits & ResourceStates::ResolveSource) != 0) result |= D3D12_RESOURCE_STATE_RESOLVE_SOURCE; if ((stateBits & ResourceStates::Present) != 0) result |= D3D12_RESOURCE_STATE_PRESENT; if ((stateBits & ResourceStates::AccelStructRead) != 0) result |= D3D12_RESOURCE_STATE_RAYTRACING_ACCELERATION_STRUCTURE; if ((stateBits & ResourceStates::AccelStructWrite) != 0) result |= D3D12_RESOURCE_STATE_RAYTRACING_ACCELERATION_STRUCTURE; if ((stateBits & ResourceStates::AccelStructBuildInput) != 0) result |= D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE; if ((stateBits & ResourceStates::AccelStructBuildBlas) != 0) result |= D3D12_RESOURCE_STATE_RAYTRACING_ACCELERATION_STRUCTURE; if ((stateBits & ResourceStates::ShadingRateSurface) != 0) result |= D3D12_RESOURCE_STATE_SHADING_RATE_SOURCE; return result; } D3D12_SHADING_RATE convertPixelShadingRate(VariableShadingRate shadingRate) { switch (shadingRate) { case VariableShadingRate::e1x2: return D3D12_SHADING_RATE_1X2; case VariableShadingRate::e2x1: return D3D12_SHADING_RATE_2X1; case VariableShadingRate::e2x2: return D3D12_SHADING_RATE_2X2; case VariableShadingRate::e2x4: return D3D12_SHADING_RATE_2X4; case VariableShadingRate::e4x2: return D3D12_SHADING_RATE_4X2; case VariableShadingRate::e4x4: return D3D12_SHADING_RATE_4X4; case VariableShadingRate::e1x1: default: return D3D12_SHADING_RATE_1X1; } } D3D12_SHADING_RATE_COMBINER convertShadingRateCombiner(ShadingRateCombiner combiner) { switch (combiner) { case ShadingRateCombiner::Override: return D3D12_SHADING_RATE_COMBINER_OVERRIDE; case ShadingRateCombiner::Min: return D3D12_SHADING_RATE_COMBINER_MIN; case ShadingRateCombiner::Max: return D3D12_SHADING_RATE_COMBINER_MAX; case ShadingRateCombiner::ApplyRelative: return D3D12_SHADING_RATE_COMBINER_SUM; case ShadingRateCombiner::Passthrough: default: return D3D12_SHADING_RATE_COMBINER_PASSTHROUGH; } } } // namespace nvrhi::d3d12
41.288462
165
0.680562
Impulse21
b1c8d4cc5fec8a3d1323059870a603e5b4f1d80a
57
cpp
C++
libboost-format/tests/basics/driver.cpp
build2-packaging/boost
203d505dd3ba04ea50785bc8b247a295db5fc718
[ "BSL-1.0" ]
4
2021-02-23T11:24:33.000Z
2021-09-11T20:10:46.000Z
libboost-format/tests/basics/driver.cpp
build2-packaging/boost
203d505dd3ba04ea50785bc8b247a295db5fc718
[ "BSL-1.0" ]
null
null
null
libboost-format/tests/basics/driver.cpp
build2-packaging/boost
203d505dd3ba04ea50785bc8b247a295db5fc718
[ "BSL-1.0" ]
null
null
null
#include <boost/format.hpp> int main () { return 0; }
7.125
27
0.614035
build2-packaging
b1c970f0df9ed60d27c8752b36c0906ea73620f6
1,324
cpp
C++
Serna_Esteban.assignment1.09/event.cpp
Este-iv/Rouge_like_game
90cd68608276c593f2c2f5ab369ee149fc9fc6ec
[ "MIT" ]
null
null
null
Serna_Esteban.assignment1.09/event.cpp
Este-iv/Rouge_like_game
90cd68608276c593f2c2f5ab369ee149fc9fc6ec
[ "MIT" ]
null
null
null
Serna_Esteban.assignment1.09/event.cpp
Este-iv/Rouge_like_game
90cd68608276c593f2c2f5ab369ee149fc9fc6ec
[ "MIT" ]
null
null
null
#include "event.h" #include "character.h" static uint32_t next_event_number(void) { static uint32_t sequence_number; /* We need to special case the first PC insert, because monsters go * * into the queue before the PC. Pre-increment ensures that this * * starts at 1, so we can use a zero there. */ return ++sequence_number; } int32_t compare_events(const void *event1, const void *event2) { int32_t difference; difference = (((event_t *) event1)->time - ((event_t *) event2)->time); return difference ? difference : (((event_t *) event1)->sequence - ((event_t *) event2)->sequence); } event_t *new_event(dungeon_t *d, event_type_t t, void *v, uint32_t delay) { event_t *e; e = (event_t *) malloc(sizeof (*e)); e->type = t; e->time = d->time + delay; e->sequence = next_event_number(); switch (t) { case event_character_turn: e->c = (character *) v; } return e; } event_t *update_event(dungeon_t *d, event_t *e, uint32_t delay) { e->time = d->time + delay; e->sequence = next_event_number(); return e; } void event_delete(void *e) { event_t *event = (event_t *) e; switch (event->type) { case event_character_turn: character_delete(event->c); break; } free(event); }
21.354839
73
0.621601
Este-iv
b1caa1215da2e50636d8c3092c2ce18937cc0cf0
9,202
cc
C++
tests/core/test_core_interaction_control_manager.cc
nugulinux/nugu-linux
c166d61b2037247d4574b7f791c31ba79ceb575e
[ "Apache-2.0" ]
null
null
null
tests/core/test_core_interaction_control_manager.cc
nugulinux/nugu-linux
c166d61b2037247d4574b7f791c31ba79ceb575e
[ "Apache-2.0" ]
null
null
null
tests/core/test_core_interaction_control_manager.cc
nugulinux/nugu-linux
c166d61b2037247d4574b7f791c31ba79ceb575e
[ "Apache-2.0" ]
null
null
null
/* * Copyright (c) 2019 SK Telecom Co., Ltd. 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 <glib.h> #include <memory> #include <string> #include "interaction_control_manager.hh" using namespace NuguCore; class InteractionControlManagerListener : public IInteractionControlManagerListener { public: // param-1 (bool) : whether multi-turn // param-2 (int) : onModeChanged method call count using InteractionModeChecker = std::pair<bool, int>; public: void onHasMultiTurn() override { has_multi_turn = true; } void onModeChanged(bool is_multi_turn) override { if (mode_checker.first == is_multi_turn) mode_checker.second++; else mode_checker = { is_multi_turn, 1 }; if (!is_multi_turn) has_multi_turn = false; }; InteractionModeChecker getModeChecker() { return mode_checker; } bool hasMultiTurn() { return has_multi_turn; } private: InteractionModeChecker mode_checker = { false, 0 }; bool has_multi_turn = false; }; using TestModeChecker = InteractionControlManagerListener::InteractionModeChecker; typedef struct { std::shared_ptr<InteractionControlManager> ic_manager; std::shared_ptr<InteractionControlManagerListener> ic_manager_listener; std::shared_ptr<InteractionControlManagerListener> ic_manager_listener_snd; } TestFixture; static void setup(TestFixture* fixture, gconstpointer user_data) { fixture->ic_manager = std::make_shared<InteractionControlManager>(); fixture->ic_manager_listener = std::make_shared<InteractionControlManagerListener>(); fixture->ic_manager_listener_snd = std::make_shared<InteractionControlManagerListener>(); } static void teardown(TestFixture* fixture, gconstpointer user_data) { fixture->ic_manager_listener.reset(); fixture->ic_manager_listener_snd.reset(); fixture->ic_manager.reset(); } #define G_TEST_ADD_FUNC(name, func) \ g_test_add(name, TestFixture, nullptr, setup, func, teardown); static void test_interaction_control_manager_listener(TestFixture* fixture, gconstpointer ignored) { fixture->ic_manager->addListener(nullptr); g_assert(fixture->ic_manager->getListenerCount() == 0); fixture->ic_manager->addListener(fixture->ic_manager_listener.get()); g_assert(fixture->ic_manager->getListenerCount() == 1); // check whether same listener is added duplicately fixture->ic_manager->addListener(fixture->ic_manager_listener.get()); g_assert(fixture->ic_manager->getListenerCount() == 1); fixture->ic_manager->addListener(fixture->ic_manager_listener_snd.get()); g_assert(fixture->ic_manager->getListenerCount() == 2); fixture->ic_manager->removeListener(nullptr); g_assert(fixture->ic_manager->getListenerCount() == 2); fixture->ic_manager->removeListener(fixture->ic_manager_listener.get()); g_assert(fixture->ic_manager->getListenerCount() == 1); // check whether same listener is removed duplicately fixture->ic_manager->removeListener(fixture->ic_manager_listener.get()); g_assert(fixture->ic_manager->getListenerCount() == 1); fixture->ic_manager->removeListener(fixture->ic_manager_listener_snd.get()); g_assert(fixture->ic_manager->getListenerCount() == 0); } static void test_interaction_control_manager_single_requester(TestFixture* fixture, gconstpointer ignored) { fixture->ic_manager->addListener(fixture->ic_manager_listener.get()); g_assert(fixture->ic_manager_listener->getModeChecker() == (TestModeChecker { false, 0 })); fixture->ic_manager->start(InteractionMode::MULTI_TURN, ""); g_assert(fixture->ic_manager_listener->getModeChecker() == (TestModeChecker { false, 0 })); fixture->ic_manager->start(InteractionMode::NONE, "requester_1"); g_assert(fixture->ic_manager_listener->getModeChecker() == (TestModeChecker { false, 0 })); fixture->ic_manager->start(InteractionMode::MULTI_TURN, "requester_1"); g_assert(fixture->ic_manager_listener->getModeChecker() == (TestModeChecker { true, 1 })); // check whether callback is called duplicately when multi-turn is already set fixture->ic_manager->start(InteractionMode::MULTI_TURN, "requester_1"); g_assert(fixture->ic_manager_listener->getModeChecker() == (TestModeChecker { true, 1 })); fixture->ic_manager->finish(InteractionMode::MULTI_TURN, ""); g_assert(fixture->ic_manager_listener->getModeChecker() == (TestModeChecker { true, 1 })); fixture->ic_manager->finish(InteractionMode::MULTI_TURN, "requester_not_start"); g_assert(fixture->ic_manager_listener->getModeChecker() == (TestModeChecker { true, 1 })); fixture->ic_manager->finish(InteractionMode::MULTI_TURN, "requester_1"); g_assert(fixture->ic_manager_listener->getModeChecker() == (TestModeChecker { false, 1 })); // check whether callback is called duplicately when multi-turn is already unset fixture->ic_manager->finish(InteractionMode::MULTI_TURN, "requester_1"); g_assert(fixture->ic_manager_listener->getModeChecker() == (TestModeChecker { false, 1 })); } static void test_interaction_control_manager_multi_requester(TestFixture* fixture, gconstpointer ignored) { fixture->ic_manager->addListener(fixture->ic_manager_listener.get()); g_assert(fixture->ic_manager_listener->getModeChecker() == (TestModeChecker { false, 0 })); fixture->ic_manager->start(InteractionMode::MULTI_TURN, "requester_1"); g_assert(fixture->ic_manager_listener->getModeChecker() == (TestModeChecker { true, 1 })); fixture->ic_manager->start(InteractionMode::MULTI_TURN, "requester_2"); g_assert(fixture->ic_manager_listener->getModeChecker() == (TestModeChecker { true, 1 })); fixture->ic_manager->finish(InteractionMode::MULTI_TURN, "requester_1"); g_assert(fixture->ic_manager_listener->getModeChecker() == (TestModeChecker { true, 1 })); fixture->ic_manager->finish(InteractionMode::MULTI_TURN, "requester_2"); g_assert(fixture->ic_manager_listener->getModeChecker() == (TestModeChecker { false, 1 })); } static void test_interaction_control_manager_has_multi_turn(TestFixture* fixture, gconstpointer ignored) { fixture->ic_manager->addListener(fixture->ic_manager_listener.get()); g_assert(!fixture->ic_manager_listener->hasMultiTurn()); fixture->ic_manager->notifyHasMultiTurn(); g_assert(fixture->ic_manager_listener->hasMultiTurn()); } static void test_interaction_control_manager_clear(TestFixture* fixture, gconstpointer ignored) { fixture->ic_manager->addListener(fixture->ic_manager_listener.get()); g_assert(fixture->ic_manager_listener->getModeChecker() == (TestModeChecker { false, 0 })); fixture->ic_manager->start(InteractionMode::MULTI_TURN, "requester_1"); g_assert(fixture->ic_manager_listener->getModeChecker() == (TestModeChecker { true, 1 })); fixture->ic_manager->start(InteractionMode::MULTI_TURN, "requester_2"); g_assert(fixture->ic_manager_listener->getModeChecker() == (TestModeChecker { true, 1 })); fixture->ic_manager->clear(); g_assert(fixture->ic_manager_listener->getModeChecker() == (TestModeChecker { false, 1 })); } static void test_interaction_control_manager_reset(TestFixture* fixture, gconstpointer ignored) { const auto& requesters = fixture->ic_manager->getAllRequesters(); fixture->ic_manager->addListener(fixture->ic_manager_listener.get()); fixture->ic_manager->start(InteractionMode::MULTI_TURN, "requester_1"); fixture->ic_manager->start(InteractionMode::MULTI_TURN, "requester_2"); g_assert(requesters.size() == 2); fixture->ic_manager->reset(); g_assert(fixture->ic_manager->getListenerCount() == 1); g_assert(requesters.empty()); } int main(int argc, char* argv[]) { #if !GLIB_CHECK_VERSION(2, 36, 0) g_type_init(); #endif g_test_init(&argc, &argv, (void*)NULL); g_log_set_always_fatal((GLogLevelFlags)G_LOG_FATAL_MASK); G_TEST_ADD_FUNC("/core/InteractionControlManager/listener", test_interaction_control_manager_listener); G_TEST_ADD_FUNC("/core/InteractionControlManager/singleRequester", test_interaction_control_manager_single_requester); G_TEST_ADD_FUNC("/core/InteractionControlManager/multiRequester", test_interaction_control_manager_multi_requester); G_TEST_ADD_FUNC("/core/InteractionControlManager/hasMultiTurn", test_interaction_control_manager_has_multi_turn); G_TEST_ADD_FUNC("/core/InteractionControlManager/clear", test_interaction_control_manager_clear); G_TEST_ADD_FUNC("/core/InteractionControlManager/reset", test_interaction_control_manager_reset); return g_test_run(); }
41.264574
122
0.749185
nugulinux
b1cd6b21651ba38c4d8b89ef4b389a3d08f35c33
313
hxx
C++
type/is.hxx
blake-sheridan/include-b
16c1712e38f5bc423565e97de6b07eeca6a9223d
[ "MIT" ]
null
null
null
type/is.hxx
blake-sheridan/include-b
16c1712e38f5bc423565e97de6b07eeca6a9223d
[ "MIT" ]
null
null
null
type/is.hxx
blake-sheridan/include-b
16c1712e38f5bc423565e97de6b07eeca6a9223d
[ "MIT" ]
null
null
null
#ifndef b_type_is_hxx_ #define b_type_is_hxx_ namespace b { namespace type { /* * Variable template which is true iff `X` is `Y`. */ template <typename X, typename Y> static constexpr bool is = false; template <typename X> static constexpr bool is<X, X> = true; } // namespace type } // namespace b #endif
13.041667
50
0.70607
blake-sheridan
b1d7b0af58d668851ca7b8410165a609920ef712
3,816
cpp
C++
AnalysisExample/TaskA.cpp
MagdaSkurzok/PET_Analysis
1527d2658d574b494f9f9eb234166e6e1f220d4e
[ "Apache-2.0" ]
null
null
null
AnalysisExample/TaskA.cpp
MagdaSkurzok/PET_Analysis
1527d2658d574b494f9f9eb234166e6e1f220d4e
[ "Apache-2.0" ]
null
null
null
AnalysisExample/TaskA.cpp
MagdaSkurzok/PET_Analysis
1527d2658d574b494f9f9eb234166e6e1f220d4e
[ "Apache-2.0" ]
null
null
null
/** * @copyright Copyright 2016 The J-PET Framework 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 find a copy of the License in the LICENCE file. * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * @file TaskA.cpp */ #include "TaskA.h" #include "JPetWriter/JPetWriter.h" #include "JPetUnpacker/Unpacker2/EventIII.h" #include <iostream> //ClassImp(TaskA); TaskA::TaskA(const char * name, const char * description): JPetTask(name, description), fCurrEventNumber(0) { } void TaskA::exec() { // Get HLD Event auto evt = reinterpret_cast<EventIII*> (getEvent()); //evt->GetTitle(); //evt->GetName(); // get number of TDC channels which fired in one TSlot int ntdc = evt->GetTotalNTDCChannels(); JPetTimeWindow tslot; tslot.setIndex(fCurrEventNumber); // Get the array of TDC channels which fired TClonesArray* tdcHits = evt->GetTDCChannelsArray(); // iterate over TDC channels TDCChannel* tdcChannel; for (int i = 0; i < ntdc; ++i) { tdcChannel = static_cast<TDCChannel*>(tdcHits->At(i)); // get data channel number which corresponds to the TOMB Channel number auto tomb_number = tdcChannel->GetChannel(); if (tomb_number % 65 == 0) { // skip trigger signals from TRB continue; } if( getParamBank().getTOMBChannels().count(tomb_number) == 0 ) { WARNING(Form("DAQ Channel %d appears in data but does not exist in the setup from DB.", tomb_number)); continue; } // get TOMBChannel object from database JPetTOMBChannel& tomb_channel = getParamBank().getTOMBChannel(tomb_number); // one TDC channel may record multiple signals in one TSlot // iterate over all signals from one TDC channel for(int j = 0; j < tdcChannel->GetHitsNum(); ++j){ JPetSigCh sigChTmpLead, sigChTmpTrail; sigChTmpLead.setDAQch(tomb_number); sigChTmpTrail.setDAQch(tomb_number); sigChTmpLead.setType(JPetSigCh::Leading); sigChTmpTrail.setType(JPetSigCh::Trailing); sigChTmpLead.setThresholdNumber(tomb_channel.getLocalChannelNumber()); sigChTmpTrail.setThresholdNumber(tomb_channel.getLocalChannelNumber()); // store pointers to the related parametric objects sigChTmpLead.setPM(tomb_channel.getPM()); sigChTmpLead.setFEB(tomb_channel.getFEB()); sigChTmpLead.setTRB(tomb_channel.getTRB()); sigChTmpLead.setTOMBChannel(tomb_channel); sigChTmpTrail.setPM(tomb_channel.getPM()); sigChTmpTrail.setFEB(tomb_channel.getFEB()); sigChTmpTrail.setTRB(tomb_channel.getTRB()); sigChTmpTrail.setTOMBChannel(tomb_channel); sigChTmpLead.setThreshold(tomb_channel.getThreshold()); sigChTmpTrail.setThreshold(tomb_channel.getThreshold()); // check for empty TDC times if( tdcChannel->GetLeadTime(j) == -100000 ) continue; if( tdcChannel->GetTrailTime(j) == -100000 ) continue; // finally, set the times in ps [raw times are in ns] sigChTmpLead.setValue(tdcChannel->GetLeadTime(j) * 1000.); sigChTmpTrail.setValue(tdcChannel->GetTrailTime(j) * 1000.); // and add the sigCh-s to TSlot tslot.addCh(sigChTmpLead); tslot.addCh(sigChTmpTrail); } } saveTimeWindow(tslot); fCurrEventNumber++; } void TaskA::terminate() { } void TaskA::saveTimeWindow( JPetTimeWindow slot) { assert(fWriter); fWriter->write(slot); }
30.774194
108
0.698113
MagdaSkurzok
b1d96d08ebf65c111702e0a56dfc40d9745fcc38
244
hpp
C++
src/cmd/command.hpp
sop/cygregext
81a8bf7a18cf71729de221b0f1dc0d64e0803d88
[ "MIT" ]
4
2017-05-04T17:26:23.000Z
2020-05-13T16:47:55.000Z
src/cmd/command.hpp
sop/cygregext
81a8bf7a18cf71729de221b0f1dc0d64e0803d88
[ "MIT" ]
2
2019-01-07T21:12:34.000Z
2021-09-08T05:53:25.000Z
src/cmd/command.hpp
sop/cygextreg
81a8bf7a18cf71729de221b0f1dc0d64e0803d88
[ "MIT" ]
null
null
null
#ifndef __COMMAND_HPP__ #define __COMMAND_HPP__ namespace cygextreg { class ICommand { public: virtual ~ICommand() { } /** * Run the command and return exit code. * * @return int Exit code */ virtual int run() = 0; }; } #endif
10.608696
41
0.655738
sop
b1dca098f5e0c28be34296c78398d13ceea7025c
1,414
hpp
C++
src/forms/ModulePropertiesDialog.hpp
stoneface86/gbsynth
b585378227522e02cc76f29e7b4b4be4b0568689
[ "MIT" ]
null
null
null
src/forms/ModulePropertiesDialog.hpp
stoneface86/gbsynth
b585378227522e02cc76f29e7b4b4be4b0568689
[ "MIT" ]
null
null
null
src/forms/ModulePropertiesDialog.hpp
stoneface86/gbsynth
b585378227522e02cc76f29e7b4b4be4b0568689
[ "MIT" ]
null
null
null
#pragma once #include "core/Module.hpp" #include "model/SongListModel.hpp" #include <QButtonGroup> #include <QDialog> #include <QDialogButtonBox> #include <QLineEdit> #include <QListView> #include <QPushButton> #include <QSpinBox> class ModulePropertiesDialog : public QDialog { Q_OBJECT public: // // exec() returns this value if the user changed the framerate/system // static constexpr int AcceptedSystemChange = 2; explicit ModulePropertiesDialog(Module &mod, SongListModel &model, QWidget *parent = nullptr); virtual void accept() override; private: enum DirtyFlag { Clean = 0x0, DirtyInfo = 0x1, DirtySystem = 0x2 }; Q_DISABLE_COPY(ModulePropertiesDialog) int selectedSong(); void add(); void remove(); void duplicate(); void moveUp(); void moveDown(); void setDirty(DirtyFlag flag); void updateSongButtons(); Module &mModule; SongListModel &mModel; unsigned mDirty; bool mWarnRemove; QListView *mSongList; QPushButton *mAddButton; QPushButton *mRemoveButton; QPushButton *mDuplicateButton; QPushButton *mMoveUpButton; QPushButton *mMoveDownButton; QLineEdit *mTitleEdit; QLineEdit *mArtistEdit; QLineEdit *mCopyrightEdit; QSpinBox *mCustomSpin; QDialogButtonBox *mDialogButtons; QButtonGroup *mFramerateRadios; };
16.635294
98
0.686704
stoneface86
b1dd88e9498ab2162abaac6f7ebf2e996ea6a1fa
71
inl
C++
serialization/serialize_post.inl
antonthefirst/am_core
b4ec7a70252105c07e6e58b2978d7dd395cee604
[ "Unlicense" ]
null
null
null
serialization/serialize_post.inl
antonthefirst/am_core
b4ec7a70252105c07e6e58b2978d7dd395cee604
[ "Unlicense" ]
null
null
null
serialization/serialize_post.inl
antonthefirst/am_core
b4ec7a70252105c07e6e58b2978d7dd395cee604
[ "Unlicense" ]
null
null
null
#undef STRUCT #undef VAR #undef BUNCH #undef BIN #undef END #undef POD
10.142857
13
0.746479
antonthefirst
b1e6cc23a1928c0a5caa04e6ee9f6d1a9b4414ec
811
hpp
C++
Sources/etwprof/Utility/ResponseFile.hpp
Donpedro13/etwprof
a9db371ef556d564529c5112c231157d3789292b
[ "MIT" ]
38
2018-06-11T19:09:16.000Z
2022-03-17T04:15:15.000Z
Sources/etwprof/Utility/ResponseFile.hpp
killvxk/etwprof
37ca044b5dd6be39dbd77ba7653395aa95768692
[ "MIT" ]
12
2018-06-12T20:24:05.000Z
2021-07-31T18:28:48.000Z
Sources/etwprof/Utility/ResponseFile.hpp
killvxk/etwprof
37ca044b5dd6be39dbd77ba7653395aa95768692
[ "MIT" ]
5
2019-02-23T04:11:03.000Z
2022-03-17T04:15:18.000Z
#ifndef ETWP_RESPONSE_FILE_HPP #define ETWP_RESPONSE_FILE_HPP #include <memory> #include <string> #include <vector> #include "OS/FileSystem/Utility.hpp" #include "Utility/Exception.hpp" #include "Utility/Macros.hpp" namespace ETWP { namespace Impl { class ResponseFileImpl; } class ResponseFile final { public: class InitException : public Exception { public: InitException (const std::wstring& msg); }; ETWP_DISABLE_COPY_AND_MOVE (ResponseFile); explicit ResponseFile (const std::wstring& filePath); ~ResponseFile (); bool Unpack (std::vector<std::wstring>* pArgumentsOut, std::wstring* pErrorOut); Encoding GetEncoding () const; private: std::unique_ptr<Impl::ResponseFileImpl> m_impl; }; } // namespace ETWP #endif // #ifndef ETWP_RESPONSE_FILE_HPP
20.794872
84
0.725031
Donpedro13
b1ead3c9907f402c726df66e655976f7e3c6644e
1,534
cc
C++
food-finder/supplier-client.cc
nholbrook/opentelemetry-starter-project
5a2303f71b1e8eb19cc7d9bdd5bfe7f159339a38
[ "Apache-2.0" ]
null
null
null
food-finder/supplier-client.cc
nholbrook/opentelemetry-starter-project
5a2303f71b1e8eb19cc7d9bdd5bfe7f159339a38
[ "Apache-2.0" ]
null
null
null
food-finder/supplier-client.cc
nholbrook/opentelemetry-starter-project
5a2303f71b1e8eb19cc7d9bdd5bfe7f159339a38
[ "Apache-2.0" ]
null
null
null
#include <iostream> #include <memory> #include <string> #include <cfloat> #include "food-finder/supplier-client.h" #include <grpcpp/grpcpp.h> #include <grpcpp/ext/proto_server_reflection_plugin.h> #include "opencensus/trace/span.h" #ifdef BAZEL_BUILD #include "proto/foodfinder.grpc.pb.h" #else #include "foodfinder.grpc.pb.h" #endif using google::protobuf::Empty; using grpc::Channel; using grpc::ClientContext; using grpc::Status; using foodfinder::SupplierService; using foodfinder::SupplyRequest; using foodfinder::VendorResponse; using foodfinder::Vendor; SupplierClient::SupplierClient(std::shared_ptr<Channel> channel) : stub_(SupplierService::NewStub(channel)) {} VendorResponse SupplierClient::RequestVendorList(const SupplyRequest& request, const opencensus::trace::Span& parentSpan) { auto span = opencensus::trace::Span::StartSpan( "Fulfilling Vendor List Request", &parentSpan); ClientContext context; VendorResponse vendors; Status status = stub_->RequestVendorList(&context, request, &vendors); if (status.ok()) { span.End(); return vendors; } else { std::cout << status.error_code() << ": " << status.error_message() << std::endl; span.End(); return vendors; } } Empty SupplierClient::RegisterVendor(const Vendor& request) { ClientContext context; Empty e; Status status = stub_->RegisterVendor(&context, request, &e); if (!status.ok()) { std::cout << status.error_code() << ": " << status.error_message() << std::endl; } return e; }
25.147541
78
0.715124
nholbrook
b1eae5878a239f42de7b3f32cda17c5bf0627636
432
cpp
C++
AuthenticationServer/Holder.cpp
zbeckerman/attac
ca07aeb7fbb14e2aea8d19aeb0b044bbc27721e7
[ "Apache-2.0" ]
1
2019-05-01T23:43:55.000Z
2019-05-01T23:43:55.000Z
JumpgateServer/Holder.cpp
zbeckerman/attac
ca07aeb7fbb14e2aea8d19aeb0b044bbc27721e7
[ "Apache-2.0" ]
null
null
null
JumpgateServer/Holder.cpp
zbeckerman/attac
ca07aeb7fbb14e2aea8d19aeb0b044bbc27721e7
[ "Apache-2.0" ]
null
null
null
// Holder.cpp: implementation of the CHolder class. // #include "stdafx.h" #include "Holder.h" ////////////////////////////////////////////////////////////////////// // Construction/Destruction CHolder::CHolder() { } CHolder::~CHolder() { } ////////////////////////////////////////////////////////////////////// SOCKET CHolder::GetSocket() { return m_socket; } void CHolder::SetSocket(SOCKET socket) { m_socket = socket; }
14.896552
70
0.465278
zbeckerman
b1f019b6e19e7f95e852b3d7ebeba5e08ea0f0dd
2,804
cpp
C++
src/affinity.cpp
f-tischler/affinity
48856696b5e89c676a04d46b25b6694e8655853c
[ "Apache-2.0" ]
null
null
null
src/affinity.cpp
f-tischler/affinity
48856696b5e89c676a04d46b25b6694e8655853c
[ "Apache-2.0" ]
null
null
null
src/affinity.cpp
f-tischler/affinity
48856696b5e89c676a04d46b25b6694e8655853c
[ "Apache-2.0" ]
null
null
null
#include <thread> #include <cmath> #include <cstdint> #include <cstddef> #include <cstring> #include <cstdlib> #include <iostream> #include <cstdio> #ifdef __linux #include <unistd.h> #include <sys/sysinfo.h> #include <sys/types.h> #endif #include <errno.h> #include <cassert> #include "affinity.hpp" #ifdef __linux /** for get cpu **/ #if (__GLIBC_MINOR__ < 14 ) && (__GLIBC__ <= 2 ) #ifndef _GNU_SOURCE #define _GNU_SOURCE 1 #endif #else #ifndef _BSD_SOURCE #define _BSD_SOURCE 1 #endif #ifndef _SVID_SOURCE #define _SVID_SOURCE 1 #endif #endif /** end glibc check **/ #include <sched.h> #endif /** end if linux **/ #ifdef INJECT_AFFINITY_NAMESPACE #define INJECTION AFFINITY_NAMESPACE:: #else #define INJECTION #endif void INJECTION affinity::set( const std::size_t desired_core ) { #ifdef __linux /** * pin the current thread */ cpu_set_t *cpuset( nullptr ); /** * FIXME, there's several ways to do this * we should probably check which is actually * avail on the calling system. */ const auto n_cores_avail( sysconf( _SC_NPROCESSORS_ONLN ) ); assert( n_cores_avail > 0 ); /** * get num bytes to alloc */ const auto set_size_bytes( CPU_ALLOC_SIZE( n_cores_avail ) ); cpuset = CPU_ALLOC( n_cores_avail ); assert( cpuset != nullptr ); CPU_ZERO_S( set_size_bytes /** man pages says to use this val **/, cpuset ); CPU_SET_S( desired_core, set_size_bytes, cpuset ); errno = 0; /** * FIXME: we should iterate over ret value given the * CPUSET of the cpu could be greater than cpu_set_size * in some cases, check return for EINVAL. */ if( sched_setaffinity( 0 /* calling thread */, set_size_bytes, cpuset ) != 0 ) { const static auto buff_length( 1000 ); char buffer[ buff_length ]; std::memset( buffer, '\0', buff_length ); const char *str( strerror_r( errno, buffer, buff_length ) ); std::cerr << "failed to set affinity, desired core( " << desired_core << " )"; std::cerr << " exited with error ( " << str << " ).\n"; exit( EXIT_FAILURE ); } CPU_FREE( cpuset ); /** wait till we know we're on the right processor **/ if( sched_yield() != 0 ) { perror( "Failed to yield to wait for core change!\n" ); } #else /** not linux **/ #if defined __APPLE__ #warning "No thread pinning for this platform, your results may vary!" #elif defined _WIN64 || defined _WIN32 #pragma message ( "No thread pinning for this platform, your results may vary!" ) #endif #endif return; } //end function here, just in case you lost curly brace #undef INJECTION
23.762712
86
0.620185
f-tischler
b1f6083b7e59bd5bcf5a26538fbcca41cfe877d2
22,307
cpp
C++
Source/AllProjects/Drivers/GenProto/Server/GenProtoS_RuntimeExpression.cpp
MarkStega/CQC
c1d0e01ec2abcaa5b8eb1899b9f0522fecee4b07
[ "MIT" ]
51
2020-12-26T18:17:16.000Z
2022-03-15T04:29:35.000Z
Source/AllProjects/Drivers/GenProto/Server/GenProtoS_RuntimeExpression.cpp
MarkStega/CQC
c1d0e01ec2abcaa5b8eb1899b9f0522fecee4b07
[ "MIT" ]
null
null
null
Source/AllProjects/Drivers/GenProto/Server/GenProtoS_RuntimeExpression.cpp
MarkStega/CQC
c1d0e01ec2abcaa5b8eb1899b9f0522fecee4b07
[ "MIT" ]
4
2020-12-28T07:24:39.000Z
2021-12-29T12:09:37.000Z
// // FILE NAME: GenProtoS_RuntimeExpression.cpp // // AUTHOR: Dean Roddey // // CREATED: 11/24/2003 // // COPYRIGHT: Charmed Quark Systems, Ltd @ 2020 // // This software is copyrighted by 'Charmed Quark Systems, Ltd' and // the author (Dean Roddey.) It is licensed under the MIT Open Source // license: // // https://opensource.org/licenses/MIT // // DESCRIPTION: // // This file implements the basic derivatives of the expression node class // that represent simple constant values. // // CAVEATS/GOTCHAS: // // LOG: // // --------------------------------------------------------------------------- // Includes // --------------------------------------------------------------------------- #include "GenProtoS_.hpp" // --------------------------------------------------------------------------- // Magic macros // --------------------------------------------------------------------------- RTTIDecls(TGenProtoCheckSumNode, TGenProtoExprNode) RTTIDecls(TGenProtoCRC16Node, TGenProtoExprNode) RTTIDecls(TGenProtoFldValNode, TGenProtoExprNode) RTTIDecls(TGenProtoInputByteNode, TGenProtoExprNode) RTTIDecls(TGenProtoVarValNode, TGenProtoExprNode) RTTIDecls(TGenProtoWriteValNode, TGenProtoExprNode) // --------------------------------------------------------------------------- // CLASS: TGenProtoCheckSumNode // PREFIX: node // --------------------------------------------------------------------------- // --------------------------------------------------------------------------- // TGenProtoCheckSumNode: Constructors and Destructor // --------------------------------------------------------------------------- TGenProtoCheckSumNode:: TGenProtoCheckSumNode( const tGenProtoS::ESpecNodes eExprType , const tGenProtoS::ETypes eType , TGenProtoExprNode* const pnodeOfs , TGenProtoExprNode* const pnodeLen , const tGenProtoS::ECheckSums eCheckSumType) : TGenProtoExprNode(eType, L"CheckSum()") , m_eCheckSumType(eCheckSumType) , m_eExprType(eExprType) , m_pnodeLen(pnodeLen) , m_pnodeOfs(pnodeOfs) { } TGenProtoCheckSumNode:: TGenProtoCheckSumNode(const TGenProtoCheckSumNode& nodeToCopy) : TGenProtoExprNode(nodeToCopy) , m_eCheckSumType(nodeToCopy.m_eCheckSumType) , m_eExprType(nodeToCopy.m_eExprType) , m_pnodeOfs(::pDupObject<TGenProtoExprNode>(nodeToCopy.m_pnodeOfs)) , m_pnodeLen(::pDupObject<TGenProtoExprNode>(nodeToCopy.m_pnodeLen)) { } TGenProtoCheckSumNode::~TGenProtoCheckSumNode() { delete m_pnodeOfs; delete m_pnodeLen; } // --------------------------------------------------------------------------- // TGenProtoCheckSumNode: Public operators // --------------------------------------------------------------------------- TGenProtoCheckSumNode& TGenProtoCheckSumNode::operator=(const TGenProtoCheckSumNode& nodeToAssign) { if (this != &nodeToAssign) { TParent::operator=(nodeToAssign); m_eCheckSumType = nodeToAssign.m_eCheckSumType; m_eExprType = nodeToAssign.m_eExprType; delete m_pnodeOfs; m_pnodeOfs = nullptr; delete m_pnodeLen; m_pnodeLen = nullptr; m_pnodeOfs = ::pDupObject<TGenProtoExprNode>(nodeToAssign.m_pnodeOfs); m_pnodeLen = ::pDupObject<TGenProtoExprNode>(nodeToAssign.m_pnodeLen); } return *this; } // --------------------------------------------------------------------------- // TGenProtoCheckSumNode: Public, inherited methods // --------------------------------------------------------------------------- tCIDLib::TBoolean TGenProtoCheckSumNode::bIsConst() const { // We are never const return kCIDLib::False; } tCIDLib::TVoid TGenProtoCheckSumNode::Evaluate(TGenProtoCtx& ctxThis) { // Get the buffer that we are working with const TMemBuf* pmbufSrc = (m_eExprType == tGenProtoS::ESpecNodes::ReplyBuf) ? &ctxThis.mbufReply() : &ctxThis.mbufSend(); const tCIDLib::TCard4 c4BufLen = (m_eExprType == tGenProtoS::ESpecNodes::ReplyBuf) ? ctxThis.c4ReplyBytes() : ctxThis.c4SendBytes(); // Evaluate the two expressions and get the offset/len values m_pnodeOfs->Evaluate(ctxThis); m_pnodeLen->Evaluate(ctxThis); tCIDLib::TCard4 c4Index = m_pnodeOfs->evalCur().c4Value(); const tCIDLib::TCard4 c4End = c4Index + m_pnodeLen->evalCur().c4Value(); // // Make sure we won't exceed the available bytes for the buffer we // are working on. // if (c4End > c4BufLen) { facGenProtoS().ThrowErr ( CID_FILE , CID_LINE , kGPDErrs::errcRunT_BadBufRange , tCIDLib::ESeverities::Failed , tCIDLib::EErrClasses::Index , TCardinal(c4Index) , TCardinal(m_pnodeLen->evalCur().c4Value()) , TCardinal(c4BufLen) ); } const tGenProtoS::ETypes eRetType = eType(); #if CID_DEBUG_ON if ((eRetType != tGenProtoS::ETypes::Card1) && (eRetType != tGenProtoS::ETypes::Card2) && (eRetType != tGenProtoS::ETypes::Card4)) { facGenProtoS().ThrowErr ( CID_FILE , CID_LINE , kGPDErrs::errcDebug_UnsupportedType , tCIDLib::ESeverities::Failed , tCIDLib::EErrClasses::Internal , TCardinal(tCIDLib::c4EnumOrd(eRetType)) , strDescription() ); } #endif // // Now, according to the type we were told to use, run the algoritm and // store the result. // if (m_eCheckSumType == tGenProtoS::ECheckSums::AddWithOverflow) { if (eRetType == tGenProtoS::ETypes::Card1) { tCIDLib::TCard1 c1Sum = 0; for (; c4Index < c4End; c4Index++) c1Sum += pmbufSrc->c1At(c4Index); evalCur().c1Value(c1Sum); } else if (eRetType == tGenProtoS::ETypes::Card2) { tCIDLib::TCard2 c2Sum = 0; for (; c4Index < c4End; c4Index++) c2Sum += pmbufSrc->c1At(c4Index); evalCur().c2Value(c2Sum); } else if (eRetType == tGenProtoS::ETypes::Card4) { tCIDLib::TCard4 c4Sum = 0; for (; c4Index < c4End; c4Index++) c4Sum += pmbufSrc->c1At(c4Index); evalCur().c4Value(c4Sum); } } else if (m_eCheckSumType == tGenProtoS::ECheckSums::Xor1) { if (eRetType == tGenProtoS::ETypes::Card1) { tCIDLib::TCard1 c1Sum = pmbufSrc->c1At(c4Index); c4Index++; for (; c4Index < c4End; c4Index++) c1Sum ^= pmbufSrc->c1At(c4Index); evalCur().c1Value(c1Sum); } else if (eRetType == tGenProtoS::ETypes::Card2) { tCIDLib::TCard2 c2Sum = pmbufSrc->c2At(c4Index); for (; c4Index < c4End; c4Index++) c2Sum ^= pmbufSrc->c2At(c4Index); evalCur().c2Value(c2Sum); } else if (eRetType == tGenProtoS::ETypes::Card4) { tCIDLib::TCard4 c4Sum = pmbufSrc->c4At(c4Index); for (; c4Index < c4End; c4Index++) c4Sum ^= pmbufSrc->c4At(c4Index); evalCur().c4Value(c4Sum); } } else { #if CID_DEBUG_ON facCIDLib().ThrowErr ( CID_FILE , CID_LINE , kCIDErrs::errcGen_BadEnumValue , tCIDLib::ESeverities::Failed , tCIDLib::EErrClasses::Internal , TCardinal(tCIDLib::c4EnumOrd(m_eCheckSumType)) , TString(L"tGenProtoS::ECheckSums") ); #endif } } tCIDLib::TVoid TGenProtoCheckSumNode::Optimize(TGenProtoCtx& ctxThis) { // // Just call a base class provided helper method on each of our children. // It handles the recursion if required. If the node can't be optimized, // we get it back again (though some of its children still may have // be optimized.) // m_pnodeOfs = pnodeOptimize(ctxThis, m_pnodeOfs); m_pnodeLen = pnodeOptimize(ctxThis, m_pnodeLen); } tCIDLib::TVoid TGenProtoCheckSumNode::PostParseValidation() { // Our type has to be cardinal if ((eType() != tGenProtoS::ETypes::Card1) && (eType() != tGenProtoS::ETypes::Card2) && (eType() != tGenProtoS::ETypes::Card4)) { facGenProtoS().ThrowErr ( CID_FILE , CID_LINE , kGPDErrs::errcExpr_PMustBeCardinal , tCIDLib::ESeverities::Failed , tCIDLib::EErrClasses::TypeMatch , TCardinal(2) , strDescription() ); } // Make sure our offset/lenexpressions are a cardinal type CheckIsCardType(*m_pnodeOfs, 3); CheckIsCardType(*m_pnodeLen, 4); } // --------------------------------------------------------------------------- // CLASS: TGenProtoCRC16Node // PREFIX: node // --------------------------------------------------------------------------- // --------------------------------------------------------------------------- // TGenProtoCRC16Node: Constructors and Destructor // --------------------------------------------------------------------------- TGenProtoCRC16Node:: TGenProtoCRC16Node( const tGenProtoS::ESpecNodes eExprType , TGenProtoExprNode* const pnodeOfs , TGenProtoExprNode* const pnodeLen , TGenProtoExprNode* const pnodePoly , TGenProtoExprNode* const pnodeCount) : TGenProtoExprNode(tGenProtoS::ETypes::Card2, L"CRC16()") , m_eExprType(eExprType) , m_pnodeCount(pnodeCount) , m_pnodeLen(pnodeLen) , m_pnodeOfs(pnodeOfs) , m_pnodePoly(pnodePoly) { } TGenProtoCRC16Node:: TGenProtoCRC16Node(const TGenProtoCRC16Node& nodeToCopy) : TGenProtoExprNode(nodeToCopy) , m_eExprType(nodeToCopy.m_eExprType) , m_pnodeCount(::pDupObject<TGenProtoExprNode>(nodeToCopy.m_pnodeCount)) , m_pnodeOfs(::pDupObject<TGenProtoExprNode>(nodeToCopy.m_pnodeOfs)) , m_pnodeLen(::pDupObject<TGenProtoExprNode>(nodeToCopy.m_pnodeLen)) , m_pnodePoly(::pDupObject<TGenProtoExprNode>(nodeToCopy.m_pnodePoly)) { } TGenProtoCRC16Node::~TGenProtoCRC16Node() { delete m_pnodeCount; delete m_pnodeOfs; delete m_pnodeLen; delete m_pnodePoly; } // --------------------------------------------------------------------------- // TGenProtoCRC16Node: Public operators // --------------------------------------------------------------------------- TGenProtoCRC16Node& TGenProtoCRC16Node::operator=(const TGenProtoCRC16Node& nodeToAssign) { if (this != &nodeToAssign) { TParent::operator=(nodeToAssign); m_eExprType = nodeToAssign.m_eExprType; delete m_pnodeCount; m_pnodeCount = nullptr; delete m_pnodeOfs; m_pnodeOfs = nullptr; delete m_pnodeLen; m_pnodeLen = nullptr; delete m_pnodePoly; m_pnodePoly = nullptr; m_pnodeCount = ::pDupObject<TGenProtoExprNode>(nodeToAssign.m_pnodeCount); m_pnodeOfs = ::pDupObject<TGenProtoExprNode>(nodeToAssign.m_pnodeOfs); m_pnodeLen = ::pDupObject<TGenProtoExprNode>(nodeToAssign.m_pnodeLen); m_pnodePoly = ::pDupObject<TGenProtoExprNode>(nodeToAssign.m_pnodePoly); } return *this; } // --------------------------------------------------------------------------- // TGenProtoCRC16Node: Public, inherited methods // --------------------------------------------------------------------------- tCIDLib::TBoolean TGenProtoCRC16Node::bIsConst() const { // We are never const return kCIDLib::False; } tCIDLib::TVoid TGenProtoCRC16Node::Evaluate(TGenProtoCtx& ctxThis) { // Get the buffer that we are working with const TMemBuf* pmbufSrc = (m_eExprType == tGenProtoS::ESpecNodes::ReplyBuf) ? &ctxThis.mbufReply() : &ctxThis.mbufSend(); const tCIDLib::TCard4 c4BufLen = (m_eExprType == tGenProtoS::ESpecNodes::ReplyBuf) ? ctxThis.c4ReplyBytes() : ctxThis.c4SendBytes(); // Evaluate the two expressions and get the offset/len values m_pnodeOfs->Evaluate(ctxThis); m_pnodeLen->Evaluate(ctxThis); tCIDLib::TCard4 c4Index = m_pnodeOfs->evalCur().c4Value(); const tCIDLib::TCard4 c4EndInd = c4Index + m_pnodeLen->evalCur().c4Value(); const tCIDLib::TCard2 c2Poly = m_pnodePoly->evalCur().c2Value(); const tCIDLib::TCard4 c4Count = m_pnodeCount->evalCur().c4Value(); // // Make sure we won't exceed the available bytes for the buffer we // are working on. // if (c4EndInd > c4BufLen) { facGenProtoS().ThrowErr ( CID_FILE , CID_LINE , kGPDErrs::errcRunT_BadBufRange , tCIDLib::ESeverities::Failed , tCIDLib::EErrClasses::Index , TCardinal(c4Index) , TCardinal(m_pnodeLen->evalCur().c4Value()) , TCardinal(c4BufLen) ); } tCIDLib::TCard2 c2CRCVal = 0; for (; c4Index <= c4EndInd; c4Index++) { c2CRCVal ^= tCIDLib::TCard2(pmbufSrc->c1At(c4Index)); for (tCIDLib::TCard4 c4InInd = 0; c4InInd < c4Count; c4InInd++) { const tCIDLib::TBoolean bFlag((c2CRCVal & 0x1) != 0); c2CRCVal >>= 1; if (bFlag) c2CRCVal ^= c2Poly; } } // Set the result as our value evalCur().c2Value(c2CRCVal); } tCIDLib::TVoid TGenProtoCRC16Node::Optimize(TGenProtoCtx& ctxThis) { // // Just call a base class provided helper method on each of our children. // It handles the recursion if required. If the node can't be optimized, // we get it back again (though some of its children still may have // be optimized.) // m_pnodeCount = pnodeOptimize(ctxThis, m_pnodeCount); m_pnodeOfs = pnodeOptimize(ctxThis, m_pnodeOfs); m_pnodeLen = pnodeOptimize(ctxThis, m_pnodeLen); m_pnodePoly = pnodeOptimize(ctxThis, m_pnodePoly); } tCIDLib::TVoid TGenProtoCRC16Node::PostParseValidation() { // Make sure our offset/len, poly, and count expressions are a cardinal type CheckIsCardType(*m_pnodeOfs, 2); CheckIsCardType(*m_pnodeLen, 3); CheckIsCardType(*m_pnodePoly, 4); CheckIsCardType(*m_pnodeCount, 5); } // --------------------------------------------------------------------------- // CLASS: TGenProtoFldValNode // PREFIX: node // --------------------------------------------------------------------------- // --------------------------------------------------------------------------- // TGenProtoFldValNode: Constructors and Destructor // --------------------------------------------------------------------------- TGenProtoFldValNode::TGenProtoFldValNode(TGenProtoFldInfo* const pfldiSrc) : TGenProtoExprNode ( TFacGenProtoS::eFldTypeToExprType(pfldiSrc->flddInfo().eType()) , L"Field Reference" ) , m_c4SerialNum(0) , m_pfldiSrc(pfldiSrc) { } TGenProtoFldValNode::TGenProtoFldValNode(const TGenProtoFldValNode& nodeToCopy) : TGenProtoExprNode(nodeToCopy) , m_c4SerialNum(nodeToCopy.m_c4SerialNum) , m_pfldiSrc(nodeToCopy.m_pfldiSrc) { } TGenProtoFldValNode::~TGenProtoFldValNode() { // We don't own the field info pointer, so we do nothing here } // --------------------------------------------------------------------------- // TGenProtoFldValNode: Public operators // --------------------------------------------------------------------------- TGenProtoFldValNode& TGenProtoFldValNode::operator=(const TGenProtoFldValNode& nodeToAssign) { if (this != &nodeToAssign) { TParent::operator=(nodeToAssign); // We just reference the field info pointer, so we can just copy it m_pfldiSrc = nodeToAssign.m_pfldiSrc; // Reset the value fields m_c4SerialNum = 0; m_strValue.Clear(); } return *this; } // --------------------------------------------------------------------------- // TGenProtoFldValNode: Public, inherited methods // --------------------------------------------------------------------------- tCIDLib::TBoolean TGenProtoFldValNode::bIsConst() const { // We are never const return kCIDLib::False; } tCIDLib::TVoid TGenProtoFldValNode::Evaluate(TGenProtoCtx& ctxInfo) { tCQCKit::EFldTypes eType; const tCIDLib::TBoolean bNew = ctxInfo.psdrvThis()->bReadFieldByName ( m_pfldiSrc->flddInfo().strName() , m_c4SerialNum , m_strValue , eType , kCIDLib::False ); if (bNew) evalCur().strValue(m_strValue); } // --------------------------------------------------------------------------- // CLASS: TGenProtoInputByteNode // PREFIX: node // --------------------------------------------------------------------------- // --------------------------------------------------------------------------- // TGenProtoInputByteNode: Constructors and Destructor // --------------------------------------------------------------------------- TGenProtoInputByteNode::TGenProtoInputByteNode() : TGenProtoExprNode(tGenProtoS::ETypes::Card1, L"Current input byte") { } TGenProtoInputByteNode:: TGenProtoInputByteNode(const TGenProtoInputByteNode& nodeToCopy) : TGenProtoExprNode(nodeToCopy) { } TGenProtoInputByteNode::~TGenProtoInputByteNode() { } // --------------------------------------------------------------------------- // TGenProtoInputByteNode: Public operators // --------------------------------------------------------------------------- TGenProtoInputByteNode& TGenProtoInputByteNode::operator=(const TGenProtoInputByteNode& nodeToAssign) { TParent::operator=(nodeToAssign); return *this; } // --------------------------------------------------------------------------- // TGenProtoInputByteNode: Public, inherited methods // --------------------------------------------------------------------------- tCIDLib::TBoolean TGenProtoInputByteNode::bIsConst() const { // We are never const return kCIDLib::False; } tCIDLib::TVoid TGenProtoInputByteNode::Evaluate(TGenProtoCtx& ctxThis) { // We just set our value from the input byte in the context evalCur().c1Value(ctxThis.c1InputByte()); } // --------------------------------------------------------------------------- // CLASS: TGenProtoVarValNode // PREFIX: node // --------------------------------------------------------------------------- // --------------------------------------------------------------------------- // TGenProtoVarValNode: Constructors and Destructor // --------------------------------------------------------------------------- TGenProtoVarValNode::TGenProtoVarValNode(TGenProtoVarInfo* const pvariSrc) : TGenProtoExprNode(pvariSrc->eType(), L"Variable Reference") , m_pvariSrc(pvariSrc) { } TGenProtoVarValNode::TGenProtoVarValNode(const TGenProtoVarValNode& nodeToCopy) : TGenProtoExprNode(nodeToCopy) , m_pvariSrc(nodeToCopy.m_pvariSrc) { } TGenProtoVarValNode::~TGenProtoVarValNode() { // We don't own the variable info pointer, so we do nothing here } // --------------------------------------------------------------------------- // TGenProtoVarValNode: Public operators // --------------------------------------------------------------------------- TGenProtoVarValNode& TGenProtoVarValNode::operator=(const TGenProtoVarValNode& nodeToAssign) { if (this != &nodeToAssign) { TParent::operator=(nodeToAssign); // We just reference the var info, so we can just shallow copy it m_pvariSrc = nodeToAssign.m_pvariSrc; } return *this; } // --------------------------------------------------------------------------- // TGenProtoVarValNode: Public, inherited methods // --------------------------------------------------------------------------- tCIDLib::TBoolean TGenProtoVarValNode::bIsConst() const { // Return the const state of the variable node return m_pvariSrc->bIsConst(); } tCIDLib::TVoid TGenProtoVarValNode::Evaluate(TGenProtoCtx&) { // Just set our expression value from the variable value evalCur().SetFrom(m_pvariSrc->evalThis()); } // --------------------------------------------------------------------------- // CLASS: TGenProtoWriteValNode // PREFIX: node // --------------------------------------------------------------------------- // --------------------------------------------------------------------------- // TGenProtoWriteValNode: Constructors and Destructor // --------------------------------------------------------------------------- TGenProtoWriteValNode::TGenProtoWriteValNode(const tCQCKit::EFldTypes eType) : TGenProtoExprNode ( TFacGenProtoS::eFldTypeToExprType(eType) , L"Field Write Value" ) { } TGenProtoWriteValNode:: TGenProtoWriteValNode(const TGenProtoWriteValNode& nodeToCopy) : TGenProtoExprNode(nodeToCopy) { } TGenProtoWriteValNode::~TGenProtoWriteValNode() { } // --------------------------------------------------------------------------- // TGenProtoWriteValNode: Public operators // --------------------------------------------------------------------------- TGenProtoWriteValNode& TGenProtoWriteValNode::operator=(const TGenProtoWriteValNode& nodeToAssign) { TParent::operator=(nodeToAssign); return *this; } // --------------------------------------------------------------------------- // TGenProtoWriteValNode: Public, inherited methods // --------------------------------------------------------------------------- tCIDLib::TBoolean TGenProtoWriteValNode::bIsConst() const { // We are never const return kCIDLib::False; } tCIDLib::TVoid TGenProtoWriteValNode::Evaluate(TGenProtoCtx& ctxThis) { // We just set our value from the write value in the context evalCur().SetFrom(ctxThis.evalWrite()); }
31.286115
86
0.530506
MarkStega
b1f70752b9c87ca72b1e2761d8384cd75ec7dde1
5,747
cpp
C++
src/vlGraphics/Light.cpp
pasenau/VisualizationLibrary
2fcf1808475aebd4862f40377754be62a7f77a52
[ "BSD-2-Clause" ]
1
2017-06-29T18:25:11.000Z
2017-06-29T18:25:11.000Z
src/vlGraphics/Light.cpp
pasenau/VisualizationLibrary
2fcf1808475aebd4862f40377754be62a7f77a52
[ "BSD-2-Clause" ]
null
null
null
src/vlGraphics/Light.cpp
pasenau/VisualizationLibrary
2fcf1808475aebd4862f40377754be62a7f77a52
[ "BSD-2-Clause" ]
1
2021-01-01T10:43:33.000Z
2021-01-01T10:43:33.000Z
/**************************************************************************************/ /* */ /* Visualization Library */ /* http://visualizationlibrary.org */ /* */ /* Copyright (c) 2005-2017, Michele Bosi */ /* 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. */ /* */ /* 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 <vlGraphics/Light.hpp> #include <vlCore/Transform.hpp> #include <vlGraphics/Camera.hpp> #include <vlCore/Log.hpp> #include <vlCore/Say.hpp> using namespace vl; //------------------------------------------------------------------------------ // Light //------------------------------------------------------------------------------ Light::Light() { VL_DEBUG_SET_OBJECT_NAME() mAmbient = fvec4(0,0,0,1); mDiffuse = fvec4(1,1,1,1); mSpecular = fvec4(1,1,1,1); mPosition = fvec4(0,0,0,1); mSpotDirection = fvec3(0,0,-1); mSpotExponent = 0; mSpotCutoff = 180.0f; mConstantAttenuation = 1.0f; mLinearAttenuation = 0.0f; mQuadraticAttenuation = 0.0f; mBoundTransform = NULL; mEnabled = true; } //------------------------------------------------------------------------------ void Light::apply(int index, const Camera* camera, OpenGLContext*) const { VL_CHECK_OGL() if (enabled()) { glEnable (GL_LIGHT0 + index); VL_CHECK_OGL() glMatrixMode(GL_MODELVIEW); glPushMatrix(); // follows the given node if ( boundTransform() ) camera->applyModelViewMatrix( boundTransform()->worldMatrix() ); else { // follows the camera /*glMatrixMode(GL_MODELVIEW);*/ glLoadIdentity(); } glLightfv(GL_LIGHT0+index, GL_AMBIENT, mAmbient.ptr()); glLightfv(GL_LIGHT0+index, GL_DIFFUSE, mDiffuse.ptr()); glLightfv(GL_LIGHT0+index, GL_SPECULAR, mSpecular.ptr()); glLightfv(GL_LIGHT0+index, GL_POSITION, mPosition.ptr()); glLightf(GL_LIGHT0+index, GL_SPOT_CUTOFF, mSpotCutoff); // if its a spot light if (mSpotCutoff != 180.0f) { VL_CHECK(mSpotCutoff>=0.0f && mSpotCutoff<=90.0f); glLightfv(GL_LIGHT0+index, GL_SPOT_DIRECTION, mSpotDirection.ptr()); glLightf(GL_LIGHT0+index, GL_SPOT_EXPONENT, mSpotExponent); } // if positional or spot light compute the attenuation factors, that is // attenuation is useless of directional lights. if (mSpotCutoff != 180.0f || mPosition.w() != 0) { glLightf(GL_LIGHT0+index, GL_CONSTANT_ATTENUATION, mConstantAttenuation); glLightf(GL_LIGHT0+index, GL_LINEAR_ATTENUATION, mLinearAttenuation); glLightf(GL_LIGHT0+index, GL_QUADRATIC_ATTENUATION, mQuadraticAttenuation); } /*glMatrixMode(GL_MODELVIEW);*/ glPopMatrix(); } else { glDisable(GL_LIGHT0 + index); } } //------------------------------------------------------------------------------ void Light::bindTransform(Transform* transform) { mBoundTransform = transform; } //------------------------------------------------------------------------------ Transform* Light::boundTransform() { return mBoundTransform.get(); } //------------------------------------------------------------------------------ const Transform* Light::boundTransform() const { return mBoundTransform.get(); } //------------------------------------------------------------------------------
44.550388
89
0.478163
pasenau
b1f8ec6ab4c7de8b6338e7c29e469fb4488766cf
2,341
hpp
C++
srcs/common/itempropertyassociation.hpp
Reflectioner/heif
bdac2fc9c66d8c1e8994eaf81f1a5db116b863ab
[ "BSD-3-Clause" ]
null
null
null
srcs/common/itempropertyassociation.hpp
Reflectioner/heif
bdac2fc9c66d8c1e8994eaf81f1a5db116b863ab
[ "BSD-3-Clause" ]
null
null
null
srcs/common/itempropertyassociation.hpp
Reflectioner/heif
bdac2fc9c66d8c1e8994eaf81f1a5db116b863ab
[ "BSD-3-Clause" ]
null
null
null
/* This file is part of Nokia HEIF library * * Copyright (c) 2015-2020 Nokia Corporation and/or its subsidiary(-ies). All rights reserved. * * Contact: heif@nokia.com * * This software, including documentation, is protected by copyright controlled by Nokia Corporation and/ or its * subsidiaries. All rights are reserved. * * Copying, including reproducing, storing, adapting or translating, any or all of this material requires the prior * written consent of Nokia. */ #ifndef ITEMPROPERTYASSOCIATION_HPP #define ITEMPROPERTYASSOCIATION_HPP #include "customallocator.hpp" #include "fullbox.hpp" /** Item Property Association class. * @details 'ipma' box implementation. * Version 0 and 1 are are supported. */ class ItemPropertyAssociation : public FullBox { public: ItemPropertyAssociation(); ~ItemPropertyAssociation() override = default; /** A property association entry */ struct Entry { bool essential; ///< True indicates that this property is essential to the item, otherwise it is non-essential. std::uint16_t index; ///< 1-based index of the property. }; typedef Vector<Entry> AssociationEntries; /** Get association information related to an item id. * @param [in] itemId The item id to request property indexes for. * @return Requested association entries. An empty vector if the itemId is not present in ItemPropertyAssociation. */ const AssociationEntries& getAssociationEntries(std::uint32_t itemId) const; /** Add a property association for an item. * @param [in] itemId Item ID of the item. * @param [in] index 1-based index of the property to associate from the Item Property Container Box. Value 0 * indicates no property is associated. * @param [in] essential True if the property is essential for the item (reader is required to process it). */ void addEntry(std::uint32_t itemId, std::uint16_t index, bool essential); /** Write box to ISOBMFF::BitStream. * @see Box::writeBox() */ void writeBox(ISOBMFF::BitStream& bitstream) const override; /** Read box from ISOBMFF::BitStream. * @see Box::parseBox() */ void parseBox(ISOBMFF::BitStream& bitstream) override; private: typedef std::uint32_t ItemId; Map<ItemId, AssociationEntries> mAssociations; }; #endif
35.469697
120
0.715933
Reflectioner
b1fb2348db940335ecbfd3c5cc2777bc11a756fd
909
cpp
C++
pair/myPair.cpp
kamal2git/DSA-Practice-Questions
ae2f4e83d0166d046e617e1159c0a55f91591ef0
[ "Apache-2.0" ]
null
null
null
pair/myPair.cpp
kamal2git/DSA-Practice-Questions
ae2f4e83d0166d046e617e1159c0a55f91591ef0
[ "Apache-2.0" ]
null
null
null
pair/myPair.cpp
kamal2git/DSA-Practice-Questions
ae2f4e83d0166d046e617e1159c0a55f91591ef0
[ "Apache-2.0" ]
null
null
null
#include<iostream> using namespace std; template <typename T,typename V> class myPair{ T x; V y; public: void setX(T x){ this->x=x; } void setY(V y){ this->y=y; } T getX(){ return x; } V getY(){ return y; } void print(myPair<int,int> p){ //cout<<"x: "<<x<<" and y: "<<y<<endl; } }; void myPair::print(myPair<int,int> p){ cout<<"x: "<<p.getX()<<" and y: "<<p.getY()<<endl; } } void myPair::print(myPair<myPair<int,int>,int> p){ cout<<p.getX().getX()<<" "<<p.getX().getY()<<" "<<p.getY<<endl; } int main(){ myPair<int,char> p1; p1.setX(10); p1.setY('a'); p1.print(); myPair<myPair<int,int>,int> p4; //pair of pair p4.setY(100); myPair<int,int> p5; p5.setX(200); p5.setY(300); p4.setX(p5); //p4.print(); overload the print fn bro! return 0; }
20.2
67
0.49725
kamal2git
b1fbfe7a5ff366bb7ccec0eb25a89dfad5339add
3,315
hpp
C++
Qv2ray/src/Qv2rayApplication.hpp
DWXXX/cnRepo
3e54581699e4bf4d0d2d8a7c85fe340ebbbb8eef
[ "Apache-2.0" ]
null
null
null
Qv2ray/src/Qv2rayApplication.hpp
DWXXX/cnRepo
3e54581699e4bf4d0d2d8a7c85fe340ebbbb8eef
[ "Apache-2.0" ]
null
null
null
Qv2ray/src/Qv2rayApplication.hpp
DWXXX/cnRepo
3e54581699e4bf4d0d2d8a7c85fe340ebbbb8eef
[ "Apache-2.0" ]
null
null
null
#pragma once #include "core/handler/ConfigHandler.hpp" #include "core/handler/RouteHandler.hpp" #include "libs/QJsonStruct/QJsonStruct.hpp" #include <QSystemTrayIcon> #ifdef Q_OS_ANDROID #include <QApplication> #else #include <SingleApplication> #endif #ifdef Q_OS_ANDROID #define QV2RAY_NO_SINGLEAPPLICATON #endif #define QV2RAY_WORKAROUND_MACOS_MEMLOCK 0 #if QV2RAY_WORKAROUND_MACOS_MEMLOCK #ifndef QV2RAY_NO_SINGLEAPPLICATION #define QV2RAY_NO_SINGLEAPPLICATON #endif #endif class MainWindow; namespace Qv2ray { enum Qv2rayExitCode { QVEXIT_NORMAL = 0, QVEXIT_SECONDARY_INSTANCE = 0, QVEXIT_PRE_INITIALIZE_FAIL = -1, QVEXIT_EARLY_SETUP_FAIL = -2, QVEXIT_CONFIG_PATH_FAIL = -3, QVEXIT_CONFIG_FILE_FAIL = -4, QVEXIT_SSL_FAIL = -5, QVEXIT_NEW_VERSION = -6 }; struct Qv2rayProcessArguments { enum Argument { NORMAL = 0, QV2RAY_LINK = 1, EXIT = 2, RECONNECT = 3, DISCONNECT = 4 }; QList<Argument> arguments; QString version; QString data; QList<QString> links; QList<QString> fullArgs; // QString _qvNewVersionPath; JSONSTRUCT_REGISTER(Qv2rayProcessArguments, F(arguments, version, data, links, fullArgs)) }; enum Qv2rayPreInitResult { PRE_INIT_RESULT_ERROR, PRE_INIT_RESULT_QUIT, PRE_INIT_RESULT_CONTINUE }; inline Qv2rayProcessArguments Qv2rayProcessArgument; #ifdef QV2RAY_NO_SINGLEAPPLICATON class Qv2rayApplication : public QApplication #else class Qv2rayApplication : public SingleApplication #endif { Q_OBJECT public: enum Qv2raySetupStatus { NORMAL, SINGLE_APPLICATION, FAILED }; // void QuitApplication(int retCode = 0); static Qv2rayPreInitResult PreInitialize(int argc, char **argv); explicit Qv2rayApplication(int &argc, char *argv[]); Qv2raySetupStatus SetupQv2ray(); bool FindAndCreateInitialConfiguration(); bool LoadConfiguration(); void InitializeGlobalVariables(); Qv2rayExitCode RunQv2ray(); public: QSystemTrayIcon **GetTrayIcon() { return &hTray; } void showMessage(const QString &m, const QIcon &icon, int msecs = 10000) { hTray->showMessage("Qv2ray", m, icon, msecs); } void showMessage(const QString &m, QSystemTrayIcon::MessageIcon icon = QSystemTrayIcon::Information, int msecs = 10000) { hTray->showMessage("Qv2ray", m, icon, msecs); } private slots: void aboutToQuitSlot(); private: #ifndef QV2RAY_NO_SINGLEAPPLICATON void onMessageReceived(quint32 clientID, QByteArray msg); #endif QSystemTrayIcon *hTray; MainWindow *mainWindow; static Qv2rayPreInitResult ParseCommandLine(QString *errorMessage, const QStringList &args); bool initialized = false; }; } // namespace Qv2ray using namespace Qv2ray; #define qvApp (dynamic_cast<Qv2ray::Qv2rayApplication *>(QCoreApplication::instance())) #define qvAppTrayIcon (*qvApp->GetTrayIcon())
26.102362
127
0.647059
DWXXX
b1fdb59b0eed2154e54ce32a3ea44706c7c97c53
911
hpp
C++
src/read_mapper/mapper/align_query_to_reference.hpp
seqan/learning-resources
e6447edca3a349cb350b73b31dbed9e3215447fc
[ "CC0-1.0", "CC-BY-4.0" ]
7
2019-08-21T11:38:01.000Z
2021-01-28T06:41:44.000Z
src/read_mapper/mapper/align_query_to_reference.hpp
seqan/learning-resources
e6447edca3a349cb350b73b31dbed9e3215447fc
[ "CC0-1.0", "CC-BY-4.0" ]
7
2019-09-03T10:32:03.000Z
2021-09-01T10:10:56.000Z
src/read_mapper/mapper/align_query_to_reference.hpp
seqan/learning-resources
e6447edca3a349cb350b73b31dbed9e3215447fc
[ "CC0-1.0", "CC-BY-4.0" ]
5
2019-08-21T11:39:30.000Z
2020-07-12T14:31:33.000Z
#pragma once #include <seqan3/alignment/matrix/detail/aligned_sequence_builder.hpp> #include <seqan3/alphabet/nucleotide/dna4.hpp> namespace read_mapper::mapper { using alignment_t = typename seqan3::detail::make_pairwise_alignment_type<std::span<seqan3::dna4 const> const, std::span<seqan3::dna4 const> const>::type; using align_query_to_reference_callback = std::function<void(int const /*score*/, size_t const /*sequence1_begin_position*/, read_mapper::mapper::alignment_t const & /*alignment*/)>; void align_query_to_reference(std::span<seqan3::dna4 const> const query_sequence, std::span<seqan3::dna4 const> const reference_sequence_region, align_query_to_reference_callback callback); } // read_mapper::mapper
39.608696
117
0.635565
seqan
b1feba8a5885bf5c11508e8c267a9d2c32d45c8b
4,338
cpp
C++
dali-toolkit/internal/transition-effects/cube-transition-fold-effect-impl.cpp
zyndor/dali-toolkit
9e3fd659c4d25706ab65345bc7c562ac27248325
[ "Apache-2.0", "BSD-3-Clause" ]
null
null
null
dali-toolkit/internal/transition-effects/cube-transition-fold-effect-impl.cpp
zyndor/dali-toolkit
9e3fd659c4d25706ab65345bc7c562ac27248325
[ "Apache-2.0", "BSD-3-Clause" ]
1
2020-10-19T15:47:43.000Z
2020-10-19T15:47:43.000Z
dali-toolkit/internal/transition-effects/cube-transition-fold-effect-impl.cpp
zyndor/dali-toolkit
9e3fd659c4d25706ab65345bc7c562ac27248325
[ "Apache-2.0", "BSD-3-Clause" ]
null
null
null
/* * Copyright (c) 2014 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ // CLASS HEADER #include "cube-transition-fold-effect-impl.h" namespace Dali { namespace Toolkit { namespace Internal { CubeTransitionFoldEffect::CubeTransitionFoldEffect( unsigned int numRows, unsigned int numColumns ) : CubeTransitionEffect( numRows, numColumns ) { } Toolkit::CubeTransitionFoldEffect CubeTransitionFoldEffect::New(unsigned int numRows, unsigned int numColumns ) { // Create the implementation IntrusivePtr< CubeTransitionFoldEffect > internalCubeTransEffect = new CubeTransitionFoldEffect( numRows, numColumns ); // Pass ownership to CustomActor handle Toolkit::CubeTransitionFoldEffect cubeTransEffect( *internalCubeTransEffect ); //Initialization internalCubeTransEffect->Initialize(); return cubeTransEffect; } void CubeTransitionFoldEffect::OnInitialize() { unsigned int idx; for( unsigned int y = 0; y < mRows; y++ ) { idx = y*mColumns; for( unsigned int x = y%2; x < mColumns; x=x+2) { SetTargetLeft( idx + x ); } for( unsigned int x = (y+1)%2; x < mColumns; x=x+2) { SetTargetRight( idx + x ); } } } void CubeTransitionFoldEffect::OnStartTransition( Vector2 panPosition, Vector2 panDisplacement ) { float angle = Math::PI_2; unsigned int idx; if( panDisplacement.x < 0 ) { for( unsigned int y = 0; y < mRows; y++ ) { idx = y*mColumns; for( unsigned int x = y%2; x < mColumns; x=x+2) { SetTargetLeft( idx + x ); } for( unsigned int x = (y+1)%2; x < mColumns; x=x+2) { SetTargetRight( idx + x ); } } } else { angle = -angle; for( unsigned int y = 0; y < mRows; y++ ) { idx = y*mColumns; for( unsigned int x = y%2; x < mColumns; x=x+2) { SetTargetRight( idx + x ); } for( unsigned int x = (y+1)%2; x < mColumns; x=x+2) { SetTargetLeft( idx + x ); } } } for( unsigned int y = 0; y < mRows; y++ ) { idx = y*mColumns; for( unsigned int x = y%2; x < mColumns; x=x+2) { SetupAnimation( idx + x, x, angle ); } for( unsigned int x = (y+1)%2; x < mColumns; x=x+2) { SetupAnimation( idx + x, x, -angle ); } } mAnimation.Play(); mIsAnimating = true; } void CubeTransitionFoldEffect::SetupAnimation( unsigned int actorIndex, unsigned int x, float angle ) { //rotate and translate the cube such that the edges remain in constant contact //calculate the maximum distance the cube has to move when it the box has rotated 45 degrees //ie distance from of centre of square to a vertex is given by: // distance = width / sqrt(2) //therefore the delta distance the cube should move is given by: // delta_distance = ( width / 2 ) - distance //re-arranging we get: // delta_distance = ( width / 2 ) * ( sqrt(2) - 1 ) //accumulating over the length of the row we get: // delta_distance_at_x = x * delta_distance; float delta = (float)x * mTileSize.x * ( 1.4142f - 1.0f ); Vector3 position( mBoxes[ actorIndex ].GetCurrentProperty< Vector3 >( Actor::Property::POSITION ) ); mAnimation.AnimateTo( Property( mBoxes[ actorIndex ], Actor::Property::ORIENTATION ), Quaternion( Radian( angle ), Vector3::YAXIS ), AlphaFunction::LINEAR ); mAnimation.AnimateTo( Property( mBoxes[ actorIndex ], Actor::Property::POSITION_X ), position.x + delta, AlphaFunction::BOUNCE ); mAnimation.AnimateTo( Property( mCurrentTiles[ actorIndex ], Actor::Property::COLOR ), HALF_BRIGHTNESS, AlphaFunction::EASE_OUT ); mAnimation.AnimateTo( Property( mTargetTiles[ actorIndex ], Actor::Property::COLOR ), FULL_BRIGHTNESS, AlphaFunction::EASE_IN ); } } // namespace Internal } // namespace Toolkit } // namespace Dali
29.310811
159
0.665975
zyndor
b1ffe636f815f8a5fb24caac853eac92983f0438
666
cc
C++
lib/asan/lit_tests/TestCases/Linux/syscalls.cc
darnic10/motocompiler
7cba5f1d950495b02bc8da53d27bdbb1b0d4f117
[ "MIT" ]
2
2015-02-22T14:05:30.000Z
2016-06-10T02:51:15.000Z
lib/asan/lit_tests/TestCases/Linux/syscalls.cc
darnic10/motocompiler
7cba5f1d950495b02bc8da53d27bdbb1b0d4f117
[ "MIT" ]
null
null
null
lib/asan/lit_tests/TestCases/Linux/syscalls.cc
darnic10/motocompiler
7cba5f1d950495b02bc8da53d27bdbb1b0d4f117
[ "MIT" ]
3
2017-07-31T18:26:06.000Z
2020-02-29T06:06:26.000Z
// RUN: %clangxx_asan -O0 %s -o %t && not %t 2>&1 | FileCheck %s // RUN: %clangxx_asan -O3 %s -o %t && not %t 2>&1 | FileCheck %s #include <assert.h> #include <errno.h> #include <glob.h> #include <stdio.h> #include <string.h> #include <sanitizer/linux_syscall_hooks.h> /* Test the presence of __sanitizer_syscall_ in the tool runtime, and general sanity of their behaviour. */ int main(int argc, char *argv[]) { char buf[1000]; __sanitizer_syscall_pre_recvmsg(0, buf - 1, 0); // CHECK: AddressSanitizer: stack-buffer-{{.*}}erflow // CHECK: READ of size {{.*}} at {{.*}} thread T0 // CHECK: #0 {{.*}} in __sanitizer_syscall_pre_recvmsg return 0; }
28.956522
77
0.657658
darnic10
5901717c63546ae5afec50f3c64f3199cde8c715
134
cpp
C++
src/classwork/04_assign/loops.cpp
acc-cosc-1337-spring-2021/acc-cosc-1337-spring-2021-Hannah-Kim-acc
6df68153283d7c974bf3fb3f174fd8185fa75372
[ "MIT" ]
null
null
null
src/classwork/04_assign/loops.cpp
acc-cosc-1337-spring-2021/acc-cosc-1337-spring-2021-Hannah-Kim-acc
6df68153283d7c974bf3fb3f174fd8185fa75372
[ "MIT" ]
null
null
null
src/classwork/04_assign/loops.cpp
acc-cosc-1337-spring-2021/acc-cosc-1337-spring-2021-Hannah-Kim-acc
6df68153283d7c974bf3fb3f174fd8185fa75372
[ "MIT" ]
null
null
null
//cpp #include "loops.h" int factorial(int num) { int fac = 1, i; for (i=1;i<=num;i++) { fac = fac * i; } return fac; }
11.166667
22
0.507463
acc-cosc-1337-spring-2021
59039b979d6453c36c53b2459a8b1da67ea5f77a
5,585
cpp
C++
SDK/PUBG_BP_FlaregunUiWidget_functions.cpp
realrespecter/PUBG-FULL-SDK
5e2b0f103c74c95d2329c4c9dfbfab48aa0da737
[ "MIT" ]
7
2019-03-06T11:04:52.000Z
2019-07-10T20:00:51.000Z
SDK/PUBG_BP_FlaregunUiWidget_functions.cpp
realrespecter/PUBG-FULL-SDK
5e2b0f103c74c95d2329c4c9dfbfab48aa0da737
[ "MIT" ]
null
null
null
SDK/PUBG_BP_FlaregunUiWidget_functions.cpp
realrespecter/PUBG-FULL-SDK
5e2b0f103c74c95d2329c4c9dfbfab48aa0da737
[ "MIT" ]
10
2019-03-06T11:53:46.000Z
2021-02-18T14:01:11.000Z
// PUBG FULL SDK - Generated By Respecter (5.3.4.11 [06/03/2019]) SDK #ifdef _MSC_VER #pragma pack(push, 0x8) #endif #include "PUBG_BP_FlaregunUiWidget_parameters.hpp" namespace SDK { //--------------------------------------------------------------------------- //Functions //--------------------------------------------------------------------------- // Function BP_FlaregunUiWidget.BP_FlaregunUiWidget_C.IsCarePackageComming // () // Parameters: // bool IsCarePackageComing (Parm, OutParm, ZeroConstructor, IsPlainOldData) // bool IsVehicleComing (Parm, OutParm, ZeroConstructor, IsPlainOldData) void UBP_FlaregunUiWidget_C::IsCarePackageComming(bool* IsCarePackageComing, bool* IsVehicleComing) { static auto fn = UObject::FindObject<UFunction>("Function BP_FlaregunUiWidget.BP_FlaregunUiWidget_C.IsCarePackageComming"); UBP_FlaregunUiWidget_C_IsCarePackageComming_Params params; auto flags = fn->FunctionFlags; UObject::ProcessEvent(fn, &params); fn->FunctionFlags = flags; if (IsCarePackageComing != nullptr) *IsCarePackageComing = params.IsCarePackageComing; if (IsVehicleComing != nullptr) *IsVehicleComing = params.IsVehicleComing; } // Function BP_FlaregunUiWidget.BP_FlaregunUiWidget_C.ShowTitle // () // Parameters: // bool bShow (Parm, ZeroConstructor, IsPlainOldData) void UBP_FlaregunUiWidget_C::ShowTitle(bool bShow) { static auto fn = UObject::FindObject<UFunction>("Function BP_FlaregunUiWidget.BP_FlaregunUiWidget_C.ShowTitle"); UBP_FlaregunUiWidget_C_ShowTitle_Params params; params.bShow = bShow; auto flags = fn->FunctionFlags; UObject::ProcessEvent(fn, &params); fn->FunctionFlags = flags; } // Function BP_FlaregunUiWidget.BP_FlaregunUiWidget_C.IsCharacterInWhiteZone // () // Parameters: // bool IsIn (Parm, OutParm, ZeroConstructor, IsPlainOldData) void UBP_FlaregunUiWidget_C::IsCharacterInWhiteZone(bool* IsIn) { static auto fn = UObject::FindObject<UFunction>("Function BP_FlaregunUiWidget.BP_FlaregunUiWidget_C.IsCharacterInWhiteZone"); UBP_FlaregunUiWidget_C_IsCharacterInWhiteZone_Params params; auto flags = fn->FunctionFlags; UObject::ProcessEvent(fn, &params); fn->FunctionFlags = flags; if (IsIn != nullptr) *IsIn = params.IsIn; } // Function BP_FlaregunUiWidget.BP_FlaregunUiWidget_C.SetVehicleNumber // () // Parameters: // int* NumVehicle (Parm, ZeroConstructor, IsPlainOldData) // bool* CanFire (Parm, ZeroConstructor, IsPlainOldData) // bool* WaitingMine (Parm, ZeroConstructor, IsPlainOldData) void UBP_FlaregunUiWidget_C::SetVehicleNumber(int* NumVehicle, bool* CanFire, bool* WaitingMine) { static auto fn = UObject::FindObject<UFunction>("Function BP_FlaregunUiWidget.BP_FlaregunUiWidget_C.SetVehicleNumber"); UBP_FlaregunUiWidget_C_SetVehicleNumber_Params params; params.NumVehicle = NumVehicle; params.CanFire = CanFire; params.WaitingMine = WaitingMine; auto flags = fn->FunctionFlags; UObject::ProcessEvent(fn, &params); fn->FunctionFlags = flags; } // Function BP_FlaregunUiWidget.BP_FlaregunUiWidget_C.SetPackageNumber // () // Parameters: // int* NumPackage (Parm, ZeroConstructor, IsPlainOldData) // bool* CanFire (Parm, ZeroConstructor, IsPlainOldData) // bool* WaitingMine (Parm, ZeroConstructor, IsPlainOldData) void UBP_FlaregunUiWidget_C::SetPackageNumber(int* NumPackage, bool* CanFire, bool* WaitingMine) { static auto fn = UObject::FindObject<UFunction>("Function BP_FlaregunUiWidget.BP_FlaregunUiWidget_C.SetPackageNumber"); UBP_FlaregunUiWidget_C_SetPackageNumber_Params params; params.NumPackage = NumPackage; params.CanFire = CanFire; params.WaitingMine = WaitingMine; auto flags = fn->FunctionFlags; UObject::ProcessEvent(fn, &params); fn->FunctionFlags = flags; } // Function BP_FlaregunUiWidget.BP_FlaregunUiWidget_C.Tick // (BlueprintCosmetic, Event) // Parameters: // struct FGeometry* MyGeometry (Parm, IsPlainOldData) // float* InDeltaTime (Parm, ZeroConstructor, IsPlainOldData) void UBP_FlaregunUiWidget_C::Tick(struct FGeometry* MyGeometry, float* InDeltaTime) { static auto fn = UObject::FindObject<UFunction>("Function BP_FlaregunUiWidget.BP_FlaregunUiWidget_C.Tick"); UBP_FlaregunUiWidget_C_Tick_Params params; params.MyGeometry = MyGeometry; params.InDeltaTime = InDeltaTime; auto flags = fn->FunctionFlags; UObject::ProcessEvent(fn, &params); fn->FunctionFlags = flags; } // Function BP_FlaregunUiWidget.BP_FlaregunUiWidget_C.ExecuteUbergraph_BP_FlaregunUiWidget // () // Parameters: // int* EntryPoint (Parm, ZeroConstructor, IsPlainOldData) void UBP_FlaregunUiWidget_C::ExecuteUbergraph_BP_FlaregunUiWidget(int* EntryPoint) { static auto fn = UObject::FindObject<UFunction>("Function BP_FlaregunUiWidget.BP_FlaregunUiWidget_C.ExecuteUbergraph_BP_FlaregunUiWidget"); UBP_FlaregunUiWidget_C_ExecuteUbergraph_BP_FlaregunUiWidget_Params params; params.EntryPoint = EntryPoint; auto flags = fn->FunctionFlags; UObject::ProcessEvent(fn, &params); fn->FunctionFlags = flags; } } #ifdef _MSC_VER #pragma pack(pop) #endif
31.553672
140
0.689705
realrespecter
5907fe3a335f678a2d86107a1b46cfc6fb2ee8e7
3,474
cpp
C++
MyApplication/Middlewares/ST/touchgfx/framework/source/touchgfx/widgets/AnimatedImage.cpp
rshane960/TouchGFX
1f1465f1aa1215d52264ae0199dafa821939de64
[ "MIT" ]
null
null
null
MyApplication/Middlewares/ST/touchgfx/framework/source/touchgfx/widgets/AnimatedImage.cpp
rshane960/TouchGFX
1f1465f1aa1215d52264ae0199dafa821939de64
[ "MIT" ]
null
null
null
MyApplication/Middlewares/ST/touchgfx/framework/source/touchgfx/widgets/AnimatedImage.cpp
rshane960/TouchGFX
1f1465f1aa1215d52264ae0199dafa821939de64
[ "MIT" ]
null
null
null
/****************************************************************************** * Copyright (c) 2018(-2021) STMicroelectronics. * All rights reserved. * * This file is part of the TouchGFX 4.18.1 distribution. * * This software is licensed under terms that can be found in the LICENSE file in * the root directory of this software component. * If no LICENSE file comes with this software, it is provided AS-IS. * *******************************************************************************/ #include <touchgfx/hal/Types.hpp> #include <touchgfx/Application.hpp> #include <touchgfx/Bitmap.hpp> #include <touchgfx/widgets/AnimatedImage.hpp> #include <touchgfx/widgets/Image.hpp> namespace touchgfx { void AnimatedImage::handleTickEvent() { if (!running) { return; } ++ticksSinceUpdate; if (ticksSinceUpdate != updateTicksInterval) { return; } ticksSinceUpdate = 0; BitmapId currentId = getBitmap(); if (((currentId == endId) && !reverse) || ((currentId == startId) && reverse)) { if (!loopAnimation) { Application::getInstance()->unregisterTimerWidget(this); running = false; } if (animationDoneAction && animationDoneAction->isValid()) { animationDoneAction->execute(*this); } if (running && loopAnimation) { if (reverse) { Image::setBitmap(Bitmap(endId)); } else { Image::setBitmap(Bitmap(startId)); } invalidate(); } } else { if (reverse) { --currentId; } else { ++currentId; } Image::setBitmap(Bitmap(currentId)); invalidate(); } } void AnimatedImage::startAnimation(const bool rev, const bool reset /*= false*/, const bool loop /*= false*/) { if ((startId != BITMAP_INVALID) && (endId != BITMAP_INVALID)) { reverse = rev; loopAnimation = loop; if (reverse && reset) { Image::setBitmap(Bitmap(endId)); invalidate(); } else if (!reverse && reset) { Image::setBitmap(Bitmap(startId)); invalidate(); } Application::getInstance()->registerTimerWidget(this); running = true; } } void AnimatedImage::stopAnimation() { if (running) { Application::getInstance()->unregisterTimerWidget(this); running = false; } if (reverse) { Image::setBitmap(Bitmap(endId)); } else { Image::setBitmap(Bitmap(startId)); } invalidate(); } void AnimatedImage::pauseAnimation() { if (running) { Application::getInstance()->unregisterTimerWidget(this); running = false; } else { Application::getInstance()->registerTimerWidget(this); running = true; } } void AnimatedImage::setBitmap(const Bitmap& bitmap) { startId = bitmap.getId(); Image::setBitmap(bitmap); } void AnimatedImage::setBitmapEnd(const Bitmap& bitmap) { endId = bitmap.getId(); } void AnimatedImage::setBitmaps(BitmapId start, BitmapId end) { setBitmap(start); setBitmapEnd(end); } void AnimatedImage::setUpdateTicksInterval(uint8_t updateInterval) { updateTicksInterval = updateInterval; ticksSinceUpdate = 0; } } // namespace touchgfx
22.705882
109
0.553541
rshane960
590e4e912367f4e3eb59f72fc24f122c1539b204
13,487
cc
C++
tensorflow/core/kernels/queue_base.cc
ryan-collins-forks/tensorflow
080a1f6c64976b11437d2dc4ef4178e4ca1205b7
[ "Apache-2.0" ]
null
null
null
tensorflow/core/kernels/queue_base.cc
ryan-collins-forks/tensorflow
080a1f6c64976b11437d2dc4ef4178e4ca1205b7
[ "Apache-2.0" ]
null
null
null
tensorflow/core/kernels/queue_base.cc
ryan-collins-forks/tensorflow
080a1f6c64976b11437d2dc4ef4178e4ca1205b7
[ "Apache-2.0" ]
1
2019-11-15T21:19:42.000Z
2019-11-15T21:19:42.000Z
/* Copyright 2015 Google Inc. All Rights Reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ==============================================================================*/ #include "tensorflow/core/kernels/queue_base.h" #include "tensorflow/core/lib/core/errors.h" #include "tensorflow/core/platform/mutex.h" #include "tensorflow/core/platform/port.h" #include "tensorflow/core/public/tensor_shape.h" namespace tensorflow { namespace { template <DataType DT> Status HandleSliceToElement(const Tensor& parent, Tensor* element, int index) { typedef typename EnumToDataType<DT>::Type T; DCHECK_NE(parent.dim_size(0), 0); if (element->NumElements() != (parent.NumElements() / parent.dim_size(0))) { TensorShape chip_shape = parent.shape(); chip_shape.RemoveDim(0); return errors::Internal( "Cannot copy slice: number of elements does not match. Shapes are: " "[element]: ", element->shape().DebugString(), ", [parent slice]: ", chip_shape.DebugString()); } auto parent_as_matrix = parent.flat_outer_dims<T>(); element->flat<T>() = parent_as_matrix.chip(index, 0); return Status::OK(); } template <DataType DT> Status HandleElementToSlice(const Tensor& element, Tensor* parent, int index) { typedef typename EnumToDataType<DT>::Type T; DCHECK_NE(parent->dim_size(0), 0); if (element.NumElements() != (parent->NumElements() / parent->dim_size(0))) { TensorShape chip_shape = parent->shape(); chip_shape.RemoveDim(0); return errors::Internal( "Cannot copy slice: number of elements does not match. Shapes are: " "[element]: ", element.shape().DebugString(), ", [parent slice]: ", chip_shape.DebugString()); } auto parent_as_matrix = parent->flat_outer_dims<T>(); parent_as_matrix.chip(index, 0) = element.flat<T>(); return Status::OK(); } } // namespace QueueBase::QueueBase(int32 capacity, const DataTypeVector& component_dtypes, const std::vector<TensorShape>& component_shapes, const string& name) : capacity_(capacity), component_dtypes_(component_dtypes), component_shapes_(component_shapes), name_(name), closed_(false) {} Status QueueBase::ValidateTupleCommon(const Tuple& tuple) const { if (tuple.size() != static_cast<size_t>(num_components())) { return errors::InvalidArgument( "Wrong number of components in tuple. Expected ", num_components(), ", got ", tuple.size()); } for (size_t i = 0; i < tuple.size(); ++i) { if (tuple[i].dtype() != component_dtypes_[i]) { return errors::InvalidArgument( "Type mismatch in tuple component ", i, ". Expected ", DataTypeString(component_dtypes_[i]), ", got ", DataTypeString(tuple[i].dtype())); } } return Status::OK(); } // static string QueueBase::ShapeListString(const gtl::ArraySlice<TensorShape>& shapes) { string result = "["; bool first = true; for (const TensorShape& shape : shapes) { strings::StrAppend(&result, (first ? "" : ", "), shape.ShortDebugString()); first = false; } strings::StrAppend(&result, "]"); return result; } Status QueueBase::MatchesNodeDefOp(const NodeDef& node_def, const string& op) const { if (node_def.op() != op) { return errors::InvalidArgument("Shared queue '", name_, "' has type '", op, "' that does not match type of Node '", node_def.name(), "': ", node_def.op()); } return Status::OK(); } Status QueueBase::MatchesNodeDefCapacity(const NodeDef& node_def, int32 capacity) const { int32 requested_capacity = -1; TF_RETURN_IF_ERROR(GetNodeAttr(node_def, "capacity", &requested_capacity)); if (requested_capacity < 0) requested_capacity = kUnbounded; if (requested_capacity != capacity) { return errors::InvalidArgument("Shared queue '", name_, "' has capacity ", capacity, " but requested capacity was ", requested_capacity); } return Status::OK(); } Status QueueBase::MatchesNodeDefTypes(const NodeDef& node_def) const { DataTypeVector requested_dtypes; TF_RETURN_IF_ERROR( GetNodeAttr(node_def, "component_types", &requested_dtypes)); if (requested_dtypes != component_dtypes_) { return errors::InvalidArgument("Shared queue '", name_, "' has component types ", DataTypeSliceString(component_dtypes_), " but requested component types were ", DataTypeSliceString(requested_dtypes)); } return Status::OK(); } Status QueueBase::MatchesNodeDefShapes(const NodeDef& node_def) const { std::vector<TensorShape> requested_shapes; TF_RETURN_IF_ERROR(GetNodeAttr(node_def, "shapes", &requested_shapes)); if (requested_shapes != component_shapes_) { return errors::InvalidArgument("Shared queue '", name_, "' has component shapes ", ShapeListString(component_shapes_), " but requested component shapes were ", ShapeListString(requested_shapes)); } return Status::OK(); } // TODO(mrry): If these checks become a bottleneck, find a way to // reduce the number of times that they are called. Status QueueBase::ValidateTuple(const Tuple& tuple) { TF_RETURN_IF_ERROR(ValidateTupleCommon(tuple)); if (specified_shapes()) { for (size_t i = 0; i < tuple.size(); ++i) { if (!tuple[i].shape().IsSameSize(component_shapes_[i])) { return errors::InvalidArgument( "Shape mismatch in tuple component ", i, ". Expected ", component_shapes_[i].ShortDebugString(), ", got ", tuple[i].shape().ShortDebugString()); } } } return Status::OK(); } // TODO(mrry): If these checks become a bottleneck, find a way to // reduce the number of times that they are called. Status QueueBase::ValidateManyTuple(const Tuple& tuple) { TF_RETURN_IF_ERROR(ValidateTupleCommon(tuple)); const int64 batch_size = tuple[0].dim_size(0); if (specified_shapes()) { for (size_t i = 0; i < tuple.size(); ++i) { // Expected shape is [batch_size] + component_shapes_[i] const TensorShape expected_shape = ManyOutShape(i, batch_size); if (!tuple[i].shape().IsSameSize(expected_shape)) { return errors::InvalidArgument( "Shape mismatch in tuple component ", i, ". Expected ", expected_shape.ShortDebugString(), ", got ", tuple[i].shape().ShortDebugString()); } } } else { for (size_t i = 1; i < tuple.size(); ++i) { if (tuple[i].dim_size(0) != batch_size) { return errors::InvalidArgument( "All input tensors must have the same size in the 0th ", "dimension. Component ", i, " has ", tuple[i].dim_size(0), ", and should have ", batch_size); } } } return Status::OK(); } void QueueBase::Cancel(Action action, CancellationToken token) { DoneCallback callback = nullptr; { mutex_lock lock(mu_); std::deque<Attempt>* attempts = action == kEnqueue ? &enqueue_attempts_ : &dequeue_attempts_; for (Attempt& attempt : *attempts) { if (attempt.cancellation_token == token) { if (!attempt.is_cancelled) { attempt.is_cancelled = true; if (action == kEnqueue) { attempt.context->SetStatus( errors::Cancelled("Enqueue operation was cancelled")); } else { attempt.context->SetStatus( errors::Cancelled("Dequeue operation was cancelled")); } std::swap(callback, attempt.done_callback); } break; } } } if (callback) { callback(); FlushUnlocked(); } } void QueueBase::CloseAndCancel() { std::vector<DoneCallback> callbacks; { mutex_lock lock(mu_); closed_ = true; for (Attempt& attempt : enqueue_attempts_) { if (!attempt.is_cancelled) { attempt.is_cancelled = true; attempt.context->SetStatus( errors::Cancelled("Enqueue operation was cancelled")); callbacks.emplace_back(std::move(attempt.done_callback)); } } } for (const DoneCallback& callback : callbacks) { callback(); } FlushUnlocked(); } void QueueBase::Close(OpKernelContext* ctx, bool cancel_pending_enqueues, DoneCallback callback) { if (cancel_pending_enqueues) { CloseAndCancel(); callback(); } else { { mutex_lock lock(mu_); enqueue_attempts_.emplace_back( 0, callback, ctx, CancellationManager::kInvalidToken, [this](Attempt* attempt) EXCLUSIVE_LOCKS_REQUIRED(mu_) { if (closed_) { attempt->context->SetStatus( errors::Aborted("Queue '", name_, "' is already closed.")); } else { closed_ = true; } return kComplete; }); } FlushUnlocked(); } } bool QueueBase::TryAttemptLocked(Action action, std::vector<CleanUp>* clean_up) { std::deque<Attempt>* attempts = action == kEnqueue ? &enqueue_attempts_ : &dequeue_attempts_; bool progress = false; bool done = false; while (!done && !attempts->empty()) { if (attempts->front().is_cancelled) { if (action == kEnqueue) { LOG(INFO) << "Skipping cancelled enqueue attempt"; } else { LOG(INFO) << "Skipping cancelled dequeue attempt"; } attempts->pop_front(); } else { Attempt* cur_attempt = &attempts->front(); switch (cur_attempt->run_callback(cur_attempt)) { case kNoProgress: done = true; break; case kProgress: done = true; progress = true; break; case kComplete: progress = true; clean_up->emplace_back(std::move(cur_attempt->done_callback), cur_attempt->cancellation_token, cur_attempt->context->cancellation_manager()); attempts->pop_front(); break; } } } return progress; } void QueueBase::FlushUnlocked() { std::vector<CleanUp> clean_up; Ref(); { mutex_lock lock(mu_); bool changed; do { changed = TryAttemptLocked(kEnqueue, &clean_up); changed = TryAttemptLocked(kDequeue, &clean_up) || changed; } while (changed); } Unref(); for (const auto& to_clean : clean_up) { if (to_clean.to_deregister != CancellationManager::kInvalidToken) { // NOTE(mrry): We can safely ignore the return value of // DeregisterCallback because the mutex mu_ ensures that the // cleanup action only executes once. to_clean.cm->DeregisterCallback(to_clean.to_deregister); } to_clean.finished(); } } // Static method Status QueueBase::CopySliceToElement(const Tensor& parent, Tensor* element, int index) { #define HANDLE_TYPE(DT) \ if (parent.dtype() == DT) { \ TF_RETURN_IF_ERROR(HandleSliceToElement<DT>(parent, element, index)); \ return Status::OK(); \ } HANDLE_TYPE(DT_FLOAT); HANDLE_TYPE(DT_DOUBLE); HANDLE_TYPE(DT_INT32); HANDLE_TYPE(DT_UINT8); HANDLE_TYPE(DT_INT16); HANDLE_TYPE(DT_INT8); HANDLE_TYPE(DT_STRING); HANDLE_TYPE(DT_COMPLEX64); HANDLE_TYPE(DT_INT64); HANDLE_TYPE(DT_BOOL); HANDLE_TYPE(DT_QINT8); HANDLE_TYPE(DT_QUINT8); HANDLE_TYPE(DT_QINT32); HANDLE_TYPE(DT_QINT16); HANDLE_TYPE(DT_QUINT16); #undef HANDLE_TYPE return errors::Unimplemented("Unhandled data type: ", parent.dtype()); } // Static method Status QueueBase::CopyElementToSlice(const Tensor& element, Tensor* parent, int index) { #define HANDLE_TYPE(DT) \ if (element.dtype() == DT) { \ TF_RETURN_IF_ERROR(HandleElementToSlice<DT>(element, parent, index)); \ return Status::OK(); \ } HANDLE_TYPE(DT_FLOAT); HANDLE_TYPE(DT_DOUBLE); HANDLE_TYPE(DT_INT32); HANDLE_TYPE(DT_UINT8); HANDLE_TYPE(DT_INT16); HANDLE_TYPE(DT_INT8); HANDLE_TYPE(DT_STRING); HANDLE_TYPE(DT_COMPLEX64); HANDLE_TYPE(DT_INT64); HANDLE_TYPE(DT_BOOL); HANDLE_TYPE(DT_QINT8); HANDLE_TYPE(DT_QUINT8); HANDLE_TYPE(DT_QINT32); HANDLE_TYPE(DT_QINT16); HANDLE_TYPE(DT_QUINT16); #undef HANDLE_TYPE return errors::Unimplemented("Unhandled data type: ", element.dtype()); } } // namespace tensorflow
34.670951
80
0.61259
ryan-collins-forks
590ed4ca49028a484fcdebe5965235d7a9b12bff
9,585
cpp
C++
lib/Transforms/BreakConstantGEPs/BreakConstantGEPs.cpp
seec-team/seec
4b92456011e86b70f9d88833a95c1f655a21cf1a
[ "MIT" ]
7
2018-06-25T12:06:13.000Z
2022-01-18T09:20:13.000Z
lib/Transforms/BreakConstantGEPs/BreakConstantGEPs.cpp
seec-team/seec
4b92456011e86b70f9d88833a95c1f655a21cf1a
[ "MIT" ]
20
2016-12-01T23:46:12.000Z
2019-08-11T02:41:04.000Z
lib/Transforms/BreakConstantGEPs/BreakConstantGEPs.cpp
seec-team/seec
4b92456011e86b70f9d88833a95c1f655a21cf1a
[ "MIT" ]
1
2020-10-19T03:20:05.000Z
2020-10-19T03:20:05.000Z
//===- BreakConstantGEPs.cpp - Change constant GEPs into GEP instructions - --// // // The SAFECode Compiler // // This file was developed by the LLVM research group and is distributed under // the University of Illinois Open Source License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // // This pass changes all GEP constant expressions into GEP instructions. This // permits the rest of SAFECode to put run-time checks on them if necessary. // //===----------------------------------------------------------------------===// #define DEBUG_TYPE "break-constgeps" #include "llvm/ADT/Statistic.h" #include "llvm/IR/Constants.h" #include "llvm/IR/InstrTypes.h" #include "llvm/IR/Instruction.h" #include "llvm/IR/Instructions.h" #include "llvm/IR/LLVMContext.h" #include "llvm/IR/InstIterator.h" #include "seec/Transforms/BreakConstantGEPs/BreakConstantGEPs.h" #include <iostream> #include <map> #include <utility> namespace llvm { // Identifier variable for the pass char BreakConstantGEPs::ID = 0; // Statistics STATISTIC (GEPChanges, "Number of Converted GEP Constant Expressions"); STATISTIC (TotalChanges, "Number of Converted Constant Expressions"); // Register the pass static RegisterPass<BreakConstantGEPs> P ("break-constgeps", "Remove GEP Constant Expressions"); // // Function: hasConstantGEP() // // Description: // This function determines whether the given value is a constant expression // that has a constant GEP expression embedded within it. // // Inputs: // V - The value to check. // // Return value: // NULL - This value is not a constant expression with a constant expression // GEP within it. // ~NULL - A pointer to the value casted into a ConstantExpr is returned. // static ConstantExpr * hasConstantGEP (Value * V) { if (ConstantExpr * CE = dyn_cast<ConstantExpr>(V)) { if (CE->getOpcode() == Instruction::GetElementPtr) { return CE; } else { for (unsigned index = 0; index < CE->getNumOperands(); ++index) { if (hasConstantGEP (CE->getOperand(index))) return CE; } } } return 0; } // // Function: convertGEP() // // Description: // Convert a GEP constant expression into a GEP instruction. // // Inputs: // CE - The GEP constant expression. // InsertPt - The instruction before which to insert the new GEP instruction. // // Return value: // A pointer to the new GEP instruction is returned. // static Instruction * convertGEP (ConstantExpr * CE, Instruction * InsertPt) { // // Create iterators to the indices of the constant expression. // std::vector<Value *> Indices; for (unsigned index = 1; index < CE->getNumOperands(); ++index) { Indices.push_back (CE->getOperand (index)); } // // Update the statistics. // ++GEPChanges; // // Make the new GEP instruction. // return (GetElementPtrInst::Create (nullptr, CE->getOperand(0), Indices, CE->getName(), InsertPt)); } // // Function: convertExpression() // // Description: // Convert a constant expression into an instruction. This routine does *not* // perform any recursion, so the resulting instruction may have constant // expression operands. // static Instruction * convertExpression (ConstantExpr * CE, Instruction * InsertPt) { // // Convert this constant expression into a regular instruction. // Instruction * NewInst = 0; switch (CE->getOpcode()) { case Instruction::GetElementPtr: { NewInst = convertGEP (CE, InsertPt); break; } case Instruction::Add: case Instruction::Sub: case Instruction::Mul: case Instruction::UDiv: case Instruction::SDiv: case Instruction::FDiv: case Instruction::URem: case Instruction::SRem: case Instruction::FRem: case Instruction::Shl: case Instruction::LShr: case Instruction::AShr: case Instruction::And: case Instruction::Or: case Instruction::Xor: { Instruction::BinaryOps Op = (Instruction::BinaryOps)(CE->getOpcode()); NewInst = BinaryOperator::Create (Op, CE->getOperand(0), CE->getOperand(1), CE->getName(), InsertPt); break; } case Instruction::Trunc: case Instruction::ZExt: case Instruction::SExt: case Instruction::FPToUI: case Instruction::FPToSI: case Instruction::UIToFP: case Instruction::SIToFP: case Instruction::FPTrunc: case Instruction::FPExt: case Instruction::PtrToInt: case Instruction::IntToPtr: case Instruction::BitCast: { Instruction::CastOps Op = (Instruction::CastOps)(CE->getOpcode()); NewInst = CastInst::Create (Op, CE->getOperand(0), CE->getType(), CE->getName(), InsertPt); break; } case Instruction:: FCmp: case Instruction:: ICmp: { Instruction::OtherOps Op = (Instruction::OtherOps)(CE->getOpcode()); NewInst = CmpInst::Create (Op, static_cast<CmpInst::Predicate>(CE->getPredicate()), CE->getOperand(0), CE->getOperand(1), CE->getName(), InsertPt); break; } case Instruction:: Select: NewInst = SelectInst::Create (CE->getOperand(0), CE->getOperand(1), CE->getOperand(2), CE->getName(), InsertPt); break; case Instruction:: ExtractElement: case Instruction:: InsertElement: case Instruction:: ShuffleVector: case Instruction:: InsertValue: default: assert (0 && "Unhandled constant expression!\n"); break; } // // Update the statistics. // ++TotalChanges; return NewInst; } // // Method: runOnFunction() // // Description: // Entry point for this LLVM pass. // // Return value: // true - The function was modified. // false - The function was not modified. // bool BreakConstantGEPs::runOnFunction (Function & F) { bool modified = false; // Worklist of values to check for constant GEP expressions std::vector<Instruction *> Worklist; // // Initialize the worklist by finding all instructions that have one or more // operands containing a constant GEP expression. // for (Function::iterator BB = F.begin(); BB != F.end(); ++BB) { for (BasicBlock::iterator i = BB->begin(); i != BB->end(); ++i) { // // Scan through the operands of this instruction. If it is a constant // expression GEP, insert an instruction GEP before the instruction. // Instruction *I = &*i; for (unsigned index = 0; index < I->getNumOperands(); ++index) { if (hasConstantGEP (I->getOperand(index))) { Worklist.push_back (I); } } } } // // Determine whether we will modify anything. // if (Worklist.size()) modified = true; // // While the worklist is not empty, take an item from it, convert the // operands into instructions if necessary, and determine if the newly // added instructions need to be processed as well. // while (Worklist.size()) { Instruction * I = Worklist.back(); Worklist.pop_back(); // // Scan through the operands of this instruction and convert each into an // instruction. Note that this works a little differently for phi // instructions because the new instruction must be added to the // appropriate predecessor block. // if (PHINode * PHI = dyn_cast<PHINode>(I)) { for (unsigned index = 0; index < PHI->getNumIncomingValues(); ++index) { // // For PHI Nodes, if an operand is a constant expression with a GEP, we // want to insert the new instructions in the predecessor basic block. // // Note: It seems that it's possible for a phi to have the same // incoming basic block listed multiple times; this seems okay as long // the same value is listed for the incoming block. // Instruction * InsertPt = PHI->getIncomingBlock(index)->getTerminator(); if (ConstantExpr * CE = hasConstantGEP (PHI->getIncomingValue(index))) { Instruction * NewInst = convertExpression (CE, InsertPt); for (unsigned i2 = index; i2 < PHI->getNumIncomingValues(); ++i2) { if ((PHI->getIncomingBlock (i2)) == PHI->getIncomingBlock (index)) PHI->setIncomingValue (i2, NewInst); } Worklist.push_back (NewInst); } } } else { for (unsigned index = 0; index < I->getNumOperands(); ++index) { // // For other instructions, we want to insert instructions replacing // constant expressions immediently before the instruction using the // constant expression. // if (ConstantExpr * CE = hasConstantGEP (I->getOperand(index))) { Instruction * NewInst = convertExpression (CE, I); I->replaceUsesOfWith (CE, NewInst); Worklist.push_back (NewInst); } } } } return modified; } } // namespace llvm
30.819936
80
0.59614
seec-team
590f37657e8ada6e3fe917bbe0be2a57e9a2e329
166
hpp
C++
addons/uh60_sfmplus/script_component.hpp
ZHANGTIANYAO1/H-60
4c6764f74190dbe7d81ddeae746cf78d8b7dff92
[ "Naumen", "Condor-1.1", "MS-PL" ]
null
null
null
addons/uh60_sfmplus/script_component.hpp
ZHANGTIANYAO1/H-60
4c6764f74190dbe7d81ddeae746cf78d8b7dff92
[ "Naumen", "Condor-1.1", "MS-PL" ]
null
null
null
addons/uh60_sfmplus/script_component.hpp
ZHANGTIANYAO1/H-60
4c6764f74190dbe7d81ddeae746cf78d8b7dff92
[ "Naumen", "Condor-1.1", "MS-PL" ]
null
null
null
#define COMPONENT uh60_sfmplus #define COMPONENT_BEAUTIFIED UH60_SFMPLUS #include "\z\vtx\addons\main\script_mod.hpp" #include "\z\vtx\addons\main\script_macros.hpp"
33.2
47
0.819277
ZHANGTIANYAO1
591033ee343329a6afb928d983ea1afe9fb1b32d
119
cpp
C++
ThreadsFuturePromise/source/SensorData.cpp
DennyMarx/modern-cpp-samples
d44d46495143795f5a8ddd61a1c21950e76a3ef2
[ "MIT" ]
null
null
null
ThreadsFuturePromise/source/SensorData.cpp
DennyMarx/modern-cpp-samples
d44d46495143795f5a8ddd61a1c21950e76a3ef2
[ "MIT" ]
null
null
null
ThreadsFuturePromise/source/SensorData.cpp
DennyMarx/modern-cpp-samples
d44d46495143795f5a8ddd61a1c21950e76a3ef2
[ "MIT" ]
null
null
null
#include "SensorData.h" SensorData::SensorData() : sensorValue(0) { } SensorData::~SensorData() { }
8.5
26
0.588235
DennyMarx
5914655ca4149f1d58c977418edc5e61bafc101f
16,612
cpp
C++
lib/src/btv_l1_gpu.cpp
raulnguyen/SuperResolution
59a783cce8032f1eeb7e6c95c95902f1b5c7c673
[ "BSD-3-Clause" ]
16
2015-03-12T10:55:27.000Z
2022-01-15T11:31:12.000Z
lib/src/btv_l1_gpu.cpp
raulnguyen/SuperResolution
59a783cce8032f1eeb7e6c95c95902f1b5c7c673
[ "BSD-3-Clause" ]
null
null
null
lib/src/btv_l1_gpu.cpp
raulnguyen/SuperResolution
59a783cce8032f1eeb7e6c95c95902f1b5c7c673
[ "BSD-3-Clause" ]
4
2015-03-16T10:34:47.000Z
2017-12-13T13:28:28.000Z
// Copyright (c) 2012, Vladislav Vinogradov (jet47) // 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 <organization> 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 <COPYRIGHT HOLDER> 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 "super_resolution.hpp" #include <opencv2/gpu/stream_accessor.hpp> #include "ring_buffer.hpp" using namespace std; using namespace cv; using namespace cv::gpu; using namespace cv::videostab; using namespace cv::superres; namespace btv_l1_device { void buildMotionMaps(PtrStepSzf motionx, PtrStepSzf motiony, PtrStepSzf forwardx, PtrStepSzf forwardy, PtrStepSzf backwardx, PtrStepSzf backwardy); template <int cn> void upscale(const PtrStepSzb src, PtrStepSzb dst, int scale, cudaStream_t stream); void diffSign(PtrStepSzf src1, PtrStepSzf src2, PtrStepSzf dst, cudaStream_t stream); void loadBtvWeights(const float* weights, size_t count); template <int cn> void calcBtvRegularization(PtrStepSzb src, PtrStepSzb dst, int ksize); } namespace { void calcRelativeMotions(const vector<pair<GpuMat, GpuMat> >& forwardMotions, vector<pair<GpuMat, GpuMat> >& relMotions, int baseIdx, Size size) { CV_DbgAssert( baseIdx >= 0 && baseIdx <= forwardMotions.size() ); #ifdef _DEBUG for (size_t i = 0; i < forwardMotions.size(); ++i) { CV_DbgAssert( forwardMotions[i].first.size() == size ); CV_DbgAssert( forwardMotions[i].second.size() == size ); CV_DbgAssert( forwardMotions[i].first.type() == CV_32FC1 ); CV_DbgAssert( forwardMotions[i].second.type() == CV_32FC1 ); } #endif relMotions.resize(forwardMotions.size() + 1); relMotions[baseIdx].first.create(size, CV_32FC1); relMotions[baseIdx].first.setTo(Scalar::all(0)); relMotions[baseIdx].second.create(size, CV_32FC1); relMotions[baseIdx].second.setTo(Scalar::all(0)); for (int i = baseIdx - 1; i >= 0; --i) { gpu::add(relMotions[i + 1].first, forwardMotions[i].first, relMotions[i].first); gpu::add(relMotions[i + 1].second, forwardMotions[i].second, relMotions[i].second); } for (size_t i = baseIdx + 1; i < relMotions.size(); ++i) { gpu::subtract(relMotions[i - 1].first, forwardMotions[i - 1].first, relMotions[i].first); gpu::subtract(relMotions[i - 1].second, forwardMotions[i - 1].second, relMotions[i].second); } } void upscaleMotions(const vector<pair<GpuMat, GpuMat> >& lowResMotions, vector<pair<GpuMat, GpuMat> >& highResMotions, int scale) { CV_DbgAssert( !lowResMotions.empty() ); #ifdef _DEBUG for (size_t i = 0; i < lowResMotions.size(); ++i) { CV_DbgAssert( lowResMotions[i].first.size() == lowResMotions[0].first.size() ); CV_DbgAssert( lowResMotions[i].second.size() == lowResMotions[0].first.size() ); CV_DbgAssert( lowResMotions[i].first.type() == CV_32FC1 ); CV_DbgAssert( lowResMotions[i].second.type() == CV_32FC1 ); } #endif CV_DbgAssert( scale > 1 ); highResMotions.resize(lowResMotions.size()); for (size_t i = 0; i < lowResMotions.size(); ++i) { gpu::resize(lowResMotions[i].first, highResMotions[i].first, Size(), scale, scale, INTER_CUBIC); gpu::resize(lowResMotions[i].second, highResMotions[i].second, Size(), scale, scale, INTER_CUBIC); gpu::multiply(highResMotions[i].first, Scalar::all(scale), highResMotions[i].first); gpu::multiply(highResMotions[i].second, Scalar::all(scale), highResMotions[i].second); } } void buildMotionMaps(const pair<GpuMat, GpuMat>& motion, pair<GpuMat, GpuMat>& forwardMap, pair<GpuMat, GpuMat>& backwardMap) { CV_DbgAssert( motion.first.type() == CV_32FC1 ); CV_DbgAssert( motion.second.type() == motion.first.type() ); CV_DbgAssert( motion.second.size() == motion.first.size() ); forwardMap.first.create(motion.first.size(), motion.first.type()); forwardMap.second.create(motion.first.size(), motion.first.type()); backwardMap.first.create(motion.first.size(), motion.first.type()); backwardMap.second.create(motion.first.size(), motion.first.type()); btv_l1_device::buildMotionMaps(motion.first, motion.second, forwardMap.first, forwardMap.second, backwardMap.first, backwardMap.second); } void upscale(const GpuMat& src, GpuMat& dst, int scale, Stream& stream) { typedef void (*func_t)(const PtrStepSzb src, PtrStepSzb dst, int scale, cudaStream_t stream); static const func_t funcs[] = { 0, btv_l1_device::upscale<1>, 0, btv_l1_device::upscale<3>, btv_l1_device::upscale<4> }; CV_DbgAssert( src.depth() == CV_32F ); CV_DbgAssert( src.channels() == 1 || src.channels() == 3 || src.channels() == 4 ); CV_DbgAssert( scale > 1 ); dst.create(src.rows * scale, src.cols * scale, src.type()); dst.setTo(Scalar::all(0)); const func_t func = funcs[src.channels()]; func(src, dst, scale, StreamAccessor::getStream(stream)); } void diffSign(const GpuMat& src1, const GpuMat& src2, GpuMat& dst, Stream& stream) { CV_DbgAssert( src1.depth() == CV_32F ); CV_DbgAssert( src1.type() == src2.type() ); CV_DbgAssert( src1.size() == src2.size() ); dst.create(src1.size(), src1.type()); btv_l1_device::diffSign(src1.reshape(1), src2.reshape(1), dst.reshape(1), StreamAccessor::getStream(stream)); } void calcBtvWeights(int btvKernelSize, double alpha, vector<float>& btvWeights) { CV_DbgAssert( btvKernelSize > 0 && btvKernelSize <= 16 ); CV_DbgAssert( alpha > 0 ); const size_t size = btvKernelSize * btvKernelSize; btvWeights.resize(size); const int ksize = (btvKernelSize - 1) / 2; const float alpha_f = static_cast<float>(alpha); for (int m = 0, ind = 0; m <= ksize; ++m) { for (int l = ksize; l + m >= 0; --l, ++ind) btvWeights[ind] = pow(alpha_f, std::abs(m) + std::abs(l)); } btv_l1_device::loadBtvWeights(&btvWeights[0], size); } void calcBtvRegularization(const GpuMat& src, GpuMat& dst, int btvKernelSize) { typedef void (*func_t)(PtrStepSzb src, PtrStepSzb dst, int ksize); static const func_t funcs[] = { 0, btv_l1_device::calcBtvRegularization<1>, 0, btv_l1_device::calcBtvRegularization<3>, btv_l1_device::calcBtvRegularization<4> }; CV_DbgAssert( src.depth() == CV_32F ); CV_DbgAssert( src.channels() == 1 || src.channels() == 3 || src.channels() == 4 ); CV_DbgAssert( btvKernelSize > 0 && btvKernelSize <= 16 ); dst.create(src.size(), src.type()); dst.setTo(Scalar::all(0)); const int ksize = (btvKernelSize - 1) / 2; funcs[src.channels()](src, dst, ksize); } } cv::superres::BTV_L1_GPU_Base::BTV_L1_GPU_Base() { scale = 4; iterations = 180; lambda = 0.03; tau = 1.3; alpha = 0.7; btvKernelSize = 7; blurKernelSize = 5; blurSigma = 0.0; opticalFlow = new Farneback_GPU; curBtvKernelSize = -1; curAlpha = -1.0; curBlurKernelSize = -1; curBlurSigma = -1.0; curSrcType = -1; } void cv::superres::BTV_L1_GPU_Base::process(const vector<GpuMat>& src, GpuMat& dst, int baseIdx) { CV_DbgAssert( !src.empty() ); #ifdef _DEBUG for (size_t i = 1; i < src.size(); ++i) { CV_DbgAssert( src[i].size() == src[0].size() ); CV_DbgAssert( src[i].type() == src[0].type() ); } #endif CV_DbgAssert( baseIdx >= 0 && baseIdx < src.size() ); // calc motions between input frames lowResMotions.resize(src.size()); for (size_t i = 0; i < src.size(); ++i) { if (i != baseIdx) opticalFlow->calc(src[i], src[baseIdx], lowResMotions[i].first, lowResMotions[i].second); else { lowResMotions[i].first.create(src[i].size(), CV_32FC1); lowResMotions[i].first.setTo(Scalar::all(0)); lowResMotions[i].second.create(src[i].size(), CV_32FC1); lowResMotions[i].second.setTo(Scalar::all(0)); } } // run run(src, dst, lowResMotions, baseIdx); } void cv::superres::BTV_L1_GPU_Base::process(const vector<GpuMat>& src, GpuMat& dst, const vector<pair<GpuMat, GpuMat> >& forwardMotions, int baseIdx) { CV_DbgAssert( !src.empty() ); #ifdef _DEBUG for (size_t i = 1; i < src.size(); ++i) { CV_DbgAssert( src[i].size() == src[0].size() ); CV_DbgAssert( src[i].type() == src[0].type() ); } #endif CV_DbgAssert( forwardMotions.size() == src.size() - 1 ); #ifdef _DEBUG for (size_t i = 1; i < forwardMotions.size(); ++i) { CV_DbgAssert( forwardMotions[i].first.size() == src[0].size() ); CV_DbgAssert( forwardMotions[i].second.size() == src[0].size() ); } #endif CV_DbgAssert( baseIdx >= 0 && baseIdx < src.size() ); // convert sources to float calcRelativeMotions(forwardMotions, lowResMotions, baseIdx, src[0].size()); // run run(src, dst, lowResMotions, baseIdx); } void cv::superres::BTV_L1_GPU_Base::run(const vector<GpuMat>& src, GpuMat& dst, const vector<pair<GpuMat, GpuMat> >& relativeMotions, int baseIdx) { CV_DbgAssert( scale > 1 ); CV_DbgAssert( iterations > 0 ); CV_DbgAssert( tau > 0.0 ); CV_DbgAssert( alpha > 0.0 ); CV_DbgAssert( btvKernelSize > 0 ); CV_DbgAssert( blurKernelSize > 0 ); CV_DbgAssert( blurSigma >= 0.0 ); // convert sources to float const vector<GpuMat>* yPtr; if (src[0].depth() == CV_32F) yPtr = &src; else { src_f.resize(src.size()); for (size_t i = 0; i < src.size(); ++i) src[i].convertTo(src_f[i], CV_32F); yPtr = &src_f; } const vector<GpuMat>& y = *yPtr; // calc motions between input frames upscaleMotions(relativeMotions, highResMotions, scale); forward.resize(highResMotions.size()); backward.resize(highResMotions.size()); for (size_t i = 0; i < highResMotions.size(); ++i) buildMotionMaps(highResMotions[i], forward[i], backward[i]); // update blur filter and btv weights if (filters.size() != src.size() || blurKernelSize != curBlurKernelSize || blurSigma != curBlurSigma || y[0].type() != curSrcType) { filters.resize(src.size()); for (size_t i = 0; i < src.size(); ++i) filters[i] = createGaussianFilter_GPU(y[0].type(), Size(blurKernelSize, blurKernelSize), blurSigma); curBlurKernelSize = blurKernelSize; curBlurSigma = blurSigma; curSrcType = y[0].type(); } if (btvWeights.empty() || btvKernelSize != curBtvKernelSize || alpha != curAlpha) { calcBtvWeights(btvKernelSize, alpha, btvWeights); curBtvKernelSize = btvKernelSize; curAlpha = alpha; } // initial estimation const Size lowResSize = y[0].size(); const Size highResSize(lowResSize.width * scale, lowResSize.height * scale); gpu::resize(y[baseIdx], highRes, highResSize, 0, 0, INTER_CUBIC); // iterations streams.resize(src.size()); diffTerms.resize(src.size()); a.resize(src.size()); b.resize(src.size()); c.resize(src.size()); for (int i = 0; i < iterations; ++i) { for (size_t k = 0; k < y.size(); ++k) { // a = M * Ih gpu::remap(highRes, a[k], backward[k].first, backward[k].second, INTER_NEAREST, BORDER_REPLICATE, Scalar(), streams[k]); // b = HM * Ih filters[k]->apply(a[k], b[k], Rect(0,0,-1,-1), streams[k]); // c = DHF * Ih gpu::resize(b[k], c[k], lowResSize, 0, 0, INTER_NEAREST, streams[k]); diffSign(y[k], c[k], c[k], streams[k]); // a = Dt * diff upscale(c[k], a[k], scale, streams[k]); // b = HtDt * diff filters[k]->apply(a[k], b[k], Rect(0,0,-1,-1), streams[k]); // diffTerm = MtHtDt * diff gpu::remap(b[k], diffTerms[k], forward[k].first, forward[k].second, INTER_NEAREST, BORDER_REPLICATE, Scalar(), streams[k]); } if (lambda > 0) calcBtvRegularization(highRes, regTerm, btvKernelSize); for (size_t k = 0; k < y.size(); ++k) streams[k].waitForCompletion(); for (size_t k = 0; k < y.size(); ++k) gpu::addWeighted(highRes, 1.0, diffTerms[k], tau, 0.0, highRes); if (lambda > 0) gpu::addWeighted(highRes, 1.0, regTerm, -tau * lambda, 0.0, highRes); } Rect inner(btvKernelSize, btvKernelSize, highRes.cols - 2 * btvKernelSize, highRes.rows - 2 * btvKernelSize); highRes(inner).convertTo(dst, src[0].depth()); } //////////////////////////////////////////////////////////// cv::superres::BTV_L1_GPU::BTV_L1_GPU() { temporalAreaRadius = 4; } void cv::superres::BTV_L1_GPU::initImpl(Ptr<IFrameSource>& frameSource) { const int cacheSize = 2 * temporalAreaRadius + 1; frames.resize(cacheSize); results.resize(cacheSize); motions.resize(cacheSize); storePos = -1; for (int t = -temporalAreaRadius; t <= temporalAreaRadius; ++t) { Mat frame = frameSource->nextFrame(); CV_Assert( !frame.empty() ); addNewFrame(frame); } for (int i = 0; i <= temporalAreaRadius; ++i) processFrame(i); procPos = temporalAreaRadius; outPos = -1; } Mat cv::superres::BTV_L1_GPU::processImpl(Ptr<IFrameSource>& frameSource) { Mat frame = frameSource->nextFrame(); addNewFrame(frame); if (procPos < storePos) { ++procPos; processFrame(procPos); } if (outPos < storePos) { ++outPos; at(outPos, results).convertTo(dst, CV_8U); dst.download(h_dst); return h_dst; } return Mat(); } void cv::superres::BTV_L1_GPU::addNewFrame(const Mat& frame) { if (frame.empty()) return; CV_DbgAssert( storePos < 0 || frame.size() == at(storePos, frames).size() ); d_frame.upload(frame); ++storePos; d_frame.convertTo(at(storePos, frames), CV_32F); if (storePos > 0) opticalFlow->calc(prevFrame, d_frame, at(storePos - 1, motions).first, at(storePos - 1, motions).second); d_frame.copyTo(prevFrame); } void cv::superres::BTV_L1_GPU::processFrame(int idx) { const int startIdx = max(idx - temporalAreaRadius, 0); const int procIdx = idx; const int endIdx = min(startIdx + 2 * temporalAreaRadius, storePos); src.resize(endIdx - startIdx + 1); relMotions.resize(endIdx - startIdx); int baseIdx = -1; for (int i = startIdx, k = 0; i <= endIdx; ++i, ++k) { if (i == procIdx) baseIdx = k; src[k] = at(i, frames); if (i < endIdx) relMotions[k] = at(i, motions); } process(src, at(idx, results), relMotions, baseIdx); }
34.040984
149
0.613894
raulnguyen
59155c01940c6f8573a8c37037c1355552bf2138
1,696
cpp
C++
include/util/FrameBuffer.cpp
hvidal/GameEngine3D
1794ad891d2200260be935283645a03af3ebcfcc
[ "MIT" ]
6
2020-07-03T21:14:56.000Z
2021-11-11T09:37:40.000Z
include/util/FrameBuffer.cpp
hvidal/GameEngine3D
1794ad891d2200260be935283645a03af3ebcfcc
[ "MIT" ]
null
null
null
include/util/FrameBuffer.cpp
hvidal/GameEngine3D
1794ad891d2200260be935283645a03af3ebcfcc
[ "MIT" ]
2
2020-08-15T22:37:21.000Z
2021-01-17T11:31:27.000Z
#include "FrameBuffer.h" FrameBuffer::FrameBuffer() { glGenFramebuffers(1, &mFboId); glBindFramebuffer(GL_FRAMEBUFFER, mFboId); } FrameBuffer::~FrameBuffer() { Log::debug("Deleting FrameBuffer"); glDeleteFramebuffers(1, &mFboId); } void FrameBuffer::check() const { GLenum status = glCheckFramebufferStatus(GL_FRAMEBUFFER); if (status != GL_FRAMEBUFFER_COMPLETE) { Log::error("Framebuffer failed - exiting"); exit(-1); } } void FrameBuffer::startColor(const ITexture* texture) const { glViewport(0, 0, texture->getWidth(), texture->getHeight()); glBindFramebuffer(GL_FRAMEBUFFER, mFboId); glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture->getID(), 0); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); check(); } void FrameBuffer::startDepth(const ITexture* texture) const { glViewport(0, 0, texture->getWidth(), texture->getHeight()); glBindFramebuffer(GL_FRAMEBUFFER, mFboId); glDrawBuffer(GL_NONE); glReadBuffer(GL_NONE); glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, texture->getID(), 0); glClear(GL_DEPTH_BUFFER_BIT); check(); } void FrameBuffer::startColorAndDepth(const ITexture* colorTexture, const ITexture* depthTexture) const { glViewport(0, 0, colorTexture->getWidth(), colorTexture->getHeight()); glBindFramebuffer(GL_FRAMEBUFFER, mFboId); glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, colorTexture->getID(), 0); glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, depthTexture->getID(), 0); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); check(); } void FrameBuffer::end() { glBindFramebuffer(GL_FRAMEBUFFER, 0); }
29.754386
104
0.774764
hvidal
5915b7a8aadfec38c1388177d726d6a33d612349
3,152
cc
C++
lite/kernels/npu/bridges/pool_op.cc
StarryRain/Paddle-Lite
f9930fc191f5289ad963fbd8b21ae0d711418fcd
[ "Apache-2.0" ]
null
null
null
lite/kernels/npu/bridges/pool_op.cc
StarryRain/Paddle-Lite
f9930fc191f5289ad963fbd8b21ae0d711418fcd
[ "Apache-2.0" ]
null
null
null
lite/kernels/npu/bridges/pool_op.cc
StarryRain/Paddle-Lite
f9930fc191f5289ad963fbd8b21ae0d711418fcd
[ "Apache-2.0" ]
1
2020-02-13T10:45:37.000Z
2020-02-13T10:45:37.000Z
// Copyright (c) 2019 PaddlePaddle Authors. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. #include "lite/backends/npu/builder.h" #include "lite/kernels/npu/bridges/registry.h" namespace paddle { namespace lite { namespace kernels { namespace npu { namespace bridges { node_map_type PoolConverter(const std::shared_ptr<lite::OpLite> pool_op, const node_map_type& inputs_map) { auto scope = pool_op->scope(); auto op_info = pool_op->op_info(); auto op_type = op_info->Type(); auto unique_op_type = lite::npu::UniqueName(op_type); LOG(INFO) << "[NPU] Converting " + op_type + "..."; std::shared_ptr<ge::op::Pooling> pool_node = std::make_shared<ge::op::Pooling>(unique_op_type); auto x_var_name = op_info->Input("X").front(); auto pooling_type = op_info->GetAttr<std::string>("pooling_type"); int npu_mode = 0; if (pooling_type == "max") { npu_mode = 0; } else if (pooling_type == "avg") { npu_mode = 1; CHECK(op_info->GetAttr<bool>("exclusive")) << "[NPU] exclusive must be true in HiAI DDK"; } else { LOG(FATAL) << "[NPU] Unsupported pooling type: " << pooling_type; } bool npu_global_pooling = op_info->GetAttr<bool>("global_pooling"); auto ksize = op_info->GetAttr<std::vector<int>>("ksize"); auto npu_window = ge::AttrValue::LIST_INT(ksize.begin(), ksize.end()); auto padding = op_info->GetAttr<std::vector<int>>("paddings"); auto npu_pad = ge::AttrValue::LIST_INT{padding[0], padding[0], padding[1], padding[1]}; auto strides = op_info->GetAttr<std::vector<int>>("strides"); auto npu_stride = ge::AttrValue::LIST_INT(strides.begin(), strides.end()); int npu_ceil_mode = 0; if (op_info->HasAttr("ceil_mode")) { npu_ceil_mode = op_info->GetAttr<bool>("ceil_mode") ? 1 : 0; } pool_node->set_input_x(*inputs_map.at(x_var_name)); pool_node->set_attr_mode(npu_mode); pool_node->set_attr_pad_mode(0); pool_node->set_attr_global_pooling(npu_global_pooling); pool_node->set_attr_window(npu_window); pool_node->set_attr_pad(npu_pad); pool_node->set_attr_stride(npu_stride); pool_node->set_attr_ceil_mode(npu_ceil_mode); // output_node->set_attr_data_mode(npu_data_mode); lite::npu::OpList::Global().add(inputs_map.at(x_var_name)); lite::npu::OpList::Global().add(pool_node); node_map_type outputs_map; outputs_map[op_info->Output("Out").front()] = pool_node; return outputs_map; } } // namespace bridges } // namespace npu } // namespace kernels } // namespace lite } // namespace paddle REGISTER_NPU_BRIDGE(pool2d, paddle::lite::kernels::npu::bridges::PoolConverter);
37.082353
80
0.704949
StarryRain
5916c712411bb69bb0e0d916c014633aa54360f2
897
cpp
C++
win64/Win64_Renderer.cpp
Fjellstedt/dk30
b9fea347620fafe2d9994b4be6e20be0b2cee6f2
[ "MIT" ]
null
null
null
win64/Win64_Renderer.cpp
Fjellstedt/dk30
b9fea347620fafe2d9994b4be6e20be0b2cee6f2
[ "MIT" ]
null
null
null
win64/Win64_Renderer.cpp
Fjellstedt/dk30
b9fea347620fafe2d9994b4be6e20be0b2cee6f2
[ "MIT" ]
null
null
null
/* ======================================================================== $Creator: Patrik Fjellstedt $ ======================================================================== */ #include "w_pch.h" #include "Win64_Renderer.h" namespace Cryptic { Win64_Renderer::Win64_Renderer() { } Win64_Renderer::~Win64_Renderer() { } B32 Win64_Renderer::Initialize(HWND hwnd, PlatformLayer *platLayer) { B32 result = m_dx11.Initialize(hwnd, platLayer); return result; } void Win64_Renderer::Shutdown() { m_dx11.Shutdown(); } void Win64_Renderer::Render(RenderState *state) { // TODO(pf): Render API swapping. if (m_settings.fullscreen != state->settings.fullscreen) m_dx11.ChangeFullscreenTo(state->settings.fullscreen); m_settings = state->settings; m_dx11.Render(state); } }
24.243243
78
0.526198
Fjellstedt
59179e81690629886ccc95409299b3778d7c4b6a
8,303
cpp
C++
src/Scheduling/APA/E_APAScheduler.cpp
ha1082104/KENS_2
7b0b9f805ad89df8e23cdc1fc7599119d600366d
[ "MIT" ]
null
null
null
src/Scheduling/APA/E_APAScheduler.cpp
ha1082104/KENS_2
7b0b9f805ad89df8e23cdc1fc7599119d600366d
[ "MIT" ]
null
null
null
src/Scheduling/APA/E_APAScheduler.cpp
ha1082104/KENS_2
7b0b9f805ad89df8e23cdc1fc7599119d600366d
[ "MIT" ]
1
2018-11-18T16:16:54.000Z
2018-11-18T16:16:54.000Z
/* * E_APAScheduler.cpp * * Created on: 2014. 11. 27. * Author: 근홍 */ #include <E/E_System.hpp> #include <E/Scheduling/E_Computer.hpp> #include <E/Scheduling/E_Task.hpp> #include <E/Scheduling/E_Job.hpp> #include <E/Scheduling/E_Processor.hpp> #include <E/Scheduling/E_Scheduler.hpp> #include <E/Scheduling/APA/E_Affinity.hpp> #include <E/Scheduling/APA/E_APAScheduler.hpp> namespace E { APAWeakScheduler::APAWeakScheduler(Size maxTask) : Scheduler(), Log() { this->maxTask = maxTask; } APAWeakScheduler::~APAWeakScheduler() { this->jobQueue.clear(); } void APAWeakScheduler::jobFinished(Job* job, Processor* processor) { this->jobQueue.erase(job); while(schedule(computer)); } void APAWeakScheduler::jobRaised(Job* job) { assert(computer); assert(job); assert(jobQueue.find(job) == jobQueue.end()); jobQueue.insert(job); while(schedule(computer)); } bool APAWeakScheduler::schedule(Computer* computer) { bool ret = false; std::list<Job*> failedJob; failedJob.clear(); while(!jobQueue.empty()) { auto iter = jobQueue.begin(); Job* current = *iter; jobQueue.erase(iter); AffinityTask::JobCompare jobCompare; AffinityTask* task = dynamic_cast<AffinityTask*>(current->getTask()); assert(task != nullptr); bool found = false; Processor* selectedProc = nullptr; Job* selectedJob = nullptr; for(auto cpu : task->getAffinity()) { assert(cpu < computer->getNumCPU()); Processor* curProc = computer->getCPU(cpu); Job* existing = curProc->getCurrentJob(); if(existing == nullptr) { selectedProc = curProc; selectedJob = existing; found = true; break; } else { if(jobCompare(current, existing)) { if(selectedJob == nullptr) { selectedProc = curProc; selectedJob = existing; found = true; } else if(jobCompare(selectedJob, existing)) { selectedProc = curProc; selectedJob = existing; found = true; } } } } if(found) { if(selectedJob != nullptr) { selectedProc->deleteJob(); if(!selectedJob->isDone()) { assert(jobQueue.find(selectedJob) == jobQueue.end()); this->jobQueue.insert(selectedJob); } } selectedProc->assignJob(current); ret = true; break; } else { failedJob.push_back(current); } } if(failedJob.size() > 0) for(Job* item : failedJob) { assert(dynamic_cast<AffinityTask*>(item->getTask()) != nullptr); assert(jobQueue.find(item) == jobQueue.end()); jobQueue.insert(item); } return ret; } APAStrongScheduler::APAStrongScheduler(Size maxTask) : Scheduler(), Log() { this->maxTask = maxTask; } APAStrongScheduler::~APAStrongScheduler() { jobQueue.clear(); } void APAStrongScheduler::jobFinished(Job* job, Processor* processor) { if(jobQueue.find(job) != jobQueue.end()) jobQueue.erase(job); while(schedule(computer)); } void APAStrongScheduler::jobRaised(Job* job) { assert(computer); assert(job); assert(jobQueue.find(job) == jobQueue.end()); jobQueue.insert(job); while(schedule(computer)); } std::list<void*> APAStrongScheduler::BFS(Computer* computer, Job* job, CPUID targetCPU) { //procedure BFS(G,v) is std::list<void*> returnList; std::unordered_map<void*, void*> prevMap; bool reachable = false; std::queue<std::pair<bool, void*>> queue;//create a queue Q, true is Job, false is processor std::unordered_set<void*> visited; //create a set V visited.insert(job); //add v to V queue.push(std::pair<bool, void*>(true, job)); //enqueue v onto Q while(!queue.empty())//while Q is not empty loop { auto currentPair = queue.front(); //t ← Q.dequeue() queue.pop(); if(currentPair.first == false) { Processor* proc = static_cast<Processor*>(currentPair.second); if(proc->getID() == targetCPU) //if t is what we are looking for then { //return t reachable = true; break; } } //for all edges e in G.adjacentEdges(t) loop if(currentPair.first == true) { Job* curJob = static_cast<Job*>(currentPair.second); AffinityTask* curTask = dynamic_cast<AffinityTask*>(curJob->getTask()); assert(curTask != nullptr); for(CPUID adjacentCPU : curTask->getAffinity()) //u ← G.adjacentVertex(t,e) { Processor* nextCPU = computer->getCPU(adjacentCPU); if(visited.find(nextCPU) == visited.end()) //if u is not in V then { visited.insert(nextCPU); //add u to V queue.push(std::pair<bool, void*>(false,nextCPU)); //enqueue u onto Q assert(prevMap.find(nextCPU) == prevMap.end()); prevMap.insert(std::pair<void*,void*>(nextCPU, curJob)); } } } else { Processor* curProc = static_cast<Processor*>(currentPair.second); Job* nextJob = curProc->getCurrentJob(); if(nextJob != nullptr) //u ← G.adjacentVertex(t,e) { if(visited.find(nextJob) == visited.end()) { visited.insert(nextJob); queue.push(std::pair<bool, void*>(true, nextJob)); assert(prevMap.find(nextJob) == prevMap.end()); prevMap.insert(std::pair<void*,void*>(nextJob, curProc)); } } } } if(reachable) { Processor* lastProc = computer->getCPU(targetCPU); void* current = lastProc; while(current != nullptr) { returnList.push_front(current); auto iter = prevMap.find(current); if(iter == prevMap.end()) current = nullptr; else current = iter->second; } } return returnList; } bool APAStrongScheduler::scheduleSingle(Computer* computer, Job* job) { AffinityTask::JobCompare compare; Job* candidateJob = nullptr; Processor* candidateCPU = nullptr; std::list<void*> candidateChain; bool found = false; for(CPUID candidateProcessorID = 0; candidateProcessorID < computer->getNumCPU(); candidateProcessorID++) { std::list<void*> currentChain = BFS(computer, job, candidateProcessorID); if(currentChain.size() == 0) continue; assert(currentChain.size() > 0); assert(currentChain.size() % 2 == 0); assert(currentChain.front() == (void*)job); Processor* lastProcessor = static_cast<Processor*>(currentChain.back()); Job* currentJob = lastProcessor->getCurrentJob(); if(currentJob == nullptr) { candidateCPU = lastProcessor; candidateJob = currentJob; candidateChain = currentChain; found = true; break; } else if(compare(job, currentJob)) //Job to be scheduled can evict the end of the chain { if(!found) { candidateCPU = lastProcessor; candidateJob = currentJob; candidateChain = currentChain; found = true; } else { assert(candidateJob != nullptr); if(compare(candidateJob, currentJob)) // currentJob is cheaper { candidateCPU = lastProcessor; candidateJob = currentJob; candidateChain = currentChain; found = true; } } } } if(found) { assert(candidateChain.size() > 0); assert(candidateChain.size() % 2 == 0); assert(candidateChain.front() == (void*)job); assert(candidateChain.back() == (void*)candidateCPU); if(candidateJob != nullptr) { assert(candidateJob == candidateCPU->getCurrentJob()); candidateCPU->deleteJob(); if(!candidateJob->isDone()) { assert(jobQueue.find(candidateJob) == jobQueue.end()); jobQueue.insert(candidateJob); } } while(candidateChain.size() > 0) { Job* movingJob = static_cast<Job*>(candidateChain.front()); candidateChain.pop_front(); Processor* movingProcessor = static_cast<Processor*>(candidateChain.front()); candidateChain.pop_front(); assert(movingJob != nullptr); assert(movingProcessor != nullptr); if(movingProcessor != candidateCPU) movingProcessor->deleteJob(); if(!movingJob->isDone()) movingProcessor->assignJob(movingJob); } } return found; } bool APAStrongScheduler::schedule(Computer* computer) { bool ret = false; std::list<Job*> failedJob; failedJob.clear(); while(!jobQueue.empty()) { auto iter = jobQueue.begin(); Job* current = *iter; jobQueue.erase(iter); bool found = scheduleSingle(computer, current); if(found) { ret = true; break; } else { failedJob.push_back(current); } } if(failedJob.size() > 0) for(Job* item : failedJob) { assert(dynamic_cast<AffinityTask*>(item->getTask()) != nullptr); assert(jobQueue.find(item) == jobQueue.end()); jobQueue.insert(item); } return ret; } }
23.323034
107
0.666024
ha1082104
59191833d1194317d6dd11f5a9ee325531988504
5,519
cpp
C++
appshell/native_menu_model.cpp
sabanaya/brackets-shell
999145fe996c54d91b3a539b8f05ba25902a39df
[ "MIT" ]
524
2015-01-02T15:26:14.000Z
2022-03-02T10:42:42.000Z
appshell/native_menu_model.cpp
sabanaya/brackets-shell
999145fe996c54d91b3a539b8f05ba25902a39df
[ "MIT" ]
458
2021-08-17T18:30:53.000Z
2021-08-17T18:59:34.000Z
appshell/native_menu_model.cpp
sabanaya/brackets-shell
999145fe996c54d91b3a539b8f05ba25902a39df
[ "MIT" ]
403
2015-01-01T21:32:43.000Z
2021-11-10T10:24:31.000Z
/* * Copyright (c) 2013 - present Adobe Systems Incorporated. All rights reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ #include "native_menu_model.h" #include "command_callbacks.h" #include "config.h" #if defined(OS_WIN) const ExtensionString WINDOW_COMMAND = L"window"; #else const ExtensionString WINDOW_COMMAND = "window"; #endif // map of menuParent --> NativeMenuModel instance typedef std::map<void*, NativeMenuModel*> menuModelMap; menuModelMap instanceMap; NativeMenuModel& NativeMenuModel::getInstance(void* menuParent, bool reset) { menuModelMap::iterator foundItem = instanceMap.find(menuParent); if (foundItem != instanceMap.end()) { return *(foundItem->second); } menu m; NativeMenuModel* instance = new NativeMenuModel(m); instance->setTag(WINDOW_COMMAND, ExtensionString(), WINDOW_MENUITEMTAG); instanceMap[menuParent] = instance; return *(instance); } bool NativeMenuModel::isMenuItemEnabled(int tag) { menu::iterator foundItem = menuItems.find(tag); if(foundItem == menuItems.end()) { //return enabled return true; } return foundItem->second.enabled; } bool NativeMenuModel::isMenuItemChecked(int tag) { menu::iterator foundItem = menuItems.find(tag); if(foundItem == menuItems.end()) { return false; } return foundItem->second.checked; } int NativeMenuModel::setMenuItemState (ExtensionString command, bool enabled, bool checked) { //woo turning O(log n) into O(n) however, the important look up is the tag -> menu so making sure that is faster as it will impact user performance. menu::iterator it; for ( it=menuItems.begin() ; it != menuItems.end(); it++ ) { if(it->second.commandId.compare(command) == 0) { it->second.enabled = enabled; it->second.checked = checked; return NO_ERROR; } } return ERR_NOT_FOUND; } ExtensionString NativeMenuModel::getCommandId(int tag) { menu::iterator foundItem = menuItems.find(tag); if(foundItem == menuItems.end()) { return ExtensionString(); } return menuItems[tag].commandId; } ExtensionString NativeMenuModel::getParentId(int tag) { menu::iterator foundItem = menuItems.find(tag); if(foundItem == menuItems.end()) { return ExtensionString(); } return menuItems[tag].parentId; } ExtensionString NativeMenuModel::getKey(int tag) { menu::iterator foundItem = menuItems.find(tag); if(foundItem == menuItems.end()) { return ExtensionString(); } return menuItems[tag].key; } void NativeMenuModel::setKey (int tag, ExtensionString theKey) { menu::iterator foundItem = menuItems.find(tag); if(foundItem == menuItems.end()) { return; } menuItems[tag].key = theKey; } int NativeMenuModel::getOrCreateTag(ExtensionString command, ExtensionString parent) { menuTag::iterator foundItem = commandMap.find(command); if(foundItem == commandMap.end()) { commandMap[command] = ++tagCount; menuItems[tagCount] = NativeMenuItemModel(command, parent, true, false); return tagCount; } return foundItem->second; } int NativeMenuModel::setTag(ExtensionString command, ExtensionString parent, int tag) { menuTag::iterator foundItem = commandMap.find(command); if(foundItem == commandMap.end()) { commandMap[command] = tag; menuItems[tag] = NativeMenuItemModel(command, parent, true, false); return tagCount; } return foundItem->second; } int NativeMenuModel::getTag(ExtensionString command) { menuTag::iterator foundItem = commandMap.find(command); if(foundItem == commandMap.end()) { return kTagNotFound; } return foundItem->second; } void NativeMenuModel::setOsItem (int tag, void* theItem) { menu::iterator foundItem = menuItems.find(tag); if(foundItem == menuItems.end()) { return; } menuItems[tag].osItem = theItem; } void* NativeMenuModel::getOsItem (int tag) { menu::iterator foundItem = menuItems.find(tag); if(foundItem == menuItems.end()) { return NULL; } return menuItems[tag].osItem; } int NativeMenuModel::removeMenuItem(const ExtensionString& command) { menuTag::iterator foundItem = commandMap.find(command); if(foundItem == commandMap.end()) { return ERR_NOT_FOUND; } menuItems.erase(foundItem->second); commandMap.erase(foundItem); return NO_ERROR; }
31.901734
152
0.698858
sabanaya
591dc60cf428163d4d94efbeeafc8ea4e8aaf7af
9,486
cpp
C++
ext/extfs.cpp
zhoujie-jay/sortix
7348cb0b9ad5931bf73c8b3fa2dd63c99cae6afa
[ "0BSD" ]
5
2018-06-13T14:56:57.000Z
2021-08-25T01:07:32.000Z
ext/extfs.cpp
zhoujie-jay/sortix
7348cb0b9ad5931bf73c8b3fa2dd63c99cae6afa
[ "0BSD" ]
null
null
null
ext/extfs.cpp
zhoujie-jay/sortix
7348cb0b9ad5931bf73c8b3fa2dd63c99cae6afa
[ "0BSD" ]
null
null
null
/* * Copyright (c) 2013, 2014, 2015 Jonas 'Sortie' Termansen. * * Permission to use, copy, modify, and 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. * * extfs.cpp * Implementation of the extended filesystem. */ #include <sys/stat.h> #include <sys/types.h> #include <assert.h> #include <dirent.h> #include <errno.h> #include <error.h> #include <fcntl.h> #include <stddef.h> #include <stdint.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> #if defined(__sortix__) #include "fsmarshall.h" #else #include "fuse.h" #endif #include "ext-constants.h" #include "ext-structs.h" #include "blockgroup.h" #include "block.h" #include "device.h" #include "extfs.h" #include "filesystem.h" #include "inode.h" #include "ioleast.h" static const uint32_t EXT2_FEATURE_COMPAT_SUPPORTED = 0; static const uint32_t EXT2_FEATURE_INCOMPAT_SUPPORTED = \ EXT2_FEATURE_INCOMPAT_FILETYPE; static const uint32_t EXT2_FEATURE_RO_COMPAT_SUPPORTED = \ EXT2_FEATURE_RO_COMPAT_LARGE_FILE; uid_t request_uid; uid_t request_gid; mode_t HostModeFromExtMode(uint32_t extmode) { mode_t hostmode = extmode & 0777; if ( extmode & EXT2_S_ISVTX ) hostmode |= S_ISVTX; if ( extmode & EXT2_S_ISGID ) hostmode |= S_ISGID; if ( extmode & EXT2_S_ISUID ) hostmode |= S_ISUID; if ( EXT2_S_ISSOCK(extmode) ) hostmode |= S_IFSOCK; if ( EXT2_S_ISLNK(extmode) ) hostmode |= S_IFLNK; if ( EXT2_S_ISREG(extmode) ) hostmode |= S_IFREG; if ( EXT2_S_ISBLK(extmode) ) hostmode |= S_IFBLK; if ( EXT2_S_ISDIR(extmode) ) hostmode |= S_IFDIR; if ( EXT2_S_ISCHR(extmode) ) hostmode |= S_IFCHR; if ( EXT2_S_ISFIFO(extmode) ) hostmode |= S_IFIFO; return hostmode; } uint32_t ExtModeFromHostMode(mode_t hostmode) { uint32_t extmode = hostmode & 0777; if ( hostmode & S_ISVTX ) extmode |= EXT2_S_ISVTX; if ( hostmode & S_ISGID ) extmode |= EXT2_S_ISGID; if ( hostmode & S_ISUID ) extmode |= EXT2_S_ISUID; if ( S_ISSOCK(hostmode) ) extmode |= EXT2_S_IFSOCK; if ( S_ISLNK(hostmode) ) extmode |= EXT2_S_IFLNK; if ( S_ISREG(hostmode) ) extmode |= EXT2_S_IFREG; if ( S_ISBLK(hostmode) ) extmode |= EXT2_S_IFBLK; if ( S_ISDIR(hostmode) ) extmode |= EXT2_S_IFDIR; if ( S_ISCHR(hostmode) ) extmode |= EXT2_S_IFCHR; if ( S_ISFIFO(hostmode) ) extmode |= EXT2_S_IFIFO; return extmode; } uint8_t HostDTFromExtDT(uint8_t extdt) { switch ( extdt ) { case EXT2_FT_UNKNOWN: return DT_UNKNOWN; case EXT2_FT_REG_FILE: return DT_REG; case EXT2_FT_DIR: return DT_DIR; case EXT2_FT_CHRDEV: return DT_CHR; case EXT2_FT_BLKDEV: return DT_BLK; case EXT2_FT_FIFO: return DT_FIFO; case EXT2_FT_SOCK: return DT_SOCK; case EXT2_FT_SYMLINK: return DT_LNK; } return DT_UNKNOWN; } void StatInode(Inode* inode, struct stat* st) { memset(st, 0, sizeof(*st)); st->st_ino = inode->inode_id; st->st_mode = HostModeFromExtMode(inode->Mode()); st->st_nlink = inode->data->i_links_count; st->st_uid = inode->UserId(); st->st_gid = inode->GroupId(); st->st_size = inode->Size(); st->st_atim.tv_sec = inode->data->i_atime; st->st_atim.tv_nsec = 0; st->st_ctim.tv_sec = inode->data->i_ctime; st->st_ctim.tv_nsec = 0; st->st_mtim.tv_sec = inode->data->i_mtime; st->st_mtim.tv_nsec = 0; st->st_blksize = inode->filesystem->block_size; st->st_blocks = inode->data->i_blocks; } static void compact_arguments(int* argc, char*** argv) { for ( int i = 0; i < *argc; i++ ) { while ( i < *argc && !(*argv)[i] ) { for ( int n = i; n < *argc; n++ ) (*argv)[n] = (*argv)[n+1]; (*argc)--; } } } static void help(FILE* fp, const char* argv0) { fprintf(fp, "Usage: %s [OPTION]... DEVICE [MOUNT-POINT]\n", argv0); } static void version(FILE* fp, const char* argv0) { fprintf(fp, "%s (Sortix) %s\n", argv0, VERSIONSTR); } int main(int argc, char* argv[]) { const char* argv0 = argv[0]; const char* pretend_mount_path = NULL; bool foreground = false; bool read = false; bool write = false; for ( int i = 1; i < argc; i++ ) { const char* arg = argv[i]; if ( arg[0] != '-' || !arg[1] ) continue; argv[i] = NULL; if ( !strcmp(arg, "--") ) break; if ( arg[1] != '-' ) { while ( char c = *++arg ) switch ( c ) { case 'r': read = true; break; case 'w': write = true; break; default: fprintf(stderr, "%s: unknown option -- '%c'\n", argv0, c); help(stderr, argv0); exit(1); } } else if ( !strcmp(arg, "--help") ) help(stdout, argv0), exit(0); else if ( !strcmp(arg, "--version") ) version(stdout, argv0), exit(0); else if ( !strcmp(arg, "--background") ) foreground = false; else if ( !strcmp(arg, "--foreground") ) foreground = true; else if ( !strcmp(arg, "--read") ) read = true; else if ( !strcmp(arg, "--write") ) write = true; else if ( !strncmp(arg, "--pretend-mount-path=", strlen("--pretend-mount-path=")) ) pretend_mount_path = arg + strlen("--pretend-mount-path="); else if ( !strcmp(arg, "--pretend-mount-path") ) { if ( i+1 == argc ) { fprintf(stderr, "%s: --pretend-mount-path: Missing operand\n", argv0); exit(1); } pretend_mount_path = argv[++i]; argv[i] = NULL; } else { fprintf(stderr, "%s: unknown option: %s\n", argv0, arg); help(stderr, argv0); exit(1); } } // It doesn't make sense to have a write-only filesystem. read = read || write; // Default to read and write filesystem access. bool default_access = !read && !write ? read = write = true : false; if ( argc == 1 ) { help(stdout, argv0); exit(0); } compact_arguments(&argc, &argv); const char* device_path = 2 <= argc ? argv[1] : NULL; const char* mount_path = 3 <= argc ? argv[2] : NULL; if ( !device_path ) { help(stderr, argv0); exit(1); } if ( !pretend_mount_path ) pretend_mount_path = mount_path; int fd = open(device_path, write ? O_RDWR : O_RDONLY); if ( fd < 0 ) error(1, errno, "`%s'", device_path); // Read the super block from the filesystem so we can verify it. struct ext_superblock sb; if ( preadall(fd, &sb, sizeof(sb), 1024) != sizeof(sb) ) { if ( errno == EEOF ) error(1, 0, "`%s' isn't a valid extended filesystem", device_path); else error(1, errno, "read: `%s'", device_path); } // Verify the magic value to detect a compatible filesystem. if ( sb.s_magic != EXT2_SUPER_MAGIC ) error(1, 0, "`%s' isn't a valid extended filesystem", device_path); // Test whether this revision of the extended filesystem is supported. if ( sb.s_rev_level == EXT2_GOOD_OLD_REV ) error(1, 0, "`%s' is formatted with an obsolete filesystem revision", device_path); // Verify that no incompatible features are in use. if ( sb.s_feature_compat & ~EXT2_FEATURE_INCOMPAT_SUPPORTED ) error(1, 0, "`%s' uses unsupported and incompatible features", device_path); // Verify that no incompatible features are in use if opening for write. if ( !default_access && write && sb.s_feature_ro_compat & ~EXT2_FEATURE_RO_COMPAT_SUPPORTED ) error(1, 0, "`%s' uses unsupported and incompatible features, " "read-only access is possible, but write-access was " "requested", device_path); if ( write && sb.s_feature_ro_compat & ~EXT2_FEATURE_RO_COMPAT_SUPPORTED ) { fprintf(stderr, "Warning: `%s' uses unsupported and incompatible " "features, falling back to read-only access\n", device_path); // TODO: Modify the file descriptor such that writing fails! read = true; } // Check whether any features are in use that we can safely disregard. if ( sb.s_feature_compat & ~EXT2_FEATURE_COMPAT_SUPPORTED ) fprintf(stderr, "Note: filesystem uses unsupported but compatible " "features\n"); // Check the block size is sane. 64 KiB may have issues, 32 KiB then. if ( sb.s_log_block_size > (15-10) /* 32 KiB blocks */ ) error(1, 0, "`%s': excess block size", device_path); // Check whether the filesystem was unmounted cleanly. if ( sb.s_state != EXT2_VALID_FS ) fprintf(stderr, "Warning: `%s' wasn't unmounted cleanly\n", device_path); uint32_t block_size = 1024U << sb.s_log_block_size; Device* dev = new Device(fd, device_path, block_size, write); if ( !dev ) // TODO: Use operator new nothrow! error(1, errno, "malloc"); Filesystem* fs = new Filesystem(dev, pretend_mount_path); if ( !fs ) // TODO: Use operator new nothrow! error(1, errno, "malloc"); fs->block_groups = new BlockGroup*[fs->num_groups]; if ( !fs->block_groups ) // TODO: Use operator new nothrow! error(1, errno, "malloc"); for ( size_t i = 0; i < fs->num_groups; i++ ) fs->block_groups[i] = NULL; if ( !mount_path ) return 0; #if defined(__sortix__) return fsmarshall_main(argv0, mount_path, foreground, fs, dev); #else return ext2_fuse_main(argv0, mount_path, foreground, fs, dev); #endif }
29.830189
85
0.668248
zhoujie-jay
591ea797eef73eb7ae54e36fa57cbe5c148d5e02
244
hpp
C++
src/ComputeSYMGS_ref.hpp
zabookey/Kokkos-HPCG
7ca081e51a275c4fb6b21e8871788e88e8715dbc
[ "BSD-3-Clause" ]
5
2015-07-10T16:35:08.000Z
2021-09-13T03:29:37.000Z
src/ComputeSYMGS_ref.hpp
zabookey/Kokkos-HPCG
7ca081e51a275c4fb6b21e8871788e88e8715dbc
[ "BSD-3-Clause" ]
null
null
null
src/ComputeSYMGS_ref.hpp
zabookey/Kokkos-HPCG
7ca081e51a275c4fb6b21e8871788e88e8715dbc
[ "BSD-3-Clause" ]
null
null
null
#ifndef COMPUTESYMGS_REF_HPP #define COMPUTESYMGS_REF_HPP #include "SparseMatrix.hpp" #include "Vector.hpp" #include "KokkosSetup.hpp" int ComputeSYMGS_ref(const SparseMatrix & A, const Vector & r, Vector & x); #endif // COMPUTESYMGS_REF_HPP
24.4
75
0.786885
zabookey
59213eb5e0cd3378c0ad476e1a79e2b4db24caea
36,053
cpp
C++
src/ChessDotCpp/search.cpp
GediminasMasaitis/chess-dot-cpp
60995f235387efc5acc03d46c8245960efef3e81
[ "MIT" ]
null
null
null
src/ChessDotCpp/search.cpp
GediminasMasaitis/chess-dot-cpp
60995f235387efc5acc03d46c8245960efef3e81
[ "MIT" ]
null
null
null
src/ChessDotCpp/search.cpp
GediminasMasaitis/chess-dot-cpp
60995f235387efc5acc03d46c8245960efef3e81
[ "MIT" ]
1
2021-05-01T11:57:03.000Z
2021-05-01T11:57:03.000Z
#include "search.h" #include "attacks.h" #include "movegen.h" #include "evaluation.h" #include "moveorder.h" #include "see.h" #include "stopper.h" #include "options.h" #include "tablebases.h" #include <thread> #include <algorithm> #include "zobrist.h" bool Search::TryProbeTranspositionTable(const ZobristKey key, const Ply depth, const Score alpha, const Score beta, TranspositionTableEntry& entry, Score& score, bool& entryExists) { score = 0; entryExists = false; ZobristKey entryKey; const bool found = State.Global.Table.TryProbe(key, &entry, &entryKey); if (!found) { State.Stats.HashMiss++; return false; } if (entryKey != key) { State.Stats.HashCollision++; return false; } entryExists = true; if (entry.Depth < depth) { State.Stats.HashInsufficientDepth++; return false; } switch (entry.Flag) { case TranspositionTableFlags::Exact: score = entry.SScore; return true; case TranspositionTableFlags::Alpha: if (entry.SScore <= alpha) { score = alpha; return true; } return false; case TranspositionTableFlags::Beta: if (entry.SScore >= beta) { score = beta; return true; } return false; default: assert(false); break; } return false; } void Search::StoreTranspositionTable(const ThreadState& threadState, const ZobristKey key, const Move move, const Ply depth, const Score score, const TtFlag flag) { if (threadState.StopIteration || Stopper.Stopped) { return; } State.Global.Table.Store(key, move, depth, score, flag); } Score Search::Contempt(const Board& board) const { //constexpr Score midgame = -(Constants::Mate + 200); //constexpr Score midgame = -15; // //if (board.PieceMaterial[State.Global.ColorToMove] < Constants::EndgameMaterial) //{ // return 0; //} // //Score score; //if (board.ColorToMove == State.Global.ColorToMove) //{ // score = midgame; //} //else //{ // score = -midgame; //} //return score; (void)board; return 0; } bool Search::IsRepetitionOr50Move(const Board& board) const { if (board.HistoryDepth - board.FiftyMoveRuleIndex > 100) { return true; } for (HistoryPly ply = board.FiftyMoveRuleIndex; ply < board.HistoryDepth; ply++) { const auto& previousEntry = board.History[ply]; const ZobristKey previousKey = previousEntry.Key; if (board.Key == previousKey) { return true; } } return false; } Score Search::Quiescence(const ThreadId threadId, Board& board, Ply depth, Ply ply, Score alpha, Score beta) { ThreadState& threadState = State.Thread[threadId]; const bool rootNode = ply == 0; ++State.Stats.Nodes; EachColor<Bitboard> pins; PinDetector::GetPinnedToKings(board, pins); const Score standPat = Evaluation::Evaluate(board, pins, State.Global.Eval); if (standPat >= beta) { return beta; } if (alpha < standPat) { alpha = standPat; } const Bitboard checkers = AttacksGenerator::GetCheckers(board); const bool inCheck = checkers != BitboardConstants::Empty; const Bitboard pinned = pins[board.ColorToMove]; MoveArray moves; MoveCount moveCount = 0; MoveGenerator::GetAllPotentialCaptures(board, checkers, pinned, moves, moveCount); const Move previousMove = rootNode ? Move(0) : board.History[board.HistoryDepth - 1].Move; const Move countermove = threadState.Countermoves[previousMove.GetPiece()][previousMove.GetTo()]; ScoreArray seeScores; See::CalculateSeeScores(board, moves, moveCount, seeScores); MoveScoreArray staticMoveScores{}; MoveOrdering::CalculateStaticScores(threadId, State, moves, seeScores, moveCount, ply, Move(0), countermove, staticMoveScores, board); Score bestScore = -Constants::Inf; Move bestMove; bool raisedAlpha = false; bool betaCutoff = false; uint8_t movesEvaluated = 0; for (MoveCount moveIndex = 0; moveIndex < moveCount; moveIndex++) { MoveOrdering::OrderNextMove(moveIndex, moves, seeScores, staticMoveScores, moveCount); const Move move = moves[moveIndex]; const bool valid = MoveValidator::IsKingSafeAfterMove2(board, move, checkers, pinned); if (!valid) { continue; } const Score takesMaterial = EvaluationConstants::PieceValues[move.GetTakesPiece()]; const Score opponentMaterial = board.PieceMaterial[board.ColorToMove ^ 1]; const Score resultMaterial = opponentMaterial - takesMaterial; // DELTA PRUNING if ( !inCheck && standPat + takesMaterial + 200 < alpha && resultMaterial > Constants::EndgameMaterial && move.GetPawnPromoteTo() == Pieces::Empty ) { continue; } // SEE PRUNING if ( !inCheck && move.GetPawnPromoteTo() == Pieces::Empty && ( resultMaterial > Constants::EndgameMaterial || move.GetTakesPiece() == Pieces::WhitePawn || move.GetTakesPiece() == Pieces::BlackPawn ) ) { const Score seeScore = seeScores[moveIndex]; if (seeScore < 0) // TODO: -10? { continue; } } board.DoMove(move); const Score childScore = -Quiescence(threadId, board, depth - 1, ply + 1, -beta, -alpha); board.UndoMove(); movesEvaluated++; if (childScore > bestScore) { bestScore = childScore; bestMove = move; if (childScore > alpha) { alpha = childScore; raisedAlpha = true; if (childScore >= beta) { betaCutoff = true; break; } } } } if (betaCutoff) { return beta; } return alpha; } class SearchedPosition { private: Breadcrumb* _breadcrumb; bool _owned; public: bool OtherThread; SearchedPosition(SearchState& state, const ThreadId threadId, const ZobristKey key, const Ply ply) { _owned = false; OtherThread = false; if(ply >= 6) { _breadcrumb = nullptr; return; } const size_t index = key & GlobalData::BreadcrumbMask; _breadcrumb = &state.Global.Breadcrumbs[index]; const ThreadId ownedId = _breadcrumb->TThreadId.load(std::memory_order::relaxed); if(ownedId == -1) { _breadcrumb->TThreadId.store(threadId, std::memory_order::relaxed); _breadcrumb->Key.store(key, std::memory_order::relaxed); _owned = true; } else if(ownedId != threadId) { const ZobristKey ownedKey = _breadcrumb->Key.load(std::memory_order::relaxed); if(ownedKey == key) { OtherThread = true; } } } ~SearchedPosition() { if(_owned) { _breadcrumb->TThreadId.store(-1, std::memory_order::relaxed); } } }; void UpdateHistoryEntry(MoveScore& score, const MoveScore value) { const MoveScore absValue = std::abs(value); if (absValue > 324) { return; } score -= (score * absValue) / 324; score += value * 32; } void Search::UpdateHistory(const ThreadId threadId, Board& board, Ply depth, Ply ply, MoveArray& attemptedMoves, MoveCount attemptedMoveCount, Move bestMove, bool betaCutoff) { auto& threadState = State.Thread[threadId]; auto& plyState = threadState.Plies[ply]; const bool isCapture = bestMove.GetTakesPiece() != Pieces::Empty; const Move previousMove1 = board.HistoryDepth > 0 ? board.History[board.HistoryDepth - 1].Move : Move(0); const Move previousMove2 = board.HistoryDepth > 1 ? board.History[board.HistoryDepth - 2].Move : Move(0); //const Score bonus = static_cast<Score>(depth * depth); const MoveScore bonus = depth * depth + depth - 1; if(isCapture) { UpdateHistoryEntry(threadState.CaptureHistory[bestMove.GetPiece()][bestMove.GetTo()][bestMove.GetTakesPiece()], bonus); } else { UpdateHistoryEntry(threadState.History[bestMove.GetColorToMove()][bestMove.GetFrom()][bestMove.GetTo()], bonus); if (previousMove1.Value != 0) { UpdateHistoryEntry(threadState.AllContinuations[previousMove1.GetPiece()][previousMove1.GetTo()].Scores[bestMove.GetPiece()][bestMove.GetTo()], bonus); } if (previousMove2.Value != 0) { UpdateHistoryEntry(threadState.AllContinuations[previousMove2.GetPiece()][previousMove2.GetTo()].Scores[bestMove.GetPiece()][bestMove.GetTo()], bonus); } UpdateHistoryEntry(threadState.History[bestMove.GetColorToMove()][bestMove.GetFrom()][bestMove.GetTo()], bonus); if(betaCutoff) { if (bestMove.Value != plyState.Killers[0].Value) { plyState.Killers[1] = plyState.Killers[0]; plyState.Killers[0] = bestMove; } threadState.Countermoves[previousMove1.GetPiece()][previousMove1.GetTo()] = bestMove; } } for (MoveCount moveIndex = 0; moveIndex < attemptedMoveCount; moveIndex++) { const Move& attemptedMove = attemptedMoves[moveIndex]; const bool attemptedCapture = attemptedMove.GetTakesPiece() != Pieces::Empty; if (attemptedCapture) { UpdateHistoryEntry(threadState.CaptureHistory[attemptedMove.GetPiece()][attemptedMove.GetTo()][attemptedMove.GetTakesPiece()], -bonus); } else { UpdateHistoryEntry(threadState.History[attemptedMove.GetColorToMove()][attemptedMove.GetFrom()][attemptedMove.GetTo()], -bonus); } } } Score Search::AlphaBeta(const ThreadId threadId, Board& board, Ply depth, const Ply ply, Score alpha, Score beta, bool isPrincipalVariation, bool isCutNode, bool nullMoveAllowed) { ThreadState& threadState = State.Thread[threadId]; PlyData& plyState = threadState.Plies[ply]; const bool rootNode = ply == 0; const bool zeroWindow = alpha == beta - 1; // TIME CONTROL if (depth > 2 && (threadState.StopIteration || Stopper.ShouldStop())) { const Score score = Contempt(board); return score; } // REPETITION DETECTION if (nullMoveAllowed && !rootNode) { const bool isDraw = IsRepetitionOr50Move(board); if (isDraw) { const auto score = Contempt(board); return score; } } // TABLEBASES PROBE //if(Tablebases::CanProbe(board)) //{ // if (rootNode) // { // Move tbMove; // const auto tbWin = Tablebases::ProbeRoot(board, tbMove); // if (tbWin) // { // StoreTranspositionTable(threadState, board.Key, tbMove, 42, Constants::TablebaseMate, TranspositionTableFlags::Exact); // return Constants::TablebaseMate; // } // } // else // { // auto result = Tablebases::Probe(board); // switch (result) // { // case GameOutcome::Win: // return Constants::TablebaseMate; // case GameOutcome::Draw: // return Contempt(board); // case GameOutcome::Loss: // return -Constants::TablebaseMate; // case GameOutcome::Unknown: // Throw(); // break; // } // } //} // MATE DISTANCE PRUNE const Score currentMateScore = Constants::Mate - ply; if (!rootNode) { if (alpha < -currentMateScore) { alpha = -currentMateScore; } if (beta > currentMateScore - 1) { beta = currentMateScore - 1; } if (alpha >= beta) { return alpha; } } // IN CHECK EXTENSION const Bitboard checkers = AttacksGenerator::GetCheckers(board); const bool inCheck = checkers != BitboardConstants::Empty; if (inCheck) { depth++; } // QUIESCENCE if(depth <= 0) { const Score eval = Quiescence(threadId, board, depth, ply, alpha, beta); return eval; } ++State.Stats.Nodes; const MoveScore bonus = depth * depth + depth - 1; // PROBE TRANSPOSITION TABLE TranspositionTableEntry entry; bool hashEntryExists = true; Score probedScore; const ZobristKey key = ZobristKeys.GetSingularKey(board.Key, threadState.SingularMove.Value); const bool probeSuccess = TryProbeTranspositionTable(key, depth, alpha, beta, entry, probedScore, hashEntryExists); const Move principalVariationMove = hashEntryExists ? entry.MMove : Move(0); if (probeSuccess) { bool returnTtValue = !isPrincipalVariation || (probedScore > alpha && probedScore < beta); if(returnTtValue /*&& isPrincipalVariation*/) { board.DoMove(principalVariationMove); if (IsRepetitionOr50Move(board)) { returnTtValue = false; } board.UndoMove(); } if (returnTtValue) { if (probedScore > Constants::MateThreshold) { probedScore -= ply; } else if (probedScore < -Constants::MateThreshold) { probedScore += ply; } if (principalVariationMove.GetTakesPiece() == Pieces::Empty) { UpdateHistoryEntry(threadState.History[principalVariationMove.GetColorToMove()][principalVariationMove.GetFrom()][principalVariationMove.GetTo()], bonus); } else { UpdateHistoryEntry(threadState.CaptureHistory[principalVariationMove.GetPiece()][principalVariationMove.GetTo()][principalVariationMove.GetTakesPiece()], bonus); } return probedScore; } } // STATIC EVALUATION EachColor<Bitboard> pins; PinDetector::GetPinnedToKings(board, pins); Score staticScore = Evaluation::Evaluate(board, pins, State.Global.Eval); //if (hashEntryExists && entry.Flag & (probedScore > staticScore ? TranspositionTableFlags::Beta : TranspositionTableFlags::Alpha)) //{ // staticScore = probedScore; //} board.StaticEvaluation = staticScore; const bool improving = board.HistoryDepth < 2 || staticScore >= board.History[board.HistoryDepth - 2].StaticEvaluation; // STATIC EVALUATION PRUNING if ( depth < 3 && !isPrincipalVariation && !inCheck ) { constexpr Score marginPerDepth = 120; // 120? Pawn is 100 Score margin = marginPerDepth * depth; //if(improving) //{ // margin += marginPerDepth; //} if (staticScore - margin >= beta) { return staticScore - margin; } } Move previousMove1 = !rootNode ? board.History[board.HistoryDepth - 1].Move : Move(0); Move previousMove2 = board.HistoryDepth > 1 ? board.History[board.HistoryDepth - 2].Move : Move(0); // NULL MOVE PRUNING if ( nullMoveAllowed && !rootNode && !inCheck && depth > 2 && staticScore >= beta //&& board.PieceMaterial[board.ColorToMove] > Constants::EndgameMaterial ) { const Ply nullDepthReduction = 3 + depth / 5 + static_cast<Ply>(std::min(3, (staticScore - beta) / 256)); const Move nullMove = Move(0, 0, Pieces::Empty); board.DoMove(nullMove); const Score nullMoveScore = -AlphaBeta(threadId, board, depth - nullDepthReduction - 1, ply + 1, -beta, -beta + 1, false, !isCutNode, false); board.UndoMove(); if (nullMoveScore >= beta) { return beta; } } const Bitboard pinned = pins[board.ColorToMove]; MoveArray moves; MoveCount moveCount = 0; ScoreArray seeScores; MoveScoreArray staticMoveScores; const Move countermove = threadState.Countermoves[previousMove1.GetPiece()][previousMove1.GetTo()]; // PROBCUT //if ( // !inCheck // && !isPrincipalVariation // && depth >= 5 // && abs(beta) < Constants::MateThreshold // && !( // hashEntryExists // && entry.Flag == TranspositionTableFlags::Alpha // && entry.SScore < beta) // ) //{ // MoveGenerator::GetAllPotentialCaptures(board, checkers, pinned, moves, moveCount); // See::CalculateSeeScores(board, moves, moveCount, seeScores); // MoveOrdering::CalculateStaticScores(threadId, State, moves, seeScores, moveCount, ply, principalVariationMove, countermove, staticMoveScores); // Score threshold = beta + 200; // for (MoveCount moveIndex = 0; moveIndex < moveCount; moveIndex++) // { // MoveOrdering::OrderNextMove(threadId, State, ply, moveIndex, moves, seeScores, staticMoveScores, moveCount); // const Move move = moves[moveIndex]; // const bool valid = MoveValidator::IsKingSafeAfterMove2(board, move, checkers, pinned); // if (!valid) // { // continue; // } // const Score seeScore = seeScores[moveIndex]; // if(seeScore < 0) // { // break; // } // board.DoMove(move); // // See if a quiescence search beats pbBeta // Score pbScore = -Quiescence(threadId, board, depth-1, ply+1, -threshold, -threshold + 1); // // If it did, do a proper search with reduced depth // if (pbScore >= threshold) // { // pbScore = -AlphaBeta(threadId, board, depth - 4, ply + 1, -threshold, -threshold + 1, false, false, true); // } // board.UndoMove(); // // Cut if the reduced depth search beats pbBeta // if (pbScore >= threshold) // { // return pbScore; // } // } //} // FUTILITY PRUNING - DETECTION bool futilityPruning = false; //const Score futilityPerDepth = Options::TuneScore1; //std::array<Score, 4> futilityMargins{ 0, futilityPerDepth, futilityPerDepth * 2, futilityPerDepth }; std::array<Score, 4> futilityMargins { 0, 200, 300, 500 }; if ( depth <= 3 && !isPrincipalVariation && !inCheck && std::abs(alpha) < 9000 && staticScore + futilityMargins[depth] <= alpha //&& board.PieceMaterial[board.ColorToMove] > 0 ) { futilityPruning = true; } //TablebaseResult parentResult = TablebaseResult::Unknown; //if(Tablebases::CanProbe(board)) //{ // parentResult = Tablebases::Probe(board); //} // MOVE LOOP SearchedPosition searchedPosition = SearchedPosition(State, threadId, board.Key, ply); moveCount = 0; MoveGenerator::GetAllPotentialMoves(board, checkers, pinned, moves, moveCount); See::CalculateSeeScores(board, moves, moveCount, seeScores); MoveOrdering::CalculateStaticScores(threadId, State, moves, seeScores, moveCount, ply, principalVariationMove, countermove, staticMoveScores, board); Score bestScore = -Constants::Inf; Move bestMove; bool raisedAlpha = false; bool betaCutoff = false; uint8_t movesEvaluated = 0; MoveArray failedMoves; MoveCount failedMoveCount = 0; for (MoveCount moveIndex = 0; moveIndex < moveCount; moveIndex++) { MoveOrdering::OrderNextMove(moveIndex, moves, seeScores, staticMoveScores, moveCount); const Move move = moves[moveIndex]; //if(move.Value == threadState.SingularMove.Value) //{ // continue; //} const bool valid = MoveValidator::IsKingSafeAfterMove2(board, move, checkers, pinned); if (!valid) { continue; } // SINGULAR EXTENSION Ply extension = 0; //if //( // !rootNode // && depth >= 6 // //&& nullMoveAllowed // && threadState.SingularMove.Value == 0 // && move.Value == principalVariationMove.Value // && entry.Flag == TranspositionTableFlags::Beta // && entry.Depth >= depth - 3 // && std::abs(entry.SScore) < Constants::MateThreshold //) //{ // const Score singularBeta = entry.SScore - 10 * depth; // const Score singularAlpha = singularBeta - 1; // const Ply singularDepth = depth / 2; // // threadState.SingularMove = move; // const Score singularScore = AlphaBeta(threadId, board, singularDepth, ply, singularAlpha, singularBeta, false, isCutNode, true); // threadState.SingularMove = Move(0); // if(singularScore < singularBeta) // { // extension++; // } // else if(singularBeta >= beta) // { // return singularBeta; // } // else if(entry.SScore >= beta) // { // threadState.SingularMove = move; // const Score zeroWindowScore = AlphaBeta(threadId, board, singularDepth, ply, beta - 1, beta, false, isCutNode, true); // threadState.SingularMove = Move(0); // if(zeroWindowScore >= beta) // { // return beta; // } // } //} const Score seeScore = seeScores[moveIndex]; // SHALLOW PRUNING //if (!rootNode && movesEvaluated > 0) //{ // if (movesEvaluated > (3 + 2 * depth * depth) / (2 - improving)) // { // continue; // } // // Quiet late move pruning // if ((move.GetTakesPiece() == Pieces::Empty) && movesEvaluated > (1 + depth * depth) / (2 - improving)) { // continue; // } // const Ply lmrDepth = depth - SearchData.Reductions[isPrincipalVariation ? 1 : 0][depth][movesEvaluated]; // //if (lmrDepth < 7 && seeScore < -50 * depth) // if (lmrDepth < 3 && threadState.History[move.GetColorToMove()][move.GetFrom()][move.GetTo()] < -1024 * depth) // { // continue; // } // if (lmrDepth < 7 && !See::SeeTest(board, move, -50 * depth)) // { // continue; // } //} board.DoMove(move); const Piece takesPiece = move.GetTakesPiece(); const bool capture = takesPiece != Pieces::Empty; const Piece pawnPromoteTo = move.GetPawnPromoteTo(); const bool promotion = pawnPromoteTo != Pieces::Empty; // FUTILITY PRUNING if ( futilityPruning && movesEvaluated > 0 && takesPiece == Pieces::Empty && pawnPromoteTo == Pieces::Empty ) { const Position opponentKingPos = board.KingPositions[board.ColorToMove]; const bool opponentInCheck = AttacksGenerator::IsPositionAttacked(board, opponentKingPos, !board.WhiteToMove); if (!opponentInCheck) { board.UndoMove(); continue; } } // LATE MOVE REDUCTION Ply reduction = 0; if ( movesEvaluated > 1 && (!rootNode || movesEvaluated > 3) //&& (!isPrincipalVariation || movesEvaluated > 3) && depth >= 3 //&& !inCheck && move.Value != plyState.Killers[0].Value && move.Value != plyState.Killers[1].Value //&& move.Value != countermove.Value && seeScore <= 0 && pawnPromoteTo == Pieces::Empty ) { const auto pvReductionIndex = isPrincipalVariation ? 1 : 0; const auto captureReductionIndex = takesPiece == Pieces::Empty ? 0 : 1; reduction = SearchData.Reductions[pvReductionIndex][captureReductionIndex][depth][movesEvaluated]; if (!isPrincipalVariation && !improving && reduction > 1) { reduction++; } //if //( // reduction > 0 // && // ( // move.Value == plyState.Killers[0].Value // || move.Value == plyState.Killers[1].Value // ) //) //{ // reduction--; //} //if //( // !isPrincipalVariation // && threadState.IterationInitialDepth > 6 // && threadState.BestMoveChanges <= 2 //) //{ // reduction++; //} MoveScore moveScore = capture ? threadState.CaptureHistory[move.GetPiece()][move.GetTo()][takesPiece] : threadState.History[move.GetColorToMove()][move.GetFrom()][move.GetTo()] + threadState.AllContinuations[previousMove1.GetPiece()][previousMove1.GetTo()].Scores[move.GetPiece()][move.GetTo()] + threadState.AllContinuations[previousMove2.GetPiece()][previousMove2.GetTo()].Scores[move.GetPiece()][move.GetTo()]; if ( reduction > 0 && moveScore > 0 ) { reduction--; } if (moveScore < 0) { //reduction -= moveScore / 4000; reduction++; //if(moveScore < 5000) //{ // reduction++; //} } //if //( // isCutNode // && move.GetTakesPiece() == Pieces::Empty //) //{ // reduction += 2; //} if ( !isPrincipalVariation && threadState.History[move.GetColorToMove()][move.GetFrom()][move.GetTo()] < 0 ) { reduction++; } if (searchedPosition.OtherThread) { reduction++; } } const bool isReduced = reduction > 0; const bool childCut = isReduced || !isCutNode; Score childScore; if (movesEvaluated > 0) { childScore = -AlphaBeta(threadId, board, depth + extension - reduction - 1, ply + 1, -alpha - 1, -alpha, false, childCut, true); if (!zeroWindow && childScore > alpha) { childScore = -AlphaBeta(threadId, board, depth + extension - reduction - 1, ply + 1, -beta, -alpha, isPrincipalVariation, childCut, true); } if (reduction > 0 && childScore > alpha) { childScore = -AlphaBeta(threadId, board, depth + extension - 1, ply + 1, -beta, -alpha, isPrincipalVariation, childCut, true); } } else { childScore = -AlphaBeta(threadId, board, depth + extension - reduction - 1, ply + 1, -beta, -alpha, isPrincipalVariation, childCut, true); if (reduction > 0 && childScore > alpha) { childScore = -AlphaBeta(threadId, board, depth + extension - 1, ply + 1, -beta, -alpha, isPrincipalVariation, false, true); } } board.UndoMove(); movesEvaluated++; if (childScore > bestScore) { bestScore = childScore; bestMove = move; if (childScore > alpha) { alpha = childScore; raisedAlpha = true; if (rootNode) { threadState.BestMoveChanges++; } if (childScore >= beta) { betaCutoff = true; break; } } } //else { failedMoves[failedMoveCount++] = move; } } if (raisedAlpha) { UpdateHistory(threadId, board, depth, ply, failedMoves, failedMoveCount, bestMove, betaCutoff); if(betaCutoff) { StoreTranspositionTable(threadState, key, bestMove, depth, bestScore, TranspositionTableFlags::Beta); return beta; } } // MATE / STALEMATE if(movesEvaluated == 0) { if(inCheck) { return -currentMateScore; } return Contempt(board); } //if (threadState.SingularMove.Value == 0) { if (raisedAlpha) { StoreTranspositionTable(threadState, key, bestMove, depth, bestScore, TranspositionTableFlags::Exact); } else { StoreTranspositionTable(threadState, key, bestMove, depth, bestScore, TranspositionTableFlags::Alpha); } } return alpha; } Score Search::Aspiration(const ThreadId threadId, Board& board, const Ply depth, const Score previous) { if(depth < 5) { State.Thread[threadId].BestMoveChanges = 0; const Score fullSearchScore = AlphaBeta(threadId, board, depth, 0, -Constants::Inf, Constants::Inf, true, false, true); return fullSearchScore; } constexpr Score window = 20; constexpr Score termination = 5000; Score widen = 20; Score alpha = previous - window; Score beta = previous + window; while (true) { if (alpha < -termination) { alpha = -Constants::Inf; } if (beta > termination) { beta = Constants::Inf; } State.Thread[threadId].BestMoveChanges = 0; const Score score = AlphaBeta(threadId, board, depth, 0, alpha, beta, true, false, true); widen *= 2; if (score <= alpha) { alpha = static_cast<Score>(std::max(alpha - widen, -Constants::Inf)); beta = (alpha + 3 * beta) / 4; // Trick to circumvent search instability issues } else if (score >= beta) { beta = std::min(static_cast<Score>(beta + widen), Constants::Inf); } else { return score; } } } void Search::GetSearchResults(SearchResults& results, Ply depth, Score score) { results.BestMove = State.Thread[0].SavedPrincipalVariation[0]; results.SearchedDepth = depth; results.SScore = score; } void Search::IterativeDeepen(const ThreadId threadId, Board& board, SearchResults& results) { ThreadState& threadState = State.Thread[threadId]; Ply depth = 1; threadState.IterationInitialDepth = depth; Score score = AlphaBeta(threadId, board, depth, 0, -Constants::Inf, Constants::Inf, true, false, true); threadState.SavedPrincipalVariation.clear(); State.Global.Table.GetPrincipalVariation(board, threadState.SavedPrincipalVariation); State.Stats.Elapsed = Stopper.GetElapsed(); SearchCallbackData callbackData(threadId, board, State, 1, score); if (threadId == 0) { Callback(callbackData); } if (Stopper.ShouldStopDepthIncrease(threadId, State)) { GetSearchResults(results, depth, score); return; } for (depth = depth + 1; depth < State.Global.Parameters.MaxDepth; depth++) { threadState.IterationInitialDepth = depth; score = Aspiration(threadId, board, depth, score); callbackData.Depth = depth; callbackData._Score = score; const bool pvMoveChanged = State.Global.Table.IsRootMoveChanged(board, threadState.SavedPrincipalVariation); if(pvMoveChanged) { threadState.IterationsSincePvChange = 0; } else { threadState.IterationsSincePvChange++; } State.Stats.Elapsed = Stopper.GetElapsed(); if(Stopper.ShouldStopDepthIncrease(threadId, State)) { break; } threadState.SavedPrincipalVariation.clear(); State.Global.Table.GetPrincipalVariation(board, threadState.SavedPrincipalVariation); if (threadId == 0) { Callback(callbackData); } } GetSearchResults(results, depth, score); } void Search::IterativeDeepenLazySmp(Board& board, SearchResults& results) { ThreadState& mainThreadState = State.Thread[0]; Ply depth = 1; mainThreadState.IterationInitialDepth = depth; Score score = AlphaBeta(0, board, 1, 0, -Constants::Inf, Constants::Inf, true, false, true); mainThreadState.SavedPrincipalVariation.clear(); State.Global.Table.GetPrincipalVariation(board, mainThreadState.SavedPrincipalVariation); State.Stats.Elapsed = Stopper.GetElapsed(); SearchCallbackData callbackData(0, board, State, 1, score); Callback(callbackData); //State.Global.Table.PrintOccupancy(); if (Stopper.ShouldStopDepthIncrease(0, State)) { GetSearchResults(results, depth, score); return; } for (depth = depth + 1; depth < State.Global.Parameters.MaxDepth; depth++) { State.Thread[0].IterationInitialDepth = depth; auto threads = std::vector<std::thread>(); for(ThreadId helperId = 1; helperId < Options::Threads; helperId++) { State.Thread[helperId] = State.Thread[0]; threads.emplace_back([this, helperId, board, depth, score]() { Board clone = board; const Ply helperDepth = depth + helperId / 2; State.Thread[helperId].IterationInitialDepth = helperDepth; Aspiration(helperId, clone, helperDepth, score); }); } score = Aspiration(0, board, depth, score); for (ThreadId helperId = 1; helperId < Options::Threads; helperId++) { State.Thread[helperId].StopIteration = true; } for (ThreadId helperId = 1; helperId < Options::Threads; helperId++) { threads[helperId-1].join(); } callbackData.Depth = depth; callbackData._Score = score; const bool pvMoveChanged = State.Global.Table.IsRootMoveChanged(board, mainThreadState.SavedPrincipalVariation); if (pvMoveChanged) { mainThreadState.IterationsSincePvChange = 0; } else { mainThreadState.IterationsSincePvChange++; } State.Stats.Elapsed = Stopper.GetElapsed(); if (Stopper.ShouldStopDepthIncrease(0, State)) { break; } mainThreadState.SavedPrincipalVariation.clear(); State.Global.Table.GetPrincipalVariation(board, mainThreadState.SavedPrincipalVariation); Callback(callbackData); //State.Global.Table.PrintOccupancy(); } GetSearchResults(results, depth, score); } void Search::Run(Board& board, const SearchParameters& parameters, SearchResults& results) { if(!State.Initialized) { State.NewGame(); } //std::cout << board.Key << std::endl; Stopper.Init(parameters, board.WhiteToMove); State.NewSearch(board, parameters); IterativeDeepenLazySmp(board, results); //IterativeDeepen(0, board, results); }
31.296007
180
0.564031
GediminasMasaitis
5921558f78644b3af23bd8b577e5c13f02be87c1
6,321
hpp
C++
IGC/Compiler/CISACodeGen/CodeSinking.hpp
bader/intel-graphics-compiler
04f51dc2f3d5047f334da5cb5eebe568480622f5
[ "MIT" ]
null
null
null
IGC/Compiler/CISACodeGen/CodeSinking.hpp
bader/intel-graphics-compiler
04f51dc2f3d5047f334da5cb5eebe568480622f5
[ "MIT" ]
null
null
null
IGC/Compiler/CISACodeGen/CodeSinking.hpp
bader/intel-graphics-compiler
04f51dc2f3d5047f334da5cb5eebe568480622f5
[ "MIT" ]
null
null
null
/*========================== begin_copyright_notice ============================ Copyright (c) 2000-2021 Intel Corporation Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ============================= end_copyright_notice ===========================*/ /** * Originated from llvm code-sinking, need add their copyright **/ //===-- Sink.cpp - Code Sinking -------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is distributed under the University of Illinois Open Source // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// #pragma once #include "common/LLVMWarningsPush.hpp" #include <llvm/Analysis/PostDominators.h> #include <llvm/Analysis/LoopInfo.h> #include "common/LLVMWarningsPop.hpp" namespace IGC { #define CODE_SINKING_MIN_SIZE 32 class CodeSinking : public llvm::FunctionPass { llvm::DominatorTree* DT; llvm::PostDominatorTree* PDT; llvm::LoopInfo* LI; const llvm::DataLayout* DL; // to estimate register pressure CodeGenContext* CTX; public: static char ID; // Pass identification CodeSinking(bool generalSinking = false); virtual bool runOnFunction(llvm::Function& F) override; virtual void getAnalysisUsage(llvm::AnalysisUsage& AU) const override { AU.setPreservesCFG(); AU.addRequired<llvm::DominatorTreeWrapperPass>(); AU.addRequired<llvm::PostDominatorTreeWrapperPass>(); AU.addRequired<llvm::LoopInfoWrapperPass>(); AU.addRequired<CodeGenContextWrapper>(); AU.addPreserved<llvm::DominatorTreeWrapperPass>(); AU.addPreserved<llvm::PostDominatorTreeWrapperPass>(); AU.addPreserved<llvm::LoopInfoWrapperPass>(); } private: bool ProcessBlock(llvm::BasicBlock& blk); bool SinkInstruction(llvm::Instruction* I, llvm::SmallPtrSetImpl<llvm::Instruction*>& Stores, bool ForceToReducePressure); bool AllUsesDominatedByBlock(llvm::Instruction* inst, llvm::BasicBlock* blk, llvm::SmallPtrSetImpl<llvm::Instruction*>& usesInBlk) const; bool FindLowestSinkTarget(llvm::Instruction* inst, llvm::BasicBlock*& blk, llvm::SmallPtrSetImpl<llvm::Instruction*>& usesInBlk, bool& outerLoop, bool doLoopSink); bool isSafeToMove(llvm::Instruction* inst, bool& reducePressure, bool& hasAliasConcern, llvm::SmallPtrSetImpl<llvm::Instruction*>& Stores); /// local processing bool LocalSink(llvm::BasicBlock* blk); /// data members for local-sinking llvm::SmallPtrSet<llvm::BasicBlock*, 8> localBlkSet; llvm::SmallPtrSet<llvm::Instruction*, 8> localInstSet; /// data members for undo std::vector<llvm::Instruction*> movedInsts; std::vector<llvm::Instruction*> undoLocas; /// counting the number of gradient/sample operation sinked into CF unsigned totalGradientMoved; unsigned numGradientMovedOutBB; bool generalCodeSinking; // diagnosis variable: int numChanges; // fat BB is the BB with the largest register pressure // Currently, used it for BB inside a loop only. llvm::BasicBlock* m_fatBB; uint32_t m_fatBBPressure; // try to hoist phi nodes with congruent incoming values typedef std::pair<llvm::Instruction*, llvm::Instruction*> InstPair; typedef smallvector<llvm::Instruction*, 4> InstVec; void appendIfNotExist(InstPair src, std::vector<InstPair> &instMap) { if (std::find(instMap.begin(), instMap.end(), src) == instMap.end()) { instMap.push_back(src); } } void appendIfNotExist(InstVec& dst, llvm::Instruction* inst) { if (std::find(dst.begin(), dst.end(), inst) == dst.end()) { dst.push_back(inst); } } void appendIfNotExist(InstVec& dst, InstVec& src) { for (auto* I : src) { appendIfNotExist(dst, I); } } // check if two values are congruent (derived from same values), and // record all intermediate results in vector. bool checkCongruent(std::vector<InstPair> &instMap, const InstPair& values, InstVec& leaves, unsigned depth); /** * Detech phi with congruent incoming values, and try to hoist them to * dominator. In some cases, GVN may leave code like this and increase * register pressure. */ bool hoistCongruentPhi(llvm::PHINode* phi); bool hoistCongruentPhi(llvm::Function& F); // Move LI back into loops bool loopSink(llvm::BasicBlock* BBWithPressure, bool SinkMultipleLevel); bool canLoopSink(llvm::Instruction* I, llvm::Loop* L, llvm::BasicBlock* BB); bool LoopSinkInstructions( llvm::SmallVector<llvm::Instruction*, 64> sinkCandidates, llvm::Loop* L); // Move referencing DbgValueInst intrinsics calls after defining instructions void ProcessDbgValueInst(llvm::BasicBlock& blk); }; }
40.261146
117
0.636925
bader