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
sequencelengths
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
sequencelengths
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
sequencelengths
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
612162de4c5e1dd79b5da101291f113d4f8c40e9
22,412
cpp
C++
ControlWnd.cpp
Memotech-Bill/CamTest
5b45ed610ba84ce4ef6feb5c5cd53a75f8797b2d
[ "BSD-2-Clause" ]
null
null
null
ControlWnd.cpp
Memotech-Bill/CamTest
5b45ed610ba84ce4ef6feb5c5cd53a75f8797b2d
[ "BSD-2-Clause" ]
null
null
null
ControlWnd.cpp
Memotech-Bill/CamTest
5b45ed610ba84ce4ef6feb5c5cd53a75f8797b2d
[ "BSD-2-Clause" ]
null
null
null
// ControlWnd.cpp - A window for containing camera controls. #include <wx/panel.h> #include <wx/choice.h> #include <wx/checkbox.h> #include <wx/slider.h> #include <wx/spinctrl.h> #include <wx/stattext.h> #include <libcamera/controls.h> #include <libcamera/control_ids.h> #include "ControlWnd.h" BEGIN_EVENT_TABLE(ControlWnd, wxPanel) EVT_CHOICE(wxID_ANY, ControlWnd::OnChoice) EVT_SLIDER(wxID_ANY, ControlWnd::OnSlider) EVT_CHECKBOX(wxID_ANY, ControlWnd::OnCheckBox) EVT_SPINCTRL(wxID_ANY, ControlWnd::OnSpinCtrl) END_EVENT_TABLE() /*** ControlWnd ******************************************************* Constructor. Inputs: parent = Parent window. Coding history: WJB 19/06/21 Converted from MovieCap */ ControlWnd::ControlWnd (wxWindow *parent) : wxPanel (parent) { // printf ("ControlWnd constructor.\n"); // Create controls. LoadCtl (); m_fgsz = new wxFlexGridSizer (2); m_fgsz->AddGrowableCol (1); std::vector<ImgCtl>::iterator it; int iCtrl; for (iCtrl = 0, it = m_victl.begin (); it != m_victl.end (); ++iCtrl, ++it) { const char *psDesc = it->GetDesc ().c_str (); // printf ("Create image control \"%s\"\n", psDesc); wxString sDesc = wxString (psDesc, wxConvUTF8); m_fgsz->Add (new wxStaticText (this, wxID_ANY, sDesc), 0, wxALIGN_CENTRE_VERTICAL); int iType = it->GetType (); int iMin, iMax, iDef, iVal; it->GetData (iMin, iMax, iDef, iVal); if ( iType == 1 ) { wxBoxSizer *phbsz1 = new wxBoxSizer (wxHORIZONTAL); m_fgsz->Add (phbsz1, 0, wxEXPAND | wxALIGN_CENTRE_VERTICAL); wxSlider *pslide = new wxSlider (this, 3*iCtrl, iVal, iMin, iMax, wxDefaultPosition, wxSize (100,-1)); pslide->Enable (it->Enabled ()); phbsz1->Add (pslide, 1, wxEXPAND | wxALIGN_CENTRE_VERTICAL); wxSpinCtrl *pspin = new wxSpinCtrl (this, 3*iCtrl + 1, wxT(""), wxDefaultPosition, wxSize (120, -1), wxSP_VERTICAL); pspin->SetRange (iMin, iMax); pspin->SetValue (iVal); pspin->Enable (it->Enabled ()); phbsz1->Add (pspin, 0, wxALIGN_CENTRE_VERTICAL); } else if ( iType == 2 ) { wxCheckBox * pchk = new wxCheckBox (this, 3*iCtrl, wxT("")); pchk->SetValue (it->Enabled ()); m_fgsz->Add (pchk, 0, wxEXPAND); } else if ( iType == 3 ) { wxChoice * pchc = new wxChoice (this, 3*iCtrl); for ( int iItem = iMin; iItem <= iMax; ++iItem ) { const char *psMenu = it->GetMenuItem (iItem).c_str (); // printf ("Menu item %d = \"%s\"\n", iItem, psMenu); pchc->Append (wxString (psMenu, wxConvUTF8)); } pchc->SetSelection (iVal - iMin); m_fgsz->Add (pchc, 0, wxEXPAND); } else if ( iType == 4 ) { wxBoxSizer *phbsz1 = new wxBoxSizer (wxHORIZONTAL); m_fgsz->Add (phbsz1, 0, wxEXPAND | wxALIGN_CENTRE_VERTICAL); wxCheckBox * pchk = new wxCheckBox (this, 3*iCtrl, wxT("")); pchk->SetValue (it->Enabled ()); phbsz1->Add (pchk, 0, wxALIGN_CENTRE_VERTICAL); wxSlider *pslide = new wxSlider (this, 3*iCtrl + 1, iVal, iMin, iMax, wxDefaultPosition, wxSize (100,-1)); pslide->Enable (it->Enabled ()); phbsz1->Add (pslide, 1, wxALIGN_CENTRE_VERTICAL); wxSpinCtrl *pspin = new wxSpinCtrl (this, 3*iCtrl + 2, wxT(""), wxDefaultPosition, wxSize (120, -1), wxSP_VERTICAL); pspin->SetRange (iMin, iMax); pspin->SetValue (iVal); pspin->Enable (it->Enabled ()); phbsz1->Add (pspin, 0, wxALIGN_CENTRE_VERTICAL); } else if ( iType == 5 ) { wxSpinCtrl *pspin = new wxSpinCtrl (this, 3*iCtrl, wxT(""), wxDefaultPosition, wxSize (120, -1), wxSP_VERTICAL); pspin->SetRange (iMin, iMax); pspin->SetValue (iVal); m_fgsz->Add (pspin, 0, wxEXPAND | wxALIGN_CENTRE_VERTICAL); } else if ( iType == 6 ) { wxBoxSizer *phbsz1 = new wxBoxSizer (wxHORIZONTAL); m_fgsz->Add (phbsz1, 0, wxEXPAND | wxALIGN_CENTRE_VERTICAL); wxCheckBox * pchk = new wxCheckBox (this, 3*iCtrl, wxT("")); pchk->SetValue (it->Enabled ()); phbsz1->Add (pchk, 0, wxALIGN_CENTRE_VERTICAL); wxSpinCtrl *pspin = new wxSpinCtrl (this, 3*iCtrl + 2, wxT(""), wxDefaultPosition, wxSize (120, -1), wxSP_VERTICAL); pspin->SetRange (iMin, iMax); pspin->SetValue (iVal); pspin->Enable (it->Enabled ()); phbsz1->Add (pspin, 1, wxALIGN_CENTRE_VERTICAL); } } m_fgsz->Add (new wxStaticText (this, wxID_ANY, ""), 0, wxALIGN_CENTRE_VERTICAL); m_fgsz->Add (new wxButton (this, ID_SNAP, "Snap"), 0, wxALIGN_CENTRE_VERTICAL); SetSizer (m_fgsz); m_fgsz->SetSizeHints (this); } /*** ~ControlWnd ****************************************************** Destructor. Coding history: WJB 19/ 6/21 Empty version. */ ControlWnd::~ControlWnd (void) { // printf ("ControlWnd destructor.\n"); } /*** LoadCtl ******************************************************* Load all the controls for the image capture device. Coding history: WJB 19/ 6/21 Converted from MovieCap */ void ControlWnd::LoadCtl (void) { ImgCtl ctl (0); m_victl.clear (); /* Brightness */ ctl.m_iID = ctrlBright; // Control ID. ctl.m_sName = "Brightness"; // Control name. ctl.m_iType = 4; // Control type. ctl.m_iMin = 0; // Minimum control value. ctl.m_iMax = 100; // Maximum control value. ctl.m_iStep = 1; // Control value step. ctl.m_iDefault = 50; // Default value. ctl.m_iValue = 50; // Current value. ctl.m_bEnable = true; ctl.m_bChanged = false; m_victl.push_back (ctl); /* Contrast */ ctl.m_iID = ctrlCont; // Control ID. ctl.m_sName = "Contrast"; // Control name. ctl.m_iType = 4; // Control type. ctl.m_iMin = -100; // Minimum control value. ctl.m_iMax = 100; // Maximum control value. ctl.m_iStep = 1; // Control value step. ctl.m_iDefault = 0; // Default value. ctl.m_iValue = 0; // Current value. ctl.m_bEnable = true; ctl.m_bChanged = false; m_victl.push_back (ctl); /* Saturation */ ctl.m_iID = ctrlSat; // Control ID. ctl.m_sName = "Saturation"; // Control name. ctl.m_iType = 4; // Control type. ctl.m_iMin = -100; // Minimum control value. ctl.m_iMax = 100; // Maximum control value. ctl.m_iStep = 1; // Control value step. ctl.m_iDefault = 0; // Default value. ctl.m_iValue = 0; // Current value. ctl.m_bEnable = true; ctl.m_bChanged = false; m_victl.push_back (ctl); /* Exposure Compensation */ ctl.m_iID = ctrlExpComp; // Control ID. ctl.m_sName = "Exposure Comp."; // Control name. ctl.m_iType = 4; // Control type. ctl.m_iMin = -10; // Minimum control value. ctl.m_iMax = 10; // Maximum control value. ctl.m_iStep = 1; // Control value step. ctl.m_iDefault = 0; // Default value. ctl.m_iValue = 0; // Current value. ctl.m_bEnable = false; ctl.m_bChanged = false; m_victl.push_back (ctl); /* White Balance */ ctl.m_iID = ctrlWhiteBal; // Control ID. ctl.m_sName = "White Balance"; // Control name. ctl.m_iType = 3; // Control type. ctl.m_iMin = 0; // Minimum control value. ctl.m_iMax = 8; // Maximum control value. ctl.m_iStep = 1; // Control value step. ctl.m_iDefault = 1; // Default value. ctl.m_iValue = 1; // Current value. ctl.m_bEnable = true; ctl.m_bChanged = false; ctl.m_vsMenu.push_back (std::string ("Off")); ctl.m_vsMenu.push_back (std::string ("Auto")); ctl.m_vsMenu.push_back (std::string ("Incandescent")); ctl.m_vsMenu.push_back (std::string ("Tungsten")); ctl.m_vsMenu.push_back (std::string ("Fluorescent")); ctl.m_vsMenu.push_back (std::string ("Indoor")); ctl.m_vsMenu.push_back (std::string ("Daylight")); ctl.m_vsMenu.push_back (std::string ("Cloudy")); ctl.m_vsMenu.push_back (std::string ("Custom")); m_victl.push_back (ctl); ctl.m_vsMenu.clear (); /* Exposure Mode */ ctl.m_iID = ctrlExMode; // Control ID. ctl.m_sName = "Exposure Mode"; // Control name. ctl.m_iType = 3; // Control type. ctl.m_iMin = 0; // Minimum control value. ctl.m_iMax = 4; // Maximum control value. ctl.m_iStep = 1; // Control value step. ctl.m_iDefault = 1; // Default value. ctl.m_iValue = 1; // Current value. ctl.m_bEnable = true; ctl.m_bChanged = false; ctl.m_vsMenu.push_back (std::string ("Off")); ctl.m_vsMenu.push_back (std::string ("Normal")); ctl.m_vsMenu.push_back (std::string ("Short")); ctl.m_vsMenu.push_back (std::string ("Long")); ctl.m_vsMenu.push_back (std::string ("Custom")); m_victl.push_back (ctl); ctl.m_vsMenu.clear (); /* Meter Mode */ ctl.m_iID = ctrlMeterMode; // Control ID. ctl.m_sName = "Meter Mode"; // Control name. ctl.m_iType = 3; // Control type. ctl.m_iMin = 0; // Minimum control value. ctl.m_iMax = 3; // Maximum control value. ctl.m_iStep = 1; // Control value step. ctl.m_iDefault = 0; // Default value. ctl.m_iValue = 0; // Current value. ctl.m_bEnable = true; ctl.m_bChanged = false; ctl.m_vsMenu.push_back (std::string ("Centre-weighted")); ctl.m_vsMenu.push_back (std::string ("Spot")); ctl.m_vsMenu.push_back (std::string ("Matrix")); ctl.m_vsMenu.push_back (std::string ("Custom")); m_victl.push_back (ctl); ctl.m_vsMenu.clear (); /* Exposure Time */ ctl.m_iID = ctrlExp; // Control ID. ctl.m_sName = "Exposure Time"; // Control name. ctl.m_iType = 6; // Control type. ctl.m_iMin = 0; // Minimum control value. ctl.m_iMax = 1000000; // Maximum control value. ctl.m_iStep = 1000; // Control value step. ctl.m_iDefault = 10000; // Default value. ctl.m_iValue = 10000; // Current value. ctl.m_bEnable = false; ctl.m_bChanged = false; m_victl.push_back (ctl); /* Analog Gain */ ctl.m_iID = ctrlAlgGain; // Control ID. ctl.m_sName = "Analog Gain"; // Control name. ctl.m_iType = 4; // Control type. ctl.m_iMin = 0; // Minimum control value. ctl.m_iMax = 400; // Maximum control value. ctl.m_iStep = 10; // Control value step. ctl.m_iDefault = 100; // Default value. ctl.m_iValue = 100; // Current value. ctl.m_bEnable = false; ctl.m_bChanged = false; m_victl.push_back (ctl); #if HAVE_DIG_GAIN /* Digital Gain */ ctl.m_iID = ctrlDigGain; // Control ID. ctl.m_sName = "Digital Gain"; // Control name. ctl.m_iType = 4; // Control type. ctl.m_iMin = 0; // Minimum control value. ctl.m_iMax = 6400; // Maximum control value. ctl.m_iStep = 100; // Control value step. ctl.m_iDefault = 100; // Default value. ctl.m_iValue = 100; // Current value. ctl.m_bEnable = false; ctl.m_bChanged = false; m_victl.push_back (ctl); #endif /* Red Gain */ ctl.m_iID = ctrlRedGain; // Control ID. ctl.m_sName = "Red Gain"; // Control name. ctl.m_iType = 4; // Control type. ctl.m_iMin = 0; // Minimum control value. ctl.m_iMax = 800; // Maximum control value. ctl.m_iStep = 10; // Control value step. ctl.m_iDefault = 100; // Default value. ctl.m_iValue = 100; // Current value. ctl.m_bEnable = false; ctl.m_bChanged = false; m_victl.push_back (ctl); /* Blue Gain */ ctl.m_iID = ctrlBlueGain; // Control ID. ctl.m_sName = "Blue Gain"; // Control name. ctl.m_iType = 4; // Control type. ctl.m_iMin = 0; // Minimum control value. ctl.m_iMax = 800; // Maximum control value. ctl.m_iStep = 10; // Control value step. ctl.m_iDefault = 100; // Default value. ctl.m_iValue = 100; // Current value. ctl.m_bEnable = false; ctl.m_bChanged = false; m_victl.push_back (ctl); /* Dynamic Noise Reduction */ ctl.m_iID = ctrlDenoise; // Control ID. ctl.m_sName = "Denoise"; // Control name. ctl.m_iType = 3; // Control type. ctl.m_iMin = 0; // Minimum control value. ctl.m_iMax = 3; // Maximum control value. ctl.m_iStep = 1; // Control value step. ctl.m_iDefault = 0; // Default value. ctl.m_iValue = 0; // Current value. ctl.m_bEnable = true; ctl.m_bChanged = false; ctl.m_vsMenu.push_back (std::string ("Off")); ctl.m_vsMenu.push_back (std::string ("Low")); ctl.m_vsMenu.push_back (std::string ("Medium")); ctl.m_vsMenu.push_back (std::string ("High")); m_victl.push_back (ctl); ctl.m_vsMenu.clear (); /* Image scale */ ctl.m_iID = ctrlScale; // Control ID. ctl.m_sName = "Image Scale"; // Control name. ctl.m_iType = 1; // Control type. ctl.m_iMin = 1; // Minimum control value. ctl.m_iMax = 5; // Maximum control value. ctl.m_iStep = 1; // Control value step. ctl.m_iDefault = 1; // Default value. ctl.m_iValue = 1; // Current value. ctl.m_bEnable = true; ctl.m_bChanged = false; m_victl.push_back (ctl); /* Camera Run */ ctl.m_iID = ctrlRun; // Control ID. ctl.m_sName = "Camera Run"; // Control name. ctl.m_iType = 2; // Control type. ctl.m_iMin = 1; // Minimum control value. ctl.m_iMax = 5; // Maximum control value. ctl.m_iStep = 1; // Control value step. ctl.m_iDefault = 1; // Default value. ctl.m_iValue = 1; // Current value. ctl.m_bEnable = false; ctl.m_bChanged = false; m_victl.push_back (ctl); } /*** ApplyControls ************************************************************************************* Apply control settings to camera WJB 19/ 6/21 First draft */ void ControlWnd::ApplyControls (libcamera::ControlList &controls_) { controls_.clear (); /* Brightness */ if ( m_victl[ctrlBright].m_bEnable ) controls_.set(libcamera::controls::Brightness, m_victl[ctrlBright].m_iValue / 50.0 - 1.0); /* Contrast */ if ( m_victl[ctrlCont].m_bEnable ) controls_.set(libcamera::controls::Contrast, m_victl[ctrlCont].m_iValue / 100.0 + 1.0); /* Saturation */ if ( m_victl[ctrlSat].m_bEnable ) controls_.set(libcamera::controls::Saturation, m_victl[ctrlSat].m_iValue / 100.0 + 1.0); /* Exposure Compensation */ if ( m_victl[ctrlExpComp].m_bEnable ) controls_.set(libcamera::controls::ExposureValue, m_victl[ctrlExpComp].m_iValue / 4.0); /* White Balance */ if ( ( m_victl[ctrlWhiteBal].m_bEnable ) && ( m_victl[ctrlWhiteBal].m_iValue > 0 ) ) { controls_.set(libcamera::controls::AwbEnable, true); controls_.set(libcamera::controls::AwbMode, m_victl[ctrlWhiteBal].m_iValue - 1); } else { controls_.set(libcamera::controls::AwbEnable, false); } /* Exposure Mode */ if ( ( m_victl[ctrlExMode].m_bEnable ) && m_victl[ctrlExMode].m_iValue > 0 ) { controls_.set(libcamera::controls::AeEnable, true); controls_.set(libcamera::controls::AeExposureMode, m_victl[ctrlExMode].m_iValue - 1); } else { controls_.set(libcamera::controls::AeEnable, false); } /* Meter Mode */ if ( m_victl[ctrlMeterMode].m_bEnable ) controls_.set(libcamera::controls::AeMeteringMode, m_victl[ctrlMeterMode].m_iValue); /* Exposure Time */ if ( m_victl[ctrlExp].m_bEnable ) controls_.set(libcamera::controls::ExposureTime, m_victl[ctrlExp].m_iValue); // else controls_.set(libcamera::controls::ExposureTime, 0); /* Analog Gain */ if ( m_victl[ctrlAlgGain].m_bEnable ) controls_.set(libcamera::controls::AnalogueGain, m_victl[ctrlAlgGain].m_iValue / 100.0); #if HAVE_DIG_GAIN /* Digital Gain */ if ( m_victl[ctrlDigGain].m_bEnable ) controls_.set(libcamera::controls::DigitalGain, m_victl[ctrlDigGain].m_iValue / 100.0); #endif /* Red & Blue Gains */ if ( ( m_victl[ctrlRedGain].m_bEnable ) && ( m_victl[ctrlBlueGain].m_bEnable ) ) controls_.set(libcamera::controls::ColourGains, {float(m_victl[ctrlRedGain].m_iValue / 100.0), float(m_victl[ctrlBlueGain].m_iValue / 100.0)}); else if ( ( m_victl[ctrlWhiteBal].m_bEnable ) && ( m_victl[ctrlWhiteBal].m_iValue > 0 ) ) controls_.set(libcamera::controls::ColourGains, {0.0f, 0.0f}); // fval = picam->awb_gains_r; printf ("awb_gains_r = %10.3E\n", fval); /* Dynamic noise reduction */ if ( m_victl[ctrlDenoise].m_bEnable ) controls_.set(libcamera::controls::draft::NoiseReductionMode, libcamera::controls::draft::NoiseReductionModeEnum(m_victl[ctrlDenoise].m_iValue)); } /*** OnChoice ********************************************************* Update a camera control. Inputs: e = Choice event. Coding history: WJB 28/ 5/10 First draft. WJB 4/ 9/11 Revised for separate controls. */ void ControlWnd::OnChoice (wxCommandEvent &e) { int iCtrl = e.GetId () / 3; wxChoice * pchc = (wxChoice *) e.GetEventObject (); ImgCtl * pictl = &m_victl[iCtrl]; int iMin, iMax, iDefault, iValue; pictl->GetData (iMin, iMax, iDefault, iValue); iValue = pchc->GetSelection () + iMin; pictl->Set (iValue); } /*** OnCheckBox ********************************************************* Update a camera control. Inputs: e = Choice event. Coding history: WJB 4/ 9/11 Revised for separate controls. */ void ControlWnd::OnCheckBox (wxCommandEvent &e) { int iCtrl = e.GetId () / 3; wxCheckBox *pchk = (wxCheckBox *) e.GetEventObject (); bool bEnable = pchk->GetValue (); ImgCtl * pictl = &m_victl[iCtrl]; pictl->Enable (bEnable); if ( pictl->GetType () == 4 ) { wxSlider * psld = (wxSlider *) pchk->GetNextSibling (); wxSpinCtrl *pspin = (wxSpinCtrl *) psld->GetNextSibling (); psld->Enable (bEnable); pspin->Enable (bEnable); } else if ( pictl->GetType () == 6 ) { wxSpinCtrl *pspin = (wxSpinCtrl *) pchk->GetNextSibling (); pspin->Enable (bEnable); } if ( iCtrl == ctrlRedGain ) { m_victl[ctrlBlueGain].m_bEnable = bEnable; ((wxCheckBox *)FindWindow (3 * ctrlBlueGain))->SetValue (bEnable); FindWindow (3 * ctrlBlueGain + 1)->Enable (bEnable); FindWindow (3 * ctrlBlueGain + 2)->Enable (bEnable); } else if ( iCtrl == ctrlBlueGain ) { m_victl[ctrlRedGain].m_bEnable = bEnable; ((wxCheckBox *)FindWindow (3 * ctrlRedGain))->SetValue (bEnable); FindWindow (3 * ctrlRedGain + 1)->Enable (bEnable); FindWindow (3 * ctrlRedGain + 2)->Enable (bEnable); } } /*** OnSlider ********************************************************* Update a camera control. Inputs: e = Choice event. Coding history: WJB 4/ 9/11 Revised for separate controls. WJB 11/ 9/11 Display both slider and spin control. */ void ControlWnd::OnSlider (wxCommandEvent &e) { int iCtrl = e.GetId () / 3; wxSlider * psld = (wxSlider *) e.GetEventObject (); wxSpinCtrl *pspin = (wxSpinCtrl *) psld->GetNextSibling (); ImgCtl * pictl = &m_victl[iCtrl]; int iVal = psld->GetValue (); // printf ("OnSlider: this = %p, m_grabimg = %p, iCtrl = %d, pictl = %p, iVal = %d\n", // this, m_grabimg, iCtrl, pictl, iVal); pspin->SetValue (iVal); pictl->Set (iVal); } /*** OnSpinCtrl ********************************************************* Update a camera control. Inputs: e = Choice event. Coding history: WJB 11/ 9/11 Display both slider and spin control. */ void ControlWnd::OnSpinCtrl (wxSpinEvent &e) { int iCtrl = e.GetId () / 3; wxSpinCtrl *pspin = (wxSpinCtrl *) e.GetEventObject (); ImgCtl * pictl = &m_victl[iCtrl]; int iVal = pspin->GetValue (); // printf ("OnSpinCtrl: this = %p, m_grabimg = %p, iCtrl = %d, pictl = %p, iVal = %d\n", // this, m_grabimg, iCtrl, pictl, iVal); pictl->Set (iVal); if ( pictl->GetType () < 5 ) { wxSlider * psld = (wxSlider *) pspin->GetPrevSibling (); psld->SetValue (iVal); } }
36.983498
104
0.543727
Memotech-Bill
6121bd54330ddad58bd7d2f63de990cc1fca7162
1,830
cpp
C++
src/bind/enums.cpp
jonathf/pyvroom
7f7c755c763ddc416455ea8c5168b53ae1477084
[ "BSD-2-Clause" ]
13
2021-12-28T13:04:45.000Z
2022-01-06T22:05:51.000Z
src/bind/enums.cpp
VROOM-Project/pyvroom
7f7c755c763ddc416455ea8c5168b53ae1477084
[ "BSD-2-Clause" ]
26
2022-01-06T09:36:45.000Z
2022-03-26T11:43:14.000Z
src/bind/enums.cpp
VROOM-Project/pyvroom
7f7c755c763ddc416455ea8c5168b53ae1477084
[ "BSD-2-Clause" ]
4
2022-01-06T14:34:56.000Z
2022-03-29T11:53:48.000Z
#include <pybind11/pybind11.h> #include "structures/typedefs.h" namespace py = pybind11; void init_enums(py::module_ &m) { py::enum_<vroom::ROUTER>(m, "ROUTER") .value("OSRM", vroom::ROUTER::OSRM) .value("LIBOSRM", vroom::ROUTER::LIBOSRM) .value("ORS", vroom::ROUTER::ORS) .value("VALHALLA", vroom::ROUTER::VALHALLA) .export_values(); py::enum_<vroom::JOB_TYPE>(m, "JOB_TYPE") .value("SINGLE", vroom::JOB_TYPE::SINGLE) .value("PICKUP", vroom::JOB_TYPE::PICKUP) .value("DELIVERY", vroom::JOB_TYPE::DELIVERY) .export_values(); py::enum_<vroom::STEP_TYPE>(m, "STEP_TYPE") .value("START", vroom::STEP_TYPE::START) .value("JOB", vroom::STEP_TYPE::JOB) .value("BREAK", vroom::STEP_TYPE::BREAK) .value("END", vroom::STEP_TYPE::END) .export_values(); py::enum_<vroom::HEURISTIC>(m, "HEURISTIC") .value("BASIC", vroom::HEURISTIC::BASIC) .value("DYNAMIC", vroom::HEURISTIC::DYNAMIC) .value("INIT_ROUTES", vroom::HEURISTIC::INIT_ROUTES) .export_values(); py::enum_<vroom::INIT>(m, "INIT") .value("NONE", vroom::INIT::NONE) .value("HIGHER_AMOUNT", vroom::INIT::HIGHER_AMOUNT) .value("NEAREST", vroom::INIT::NEAREST) .value("FURTHEST", vroom::INIT::FURTHEST) .value("EARLIEST_DEADLINE", vroom::INIT::EARLIEST_DEADLINE) .export_values(); py::enum_<vroom::VIOLATION>(m, "VIOLATION") .value("LEAD_TIME", vroom::VIOLATION::LEAD_TIME) .value("DELAY", vroom::VIOLATION::DELAY) .value("LOAD", vroom::VIOLATION::LOAD) .value("MAX_TASKS", vroom::VIOLATION::MAX_TASKS) .value("SKILLS", vroom::VIOLATION::SKILLS) .value("PRECEDENCE", vroom::VIOLATION::PRECEDENCE) .value("MISSING_BREAK", vroom::VIOLATION::MISSING_BREAK) .export_values(); }
34.528302
65
0.636612
jonathf
6129455e861a8422a65a57f3961ec70be44e7e88
1,789
hh
C++
test/centreon-benchmark/connector/inc/com/centreon/benchmark/connector/plugin.hh
centreon-lab/centreon-connectors
3e80bea5c5d999bbce0fcb33b819ddc1cab4d917
[ "Apache-2.0" ]
5
2015-09-04T11:54:52.000Z
2016-12-29T02:36:21.000Z
test/centreon-benchmark/connector/inc/com/centreon/benchmark/connector/plugin.hh
centreon-lab/centreon-connectors
3e80bea5c5d999bbce0fcb33b819ddc1cab4d917
[ "Apache-2.0" ]
19
2015-07-29T10:00:06.000Z
2022-03-09T08:42:10.000Z
test/centreon-benchmark/connector/inc/com/centreon/benchmark/connector/plugin.hh
centreon-lab/centreon-connectors
3e80bea5c5d999bbce0fcb33b819ddc1cab4d917
[ "Apache-2.0" ]
6
2016-02-05T15:12:03.000Z
2021-09-02T19:40:35.000Z
/* ** Copyright 2011-2013 Centreon ** ** 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. ** ** For more information : [email protected] */ #ifndef CCB_CONNECTOR_PLUGIN #define CCB_CONNECTOR_PLUGIN #include <list> #include <map> #include <string> #include <sys/types.h> #include <vector> #include "com/centreon/benchmark/connector/benchmark.hh" #include "com/centreon/benchmark/connector/namespace.hh" CCB_CONNECTOR_BEGIN() /** * @class plugin plugin.hh "com/centreon/benchmark/connector/plugin.hh" * @brief Implementation of benchmark for testing nagios plugin. * * This class is an implementation of benchmark for testing nagios * plugin. */ class plugin : public benchmark { public: plugin(std::string const& commands_file, std::list<std::string> const& args); plugin(plugin const& right); ~plugin() throw(); plugin& operator=(plugin const& right); void run(); private: void _cleanup(); plugin& _internal_copy(plugin const& right); void _recv_data(int fd); void _start_plugin(char** args); void _wait_plugin(bool block); std::list<std::string> _args; std::vector<std::string> _commands; std::string _commands_file; unsigned int _current_running; std::map<pid_t, int> _pid; }; CCB_CONNECTOR_END() #endif // !CCB_CONNECTOR_PLUGIN
27.523077
79
0.735048
centreon-lab
612b25568304beac9252ad293051a6b32b490e51
640
hpp
C++
nall/algorithm.hpp
13824125580/higan
fbdd3f980b65412c362096579869ae76730e4118
[ "Intel", "ISC" ]
38
2018-04-05T05:00:05.000Z
2022-02-06T00:02:02.000Z
nall/algorithm.hpp
ameer-bauer/higan-097
a4a28968173ead8251cfa7cd6b5bf963ee68308f
[ "Info-ZIP" ]
1
2018-04-29T19:45:14.000Z
2018-04-29T19:45:14.000Z
nall/algorithm.hpp
ameer-bauer/higan-097
a4a28968173ead8251cfa7cd6b5bf963ee68308f
[ "Info-ZIP" ]
8
2018-04-16T22:37:46.000Z
2021-02-10T07:37:03.000Z
#pragma once #include <nall/traits.hpp> #undef min #undef max namespace nall { namespace { template<typename T, typename U> auto min(const T& t, const U& u) -> T { return t < u ? t : u; } template<typename T, typename U, typename... P> auto min(const T& t, const U& u, P&&... p) -> T { return t < u ? min(t, forward<P>(p)...) : min(u, forward<P>(p)...); } template<typename T, typename U> auto max(const T& t, const U& u) -> T { return t > u ? t : u; } template<typename T, typename U, typename... P> auto max(const T& t, const U& u, P&&... p) -> T { return t > u ? max(t, forward<P>(p)...) : max(u, forward<P>(p)...); } }}
23.703704
97
0.578125
13824125580
612b89d2508c51039bb46e37ae3fadc8963ded74
10,582
cpp
C++
game/server/tfo/weapon_stg44.cpp
BerntA/tfo-code
afa3ea06a64cbbf7a9370b214ea5e80e69d9d7a1
[ "MIT" ]
13
2016-04-05T23:23:16.000Z
2022-03-20T11:06:04.000Z
game/server/tfo/weapon_stg44.cpp
BerntA/tfo-code
afa3ea06a64cbbf7a9370b214ea5e80e69d9d7a1
[ "MIT" ]
null
null
null
game/server/tfo/weapon_stg44.cpp
BerntA/tfo-code
afa3ea06a64cbbf7a9370b214ea5e80e69d9d7a1
[ "MIT" ]
4
2016-04-05T23:23:19.000Z
2021-05-16T05:09:46.000Z
//========= Copyright Bernt Andreas Eide, All rights reserved. ============// // // Purpose: MP44 / STG44 // //=============================================================================// #include "cbase.h" #include "basehlcombatweapon.h" #include "NPCevent.h" #include "basecombatcharacter.h" #include "AI_BaseNPC.h" #include "player.h" #include "game.h" #include "in_buttons.h" #include "grenade_ar2.h" #include "AI_Memory.h" #include "soundent.h" #include "rumble_shared.h" #include "gamestats.h" #include "te_effect_dispatch.h" #include "particle_parse.h" // memdbgon must be the last include file in a .cpp file!!! #include "tier0/memdbgon.h" class CWeaponSTG44 : public CHLSelectFireMachineGun { DECLARE_DATADESC(); public: DECLARE_CLASS( CWeaponSTG44, CHLSelectFireMachineGun ); CWeaponSTG44(); DECLARE_SERVERCLASS(); void Precache( void ); void AddViewKick( void ); int GetOverloadCapacity() { return 10; } void ItemPostFrame( void ); int GetMinBurst() { return 2; } int GetMaxBurst() { return 5; } virtual void Equip( CBaseCombatCharacter *pOwner ); bool Reload( void ); float GetFireRate( void ) { return 0.100f; } int CapabilitiesGet( void ) { return bits_CAP_WEAPON_RANGE_ATTACK1; } virtual const Vector& GetBulletSpread( void ) { static Vector cone; if (m_bIsIronsighted) cone = VECTOR_CONE_1DEGREES; else cone = VECTOR_CONE_7DEGREES; return cone; } const WeaponProficiencyInfo_t *GetProficiencyValues(); void FireNPCPrimaryAttack( CBaseCombatCharacter *pOperator, Vector &vecShootOrigin, Vector &vecShootDir ); void Operator_ForceNPCFire( CBaseCombatCharacter *pOperator, bool bSecondary ); void Operator_HandleAnimEvent( animevent_t *pEvent, CBaseCombatCharacter *pOperator ); DECLARE_ACTTABLE(); }; IMPLEMENT_SERVERCLASS_ST(CWeaponSTG44, DT_WeaponSTG44) END_SEND_TABLE() LINK_ENTITY_TO_CLASS( weapon_stg44, CWeaponSTG44 ); PRECACHE_WEAPON_REGISTER(weapon_stg44); BEGIN_DATADESC( CWeaponSTG44 ) END_DATADESC() acttable_t CWeaponSTG44::m_acttable[] = { { ACT_RANGE_ATTACK1, ACT_RANGE_ATTACK_SMG1, true }, { ACT_RELOAD, ACT_RELOAD_SMG1, true }, { ACT_IDLE, ACT_IDLE_SMG1, true }, { ACT_IDLE_ANGRY, ACT_IDLE_ANGRY_SMG1, true }, { ACT_WALK, ACT_WALK_RIFLE, true }, { ACT_WALK_AIM, ACT_WALK_AIM_RIFLE, true }, // Readiness activities (not aiming) { ACT_IDLE_RELAXED, ACT_IDLE_SMG1_RELAXED, false },//never aims { ACT_IDLE_STIMULATED, ACT_IDLE_SMG1_STIMULATED, false }, { ACT_IDLE_AGITATED, ACT_IDLE_ANGRY_SMG1, false },//always aims { ACT_WALK_RELAXED, ACT_WALK_RIFLE_RELAXED, false },//never aims { ACT_WALK_STIMULATED, ACT_WALK_RIFLE_STIMULATED, false }, { ACT_WALK_AGITATED, ACT_WALK_AIM_RIFLE, false },//always aims { ACT_RUN_RELAXED, ACT_RUN_RIFLE_RELAXED, false },//never aims { ACT_RUN_STIMULATED, ACT_RUN_RIFLE_STIMULATED, false }, { ACT_RUN_AGITATED, ACT_RUN_AIM_RIFLE, false },//always aims // Readiness activities (aiming) { ACT_IDLE_AIM_RELAXED, ACT_IDLE_SMG1_RELAXED, false },//never aims { ACT_IDLE_AIM_STIMULATED, ACT_IDLE_AIM_RIFLE_STIMULATED, false }, { ACT_IDLE_AIM_AGITATED, ACT_IDLE_ANGRY_SMG1, false },//always aims { ACT_WALK_AIM_RELAXED, ACT_WALK_RIFLE_RELAXED, false },//never aims { ACT_WALK_AIM_STIMULATED, ACT_WALK_AIM_RIFLE_STIMULATED, false }, { ACT_WALK_AIM_AGITATED, ACT_WALK_AIM_RIFLE, false },//always aims { ACT_RUN_AIM_RELAXED, ACT_RUN_RIFLE_RELAXED, false },//never aims { ACT_RUN_AIM_STIMULATED, ACT_RUN_AIM_RIFLE_STIMULATED, false }, { ACT_RUN_AIM_AGITATED, ACT_RUN_AIM_RIFLE, false },//always aims //End readiness activities { ACT_WALK_AIM, ACT_WALK_AIM_RIFLE, true }, { ACT_WALK_CROUCH, ACT_WALK_CROUCH_RIFLE, true }, { ACT_WALK_CROUCH_AIM, ACT_WALK_CROUCH_AIM_RIFLE, true }, { ACT_RUN, ACT_RUN_RIFLE, true }, { ACT_RUN_AIM, ACT_RUN_AIM_RIFLE, true }, { ACT_RUN_CROUCH, ACT_RUN_CROUCH_RIFLE, true }, { ACT_RUN_CROUCH_AIM, ACT_RUN_CROUCH_AIM_RIFLE, true }, { ACT_GESTURE_RANGE_ATTACK1, ACT_GESTURE_RANGE_ATTACK_SMG1, true }, { ACT_RANGE_ATTACK1_LOW, ACT_RANGE_ATTACK_SMG1_LOW, true }, { ACT_COVER_LOW, ACT_COVER_SMG1_LOW, false }, { ACT_RANGE_AIM_LOW, ACT_RANGE_AIM_SMG1_LOW, false }, { ACT_RELOAD_LOW, ACT_RELOAD_SMG1_LOW, false }, { ACT_GESTURE_RELOAD, ACT_GESTURE_RELOAD_SMG1, true }, { ACT_HL2MP_IDLE, ACT_HL2MP_IDLE_SMG1, false }, { ACT_HL2MP_RUN, ACT_HL2MP_RUN_SMG1, false }, { ACT_HL2MP_IDLE_CROUCH, ACT_HL2MP_IDLE_CROUCH_SMG1, false }, { ACT_HL2MP_WALK_CROUCH, ACT_HL2MP_WALK_CROUCH_SMG1, false }, { ACT_HL2MP_GESTURE_RANGE_ATTACK, ACT_HL2MP_GESTURE_RANGE_ATTACK_SMG1, false }, { ACT_HL2MP_GESTURE_RELOAD, ACT_GESTURE_RELOAD_SMG1, false }, { ACT_HL2MP_JUMP, ACT_HL2MP_JUMP_SMG1, false }, { ACT_RANGE_ATTACK1, ACT_RANGE_ATTACK_SMG1, false }, }; IMPLEMENT_ACTTABLE(CWeaponSTG44); //========================================================= CWeaponSTG44::CWeaponSTG44( ) { m_fMinRange1 = 0;// No minimum range. m_fMaxRange1 = 1400; m_bMagazineStyleReloads = true; // Magazine style reloads m_bAltFiresUnderwater = false; } //----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CWeaponSTG44::Precache( void ) { BaseClass::Precache(); } //----------------------------------------------------------------------------- // Purpose: Give this weapon longer range when wielded by an ally NPC. //----------------------------------------------------------------------------- void CWeaponSTG44::Equip( CBaseCombatCharacter *pOwner ) { if( pOwner->Classify() == CLASS_PLAYER_ALLY ) { m_fMaxRange1 = 3000; } else { m_fMaxRange1 = 1400; } BaseClass::Equip( pOwner ); } //----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CWeaponSTG44::FireNPCPrimaryAttack( CBaseCombatCharacter *pOperator, Vector &vecShootOrigin, Vector &vecShootDir ) { // FIXME: use the returned number of bullets to account for >10hz firerate WeaponSoundRealtime( SINGLE_NPC ); CSoundEnt::InsertSound( SOUND_COMBAT|SOUND_CONTEXT_GUNFIRE, pOperator->GetAbsOrigin(), SOUNDENT_VOLUME_MACHINEGUN, 0.2, pOperator, SOUNDENT_CHANNEL_WEAPON, pOperator->GetEnemy() ); pOperator->FireBullets( 1, vecShootOrigin, vecShootDir, VECTOR_CONE_PRECALCULATED, MAX_TRACE_LENGTH, m_iPrimaryAmmoType, 2, entindex(), 0 ); pOperator->DoMuzzleFlash(); m_iClip1 = m_iClip1 - 1; } //----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CWeaponSTG44::Operator_ForceNPCFire( CBaseCombatCharacter *pOperator, bool bSecondary ) { // Ensure we have enough rounds in the clip m_iClip1++; Vector vecShootOrigin, vecShootDir; QAngle angShootDir; GetAttachment( LookupAttachment( "muzzle" ), vecShootOrigin, angShootDir ); AngleVectors( angShootDir, &vecShootDir ); FireNPCPrimaryAttack( pOperator, vecShootOrigin, vecShootDir ); } //----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CWeaponSTG44::Operator_HandleAnimEvent( animevent_t *pEvent, CBaseCombatCharacter *pOperator ) { switch( pEvent->event ) { case EVENT_WEAPON_SMG1: { Vector vecShootOrigin, vecShootDir; QAngle angDiscard; // Support old style attachment point firing if ((pEvent->options == NULL) || (pEvent->options[0] == '\0') || (!pOperator->GetAttachment(pEvent->options, vecShootOrigin, angDiscard))) { vecShootOrigin = pOperator->Weapon_ShootPosition(); } CAI_BaseNPC *npc = pOperator->MyNPCPointer(); ASSERT( npc != NULL ); vecShootDir = npc->GetActualShootTrajectory( vecShootOrigin ); FireNPCPrimaryAttack( pOperator, vecShootOrigin, vecShootDir ); } break; default: BaseClass::Operator_HandleAnimEvent( pEvent, pOperator ); break; } } //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- bool CWeaponSTG44::Reload( void ) { bool fRet; float fCacheTime = m_flNextSecondaryAttack; fRet = DefaultReload( GetMaxClip1(), GetMaxClip2(), ACT_VM_RELOAD ); if ( fRet ) { // Undo whatever the reload process has done to our secondary // attack timer. We allow you to interrupt reloading to fire // a grenade. m_flNextSecondaryAttack = GetOwner()->m_flNextAttack = fCacheTime; WeaponSound( RELOAD ); CBasePlayer *pOwner = ToBasePlayer( GetOwner() ); CEffectData data; data.m_vOrigin = pOwner->WorldSpaceCenter() + RandomVector( 0, 0 ); data.m_vAngles = QAngle( 90, random->RandomInt( 0, 360 ), 0 ); data.m_nEntIndex = entindex(); DispatchEffect( "ClipEject", data ); } return fRet; } //----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CWeaponSTG44::AddViewKick( void ) { #define EASY_DAMPEN 0.5f #define MAX_VERTICAL_KICK 1.0f //Degrees #define SLIDE_LIMIT 2.0f //Seconds //Get the view kick CBasePlayer *pPlayer = ToBasePlayer( GetOwner() ); if ( pPlayer == NULL ) return; DoMachineGunKick( pPlayer, EASY_DAMPEN, MAX_VERTICAL_KICK, m_fFireDuration, SLIDE_LIMIT ); } void CWeaponSTG44::ItemPostFrame( void ) { BaseClass::ItemPostFrame(); CBasePlayer *pPlayer = ToBasePlayer( GetOwner() ); if ( pPlayer == NULL ) return; // Ammo Fix int CurrAmmo = pPlayer->GetAmmoCount(m_iPrimaryAmmoType); if ( CurrAmmo <= 29 && CurrAmmo >= 1 ) { pPlayer->RemoveAmmo( CurrAmmo, m_iPrimaryAmmoType ); } } //---------------------------------------------------------------------------- const WeaponProficiencyInfo_t *CWeaponSTG44::GetProficiencyValues() { static WeaponProficiencyInfo_t proficiencyTable[] = { { 7.0, 0.75 }, { 5.00, 0.75 }, { 10.0/3.0, 0.75 }, { 5.0/3.0, 0.75 }, { 1.00, 1.0 }, }; COMPILE_TIME_ASSERT( ARRAYSIZE(proficiencyTable) == WEAPON_PROFICIENCY_PERFECT + 1); return proficiencyTable; }
32.965732
181
0.626347
BerntA
612b9a750ba7eaff8b20a1e339279183d01df9ff
4,488
cpp
C++
tf2_src/utils/vgui_panel_zoo/QueryBoxDemo.cpp
IamIndeedGamingAsHardAsICan03489/TeamFortress2
1b81dded673d49adebf4d0958e52236ecc28a956
[ "MIT" ]
4
2021-10-03T05:16:55.000Z
2021-12-28T16:49:27.000Z
tf2_src/utils/vgui_panel_zoo/QueryBoxDemo.cpp
Counter2828/TeamFortress2
1b81dded673d49adebf4d0958e52236ecc28a956
[ "MIT" ]
null
null
null
tf2_src/utils/vgui_panel_zoo/QueryBoxDemo.cpp
Counter2828/TeamFortress2
1b81dded673d49adebf4d0958e52236ecc28a956
[ "MIT" ]
3
2022-02-02T18:09:58.000Z
2022-03-06T18:54:39.000Z
//========= Copyright Valve Corporation, All rights reserved. ============// // // Purpose: // // $NoKeywords: $ //=============================================================================// #include "DemoPage.h" #include <VGUI/IVGui.h> #include <vgui_controls/Controls.h> #include <Keyvalues.h> #include <vgui_controls/Button.h> #include <vgui_controls/QueryBox.h> using namespace vgui; // Query boxes are windows that pop up in response to events. // They are useful for asking questions (like... "Are you sure you want to do this?"). // In this example we will trigger the opening of a query box when // a button is pressed. // Query boxes are Message boxes that have an OK and a Cancel button, // each button may be linked to an additional command in order to trigger an // appropriate response. class QueryBoxDemo: public DemoPage { public: QueryBoxDemo(Panel *parent, const char *name); ~QueryBoxDemo(); void OnButtonClicked(); void ShowQueryBox(); void OnOK(); void OnCancel(); private: Button *m_pButton; DECLARE_PANELMAP(); }; //----------------------------------------------------------------------------- // Purpose: Constructor //----------------------------------------------------------------------------- QueryBoxDemo::QueryBoxDemo(Panel *parent, const char *name) : DemoPage(parent, name) { // Create a button to trigger the message box. m_pButton = new Button(this, "AButton", "Click Me For A Question"); // Size the button to its text. m_pButton->SizeToContents(); // Set its position. m_pButton->SetPos(100, 100); // Install a command that will be executed when the button is pressed // Here we use a KeyValues command, this is mapped using the Message map // below to a function. m_pButton->SetCommand(new KeyValues ("ButtonClicked")); } //----------------------------------------------------------------------------- // Purpose: Destructor //----------------------------------------------------------------------------- QueryBoxDemo::~QueryBoxDemo() { } //----------------------------------------------------------------------------- // Purpose: Respond to a message based action signal // Popup the query box. //----------------------------------------------------------------------------- void QueryBoxDemo::OnButtonClicked() { ivgui()->DPrintf("Button was clicked.\n"); // When the button is clicked we open the message box in response. ShowQueryBox(); } //----------------------------------------------------------------------------- // Purpose: Display a query box //----------------------------------------------------------------------------- void QueryBoxDemo::ShowQueryBox() { // create a new message box. // The first arg is the name of the window and will be across the top. // The second arg is the text that will appear in the message box. QueryBox *pQuery = new QueryBox ("Message Window", "Will you pick OK or Cancel?"); // Make ourselves the target of the button messages pQuery->AddActionSignalTarget(this); // Install the message to be sent when the ok button is clicked. pQuery->SetOKCommand(new KeyValues("OKClicked")); // Install the message to be sent when the cancel button is clicked. pQuery->SetCancelCommand(new KeyValues("Cancel")); // This command will pop up the message box and hold it there until we click // a button. When a button is clicked the query box object is destroyed. pQuery->DoModal(); } //----------------------------------------------------------------------------- // Purpose: Respond to a message based action signal // Respond to the OK button in the query box. //----------------------------------------------------------------------------- void QueryBoxDemo::OnOK() { ivgui()->DPrintf("Query received the OK.\n"); } //----------------------------------------------------------------------------- // Purpose: Respond to a message based action signal // Respond to the Cancel button in the query box //----------------------------------------------------------------------------- void QueryBoxDemo::OnCancel() { ivgui()->DPrintf("Query was canceled.\n"); } MessageMapItem_t QueryBoxDemo::m_MessageMap[] = { MAP_MESSAGE( QueryBoxDemo, "ButtonClicked", OnButtonClicked ), MAP_MESSAGE( QueryBoxDemo, "OKClicked", OnOK ), MAP_MESSAGE( QueryBoxDemo, "Cancel", OnCancel ), }; IMPLEMENT_PANELMAP(QueryBoxDemo, DemoPage); Panel* QueryBoxDemo_Create(Panel *parent) { return new QueryBoxDemo(parent, "QueryBoxDemo"); }
30.324324
86
0.552362
IamIndeedGamingAsHardAsICan03489
612be61ed565e42e7d013d3e11699fdc54e7f1f8
4,004
hpp
C++
Library/Deps/MessagePack/Include/msgpack/preprocessor/iteration/iterate.hpp
rneogns/simpleio
20830a2b9b22c31eab23508acd25b275b53103c9
[ "MIT" ]
null
null
null
Library/Deps/MessagePack/Include/msgpack/preprocessor/iteration/iterate.hpp
rneogns/simpleio
20830a2b9b22c31eab23508acd25b275b53103c9
[ "MIT" ]
null
null
null
Library/Deps/MessagePack/Include/msgpack/preprocessor/iteration/iterate.hpp
rneogns/simpleio
20830a2b9b22c31eab23508acd25b275b53103c9
[ "MIT" ]
null
null
null
# /* ************************************************************************** # * * # * (C) Copyright Paul Mensonides 2002. # * Distributed under the Boost Software License, Version 1.0. (See # * accompanying file LICENSE_1_0.txt or copy at # * http://www.boost.org/LICENSE_1_0.txt) # * * # ************************************************************************** */ # # /* See http://www.boost.org for most recent version. */ # # ifndef MSGPACK_PREPROCESSOR_ITERATION_ITERATE_HPP # define MSGPACK_PREPROCESSOR_ITERATION_ITERATE_HPP # # include <msgpack/preprocessor/arithmetic/dec.hpp> # include <msgpack/preprocessor/arithmetic/inc.hpp> # include <msgpack/preprocessor/array/elem.hpp> # include <msgpack/preprocessor/array/size.hpp> # include <msgpack/preprocessor/cat.hpp> # include <msgpack/preprocessor/slot/slot.hpp> # include <msgpack/preprocessor/tuple/elem.hpp> # # /* MSGPACK_PP_ITERATION_DEPTH */ # # define MSGPACK_PP_ITERATION_DEPTH() 0 # # /* MSGPACK_PP_ITERATION */ # # define MSGPACK_PP_ITERATION() MSGPACK_PP_CAT(MSGPACK_PP_ITERATION_, MSGPACK_PP_ITERATION_DEPTH()) # # /* MSGPACK_PP_ITERATION_START && MSGPACK_PP_ITERATION_FINISH */ # # define MSGPACK_PP_ITERATION_START() MSGPACK_PP_CAT(MSGPACK_PP_ITERATION_START_, MSGPACK_PP_ITERATION_DEPTH()) # define MSGPACK_PP_ITERATION_FINISH() MSGPACK_PP_CAT(MSGPACK_PP_ITERATION_FINISH_, MSGPACK_PP_ITERATION_DEPTH()) # # /* MSGPACK_PP_ITERATION_FLAGS */ # # define MSGPACK_PP_ITERATION_FLAGS() (MSGPACK_PP_CAT(MSGPACK_PP_ITERATION_FLAGS_, MSGPACK_PP_ITERATION_DEPTH())()) # # /* MSGPACK_PP_FRAME_ITERATION */ # # define MSGPACK_PP_FRAME_ITERATION(i) MSGPACK_PP_CAT(MSGPACK_PP_ITERATION_, i) # # /* MSGPACK_PP_FRAME_START && MSGPACK_PP_FRAME_FINISH */ # # define MSGPACK_PP_FRAME_START(i) MSGPACK_PP_CAT(MSGPACK_PP_ITERATION_START_, i) # define MSGPACK_PP_FRAME_FINISH(i) MSGPACK_PP_CAT(MSGPACK_PP_ITERATION_FINISH_, i) # # /* MSGPACK_PP_FRAME_FLAGS */ # # define MSGPACK_PP_FRAME_FLAGS(i) (MSGPACK_PP_CAT(MSGPACK_PP_ITERATION_FLAGS_, i)()) # # /* MSGPACK_PP_RELATIVE_ITERATION */ # # define MSGPACK_PP_RELATIVE_ITERATION(i) MSGPACK_PP_CAT(MSGPACK_PP_RELATIVE_, i)(MSGPACK_PP_ITERATION_) # # define MSGPACK_PP_RELATIVE_0(m) MSGPACK_PP_CAT(m, MSGPACK_PP_ITERATION_DEPTH()) # define MSGPACK_PP_RELATIVE_1(m) MSGPACK_PP_CAT(m, MSGPACK_PP_DEC(MSGPACK_PP_ITERATION_DEPTH())) # define MSGPACK_PP_RELATIVE_2(m) MSGPACK_PP_CAT(m, MSGPACK_PP_DEC(MSGPACK_PP_DEC(MSGPACK_PP_ITERATION_DEPTH()))) # define MSGPACK_PP_RELATIVE_3(m) MSGPACK_PP_CAT(m, MSGPACK_PP_DEC(MSGPACK_PP_DEC(MSGPACK_PP_DEC(MSGPACK_PP_ITERATION_DEPTH())))) # define MSGPACK_PP_RELATIVE_4(m) MSGPACK_PP_CAT(m, MSGPACK_PP_DEC(MSGPACK_PP_DEC(MSGPACK_PP_DEC(MSGPACK_PP_DEC(MSGPACK_PP_ITERATION_DEPTH()))))) # # /* MSGPACK_PP_RELATIVE_START && MSGPACK_PP_RELATIVE_FINISH */ # # define MSGPACK_PP_RELATIVE_START(i) MSGPACK_PP_CAT(MSGPACK_PP_RELATIVE_, i)(MSGPACK_PP_ITERATION_START_) # define MSGPACK_PP_RELATIVE_FINISH(i) MSGPACK_PP_CAT(MSGPACK_PP_RELATIVE_, i)(MSGPACK_PP_ITERATION_FINISH_) # # /* MSGPACK_PP_RELATIVE_FLAGS */ # # define MSGPACK_PP_RELATIVE_FLAGS(i) (MSGPACK_PP_CAT(MSGPACK_PP_RELATIVE_, i)(MSGPACK_PP_ITERATION_FLAGS_)()) # # /* MSGPACK_PP_ITERATE */ # # define MSGPACK_PP_ITERATE() MSGPACK_PP_CAT(MSGPACK_PP_ITERATE_, MSGPACK_PP_INC(MSGPACK_PP_ITERATION_DEPTH())) # # define MSGPACK_PP_ITERATE_1 <msgpack/preprocessor/iteration/detail/iter/forward1.hpp> # define MSGPACK_PP_ITERATE_2 <msgpack/preprocessor/iteration/detail/iter/forward2.hpp> # define MSGPACK_PP_ITERATE_3 <msgpack/preprocessor/iteration/detail/iter/forward3.hpp> # define MSGPACK_PP_ITERATE_4 <msgpack/preprocessor/iteration/detail/iter/forward4.hpp> # define MSGPACK_PP_ITERATE_5 <msgpack/preprocessor/iteration/detail/iter/forward5.hpp> # # endif
48.240964
146
0.731518
rneogns
612da374e6268428770467a74984697b73f626f1
7,226
cpp
C++
export/debug/macos/obj/src/__ASSET__flixel_flixel_ui_img_finger_small_png.cpp
EnvyBun/KB-FNF-MOD
f7541661229c587bf99f0508cc3eba7043f8c177
[ "Apache-2.0" ]
null
null
null
export/debug/macos/obj/src/__ASSET__flixel_flixel_ui_img_finger_small_png.cpp
EnvyBun/KB-FNF-MOD
f7541661229c587bf99f0508cc3eba7043f8c177
[ "Apache-2.0" ]
null
null
null
export/debug/macos/obj/src/__ASSET__flixel_flixel_ui_img_finger_small_png.cpp
EnvyBun/KB-FNF-MOD
f7541661229c587bf99f0508cc3eba7043f8c177
[ "Apache-2.0" ]
null
null
null
// Generated by Haxe 4.1.5 #include <hxcpp.h> #ifndef INCLUDED___ASSET__flixel_flixel_ui_img_finger_small_png #include <__ASSET__flixel_flixel_ui_img_finger_small_png.h> #endif #ifndef INCLUDED_haxe_Resource #include <haxe/Resource.h> #endif #ifndef INCLUDED_haxe_io_Bytes #include <haxe/io/Bytes.h> #endif #ifndef INCLUDED_lime_graphics_Image #include <lime/graphics/Image.h> #endif #ifndef INCLUDED_lime_graphics_ImageBuffer #include <lime/graphics/ImageBuffer.h> #endif #ifndef INCLUDED_lime_graphics_ImageType #include <lime/graphics/ImageType.h> #endif HX_DEFINE_STACK_FRAME(_hx_pos_a8b28c08cd7936ec_346_new,"__ASSET__flixel_flixel_ui_img_finger_small_png","new",0x4e817064,"__ASSET__flixel_flixel_ui_img_finger_small_png.new","lime/_internal/macros/AssetsMacro.hx",346,0xc651f030) HX_LOCAL_STACK_FRAME(_hx_pos_db845bbd0c26ed3d_600_boot,"__ASSET__flixel_flixel_ui_img_finger_small_png","boot",0x5ad9e7ae,"__ASSET__flixel_flixel_ui_img_finger_small_png.boot","ManifestResources.hx",600,0xf77aa668) void __ASSET__flixel_flixel_ui_img_finger_small_png_obj::__construct( ::lime::graphics::ImageBuffer buffer, ::Dynamic offsetX, ::Dynamic offsetY, ::Dynamic width, ::Dynamic height, ::Dynamic color, ::lime::graphics::ImageType type){ HX_STACKFRAME(&_hx_pos_a8b28c08cd7936ec_346_new) HXLINE( 375) super::__construct(null(),null(),null(),null(),null(),null(),null()); HXLINE( 377) this->_hx___fromBytes(::haxe::Resource_obj::getBytes(::__ASSET__flixel_flixel_ui_img_finger_small_png_obj::resourceName),null()); } Dynamic __ASSET__flixel_flixel_ui_img_finger_small_png_obj::__CreateEmpty() { return new __ASSET__flixel_flixel_ui_img_finger_small_png_obj; } void *__ASSET__flixel_flixel_ui_img_finger_small_png_obj::_hx_vtable = 0; Dynamic __ASSET__flixel_flixel_ui_img_finger_small_png_obj::__Create(::hx::DynamicArray inArgs) { ::hx::ObjectPtr< __ASSET__flixel_flixel_ui_img_finger_small_png_obj > _hx_result = new __ASSET__flixel_flixel_ui_img_finger_small_png_obj(); _hx_result->__construct(inArgs[0],inArgs[1],inArgs[2],inArgs[3],inArgs[4],inArgs[5],inArgs[6]); return _hx_result; } bool __ASSET__flixel_flixel_ui_img_finger_small_png_obj::_hx_isInstanceOf(int inClassId) { if (inClassId<=(int)0x33f052f7) { return inClassId==(int)0x00000001 || inClassId==(int)0x33f052f7; } else { return inClassId==(int)0x57173132; } } ::String __ASSET__flixel_flixel_ui_img_finger_small_png_obj::resourceName; ::hx::ObjectPtr< __ASSET__flixel_flixel_ui_img_finger_small_png_obj > __ASSET__flixel_flixel_ui_img_finger_small_png_obj::__new( ::lime::graphics::ImageBuffer buffer, ::Dynamic offsetX, ::Dynamic offsetY, ::Dynamic width, ::Dynamic height, ::Dynamic color, ::lime::graphics::ImageType type) { ::hx::ObjectPtr< __ASSET__flixel_flixel_ui_img_finger_small_png_obj > __this = new __ASSET__flixel_flixel_ui_img_finger_small_png_obj(); __this->__construct(buffer,offsetX,offsetY,width,height,color,type); return __this; } ::hx::ObjectPtr< __ASSET__flixel_flixel_ui_img_finger_small_png_obj > __ASSET__flixel_flixel_ui_img_finger_small_png_obj::__alloc(::hx::Ctx *_hx_ctx, ::lime::graphics::ImageBuffer buffer, ::Dynamic offsetX, ::Dynamic offsetY, ::Dynamic width, ::Dynamic height, ::Dynamic color, ::lime::graphics::ImageType type) { __ASSET__flixel_flixel_ui_img_finger_small_png_obj *__this = (__ASSET__flixel_flixel_ui_img_finger_small_png_obj*)(::hx::Ctx::alloc(_hx_ctx, sizeof(__ASSET__flixel_flixel_ui_img_finger_small_png_obj), true, "__ASSET__flixel_flixel_ui_img_finger_small_png")); *(void **)__this = __ASSET__flixel_flixel_ui_img_finger_small_png_obj::_hx_vtable; __this->__construct(buffer,offsetX,offsetY,width,height,color,type); return __this; } __ASSET__flixel_flixel_ui_img_finger_small_png_obj::__ASSET__flixel_flixel_ui_img_finger_small_png_obj() { } bool __ASSET__flixel_flixel_ui_img_finger_small_png_obj::__GetStatic(const ::String &inName, Dynamic &outValue, ::hx::PropertyAccess inCallProp) { switch(inName.length) { case 12: if (HX_FIELD_EQ(inName,"resourceName") ) { outValue = ( resourceName ); return true; } } return false; } bool __ASSET__flixel_flixel_ui_img_finger_small_png_obj::__SetStatic(const ::String &inName,Dynamic &ioValue,::hx::PropertyAccess inCallProp) { switch(inName.length) { case 12: if (HX_FIELD_EQ(inName,"resourceName") ) { resourceName=ioValue.Cast< ::String >(); return true; } } return false; } #ifdef HXCPP_SCRIPTABLE static ::hx::StorageInfo *__ASSET__flixel_flixel_ui_img_finger_small_png_obj_sMemberStorageInfo = 0; static ::hx::StaticInfo __ASSET__flixel_flixel_ui_img_finger_small_png_obj_sStaticStorageInfo[] = { {::hx::fsString,(void *) &__ASSET__flixel_flixel_ui_img_finger_small_png_obj::resourceName,HX_("resourceName",39,7a,62,90)}, { ::hx::fsUnknown, 0, null()} }; #endif static void __ASSET__flixel_flixel_ui_img_finger_small_png_obj_sMarkStatics(HX_MARK_PARAMS) { HX_MARK_MEMBER_NAME(__ASSET__flixel_flixel_ui_img_finger_small_png_obj::resourceName,"resourceName"); }; #ifdef HXCPP_VISIT_ALLOCS static void __ASSET__flixel_flixel_ui_img_finger_small_png_obj_sVisitStatics(HX_VISIT_PARAMS) { HX_VISIT_MEMBER_NAME(__ASSET__flixel_flixel_ui_img_finger_small_png_obj::resourceName,"resourceName"); }; #endif ::hx::Class __ASSET__flixel_flixel_ui_img_finger_small_png_obj::__mClass; static ::String __ASSET__flixel_flixel_ui_img_finger_small_png_obj_sStaticFields[] = { HX_("resourceName",39,7a,62,90), ::String(null()) }; void __ASSET__flixel_flixel_ui_img_finger_small_png_obj::__register() { __ASSET__flixel_flixel_ui_img_finger_small_png_obj _hx_dummy; __ASSET__flixel_flixel_ui_img_finger_small_png_obj::_hx_vtable = *(void **)&_hx_dummy; ::hx::Static(__mClass) = new ::hx::Class_obj(); __mClass->mName = HX_("__ASSET__flixel_flixel_ui_img_finger_small_png",72,ae,28,1f); __mClass->mSuper = &super::__SGetClass(); __mClass->mConstructEmpty = &__CreateEmpty; __mClass->mConstructArgs = &__Create; __mClass->mGetStaticField = &__ASSET__flixel_flixel_ui_img_finger_small_png_obj::__GetStatic; __mClass->mSetStaticField = &__ASSET__flixel_flixel_ui_img_finger_small_png_obj::__SetStatic; __mClass->mMarkFunc = __ASSET__flixel_flixel_ui_img_finger_small_png_obj_sMarkStatics; __mClass->mStatics = ::hx::Class_obj::dupFunctions(__ASSET__flixel_flixel_ui_img_finger_small_png_obj_sStaticFields); __mClass->mMembers = ::hx::Class_obj::dupFunctions(0 /* sMemberFields */); __mClass->mCanCast = ::hx::TCanCast< __ASSET__flixel_flixel_ui_img_finger_small_png_obj >; #ifdef HXCPP_VISIT_ALLOCS __mClass->mVisitFunc = __ASSET__flixel_flixel_ui_img_finger_small_png_obj_sVisitStatics; #endif #ifdef HXCPP_SCRIPTABLE __mClass->mMemberStorageInfo = __ASSET__flixel_flixel_ui_img_finger_small_png_obj_sMemberStorageInfo; #endif #ifdef HXCPP_SCRIPTABLE __mClass->mStaticStorageInfo = __ASSET__flixel_flixel_ui_img_finger_small_png_obj_sStaticStorageInfo; #endif ::hx::_hx_RegisterClass(__mClass->mName, __mClass); } void __ASSET__flixel_flixel_ui_img_finger_small_png_obj::__boot() { { HX_STACKFRAME(&_hx_pos_db845bbd0c26ed3d_600_boot) HXDLIN( 600) resourceName = HX_("__ASSET__:image___ASSET__flixel_flixel_ui_img_finger_small_png",80,fb,be,f7); } }
48.173333
313
0.822862
EnvyBun
9ecea26f4cd94cceb3df7ad768c739f9a2fb80fe
1,151
hpp
C++
src/sip-0x/parser/tokens/TokenSIPVersion.hpp
zanfire/sip-0x
de38b3ff782d2a63b69d7f785e2bd9ce7674abd5
[ "Apache-2.0" ]
1
2021-06-03T15:56:32.000Z
2021-06-03T15:56:32.000Z
src/sip-0x/parser/tokens/TokenSIPVersion.hpp
zanfire/sip-0x
de38b3ff782d2a63b69d7f785e2bd9ce7674abd5
[ "Apache-2.0" ]
1
2015-08-05T05:51:49.000Z
2015-08-05T05:51:49.000Z
src/sip-0x/parser/tokens/TokenSIPVersion.hpp
zanfire/sip-0x
de38b3ff782d2a63b69d7f785e2bd9ce7674abd5
[ "Apache-2.0" ]
null
null
null
#if !defined(SIP0X_PARSER_TOKENSIPVERSION_HPP__) #define SIP0X_PARSER_TOKENSIPVERSION_HPP__ #include "parser/tokens/TokenAbstract.hpp" #include "parser/tokens/Operators.hpp" #include "parser/tokens/Token.hpp" #include "parser/tokens/TokenRegex.hpp" #include "parser/factory/FactoryContextSIPVersion.hpp" namespace sip0x { namespace parser { // SIP-Version = "SIP" "/" 1*DIGIT "." 1*DIGIT class TokenSIPVersion : public TokenAbstract { protected: Sequence<Token, TokenDigits, Token, TokenDigits> _sequence; public: TokenSIPVersion(void) : TokenAbstract("SIPVersion"), _sequence(Token("SIP/"), TokenDigits(), Token("."), TokenDigits()) { _sequence.disable_factory(true); } virtual ~TokenSIPVersion(void) { } protected: virtual ParserResult handle_read(sip0x::utils::InputTokenStream& iss, FactoryContext* ctx) const override { return _sequence.read(iss, ctx); } virtual FactoryContext* create_factory(void) const override { return new FactoryContextSIPVersion(); } }; } } #endif // SIP0X_PARSER_TOKENSIPVERSION_HPP__
26.767442
113
0.694179
zanfire
9ecf6445c565af4b25c30b86595de8d8d9ebadfe
6,194
cpp
C++
src/demos/irrlicht/demo_IRR_ballSMC.cpp
Ruochun/chrono
7b0f09242ef540ae56cfc8add3a5dc7985c654d2
[ "BSD-3-Clause" ]
null
null
null
src/demos/irrlicht/demo_IRR_ballSMC.cpp
Ruochun/chrono
7b0f09242ef540ae56cfc8add3a5dc7985c654d2
[ "BSD-3-Clause" ]
null
null
null
src/demos/irrlicht/demo_IRR_ballSMC.cpp
Ruochun/chrono
7b0f09242ef540ae56cfc8add3a5dc7985c654d2
[ "BSD-3-Clause" ]
null
null
null
// ============================================================================= // PROJECT CHRONO - http://projectchrono.org // // Copyright (c) 2014 projectchrono.org // All rights reserved. // // Use of this source code is governed by a BSD-style license that can be found // in the LICENSE file at the top level of the distribution and at // http://projectchrono.org/license-chrono.txt. // // ============================================================================= // Authors: Radu Serban // ============================================================================= // // Demo code about collisions and contacts using the penalty method (SMC) // // ============================================================================= #include "chrono/physics/ChSystemSMC.h" #include "chrono/physics/ChContactContainerSMC.h" #include "chrono_irrlicht/ChIrrApp.h" #include <irrlicht.h> // Use the namespaces of Chrono using namespace chrono; using namespace chrono::irrlicht; // Use the main namespaces of Irrlicht using namespace irr; using namespace irr::core; using namespace irr::scene; using namespace irr::video; using namespace irr::io; using namespace irr::gui; void AddWall(std::shared_ptr<ChBody> body, const ChVector<>& dim, const ChVector<>& loc, std::shared_ptr<ChMaterialSurface> mat) { body->GetCollisionModel()->AddBox(mat, dim.x(), dim.y(), dim.z(), loc); auto box = chrono_types::make_shared<ChBoxShape>(); box->GetBoxGeometry().Size = dim; box->GetBoxGeometry().Pos = loc; box->SetColor(ChColor(1, 0, 0)); box->SetFading(0.6f); body->AddAsset(box); } int main(int argc, char* argv[]) { GetLog() << "Copyright (c) 2017 projectchrono.org\nChrono version: " << CHRONO_VERSION << "\n\n"; // Simulation parameters double gravity = -9.81; double time_step = 0.00001; double out_step = 2000 * time_step; // Parameters for the falling ball int ballId = 100; double radius = 1; double mass = 1000; ChVector<> pos(0, 2, 0); ChQuaternion<> rot(1, 0, 0, 0); ChVector<> init_vel(0, 0, 0); // Parameters for the containing bin int binId = 200; double width = 2; double length = 2; double height = 1; double thickness = 0.1; // Create the system ChSystemSMC msystem; // The following two lines are optional, since they are the default options. They are added for future reference, // i.e. when needed to change those models. msystem.SetContactForceModel(ChSystemSMC::ContactForceModel::Hertz); msystem.SetAdhesionForceModel(ChSystemSMC::AdhesionForceModel::Constant); msystem.Set_G_acc(ChVector<>(0, gravity, 0)); // Change the default collision effective radius of curvature collision::ChCollisionInfo::SetDefaultEffectiveCurvatureRadius(1); // Create the Irrlicht visualization ChIrrApp application(&msystem, L"SMC demo", core::dimension2d<u32>(800, 600)); // Easy shortcuts to add camera, lights, logo and sky in Irrlicht scene application.AddTypicalLogo(); application.AddTypicalSky(); application.AddTypicalLights(); application.AddTypicalCamera(core::vector3df(0, 3, -6)); // This means that contactforces will be shown in Irrlicht application application.SetSymbolscale(1e-4); application.SetContactsDrawMode(IrrContactsDrawMode::CONTACT_FORCES); // Create a material (will be used by both objects) auto material = chrono_types::make_shared<ChMaterialSurfaceSMC>(); material->SetRestitution(0.1f); material->SetFriction(0.4f); material->SetAdhesion(0); // Magnitude of the adhesion in Constant adhesion model // Create the falling ball auto ball = chrono_types::make_shared<ChBody>(); ball->SetIdentifier(ballId); ball->SetMass(mass); ball->SetPos(pos); ball->SetRot(rot); ball->SetPos_dt(init_vel); // ball->SetWvel_par(ChVector<>(0,0,3)); ball->SetBodyFixed(false); ball->SetCollide(true); ball->GetCollisionModel()->ClearModel(); ball->GetCollisionModel()->AddSphere(material, radius); ball->GetCollisionModel()->BuildModel(); ball->SetInertiaXX(0.4 * mass * radius * radius * ChVector<>(1, 1, 1)); auto sphere = chrono_types::make_shared<ChSphereShape>(); sphere->GetSphereGeometry().rad = radius; ball->AddAsset(sphere); auto mtexture = chrono_types::make_shared<ChTexture>(); mtexture->SetTextureFilename(GetChronoDataFile("textures/bluewhite.png")); ball->AddAsset(mtexture); msystem.AddBody(ball); // Create container auto bin = chrono_types::make_shared<ChBody>(); bin->SetIdentifier(binId); bin->SetMass(1); bin->SetPos(ChVector<>(0, 0, 0)); bin->SetRot(ChQuaternion<>(1, 0, 0, 0)); bin->SetCollide(true); bin->SetBodyFixed(true); bin->GetCollisionModel()->ClearModel(); AddWall(bin, ChVector<>(width, thickness, length), ChVector<>(0, 0, 0), material); ////AddWall(bin, ChVector<>(thickness, height, length), ChVector<>(-width + thickness, height, 0), material); ////AddWall(bin, ChVector<>(thickness, height, length), ChVector<>(width - thickness, height, 0), material); ////AddWall(bin, ChVector<>(width, height, thickness), ChVector<>(0, height, -length + thickness), material); ////AddWall(bin, ChVector<>(width, height, thickness), ChVector<>(0, height, length - thickness), material); bin->GetCollisionModel()->BuildModel(); msystem.AddBody(bin); // Complete asset construction application.AssetBindAll(); application.AssetUpdateAll(); // The soft-real-time cycle double time = 0.0; double out_time = 0.0; while (application.GetDevice()->run()) { application.BeginScene(); application.DrawAll(); tools::drawGrid(application.GetVideoDriver(), 0.2, 0.2, 20, 20, ChCoordsys<>(ChVector<>(0, 0, 0), Q_from_AngX(CH_C_PI_2)), video::SColor(255, 80, 100, 100), true); while (time < out_time) { msystem.DoStepDynamics(time_step); time += time_step; } out_time += out_step; application.EndScene(); } return 0; }
34.220994
130
0.638683
Ruochun
9ed36b848f34902d45895d054f7e3672e71cc7a6
636
cpp
C++
cses/Two_Sets.cpp
st3v3nmw/competitive-programming
581d36c1c128e0e3ee3a0b52628e932ab43821d4
[ "MIT" ]
null
null
null
cses/Two_Sets.cpp
st3v3nmw/competitive-programming
581d36c1c128e0e3ee3a0b52628e932ab43821d4
[ "MIT" ]
null
null
null
cses/Two_Sets.cpp
st3v3nmw/competitive-programming
581d36c1c128e0e3ee3a0b52628e932ab43821d4
[ "MIT" ]
null
null
null
#include <bits/stdc++.h> using namespace std; #define ll long long int main() { ll n; cin >> n; vector<ll> v1, v2; ll sum = n * (n + 1) / 2; if (sum % 2 != 0) { cout << "NO" << endl; return 0; } sum /= 2; for (int i = n; i > 0; i--) { if (sum - i >= 0) { v1.push_back(i); sum -= i; } else v2.push_back(i); } cout << "YES\n" << endl; cout << v1.size() << endl; for(int e : v1) cout << e << " "; cout << endl; cout << v2.size() << endl; for(int e : v2) cout << e << " "; cout << endl; }
18.705882
33
0.386792
st3v3nmw
9ed42813791eb28e968c11a32c0668ffdf14571b
15,456
cpp
C++
Source/AliveLibAE/ParticleBurst.cpp
THEONLYDarkShadow/alive_reversing
680d87088023f2d5f2a40c42d6543809281374fb
[ "MIT" ]
1
2021-04-11T23:44:43.000Z
2021-04-11T23:44:43.000Z
Source/AliveLibAE/ParticleBurst.cpp
THEONLYDarkShadow/alive_reversing
680d87088023f2d5f2a40c42d6543809281374fb
[ "MIT" ]
null
null
null
Source/AliveLibAE/ParticleBurst.cpp
THEONLYDarkShadow/alive_reversing
680d87088023f2d5f2a40c42d6543809281374fb
[ "MIT" ]
null
null
null
#include "stdafx.h" #include "ParticleBurst.hpp" #include "Math.hpp" #include "Game.hpp" #include "Function.hpp" #include "Events.hpp" #include "Sfx.hpp" #include "ScreenManager.hpp" #include "Map.hpp" #include "stdlib.hpp" struct ParticleBurst_Item { FP field_0_x; FP field_4_y; FP field_8_z; FP field_C_x_speed; FP field_10_y_speed; FP field_14_z_speed; AnimationUnknown field_18_anim; }; ALIVE_ASSERT_SIZEOF(ParticleBurst_Item, 0x88); ParticleBurst* ParticleBurst::ctor_41CF50(FP xpos, FP ypos, unsigned int numOfParticles, FP scale, BurstType type, signed __int16 count) { BaseAnimatedWithPhysicsGameObject_ctor_424930(0); SetVTable(this, 0x5447DC); field_4_typeId = Types::eParticleBurst_29; // TODO: Check it if (numOfParticles > 5) { numOfParticles /= 2; } if (count > 13) { count = 13; } else if (count <= 0) { count = 1; } field_106_count = count; field_CC_sprite_scale = scale; field_F4_ppRes = ResourceManager::Allocate_New_Locked_Resource_49BF40(ResourceManager::ResourceType::Resource_3DGibs, 0, sizeof(ParticleBurst_Item) * numOfParticles); if (field_F4_ppRes) { field_F8_pRes = reinterpret_cast<ParticleBurst_Item*>(*field_F4_ppRes); for (DWORD i = 0; i < numOfParticles; i++) { // Placement new each element new (&field_F8_pRes[i]) ParticleBurst_Item(); SetVTable(&field_F8_pRes[i].field_18_anim, 0x5447CC); } field_104_type = type; switch (field_104_type) { case BurstType::eFallingRocks_0: Animation_Init_424E10(6484, 71, 36, Add_Resource_4DC130(ResourceManager::Resource_Animation, ResourceID::kDebrisID00), 1, 1u); field_20_animation.field_4_flags.Clear(AnimFlags::eBit15_bSemiTrans); field_20_animation.field_4_flags.Set(AnimFlags::eBit16_bBlending); break; case BurstType::eSticks_1: Animation_Init_424E10(1704, 49, 29, Add_Resource_4DC130(ResourceManager::Resource_Animation, ResourceID::kStickGib), 1, 1u); field_20_animation.field_4_flags.Clear(AnimFlags::eBit15_bSemiTrans); field_20_animation.field_4_flags.Set(AnimFlags::eBit16_bBlending); break; case BurstType::eBigPurpleSparks_2: Animation_Init_424E10(9912, 122, 43, Add_Resource_4DC130(ResourceManager::Resource_Animation, ResourceID::kDeathFlareResID), 1, 1u); field_20_animation.field_4_flags.Set(AnimFlags::eBit15_bSemiTrans); field_20_animation.field_4_flags.Set(AnimFlags::eBit16_bBlending); field_20_animation.field_B_render_mode = TPageAbr::eBlend_1; break; case BurstType::eBigRedSparks_3: case BurstType::eGreenSparks_5: case BurstType::eSmallPurpleSparks_6: Animation_Init_424E10(9912, 122, 43, Add_Resource_4DC130(ResourceManager::Resource_Animation, ResourceID::kDeathFlareResID), 1, 1u); field_20_animation.field_B_render_mode = TPageAbr::eBlend_1; field_20_animation.field_4_flags.Set(AnimFlags::eBit15_bSemiTrans); field_20_animation.field_4_flags.Clear(AnimFlags::eBit16_bBlending); if (field_104_type == BurstType::eBigRedSparks_3) { field_20_animation.field_8_r = 254; field_20_animation.field_9_g = 148; field_20_animation.field_A_b = 18; } else if (field_104_type == BurstType::eSmallPurpleSparks_6) { field_20_animation.field_8_r = 127; field_20_animation.field_9_g = 127; field_20_animation.field_A_b = 127; } else { field_20_animation.field_8_r = 0; field_20_animation.field_9_g = 255; field_20_animation.field_A_b = 32; } break; default: break; } if (field_6_flags.Get(BaseGameObject::eListAddFailed_Bit1)) { field_6_flags.Set(BaseGameObject::eDead_Bit3); } else { if (field_CC_sprite_scale == FP_FromInteger(1)) { field_D6_scale = 1; field_20_animation.field_C_render_layer = Layer::eLayer_39; } else { field_D6_scale = 0; field_20_animation.field_C_render_layer = Layer::eLayer_20; } field_FC_number_of_particles = static_cast<short>(numOfParticles); field_100_timer = sGnFrame_5C1B84 + 91; field_B8_xpos = xpos; field_BC_ypos = ypos; for (DWORD i = 0; i < numOfParticles; i++) { field_F8_pRes[i].field_18_anim.field_68_anim_ptr = &field_20_animation; field_F8_pRes[i].field_18_anim.field_C_render_layer = field_20_animation.field_C_render_layer; field_F8_pRes[i].field_18_anim.field_6C_scale = FP_FromDouble(0.95) * field_CC_sprite_scale; field_F8_pRes[i].field_18_anim.field_4_flags.Set(AnimFlags::eBit3_Render); field_F8_pRes[i].field_18_anim.field_4_flags.Set(AnimFlags::eBit25_bDecompressDone); // TODO: HIWORD &= ~0x0100u ?? field_F8_pRes[i].field_18_anim.field_4_flags.Set(AnimFlags::eBit15_bSemiTrans, field_20_animation.field_4_flags.Get(AnimFlags::eBit15_bSemiTrans)); field_F8_pRes[i].field_18_anim.field_4_flags.Set(AnimFlags::eBit16_bBlending, field_20_animation.field_4_flags.Get(AnimFlags::eBit16_bBlending)); if (type == BurstType::eBigPurpleSparks_2) { if (i % 2) { field_F8_pRes[i].field_18_anim.field_4_flags.Set(AnimFlags::eBit16_bBlending); } } field_F8_pRes[i].field_18_anim.field_8_r = field_20_animation.field_8_r; field_F8_pRes[i].field_18_anim.field_9_g = field_20_animation.field_9_g; field_F8_pRes[i].field_18_anim.field_A_b = field_20_animation.field_A_b; field_F8_pRes[i].field_0_x = field_B8_xpos; field_F8_pRes[i].field_4_y = field_BC_ypos; field_F8_pRes[i].field_8_z = FP_FromInteger(0); Random_Speed_41CEE0(&field_F8_pRes[i].field_C_x_speed); Random_Speed_41CEE0(&field_F8_pRes[i].field_10_y_speed); // OG bug sign could be wrong here as it called random again to Abs() it! FP zRandom = {}; field_F8_pRes[i].field_14_z_speed = -FP_Abs(*Random_Speed_41CEE0(&zRandom)); } } } else { field_6_flags.Set(BaseGameObject::eDead_Bit3); } return this; } BaseGameObject* ParticleBurst::VDestructor(signed int flags) { return vdtor_41D4E0(flags); } void ParticleBurst::VUpdate() { vUpdate_41D590(); } void ParticleBurst::VRender(PrimHeader** ppOt) { vRender_41D7B0(ppOt); } FP* ParticleBurst::Random_Speed_41CEE0(FP* random) { const FP v2 = FP_FromRaw((Math_NextRandom() - 128) << LOBYTE(field_106_count)); *random = v2 * field_CC_sprite_scale; return random; } ParticleBurst* ParticleBurst::vdtor_41D4E0(signed int flags) { dtor_41D510(); if (flags & 1) { ae_delete_free_495540(this); } return this; } void ParticleBurst::dtor_41D510() { SetVTable(this, 0x5447DC); if (field_F4_ppRes) { ResourceManager::FreeResource_49C330(field_F4_ppRes); } BaseAnimatedWithPhysicsGameObject_dtor_424AD0(); } void ParticleBurst::vRender_41D7B0(PrimHeader** ppOt) { bool bFirst = true; if (sNum_CamSwappers_5C1B66 == 0) { field_20_animation.field_14_scale = field_CC_sprite_scale; const FP camX = pScreenManager_5BB5F4->field_20_pCamPos->field_0_x; const FP camY = pScreenManager_5BB5F4->field_20_pCamPos->field_4_y; for (int i = 0; i < field_FC_number_of_particles; i++) { if (field_F8_pRes[i].field_0_x < camX) { continue; } if (field_F8_pRes[i].field_0_x > camX + FP_FromInteger(640)) { continue; } if (field_F8_pRes[i].field_4_y < camY) { continue; } if (field_F8_pRes[i].field_4_y > camY + FP_FromInteger(240)) { continue; } const FP zPos = field_F8_pRes[i].field_8_z; // TODO: Much duplicated code in each branch if (bFirst) { field_20_animation.field_14_scale = FP_FromInteger(100) / (zPos + FP_FromInteger(300)); field_20_animation.field_14_scale *= field_CC_sprite_scale; field_20_animation.field_14_scale *= FP_FromInteger(field_106_count) / FP_FromInteger(13); if (field_20_animation.field_14_scale <= FP_FromInteger(1)) { field_20_animation.vRender_40B820( FP_GetExponent(field_F8_pRes[i].field_0_x - camX), FP_GetExponent(field_F8_pRes[i].field_4_y - camY), ppOt, 0, 0); bFirst = false; PSX_RECT frameRect = {}; field_20_animation.Get_Frame_Rect_409E10(&frameRect); if (field_106_count == 9) { if (field_20_animation.field_8_r > 5) { field_20_animation.field_8_r -= 6; } else { field_20_animation.field_8_r = 0; } if (field_20_animation.field_9_g > 5) { field_20_animation.field_9_g -= 6; } else { field_20_animation.field_9_g = 0; } if (field_20_animation.field_A_b > 5) { field_20_animation.field_A_b -= 6; } else { field_20_animation.field_A_b = 0; } } pScreenManager_5BB5F4->InvalidateRect_40EC90( frameRect.x, frameRect.y, frameRect.w, frameRect.h, pScreenManager_5BB5F4->field_3A_idx); } } else { field_F8_pRes[i].field_18_anim.field_6C_scale = FP_FromInteger(100) / (zPos + FP_FromInteger(300)); field_F8_pRes[i].field_18_anim.field_6C_scale *= field_CC_sprite_scale; field_F8_pRes[i].field_18_anim.field_6C_scale *= FP_FromInteger(field_106_count) / FP_FromInteger(13); if (field_F8_pRes[i].field_18_anim.field_6C_scale <= FP_FromInteger(1)) { field_F8_pRes[i].field_18_anim.vRender_40B820( FP_GetExponent(field_F8_pRes[i].field_0_x - camX), FP_GetExponent(field_F8_pRes[i].field_4_y - camY), ppOt, 0, 0); PSX_RECT frameRect = {}; field_F8_pRes[i].field_18_anim.GetRenderedSize_40C980(&frameRect); if (field_106_count == 9) { if (field_F8_pRes[i].field_18_anim.field_8_r > 5) { field_F8_pRes[i].field_18_anim.field_8_r -= 6; } else { field_F8_pRes[i].field_18_anim.field_8_r = 0; } if (field_F8_pRes[i].field_18_anim.field_9_g > 5) { field_F8_pRes[i].field_18_anim.field_9_g -= 6; } else { field_F8_pRes[i].field_18_anim.field_9_g = 0; } if (field_F8_pRes[i].field_18_anim.field_A_b > 5) { field_F8_pRes[i].field_18_anim.field_A_b -= 6; } else { field_F8_pRes[i].field_18_anim.field_A_b = 0; } } pScreenManager_5BB5F4->InvalidateRect_40EC90( frameRect.x, frameRect.y, frameRect.w, frameRect.h, pScreenManager_5BB5F4->field_3A_idx); } } } } } void ParticleBurst::vUpdate_41D590() { const int v3 = field_CC_sprite_scale != FP_FromInteger(1) ? 2 : 4; for (int i = 0; i < field_FC_number_of_particles; i++) { field_F8_pRes[i].field_0_x += field_F8_pRes[i].field_C_x_speed; field_F8_pRes[i].field_4_y += field_F8_pRes[i].field_10_y_speed; field_F8_pRes[i].field_8_z += field_F8_pRes[i].field_14_z_speed; field_F8_pRes[i].field_10_y_speed += FP_FromDouble(0.25); if (field_106_count == 9) { if ((sGnFrame_5C1B84 + i) & v3) { field_F8_pRes[i].field_0_x -= FP_FromInteger(1); } else { field_F8_pRes[i].field_0_x += FP_FromInteger(1); } } if (field_F8_pRes[i].field_8_z + FP_FromInteger(300) < FP_FromInteger(15)) { field_F8_pRes[i].field_14_z_speed = -field_F8_pRes[i].field_14_z_speed; field_F8_pRes[i].field_8_z += field_F8_pRes[i].field_14_z_speed; // TODO: Never used by OG ?? //Math_RandomRange_496AB0(-64, 46); // TODO: This might be wrong const short volume = static_cast<short>(Math_RandomRange_496AB0(-10, 10) + ((field_100_timer - sGnFrame_5C1B84) / 91) + 25); const BYTE next_rand = Math_NextRandom(); if (next_rand < 43) { SFX_Play_46FC20(SoundEffect::ParticleBurst_27, volume, CameraPos::eCamLeft_3); } else if (next_rand >= 85) { SFX_Play_46FC20(SoundEffect::ParticleBurst_27, volume, CameraPos::eCamRight_4); } else { SFX_Play_46FC20(SoundEffect::ParticleBurst_27, volume, CameraPos::eCamCurrent_0); } } } if (static_cast<int>(sGnFrame_5C1B84) > field_100_timer) { field_6_flags.Set(BaseGameObject::eDead_Bit3); } if (Event_Get_422C00(kEventDeathReset)) { field_6_flags.Set(BaseGameObject::eDead_Bit3); } }
35.777778
170
0.551889
THEONLYDarkShadow
9ed55f3e8b285a0b17d289c1443def0bd4afc0b4
854
hpp
C++
inc/RingBuffer.hpp
izissise/network
7267690fdaa379331b130e5bdd7ee87649c240b2
[ "MIT" ]
1
2015-05-06T09:21:07.000Z
2015-05-06T09:21:07.000Z
inc/RingBuffer.hpp
izissise/network
7267690fdaa379331b130e5bdd7ee87649c240b2
[ "MIT" ]
1
2015-06-14T17:23:11.000Z
2015-06-15T09:41:16.000Z
inc/RingBuffer.hpp
izissise/network
7267690fdaa379331b130e5bdd7ee87649c240b2
[ "MIT" ]
null
null
null
#ifndef RINGBUFFER_H # define RINGBUFFER_H # include <cstdint> # include <memory> # include <cstring> # include "ASocket.hpp" namespace Network { class RingBuffer { public: RingBuffer(size_t size = 4096); virtual ~RingBuffer() = default; void writeBuffer(const Network::Buffer& data); void readBuffer(Network::Buffer& data, size_t rSize); size_t getBuffSize() const {return _buffSize;}; void extendRingBuffer(size_t addSize); void rollbackReadBuffer(size_t rbsize); inline size_t getLeftRead() const { return (((_idxW + _buffSize) - _idxR) % _buffSize); }; inline size_t getLeftWrite() const { return (((_idxR + _buffSize - 1) - _idxW) % _buffSize); }; //Iterators protected: size_t _buffSize; size_t _idxR; size_t _idxW; std::unique_ptr<uint8_t[]> _buffer; }; }; #endif // RINGBUFFER_H
18.977778
59
0.687354
izissise
9edb100510240b459c4ce833507d90c8772568b3
134
hxx
C++
src/Providers/UNIXProviders/PackageInConnector/UNIX_PackageInConnector_SOLARIS.hxx
brunolauze/openpegasus-providers-old
b00f1aad575bae144b8538bf57ba5fd5582a4ec7
[ "MIT" ]
1
2020-10-12T09:00:09.000Z
2020-10-12T09:00:09.000Z
src/Providers/UNIXProviders/PackageInConnector/UNIX_PackageInConnector_SOLARIS.hxx
brunolauze/openpegasus-providers-old
b00f1aad575bae144b8538bf57ba5fd5582a4ec7
[ "MIT" ]
null
null
null
src/Providers/UNIXProviders/PackageInConnector/UNIX_PackageInConnector_SOLARIS.hxx
brunolauze/openpegasus-providers-old
b00f1aad575bae144b8538bf57ba5fd5582a4ec7
[ "MIT" ]
null
null
null
#ifdef PEGASUS_OS_SOLARIS #ifndef __UNIX_PACKAGEINCONNECTOR_PRIVATE_H #define __UNIX_PACKAGEINCONNECTOR_PRIVATE_H #endif #endif
11.166667
43
0.858209
brunolauze
9ee49a10c4b53cd5e34bfb1f8b4fa06ec39e7967
4,988
cpp
C++
src/archutils/Darwin/Crash.cpp
SharpnelXu/etterna
8775f74ac9c353320128609d4b4150672e9a6d04
[ "MIT" ]
1
2022-02-22T01:24:02.000Z
2022-02-22T01:24:02.000Z
src/archutils/Darwin/Crash.cpp
john-marinelli/etterna
8775f74ac9c353320128609d4b4150672e9a6d04
[ "MIT" ]
1
2019-05-04T02:30:57.000Z
2019-05-04T02:30:57.000Z
src/archutils/Darwin/Crash.cpp
john-marinelli/etterna
8775f74ac9c353320128609d4b4150672e9a6d04
[ "MIT" ]
3
2019-05-02T01:50:23.000Z
2020-05-25T01:08:36.000Z
#include "Etterna/Globals/global.h" #include "Crash.h" #include "Core/Services/Locator.hpp" #include "Core/Platform/Platform.hpp" #include "Core/Misc/AppInfo.hpp" #include <CoreServices/CoreServices.h> #include <sys/types.h> #include <fmt/format.h> #if defined(HAVE_UNISTD_H) #include <unistd.h> #endif #include <sys/sysctl.h> std::string CrashHandler::GetLogsDirectory() { FSRef fs; char dir[PATH_MAX]; if (FSFindFolder( kUserDomain, kDomainLibraryFolderType, kDontCreateFolder, &fs) || FSRefMakePath(&fs, (UInt8*)dir, PATH_MAX)) { return "/tmp"; } return fmt::format("{}/Logs/{}", dir, Core::AppInfo::APP_TITLE); } // XXX Can we use LocalizedString here instead? #define LSTRING(b, x) \ CFBundleCopyLocalizedString((b), CFStringCreateWithCString(kCFAllocatorDefault, x, kCFStringEncodingUTF8), NULL, CFSTR("Localizable")) void CrashHandler::InformUserOfCrash(const std::string& sPath) { CFBundleRef bundle = CFBundleGetMainBundle(); CFStringRef sAlternate = LSTRING(bundle, fmt::format("Quit {}", Core::AppInfo::APP_TITLE).c_str()); /* XXX Translate these and remove the redefine of LSTRING. Another way to do * this would be to pass bundle's URL to CFUserNotificationDisplayAlert's * localizationURL parameter and let it do it. This wouldn't work for sBody * though. */ CFStringRef sDefault = LSTRING(bundle, "File Bug Report"); CFStringRef sOther = LSTRING(bundle, "Open crashinfo.txt"); CFStringRef sTitle = LSTRING(bundle, fmt::format("{} has crashed", Core::AppInfo::APP_TITLE).c_str()); CFStringRef sFormat = LSTRING(bundle, fmt::format("{} has crashed" "Debugging information has been output to\n\n%s\n\n" "Please file a bug report at\n\n%s", Core::AppInfo::APP_TITLE).c_str()); CFStringRef sBody = CFStringCreateWithFormat( kCFAllocatorDefault, NULL, sFormat, sPath.c_str(), Core::AppInfo::BUG_REPORT_URL); CFOptionFlags response = kCFUserNotificationCancelResponse; CFTimeInterval timeout = 0.0; // Should we ever time out? CFUserNotificationDisplayAlert(timeout,kCFUserNotificationStopAlertLevel, NULL, NULL, NULL, sTitle, sBody, sDefault, sAlternate, sOther, &response); switch (response) { case kCFUserNotificationDefaultResponse: Core::Platform::openWebsite(Core::AppInfo::BUG_REPORT_URL); // Fall through. case kCFUserNotificationOtherResponse: // Open the file with the default application (probably TextEdit). Core::Platform::openWebsite("file://" + sPath); break; } CFRelease(sBody); CFRelease(sFormat); CFRelease(sTitle); CFRelease(sOther); CFRelease(sDefault); CFRelease(sAlternate); } /* IMPORTANT: Because the definition of the kinfo_proc structure (in * <sys/sysctl.h>) is conditionalized by __APPLE_API_UNSTABLE, you should * restrict use of the [below] code to the debug build of your program. * http://developer.apple.com/qa/qa2004/qa1361.html */ bool CrashHandler::IsDebuggerPresent() { #ifdef DEBUG int ret; int mib[] = { CTL_KERN, KERN_PROC, KERN_PROC_PID, getpid() }; struct kinfo_proc info; size_t size; // Initialize the flags so that, if sysctl fails for some bizarre // reason, we get a predictable result. info.kp_proc.p_flag = 0; // Call sysctl. size = sizeof(info); ret = sysctl(mib, sizeof(mib) / sizeof(*mib), &info, &size, NULL, 0); // We're being debugged if the P_TRACED flag is set. return ret == 0 && (info.kp_proc.p_flag & P_TRACED) != 0; #else return false; #endif } void CrashHandler::DebugBreak() { // TODO: Following command is depreciated. // DebugStr("\pDebugBreak()"); } /* * (c) 2003-2006 Steve Checkoway * 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, and/or sell copies of the Software, and to permit persons to * whom the Software is furnished to do so, provided that the above * copyright notice(s) and this permission notice appear in all copies of * the Software and that both the above copyright notice(s) and this * permission notice appear in supporting documentation. * * 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 OF * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS * INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL 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. */
35.884892
135
0.722735
SharpnelXu
9ee63a11f3a00f146be2413047aad5fc8465af25
461
cpp
C++
Fast Fibonacci/Fast Fibonacci/main.cpp
brunorabelo/URI-Online-Judge
87051c4fa7339c0ed6d9613739b70cedea2fe090
[ "MIT" ]
null
null
null
Fast Fibonacci/Fast Fibonacci/main.cpp
brunorabelo/URI-Online-Judge
87051c4fa7339c0ed6d9613739b70cedea2fe090
[ "MIT" ]
null
null
null
Fast Fibonacci/Fast Fibonacci/main.cpp
brunorabelo/URI-Online-Judge
87051c4fa7339c0ed6d9613739b70cedea2fe090
[ "MIT" ]
null
null
null
// // main.cpp // Fast Fibonacci // // Created by MacBook on 02/05/17. // Copyright © 2017 Bruno Botelho. All rights reserved. // #include <stdio.h> #include <math.h> int main(int argc, const char * argv[]) { // insert code here... int n; double result; scanf("%d",&n); result= pow(((1+sqrt(5))/2.0),n)-pow((1-sqrt(5))/2.0, n); result/=sqrt(5); printf("%.1lf\n",result); return 0; }
15.366667
61
0.518438
brunorabelo
9eeabe215b2ffe2a8763142d9ee64ea8c27c4a8b
2,834
cc
C++
libcurv/program.cc
curv3d/curv
f3b7a0045b681df86ec25f1f97c4e6feb7dd5c6a
[ "Apache-2.0" ]
921
2019-01-13T18:47:47.000Z
2022-03-28T03:36:18.000Z
libcurv/program.cc
curv3d/curv
f3b7a0045b681df86ec25f1f97c4e6feb7dd5c6a
[ "Apache-2.0" ]
93
2019-01-11T15:35:01.000Z
2022-01-14T17:42:05.000Z
libcurv/program.cc
curv3d/curv
f3b7a0045b681df86ec25f1f97c4e6feb7dd5c6a
[ "Apache-2.0" ]
59
2019-01-20T09:37:59.000Z
2022-02-17T15:12:10.000Z
// Copyright 2016-2021 Doug Moen // Licensed under the Apache License, version 2.0 // See accompanying file LICENSE or https://www.apache.org/licenses/LICENSE-2.0 #include <libcurv/program.h> #include <libcurv/analyser.h> #include <libcurv/builtin.h> #include <libcurv/context.h> #include <libcurv/definition.h> #include <libcurv/exception.h> #include <libcurv/parser.h> #include <libcurv/scanner.h> #include <libcurv/system.h> namespace curv { struct File_Phrase : public Phrase { Src_Loc loc_; File_Phrase(const Filesystem::path& path, Source::Type type) : loc_{make<Source>(path.string(), type), Token{}} { } virtual Src_Loc location() const override { return loc_; } virtual Shared<Meaning> analyse(Environ& env, Interp) const override { throw Exception(At_Phrase(*this, env), "internal error: File_Phrase::analyse"); } }; void Program::compile(Shared<const Source> source, Scanner_Opts scopts, Environ& env, Interp terp) { Scanner scanner(move(source), sstate_, scopts); phrase_ = parse_program(scanner); if (auto def = phrase_->as_definition(env, Fail::soft)) { module_ = analyse_module(*def, env); } else { meaning_ = phrase_->analyse(env, terp); } frame_ = {make_tail_array<Frame>(env.frame_maxslots_, sstate_, sstate_.file_frame_, nullptr, nullptr)}; } void Program::compile(Shared<const Source> source, Environ& env, Interp terp) { compile(move(source), Scanner_Opts(), env, terp); } void Program::compile(Shared<const Source> source) { Builtin_Environ env{sstate_.system_.std_namespace(), sstate_}; compile(move(source), env, Interp::expr()); } void Program::compile(Shared<const Source> source, Scanner_Opts scopts) { Builtin_Environ env{sstate_.system_.std_namespace(), sstate_}; compile(move(source), scopts, env, Interp::expr()); } void Program::compile(Filesystem::path path, Source::Type type, Value val) { value_ = val; phrase_ = make<File_Phrase>(path, type); } const Phrase& Program::syntax() const { return *nub_phrase(phrase_); } Value Program::eval() { if (value_) return value_; else if (module_ != nullptr) { throw Exception(At_Program(*this), "definition found; expecting an expression"); } else { auto expr = meaning_->to_operation(sstate_); frame_->next_op_ = &*expr; return tail_eval_frame(move(frame_)); } } Shared<Module> Program::exec(Operation::Executor& ex) { if (value_) { ex.push_value(value_, At_Program(*this)); return nullptr; } else if (module_) { return module_->eval_module(*frame_); } else { auto op = meaning_->to_operation(sstate_); op->exec(*frame_, ex); return nullptr; } } } // namespace curv
24.859649
79
0.666196
curv3d
9eeb5a2ef550c476cc02eb2855487ed91a5cf6e8
2,391
cpp
C++
src/runtime/fnput/fnput_impl.cpp
jsoniq/jsoniq
f7af29417f809d64d1f0b2622d880bc4d87f2e42
[ "Apache-2.0" ]
94
2015-01-18T09:40:36.000Z
2022-03-02T21:14:55.000Z
src/runtime/fnput/fnput_impl.cpp
jsoniq/jsoniq
f7af29417f809d64d1f0b2622d880bc4d87f2e42
[ "Apache-2.0" ]
72
2015-01-05T22:00:31.000Z
2021-07-17T11:35:03.000Z
src/runtime/fnput/fnput_impl.cpp
jsoniq/jsoniq
f7af29417f809d64d1f0b2622d880bc4d87f2e42
[ "Apache-2.0" ]
27
2015-01-18T20:20:54.000Z
2020-11-01T18:01:07.000Z
/* * Copyright 2006-2008 The FLWOR Foundation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include "stdafx.h" #include "common/shared_types.h" #include "system/globalenv.h" #include "context/static_context.h" #include "runtime/fnput/fnput.h" #include "store/api/pul.h" #include "store/api/item_factory.h" #include "store/api/copymode.h" #include "zorbatypes/URI.h" #include <zorba/internal/unique_ptr.h> namespace zorba { /******************************************************************************* fn:put ********************************************************************************/ bool FnPutIterator::nextImpl(store::Item_t& result, PlanState& planState) const { store::Item_t node; store::Item_t uriItem; zstring uriString; zstring resolvedUriString; URI lTargetUri; store::Item_t resolvedUriItem; std::unique_ptr<store::PUL> pul; PlanIteratorState* state; DEFAULT_STACK_INIT(PlanIteratorState, state, planState); consumeNext(node, theChildren[0].getp(), planState); if (node->getNodeKind()==store::StoreConsts::attributeNode) { throw XQUERY_EXCEPTION( err::FOUP0001, ERROR_LOC( loc ) ); } consumeNext(uriItem, theChildren[1].getp(), planState); uriString = uriItem->getStringValue(); #if 1 resolvedUriString = theSctx->resolve_relative_uri(uriString, false); GENV_ITEMFACTORY->createAnyURI(resolvedUriItem, resolvedUriString); #else GENV_ITEMFACTORY->createAnyURI(resolvedUriItem, uriString); #endif try { lTargetUri = URI(uriString); } catch (XQueryException& e) { set_source(e, loc); e.set_diagnostic(err::FOUP0002); throw; } pul.reset(GENV_ITEMFACTORY->createPendingUpdateList()); pul->addPut(&loc, node, resolvedUriItem); result = pul.release(); STACK_PUSH(true, state); STACK_END(state); } } /* vim:set et sw=2 ts=2: */
23.91
81
0.668758
jsoniq
9eef58a4eb99274a4f325f64f7f4d500fe773df8
13,202
cpp
C++
code/engine.vc2008/xrGame/ActorEffector.cpp
Rikoshet-234/xray-oxygen
eaac3fa4780639152684f3251b8b4452abb8e439
[ "Apache-2.0" ]
7
2018-03-27T12:36:07.000Z
2020-06-26T11:31:52.000Z
code/engine.vc2008/xrGame/ActorEffector.cpp
Rikoshet-234/xray-oxygen
eaac3fa4780639152684f3251b8b4452abb8e439
[ "Apache-2.0" ]
2
2018-05-26T23:17:14.000Z
2019-04-14T18:33:27.000Z
code/engine.vc2008/xrGame/ActorEffector.cpp
Rikoshet-234/xray-oxygen
eaac3fa4780639152684f3251b8b4452abb8e439
[ "Apache-2.0" ]
3
2020-06-26T11:41:44.000Z
2021-09-29T19:35:04.000Z
#include "stdafx.h" #include "PostprocessAnimator.h" #include "../xrEngine/effectorPP.h" #include "../xrEngine/ObjectAnimator.h" #include "object_broker.h" #include "Actor.h" void GAME_API AddEffector(CActor* A, int type, const shared_str& sect_name) { bool bCyclic = false; if (pSettings->line_exist(sect_name, "pp_eff_name")) { bCyclic = pSettings->r_bool(sect_name, "pp_eff_cyclic"); CPostprocessAnimator* pp_anm = xr_new<CPostprocessAnimator>(); pp_anm->bOverlap = pSettings->r_bool(sect_name, "pp_eff_overlap"); pp_anm->SetType((EEffectorPPType)type); pp_anm->SetCyclic(bCyclic); LPCSTR fn = pSettings->r_string(sect_name, "pp_eff_name"); pp_anm->Load(fn); A->Cameras().AddPPEffector(pp_anm); } if (pSettings->line_exist(sect_name, "cam_eff_name")) { bCyclic = pSettings->r_bool(sect_name, "cam_eff_cyclic"); CAnimatorCamEffector* cam_anm = xr_new<CAnimatorCamEffector>(); cam_anm->SetType((ECamEffectorType)type); cam_anm->SetCyclic(bCyclic); if (pSettings->line_exist(sect_name, "cam_eff_hud_affect")) cam_anm->SetHudAffect(pSettings->r_bool(sect_name, "cam_eff_hud_affect")); LPCSTR fn = pSettings->r_string(sect_name, "cam_eff_name"); cam_anm->Start(fn); A->Cameras().AddCamEffector(cam_anm); } } void GAME_API AddEffector(CActor* A, int type, const shared_str& sect_name, CEffectorController* ec) { bool bCyclic = false; if (pSettings->line_exist(sect_name, "pp_eff_name")) { bCyclic = pSettings->r_bool(sect_name, "pp_eff_cyclic"); CPostprocessAnimatorControlled* pp_anm = xr_new<CPostprocessAnimatorControlled>(ec); pp_anm->SetType((EEffectorPPType)type); pp_anm->SetCyclic(bCyclic); pp_anm->bOverlap = pSettings->r_bool(sect_name, "pp_eff_overlap"); LPCSTR fn = pSettings->r_string(sect_name, "pp_eff_name"); pp_anm->Load(fn); A->Cameras().AddPPEffector(pp_anm); } if (pSettings->line_exist(sect_name, "cam_eff_name")) { bCyclic = pSettings->r_bool(sect_name, "cam_eff_cyclic"); CCameraEffectorControlled* cam_anm = xr_new<CCameraEffectorControlled>(ec); cam_anm->SetType((ECamEffectorType)type); cam_anm->SetCyclic(bCyclic); if (pSettings->line_exist(sect_name, "cam_eff_hud_affect")) cam_anm->SetHudAffect(pSettings->r_bool(sect_name, "cam_eff_hud_affect")); LPCSTR fn = pSettings->r_string(sect_name, "cam_eff_name"); cam_anm->Start(fn); A->Cameras().AddCamEffector(cam_anm); } } void GAME_API AddEffector(CActor* A, int type, const shared_str& sect_name, GET_KOEFF_FUNC k_func) { bool bCyclic = false; if (pSettings->line_exist(sect_name, "pp_eff_name")) { bCyclic = pSettings->r_bool(sect_name, "pp_eff_cyclic"); CPostprocessAnimatorLerp* pp_anm = xr_new<CPostprocessAnimatorLerp>(); pp_anm->SetType((EEffectorPPType)type); pp_anm->SetCyclic(bCyclic); pp_anm->bOverlap = !!pSettings->r_bool(sect_name, "pp_eff_overlap"); LPCSTR fn = pSettings->r_string(sect_name, "pp_eff_name"); pp_anm->SetFactorFunc(k_func); pp_anm->Load(fn); A->Cameras().AddPPEffector(pp_anm); } if (pSettings->line_exist(sect_name, "cam_eff_name")) { bCyclic = pSettings->r_bool(sect_name, "cam_eff_cyclic"); CAnimatorCamLerpEffector* cam_anm = xr_new<CAnimatorCamLerpEffector>(); cam_anm->SetFactorFunc(k_func); cam_anm->SetType((ECamEffectorType)type); cam_anm->SetCyclic(bCyclic); if (pSettings->line_exist(sect_name, "cam_eff_hud_affect")) cam_anm->SetHudAffect(pSettings->r_bool(sect_name, "cam_eff_hud_affect")); LPCSTR fn = pSettings->r_string(sect_name, "cam_eff_name"); cam_anm->Start(fn); A->Cameras().AddCamEffector(cam_anm); } } void GAME_API AddEffector(CActor* A, int type, const shared_str& sect_name, float factor) { clamp(factor, 0.001f, 1.5f); bool bCyclic = false; if (pSettings->line_exist(sect_name, "pp_eff_name")) { bCyclic = pSettings->r_bool(sect_name, "pp_eff_cyclic"); CPostprocessAnimatorLerpConst* pp_anm = xr_new<CPostprocessAnimatorLerpConst>(); pp_anm->SetType((EEffectorPPType)type); pp_anm->SetCyclic(bCyclic); pp_anm->SetPower(factor); pp_anm->bOverlap = pSettings->r_bool(sect_name, "pp_eff_overlap"); LPCSTR fn = pSettings->r_string(sect_name, "pp_eff_name"); pp_anm->Load(fn); A->Cameras().AddPPEffector(pp_anm); } if (pSettings->line_exist(sect_name, "cam_eff_name")) { bCyclic = pSettings->r_bool(sect_name, "cam_eff_cyclic"); CAnimatorCamLerpEffectorConst* cam_anm = xr_new<CAnimatorCamLerpEffectorConst>(); cam_anm->SetFactor(factor); cam_anm->SetType((ECamEffectorType)type); cam_anm->SetCyclic(bCyclic); if (pSettings->line_exist(sect_name, "cam_eff_hud_affect")) cam_anm->SetHudAffect(pSettings->r_bool(sect_name, "cam_eff_hud_affect")); LPCSTR fn = pSettings->r_string(sect_name, "cam_eff_name"); cam_anm->Start(fn); A->Cameras().AddCamEffector(cam_anm); } } void GAME_API RemoveEffector(CActor* A, int type) { A->Cameras().RemoveCamEffector((ECamEffectorType)type); A->Cameras().RemovePPEffector((EEffectorPPType)type); } CEffectorController::~CEffectorController() { R_ASSERT(!m_ce&&!m_pe); } CAnimatorCamEffector::CAnimatorCamEffector() { m_bCyclic = true; m_objectAnimator = xr_new<CObjectAnimator>(); m_bAbsolutePositioning = false; m_fov = -1.0f; } CAnimatorCamEffector::~CAnimatorCamEffector() { delete_data(m_objectAnimator); } void CAnimatorCamEffector::Start(LPCSTR fn) { m_objectAnimator->Load(fn); m_objectAnimator->Play(Cyclic()); fLifeTime = m_objectAnimator->GetLength(); } BOOL CAnimatorCamEffector::Valid() { if (Cyclic()) return TRUE; return inherited::Valid(); } BOOL CAnimatorCamEffector::ProcessCam(SCamEffectorInfo& info) { if (!inherited::ProcessCam(info)) return FALSE; const Fmatrix& m = m_objectAnimator->XFORM(); m_objectAnimator->Update(Device.fTimeDelta); if (!m_bAbsolutePositioning) { Fmatrix Mdef; Mdef.identity(); Mdef.j = info.n; Mdef.k = info.d; Mdef.i.crossproduct(info.n, info.d); Mdef.c = info.p; Fmatrix mr; mr.mul(Mdef, m); info.d = mr.k; info.n = mr.j; info.p = mr.c; } else { info.d = m.k; info.n = m.j; info.p = m.c; } if (m_fov > 0.0f) info.fFov = m_fov; return TRUE; } BOOL CAnimatorCamLerpEffector::ProcessCam(SCamEffectorInfo& info) { if (!inherited::inherited::ProcessCam(info)) return FALSE; const Fmatrix& m = m_objectAnimator->XFORM(); m_objectAnimator->Update(Device.fTimeDelta); Fmatrix Mdef; Mdef.identity(); Mdef.j = info.n; Mdef.k = info.d; Mdef.i.crossproduct(info.n, info.d); Mdef.c = info.p; Fmatrix mr; mr.mul(Mdef, m); Fquaternion q_src, q_dst, q_res; q_src.set(Mdef); q_dst.set(mr); float t = m_func(); clamp(t, 0.0f, 1.0f); VERIFY(t >= 0.f && t <= 1.f); q_res.slerp(q_src, q_dst, t); Fmatrix res; res.rotation(q_res); res.c.lerp(info.p, mr.c, t); info.d = res.k; info.n = res.j; info.p = res.c; if (m_fov > 0.0f) info.fFov = m_fov; return TRUE; } CAnimatorCamLerpEffectorConst::CAnimatorCamLerpEffectorConst() :m_factor(0.0f) { SetFactorFunc(GET_KOEFF_FUNC(this, &CAnimatorCamLerpEffectorConst::GetFactor)); } CCameraEffectorControlled::CCameraEffectorControlled(CEffectorController* c) : m_controller(c) { m_controller->SetCam(this); SetFactorFunc(GET_KOEFF_FUNC(m_controller, &CEffectorController::GetFactor)); } CCameraEffectorControlled::~CCameraEffectorControlled() { m_controller->SetCam(nullptr); } BOOL CCameraEffectorControlled::Valid() { return m_controller->Valid(); } static const float SND_MIN_VOLUME_FACTOR = 0.1f; SndShockEffector::SndShockEffector() { m_snd_length = 0.0f; m_cur_length = 0.0f; m_stored_volume = -1.0f; m_actor = nullptr; } SndShockEffector::~SndShockEffector() { psSoundVFactor = m_stored_volume; if (m_actor && (m_ce || m_pe)) RemoveEffector(m_actor, effHit); R_ASSERT(!m_ce && !m_pe); } BOOL SndShockEffector::Valid() { return (m_cur_length<=m_snd_length); } BOOL SndShockEffector::InWork() { return inherited::Valid(); } float SndShockEffector::GetFactor() { float f = (m_end_time - Device.fTimeGlobal) / m_life_time; float ff = f * m_life_time / 8.0f; return clampr(ff, 0.0f, 1.0f); } void SndShockEffector::Start(CActor* A, float snd_length, float power) { clamp(power, 0.1f, 1.5f); m_actor = A; m_snd_length = snd_length; if (m_stored_volume < 0.0f) m_stored_volume = psSoundVFactor; m_cur_length = 0; psSoundVFactor = m_stored_volume * SND_MIN_VOLUME_FACTOR; static float xxx = 6.0f / 1.50f; //6sec on max power(1.5) m_life_time = power * xxx; m_end_time = Device.fTimeGlobal + m_life_time; AddEffector(A, effHit, "snd_shock_effector", this); } void SndShockEffector::Update() { m_cur_length += Device.dwTimeDelta; float x = float(m_cur_length) / m_snd_length; float y = 2.f * x - 1; if (y > 0.f) psSoundVFactor = y * (m_stored_volume - m_stored_volume * SND_MIN_VOLUME_FACTOR) + m_stored_volume * SND_MIN_VOLUME_FACTOR; } static const float DELTA_ANGLE_XYZ = 0.5f * PI / 180; static const float ANGLE_SPEED = 1.5f; const float _base_fov = 170.f; const float _max_fov_add = 30.f; CControllerPsyHitCamEffector::CControllerPsyHitCamEffector(ECamEffectorType type, const Fvector &src_pos, const Fvector &target_pos, float time, float base_fov, float dest_fov) : inherited(eCEControllerPsyHit, flt_max) { m_base_fov = base_fov; m_dest_fov = dest_fov; m_time_total = time; m_time_current = 0; m_dangle_target.set(angle_normalize(Random.randFs(DELTA_ANGLE_XYZ)), angle_normalize(Random.randFs(DELTA_ANGLE_XYZ)), angle_normalize(Random.randFs(DELTA_ANGLE_XYZ))); m_dangle_current.set(0.f, 0.f, 0.f); m_position_source = src_pos; m_direction.sub(target_pos, src_pos); m_distance = m_direction.magnitude(); m_direction.normalize(); } BOOL CControllerPsyHitCamEffector::ProcessCam(SCamEffectorInfo& info) { Fmatrix Mdef; Mdef.identity(); Mdef.j.set(info.n); Mdef.k.set(m_direction); Mdef.i.crossproduct(info.n, m_direction); Mdef.c.set(info.p); ////////////////////////////////////////////////////////////////////////// if (angle_lerp(m_dangle_current.x, m_dangle_target.x, ANGLE_SPEED, Device.fTimeDelta)) m_dangle_target.x = angle_normalize(Random.randFs(DELTA_ANGLE_XYZ)); if (angle_lerp(m_dangle_current.y, m_dangle_target.y, ANGLE_SPEED, Device.fTimeDelta)) m_dangle_target.y = angle_normalize(Random.randFs(DELTA_ANGLE_XYZ)); if (angle_lerp(m_dangle_current.z, m_dangle_target.z, ANGLE_SPEED, Device.fTimeDelta)) m_dangle_target.z = angle_normalize(Random.randFs(DELTA_ANGLE_XYZ)); ////////////////////////////////////////////////////////////////////////// if (m_time_current > m_time_total) m_time_current = m_time_total; float perc_past = m_time_current / m_time_total; float cur_dist = m_distance * perc_past; Mdef.c.mad(m_position_source, m_direction, cur_dist); info.fFov = m_base_fov + (m_dest_fov - m_base_fov) * perc_past; m_time_current += Device.fTimeDelta; ////////////////////////////////////////////////////////////////////////// // Установить углы смещения Fmatrix R; if (m_time_current > m_time_total) R.identity(); else R.setHPB(m_dangle_current.x, m_dangle_current.y, m_dangle_current.z); Fmatrix mR; mR.mul(Mdef, R); info.d.set(mR.k); info.n.set(mR.j); info.p.set(mR.c); return TRUE; } bool similar_cam_info(const SCamEffectorInfo& c1, const SCamEffectorInfo& c2) { return(c1.p.similar(c2.p, EPS_L) && c1.d.similar(c2.d, EPS_L) && c1.n.similar(c2.n, EPS_L) && c1.r.similar(c2.r, EPS_L)); } void CActorCameraManager::UpdateCamEffectors() { m_cam_info_hud = m_cam_info; inherited::UpdateCamEffectors(); m_cam_info_hud.d.normalize(); m_cam_info_hud.n.normalize(); m_cam_info_hud.r.crossproduct(m_cam_info_hud.n, m_cam_info_hud.d); m_cam_info_hud.n.crossproduct(m_cam_info_hud.d, m_cam_info_hud.r); } void GAME_API cam_effector_sub(const SCamEffectorInfo& c1, const SCamEffectorInfo& c2, SCamEffectorInfo& dest) { dest.p.sub(c1.p, c2.p); dest.d.sub(c1.d, c2.d); dest.n.sub(c1.n, c2.n); dest.r.sub(c1.r, c2.r); } void GAME_API cam_effector_add(const SCamEffectorInfo& diff, SCamEffectorInfo& dest) { dest.p.add(diff.p); dest.d.add(diff.d); dest.n.add(diff.n); dest.r.add(diff.r); } bool CActorCameraManager::ProcessCameraEffector(CEffectorCam* eff) { SCamEffectorInfo prev = m_cam_info; bool res = inherited::ProcessCameraEffector(eff); if (res) { if (eff->GetHudAffect()) { SCamEffectorInfo affected = m_cam_info; SCamEffectorInfo diff; cam_effector_sub(affected, prev, diff); cam_effector_add(diff, m_cam_info_hud); } m_cam_info_hud.fFov = m_cam_info.fFov; m_cam_info_hud.fFar = m_cam_info.fFar; m_cam_info_hud.fAspect = m_cam_info.fAspect; } return res; } void CAnimatorCamEffectorScriptCB::ProcessIfInvalid(SCamEffectorInfo& info) { if (m_bAbsolutePositioning) { const Fmatrix& m = m_objectAnimator->XFORM(); info.d = m.k; info.n = m.j; info.p = m.c; if (m_fov > 0.0f) info.fFov = m_fov; } } #include "ai_space.h" #include "script_engine.h" #include <luabind/luabind.hpp> BOOL CAnimatorCamEffectorScriptCB::Valid() { BOOL res = inherited::Valid(); if (!res && cb_name.size()) { luabind::functor<LPCSTR> fl; R_ASSERT(ai().script_engine().functor<LPCSTR>(*cb_name, fl)); fl(); cb_name = ""; } return res; }
25.585271
176
0.722391
Rikoshet-234
9ef0de28456ebc1de37f6154aaebdc16fc6e0add
59,522
cpp
C++
Src/ime/PhoneKeyboard.cpp
ericblade/luna-sysmgr
82d5d7ced4ba21d3802eb2c8ae063236b6562331
[ "Apache-2.0" ]
3
2018-11-16T14:51:17.000Z
2019-11-21T10:55:24.000Z
Src/ime/PhoneKeyboard.cpp
penk/luna-sysmgr
60c7056a734cdb55a718507f3a739839c9d74edf
[ "Apache-2.0" ]
1
2021-02-20T13:12:15.000Z
2021-02-20T13:12:15.000Z
Src/ime/PhoneKeyboard.cpp
ericblade/luna-sysmgr
82d5d7ced4ba21d3802eb2c8ae063236b6562331
[ "Apache-2.0" ]
null
null
null
/* @@@LICENSE * * Copyright (c) 2010-2012 Hewlett-Packard Development Company, L.P. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * LICENSE@@@ */ #include "PhoneKeyboard.h" #include "KeyLocationRecorder.h" #include "PalmIMEHelpers.h" #include "Settings.h" #include "SingletonTimer.h" #include "Utils.h" #include "VirtualKeyboardPreferences.h" #include <QDebug> #include <QFile> #include <QApplication> #include <stdlib.h> #include <glib.h> #include <sys/times.h> namespace Phone_Keyboard { /** * temporary XML filename */ #define IME_KDB_XML_FILENAME "/tmp/kdb.xml" #define CURRENT_TIME SingletonTimer::currentTime() // #define DOUBLE_TAP_DURATION Settings::LunaSettings()->tapDoubleClickDuration #define DOUBLE_TAP_DURATION 500 #define DEBUG_TOUCH 0 inline bool KeyCap_TwoVertical(const QPoint & keyCoord, UKey key) { return !UKeyIsFunctionKey(key) && (key < Qt::Key_A || key > Qt::Key_Z); } const int cFirstRepeatDelay = 350; const int cFirstRepeatLongDelay = 750; const int cLetterDeleteRepeatDelay = 120; const int cWordDeleteRepeatDelay = 275; const uint64_t cWordDeleteDelay = cFirstRepeatDelay + 1500; const QPainter::RenderHints cRenderHints = QPainter::SmoothPixmapTransform | QPainter::HighQualityAntialiasing | QPainter::TextAntialiasing; // constants used to draw the popup for extended keys const int cPopupFontSize = 22; const int cPopupLeftSide = 11; const int cPopupRightSide = 10; const int cPopupSide = 20; const int cPopupPointerStart = 37; const int cPopupPointerWidth = 25; const int cPopupTopToKey = 10; const int cPopupSingleLineMax = 5; // if more extended chars that this, break-up in two lines const int cPressedTranslateH = 0; const int cPressedTranslateV = 0; static QFont sFont("Prelude"); static QFont sPopoutFont("Prelude", 32); static QString sElipsis(QChar(0x2026 /* … */)); const int cElipsisFontSize = 14; const QColor cActiveColor(0xd2, 0xd2, 0xd2); const QColor cActiveColor_back(0xd2, 0xd2, 0xd2); const QColor cDisabledColor(0x80, 0x80, 0x80); const QColor cDisabledColor_back(0x80, 0x80, 0x80); const QColor cFunctionColor(0xd2, 0xd2, 0xd2); const QColor cFunctionColor_back(0xd2, 0xd2, 0xd2); const QColor cBlueColor(75, 151, 222); const QColor cBlueColor_back(255, 255, 255); const QColor cPopoutTextColor(20, 20, 20); const QColor cPopoutTextColor_back(0xe2, 0xe2, 0xe2); class PhoneKeyboardFactory : public VirtualKeyboardFactory { public: PhoneKeyboardFactory() : VirtualKeyboardFactory("Phone Keyboard") {} InputMethod * create(IMEDataInterface * dataInterface) { return new PhoneKeyboard(dataInterface); } EVirtualKeyboardSupport getSupport(int maxWidth, int maxHeight) { // return eVirtualKeyboardSupport_Preferred_SizeAndLocale; // force phone keyboard for testing! if (maxWidth < 1024 && maxHeight < 1024) return eVirtualKeyboardSupport_Preferred_Size; return eVirtualKeyboardSupport_Poor; } }; static PhoneKeyboardFactory sPhoneKeyboardFactory; static gboolean keyboard_idle(gpointer) { PhoneKeyboard * keyboard = PhoneKeyboard::getExistingInstance(); if (keyboard) return keyboard->idle(); return false; } typedef DoubleDrawRendererT<GlyphSpec> DoubleDrawRenderer; PhoneKeyboard * PhoneKeyboard::s_instance = NULL; PhoneKeyboard::PhoneKeyboard(IMEDataInterface * dataInterface) : VirtualKeyboard(dataInterface), m_shiftDown(false), m_symbolDown(false), m_lastShiftTime(0), m_lastUnlockTime(0), m_keyboardTopPading(0), m_requestedHeight(-1), m_9tileCorner(22, 22), m_keyboardBackgound(NULL), m_keyboardLimitsVersion(0), m_keyboardDirty(true), m_candidateBar(m_keymap, m_IMEDataInterface), m_candidateBarLayoutOutdated(true), m_generatedKeymapLayout(NULL), m_timer(this), m_repeatKey(cOutside), m_repeatStartTime(0), m_extendedKeys(NULL), m_extendedKeyShown(cKey_None), m_shortcutsHandler(dataInterface), m_showPopupKeys(true), m_idleInit(false), m_backspace("icon-delete.png"), m_shift("icon-shift.png"), m_shift_on("icon-shift-on.png"), m_shift_lock("icon-shift-lock.png"), m_hide("icon-hide-keyboard.png"), m_emoticon_frown("/usr/palm/emoticons/emoticon-frown.png"), m_emoticon_cry("/usr/palm/emoticons/emoticon-cry.png"), m_emoticon_smile("/usr/palm/emoticons/emoticon-smile.png"), m_emoticon_wink("/usr/palm/emoticons/emoticon-wink.png"), m_emoticon_yuck("/usr/palm/emoticons/emoticon-yuck.png"), m_emoticon_gasp("/usr/palm/emoticons/emoticon-gasp.png"), m_emoticon_heart("/usr/palm/emoticons/emoticon-heart.png"), m_background("keyboard-bg.png"), m_white_key("key-white.png"), m_gray_key("key-gray.png"), m_black_key("key-black.png"), m_shift_on_key("key-shift-on.png"), m_shift_lock_key("key-shift-lock.png"), m_popup("popup-bg.png"), m_popup_2("popup-bg-2.png"), m_popup_key("popup-key.png"), m_glyphCache(600, 800) { if (VERIFY(s_instance == NULL)) s_instance = this; Q_ASSERT(m_IMEDataInterface); IMEPixmap::setDefaultLocation("keyboard-phone"); for (int r = 0; r < PhoneKeymap::cKeymapRows; ++r) m_keymap.setRowHeight(r, m_white_key.height() / 2); m_presetHeight[0] = 377; // portrait m_presetHeight[1] = 260; // landscape connect(&m_IMEDataInterface->m_availableSpace, SIGNAL(valueChanged(const QRect &)), SLOT(availableSpaceChanged(const QRect &))); connect(&m_IMEDataInterface->m_visible, SIGNAL(valueChanged(const bool &)), SLOT(visibleChanged(const bool &))); connect(&m_IMEDataInterface->m_editorState, SIGNAL(valueChanged(const PalmIME::EditorState &)), SLOT(editorStateChanged(const PalmIME::EditorState &))); connect(&m_IMEDataInterface->m_autoCap, SIGNAL(valueChanged(const bool &)), SLOT(autoCapChanged(const bool &))); connect(&m_timer, SIGNAL(timeout()), this, SLOT(repeatChar())); m_candidateBar.font().setPixelSize(24); connect(&m_candidateBar, SIGNAL(needsRedraw()), SLOT(triggerRepaint())); connect(&m_candidateBar, SIGNAL(resized()), SLOT(candidateBarResized())); // init size VirtualKeyboardPreferences::instance().applyInitSettings(this); } PhoneKeyboard::~PhoneKeyboard() { if (VERIFY(s_instance == this)) s_instance = NULL; } void PhoneKeyboard::editorStateChanged(const PalmIME::EditorState & state) { bool layoutChanged = false; if (m_keymap.symbolMode() == PhoneKeymap::eSymbolMode_Lock) if (m_keymap.setSymbolMode(PhoneKeymap::eSymbolMode_Off)) layoutChanged = true; if (m_keymap.setEditorState(state)) layoutChanged = true; m_candidateBar.setEditorState(state); if (layoutChanged) keyboardLayoutChanged(); m_shortcutsHandler.resetEditor(state); } void PhoneKeyboard::autoCapChanged(const bool & autoCap) { if (m_keymap.setAutoCap(autoCap)) keyboardLayoutChanged(); } void PhoneKeyboard::setShiftMode(PhoneKeymap::EShiftMode shiftMode) { if (m_keymap.setShiftMode(shiftMode)) keyboardLayoutChanged(); } void PhoneKeyboard::setSymbolMode(PhoneKeymap::ESymbolMode symbolMode) { if (m_keymap.setSymbolMode(symbolMode)) keyboardLayoutChanged(); } void PhoneKeyboard::setKeyboardCombo(const std::string & layoutName, const std::string & languageName, bool showLanguageKey) { const PhoneKeymap::LayoutFamily * layoutFamily = PhoneKeymap::LayoutFamily::findLayoutFamily(layoutName.c_str(), false); // get default if not found bool changed = false; if (m_keymap.setLayoutFamily(layoutFamily)) { changed = true; KeyLocationRecorder::instance().keyboardSizeChanged(m_keymap.layoutName(), m_keymap.rect()); } syncKeymap(); if (m_keymap.setLanguageName(showLanguageKey ? languageName : "")) changed = true; m_candidateBar.setLanguage(languageName); if (changed) keyboardLayoutChanged(); } void PhoneKeyboard::syncKeymap() { if (m_keymap.layoutFamily() != m_generatedKeymapLayout) { if (VERIFY(m_keymap.generateKeyboardLayout(IME_KDB_XML_FILENAME))) m_generatedKeymapLayout = m_keymap.layoutFamily(); else m_generatedKeymapLayout = NULL; m_candidateBarLayoutOutdated = true; } if (m_candidateBarLayoutOutdated && m_generatedKeymapLayout) { if (m_candidateBar.loadKeyboardLayoutFile(IME_KDB_XML_FILENAME, m_generatedKeymapLayout->m_primaryID, m_generatedKeymapLayout->m_secondaryID)) m_candidateBarLayoutOutdated = false; } } void PhoneKeyboard::showSuggestions(bool show) { m_candidateBar.setEnabled(show); if (show) { m_candidateBarLayoutOutdated = true; syncKeymap(); keyboardLayoutChanged(); VirtualKeyboardPreferences::instance().activateCombo(); // for language update... } } void PhoneKeyboard::visibleChanged(const bool & visible) { m_candidateBar.clearCandidates(); if (visible) { setKeyboardHeight(m_requestedHeight); } else { m_keymap.setSymbolMode(PhoneKeymap::eSymbolMode_Off); m_keymap.setShiftMode(PhoneKeymap::eShiftMode_Off); clearExtendedkeys(); } } bool PhoneKeyboard::setBoolOption(const std::string & optionName, bool value) { if (optionName == "suggestions") { showSuggestions(value); } else if (optionName == "popupkeys") { m_showPopupKeys = value; triggerRepaint(); } else { g_warning("PhoneKeyboard::setBoolOption: \"%s\" is not supported.", optionName.c_str()); return false; } return true; } bool PhoneKeyboard::setIntOption(const std::string & optionName, int value) { g_warning("PhoneKeyboard::setIntOption: \"%s\" is not supported.", optionName.c_str()); return false; } bool PhoneKeyboard::getValue(const std::string & name, std::string & outValue) { if (name == "height") { outValue = string_printf("%d", m_requestedHeight); return true; } else if (name == "keyboard_layout") { outValue = m_keymap.getKeyboardLayoutAsJson(); return true; } else if (name == "autocap") { outValue = m_keymap.isAutoCapActive() ? "1" : "0"; return true; } return false; } void PhoneKeyboard::requestSize(int size) { requestHeight(m_presetHeight[inLandscapeOrientation()]); } void PhoneKeyboard::requestHeight(int height) { m_requestedHeight = height; setKeyboardHeight(height); if (height > 0) queueIdlePrerendering(); } void PhoneKeyboard::changePresetHeightForSize(int size, int height) { bool landscape = (size != 0); m_presetHeight[landscape] = qBound<int>(10, height, 2 * m_background.height()); if (landscape == inLandscapeOrientation()) requestHeight(height); } void PhoneKeyboard::availableSpaceChanged(const QRect & size) { m_candidateBar.commit(); m_extendedKeys = NULL; m_keymap.setRect(0, 0, 0, 0); m_candidateBar.frame().setRect(0, 0, 0, 0); m_keyboardTopPading = 0; // use the height preset for that orientation m_requestedHeight = m_presetHeight[inLandscapeOrientation()]; setKeyboardHeight(m_requestedHeight); queueIdlePrerendering(); } void PhoneKeyboard::setKeyboardHeight(int height, bool notify) { const QRect & availableSpace = m_IMEDataInterface->m_availableSpace.get(); int width = availableSpace.width(); int screenHeight = availableSpace.height(); height = qBound<int>(50, height, screenHeight - 28); if (VERIFY(height > 0)) { m_keyboardDirty = true; // assets give us "ideal" non-scaled sizes. Proportionaly adjust m_keyboardTopPading int fullHeight = m_background.height(); int fullKeymapHeight = PhoneKeymap::cKeymapRows * m_white_key.height() / 2; if (fullHeight < fullKeymapHeight) fullHeight = fullKeymapHeight; // if background shorter than assets, stretch background! int keymapHeight = height * fullKeymapHeight / fullHeight; m_keyboardTopPading = height - keymapHeight; if (m_keyboardTopPading < 0) m_keyboardTopPading = 0; // PhoneKeymap pushed at the bottom of the available space m_keymap.setRect(0, availableSpace.height() - keymapHeight, width, keymapHeight); if (notify) { keyboardLayoutChanged(); KeyLocationRecorder::instance().keyboardSizeChanged(m_keymap.layoutName(), m_keymap.rect()); } int candidateBarHeight = m_candidateBar.enabled() ? m_white_key.height() / 2 : 0; m_candidateBar.frame().setRect(0, m_keymap.rect().top() - candidateBarHeight - m_keyboardTopPading, width, candidateBarHeight); //g_debug("PhoneKeyboard::setKeyboardHeight: %d pixels of height, Setting keymap rect to: %d, %d, %dx%d, candidateBar: %d", height, m_keymap.rect().left(), m_keymap.rect().top(), m_keymap.rect().width(), m_keymap.rect().height(), candidateBarHeight); m_9tileCorner.m_trimV = 0; m_9tileCorner.m_trimH = 0; // if (availableSpace.width() < 480) // m_9tileCorner.m_trimH = 4; // else if (availableSpace.width() == 480) // m_9tileCorner.m_trimH = 3; // else if (keymapHeight >= fullKeymapHeight) // m_9tileCorner.m_trimH = 0; // else // { // m_9tileCorner.m_trimH = (fullKeymapHeight - keymapHeight) / 40; // if (m_9tileCorner.m_trimH > 3) // m_9tileCorner.m_trimH = 3; // } //g_critical("9Tile Shrink: %g-%g (%d)", m_9tileCorner.m_trimH, m_9tileCorner.m_trimV, fullKeymapHeight - keymapHeight); } else g_debug("PhoneKeyboard::setKeyboardHeight: FAILED! height: %d, requestedHeight: %d, portrait: %d, landscape %d, background height: %d, keyboard height: %d, available: %d-%d %dx%d.", height, m_requestedHeight, m_presetHeight[0], m_presetHeight[1], m_background.height(), m_keymap.rect().height() + m_keyboardTopPading + m_candidateBar.frame().height(), availableSpace.x(), availableSpace.y(), availableSpace.width(), availableSpace.height()); if (notify) m_IMEDataInterface->m_keyboardHeight.set(m_keymap.rect().height() + m_keyboardTopPading + m_candidateBar.frame().height()); } void PhoneKeyboard::keyboardLayoutChanged() { if (!m_keyboardDirty && m_IMEDataInterface->m_visible.get()) { m_keyboardDirty = true; triggerRepaint(); } m_candidateBar.updateKeyboardLayout(m_keymap.layoutName(), m_keymap.getPage(), m_keymap.rect(), m_keymap.isShiftActive(), m_keymap.isCapsLocked(), m_keymap.isAutoCapActive()); } void PhoneKeyboard::clearExtendedkeys() { if (m_extendedKeys) { m_extendedKeys = 0; m_IMEDataInterface->m_hitRegion.set(QRegion()); if (m_IMEDataInterface->m_visible.get()) triggerRepaint(); } else if (!m_IMEDataInterface->m_hitRegion.get().isEmpty()) m_IMEDataInterface->m_hitRegion.set(QRegion()); // defensive... triggerRepaint(); } void PhoneKeyboard::releaseTouch(int id) { Touch & touch = m_touches[id]; #if DEBUG_TOUCH g_debug("PhoneKeyboard::releaseTouch: '%s', consumed: %d, visible: %d", QString(m_keymap.map(touch.m_keyCoordinate)).toUtf8().data(), touch.m_consumed, touch.m_visible); #endif if (m_candidateBar.endTrace(id)) { triggerRepaint(); } else if (m_extendedKeys) { UKey key; if (!pointToExtendedPopup(touch.m_lastPosition, key)) { key = m_keymap.map(touch.m_keyCoordinate); if (key == Qt::Key_Shift || key == cKey_Symbol) handleKey(key, touch.m_lastPosition); else if (!setExtendedKeys(touch.m_keyCoordinate, true) && !touch.m_consumed) clearExtendedkeys(); else triggerRepaint(); } else { if (key != cKey_None) { g_debug("Extended character selected: %s", QString(m_keymap.getKeyDisplayString(key, true)).toUtf8().data()); handleKey(key, QPointF()); } clearExtendedkeys(); } } else if (touch.m_inCandidateBar) { m_candidateBar.releaseTouch(touch.m_lastPosition.x() - touch.m_firstPosition.x()); } else if (m_keymap.isValidLocation(touch.m_keyCoordinate)) { bool sendKey = touch.m_visible && !touch.m_consumed; UKey key = m_keymap.map(touch.m_keyCoordinate); if (key == cKey_Symbol) setSymbolKeyDown(false); else if (key == Qt::Key_Shift) setShiftKeyDown(false); else { touch.m_visible = false; // the key is no longer considered pressed... touch.m_consumed = true; if (m_shiftDown || m_symbolDown) { // we are sending the key, which means we are "using" the shift or symbol keypress: when these are released, they are NOT sent out/used again. for (std::map<int, Touch>::iterator iter = m_touches.begin(); iter != m_touches.end(); ++iter) { if (iter->first != id) { Touch & touch = iter->second; UKey key = m_keymap.map(touch.m_keyCoordinate); if (key == cKey_Symbol || key == Qt::Key_Shift) touch.m_consumed = true; } } } } if (sendKey) handleKey(key, touch.m_lastPosition); triggerRepaint(); if (touch.m_keyCoordinate == m_repeatKey) stopRepeat(); } } inline int Min(int a, int b) { return a < b ? a : b; } inline int MinMax(int min, int v, int max) { return v < min ? min : (v < max ? v : max); } void PhoneKeyboard::updateTouch(int id, QPointF position) { uint64_t now = CURRENT_TIME; QPointF touchPosition(position.x(), position.y() - m_keymap.rect().top()); UKey extendedKey; QPoint keyCoordinate = (!pointToExtendedPopup(touchPosition, extendedKey) && position.y() > m_keymap.rect().top() - m_keyboardTopPading) ? m_keymap.pointToKeyboard(position.toPoint()) : cOutside; bool newTouch = m_touches.find(id) == m_touches.end(); Touch & touch = m_touches[id]; bool inCandidatebar = m_candidateBar.frame().contains(position.x(), position.y()); UKey newKey = m_keymap.map(keyCoordinate); if (newTouch) { touch.m_firstPosition = touchPosition; touch.m_lastPosition = touchPosition; touch.m_inCandidateBar = inCandidatebar; } //g_debug("Touch bar: %d, %gx%g", inCandidatebar, position.x(), position.y()); if (extendedKey != cKey_None) { if (newTouch) makeSound(extendedKey); if (extendedKey != m_extendedKeyShown || (touch.m_visible && touch.m_keyCoordinate != keyCoordinate)) triggerRepaint(); } else if (!m_extendedKeys && newTouch && m_touches.size() == 1 && QChar(newKey).isLetter() && m_candidateBar.tracePoint(touchPosition.toPoint(), newKey, id, true)) { } else if (!m_extendedKeys && !newTouch && m_candidateBar.tracePoint(touchPosition.toPoint(), newKey, id, false)) { stopRepeat(); } else if (newTouch || (!touch.m_inCandidateBar && touch.m_keyCoordinate != keyCoordinate) || (touch.m_inCandidateBar && inCandidatebar)) { triggerRepaint(); if (touch.m_inCandidateBar) { m_candidateBar.setScrollOffset(m_candidateBar.scrollOffset() + position.x() - touch.m_lastPosition.x()); //g_debug("Candidate bar offset: %d", m_candidateBar.scrollOffset()); } else { #if DEBUG_TOUCH g_debug("%s key '%s', consumed: %d, visible: %d", newTouch ? "New" : "Moved", m_keymap.getKeyDisplayString(newKey, true).toUtf8().data(), touch.m_consumed, touch.m_visible); #endif if (touch.m_visible && !touch.m_consumed) { if (keyCoordinate != m_repeatKey) { if (newTouch && newKey == cKey_Emoticon_Options) { if (!setExtendedKeys(keyCoordinate, true)) m_extendedKeys = NULL; touch.m_consumed = true; stopRepeat(); } else if (newTouch && (canRepeat(newKey) || m_keymap.getExtendedChars(keyCoordinate) || (newKey == cKey_Hide && m_touches.size() == 1))) { m_timer.start(newKey == cKey_Hide || m_candidateBar.isTraceActive() ? cFirstRepeatLongDelay : cFirstRepeatDelay); m_repeatKey = keyCoordinate; m_repeatStartTime = CURRENT_TIME; } else stopRepeat(); } } if (newTouch) { // send pressed keys not already sent out... makeSound(newKey); for (std::map<int, Touch>::iterator iter = m_touches.begin(); iter != m_touches.end(); ++iter) { if (iter->first != id && !touch.m_inCandidateBar) { Touch & othertouch = iter->second; if (othertouch.m_visible) { UKey key = m_keymap.map(othertouch.m_keyCoordinate); if (key != cKey_Symbol && key != Qt::Key_Shift && key != cKey_Hide && !othertouch.m_consumed) { #if DEBUG_TOUCH g_debug("Consumming pressed key '%s', consumed: %d, visible: %d", m_keymap.getKeyDisplayString(key, true).toUtf8().data(), touch.m_consumed, touch.m_visible); #endif handleKey(key, othertouch.m_lastPosition); othertouch.m_visible = false; } othertouch.m_consumed = true; } } } } if (touch.m_visible && ((newKey == cKey_Symbol && !m_extendedKeys && setSymbolKeyDown(true)) || (newKey == Qt::Key_Shift && setShiftKeyDown(true)))) { if (m_extendedKeys) touch.m_consumed = true; } } } touch.m_keyCoordinate = keyCoordinate; if (m_extendedKeys && touch.m_visible != (extendedKey == cKey_None)) { // show keyboard key when NOT on the extended bar touch.m_visible = !touch.m_visible; triggerRepaint(); } touch.m_lastPosition = touchPosition; touch.m_lastTouchTime = now; } void PhoneKeyboard::handleKey(UKey key, QPointF where) { //g_debug("PhoneKeyboard::handleKey: '%s'", QString(key).toUtf8().data()); PhoneKeymap::EShiftMode shiftMode = m_keymap.shiftMode(); PhoneKeymap::ESymbolMode symbolMode = m_keymap.symbolMode(); bool consumeMode = false; bool commit = false; bool sendKey = true; Qt::Key qtkey = Qt::Key_unknown; if (UKeyIsUnicodeQtKey(key)) { qtkey = Qt::Key(key); // "normal" case: UKey is also a valid Qt::Key if (m_candidateBar.enabled()) { if (QChar(key).isLetter()) sendKey = !m_candidateBar.keyboardTap(where, key); else commit = true; } else { sendKey = true; } } else if (UKeyIsTextShortcutKey(key)) { commit = true; qtkey = key; } else if (UKeyIsKeyboardComboKey(key)) { int index = key - cKey_KeyboardComboChoice_First; VirtualKeyboardPreferences::instance().selectKeyboardCombo(index); } else { switch ((int)key) { case Qt::Key_Backspace: qtkey = Qt::Key_Backspace; sendKey = !m_candidateBar.backspace(m_keymap.isShiftDown()); break; case Qt::Key_Return: qtkey = key; commit = true; break; case cKey_SymbolPicker: qtkey = Qt::Key_Control; break; case cKey_Symbol: if (m_extendedKeys) clearExtendedkeys(); else if (m_keymap.symbolMode() == PhoneKeymap::eSymbolMode_Lock) symbolMode = PhoneKeymap::eSymbolMode_Off; else symbolMode = PhoneKeymap::eSymbolMode_Lock, shiftMode = PhoneKeymap::eShiftMode_Off; break; case Qt::Key_Shift: { uint64_t now = CURRENT_TIME; if (m_lastUnlockTime + DOUBLE_TAP_DURATION > now) { // quick tap after unlocking: eat that tap, and next tap is like nothing happened before... m_lastUnlockTime = 0; now = 0; } else if (m_lastShiftTime + DOUBLE_TAP_DURATION > now) shiftMode = PhoneKeymap::eShiftMode_CapsLock; else if (shiftMode == PhoneKeymap::eShiftMode_CapsLock) { shiftMode = PhoneKeymap::eShiftMode_Off; m_lastUnlockTime = now; } else if (shiftMode == PhoneKeymap::eShiftMode_Off) shiftMode = PhoneKeymap::eShiftMode_Once; else shiftMode = PhoneKeymap::eShiftMode_Off; m_lastShiftTime = now; autoCapChanged(false); break; } case cKey_Hide: m_IMEDataInterface->requestHide(); break; case cKey_ToggleSuggestions: showSuggestions(!m_candidateBar.enabled()); break; case cKey_ShowXT9Regions: { PerfMonitor regionMonitor("showXT9Regions"); m_candidateBar.drawXT9Regions(m_keyboardBackgound, m_keyboardTopPading); triggerRepaint(); break; } case cKey_ShowKeymapRegions: showKeymapRegions(); triggerRepaint(); break; case cKey_SwitchToQwerty: VirtualKeyboardPreferences::instance().selectLayoutCombo("qwerty"); break; case cKey_SwitchToAzerty: VirtualKeyboardPreferences::instance().selectLayoutCombo("azerty"); break; case cKey_SwitchToQwertz: VirtualKeyboardPreferences::instance().selectLayoutCombo("qwertz"); break; case cKey_StartStopRecording: { bool wasRecording = KeyLocationRecorder::instance().isRecording(); KeyLocationRecorder::instance().startStop(m_keymap.layoutName(), m_keymap.rect()); if (KeyLocationRecorder::instance().isRecording()) { sendKeyDownUp(Qt::Key_Space, Qt::NoModifier); sendKeyDownUp(Qt::Key_Backspace, Qt::NoModifier); } break; } case cKey_ToggleLanguage: VirtualKeyboardPreferences::instance().selectNextKeyboardCombo(); break; case cKey_CreateDefaultKeyboards: VirtualKeyboardPreferences::instance().createDefaultKeyboards(); break; case cKey_ClearDefaultKeyboards: VirtualKeyboardPreferences::instance().clearDefaultDeyboards(); break; case cKey_ToggleSoundFeedback: VirtualKeyboardPreferences::instance().setTapSounds(!VirtualKeyboardPreferences::instance().getTapSounds()); break; case Qt::Key_Left: qtkey = Qt::Key_Left; // used to navigate the cursor left break; case Qt::Key_Right: qtkey = Qt::Key_Right; // used to navigate the cursor right break; case Qt::Key_Tab: switch (m_keymap.tabAction()) { case PhoneKeymap::eTabAction_Next: m_IMEDataInterface->performEditorAction(PalmIME::FieldAction_Next); break; case PhoneKeymap::eTabAction_Previous: m_IMEDataInterface->performEditorAction(PalmIME::FieldAction_Previous); break; case PhoneKeymap::eTabAction_Tab: default: qtkey = Qt::Key_Tab; } break; default: break; } } if (qtkey != Qt::Key_unknown) { if (commit) m_candidateBar.commit(); consumeMode = true; if (sendKey) { if (KeyLocationRecorder::instance().isRecording()) KeyLocationRecorder::instance().record(m_keymap.getKeyDisplayString(key, true), where.toPoint()); if (UKeyIsTextShortcutKey(key)) { m_IMEDataInterface->commitText(m_keymap.getKeyDisplayString(key).toUtf8().data()); m_shortcutsHandler.resetEditor(); } else if (m_shortcutsHandler.filterKey(qtkey)) { if (UKeyIsFunctionKey(qtkey)) { if (qtkey == Qt::Key_Tab) m_IMEDataInterface->commitText("\t"); else sendKeyDownUp(qtkey, m_keymap.isShiftDown() ? Qt::ShiftModifier : Qt::NoModifier); } else if (qtkey > 0 && qtkey < 128) sendKeyDownUp(qtkey, m_keymap.isCapActive() ? Qt::ShiftModifier : Qt::NoModifier); // send as basic keystroke else if (m_keymap.isCapActive()) sendKeyDownUp((Qt::Key) QChar(qtkey).toUpper().unicode(), Qt::ShiftModifier); else sendKeyDownUp((Qt::Key) QChar(qtkey).toLower().unicode(), Qt::NoModifier); } } else m_shortcutsHandler.resetEditor(); if (qtkey == Qt::Key_Space || qtkey == Qt::Key_Return) symbolMode = PhoneKeymap::eSymbolMode_Off; } if (consumeMode) { if (m_keymap.shiftMode() == PhoneKeymap::eShiftMode_Once) shiftMode = PhoneKeymap::eShiftMode_Off; } if (m_keymap.shiftMode() != shiftMode) setShiftMode(shiftMode); if (m_keymap.symbolMode() != symbolMode) setSymbolMode(symbolMode); } void PhoneKeyboard::sendKeyDownUp(Qt::Key key, Qt::KeyboardModifiers modifiers) { if (m_IMEDataInterface) { m_IMEDataInterface->sendKeyEvent(QEvent::KeyPress, key, modifiers); m_IMEDataInterface->sendKeyEvent(QEvent::KeyRelease, key, modifiers); } } inline const char * touchPointState(Qt::TouchPointState state) { switch (state) { case Qt::TouchPointPressed: return "pressed"; case Qt::TouchPointMoved: return "moved"; case Qt::TouchPointStationary: return "stationary"; case Qt::TouchPointReleased: return "released"; default: return "<unknown>"; } } void PhoneKeyboard::touchEvent(const QTouchEvent& te) { if (m_IMEDataInterface) { const QList<QTouchEvent::TouchPoint> & touchPoints = te.touchPoints(); #if DEBUG_TOUCH std::string str; for (QList<QTouchEvent::TouchPoint>::ConstIterator iter = touchPoints.constBegin(); iter != touchPoints.constEnd(); ++iter) { const QTouchEvent::TouchPoint & touchPoint = *iter; QPoint keyPos = m_keymap.pointToKeyboard(touchPoint.pos().toPoint()); Qt::Key key = m_keymap.map(keyPos); ::append_format(str, " Id: %d, location: %gx%g %s, Key: %dx%d = '%s'.\n", touchPoint.id(), touchPoint.pos().x(), touchPoint.pos().y(), touchPointState(touchPoint.state()), keyPos.x(), keyPos.y(), m_keymap.getKeyDisplayString(key, true).toUtf8().data()); } g_debug("TouchEvent: \n%s", str.c_str()); #endif if (m_IMEDataInterface->m_visible.get()) { // handle new presses after handling release & moves bool presses = false; for (QList<QTouchEvent::TouchPoint>::ConstIterator iter = touchPoints.constBegin(); iter != touchPoints.constEnd(); ++iter) { const QTouchEvent::TouchPoint & touchPoint = *iter; Qt::TouchPointState state = touchPoint.state(); if (state == Qt::TouchPointReleased) { releaseTouch(touchPoint.id()); m_touches.erase(touchPoint.id()); } else if (state == Qt::TouchPointMoved) updateTouch(touchPoint.id(), touchPoint.pos()); else if (state == Qt::TouchPointPressed) presses = true; } if (presses) { for (QList<QTouchEvent::TouchPoint>::ConstIterator iter = touchPoints.constBegin(); iter != touchPoints.constEnd(); ++iter) { const QTouchEvent::TouchPoint & touchPoint = *iter; if (touchPoint.state() == Qt::TouchPointPressed) updateTouch(touchPoint.id(), touchPoint.pos()); } } } else g_warning("TabletKeyboard::touchEvent: hidden (probably being hidden...), so we will ignore these touches."); // everything is released: make sure we have nothing left in our records... if (te.type() == QEvent::TouchEnd) { if (m_touches.size() > 0) { if (m_IMEDataInterface->m_visible.get()) g_critical("Clearing %u non-finished touches!", m_touches.size()); for (QList<QTouchEvent::TouchPoint>::ConstIterator iter = touchPoints.constBegin(); iter != touchPoints.constEnd(); ++iter) m_candidateBar.endTrace(iter->id()); m_touches.clear(); } stopRepeat(); setShiftKeyDown(false); setSymbolKeyDown(false); } } } void PhoneKeyboard::tapEvent(const QPoint& tapPt) { #if DEBUG_TOUCH g_debug("tapEvent: %d, %d", tapPt.x(), tapPt.y()); #endif m_candidateBar.tapEvent(tapPt); } void PhoneKeyboard::screenEdgeFlickEvent() { // Mark all touches as consumed for (std::map<int, Touch>::iterator iter = m_touches.begin(); iter != m_touches.end(); ++iter) { iter->second.m_consumed = true; } } void PhoneKeyboard::repeatChar() { if (PhoneKeymap::isValidLocation(m_repeatKey)) { UKey key = m_keymap.map(m_repeatKey); if (canRepeat(key)) { makeSound(key); bool wordDelete = m_keymap.isShiftDown() || (CURRENT_TIME - m_repeatStartTime > cWordDeleteDelay); if (key == Qt::Key_Backspace) sendKeyDownUp(Qt::Key_Backspace, wordDelete ? Qt::ShiftModifier : Qt::NoModifier); else sendKeyDownUp(Qt::Key(key), m_keymap.isCapActive() ? Qt::ShiftModifier : Qt::NoModifier); int repeatInterval = wordDelete ? cWordDeleteRepeatDelay : cLetterDeleteRepeatDelay; if (m_timer.interval() != repeatInterval) m_timer.setInterval(repeatInterval); } else { if (setExtendedKeys(m_repeatKey)) { for (std::map<int, Touch>::iterator iter = m_touches.begin(); iter != m_touches.end(); ++iter) { Touch & touch = iter->second; if (touch.m_keyCoordinate == m_repeatKey) touch.m_consumed = true; } } stopRepeat(); } } else stopRepeat(); } bool PhoneKeyboard::setExtendedKeys(QPoint keyCoord, bool cancelIfSame) { const UKey * newExtended = m_keymap.getExtendedChars(keyCoord); if (cancelIfSame && newExtended == m_extendedKeys) return false; m_extendedKeys = newExtended; if (m_extendedKeys) { int cellCount, lineCount, lineLength; getExtendedPopupSpec(cellCount, lineCount, lineLength); IMEPixmap & popup = (lineCount > 1) ? m_popup_2 : m_popup; m_extendedKeyShown = cKey_None; m_keymap.keyboardToKeyZone(keyCoord, m_extendedKeysFrame); m_extendedKeysPointer = m_extendedKeysFrame.left() + m_extendedKeysFrame.width() / 2; m_extendedKeysFrame.translate(0, -popup.height() + 10); int width = cPopupLeftSide + cPopupRightSide + lineLength * m_popup_key.width(); m_extendedKeysFrame.setLeft(m_extendedKeysPointer - m_popup_key.width() / 2 - cPopupLeftSide); m_extendedKeysFrame.setWidth(width); m_extendedKeysFrame.setHeight(popup.height()); if (m_extendedKeysFrame.left() < 0) m_extendedKeysFrame.moveLeft(0); else if (m_extendedKeysFrame.right() > m_keymap.rect().right()) m_extendedKeysFrame.translate(m_keymap.rect().right() - m_extendedKeysFrame.right(), 0); if (m_extendedKeysFrame.isValid()) { m_IMEDataInterface->m_hitRegion.set(QRegion(m_IMEDataInterface->m_availableSpace.get())); triggerRepaint(); } return true; } else m_IMEDataInterface->m_hitRegion.set(QRegion()); return false; } bool PhoneKeyboard::pointToExtendedPopup(QPointF position, UKey & outKey) { outKey = cKey_None; if (m_extendedKeys && m_extendedKeysFrame.contains(position.x(), position.y() + m_keymap.rect().top())) { QPoint where = position.toPoint() - m_extendedKeysFrame.topLeft() - QPoint(cPopupLeftSide, -m_keymap.rect().top() + cPopupTopToKey); int cellCount, lineCount, lineLength; getExtendedPopupSpec(cellCount, lineCount, lineLength); int x = qMin<int>(where.x() / m_popup_key.width(), lineLength - 1); int y = where.y() / (m_popup_key.height() / 2); int index = (y == 0) ? x : x + lineLength; if (index <= cellCount) outKey = m_extendedKeys[index]; return true; } return false; } void PhoneKeyboard::getExtendedPopupSpec(int & outCellCount, int & outLineCount, int & outLineLength) { outCellCount = 0; if (m_extendedKeys) while (m_extendedKeys[outCellCount] != cKey_None) ++outCellCount; outLineCount = (outCellCount > cPopupSingleLineMax) ? 2 : 1; outLineLength = (outCellCount + outLineCount - 1) / outLineCount; } bool PhoneKeyboard::canRepeat(UKey key) const { return (key == Qt::Key_Space || key == Qt::Key_Backspace || key == Qt::Key_Left || key == Qt::Key_Right); } void PhoneKeyboard::stopRepeat() { m_timer.stop(); m_repeatKey = cOutside; m_repeatStartTime = 0; } void PhoneKeyboard::showKeymapRegions() { PerfMonitor regionMonitor("showKeymapRegions"); m_keyboardBackgound->fill(QColor(0, 0, 0)); QRect frame = m_keymap.rect(); QPainter painter(m_keyboardBackgound); int y_offset = frame.top() - m_keyboardTopPading; ColorMap colorMap; for (int x = 0; x < frame.width(); ++x) for (int y = 0; y < m_keyboardTopPading + frame.height(); ++y) { QPoint keycoord = m_keymap.pointToKeyboard(QPoint(x, y_offset + y)); if (keycoord != cOutside) { painter.setPen(colorMap[QChar(m_keymap.map(keycoord)).unicode()]); // create or reuse random color for this character painter.drawPoint(x, y); } } m_keyboardDirty = true; } void PhoneKeyboard::paint(QPainter & painter) { PerfMonitor perf("PhoneKeyboard::paint"); m_candidateBar.paint(painter, cBlueColor); const QRect & keymapRect = m_keymap.rect(); QRect keyboardFrame(keymapRect.left(), keymapRect.top() - m_keyboardTopPading, keymapRect.width(), keymapRect.height() + m_keyboardTopPading); if (updateBackground()) perf.trace("background rebuilt"); painter.setCompositionMode(QPainter::CompositionMode_Source); painter.drawPixmap(QPointF(keyboardFrame.left(), keyboardFrame.top()), *m_keyboardBackgound); painter.setCompositionMode(QPainter::CompositionMode_SourceOver); perf.trace("Draw background"); DoubleDrawRenderer doubleDrawRenderer; CachedGlyphRenderer<GlyphSpec> renderer(painter, m_glyphCache, doubleDrawRenderer, PhoneKeymap::cKeymapColumns * (PhoneKeymap::cKeymapRows + 1)); for (int y = 0; y < PhoneKeymap::cKeymapRows; ++y) { for (int x = 0; x < PhoneKeymap::cKeymapColumns; ++x) { QPoint keyCoord(x, y); UKey plainKey = m_keymap.map(x, y, PhoneKeymap::eLayoutPage_plain); QRect r; int count = m_keymap.keyboardToKeyZone(keyCoord, r); if (count > 0 && plainKey != cKey_None) { UKey key = m_keymap.map(x, y); // if (key == Qt::Key_Shift) // drawKeyBackground(painter, r, keyCoord, key, false, count); drawKeyCap(&painter, renderer, r, keyCoord, key, eUse_unpressed); } } } bool extendedKeysShown = m_extendedKeys && m_extendedKeysFrame.isValid(); QRect r; if (extendedKeysShown) { for (int y = 0; y < PhoneKeymap::cKeymapRows; ++y) // draw caps second (faster to split) { for (int x = 0; x < PhoneKeymap::cKeymapColumns; ++x) { if (m_keymap.getExtendedChars(QPoint(x, y)) && m_keymap.keyboardToKeyZone(QPoint(x, y), r) > 0) { r.setWidth(r.width() - 9 + m_9tileCorner.m_trimH); r.setHeight(r.height() - 9 + m_9tileCorner.m_trimV); renderer.render(r, GlyphSpec(sElipsis, cElipsisFontSize, false, cActiveColor, cActiveColor_back), sFont, Qt::AlignRight | Qt::AlignBottom); } } } } renderer.flush(); perf.trace("Draw labels"); UKey extendedKey = cKey_None; for (std::map<int, Touch>::iterator iter = m_touches.begin(); iter != m_touches.end(); ++iter) { Touch & touch = iter->second; if (!pointToExtendedPopup(touch.m_lastPosition, extendedKey)) { if (touch.m_visible) { int count = m_keymap.keyboardToKeyZone(touch.m_keyCoordinate, r); if (count > 0) { UKey key = m_keymap.map(touch.m_keyCoordinate); if (key != cKey_None) { painter.setClipRect(r); painter.drawPixmap(r.left(), keyboardFrame.top(), r.width(), keyboardFrame.height(), m_background.pixmap()); painter.setClipping(false); drawKeyBackground(painter, r, touch.m_keyCoordinate, key, true, count); drawKeyCap(&painter, renderer, r, touch.m_keyCoordinate, key, eUse_pressed); if (extendedKeysShown && m_keymap.getExtendedChars(touch.m_keyCoordinate)) { QRect elipsisRect(r.left() + cPressedTranslateH, r.top() + cPressedTranslateV, r.width() - 9 + m_9tileCorner.m_trimH, r.height() - 9 + m_9tileCorner.m_trimV); renderer.render(elipsisRect, GlyphSpec(sElipsis, cElipsisFontSize, false, cActiveColor, cActiveColor_back), sFont, Qt::AlignRight | Qt::AlignBottom); } if (!m_extendedKeys && m_showPopupKeys && key != Qt::Key_Shift && key != cKey_Symbol && key != Qt::Key_Space && key != Qt::Key_Return && key != Qt::Key_Backspace) { QPoint topLeft((r.left() + r.right() - m_popup.width()) / 2, r.top() - m_popup.height()); painter.drawPixmap(topLeft, m_popup); QRect destRect(topLeft + QPoint((m_popup.width() - m_popup_key.width()) / 2, cPopupTopToKey), QSize(m_popup_key.width(), m_popup_key.height() / 2)); painter.drawPixmap(destRect.topLeft(), m_popup_key, QRect(0, m_popup_key.height() / 2, destRect.width(), destRect.height())); drawKeyCap(&painter, renderer, destRect, touch.m_keyCoordinate, key, eUse_preview); } //g_debug("'%s' drawn pressed, consumed: %d", QString(key).toUtf8().data(), touch.m_consumed); } } } } } renderer.flush(); m_candidateBar.paintTrace(painter, keyboardFrame.top() + m_keyboardTopPading, cBlueColor, 4); if (extendedKeysShown) { renderer.flush(); painter.setFont(sFont); int cellCount, lineCount, lineLength; getExtendedPopupSpec(cellCount, lineCount, lineLength); IMEPixmap & popup = (lineCount > 1) ? m_popup_2 : m_popup; QRect r(m_extendedKeysFrame); int left = r.left() + cPopupSide; int right = r.right() - cPopupSide + 1; painter.drawPixmap(r.left(), r.top(), popup.pixmap(), 0, 0, cPopupSide, popup.height()); painter.drawPixmap(right, r.top(), popup.pixmap(), popup.width() - cPopupSide, 0, cPopupSide, popup.height()); int pointerLeft = m_extendedKeysPointer - cPopupPointerWidth / 2; int pointerRight = pointerLeft + cPopupPointerWidth; if (left < pointerLeft) painter.drawPixmap(left, r.top(), pointerLeft - left, popup.height(), popup.pixmap(), cPopupSide, 0, 1, popup.height()); if (pointerRight < right) painter.drawPixmap(pointerRight, r.top(), right - pointerRight, popup.height(), popup.pixmap(), cPopupSide, 0, 1, popup.height()); painter.drawPixmap(pointerLeft, r.top(), popup.pixmap(), cPopupPointerStart, 0, cPopupPointerWidth, popup.height()); r.translate(cPopupLeftSide, cPopupTopToKey); UKey key; for (int k = 0; (key = m_extendedKeys[k]) != cKey_None; ++k) { if (k < lineLength) painter.drawPixmap(r.left() + k * m_popup_key.width(), r.top(), m_popup_key.pixmap(), 0, (extendedKey == key) ? m_popup_key.height() / 2 : 0, m_popup_key.width(), m_popup_key.height() / 2); else painter.drawPixmap(r.left() + (k - lineLength) * m_popup_key.width(), r.top() + m_popup_2.height() - m_popup.height(), m_popup_key.pixmap(), 0, (extendedKey == key) ? m_popup_key.height() / 2 : 0, m_popup_key.width(), m_popup_key.height() / 2); } r.setWidth(m_popup_key.width() - 3); r.setHeight(m_popup_key.height() / 2 - 2); QRect cell(r); for (int k = 0; (key = m_extendedKeys[k]) != cKey_None; ++k) { if (k < lineLength) cell.moveTopLeft(QPoint(r.left() + k * m_popup_key.width(), r.top())); else cell.moveTopLeft(QPoint(r.left() + (k - lineLength) * m_popup_key.width(), r.top() + m_popup_2.height() - m_popup.height())); QPixmap * pix = (UKeyIsEmoticonKey(key) && m_keymap.showEmoticonsAsGraphics()) ? getPixmapForKey(key) : NULL; if (pix) { drawCenteredPixmap(painter, *pix, cell); } else { QString text = m_keymap.getKeyDisplayString(key); int fontSize = (text.length() < 6) ? cPopupFontSize : cPopupFontSize - 8; if (sFont.pixelSize() != fontSize) { sFont.setPixelSize(fontSize); painter.setFont(sFont); } renderer.render(cell, GlyphSpec(text, fontSize, false, cPopoutTextColor, cPopoutTextColor_back), sFont); } } } m_extendedKeyShown = extendedKey; #if VKB_SHOW_GLYPH_CACHE painter.setPen(QColor(255, 0, 0)); painter.drawRect(QRect(QPoint(0, 0), m_glyphCache.pixmap().size())); painter.drawPixmap(0, 0, m_glyphCache.pixmap()); #endif #if VKB_FORCE_FPS triggerRepaint(); #endif if (renderer.getCacheMissCount() > 0 && m_keymap.getCachedGlyphsCount() < 3) queueIdlePrerendering(); } bool PhoneKeyboard::updateBackground() { if (!m_keyboardBackgound || m_keyboardDirty) { QRect keymapFrame(m_keymap.rect()); int width = keymapFrame.width(); int usedHeight = keymapFrame.height() + m_keyboardTopPading; QRect keyboardFrame(keymapFrame.left(), keymapFrame.top() - m_keyboardTopPading, width, usedHeight); if (!m_keyboardBackgound || m_keyboardBackgound->width() != width || m_keyboardBackgound->height() != usedHeight) { PixmapCache::instance().dispose(m_keyboardBackgound); m_keyboardBackgound = PixmapCache::instance().get(width, usedHeight); } if (m_keymap.updateLimits() != m_keyboardLimitsVersion) { //g_critical("Rebuilding BACKGROUND"); m_keyboardLimitsVersion = m_keymap.updateLimits(); QPainter offscreenPainter(m_keyboardBackgound); //m_keyboardBackgound->fill(QColor(255, 0, 0)); offscreenPainter.drawPixmap(QRect(0, 0, width, usedHeight), m_background.pixmap()); offscreenPainter.translate(0, -keyboardFrame.top()); offscreenPainter.setRenderHints(cRenderHints, true); m_nineTileSprites.reserve(true); for (int y = 0; y < PhoneKeymap::cKeymapRows; ++y) { for (int x = 0; x < PhoneKeymap::cKeymapColumns; ++x) { QPoint keyCoord(x, y); UKey key = m_keymap.map(x, y); QRect r; int count = m_keymap.keyboardToKeyZone(keyCoord, r); if (count > 0) { QSize size = r.size(); if (key == Qt::Key_Shift) { m_nineTileSprites.reserve(size, count, m_shift_on_key); m_nineTileSprites.reserve(size, count, m_shift_lock_key); m_nineTileSprites.reserve(size, count, m_black_key); } else m_nineTileSprites.reserve(size, count, getKeyBackground(keyCoord, key)); } } } m_nineTileSprites.reserve(false); for (int y = 0; y < PhoneKeymap::cKeymapRows; ++y) { for (int x = 0; x < PhoneKeymap::cKeymapColumns; ++x) { UKey plainKey = m_keymap.map(x, y, PhoneKeymap::eLayoutPage_plain); //if (plainKey != Qt::Key_Shift) { QPoint keyCoord(x, y); QRect r; int count = m_keymap.keyboardToKeyZone(keyCoord, r); if (count > 0) drawKeyBackground(offscreenPainter, r, keyCoord, plainKey, false, count); } } } } m_keyboardDirty = false; return true; } return false; } QPixmap & PhoneKeyboard::getKeyBackground(const QPoint & keyCoord, UKey key) { /* if (key == Qt::Key_Shift) { switch (m_keymap.shiftMode()) { case PhoneKeymap::eShiftMode_CapsLock: return m_shift_lock_key; case PhoneKeymap::eShiftMode_Once: return m_shift_on_key; default: return m_black_key; } } else */ return selectFromKeyType<QPixmap &>(m_keymap.map(keyCoord, PhoneKeymap::eLayoutPage_plain), m_white_key, m_black_key, m_gray_key); } QPixmap * PhoneKeyboard::getPixmapForKey(UKey key) { switch ((int)key) { case Qt::Key_Shift: switch (m_keymap.shiftMode()) { case PhoneKeymap::eShiftMode_Once: return &m_shift_on.pixmap(); break; case PhoneKeymap::eShiftMode_CapsLock: return &m_shift_lock.pixmap(); break; case PhoneKeymap::eShiftMode_Off: default: return m_keymap.isAutoCapActive() ? &m_shift_on.pixmap() : &m_shift.pixmap(); } break; case Qt::Key_Backspace: return &m_backspace.pixmap(); break; case cKey_Hide: return &m_hide.pixmap(); break; case cKey_Emoticon_Frown: return &m_emoticon_frown.pixmap(); break; case cKey_Emoticon_Cry: return &m_emoticon_cry.pixmap(); break; case cKey_Emoticon_Options: case cKey_Emoticon_Smile: return &m_emoticon_smile.pixmap(); break; case cKey_Emoticon_Wink: return &m_emoticon_wink.pixmap(); break; case cKey_Emoticon_Yuck: return &m_emoticon_yuck.pixmap(); break; case cKey_Emoticon_Gasp: return &m_emoticon_gasp.pixmap(); break; case cKey_Emoticon_Heart: return &m_emoticon_heart.pixmap(); break; default: /* NOP */; } return NULL; } void PhoneKeyboard::drawCenteredPixmap(QPainter & painter, QPixmap & pixmap, const QRect & location) { if (pixmap.height() > location.height() || pixmap.width() > location.width()) { //g_debug("TabletKeyboard::drawKeyCap shrinking \"%s\" by %d pixels", m_keymap.getKeyDisplayString(key, true).toUtf8().data(), location.height() - pixmap.height()); painter.setRenderHints(cRenderHints, true); if (pixmap.height() * location.width() > location.height() * pixmap.width()) { int targetWidth = location.height() * pixmap.width() / pixmap.height(); painter.drawPixmap(location.left() + (location.width() - targetWidth) / 2, location.top(), targetWidth, location.height(), pixmap); } else { int targetHeight = location.width() * pixmap.height() / pixmap.width(); painter.drawPixmap(location.left(), location.top() + (location.height() - targetHeight) / 2, location.width(), targetHeight, pixmap); } } else painter.drawPixmap((int) location.left() + (location.width() - pixmap.width()) / 2, (int) location.top() + (location.height() - pixmap.height()) / 2, pixmap); } inline bool boostSize(QChar c) { ushort ci = c.unicode(); return ci == '.' || ci == ',' || ci == ';' || ci == ':' || ci == '\'' || ci == '"'; } inline bool boostSize(QString s) { return s.size() == 1 && boostSize(s[0]); } //inline int font_size(const QString & text, const QColor & color, int baseSize, int percent) //{ // if (color != cActiveColor) // return baseSize * percent / 100; // return boostSize(text) ? baseSize + 2 : baseSize; //} #define font_size(text, color, baseSize, percent) ((color != activeColor) ? (baseSize * percent / 100) : (boostSize(text) ? baseSize + 2 : baseSize)) void PhoneKeyboard::drawKeyCap(QPainter * painter, GlyphRenderer<GlyphSpec> & renderer, QRect location, const QPoint & keyCoord, UKey key, EUse use) { location.setBottom(location.bottom() - 4); // if (pressed) // location.translate(cPressedTranslateH, cPressedTranslateV); QString text, altText; bool twoHorizontal = false; bool twoVertical = false; bool useTwo = false; QColor activeColor = useWhite(use) ? cActiveColor : cPopoutTextColor; QColor activeColor_back = useWhite(use) ? cActiveColor_back : cPopoutTextColor_back; QColor mainCharColor = activeColor; QColor mainCharColor_back = activeColor_back; QColor altCharColor = cDisabledColor; QColor altCharColor_back = cDisabledColor_back; bool capitalize = m_keymap.isCapOrAutoCapActive(); // bool capitalize = key >= Qt::Key_A && key <= Qt::Key_Z; if (key == Qt::Key_Space) text = m_candidateBar.autoSelectCandidate(); else if (UKeyIsUnicodeQtKey(key)) { // key is also a unicode character... UKey plain = m_keymap.map(keyCoord, PhoneKeymap::eLayoutPage_plain); UKey alt = m_keymap.map(keyCoord, PhoneKeymap::eLayoutPage_Alternate); if (plain != alt && alt != cKey_None) { useTwo = twoVertical = KeyCap_TwoVertical(keyCoord, plain); if (twoVertical) { if (key == plain) { text = capitalize ? QChar(plain) : QChar(plain).toLower(); altText = QChar(alt).toLower(); } else { mainCharColor = cDisabledColor; mainCharColor_back = cDisabledColor_back; altCharColor = activeColor; altCharColor_back = activeColor_back; text = QChar(plain).toLower(); altText = capitalize ? QChar(alt) : QChar(alt).toLower(); } } else text = capitalize ? QChar(key) : QChar(key).toLower(); } else text = capitalize ? QChar(key) : QChar(key).toLower(); } else if (((UKeyIsEmoticonKey(key) && m_keymap.showEmoticonsAsGraphics()) || (text = m_keymap.getKeyDisplayString(key)).size() == 0)) { if (painter) { QPixmap * pix = getPixmapForKey(key); if (pix) { int cPixMargin = UKeyIsEmoticonKey(key) ? 8 : 2; location.adjust(cPixMargin, cPixMargin, - cPixMargin, - cPixMargin); drawCenteredPixmap(*painter, *pix, location); } } } if (text.size() > 0) { sFont.setBold(useExtraLarge(use)); bool forceAlignHCenter = false; // if too tight, center text for better looking results int height = location.height(); int fontSize = useExtraLarge(use) ? 32 : 24; int centerOffset = 1; if (useTwo && use == eUse_preview) twoHorizontal = true, centerOffset = 2; if (height / 2 < fontSize) fontSize = (height + 1) / 2 + (useExtraLarge(use) ? 4 : 0); if (text.size() > 1) { if (!useExtraLarge(use)) sFont.setBold(UKeyIsFunctionKey(key) && !UKeyIsTextShortcutKey(key)); fontSize = qMin<int>(fontSize, 22); sFont.setPixelSize(fontSize); int gap; while ((gap = QFontMetrics(sFont).width(text) + 16 - location.width()) > 0) { forceAlignHCenter = true; int reduction = gap / text.length(); if (reduction < 1) reduction = 1; //g_debug("font size %d, Width = %d, gap = %d, reduction = %d", fontSize, location.width(), gap, reduction); fontSize -= reduction; sFont.setPixelSize(fontSize); }; if (gap > -8) forceAlignHCenter = true; //g_debug("Using font size %d, Width = %d, text width = %d", fontSize, location.width(), QFontMetrics(sFont).width(text)); } if (twoHorizontal) { if (mainCharColor == activeColor) location.adjust(4, 1, -5, 1); else location.adjust(5, 1, -4, 1); if (inLandscapeOrientation() == false) fontSize -= 1; QRect rect(location.left() + location.width() / 2 - centerOffset, location.top(), location.width() / 2, location.height()); renderer.render(rect, GlyphSpec(text, font_size(text, mainCharColor, fontSize, 75), sFont.bold(), mainCharColor, mainCharColor_back), sFont); rect.moveLeft(location.left() + centerOffset); renderer.render(rect, GlyphSpec(altText, font_size(altText, altCharColor, fontSize, 75), sFont.bold(), altCharColor, altCharColor_back), sFont); } else if (twoVertical) { int boxheight = location.height() / 3; QRect rect(location.left(), location.bottom() - boxheight - 10 + (boostSize(text) ? -2 : 0), location.width(), boxheight); renderer.render(rect, GlyphSpec(text, font_size(text, mainCharColor, fontSize, 75), sFont.bold(), mainCharColor, mainCharColor_back), sFont); rect.moveTop(location.top() + 10); renderer.render(rect, GlyphSpec(altText, font_size(altText, altCharColor, fontSize, 75), sFont.bold(), altCharColor, altCharColor_back), sFont); } else { /* if (key == Qt::Key_Return) { // Smaller, bottom right corner... location.setHeight((location.height()) * 90 / 100); if (forceAlignHCenter) renderer.render(location, GlyphSpec(text, qMin<int>(height, fontSize - 2), sFont.bold(), cFunctionColor, cFunctionColor_back), sFont, Qt::AlignBottom | Qt::AlignHCenter); else { location.setWidth(location.width() * 85 / 100 + m_9tileCorner.m_trimH); renderer.render(location, GlyphSpec(text, qMin<int>(height, fontSize - 2), sFont.bold(), cFunctionColor, cFunctionColor_back), sFont, Qt::AlignBottom | Qt::AlignRight); } } else */ { int size = qMin<int>(height, fontSize); if (key == cKey_ToggleLanguage && text.endsWith('-')) // special case: strike the language key if the language ends with '-' { QString realText = text.left(text.size() - 1); renderer.render(location, GlyphSpec(realText, size, sFont.bold(), mainCharColor, cFunctionColor_back), sFont); if (painter) { renderer.flush(); painter->setPen(QPen(QBrush(cActiveColor), 4, Qt::SolidLine, Qt::RoundCap)); int width = QFontMetrics(sFont).width(realText) / 2 + 4; int cx = (location.left() + location.right()) / 2; int cy = (location.top() + location.bottom()) / 2; painter->drawLine(cx - width, cy, cx + width, cy); } } else if (key == Qt::Key_Space) renderer.renderNow(location, GlyphSpec(text, size, sFont.bold(), mainCharColor, cFunctionColor_back), sFont); else renderer.render(location, GlyphSpec(text, size, sFont.bold(), mainCharColor, cFunctionColor_back), sFont); } } sFont.setBold(false); } } bool PhoneKeyboard::setShiftKeyDown(bool shiftKeyDown) { if (m_keymap.setShiftKeyDown(shiftKeyDown)) { // if (m_IMEDataInterface) // m_IMEDataInterface->sendKeyEvent(shiftKeyDown ? QEvent::KeyPress : QEvent::KeyRelease, Qt::Key_Shift, Qt::NoModifier); keyboardLayoutChanged(); return true; } return false; } bool PhoneKeyboard::setSymbolKeyDown(bool symbolKeyDown) { if (m_keymap.setSymbolKeyDown(symbolKeyDown)) { keyboardLayoutChanged(); return true; } return false; } void PhoneKeyboard::makeSound(UKey key) { if (VirtualKeyboardPreferences::instance().getTapSounds() && key != cKey_None) m_IMEDataInterface->keyDownAudioFeedback(key); } void PhoneKeyboard::queueIdlePrerendering() { if (!m_idleInit) { m_idleInit = true; g_idle_add_full(G_PRIORITY_LOW, keyboard_idle, NULL, NULL); } } bool PhoneKeyboard::idle() { // there is only ever one PhoneKeyboard. Using statics to avoid exposing everywhere variables only used here static int sCount = 0; static bool sInitExtendedGlyphs = true; if (m_IMEDataInterface->isUIAnimationActive()) return true; if (sCount < IMEPixmap::count()) { IMEPixmap::load(sCount++); return true; } int index = sCount++ - IMEPixmap::count(); int stateIndex = index / PhoneKeymap::cKeymapRows; int y = index % PhoneKeymap::cKeymapRows; if (stateIndex < 3) { // pre-rendering all keyboards states for the current size, one row at a time... DoubleDrawRenderer renderer; GlyphCachePopulator<GlyphSpec> populator(m_glyphCache, renderer); bool shiftDown = m_keymap.isShiftDown(); bool symbolDown = m_keymap.isSymbolDown(); bool autoCapActive = m_keymap.isAutoCapActive(); PhoneKeymap::EShiftMode shiftMode = m_keymap.shiftMode(); PhoneKeymap::ESymbolMode symbolMode = m_keymap.symbolMode(); m_keymap.setShiftKeyDown(false); m_keymap.setSymbolKeyDown(false); m_keymap.setAutoCap(false); if (stateIndex == 0) { m_keymap.setShiftMode(PhoneKeymap::eShiftMode_Off); m_keymap.setSymbolMode(PhoneKeymap::eSymbolMode_Off); } else if (stateIndex == 1) { m_keymap.setShiftMode(PhoneKeymap::eShiftMode_Once); m_keymap.setSymbolMode(PhoneKeymap::eSymbolMode_Off); } else { m_keymap.setShiftMode(PhoneKeymap::eShiftMode_CapsLock); m_keymap.setSymbolMode(PhoneKeymap::eSymbolMode_Lock); } std::string msg = string_printf("PhoneKeyboard pre-render (%dx%d): shift %d, symbol %d, autoCap %d, index=%d, y=%d", m_keymap.rect().width(), m_keymap.rect().height(), m_keymap.isShiftActive(), m_keymap.isSymbolActive(), m_keymap.isCapOrAutoCapActive(), stateIndex, y); PerfMonitor perf(msg.c_str()); //g_debug("%s", msg.c_str()); for (int x = 0; x < PhoneKeymap::cKeymapColumns; ++x) { QPoint keyCoord(x, y); UKey key = m_keymap.map(x, y); QRect r; int count = m_keymap.keyboardToKeyZone(keyCoord, r); r.moveTo(0, 0); if (count > 0 && key != Qt::Key_Space && key != cKey_None) { drawKeyCap(NULL, populator, r, keyCoord, key, eUse_unpressed); drawKeyCap(NULL, populator, r, keyCoord, key, eUse_pressed); drawKeyCap(NULL, populator, QRect(QPoint(), m_popup_key.size()), keyCoord, key, eUse_preview); drawKeyCap(NULL, populator, QRect(QPoint(), m_popup_key.size()), keyCoord, key, eUse_extended); } } m_keymap.setShiftKeyDown(shiftDown); m_keymap.setSymbolKeyDown(symbolDown); m_keymap.setAutoCap(autoCapActive); m_keymap.setShiftMode(shiftMode); m_keymap.setSymbolMode(symbolMode); return true; } else if (stateIndex == 0 && y == 0) { // pre-rendering background, with 9-tiled keys updateBackground(); return true; } else if (sInitExtendedGlyphs) { // pre-render extended chars, but only once per run (they are always shown at the same size & same color) DoubleDrawRenderer renderer; GlyphCachePopulator<GlyphSpec> populator(m_glyphCache, renderer); static int x = -1; static int y = -1; static const UKey * extendedChars = NULL; static int extendedIndex = 0; if (x < 0 || y < 0 || x >= PhoneKeymap::cKeymapColumns || y >= PhoneKeymap::cKeymapRows) { x = y = 0; extendedChars = m_keymap.getExtendedChars(QPoint(x, y)); extendedIndex = 0; } uint64_t timeLimit = CURRENT_TIME + 10; // process 10ms max do { if (extendedChars) { //g_debug("pre-render %dx%d %s...", x, y, QString(QChar(extendedChars[extendedIndex])).toUtf8().data()); if (UKeyIsUnicodeQtKey(extendedChars[extendedIndex])) { populator.render(QRect(QPoint(), m_popup_key.size()), GlyphSpec(QString(QChar(extendedChars[extendedIndex]).toLower()), cPopupFontSize, false, cPopoutTextColor, cPopoutTextColor_back), sFont); populator.render(QRect(QPoint(), m_popup_key.size()), GlyphSpec(QString(QChar(extendedChars[extendedIndex]).toUpper()), cPopupFontSize, false, cPopoutTextColor, cPopoutTextColor_back), sFont); } if (!extendedChars[++extendedIndex]) extendedChars = NULL; } if (!extendedChars) { if (++x >= PhoneKeymap::cKeymapColumns) { x = 0; if (++y >= PhoneKeymap::cKeymapRows) break; } extendedChars = m_keymap.getExtendedChars(QPoint(x, y)); extendedIndex = 0; } if (CURRENT_TIME > timeLimit) return true; } while (true); sInitExtendedGlyphs = false; // cache elipsis... populator.render(QRect(0, 0, 20, 20), GlyphSpec(sElipsis, cElipsisFontSize, false, cActiveColor, cActiveColor_back), sFont); } m_keymap.incCachedGlyphs(); sCount = IMEPixmap::count(); m_idleInit = false; //g_debug("PhoneKeyboard background init complete!"); #if 0 #ifdef TARGET_DEVICE m_glyphCache.pixmap().toImage().save("/media/internal/glyphcache.png"); #else m_glyphCache.pixmap().toImage().save(QString(getenv("HOME")) + "/Desktop/glyphcache.png"); #endif #endif return false; } }; // namespace Phone_Keyboard
34.445602
271
0.707453
ericblade
9ef12f1194d9b7fd6992a0f83ae2c1dda78d3b04
30,109
cpp
C++
src/Tableau.cpp
gjo11/causaloptim
81155ff1aeef5cd2618f2498ba6b779d5a944cff
[ "MIT" ]
13
2019-11-28T16:33:10.000Z
2021-12-10T12:03:35.000Z
src/Tableau.cpp
boennecd/causaloptim
b32016510e64ca4c688ff7df9fcf049404223630
[ "MIT" ]
8
2020-05-04T14:32:49.000Z
2021-12-09T13:10:07.000Z
src/Tableau.cpp
boennecd/causaloptim
b32016510e64ca4c688ff7df9fcf049404223630
[ "MIT" ]
3
2020-04-22T23:18:06.000Z
2020-12-10T09:32:05.000Z
//#include <afx.h> #include <R.h> //#include <windows.h> #include <stdlib.h> #include <stdio.h> #include <string> #include <math.h> #include "MyUtils.h" #include "Tableau.h" #define AUG_COST -1000000.00 #define LEEWAY ((double) 0.00001) #define LINE_LEN 1024 #define MAX_SOL 50.00 float SolFactor[3] = // Indexed by TERM_SIGN {-1.0f, 0.0f, +1.0f}; float SymFactor[3] = // Indexed by TERM_SIGN {+1.0f, +1.0f, -1.0f}; void Approx (double & p_Value, double p_Point) { if (p_Value < p_Point + LEEWAY && p_Value > p_Point - LEEWAY) p_Value = p_Point; } /* Approx () */ CTableau :: CTableau ( int p_ParamCnt, int p_Rows, Label_ p_pParamNames[], pFloat_ * p_pA, double * p_pb //************************ // Ax <= b //************************ ) { Setup (p_ParamCnt, p_Rows, p_pParamNames, p_pA, p_pb); } /* CTableau :: CTableau () */ void CTableau :: Setup ( int p_ParamCnt, int p_Rows, Label_ p_pParamNames[], pFloat_ * p_pA, double * p_pb //************************ // Ax <= b //************************ ) { int nParam; int nVar; int nRow; int nBasis; int nAug; double Coef; double YCoef; m_pEnumList = NULL; m_pEnumCrnt = NULL; m_EnumListLen = 0; memset (m_pVertices, NULL, sizeof (m_pVertices)); // Check that the number of rows is greater than the number of parameters. // if (p_Rows <= p_ParamCnt) { //Rprintf ("ERROR: Let A be a mxn matrix. m must be greater than n.\n"); error ("ERROR: Let A be a mxn matrix. m must be greater than n.\n"); } // //**************************************************************** // Get the names of all the parameters. // m_ParamCnt = p_ParamCnt; m_pParamNames = new Label_ [m_ParamCnt]; for (nParam = 0; nParam < m_ParamCnt; nParam++) strcpy (m_pParamNames [nParam], p_pParamNames [nParam]); //************************ // Determine how many augmented variables must be added. // This is just the number of negative entries in the solution // vector 'b'. m_AugCnt = 0; for (nRow = 0; nRow < p_Rows; nRow++) { if (p_pb [nRow] < 0.0) m_AugCnt++; } //********************************************************** // Evaluate the number of variables required and label them. m_VarCnt = 1 + m_ParamCnt + 1 + p_Rows + m_AugCnt; m_pVarLabels = new Label_ [m_VarCnt]; strcpy (m_pVarLabels [0], "nz"); for (nParam = 0; nParam < m_ParamCnt; nParam++) { nVar = 1 + nParam; strcpy (m_pVarLabels [nVar], p_pParamNames [nParam]); } strcpy (m_pVarLabels [1 + m_ParamCnt], "y"); for (nRow = 0; nRow < p_Rows; nRow++) { nVar = 1 + m_ParamCnt + 1 + nRow; sprintf (m_pVarLabels [nVar], "$%02d", nRow); } for (nAug = 0; nAug < m_AugCnt; nAug++) { nVar = 1 + m_ParamCnt + 1 + p_Rows + nAug; sprintf (m_pVarLabels [nVar], "@%02d", nAug); } //************************************** // Determine the size of the basis for this problem. m_BasisCnt = p_Rows + 1; //*********************************************************** // Done incorporating optimization problem parameters. // Allocate the space for the Tableau. //*********************************************************** m_pOrigBasisVars = new int [m_BasisCnt]; memset (m_pOrigBasisVars, 0, m_BasisCnt * sizeof (int)); m_pBasisVars = new int [m_BasisCnt]; memset (m_pBasisVars, 0, m_BasisCnt * sizeof (int)); m_pOrigSolution = new double [m_BasisCnt]; memset (m_pOrigSolution, 0, m_BasisCnt * sizeof (double)); m_pSolution = new double [m_BasisCnt]; memset (m_pSolution, 0, m_BasisCnt * sizeof (double)); m_pCj = new double [m_VarCnt]; memset (m_pCj, 0, m_VarCnt * sizeof (double)); m_pOrigTable = new pFloat_ [m_BasisCnt]; m_pTable = new pFloat_ [m_BasisCnt]; for (nBasis = 0; nBasis < m_BasisCnt; nBasis++) { m_pOrigTable [nBasis] = new double [m_VarCnt]; memset (m_pOrigTable [nBasis], 0, m_VarCnt * sizeof(double)); m_pTable [nBasis] = new double [m_VarCnt]; memset (m_pTable [nBasis], 0, m_VarCnt * sizeof(double)); } //****************************** // Instantiate the Tableau from the given matrix, A. m_pOrigTable [0][0] = 1.0; m_pOrigTable [0][1 + m_ParamCnt] = 1.0; m_pCj [1 + m_ParamCnt] = 1.0; nAug = 0; for (nRow = 0; nRow < p_Rows; nRow++) { nBasis = nRow + 1; //**************************** // Determine the set of variables to use in the basis, // and set the table coefficients for the augmented // variables. // Also determine the coefficient to be used for the // current basis row. //*************************** if (p_pb [nRow] < 0) { //*********************************** // The slack variable will have a negative // coefficient; use an augmented variable // in the basis. //*********************************** Coef = -1.0; nVar = 1 + m_ParamCnt + 1 + p_Rows + nAug; m_pOrigTable [nBasis][nVar] = 1.0; m_pCj [nVar] = AUG_COST; m_pOrigBasisVars [nBasis] = nVar; nAug++; } else { //************************************ // Use the slack variable in the basis. //************************************ nVar = 1 + m_ParamCnt + 1 + nRow; m_pOrigBasisVars [nBasis] = nVar; Coef = 1.0; } //************************************** // Set the entries corresponding to the user defined // parameters. // At the same time compute the coefficient for the // 'y' variable. //************************************** YCoef = 0.0; for (nParam = 0; nParam < m_ParamCnt; nParam++) { nVar = 1 + nParam; m_pOrigTable [nBasis][nVar] = Coef * p_pA [nRow][nParam]; YCoef += p_pA [nRow][nParam] * p_pA [nRow][nParam]; } nVar = 1 + m_ParamCnt; m_pOrigTable [nBasis][nVar] = Coef * sqrt (YCoef); //************************************** // Set the entries corresponding to the slack variables. //************************************** nVar = 1 + m_ParamCnt + 1 + nRow; m_pOrigTable [nBasis][nVar] = Coef; //***************************************** // Set the solution value to be non-negative. //**************************************** m_pOrigSolution [nBasis] = Coef * p_pb [nRow]; } //******************************* // Copy the original tableau over to the working copy. //******************************* Reset (); m_VertexCnt = 0; m_pSlackFlag = new char [m_BasisCnt - 1]; memset (m_pSlackFlag, 0, (m_BasisCnt - 1) * sizeof (char)); } /* CTableau :: Setup () */ CTableau :: CTableau (FILE * p_pFile) { char szLine [LINE_LEN]; char szWord [LINE_LEN]; char bMinimize; int ParamCnt; int ConstCnt; Label_ * pParamNames; String_ * pszConstraints; String_ szObjective; int nParam; int nConst; int ScanRslt; char* objGet; //***************************************************************** // Determine whether to Minimize or Maximize the objective // function. // while (1) { if (fgets (szLine, LINE_LEN, p_pFile) == 0) { //printf ("ERROR: didn't find Min/Max specifier\n"); error ("ERROR: didn't find Min/Max specifier\n"); } sscanf (szLine, "%s", szWord); if (strcmp (szWord, "MAXIMIZE") == 0) { bMinimize = 0; break; } if (strcmp (szWord, "MINIMIZE") == 0) { bMinimize = 1; break; } } // //**************************************************************** // Get the number of parameters. // while (1) { if (fgets (szLine, LINE_LEN, p_pFile) == 0) { //Rprintf ("ERROR: didn't find 'PARAMETERS'\n"); error ("ERROR: didn't find 'PARAMETERS'\n"); } sscanf (szLine, "%s", szWord); if (strcmp (szWord, "PARAMETERS") == 0) break; } ParamCnt = 0; while (1) { if (fgets (szLine, LINE_LEN, p_pFile) == 0) { //Rprintf ("ERROR: no 'CONSTRAINTS' line\n"); error ("ERROR: no 'CONSTRAINTS' line\n"); } if (sscanf (szLine, "%s", szWord) >= 0) { if (strcmp (szWord, "CONSTRAINTS") == 0) break; else ParamCnt++; } } pParamNames = new Label_ [ParamCnt]; // //**************************************************************** // Get the number of constraints. // ConstCnt = 0; while (1) { if (fgets (szLine, LINE_LEN, p_pFile) == 0) { //Rprintf ("ERROR: no 'OBJECTIVE' line\n"); error ("ERROR: no 'OBJECTIVE' line\n"); } if (sscanf (szLine, "%s", szWord) >= 0) { if (strcmp (szWord, "OBJECTIVE") == 0) break; else ConstCnt++; } } pszConstraints = new String_ [ConstCnt]; // //****************************************************** // Copy the objective function // objGet = fgets (szObjective, LINE_LEN, p_pFile); // Go back to beginning of file. rewind (p_pFile); // //************************************************ // Find the parameter names and copy them. // while (1) { if (fgets (szLine, LINE_LEN, p_pFile) == 0) { //printf ("ERROR: didn't find 'PARAMETERS'\n"); error ("ERROR: didn't find 'PARAMETERS'\n"); } sscanf (szLine, "%s", szWord); if (strcmp (szWord, "PARAMETERS") == 0) break; } nParam = 0; while (1) { if (fgets (szLine, LINE_LEN, p_pFile) == 0) { //Rprintf ("ERROR: no 'CONSTRAINTS' line\n"); error ("ERROR: no 'CONSTRAINTS' line\n"); } if (sscanf (szLine, "%s", szWord) >= 0) { if (strcmp (szWord, "CONSTRAINTS") == 0) break; else { strcpy (pParamNames [nParam], szWord); nParam++; } } } // //**************************************** // Find the constraints and copy them. // nConst = 0; while (1) { if (fgets (szLine, LINE_LEN, p_pFile) == 0) { //Rprintf ("ERROR: no 'OBJECTIVE' line\n"); error ("ERROR: no 'OBJECTIVE' line\n"); } if (sscanf (szLine, "%s", szWord) >= 0) { if (strcmp (szWord, "OBJECTIVE") == 0) break; else { strcpy (pszConstraints [nConst], szLine); nConst++; } } } // Setup (p_bVertices, bMinimize, ParamCnt, pParamNames, // ConstCnt, pszConstraints, szObjective); } /* CTableau :: CTableau () */ //====================================== // FUNCTION: Reset // PURPOSE: // Sets the Working Tableau equal to the Original Tableau. //====================================== void CTableau :: Reset () { int nBasis; int nVar; for (nBasis = 0; nBasis < m_BasisCnt; nBasis++) { m_pSolution [nBasis] = m_pOrigSolution [nBasis]; m_pBasisVars [nBasis] = m_pOrigBasisVars [nBasis]; } for (nVar = 0; nVar < m_VarCnt; nVar++) { for (nBasis = 0; nBasis < m_BasisCnt; nBasis++) { m_pTable [nBasis] [nVar] = m_pOrigTable [nBasis] [nVar]; } } } /* CTableau :: Reset () */ CTableau :: ~CTableau () { CEnumRcd * pNextRcd; CEnumRcd * pEnumRcd; for (int nBasis = 0; nBasis < m_BasisCnt; nBasis++) { delete [] m_pOrigTable [nBasis]; delete [] m_pTable [nBasis]; } delete [] m_pTable; delete [] m_pOrigTable; delete [] m_pBasisVars; delete [] m_pOrigBasisVars; delete [] m_pSolution; delete [] m_pOrigSolution; delete [] m_pCj; delete [] m_pSlackFlag; // delete m_pConstraints; // delete m_pObjective; delete m_pVarLabels; delete m_pParamNames; for (int nVertex = 0; nVertex < MAX_VERTICES; nVertex++) if (m_pVertices [nVertex]) delete [] m_pVertices [nVertex]; pEnumRcd = m_pEnumList; while (pEnumRcd) { pNextRcd = pEnumRcd-> m_pNext; delete [] pEnumRcd-> Contents (); delete pEnumRcd; pEnumRcd = pNextRcd; } } /* CTableau :: ~CTableau () */ /*======================================= | FUNCTION: TradeBasis | PURPOSE: | Swaps the indicated non-basis variable for the specified | basis variable. ========================================*/ void CTableau :: TradeBasis (int p_Basis, int p_Var) { double Pivot; double Factor; int nVar; int nBasis; Pivot = m_pTable [p_Basis] [p_Var]; m_pBasisVars [p_Basis] = p_Var; m_pSolution [p_Basis] /= Pivot; for (nVar = 0; nVar < m_VarCnt; nVar++) { m_pTable [p_Basis] [nVar] /= Pivot; } for (nBasis = 0; nBasis < m_BasisCnt; nBasis++) { if (nBasis != p_Basis) { Factor = m_pTable [nBasis] [p_Var]; m_pSolution [nBasis] -= Factor * m_pSolution [p_Basis]; Approx (m_pSolution [nBasis], 0.0); for (nVar = 0; nVar < m_VarCnt; nVar++) { m_pTable [nBasis] [nVar] -= Factor * m_pTable [p_Basis] [nVar]; Approx (m_pTable [nBasis][nVar], 0.0); } } } } /* CTableau :: TradeBasis () */ std::string CTableau :: DecisionDisplay () { int nBasis; int nVar; char buffer[100]; std::string result; result.append ("Basis"); for (nBasis = 0; nBasis < m_BasisCnt; nBasis++) { sprintf (buffer, "%7s", m_pVarLabels [m_pBasisVars [nBasis]]); result.append (buffer); } result.append ("\n"); for (nVar = 0; nVar < m_VarCnt; nVar++) { // Display only the nonbasis variables. for (nBasis = 0; nBasis < m_BasisCnt; nBasis++) if (m_pBasisVars [nBasis] == nVar) break; if (nBasis < m_BasisCnt) continue; sprintf (buffer, "%7s", m_pVarLabels [nVar]); result.append(buffer); for (nBasis = 0; nBasis < m_BasisCnt; nBasis++) { sprintf (buffer, "%7.3lf", m_pTable [nBasis][nVar]); result.append(buffer); } result.append ("\n"); } result.append ( "Sol"); for (nBasis = 0; nBasis < m_BasisCnt; nBasis++) { sprintf (buffer, "%7.3lf", m_pSolution [nBasis]); result.append(buffer); } result.append ("\n\n"); return result; } /* CTableau :: DecisionDisplay () */ /*================================= | FUNCTION: DetermineSwap | PURPOSE: | Determines which non-basis and basis variable to swap. ===================================*/ void CTableau :: DetermineSwap (int & p_Basis, int & p_Var) { int nBasis; int nVar; int nFirstAug; double Contr; double MaxPosContr = 0.0; double Ratio; double MinRatio; p_Var = -1; for (nVar = 1; nVar < m_VarCnt; nVar++) { //=============================== // Compute zj-cj for this column //=============================== Contr = m_pCj [nVar]; for (nBasis = 1; nBasis < m_BasisCnt; nBasis++) { Contr -= m_pTable [nBasis][nVar] * m_pCj [m_pBasisVars [nBasis]]; } if (Contr > MaxPosContr) { MaxPosContr = Contr; p_Var = nVar; } } if (p_Var < 0) { return; } p_Basis = -1; MinRatio = 1000000.0; for (nBasis = 1; nBasis < m_BasisCnt; nBasis++) { if (m_pTable [nBasis] [p_Var] > LEEWAY) { Ratio = m_pSolution [nBasis] / m_pTable [nBasis] [p_Var]; if (Ratio >= 0.0 && Ratio < MinRatio) { MinRatio = Ratio; p_Basis = nBasis; } } } } /* CTableau :: DetermineSwap () */ double CTableau :: GetSolution (char * p_szVarName) { for (int nBasis = 0; nBasis < m_BasisCnt; nBasis++) { if (strcmp (p_szVarName, m_pVarLabels [m_pBasisVars [nBasis]]) == 0) { return m_pSolution [nBasis]; } } return 0.0; } /* CTableau :: GetValue () */ double CTableau :: ObjectiveValue () { return -m_pSolution [0]; } /* CTableau :: ObjectiveValue () */ char CTableau :: Optimize () { int nVar; int Var; int Basis; //#define MYDEBUG while (1) { #ifdef MYDEBUG DecisionDisplay (); #endif DetermineSwap (Basis, Var); #ifdef MYDEBUG Rprintf ("Var: %4s, Basis: %4s\n", m_pVarLabels [Var], m_pVarLabels [m_pBasisVars[Basis]]); #endif if (Var < 0 || Basis < 0) break; TradeBasis (Basis, Var); } return 1; } /* CTableau :: Optimize () */ void CTableau :: DisplayBasis () { int nBasis; for (nBasis = 0; nBasis < m_BasisCnt; nBasis++) { Rprintf ("%s: %lf\n", m_pVarLabels [m_pBasisVars [nBasis]], m_pSolution [nBasis]); } } /* CTableau :: DisplayBasis () */ void CTableau :: DisplayParams () { int nVar; int nBasis; for (nVar = m_BasisCnt; nVar < m_BasisCnt + m_ParamCnt; nVar++) { for (nBasis = 0; nBasis < m_BasisCnt; nBasis++) { if (nVar == m_pBasisVars [nBasis]) { Rprintf ("%5s: %lf\n", m_pVarLabels [nVar], m_pSolution [nBasis]); break; } } } } /* CTableau :: DisplayParams () */ void CTableau :: DropVars () { m_VarCnt = 1 + m_ParamCnt + 1 + (m_BasisCnt - 1); m_AugCnt = 0; // Changing these values will not affect the later deallocation of the // Tableau. } /* CTableau :: DropVars () */ //====================================== // FUNCTION: WorkToOrig // PURPOSE: // Sets the Original Tableau equal to the Working Tableau. //====================================== void CTableau :: WorkToOrig () { int nBasis; int nVar; for (nBasis = 0; nBasis < m_BasisCnt; nBasis++) { m_pOrigSolution [nBasis] = m_pSolution [nBasis]; m_pOrigBasisVars [nBasis] = m_pBasisVars [nBasis]; } for (nVar = 0; nVar < m_VarCnt; nVar++) { for (nBasis = 0; nBasis < m_BasisCnt; nBasis++) { m_pOrigTable [nBasis] [nVar] = m_pTable [nBasis] [nVar]; } } } /* CTableau :: WorkToOrig () */ WORD * CTableau :: PopFirst () { int * pNonBasics; CEnumRcd * pNextRcd; CEnumRcd * pEnumRcd; double CrntValue; double NewValue; int nNonBasis; if (m_pEnumList == NULL) return NULL; if (m_pEnumCrnt == NULL) { m_pEnumCrnt = m_pEnumList; return m_pEnumCrnt-> Contents (); } if (m_pEnumCrnt-> m_pNext == NULL) { // printf ("No more records, deleting all:\n"); // DisplayEnumRcds (); return NULL; } CrntValue = m_pEnumCrnt-> Value (); NewValue = m_pEnumCrnt-> m_pNext-> Value (); m_pEnumCrnt = m_pEnumCrnt-> m_pNext; if (NewValue > CrntValue + LEEWAY) { //Rprintf ("ERROR: The list is not monotonically non-increasing.\n"); error ("ERROR: The list is not monotonically non-increasing.\n"); } if (NewValue < CrntValue - LEEWAY) { //================================= // Remove all the preceding elements in the // list. They are no longer needed for eliminating // duplicates. //================================== pEnumRcd = m_pEnumList; while (pEnumRcd != m_pEnumCrnt) { // printf ("Deleting record: %6.3lf :", pEnumRcd-> Value ()); // for (nNonBasis = 0; nNonBasis < m_VarCnt - m_BasisCnt; // nNonBasis++) // { // printf (" %4s", m_pVarLabels [ // (pEnumRcd-> Contents ()) [nNonBasis]]); // } // printf ("\n"); pNextRcd = pEnumRcd-> m_pNext; delete [] pEnumRcd-> Contents (); delete pEnumRcd; pEnumRcd = pNextRcd; m_EnumListLen--; } m_pEnumList = m_pEnumCrnt; // DisplayEnumRcds (); } return m_pEnumCrnt-> Contents (); } /* CTableau :: PopFirst () */ void CTableau :: AddUnique (double p_Value, WORD * p_pNonBasics) { CEnumRcd * pCurrent; CEnumRcd ** ppPrior; CEnumRcd * pNew; double Value; int nNonBasis; // printf (":v%lf", p_Value); ppPrior = &m_pEnumList; pCurrent = m_pEnumList; while (pCurrent != NULL) { Value = pCurrent-> Value (); if (p_Value < Value + LEEWAY && p_Value > Value - LEEWAY) { // See if the new record is non-unique. // This assumes that the non-basic variables are // always ordered by index value. for (nNonBasis = 0; nNonBasis < m_VarCnt - m_BasisCnt; nNonBasis++) { if (p_pNonBasics [nNonBasis] != (pCurrent-> Contents ())[nNonBasis]) break; } if (nNonBasis == m_VarCnt - m_BasisCnt) { // NonBasis is not unique; do not add to list. delete [] p_pNonBasics; return; } } else if (p_Value > Value) { pNew = new CEnumRcd (p_Value, p_pNonBasics); *ppPrior = pNew; pNew-> m_pNext = pCurrent; m_EnumListLen++; return; } ppPrior = &(pCurrent-> m_pNext); pCurrent = pCurrent-> m_pNext; } pNew = new CEnumRcd (p_Value, p_pNonBasics); *ppPrior = pNew; m_EnumListLen++; } /* CTableau :: AddUnique () */ void CTableau :: DisplayEnumRcds () { CEnumRcd * pCurrent; WORD * pNonBasis; int nNonBasis; Rprintf ("Contents of Enum List\n"); pCurrent = m_pEnumList; while (pCurrent != NULL) { Rprintf ("\t%6.3lf : ", pCurrent-> Value ()); pNonBasis = pCurrent-> Contents (); for (nNonBasis = 0; nNonBasis < m_VarCnt - m_BasisCnt; nNonBasis++) { Rprintf ("%4s ", m_pVarLabels [pNonBasis [nNonBasis]]); } if (pCurrent == m_pEnumCrnt) Rprintf (" **"); Rprintf ("\n"); pCurrent = pCurrent-> m_pNext; } } /* CTableau :: DisplayEnumRcds () */ std::string CTableau :: VertexEnumerate () { int nBasis; int nNonBasis; int nSlack; WORD * pNonBasics; int nVar; int PivotBasis; double MinRatio; double Ratio; double * pNewSol; int * pBasisVars; double Factor; double Pivot; char szResponse[100]; char buffer[1024]; std::string result; result.append ("Table before optimizing Y.\n"); result.append ("--------------------------\n"); pNewSol = new double [m_BasisCnt]; pBasisVars = new int [m_BasisCnt]; result.append(DecisionDisplay ()); Optimize (); DropVars (); WorkToOrig (); AddEnumRcd (m_pBasisVars, - m_pSolution[0]); // DisplayEnumRcds (); while ((pNonBasics = PopFirst ()) != NULL) { // printf ("Analyzing: "); // for (nNonBasis = 0; nNonBasis < m_VarCnt - m_BasisCnt; nNonBasis++) // { // printf (" %4s", m_pVarLabels [pNonBasics [nNonBasis]]); // } // printf ("\n"); R_CheckUserInterrupt(); GenerateTableau (pNonBasics); // Flag all the nonbasic slack variables. This is later used to // identify relevant constraints. for (nNonBasis = 0; nNonBasis < m_VarCnt - m_BasisCnt; nNonBasis++) { m_pSlackFlag [pNonBasics [nNonBasis] - m_ParamCnt - 2] = 1; } // DecisionDisplay (); for (nNonBasis = 0; nNonBasis < m_VarCnt - m_BasisCnt; nNonBasis++) { nVar = pNonBasics [nNonBasis]; #ifdef MYDEBUG Rprintf ("NonBasis [%d] = %4s\n", nNonBasis, m_pVarLabels [pNonBasics [nNonBasis]]); #endif if (m_pTable [0][nVar] > LEEWAY) continue; //============================== // Find the basis to pivot on. //============================== MinRatio = 1000000.0; for (nBasis = 1; nBasis < m_BasisCnt; nBasis++) { if (m_pTable [nBasis] [nVar] > LEEWAY && m_pSolution [nBasis] >= -LEEWAY) { Ratio = m_pSolution [nBasis] / m_pTable [nBasis] [nVar]; if (Ratio >= - LEEWAY && Ratio < MinRatio) { MinRatio = Ratio; } } } for (PivotBasis = 1; PivotBasis < m_BasisCnt; PivotBasis++) { R_CheckUserInterrupt(); if (m_pTable [PivotBasis] [nVar] <= LEEWAY) continue; Ratio = m_pSolution [PivotBasis] / m_pTable [PivotBasis] [nVar]; if (Ratio < -LEEWAY || Ratio > MinRatio + LEEWAY) continue; if (m_pBasisVars [PivotBasis] >= 1 && m_pBasisVars [PivotBasis] < 1 + m_ParamCnt) //================================== // Pivot is a user-defined parameter. //================================== continue; for (nBasis = 0; nBasis < m_BasisCnt; nBasis++) { pNewSol [nBasis] = m_pSolution [nBasis]; pBasisVars [nBasis] = m_pBasisVars [nBasis]; } //=============================== // Evaluate the new solutions and basis // variables given the pivot point. //=============================== Pivot = m_pTable [PivotBasis] [nVar]; pBasisVars [PivotBasis] = nVar; pNewSol [PivotBasis] /= Pivot; for (nBasis = 0; nBasis < m_BasisCnt; nBasis++) { if (nBasis != PivotBasis) { Factor = m_pTable [nBasis] [nVar]; pNewSol [nBasis] -= Factor * pNewSol [PivotBasis]; } } // printf ("Pivot %5s for %5s\n", // m_pVarLabels [nVar], // m_pVarLabels [m_pBasisVars [PivotBasis]]); if (m_pBasisVars [PivotBasis] == 1 + m_ParamCnt) { //=================================== // Pivot is Y. //=================================== AddVertex (pBasisVars, pNewSol); // printf ("\nVERTEX:\n"); // for (nBasis = 0; nBasis < m_BasisCnt; nBasis++) // { // printf ("\t%5s: %lf\n", // m_pVarLabels [pBasisVars [nBasis]], // pNewSol [nBasis]); // } } else { //=================================== // Pivot is a slack variable. //=================================== // If Y = 0.0, then the solution corresponds to a // point in the n-dim space, K; therefore, do not // add the point as a subsystem in the (n+1)-dim // space (currently, I do not know if this is // absolutely correct). if (- pNewSol [0] > LEEWAY) { AddEnumRcd (pBasisVars, - pNewSol [0]); } } } } } result.append(DisplayVertices ()); result.append ("Irrelevant contraints:\n"); for (nSlack = 0; nSlack < m_BasisCnt - 1; nSlack++) { if (m_pSlackFlag [nSlack] == 0) { sprintf (buffer, "\t%d\n", nSlack); result.append(buffer); } } delete [] pNewSol; return result; } /* CTableau :: VertexEnumerate () */ void CTableau :: GenerateTableau (WORD * p_pNonBasics) { int nRow; int nVar; int nNonBasis = 0; char * pbBasis; int nBasis; int MaxRow; double MaxAbs; double FTemp; pbBasis = new char [m_VarCnt]; Reset (); memset (pbBasis, 1, m_VarCnt * sizeof (char)); for (nNonBasis = 0; nNonBasis < m_VarCnt - m_BasisCnt; nNonBasis++) pbBasis [p_pNonBasics [nNonBasis]] = 0; nBasis = 1; for (nVar = 1; nVar < m_VarCnt; nVar++) { if (pbBasis [nVar]) { m_pBasisVars [nBasis] = nVar; nBasis++; } } if (nBasis != m_BasisCnt) { //Rprintf ("ERROR: GenerateTableau: incorrect basis count.\n"); error ("ERROR: GenerateTableau: incorrect basis count.\n"); } for (nBasis = 1; nBasis < m_BasisCnt; nBasis++) { nVar = m_pBasisVars [nBasis]; if (m_pTable [nBasis][nVar] < LEEWAY && m_pTable [nBasis][nVar] > -LEEWAY) { //=========================== // Make sure the pivot element is not zero. //============================= MaxRow = 0; MaxAbs = 0.0; for (nRow = nBasis; nRow < m_BasisCnt; nRow++) { FTemp = m_pTable [nRow][nVar]; FTemp = fabs(FTemp); if (FTemp > MaxAbs) { MaxRow = nRow; MaxAbs = FTemp; } } FactorAddRows (MaxRow, nBasis, 1.0); } DivideRow (nBasis, m_pTable [nBasis][nVar]); for (nRow = 0; nRow < m_BasisCnt; nRow++) { if (nRow != nBasis) FactorAddRows (nBasis, nRow, -m_pTable [nRow][nVar]); } } delete [] pbBasis; } /* CTableau :: GenerateTableau () */ void CTableau :: DivideRow (int p_Basis, double p_Divisor) { int nVar; if (p_Divisor < LEEWAY && p_Divisor > -LEEWAY) return; m_pSolution [p_Basis] /= p_Divisor; for (nVar = 1; nVar < m_VarCnt; nVar++) { m_pTable [p_Basis][nVar] /= p_Divisor; } } /* CTableau :: DivideRow () */ void CTableau :: FactorAddRows (int p_SrcRow, int p_TgtRow, double p_Factor) { int nVar; m_pSolution [p_TgtRow] += p_Factor * m_pSolution [p_SrcRow]; for (nVar = 1; nVar < m_VarCnt; nVar++) { m_pTable [p_TgtRow][nVar] += p_Factor * m_pTable [p_SrcRow][nVar]; } } /* CTableau :: AddRows () */ void CTableau :: AddEnumRcd (int * p_pBasisVars, double p_Value) { int nVar; int nBasis; char * pbBasis; WORD * pNonBasis; int nNonBasis; pbBasis = new char [m_VarCnt]; pNonBasis = new /*int*/ WORD [m_VarCnt - m_BasisCnt]; memset (pbBasis, 0, m_VarCnt * sizeof (char)); for (nBasis = 0; nBasis < m_BasisCnt; nBasis++) { pbBasis[p_pBasisVars [nBasis]] = 1; } nNonBasis = 0; for (nVar = 0; nVar < m_VarCnt; nVar++) { if (pbBasis [nVar] == 0) { pNonBasis[nNonBasis] = (WORD) nVar; nNonBasis++; } } AddUnique (p_Value, pNonBasis); //printf (":%d", m_EnumListLen); delete [] pbBasis; // printf ("\nAdding Enum Record: %6.3lf :", p_Value); // for (nNonBasis = 0; nNonBasis < m_VarCnt - m_BasisCnt; nNonBasis++) // { // printf (" %4s", m_pVarLabels [pNonBasis [nNonBasis]]); // } // printf ("\n"); // DisplayEnumRcds (); } /* CTableau :: AddEnumRcd () */ void CTableau :: AddVertex (int * p_pBasisVars, double * p_pSolution) { double * pVertex; int nBasis; int nParam; int nVertex; double NewVal; double OldVal; if (m_VertexCnt >= MAX_VERTICES) { error ("ERROR: Exceeded maximum number of vertices.\n"); return; } pVertex = new double [m_ParamCnt]; memset (pVertex, 0, m_ParamCnt * sizeof (double)); for (nBasis = 1; nBasis < m_BasisCnt; nBasis++) { if (p_pBasisVars [nBasis] >= 1 && p_pBasisVars [nBasis] <= m_ParamCnt) { pVertex [p_pBasisVars [nBasis] - 1] = p_pSolution [nBasis]; } } //============================ // Check that all coordinates in the vertex are // not positively extreme. Otherwise, do not add vertex. //============================ for (nVertex = 0; nVertex < m_ParamCnt; nVertex++) { if (pVertex [nVertex] > MAX_SOL) { delete [] pVertex; //printf ("-"); return; } } //============================ // Check vertex for uniqueness. //============================ for (nVertex = 0; nVertex < m_VertexCnt; nVertex++) { for (nParam = 0; nParam < m_ParamCnt; nParam++) { NewVal = pVertex [nParam]; OldVal = m_pVertices [nVertex][nParam]; if (NewVal < OldVal - LEEWAY || NewVal > OldVal + LEEWAY) break; } if (nParam == m_ParamCnt) break; // Duplicate found. } if (nVertex == m_VertexCnt) { // Vertex is unique. m_pVertices [m_VertexCnt] = pVertex; m_VertexCnt++; //printf ("\nADDED Unique Vertex!\n"); // DisplayVertices (); // DecisionDisplay (); } else { delete [] pVertex; //printf ("\n+"); } } /* CTableau :: AddVertex () */ std::string CTableau :: DisplayVertices () { int nVertex; int nParam; char buffer[1024]; std::string result; result.append ("\n\n"); for (nParam = 0; nParam < m_ParamCnt; nParam++) { sprintf (buffer, "%6s ", m_pVarLabels [nParam + 1]); result.append(buffer); } result.append ("\n\n"); for (nVertex = 0; nVertex < m_VertexCnt; nVertex++) { for (nParam = 0; nParam < m_ParamCnt; nParam++) { sprintf (buffer, "%6.3lf ", m_pVertices [nVertex][nParam]); result.append(buffer); } result.append ("\n"); } return result; } /* CTableau :: DisplayVertices () */ BOOL CTableau :: GetVertex (int p_nVertex, double * p_pVertex, int p_VertexLength) { int nParam; if (p_VertexLength != m_ParamCnt) return FALSE; if (p_nVertex >= m_VertexCnt) return FALSE; for (nParam = 0; nParam < m_ParamCnt; nParam++) p_pVertex [nParam] = m_pVertices [p_nVertex][nParam]; return TRUE; }
21.369056
82
0.565877
gjo11
9ef6e673919e22248aea4048d92925eaef6af77d
8,951
hpp
C++
original_periodic/src/discrete_function.hpp
four-spins/dissertation
6a61b6d5b133c8839b7aa740784472c2beb5912e
[ "MIT" ]
null
null
null
original_periodic/src/discrete_function.hpp
four-spins/dissertation
6a61b6d5b133c8839b7aa740784472c2beb5912e
[ "MIT" ]
null
null
null
original_periodic/src/discrete_function.hpp
four-spins/dissertation
6a61b6d5b133c8839b7aa740784472c2beb5912e
[ "MIT" ]
null
null
null
/****************************************************************************** * * @file: discrete_function.hpp * * @date: 12/06/2012 01:39:53 PM (CET) * * @author: Marco Müller <[email protected]> * ******************************************************************************/ #pragma once #include <vector> #include <cassert> #include <iostream> #include <iomanip> // stream manipulators #include <sstream> // string streams used for output #include <limits> #include <cmath> #include "dlib/serialize.h" /// class to manage a functional dependency y = f(x) with automatic /// discretisation in x /// /// The naming of the class is as follows:\n /// x is called the abscissa\n /// y is called the ordinate\n /// The interval [abscissa_min, abscissa_max] is divided in a number of /// nr_bins subintervals of a given length bin_width_ where each subinterval /// holds exactly one value for the ordinate.\n /// Subintervals are also referred to as "bins". template<class T> class discrete_function { public: typedef typename std::vector<T>::iterator iterator; typedef typename std::vector<T>::reverse_iterator reverse_iterator; typedef typename std::vector<T>::const_iterator const_iterator; typedef typename std::vector<T>::const_reverse_iterator const_reverse_iterator; typedef T value_type; /// constructor defining /// interval limits and length of one subinterval discrete_function(double abscissa_min_, double abscissa_max_, double bin_width_); // members defining the discretisation: double abscissa_min; ///< minimum of the interval double abscissa_max; ///< maximum of the interval double bin_width; ///< length of a subinterval size_t nr_bins; size_t normalization; // vector storing the ordinates std::vector<T> data; /// access by index T& operator[]( size_t index ); const T& operator[]( size_t index ) const; /// access by value for the abscissa T& operator[]( double abscissa_val ); const T& operator[]( double abscissa_val ) const; /// returns iterator to begin of underlying data iterator begin() { return data.begin(); } /// returns const iterator to begin of underlying data const_iterator begin() const { return data.begin(); } /// returns const iterator to begin of underlying data const_iterator cbegin() const { return data.cbegin(); } /// returns iterator to end of underlying data iterator end() { return data.end(); } /// returns const iterator to end of underlying data const_iterator end() const { return data.end(); } /// returns const iterator to end of underlying data const_iterator cend() const { return data.cend(); } /// returns reverse iterator to begin of underlying data reverse_iterator rbegin() { return data.rbegin(); } /// returns const reverse iterator to begin of underlying data const_reverse_iterator rbegin() const { return data.rbegin(); } /// returns const reverse iterator to begin of underlying data const_reverse_iterator crbegin() const { return data.crbegin(); } /// returns reverse iterator to end of underlying data reverse_iterator rend() { return data.rend(); } /// returns const reverse iterator to end of underlying data const_reverse_iterator rend() const { return data.rend(); } /// returns const reverse iterator to end of underlying data const_reverse_iterator crend() const { return data.crend(); } /// get internal vector storing ordinates std::vector<T>& get_data() { return data; } /// get lower limit of the interval double get_abscissa_min() const { return abscissa_min; } /// get upper limit of the interval double get_abscissa_max() const { return abscissa_max; } /// get size of a subinterval double get_bin_width() const { return bin_width; } /// return normalization size_t get_norm() const { return normalization; } /// get number of subintervals size_t size() const; /// get index for a value of the abscissa size_t get_index( double abscissa_val ) const; /// get the abscissa for an index interpolated to be the /// mean value of the subinterval double get_abscissa(size_t index) const; /// get a string representation std::string to_string() const; //template<class T2> //friend std::ostream& operator<<(std::ostream& os, discrete_function<T2>& func); }; // class discrete_function // constructor definition template<class T> discrete_function<T> ::discrete_function(double abscissa_min_, double abscissa_max_, double bin_width_) : abscissa_min(abscissa_min_) , abscissa_max(abscissa_max_) , bin_width(bin_width_) , normalization( std::numeric_limits<double>::quiet_NaN() ){ const double diff = abscissa_max - abscissa_min; // Error: // either the lower bound of the interval is greater than // the upper bound or they are equal assert( diff > 0 && "Error: creating discrete_function failed due to improper definition of the interval."); nr_bins = static_cast<size_t>( (diff / bin_width) ); abscissa_max = abscissa_min + nr_bins*bin_width; // Error: // length of a subinterval is bigger than the length of the // whole interval assert( nr_bins > 0 && "Error: discrete_function needs at least one subinterval."); data.resize(nr_bins); } // number of subintervals template<class T> size_t discrete_function<T> ::size() const { return nr_bins; } // access by index template<class T> const T& discrete_function<T> ::operator[](size_t index) const { assert( index < nr_bins ); return data[index]; } template<class T> T& discrete_function<T> ::operator[](size_t index) { assert( index < nr_bins ); return data[index]; } // access by value template<class T> inline const T& discrete_function<T> ::operator[](double abscissa) const { return data[get_index(abscissa)]; } template<class T> inline T& discrete_function<T> ::operator[](double abscissa) { return data[get_index(abscissa)]; } template<class T> inline size_t discrete_function<T> ::get_index( double abscissa_val ) const { size_t index = 0; index = static_cast<size_t>((abscissa_val - abscissa_min)/bin_width); assert( index < nr_bins ); return index; } template<class T> double discrete_function<T> ::get_abscissa(size_t index) const{ double tmp =static_cast<double>(abscissa_min) + static_cast<double>(bin_width) * (index + 0.5); return tmp; } template<class T> std::string discrete_function<T> ::to_string() const { std::ostringstream os; os << "# discrete function:\n" << "# abscissa_min = " << std::scientific << std::setprecision(16) << abscissa_min << "\n" << "# abscissa_max = " << std::scientific << std::setprecision(16) << abscissa_max << "\n" << "# bin_width = " << std::scientific << std::setprecision(16) << bin_width << "\n" << "# nr_bins = " << nr_bins << "\n" << "# -----\n" << "# Every line represents a right-open subinterval of the abscissa with its ordinate\n" << "#" << std::setw(29) << "x_mean" << std::setw(31) << "f[x_min, x_max)\n"; // TODO: how to write type information ... logval vs. double ... os.setf(std::ios::scientific); os.precision(16); for ( size_t i = 0; i < nr_bins; i++ ) { double mean = this->get_abscissa(i) ; os << std::setw(30) << mean << " " << std::setw(29) << this->operator[](i) << " " << "\n"; } return os.str(); } template<class T> std::ostream& operator<<(std::ostream& os, discrete_function<T>& func){ os << func.to_string(); return os; } template<class T> void serialize (const discrete_function<T>& df, std::ostream& out) { /* serialize() just needs to write the state of item to the output stream. You can do this however you like. Below, I'm using the serialize functions for int and std::string which come with dlib. But again, you can do whatever you want here. */ dlib::serialize(df.abscissa_min, out); dlib::serialize(df.abscissa_max, out); dlib::serialize(df.bin_width, out); dlib::serialize(df.nr_bins, out); dlib::serialize(df.normalization, out); dlib::serialize(df.data, out); } template<class T> void deserialize (discrete_function<T>& df, std::istream& in) { /* deserialize() is just the inverse of serialize(). Again, you can do whatever you want here so long as it correctly reconstructs item. This also means that deserialize() must always consume as many bytes as serialize() generates. */ dlib::deserialize(df.abscissa_min, in); dlib::deserialize(df.abscissa_max, in); dlib::deserialize(df.bin_width, in); dlib::deserialize(df.nr_bins, in); dlib::deserialize(df.normalization, in); dlib::deserialize(df.data, in); }
35.804
110
0.662272
four-spins
9ef70ccca3e23f25edaadde59f7b308c8c1c461b
2,922
cpp
C++
src/wham/Simulation.cpp
seanmarks/wham
3ffdfcd46d165836c236588c6444acc0cb01fa6b
[ "MIT" ]
1
2020-10-12T19:32:33.000Z
2020-10-12T19:32:33.000Z
src/wham/Simulation.cpp
seanmarks/wham
3ffdfcd46d165836c236588c6444acc0cb01fa6b
[ "MIT" ]
null
null
null
src/wham/Simulation.cpp
seanmarks/wham
3ffdfcd46d165836c236588c6444acc0cb01fa6b
[ "MIT" ]
1
2020-10-15T19:02:21.000Z
2020-10-15T19:02:21.000Z
#include "Simulation.h" #include "OrderParameterRegistry.h" Simulation::Simulation( const std::string& data_set_label, const double t_min, const double t_max, const double temperature, const bool use_floored_times, const OrderParameterRegistry& op_registry ): data_set_label_(data_set_label), t_min_(t_min), t_max_(t_max), temperature_(temperature), kBT_(Constants::k_B * temperature_), beta_(1.0/kBT_), use_floored_times_(use_floored_times), op_registry_ptr_(&op_registry) { // Read time series const auto& time_series_files = op_registry_ptr_->getSimulationFiles(data_set_label); const int num_ops = time_series_files.size(); time_series_.reserve(num_ops); for ( int p=0; p<num_ops; ++p ) { int data_col = op_registry_ptr_->getTimeSeriesDataCol(p); time_series_.emplace_back( time_series_files[p], data_col, t_min_, t_max_, use_floored_times ); } checkTimeSeries(); } const TimeSeries& Simulation::getTimeSeriesForOrderParameter(const std::string& op_name) const { FANCY_ASSERT(op_registry_ptr_ != nullptr, "order parameter registry is missing"); const int op_index = op_registry_ptr_->nameToIndex(op_name); return time_series_[op_index]; } void Simulation::setShuffledFromOther(const Simulation& other, const std::vector<int>& indices) { FANCY_ASSERT(this != &other, "unsupported usage"); *this = other; const int num_time_series = other.time_series_.size(); for ( int p=0; p<num_time_series; ++p ) { time_series_[p].setShuffledFromOther( other.time_series_[p], indices ); } } void Simulation::checkTimeSeries() const { FANCY_ASSERT(op_registry_ptr_ != nullptr, "order parameter registry is missing"); // Check number present const int num_time_series = time_series_.size(); const int num_ops = op_registry_ptr_->getNumRegistered(); FANCY_ASSERT( num_time_series == num_ops, "Error setting up Simulation with data set label " << data_set_label_ << "\n" << " Mismatch between number of time series files parsed (" << num_time_series << ") and number of order parameters (" << num_ops << "\n" ); if ( num_time_series == 0 ) { return; // nothing to do } const auto& time_series_ref = time_series_.front(); for ( int p=1; p<num_time_series; ++p ) { // Check sampled times const auto& time_series_p = time_series_[p]; if ( time_series_p.get_times() != time_series_ref.get_times() ) { std::stringstream err_ss; err_ss << "Error setting up Simulation with data set label " << data_set_label_ << "\n" << " Mismatch in times sampled for the following order parameters\n"; std::vector<int> op_indices = {{ 0, p }}; for ( auto j : op_indices ) { const auto& time_series_j = time_series_[j]; err_ss << " " << op_registry_ptr_->indexToName(j) << ": " << time_series_j.size() << " points from file " << time_series_j.getFile() << "\n"; } throw std::runtime_error( err_ss.str() ); } } }
34.785714
112
0.714921
seanmarks
9ef7d2e7aa8de4f68131f4e7790c3bc8ed59b423
5,246
cpp
C++
software_embedded/squantorProgger/src/commands.cpp
Squantor/squantProgger
c3a7eecdb6fdb5d3aa717bf14bde615e73b0f236
[ "MIT" ]
1
2019-10-08T03:55:46.000Z
2019-10-08T03:55:46.000Z
software_embedded/squantorProgger/src/commands.cpp
Squantor/squantProgger
c3a7eecdb6fdb5d3aa717bf14bde615e73b0f236
[ "MIT" ]
null
null
null
software_embedded/squantorProgger/src/commands.cpp
Squantor/squantProgger
c3a7eecdb6fdb5d3aa717bf14bde615e73b0f236
[ "MIT" ]
null
null
null
/* MIT License Copyright (c) 2019 Bart Bilos Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #include <command_mini.h> #include <stddef.h> #include <board.hpp> #include <chip.h> #include <stream_uart.hpp> #include <strings.hpp> #include <parsedigit.h> #include <string.h> #include <print.h> result cmdPrintVerHandler(const char *argument); result cmdSpiTestHandler(const char *argument); result cmdSwdEnableHandler(const char *argument); result cmdSwdDisableHandler(const char *argument); result cmdGeneralTestHandler(const char *argument); const char cmdPrintVer[] = "pv"; const char cmdSpiTest[] = "ts"; const char cmdSwdEnable[] = "swde"; const char cmdSwdDisable[] = "swdd"; const char cmdGeneralTest[] = "test"; commandEntry_t sqProgCommands[] = { {cmdPrintVer, cmdPrintVerHandler}, {cmdSpiTest, cmdSpiTestHandler}, {cmdSwdEnable, cmdSwdEnableHandler}, {cmdSwdDisable, cmdSwdDisableHandler}, {cmdGeneralTest, cmdGeneralTestHandler}, {NULL, NULL}, }; // commands may not use an argument and this is fine, ignore warning #pragma GCC diagnostic ignored "-Wunused-parameter" result cmdPrintVerHandler(const char *argument) { dsPuts(&streamUart, strHello); return noError; } result cmdGeneralTestHandler(const char *argument) { Chip_GPIO_SetPinDIROutput(LPC_GPIO_PORT, 0, JTAG_TCK_GPIO); Chip_GPIO_SetPinToggle(LPC_GPIO_PORT, 0, JTAG_TCK_GPIO); } // now we want warnings on arguments missing again #pragma GCC diagnostic pop result cmdSpiTestHandler(const char *argument) { const char *s = argument; unsigned int bitCount; if(parseDigit(*s, &bitCount) != parseOk) return invalidArg; s++; // we know bit count, now check rest unsigned int charCount = (bitCount / 4 + 1); if(strlen(s) != charCount) return invalidArg; // we increment bit count so we cover a range from 1 to 16 bitCount++; // parse data characters uint16_t spiData = 0; for(unsigned int i = 0; i < charCount; i++) { spiData = spiData << 4; unsigned int data; if(parseDigit(*s, &data) != parseOk) return invalidArg; s++; spiData = spiData | (uint16_t) data; } // transfer uint32_t transfer = spiData | (0xE << 16) | SPI_TXDATCTL_EOT | SPI_TXDATCTL_FLEN(bitCount-1); Chip_SPI_ClearStatus(LPC_SPI0, SPI_STAT_CLR_RXOV | SPI_STAT_CLR_TXUR | SPI_STAT_CLR_SSA | SPI_STAT_CLR_SSD); while( !(Chip_SPI_GetStatus(LPC_SPI0) & SPI_STAT_TXRDY)) ; LPC_SPI0->TXDATCTL = transfer; while( !(Chip_SPI_GetStatus(LPC_SPI0) & SPI_STAT_RXRDY)) ; uint16_t rxData = (uint16_t) LPC_SPI0->RXDAT & 0xFFFF; printHexU32(&streamUart, rxData); dsPuts(&streamUart, strNl); // print result return noError; } result cmdSwdEnableHandler(const char *argument) { // check if we have valid divisor number, max 4 hex digits size_t arglen = strlen(argument); if((arglen == 0) || (arglen > 4)) return invalidArg; uint16_t divisor = 0; for(unsigned int i = 0; i < arglen; i++) { divisor = divisor << 4; unsigned int data; if(parseDigit(*argument, &data) != parseOk) return invalidArg; argument++; divisor = divisor | (uint16_t) data; } Chip_Clock_EnablePeriphClock(SYSCTL_CLOCK_SWM); Chip_SWM_MovablePinAssign(SWM_SPI0_SCK_IO, JTAG_TCK_GPIO); Chip_SWM_MovablePinAssign(SWM_SPI0_MISO_IO, JTAG_TMSI_GPIO); Chip_SWM_MovablePinAssign(SWM_SPI0_MOSI_IO, JTAG_TMSO_GPIO); Chip_SWM_MovablePinAssign(SWM_SPI0_SSEL0_IO, JTAG_TMSOE_GPIO); Chip_Clock_DisablePeriphClock(SYSCTL_CLOCK_SWM); Chip_Clock_EnablePeriphClock(SYSCTL_CLOCK_SPI0); Chip_SYSCTL_PeriphReset(RESET_SPI0); Chip_SPI_ConfigureSPI(LPC_SPI0, SPI_CFG_MASTER_EN | SPI_CLOCK_CPHA0_CPOL0 | SPI_CFG_MSB_FIRST_EN | SPI_CFG_SPOL_LO); LPC_SPI0->DLY = 0x0; LPC_SPI0->DIV = SPI_DIV_VAL(divisor); Chip_SPI_Enable(LPC_SPI0); return noError; } result cmdSwdDisableHandler(const char *argument) { Chip_Clock_DisablePeriphClock(SYSCTL_CLOCK_SPI0); // reset SPI core return noError; }
33.414013
112
0.705871
Squantor
9ef9ff178da35b4381c5aa73d9e92ef318162b3a
776
cpp
C++
src/test/scalar/operators/nonsmooth_operators/operator_unary_not_test.cpp
stan-dev/nomad
a21149ef9f4d53a198e6fdb06cfd0363d3df69e7
[ "BSD-3-Clause" ]
23
2015-12-11T20:06:57.000Z
2021-01-15T18:59:58.000Z
src/test/scalar/operators/nonsmooth_operators/operator_unary_not_test.cpp
stan-dev/nomad
a21149ef9f4d53a198e6fdb06cfd0363d3df69e7
[ "BSD-3-Clause" ]
2
2015-12-15T08:12:01.000Z
2016-07-17T01:36:56.000Z
src/test/scalar/operators/nonsmooth_operators/operator_unary_not_test.cpp
stan-dev/nomad
a21149ef9f4d53a198e6fdb06cfd0363d3df69e7
[ "BSD-3-Clause" ]
2
2017-10-13T17:40:34.000Z
2021-03-08T19:17:51.000Z
#include <gtest/gtest.h> #include <math.h> #include <string> #include <src/autodiff/base_functor.hpp> #include <src/scalar/functions.hpp> #include <src/scalar/operators.hpp> #include <src/test/io_validation.hpp> #include <src/test/finite_difference.hpp> template <typename T> class operator_unary_not_eval_func: public nomad::base_functor<T> { public: T operator()(const Eigen::VectorXd& x) const { T v = nomad::tests::construct_unsafe_var<T>(x[0]); if (!v) return -v; else return v; } static std::string name() { return "operator_unary_not"; } }; TEST(ScalarNonSmoothOperators, OperatorUnaryNot) { nomad::eigen_idx_t d = 1; Eigen::VectorXd x(d); x[0] = 1.5; nomad::tests::test_validation<operator_unary_not_eval_func>(x); }
22.823529
67
0.699742
stan-dev
9efb6742f2eaca1021e1d86f2c7f977927373c63
4,080
hpp
C++
include/http/request.hpp
anand-gs/cplusplus
97f9115df1920c811531b053fc8b9fc9b1ad2ed2
[ "MIT" ]
null
null
null
include/http/request.hpp
anand-gs/cplusplus
97f9115df1920c811531b053fc8b9fc9b1ad2ed2
[ "MIT" ]
null
null
null
include/http/request.hpp
anand-gs/cplusplus
97f9115df1920c811531b053fc8b9fc9b1ad2ed2
[ "MIT" ]
null
null
null
/* LICENSE: BEGIN =============================================================================== @author Shan Anand @email [email protected] @source https://github.com/shan-anand @brief HTTP library implementation in C++ =============================================================================== MIT License Copyright (c) 2017 Shanmuga (Anand) Gunasekaran Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. =============================================================================== LICENSE: END */ /** * @file request.hpp * @brief Defines the HTTP request object. */ #ifndef _SID_HTTP_REQUEST_H_ #define _SID_HTTP_REQUEST_H_ #include "method.hpp" #include "version.hpp" #include "headers.hpp" #include "content.hpp" #include "connection.hpp" #include <string> namespace sid { namespace http { /** * @class request * @brief Definition of HTTP request object. */ class request { public: //! Default constructor request(); //! Copy constructor request(const request&) = default; //! Virtual destructor virtual ~request(); //! Copy operator request& operator=(const request&) = default; /** * @fn void clear(); * @brief Clear the object so that it can be reused again */ void clear(); /** * @fn void set(const std::string& _input); * @brief Set the contents of the object using the complete HTTP request string. * If there is an error a sid::exception is thrown. */ void set(const std::string& _input); /** * @fn std::string to_str() const; * @brief Return the complete HTTP request as a string. */ std::string to_str() const; std::string to_str(bool _withContent) const; /** * @fn void set_content(const std::string& data, size_t len); * @brief Sets the payload of the request * * @param data Payload * @param len if std::string::npos it takes the whole string, otherwise it restricts the length. * * @note This also sets the "Content-Length" field in the headers. */ void set_content(const std::string& _data, size_t _len = std::string::npos); /** * @fn const http::content& content() const; * @brief Gets the payload of the request. */ const http::content& content() const { return m_content; } http::content& content() { return m_content; } bool send(connection_ptr _conn); bool send(connection_ptr _conn, const std::string& _data); bool send(connection_ptr _conn, const void* _buffer, size_t _count); bool recv(connection_ptr _conn); private: http::content m_content; //! HTTP request payload public: http::method method; //! HTTP method in Line-1 of request std::string uri; //! resource identifier in Line-1 of request http::version version; //! HTTP version http::headers headers; //! List of request headers std::string userName; //! Username for challenge authentication (used in www_authenticate) std::string password; //! Password for challenge authentication bool content_is_file_path; std::string error; }; } // namespace http } // namespace sid #endif // _SID_HTTP_REQUEST_H_
31.145038
99
0.672059
anand-gs
7301b4da087636648f8729e62b532567a4f5d715
362
cpp
C++
docs/mfc/codesnippet/CPP/clistbox-class_23.cpp
bobbrow/cpp-docs
769b186399141c4ea93400863a7d8463987bf667
[ "CC-BY-4.0", "MIT" ]
965
2017-06-25T23:57:11.000Z
2022-03-31T14:17:32.000Z
docs/mfc/codesnippet/CPP/clistbox-class_23.cpp
bobbrow/cpp-docs
769b186399141c4ea93400863a7d8463987bf667
[ "CC-BY-4.0", "MIT" ]
3,272
2017-06-24T00:26:34.000Z
2022-03-31T22:14:07.000Z
docs/mfc/codesnippet/CPP/clistbox-class_23.cpp
bobbrow/cpp-docs
769b186399141c4ea93400863a7d8463987bf667
[ "CC-BY-4.0", "MIT" ]
951
2017-06-25T12:36:14.000Z
2022-03-26T22:49:06.000Z
// Initialize the storage of the list box to be 256 strings with // about 10 characters per string, performance improvement. int n = m_myListBox.InitStorage(256, 16 * sizeof(TCHAR)); ASSERT(n != LB_ERRSPACE); // Add 256 items to the list box. CString str; for (int i = 0; i < 256; i++) { str.Format(_T("item string %d"), i); m_myListBox.AddString(str); }
27.846154
64
0.690608
bobbrow
7308e85e1bf6a7cae25f7e841e1503edfa31a09c
16,180
cpp
C++
configuration/configurator/ConfiguratorAPI.cpp
miguelvazq/HPCC-Platform
22ad8e5fcb59626abfd8febecbdfccb1e9fb0aa5
[ "Apache-2.0" ]
null
null
null
configuration/configurator/ConfiguratorAPI.cpp
miguelvazq/HPCC-Platform
22ad8e5fcb59626abfd8febecbdfccb1e9fb0aa5
[ "Apache-2.0" ]
1
2018-03-01T18:15:12.000Z
2018-03-01T18:15:12.000Z
configuration/configurator/ConfiguratorAPI.cpp
miguelvazq/HPCC-Platform
22ad8e5fcb59626abfd8febecbdfccb1e9fb0aa5
[ "Apache-2.0" ]
null
null
null
/*############################################################################## HPCC SYSTEMS software Copyright (C) 2015 HPCC Systems®. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ############################################################################## */ #include "ConfiguratorAPI.hpp" #include "ConfiguratorMain.hpp" #include "BuildSet.hpp" #include "ConfigSchemaHelper.hpp" #include "ConfiguratorMain.hpp" #include "jstring.hpp" #include "SchemaMapManager.hpp" #include "SchemaEnumeration.hpp" #include "SchemaCommon.hpp" #include "ConfiguratorMain.hpp" #include "EnvironmentModel.hpp" #include "ConfigNotifications.hpp" #include <iostream> #include "jlog.hpp" static int nAllocatedTables = 0; static char *modelName[MAX_ARRAY_X]; const char* getTableDataModelName(int index) { if (index < nAllocatedTables) return modelName[index]; else { modelName[index] = new char[MAX_ARRAY_Y]; sprintf(modelName[index],"tableDataModel%d", index); nAllocatedTables++; return modelName[index]; } } void deleteTableModels() { while (nAllocatedTables > 0) { delete[] modelName[nAllocatedTables]; nAllocatedTables--; } } namespace CONFIGURATOR_API { using namespace CONFIGURATOR; static CConfigSchemaHelper *s_pConfigSchemaHelper = NULL; void reload(const char *pFile) { assert(pFile != NULL && *pFile != 0); delete s_pConfigSchemaHelper; s_pConfigSchemaHelper = NULL; s_pConfigSchemaHelper = CConfigSchemaHelper::getInstance(); s_pConfigSchemaHelper->populateSchema(); CConfigSchemaHelper::getInstance()->loadEnvFromConfig(pFile); } int getNumberOfAvailableComponents() { assert(s_pConfigSchemaHelper != NULL); return CBuildSetManager::getInstance()->getBuildSetComponentCount(); } int getNumberOfAvailableServices() { assert(s_pConfigSchemaHelper != NULL); return CBuildSetManager::getInstance()->getBuildSetServiceCount(); } #ifdef CONFIGURATOR_LIB int initialize() { assert(s_pConfigSchemaHelper == NULL); static bool bOnce = true; if (bOnce == true) { bOnce = false; InitModuleObjects(); } s_pConfigSchemaHelper = CConfigSchemaHelper::getInstance(); s_pConfigSchemaHelper->populateSchema(); return 1; } #else // CONFIGURATOR_LIB int initialize(int argc, char *argv[]) { assert(s_pConfigSchemaHelper == NULL); InitModuleObjects(); s_pConfigSchemaHelper = CConfigSchemaHelper::getInstance(); return 0; } #endif // CONFIGURATOR_LIB int getValue(const char *pXPath, char *pValue) { // By Default, return xPath as value. if (pXPath == NULL || *pXPath == 0) return 0; strcpy(pValue, pXPath[0] == '#' ? &(pXPath[1]) : pXPath); // href for frontend CAttribute *pAttribute = CConfigSchemaHelper::getInstance()->getSchemaMapManager()->getAttributeFromXPath(pXPath); if(pAttribute == NULL) ::std::cout << "xPath: " << pXPath << "| value: " << pXPath << ::std::endl; else if (pAttribute->isInstanceValueValid() == true) { strcpy(pValue, pAttribute->getInstanceValue()); ::std::cout << "xPath: " << pXPath << "| value: " << pValue << ::std::endl; } return 1; } bool setValue(const char *pXPath, const char *pValue) { assert(pXPath != NULL && pXPath[0] != 0); assert(pValue != NULL); StringBuffer strXPath(pXPath); strXPath.replace('_','/'); CAttribute *pAttribute = CConfigSchemaHelper::getInstance()->getSchemaMapManager()->getAttributeFromXPath(strXPath.str()); if (pAttribute == NULL) return false; assert(pAttribute != NULL); pAttribute->setEnvValueFromXML(pValue); /*if (strstr(pValue, "/") == NULL) { strXPath.replace('_','/'); }*/ CConfigSchemaHelper::getInstance()->setEnvTreeProp(strXPath.str(), pValue); return true; } int getIndex(const char *pXPath) { CRestriction *pRestriction = CConfigSchemaHelper::getInstance()->getSchemaMapManager()->getRestrictionFromXPath(pXPath); assert(pRestriction != NULL); assert(pRestriction->getEnumerationArray() != NULL); return pRestriction->getEnumerationArray()->getEnvValueNodeIndex(); } void setIndex(const char *pXPath, int newIndex) { assert(newIndex >= 0); CRestriction *pRestriction = CConfigSchemaHelper::getInstance()->getSchemaMapManager()->getRestrictionFromXPath(pXPath); assert(pRestriction != NULL); assert(pRestriction->getEnumerationArray() != NULL); pRestriction->getEnumerationArray()->setEnvValueNodeIndex(newIndex); CConfigSchemaHelper::getInstance()->setEnvTreeProp(pXPath, pRestriction->getEnumerationArray()->item(newIndex).getValue()); } const char* getTableValue(const char *pXPath, int nRow) { assert(pXPath != NULL && *pXPath != 0); CAttribute *pAttribute = NULL; CElement *pElement = NULL; if (CConfigSchemaHelper::isXPathTailAttribute(pXPath) == true) pAttribute = CConfigSchemaHelper::getInstance()->getSchemaMapManager()->getAttributeFromXPath(pXPath); if (pAttribute == NULL) { pElement = CConfigSchemaHelper::getInstance()->getSchemaMapManager()->getElementFromXPath(pXPath); assert(pElement != NULL); return pAttribute->getInstanceValue(); } else { assert(pAttribute != NULL); if (nRow == 1) return pAttribute->getInstanceValue(); else { StringBuffer strXPath(pXPath); const StringBuffer strXPathOriginal(pXPath); int offset = strXPathOriginal.length() - (CConfigSchemaHelper::stripXPathIndex(strXPath) + 1) ; CConfigSchemaHelper::stripXPathIndex(strXPath); strXPath.appendf("[%d]", nRow); strXPath.append(strXPathOriginal, offset, strXPathOriginal.length() - offset); //confirm the next 2 lines are sufficient //CConfigSchemaHelper::stripXPathIndex(strXPath); //strXPath.appendf("[%d]", nRow); pAttribute = CConfigSchemaHelper::getInstance()->getSchemaMapManager()->getAttributeFromXPath(strXPath.str()); if (STRICTNESS_LEVEL >= DEFAULT_STRICTNESS) assert(pAttribute != NULL); if (pAttribute == NULL) return NULL; return pAttribute->getInstanceValue(); } } } void setTableValue(const char *pXPath, int index, const char *pValue) { UNIMPLEMENTED; } int getNumberOfUniqueColumns() { return CConfigSchemaHelper::getInstance()->getEnvironmentXPathSize(); } const char* getColumnName(int idx) { if (idx < CConfigSchemaHelper::getInstance()->getEnvironmentXPathSize()) return CConfigSchemaHelper::getInstance()->getEnvironmentXPaths(idx); else return NULL; } int getNumberOfRows(const char* pXPath) { assert(pXPath != NULL && *pXPath != 0); PROGLOG("Get number of rows for %s = %d", pXPath, CConfigSchemaHelper::getInstance()->getElementArraySize(pXPath)); return CConfigSchemaHelper::getInstance()->getElementArraySize(pXPath); } int getNumberOfTables() { return CConfigSchemaHelper::getInstance()->getNumberOfTables(); } const char* getServiceName(int idx, char *pName) { if (pName != NULL) strcpy (pName, CBuildSetManager::getInstance()->getBuildSetServiceName(idx)); return CBuildSetManager::getInstance()->getBuildSetServiceName(idx); } const char* getComponentName(int idx, char *pName) { if (pName != NULL) strcpy (pName, CBuildSetManager::getInstance()->getBuildSetComponentTypeName(idx)); return CBuildSetManager::getInstance()->getBuildSetComponentTypeName(idx); } int openConfigurationFile(const char* pFile) { /*s_pConfigSchemaHelper = NULL; s_pConfigSchemaHelper = CConfigSchemaHelper::getInstance(); StringArray arrXSDS; arrXSDS.append("dali.xsd"); CBuildSetManager::getInstance()->setBuildSetArray(arrXSDS); s_pConfigSchemaHelper->populateSchema();*/ CConfigSchemaHelper::getNewInstance()->loadEnvFromConfig(pFile); return 1; } int getNumberOfComponentsInConfiguration(void *pData) { if (pData == NULL) { return CConfigSchemaHelper::getInstance()->getSchemaMapManager()->getNumberOfComponents(); } else { CElement *pElement = static_cast<CElement*>(pData); assert(pElement->getNodeType() == XSD_ELEMENT); CElementArray *pElementArray = static_cast<CElementArray*>(pElement->getParentNode()); assert(pElementArray->getNodeType() == XSD_ELEMENT_ARRAY); return pElementArray->length(); } } void* getComponentInConfiguration(int idx) { assert(idx < CConfigSchemaHelper::getInstance()->getSchemaMapManager()->getNumberOfComponents()); return CConfigSchemaHelper::getInstance()->getSchemaMapManager()->getComponent(idx); } void* getComponentInstance(int idx, void *pData) { assert(pData != NULL); assert(((static_cast<CElement*>(pData))->getNodeType()) == XSD_ELEMENT); CElement *pElement = static_cast<CElement*>(pData); CElementArray *pElementArray = static_cast<CElementArray*>(pElement->getParentNode()); if (pElementArray->length() >= idx) idx = 0; return &(pElementArray->item(idx)); } const char* getComponentNameInConfiguration(int idx, void *pData) { if (pData == NULL) return CConfigSchemaHelper::getInstance()->getSchemaMapManager()->getComponent(idx)->getName(); assert(!"Invalid component index"); return NULL; } const void* getPointerToComponentInConfiguration(int idx, void *pData, int compIdx) { if (pData == NULL) { const CElement *pElement = CConfigSchemaHelper::getInstance()->getSchemaMapManager()->getComponent(idx); assert(pElement != NULL); const CXSDNodeBase *pNodeBase = pElement->getConstParentNode(); const CElementArray *pElementArray = dynamic_cast<const CElementArray*>(pNodeBase); assert(pElementArray != NULL); return pElementArray; } else { assert( compIdx >= 0); CElementArray *pElementArray = static_cast<CElementArray*>(pData); assert(pElementArray->getNodeType() == XSD_ELEMENT_ARRAY); const CXSDNodeBase *pNodeBase = &(pElementArray->item(compIdx+idx)); return(dynamic_cast<const CElement*>(pNodeBase)); } } const void* getPointerToComponentTypeInConfiguration(void *pData) { assert (pData != NULL); CElement *pElement = static_cast<CElement*>(pData); assert (pElement->getNodeType() == XSD_ELEMENT); CElementArray *pElementArray = static_cast<CElementArray*>(pElement->getParentNode()); return &(pElementArray->item(0)); } int getIndexOfParent(void *pData) { assert (pData != NULL); assert((static_cast<CElement*>(pData))->getNodeType() == XSD_ELEMENT); int nIndexOfParent = CConfigSchemaHelper::getInstance()->getSchemaMapManager()->getIndexOfElement(static_cast<CElement*>(pData)); assert(nIndexOfParent >= 0); return nIndexOfParent; } const void* getPointerToComponents() { assert(CConfigSchemaHelper::getInstance()->getSchemaMapManager()->getComponent(0)->getConstParentNode()->getNodeType() == XSD_ELEMENT_ARRAY); return (CConfigSchemaHelper::getInstance()->getSchemaMapManager()->getComponent(0)->getConstParentNode()); } int getNumberOfChildren(void *pData) { int nRetVal = 0; if (pData == NULL) { assert(!"Should not be null"); // why ever null? return 0; } if (pData == (void*)(CEnvironmentModel::getInstance())) nRetVal = (static_cast<CEnvironmentModel*>(pData))->getNumberOfRootNodes(); else // must be of type CEnvironmentModelNode* { CEnvironmentModelNode *pNode = static_cast<CEnvironmentModelNode*>(pData); nRetVal = pNode->getNumberOfChildren(); } return nRetVal; } const char* getData(void *pData) { if (pData == NULL) return NULL; return CEnvironmentModel::getInstance()->getData(static_cast<CEnvironmentModelNode*>(pData)); } const char* getName(void *pData) { if (pData == NULL) return NULL; return CEnvironmentModel::getInstance()->getInstanceName(static_cast<CEnvironmentModelNode*>(pData)); } const char* getFileName(void *pData) { if (pData == NULL) return NULL; return CEnvironmentModel::getInstance()->getXSDFileName(static_cast<CEnvironmentModelNode*>(pData)); } void* getParent(void *pData) { if (pData == NULL) return NULL; if (pData == (void*)(CEnvironmentModel::getInstance()->getRoot())) return (void*)(CEnvironmentModel::getInstance()); else return (void*)(CEnvironmentModel::getInstance()->getParent(static_cast<CEnvironmentModelNode*>(pData))); } void* getChild(void *pData, int idx) { if (pData == NULL || pData == CEnvironmentModel::getInstance()) { if (idx == 0) return (void*)(CEnvironmentModel::getInstance()->getRoot(0)); return NULL; } else return (void*)(CEnvironmentModel::getInstance()->getChild(static_cast<CEnvironmentModelNode*>(pData), idx)); } int getIndexFromParent(void *pData) { CEnvironmentModelNode *pNode = static_cast<CEnvironmentModelNode*>(pData); if (pNode->getParent() == NULL) return 0; // Must be 'Environment' node const CEnvironmentModelNode *pGrandParent = pNode->getParent(); int nChildren = pGrandParent->getNumberOfChildren(); for (int idx = 0; idx < nChildren; idx++) { if (pNode == pGrandParent->getChild(idx)) return idx; } assert(!"Should not reach here"); return 0; } void* getRootNode(int idx) { return (void*)(CEnvironmentModel::getInstance()->getRoot(idx)); } void* getModel() { return (void*)(CEnvironmentModel::getInstance()); } void getJSON(void *pData, char **pOutput, int nIdx) { CConfigSchemaHelper::getInstance()->printJSON(CONFIGURATOR_API::getFileName(pData), pOutput, nIdx, true); } void getNavigatorJSON(char **pOutput) { CConfigSchemaHelper::getInstance()->printNavigatorJSON(pOutput, true); } void getJSONByComponentName(const char *pComponentName, char **pOutput, int nIdx) { CConfigSchemaHelper::getInstance()->printJSON(pComponentName, pOutput, nIdx, true); } void getJSONByComponentKey(const char *pKey, char **pOutput) { CConfigSchemaHelper::getInstance()->printJSONByKey(pKey, pOutput, true); } void getDocBookByIndex(int idx, char **pOutput) { const char *pFileName = CBuildSetManager::getInstance()->getBuildSetComponentFileName(idx); CConfigSchemaHelper::getInstance()->printDocumentation(pFileName, pOutput); } bool saveConfigurationFile() { return CConfigSchemaHelper::getInstance()->saveConfigurationFile(); } bool saveConfigurationFileAs(const char *pFilePath) { if (pFilePath == NULL || *pFilePath == 0) return false; return CConfigSchemaHelper::getInstance()->saveConfigurationFileAs(pFilePath); } int getNumberOfNotificationTypes() { return CNotificationManager::getInstance()->getNumberOfNotificationTypes(); } const char* getNotificationTypeName(int type) { return CNotificationManager::getInstance()->getNotificationTypeName(type); } int getNumberOfNotifications(int type) { enum ENotificationType eType = static_cast<ENotificationType>(type); return CNotificationManager::getInstance()->getNumberOfNotifications(eType); } const char* getNotification(int type, int idx) { const char *pRet = NULL; enum ENotificationType eType = static_cast<ENotificationType>(type); return CNotificationManager::getInstance()->getNotification(eType, idx); } } // CONFIGURATOR_API namespace
28.738899
145
0.686836
miguelvazq
730daedec1ae75a1acd8b2fbe243881225858d2f
1,333
cpp
C++
Common_3/ThirdParty/OpenSource/meshoptimizer/src/allocator.cpp
Mercesa/The-Forge
13d7604bde91f90188c9dcb480ea6e97f60f1645
[ "Apache-2.0" ]
1
2021-11-16T08:35:01.000Z
2021-11-16T08:35:01.000Z
Common_3/ThirdParty/OpenSource/meshoptimizer/src/allocator.cpp
Mercesa/The-Forge
13d7604bde91f90188c9dcb480ea6e97f60f1645
[ "Apache-2.0" ]
null
null
null
Common_3/ThirdParty/OpenSource/meshoptimizer/src/allocator.cpp
Mercesa/The-Forge
13d7604bde91f90188c9dcb480ea6e97f60f1645
[ "Apache-2.0" ]
null
null
null
// This file is part of meshoptimizer library; see meshoptimizer.h for version/license details #include "meshoptimizer.h" #include "../../../../OS/Interfaces/ILog.h" #include "../../../../ThirdParty/OpenSource/ModifiedSonyMath/vectormath_settings.hpp" #define MEM_MAX(a, b) ((a) > (b) ? (a) : (b)) #define MIN_ALLOC_ALIGNMENT MEM_MAX(VECTORMATH_MIN_ALIGN, EA_PLATFORM_MIN_MALLOC_ALIGNMENT) size_t buffer_length = 0; size_t current_offset = 0; char* buffer; //Scratch-Pad memory void* Allocate(size_t size) { // make the current offset always aligned current_offset += current_offset % MIN_ALLOC_ALIGNMENT; if (current_offset + size <= buffer_length) { void* ptr = &buffer[current_offset]; current_offset += size; return ptr; } LOGF(LogLevel::eWARNING, "Mesh Optimizer out of memory"); return NULL; } void DeAllocate(void* b) { current_offset = 0; } void meshopt_SetScratchMemory(size_t size, void* memory) { buffer_length = size; buffer = (char*)memory; meshopt_setAllocator(); } //void meshopt_setAllocator(void* (*allocate)(size_t), void (*deallocate)(void*)) void meshopt_setAllocator() { //meshopt_Allocator::Storage::allocate = allocate; //meshopt_Allocator::Storage::deallocate = deallocate; meshopt_Allocator::Storage::allocate = Allocate; meshopt_Allocator::Storage::deallocate = DeAllocate; }
26.137255
94
0.740435
Mercesa
730e961086ae68d929f9d93fd746fb8faee658fb
18,430
cpp
C++
Classes/GameSceneEx.cpp
lfeng1420/BrickGame
e4961a7454ae1adece6845c64a6ba8ac59856d68
[ "MIT" ]
39
2016-05-07T06:39:54.000Z
2021-04-13T15:00:52.000Z
Classes/GameSceneEx.cpp
lfeng1420/BrickGame
e4961a7454ae1adece6845c64a6ba8ac59856d68
[ "MIT" ]
8
2016-07-17T06:39:54.000Z
2021-07-06T15:14:19.000Z
Classes/GameSceneEx.cpp
lfeng1420/BrickGame
e4961a7454ae1adece6845c64a6ba8ac59856d68
[ "MIT" ]
13
2016-03-11T11:46:19.000Z
2018-08-10T16:34:33.000Z
#include "stdafx.h" #include "GameSceneEx.h" cocos2d::Scene* CGameSceneEx::CreateScene(const TGameSceneContext* pContext /*= nullptr*/) { auto scene = Scene::create(); auto layer = CGameSceneEx::create(pContext); scene->addChild(layer); scene->setTag(GAME_SCENE_TAG); return scene; } cocos2d::LayerColor* CGameSceneEx::create(const TGameSceneContext* pContext /*= nullptr*/) { CGameSceneEx* pLayer = new CGameSceneEx(); if (pLayer == nullptr) { return nullptr; } // First step pLayer->ImportContextFirst(pContext); // init if (!pLayer->init()) { delete pLayer; return nullptr; } // Last step pLayer->ImportContextLast(pContext); pLayer->autorelease(); return pLayer; } void CGameSceneEx::InitUI() { float fBottomY = 0; float fTopY = 0; float fTempBottomY = 0; __InitAllBricksEx(fBottomY, fTopY); __InitBottomMenuEx(fTempBottomY); float fBottomCenterY = (fBottomY - fTempBottomY) * 0.5f + fTempBottomY; __InitControllerEx(fBottomCenterY, fTopY); __InitRightUIEx(fBottomCenterY, fTopY); __ApplyRightHandModeEx(); // Tips __InitTips(); } void CGameSceneEx::UpdateLevelOrSpeed(Vector<Sprite*> vecSpr, int& nOldVal, int nNewVal) { if (nOldVal == nNewVal) { return; } char szSpriteName[10] = { 0 }; Sprite* pFirstSpr = vecSpr.at(0); Sprite* pSecSpr = vecSpr.at(1); if (pFirstSpr == nullptr || pSecSpr == nullptr) { return; } if (nNewVal < 10) { sprintf(szSpriteName, "%d.png", nNewVal); pSecSpr->setSpriteFrame(CGlobalFunc::GetSpriteNameWithMode(szSpriteName)); pFirstSpr->setVisible(false); pSecSpr->setVisible(true); float fPosY = pFirstSpr->getPositionY(); Size sprSize = GET_CONTENTSIZE(pSecSpr); pSecSpr->setPositionY(fPosY - sprSize.width * 0.5f - LEVEL_SPEED_NUM_PADDING * 0.5f); } else { pFirstSpr->setSpriteFrame(CGlobalFunc::GetSpriteNameWithMode("1.png")); pFirstSpr->setVisible(true); pSecSpr->setSpriteFrame(CGlobalFunc::GetSpriteNameWithMode("0.png")); pSecSpr->setVisible(true); float fPosY = pFirstSpr->getPositionY(); Size sprSize = GET_CONTENTSIZE(pSecSpr); pSecSpr->setPositionY(fPosY - sprSize.width - LEVEL_SPEED_NUM_PADDING); } // Update value nOldVal = nNewVal; } bool CGameSceneEx::AdjustClickBtnID(const Vec2* pos, int& nBtnID) { //ֻ������� if (nBtnID >= BTNID_DIRMAX) { return true; } Vec2 dis = *pos - m_oControllerCenterPos; float fFactor = dis.x / dis.y; if (fFactor >= 1 || fFactor <= -1) { nBtnID = dis.x > 1e-6 ? BTNID_UP : BTNID_DOWN; return true; } if (fFactor < 1 && fFactor >= -1) { nBtnID = dis.y > 1e-6 ? BTNID_LEFT : BTNID_RIGHT; return true; } nBtnID = -1; return false; } void CGameSceneEx::__InitAllBricksEx(float& fBottomY, float& fTopY) { Size visibleSize = GET_VISIBLESIZE(); Size brickSize = Size::ZERO; fBottomY = 0; fTopY = 0; float fCurX = visibleSize.width; for (int nRowIdx = 0; nRowIdx < ROW_COUNT; ++nRowIdx) { for (int nColIdx = 0; nColIdx < COLUMN_COUNT; ++nColIdx) { int nBrickID = GET_BRICKID(nRowIdx, nColIdx); // Create sprite Sprite* pSpr = CREATE_SPRITEWITHNAME(CGlobalFunc::GetSpriteNameWithMode(m_arrBrickState[nBrickID] ? "black.png" : "empty.png")); if (brickSize.equals(Size::ZERO)) { brickSize = GET_CONTENTSIZE(pSpr); fTopY = visibleSize.height * 0.5f + brickSize.width * COLUMN_COUNT * 0.5f; fBottomY = visibleSize.height * 0.5f - brickSize.width * COLUMN_COUNT * 0.5f; } pSpr->setRotation(90); pSpr->setPosition(fCurX - brickSize.height * 0.5f, fTopY - nColIdx * brickSize.width - brickSize.width * 0.5f); pSpr->setTag(nBrickID); this->addChild(pSpr); m_vecBrickSpr.pushBack(pSpr); } fCurX -= brickSize.width; } } void CGameSceneEx::__InitControllerEx(float fBottomCenterY, float fTopY) { Size visibleSize = GET_VISIBLESIZE(); float fBtnInnerPadding = CONTROLLER_INNER_PADDING; float fControllerPadding = 10; const float CONTROLLER_SCALE_MAX = GET_INTVALUE("DIRBTN_SCALE", DIRBTN_DEFAULT_SCALE) / 100.0f; // Up button string strBtn0Name = CGlobalFunc::GetSpriteNameWithMode("btn_0.png"); string strBtn1Name = CGlobalFunc::GetSpriteNameWithMode("btn_1.png"); MenuItemSprite* pUpBtn = MenuItemSprite::create( CREATE_SPRITEWITHNAME(strBtn0Name), CREATE_SPRITEWITHNAME(strBtn1Name), nullptr); Size btnSize = GET_CONTENTSIZE(pUpBtn); float fControlBtnScale = (visibleSize.height - fTopY - fControllerPadding * 2) / (btnSize.height * 2); if (fControlBtnScale > CONTROLLER_SCALE_MAX) { fControlBtnScale = CONTROLLER_SCALE_MAX; fControllerPadding = (visibleSize.height - fTopY - CONTROLLER_SCALE_MAX * btnSize.height * 2 + CONTROLLER_INNER_PADDING) * 0.5f; } pUpBtn->setRotation(90); pUpBtn->setScale(fControlBtnScale); Size upBtnSize = btnSize * fControlBtnScale; // Right button MenuItemSprite* pRightBtn = MenuItemSprite::create(CREATE_SPRITEWITHNAME(strBtn0Name), CREATE_SPRITEWITHNAME(strBtn1Name), nullptr); pRightBtn->setScale(fControlBtnScale); pRightBtn->setRotation(180); Size rightBtnSize = GET_CONTENTSIZE(pRightBtn) * fControlBtnScale; // Down button MenuItemSprite* pDownBtn = MenuItemSprite::create(CREATE_SPRITEWITHNAME(strBtn0Name), CREATE_SPRITEWITHNAME(strBtn1Name), nullptr); pDownBtn->setScale(fControlBtnScale); pDownBtn->setRotation(270); Size downBtnSize = GET_CONTENTSIZE(pDownBtn) * fControlBtnScale; // Left button MenuItemSprite* pLeftBtn = MenuItemSprite::create(CREATE_SPRITEWITHNAME(strBtn0Name), CREATE_SPRITEWITHNAME(strBtn1Name), nullptr); pLeftBtn->setScale(fControlBtnScale); Size leftBtnSize = GET_CONTENTSIZE(pLeftBtn) * fControlBtnScale; //Fire button string strFire0Name = CGlobalFunc::GetSpriteNameWithMode("fire_0.png"); string strFire1Name = CGlobalFunc::GetSpriteNameWithMode("fire_1.png"); MenuItemSprite* pFireBtn = MenuItemSprite::create( CREATE_SPRITEWITHNAME(strFire0Name), CREATE_SPRITEWITHNAME(strFire1Name), nullptr); pFireBtn->setRotation(90); Size fireBtnSize = pFireBtn->getContentSize(); // Set position float fPosX = upBtnSize.height * 1.2f + GET_INTVALUE("DIRBTN_YOFFSET", 0); float fTopCenterY = fTopY + fControllerPadding + upBtnSize.height; pLeftBtn->setPosition(Vec2(fPosX, fTopCenterY + leftBtnSize.height * 0.5f - fBtnInnerPadding)); pRightBtn->setPosition(Vec2(fPosX, fTopCenterY - rightBtnSize.height * 0.5f + fBtnInnerPadding)); pDownBtn->setPosition(Vec2(fPosX - upBtnSize.height * 0.5f + fBtnInnerPadding, fTopCenterY)); pUpBtn->setPosition(Vec2(fPosX + upBtnSize.height * 0.5f - fBtnInnerPadding, fTopCenterY)); pFireBtn->setPosition(Vec2(fPosX, fBottomCenterY)); // Center pos and area size m_oControllerCenterPos = Vec2(fPosX, fTopCenterY); m_oControllerCenterSize = Size(upBtnSize.width, upBtnSize.width); Menu* pMenu = Menu::create(pUpBtn, pRightBtn, pDownBtn, pLeftBtn, nullptr); pMenu->setTouchCallback(CC_CALLBACK_3(CGameSceneEx::__OnMenuTouch, this)); pMenu->setPosition(Vec2::ZERO); this->addChild(pMenu); Menu* pFireMenu = Menu::create(pFireBtn, nullptr); pFireMenu->setTouchCallback(CC_CALLBACK_3(CGameSceneEx::__OnMenuTouch, this)); pFireMenu->setPosition(Vec2::ZERO); this->addChild(pFireMenu); // Add all buttons to vector // Order: BTNID_RIGHT -> BTNID_DOWN -> BTNID_LEFT -> BTNID_UP -> BTNID_FIRE m_vecDirBtn.pushBack(pRightBtn); m_vecDirBtn.pushBack(pDownBtn); m_vecDirBtn.pushBack(pLeftBtn); m_vecDirBtn.pushBack(pUpBtn); m_vecDirBtn.pushBack(pFireBtn); } void CGameSceneEx::__InitBottomMenuEx(float& fBottomY) { float fSpriteScale = 0.4f; Size visibleSize = GET_VISIBLESIZE(); // Start button Sprite* pPlaySpr = CREATE_SPRITEWITHNAME(CGlobalFunc::GetSpriteNameWithMode("play.png")); Sprite* pPauseSpr = CREATE_SPRITEWITHNAME(CGlobalFunc::GetSpriteNameWithMode("pause.png")); m_pStartBtn = MenuItemToggle::createWithCallback( CC_CALLBACK_1(CGameSceneEx::__OnClickButton, this, BTNID_START), MenuItemSprite::create(pPlaySpr, pPlaySpr, nullptr), MenuItemSprite::create(pPauseSpr, pPauseSpr, nullptr), nullptr ); m_pStartBtn->setRotation(90); m_pStartBtn->setScale(fSpriteScale); Size startBtnSize = m_pStartBtn->getContentSize() * fSpriteScale; // Sound button Sprite* pSndOnSpr = CREATE_SPRITEWITHNAME(CGlobalFunc::GetSpriteNameWithMode("sound_on.png")); Sprite* pSndOffSpr = CREATE_SPRITEWITHNAME(CGlobalFunc::GetSpriteNameWithMode("sound_off.png")); auto pSoundOnMenu = MenuItemSprite::create( pSndOnSpr, pSndOnSpr, nullptr ); auto pSoundOffMenu = MenuItemSprite::create( pSndOffSpr, pSndOffSpr, nullptr ); m_pSoundBtn = MenuItemToggle::createWithCallback( CC_CALLBACK_1(CGameSceneEx::__OnClickButton, this, BTNID_SOUND), pSoundOnMenu, pSoundOffMenu, nullptr ); m_pSoundBtn->setRotation(90); m_pSoundBtn->setScale(fSpriteScale); m_pSoundBtn->setSelectedIndex(GET_BOOLVALUE("SOUND", true) ? 0 : 1); Size soundBtnSize = m_pSoundBtn->getContentSize() * fSpriteScale; // Reset button Sprite* pResetSpr = CREATE_SPRITEWITHNAME(CGlobalFunc::GetSpriteNameWithMode("reset.png")); m_pResetBtn = MenuItemSprite::create( pResetSpr, pResetSpr, CC_CALLBACK_1(CGameSceneEx::__OnClickButton, this, BTNID_RESET) ); m_pStartBtn->setRotation(90); m_pResetBtn->setScale(fSpriteScale); Size resetBtnSize = m_pResetBtn->getContentSize() * fSpriteScale; // Setup button Sprite* pStarSpr = CREATE_SPRITEWITHNAME(CGlobalFunc::GetSpriteNameWithMode("setup.png")); m_pSetupBtn = MenuItemSprite::create( pStarSpr, pStarSpr, CC_CALLBACK_1(CGameSceneEx::__OnClickButton, this, BTNID_SETUP) ); m_pStartBtn->setRotation(90); m_pSetupBtn->setScale(fSpriteScale); Size setupBtnSize = m_pSetupBtn->getContentSize() * fSpriteScale; // Bottom button horizontal padding fBottomY = soundBtnSize.height * 0.75f; float fBtnBottomInnerPadding = (visibleSize.width - resetBtnSize.height - setupBtnSize.height - startBtnSize.height - soundBtnSize.height) / 5; m_pStartBtn->setPosition(fBtnBottomInnerPadding + startBtnSize.height * 0.5f, fBottomY); m_pSoundBtn->setPosition(fBtnBottomInnerPadding * 2 + startBtnSize.height + soundBtnSize.height * 0.5f, fBottomY); m_pResetBtn->setPosition(fBtnBottomInnerPadding * 3 + startBtnSize.height + soundBtnSize.height + resetBtnSize.height * 0.5f, fBottomY); m_pSetupBtn->setPosition(visibleSize.width - fBtnBottomInnerPadding - setupBtnSize.height * 0.5f, fBottomY); // Menu auto menu = Menu::create(m_pStartBtn, m_pSoundBtn, m_pResetBtn, m_pSetupBtn, nullptr); menu->setPosition(Vec2::ZERO); this->addChild(menu); fBottomY += soundBtnSize.height * 0.5f; } void CGameSceneEx::__InitRightUIEx(float fBottomCenterY, float fTopY) { float fSpriteScale = 0.38f; float fSmallBrickScale = 0.7f; int nSmallBrickPadding = 2; int nNumSprPadding = 1; Size visibleSize = GET_VISIBLESIZE(); float fRightX = visibleSize.width; float fTopCenterY = (visibleSize.height - fTopY) * 0.5f + fTopY; string strZeroSprName = CGlobalFunc::GetSpriteNameWithMode("0.png"); ////////////////////////// Top part ////////////////////////// // Score label Sprite* pScoreSpr = CREATE_SPRITEWITHNAME(CGlobalFunc::GetSpriteNameWithMode("score.png")); Size scoreSize = GET_CONTENTSIZE(pScoreSpr) * fSpriteScale; pScoreSpr->setRotation(90); pScoreSpr->setScale(fSpriteScale); pScoreSpr->setPosition(fRightX - scoreSize.height, fTopCenterY); fRightX -= scoreSize.height * 1.5f; this->addChild(pScoreSpr); m_vecMiscSpr.pushBack(pScoreSpr); // Score num sprite Size numSize = Size::ZERO; float fTempY = 0; for (int nIndex = 0; nIndex < SCORE_NUM_COUNT; ++nIndex) { Sprite* pSpr = CREATE_SPRITEWITHNAME(strZeroSprName); if (numSize.equals(Size::ZERO)) { numSize = GET_CONTENTSIZE(pSpr); fRightX -= numSize.height * 0.3f; fTempY = fTopCenterY + nNumSprPadding * 2.5f + numSize.width * 3; } pSpr->setPosition(fRightX - numSize.height * 0.5f, fTempY - numSize.width * 0.5f); pSpr->setRotation(90); this->addChild(pSpr); m_vecScoreSpr.pushBack(pSpr); fTempY -= numSize.width + nNumSprPadding; } fRightX -= numSize.height; // Max score label Sprite* pMaxScoreSpr = CREATE_SPRITEWITHNAME(CGlobalFunc::GetSpriteNameWithMode("hiscore.png")); Size maxScoreSize = GET_CONTENTSIZE(pMaxScoreSpr) * fSpriteScale; pMaxScoreSpr->setPosition(fRightX - maxScoreSize.height, fTopCenterY); pMaxScoreSpr->setRotation(90); pMaxScoreSpr->setScale(fSpriteScale); fRightX -= maxScoreSize.height * 1.5f; this->addChild(pMaxScoreSpr); m_vecMiscSpr.pushBack(pMaxScoreSpr); // Max score num sprite fRightX -= numSize.height * 0.3f; fTempY = fTopCenterY + nNumSprPadding * 2.5f + numSize.width * 3; for (int nIndex = 0; nIndex < SCORE_NUM_COUNT; ++nIndex) { Sprite* pSpr = CREATE_SPRITEWITHNAME(strZeroSprName); pSpr->setPosition(fRightX - numSize.height * 0.5f, fTempY - numSize.width * 0.5f); pSpr->setRotation(90); this->addChild(pSpr); m_vecMaxScoreSpr.pushBack(pSpr); fTempY -= numSize.width + nNumSprPadding; } fRightX -= numSize.height; ////////////////////////// Bottom part ////////////////////////// fRightX = visibleSize.width; // Small bricks Size smallBrickSize = Size::ZERO; for (int nRowIdx = 0; nRowIdx < SMALL_BRICK_ROW_COUNT; ++nRowIdx) { for (int nColIdx = 0; nColIdx < SMALL_BRICK_COLUMN_COUNT; ++nColIdx) { Sprite* pSpr = CREATE_SPRITEWITHNAME(CGlobalFunc::GetSpriteNameWithMode("empty.png")); if (smallBrickSize.equals(Size::ZERO)) { smallBrickSize = GET_CONTENTSIZE(pSpr) * fSmallBrickScale; fRightX -= (nSmallBrickPadding + smallBrickSize.height * 0.7f); } if (nColIdx == 0) { fTempY = fBottomCenterY + nNumSprPadding * 1.5f + smallBrickSize.width * 2; } // Calc position pSpr->setRotation(90); pSpr->setScale(fSmallBrickScale); pSpr->setPosition(fRightX - smallBrickSize.height * 0.5f, fTempY - smallBrickSize.width * 0.5f); this->addChild(pSpr); m_vecSmallBrickSpr.pushBack(pSpr); fTempY -= (smallBrickSize.width + nSmallBrickPadding); } fRightX -= (smallBrickSize.height + nSmallBrickPadding); } // Speed label Sprite* pSpeedSpr = CREATE_SPRITEWITHNAME(CGlobalFunc::GetSpriteNameWithMode("speed.png")); Size speedSize = GET_CONTENTSIZE(pSpeedSpr) * fSpriteScale; fRightX -= speedSize.height * 1.6f; fTempY = fBottomCenterY + (speedSize.width + numSize.width * 2 + LEVEL_SPEED_NUM_PADDING * 2) * 0.5f; pSpeedSpr->setRotation(90); pSpeedSpr->setScale(fSpriteScale); pSpeedSpr->setPosition(fRightX + speedSize.height * 0.5f, fTempY - speedSize.width * 0.5f); this->addChild(pSpeedSpr); m_vecMiscSpr.pushBack(pSpeedSpr); // Speed num sprite fTempY -= speedSize.width; for (int nIndex = 0; nIndex < SPEED_NUM_COUNT; ++nIndex) { Sprite* pSpr = CREATE_SPRITEWITHNAME(strZeroSprName); pSpr->setRotation(90); pSpr->setPosition(fRightX + numSize.height * 0.5f, fTempY - numSize.width * 0.5f); this->addChild(pSpr); m_vecSpeedSpr.pushBack(pSpr); fTempY -= (numSize.width + LEVEL_SPEED_NUM_PADDING); } // Level label Sprite* pLevelSpr = CREATE_SPRITEWITHNAME(CGlobalFunc::GetSpriteNameWithMode("level.png")); Size levelSize = GET_CONTENTSIZE(pLevelSpr) * fSpriteScale; fTempY = fBottomCenterY + (levelSize.width + numSize.width * 2 + LEVEL_SPEED_NUM_PADDING * 2) * 0.5f; fRightX -= levelSize.height * 1.5f; pLevelSpr->setRotation(90); pLevelSpr->setScale(fSpriteScale); pLevelSpr->setPosition(fRightX + levelSize.height * 0.5f, fTempY - levelSize.width * 0.5f); this->addChild(pLevelSpr); m_vecMiscSpr.pushBack(pLevelSpr); // Level num sprite fTempY -= levelSize.width; for (int nIndex = 0; nIndex < SPEED_NUM_COUNT; ++nIndex) { Sprite* pSpr = CREATE_SPRITEWITHNAME(strZeroSprName); pSpr->setRotation(90); pSpr->setPosition(fRightX + numSize.height * 0.5f, fTempY - numSize.width * 0.5f); this->addChild(pSpr); m_vecLevelSpr.pushBack(pSpr); fTempY -= (numSize.width + LEVEL_SPEED_NUM_PADDING); } // Pause sprite fRightX -= levelSize.height * 0.5f; m_pPauseSpr = CREATE_SPRITEWITHNAME(CGlobalFunc::GetSpriteNameWithMode("tea.png")); Size pauseSize = GET_CONTENTSIZE(m_pPauseSpr) * fSpriteScale; m_pPauseSpr->setRotation(90); m_pPauseSpr->setScale(fSpriteScale); m_pPauseSpr->setPosition(fRightX - pauseSize.height * 0.5f, fBottomCenterY); this->addChild(m_pPauseSpr); m_pPauseSpr->setVisible(false); // Update level UpdateLevelOrSpeed(m_vecLevelSpr, m_stGameData.nLevel, m_stGameData.nLevel); // Update speed UpdateLevelOrSpeed(m_vecSpeedSpr, m_stGameData.nSpeed, m_stGameData.nLevel); } void CGameSceneEx::__ApplyRightHandModeEx() { if (!GET_BOOLVALUE("RHMODE", false)) { return; } MenuItem* pRightBtn = m_vecDirBtn.at(BTNID_RIGHT); RETURN_IF_NULLPTR(pRightBtn); MenuItem* pDownBtn = m_vecDirBtn.at(BTNID_DOWN); RETURN_IF_NULLPTR(pDownBtn); MenuItem* pLeftBtn = m_vecDirBtn.at(BTNID_LEFT); RETURN_IF_NULLPTR(pLeftBtn); MenuItem* pUpBtn = m_vecDirBtn.at(BTNID_UP); RETURN_IF_NULLPTR(pUpBtn); MenuItem* pFireBtn = m_vecDirBtn.at(BTNID_FIRE); RETURN_IF_NULLPTR(pFireBtn); Size btnSize = GET_CONTENTSIZE(pUpBtn) * pUpBtn->getScale(); Size visibleSize = GET_VISIBLESIZE(); // Update controller position float fControllerCenterY = visibleSize.height - pUpBtn->getPositionY(); pFireBtn->setPositionY(visibleSize.height - pFireBtn->getPositionY()); pDownBtn->setPositionY(fControllerCenterY); pUpBtn->setPositionY(fControllerCenterY); pLeftBtn->setPositionY(fControllerCenterY + btnSize.height * 0.5f - CONTROLLER_INNER_PADDING); pRightBtn->setPositionY(fControllerCenterY - btnSize.height * 0.5f + CONTROLLER_INNER_PADDING); m_oControllerCenterPos.y = fControllerCenterY; // Update bottom button position m_pStartBtn->setPositionY(visibleSize.height - m_pStartBtn->getPositionY()); m_pSoundBtn->setPositionY(visibleSize.height - m_pSoundBtn->getPositionY()); m_pResetBtn->setPositionY(visibleSize.height - m_pResetBtn->getPositionY()); m_pSetupBtn->setPositionY(visibleSize.height - m_pSetupBtn->getPositionY()); } void CGameSceneEx::__InitTips() { Size visibleSize = GET_VISIBLESIZE(); m_pTipsLabel = Label::createWithSystemFont("123", FONT_NAME, TIPS_LABEL_SIZE); Color3B color = GET_BOOLVALUE("NIGHTMODE", false) ? Color3B::WHITE : Color3B::BLACK; m_pTipsLabel->setColor(color); m_pTipsLabel->setOpacity(0); m_pTipsLabel->setPosition(visibleSize.width * 0.5f, visibleSize.height * 0.5f); m_pTipsLabel->setRotation(90); this->addChild(m_pTipsLabel); }
33.941068
144
0.741671
lfeng1420
731157651556f53e1b0fd10738e263f79fd480aa
4,159
cc
C++
tests/registrationbuilder_tests.cc
aghoward/cdif
838bab6eb5c52f6cad47018860d37bb1d18c723f
[ "MIT" ]
10
2017-06-24T12:54:48.000Z
2020-02-17T07:58:33.000Z
tests/registrationbuilder_tests.cc
aghoward/cdif
838bab6eb5c52f6cad47018860d37bb1d18c723f
[ "MIT" ]
2
2018-01-26T19:01:03.000Z
2018-03-15T23:34:20.000Z
tests/registrationbuilder_tests.cc
aghoward/cdif
838bab6eb5c52f6cad47018860d37bb1d18c723f
[ "MIT" ]
null
null
null
#include "cdif.h" #include "test_types.h" #include <gtest/gtest.h> #include <functional> #include <string> #include <thread> class RegistrationBuilderTests : public ::testing::Test { protected: cdif::Container _subject; template <typename T> void givenRegistrationReturningValue(T value, const std::string& name = "") { auto factory = [value] () { return value; }; _subject.bind<T>(factory).named(name).build(); } public: RegistrationBuilderTests() : _subject(cdif::Container()) { }; }; TEST_F(RegistrationBuilderTests, Resolve_GivenNamedRegistration_ReturnsNamedItem) { auto name = "NamedInt"; auto expectedValue = 5; givenRegistrationReturningValue(expectedValue, name); givenRegistrationReturningValue(35); auto result = _subject.resolve<int>(name); ASSERT_EQ(expectedValue, result); } TEST_F(RegistrationBuilderTests, Resolve_GivenPerDependencyRegistration_ResolvesNewInstancePerCall) { givenRegistrationReturningValue(322); _subject.bind<SimpleImplementation, int>().in<cdif::Scope::PerDependency>().build(); auto* a = _subject.resolve<SimpleImplementation*>(); auto* b = _subject.resolve<SimpleImplementation*>(); ASSERT_NE(a, b); delete a; delete b; } TEST_F(RegistrationBuilderTests, Resolve_GivenSingletonRegistration_ResolvesSameInstancePerCall) { givenRegistrationReturningValue(322); _subject.bind<SimpleImplementation, int>().in<cdif::Scope::Singleton>().build(); auto& a = _subject.resolve<SimpleImplementation&>(); auto& b = _subject.resolve<SimpleImplementation&>(); ASSERT_EQ(std::addressof(a), std::addressof(b)); } TEST_F(RegistrationBuilderTests, Resolve_GivenSingletonRegistration_CanResolveReference) { givenRegistrationReturningValue(343); _subject.bind<SimpleImplementation, int>().in<cdif::Scope::Singleton>().build(); auto& result = _subject.resolve<SimpleImplementation&>(); ASSERT_NE(std::addressof(result), nullptr); } TEST_F(RegistrationBuilderTests, Resolve_GivenSingletonRegistration_CanResolveRawPointer) { givenRegistrationReturningValue(343); _subject.bind<SimpleImplementation, int>().in<cdif::Scope::Singleton>().build(); auto* result = _subject.resolve<SimpleImplementation*>(); ASSERT_NE(result, nullptr); } TEST_F(RegistrationBuilderTests, Resolve_GivenSingletonRegistration_CanResolveSharedPointer) { givenRegistrationReturningValue(343); _subject.bind<SimpleImplementation, int>().in<cdif::Scope::Singleton>().build(); auto result = _subject.resolve<std::shared_ptr<SimpleImplementation>>(); ASSERT_NE(result.get(), nullptr); } TEST_F(RegistrationBuilderTests, Resolve_GivenPerThreadRegistration_ResolvesNewInstancePerThread) { NonCopyable* first = nullptr, * second = nullptr; givenRegistrationReturningValue(333); _subject.bind<NonCopyable, int>().in<cdif::Scope::PerThread>().build(); auto functor = [&] (NonCopyable** ptr) { *ptr = _subject.resolve<NonCopyable*>(); }; auto t1 = std::thread(functor, &first); auto t2 = std::thread(functor, &second); t1.join(); t2.join(); ASSERT_NE(first, second); } TEST_F(RegistrationBuilderTests, Resolve_GivenPerThreadRegistration_ResolvesSingleInstanceInThread) { givenRegistrationReturningValue(343); _subject.bind<NonCopyable, int>().in<cdif::Scope::PerThread>().build(); auto functor = [&] () { auto* p1 = _subject.resolve<NonCopyable*>(); auto* p2 = _subject.resolve<NonCopyable*>(); ASSERT_EQ(p1, p2); }; auto t = std::thread(functor); t.join(); } TEST_F(RegistrationBuilderTests, Resolve_GivenRegistrationWithParameterFactory_ResolvesParametersFromFactory) { auto expectedValue = 324; givenRegistrationReturningValue(333333); _subject.bind<SimpleImplementation, int>() .withIndexedParameterFrom<0, int>([expectedValue] (const cdif::Container&) { return expectedValue; }) .build(); auto result = _subject.resolve<SimpleImplementation>(); ASSERT_EQ(expectedValue, result.m_data); }
29.707143
111
0.716999
aghoward
73121d342e29deaab3ef11167a551b144578f7db
3,475
cpp
C++
src/TableFunctions/TableFunctionS3.cpp
monadbobo/ClickHouse
73b0f8db8c327a1d63cc7ebcc56087a3f9866dae
[ "Apache-2.0" ]
null
null
null
src/TableFunctions/TableFunctionS3.cpp
monadbobo/ClickHouse
73b0f8db8c327a1d63cc7ebcc56087a3f9866dae
[ "Apache-2.0" ]
1
2020-04-04T04:25:47.000Z
2020-04-04T04:25:47.000Z
src/TableFunctions/TableFunctionS3.cpp
monadbobo/ClickHouse
73b0f8db8c327a1d63cc7ebcc56087a3f9866dae
[ "Apache-2.0" ]
null
null
null
#include <Common/config.h> #if USE_AWS_S3 #include <IO/S3Common.h> #include <Storages/StorageS3.h> #include <Access/AccessFlags.h> #include <Interpreters/evaluateConstantExpression.h> #include <Interpreters/Context.h> #include <TableFunctions/TableFunctionFactory.h> #include <TableFunctions/TableFunctionS3.h> #include <TableFunctions/parseColumnsListForTableFunction.h> #include <Parsers/ASTLiteral.h> #include "registerTableFunctions.h" namespace DB { namespace ErrorCodes { extern const int LOGICAL_ERROR; extern const int NUMBER_OF_ARGUMENTS_DOESNT_MATCH; } StoragePtr TableFunctionS3::executeImpl(const ASTPtr & ast_function, const Context & context, const std::string & table_name) const { /// Parse args ASTs & args_func = ast_function->children; if (args_func.size() != 1) throw Exception("Table function '" + getName() + "' must have arguments.", ErrorCodes::LOGICAL_ERROR); ASTs & args = args_func.at(0)->children; if (args.size() < 3 || args.size() > 6) throw Exception("Table function '" + getName() + "' requires 3 to 6 arguments: url, [access_key_id, secret_access_key,] format, structure and [compression_method].", ErrorCodes::NUMBER_OF_ARGUMENTS_DOESNT_MATCH); for (auto & arg : args) arg = evaluateConstantExpressionOrIdentifierAsLiteral(arg, context); String filename = args[0]->as<ASTLiteral &>().value.safeGet<String>(); String format; String structure; String access_key_id; String secret_access_key; if (args.size() < 5) { format = args[1]->as<ASTLiteral &>().value.safeGet<String>(); structure = args[2]->as<ASTLiteral &>().value.safeGet<String>(); } else { access_key_id = args[1]->as<ASTLiteral &>().value.safeGet<String>(); secret_access_key = args[2]->as<ASTLiteral &>().value.safeGet<String>(); format = args[3]->as<ASTLiteral &>().value.safeGet<String>(); structure = args[4]->as<ASTLiteral &>().value.safeGet<String>(); } String compression_method; if (args.size() == 4 || args.size() == 6) compression_method = args.back()->as<ASTLiteral &>().value.safeGet<String>(); else compression_method = "auto"; context.checkAccess(AccessType::s3); ColumnsDescription columns = parseColumnsListFromString(structure, context); /// Create table StoragePtr storage = getStorage(filename, access_key_id, secret_access_key, format, columns, const_cast<Context &>(context), table_name, compression_method); storage->startup(); return storage; } StoragePtr TableFunctionS3::getStorage( const String & source, const String & access_key_id, const String & secret_access_key, const String & format, const ColumnsDescription & columns, Context & global_context, const std::string & table_name, const String & compression_method) { Poco::URI uri (source); S3::URI s3_uri (uri); UInt64 min_upload_part_size = global_context.getSettingsRef().s3_min_upload_part_size; return StorageS3::create( s3_uri, access_key_id, secret_access_key, StorageID(getDatabaseName(), table_name), format, min_upload_part_size, columns, ConstraintsDescription{}, global_context, compression_method); } void registerTableFunctionS3(TableFunctionFactory & factory) { factory.registerFunction<TableFunctionS3>(); } } #endif
30.482456
173
0.688345
monadbobo
7314ebc2c980d79fa0bbb381775a016c107d5f95
1,004,280
cpp
C++
test/bidi_test_147.cpp
eightysquirrels/text
d935545648777786dc196a75346cde8906da846a
[ "BSL-1.0" ]
null
null
null
test/bidi_test_147.cpp
eightysquirrels/text
d935545648777786dc196a75346cde8906da846a
[ "BSL-1.0" ]
1
2021-03-05T12:56:59.000Z
2021-03-05T13:11:53.000Z
test/bidi_test_147.cpp
eightysquirrels/text
d935545648777786dc196a75346cde8906da846a
[ "BSL-1.0" ]
3
2019-10-30T18:38:15.000Z
2021-03-05T12:10:13.000Z
// Warning! This file is autogenerated. #include <boost/text/bidirectional.hpp> #include "bidi_tests.hpp" #include <gtest/gtest.h> #include <algorithm> std::vector<int> expected_levels; std::vector<int> expected_reordered_indices; TEST(bidi, bidi_147_000) { expected_levels = { 1, 1, -1, -1 }; expected_reordered_indices = { 1, 0 }; { // S PDI BN PDF; 4 ('RTL') (line 73501) std::vector<uint32_t> const cps = { 0x0009, 0x2069, 0x00AD, 0x202C }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // S PDI BN BN; 4 ('RTL') (line 73502) std::vector<uint32_t> const cps = { 0x0009, 0x2069, 0x00AD, 0x00AD }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS R LRE LRE; 5 ('auto') (line 73503) std::vector<uint32_t> const cps = { 0x0020, 0x05BE, 0x202A, 0x202A }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), -1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), -1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, -1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS R LRE LRE; 5 ('RTL') (line 73503) std::vector<uint32_t> const cps = { 0x0020, 0x05BE, 0x202A, 0x202A }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS R LRE LRO; 5 ('auto') (line 73504) std::vector<uint32_t> const cps = { 0x0020, 0x05BE, 0x202A, 0x202D }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), -1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), -1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, -1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS R LRE LRO; 5 ('RTL') (line 73504) std::vector<uint32_t> const cps = { 0x0020, 0x05BE, 0x202A, 0x202D }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS R LRE RLE; 5 ('auto') (line 73505) std::vector<uint32_t> const cps = { 0x0020, 0x05BE, 0x202A, 0x202B }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), -1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), -1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, -1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS R LRE RLE; 5 ('RTL') (line 73505) std::vector<uint32_t> const cps = { 0x0020, 0x05BE, 0x202A, 0x202B }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS R LRE RLO; 5 ('auto') (line 73506) std::vector<uint32_t> const cps = { 0x0020, 0x05BE, 0x202A, 0x202E }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), -1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), -1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, -1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS R LRE RLO; 5 ('RTL') (line 73506) std::vector<uint32_t> const cps = { 0x0020, 0x05BE, 0x202A, 0x202E }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS R LRE PDF; 5 ('auto') (line 73507) std::vector<uint32_t> const cps = { 0x0020, 0x05BE, 0x202A, 0x202C }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), -1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), -1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, -1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS R LRE PDF; 5 ('RTL') (line 73507) std::vector<uint32_t> const cps = { 0x0020, 0x05BE, 0x202A, 0x202C }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS R LRE BN; 5 ('auto') (line 73508) std::vector<uint32_t> const cps = { 0x0020, 0x05BE, 0x202A, 0x00AD }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), -1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), -1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, -1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS R LRE BN; 5 ('RTL') (line 73508) std::vector<uint32_t> const cps = { 0x0020, 0x05BE, 0x202A, 0x00AD }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS R LRO LRE; 5 ('auto') (line 73509) std::vector<uint32_t> const cps = { 0x0020, 0x05BE, 0x202D, 0x202A }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), -1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), -1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, -1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS R LRO LRE; 5 ('RTL') (line 73509) std::vector<uint32_t> const cps = { 0x0020, 0x05BE, 0x202D, 0x202A }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS R LRO LRO; 5 ('auto') (line 73510) std::vector<uint32_t> const cps = { 0x0020, 0x05BE, 0x202D, 0x202D }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), -1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), -1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, -1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS R LRO LRO; 5 ('RTL') (line 73510) std::vector<uint32_t> const cps = { 0x0020, 0x05BE, 0x202D, 0x202D }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } } TEST(bidi, bidi_147_001) { expected_levels = { 1, 1, -1, -1 }; expected_reordered_indices = { 1, 0 }; { // WS R LRO RLE; 5 ('auto') (line 73511) std::vector<uint32_t> const cps = { 0x0020, 0x05BE, 0x202D, 0x202B }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), -1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), -1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, -1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS R LRO RLE; 5 ('RTL') (line 73511) std::vector<uint32_t> const cps = { 0x0020, 0x05BE, 0x202D, 0x202B }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS R LRO RLO; 5 ('auto') (line 73512) std::vector<uint32_t> const cps = { 0x0020, 0x05BE, 0x202D, 0x202E }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), -1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), -1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, -1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS R LRO RLO; 5 ('RTL') (line 73512) std::vector<uint32_t> const cps = { 0x0020, 0x05BE, 0x202D, 0x202E }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS R LRO PDF; 5 ('auto') (line 73513) std::vector<uint32_t> const cps = { 0x0020, 0x05BE, 0x202D, 0x202C }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), -1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), -1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, -1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS R LRO PDF; 5 ('RTL') (line 73513) std::vector<uint32_t> const cps = { 0x0020, 0x05BE, 0x202D, 0x202C }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS R LRO BN; 5 ('auto') (line 73514) std::vector<uint32_t> const cps = { 0x0020, 0x05BE, 0x202D, 0x00AD }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), -1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), -1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, -1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS R LRO BN; 5 ('RTL') (line 73514) std::vector<uint32_t> const cps = { 0x0020, 0x05BE, 0x202D, 0x00AD }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS R RLE LRE; 5 ('auto') (line 73515) std::vector<uint32_t> const cps = { 0x0020, 0x05BE, 0x202B, 0x202A }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), -1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), -1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, -1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS R RLE LRE; 5 ('RTL') (line 73515) std::vector<uint32_t> const cps = { 0x0020, 0x05BE, 0x202B, 0x202A }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS R RLE LRO; 5 ('auto') (line 73516) std::vector<uint32_t> const cps = { 0x0020, 0x05BE, 0x202B, 0x202D }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), -1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), -1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, -1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS R RLE LRO; 5 ('RTL') (line 73516) std::vector<uint32_t> const cps = { 0x0020, 0x05BE, 0x202B, 0x202D }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS R RLE RLE; 5 ('auto') (line 73517) std::vector<uint32_t> const cps = { 0x0020, 0x05BE, 0x202B, 0x202B }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), -1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), -1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, -1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS R RLE RLE; 5 ('RTL') (line 73517) std::vector<uint32_t> const cps = { 0x0020, 0x05BE, 0x202B, 0x202B }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS R RLE RLO; 5 ('auto') (line 73518) std::vector<uint32_t> const cps = { 0x0020, 0x05BE, 0x202B, 0x202E }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), -1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), -1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, -1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS R RLE RLO; 5 ('RTL') (line 73518) std::vector<uint32_t> const cps = { 0x0020, 0x05BE, 0x202B, 0x202E }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS R RLE PDF; 5 ('auto') (line 73519) std::vector<uint32_t> const cps = { 0x0020, 0x05BE, 0x202B, 0x202C }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), -1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), -1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, -1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS R RLE PDF; 5 ('RTL') (line 73519) std::vector<uint32_t> const cps = { 0x0020, 0x05BE, 0x202B, 0x202C }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS R RLE BN; 5 ('auto') (line 73520) std::vector<uint32_t> const cps = { 0x0020, 0x05BE, 0x202B, 0x00AD }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), -1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), -1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, -1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS R RLE BN; 5 ('RTL') (line 73520) std::vector<uint32_t> const cps = { 0x0020, 0x05BE, 0x202B, 0x00AD }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } } TEST(bidi, bidi_147_002) { expected_levels = { 1, 1, -1, -1 }; expected_reordered_indices = { 1, 0 }; { // WS R RLO LRE; 5 ('auto') (line 73521) std::vector<uint32_t> const cps = { 0x0020, 0x05BE, 0x202E, 0x202A }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), -1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), -1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, -1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS R RLO LRE; 5 ('RTL') (line 73521) std::vector<uint32_t> const cps = { 0x0020, 0x05BE, 0x202E, 0x202A }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS R RLO LRO; 5 ('auto') (line 73522) std::vector<uint32_t> const cps = { 0x0020, 0x05BE, 0x202E, 0x202D }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), -1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), -1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, -1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS R RLO LRO; 5 ('RTL') (line 73522) std::vector<uint32_t> const cps = { 0x0020, 0x05BE, 0x202E, 0x202D }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS R RLO RLE; 5 ('auto') (line 73523) std::vector<uint32_t> const cps = { 0x0020, 0x05BE, 0x202E, 0x202B }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), -1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), -1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, -1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS R RLO RLE; 5 ('RTL') (line 73523) std::vector<uint32_t> const cps = { 0x0020, 0x05BE, 0x202E, 0x202B }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS R RLO RLO; 5 ('auto') (line 73524) std::vector<uint32_t> const cps = { 0x0020, 0x05BE, 0x202E, 0x202E }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), -1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), -1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, -1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS R RLO RLO; 5 ('RTL') (line 73524) std::vector<uint32_t> const cps = { 0x0020, 0x05BE, 0x202E, 0x202E }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS R RLO PDF; 5 ('auto') (line 73525) std::vector<uint32_t> const cps = { 0x0020, 0x05BE, 0x202E, 0x202C }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), -1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), -1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, -1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS R RLO PDF; 5 ('RTL') (line 73525) std::vector<uint32_t> const cps = { 0x0020, 0x05BE, 0x202E, 0x202C }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS R RLO BN; 5 ('auto') (line 73526) std::vector<uint32_t> const cps = { 0x0020, 0x05BE, 0x202E, 0x00AD }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), -1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), -1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, -1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS R RLO BN; 5 ('RTL') (line 73526) std::vector<uint32_t> const cps = { 0x0020, 0x05BE, 0x202E, 0x00AD }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS R PDF LRE; 5 ('auto') (line 73527) std::vector<uint32_t> const cps = { 0x0020, 0x05BE, 0x202C, 0x202A }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), -1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), -1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, -1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS R PDF LRE; 5 ('RTL') (line 73527) std::vector<uint32_t> const cps = { 0x0020, 0x05BE, 0x202C, 0x202A }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS R PDF LRO; 5 ('auto') (line 73528) std::vector<uint32_t> const cps = { 0x0020, 0x05BE, 0x202C, 0x202D }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), -1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), -1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, -1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS R PDF LRO; 5 ('RTL') (line 73528) std::vector<uint32_t> const cps = { 0x0020, 0x05BE, 0x202C, 0x202D }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS R PDF RLE; 5 ('auto') (line 73529) std::vector<uint32_t> const cps = { 0x0020, 0x05BE, 0x202C, 0x202B }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), -1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), -1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, -1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS R PDF RLE; 5 ('RTL') (line 73529) std::vector<uint32_t> const cps = { 0x0020, 0x05BE, 0x202C, 0x202B }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS R PDF RLO; 5 ('auto') (line 73530) std::vector<uint32_t> const cps = { 0x0020, 0x05BE, 0x202C, 0x202E }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), -1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), -1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, -1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS R PDF RLO; 5 ('RTL') (line 73530) std::vector<uint32_t> const cps = { 0x0020, 0x05BE, 0x202C, 0x202E }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } } TEST(bidi, bidi_147_003) { expected_levels = { 1, 1, -1, -1 }; expected_reordered_indices = { 1, 0 }; { // WS R PDF PDF; 5 ('auto') (line 73531) std::vector<uint32_t> const cps = { 0x0020, 0x05BE, 0x202C, 0x202C }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), -1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), -1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, -1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS R PDF PDF; 5 ('RTL') (line 73531) std::vector<uint32_t> const cps = { 0x0020, 0x05BE, 0x202C, 0x202C }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS R PDF BN; 5 ('auto') (line 73532) std::vector<uint32_t> const cps = { 0x0020, 0x05BE, 0x202C, 0x00AD }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), -1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), -1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, -1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS R PDF BN; 5 ('RTL') (line 73532) std::vector<uint32_t> const cps = { 0x0020, 0x05BE, 0x202C, 0x00AD }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS R BN LRE; 5 ('auto') (line 73533) std::vector<uint32_t> const cps = { 0x0020, 0x05BE, 0x00AD, 0x202A }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), -1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), -1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, -1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS R BN LRE; 5 ('RTL') (line 73533) std::vector<uint32_t> const cps = { 0x0020, 0x05BE, 0x00AD, 0x202A }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS R BN LRO; 5 ('auto') (line 73534) std::vector<uint32_t> const cps = { 0x0020, 0x05BE, 0x00AD, 0x202D }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), -1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), -1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, -1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS R BN LRO; 5 ('RTL') (line 73534) std::vector<uint32_t> const cps = { 0x0020, 0x05BE, 0x00AD, 0x202D }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS R BN RLE; 5 ('auto') (line 73535) std::vector<uint32_t> const cps = { 0x0020, 0x05BE, 0x00AD, 0x202B }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), -1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), -1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, -1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS R BN RLE; 5 ('RTL') (line 73535) std::vector<uint32_t> const cps = { 0x0020, 0x05BE, 0x00AD, 0x202B }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS R BN RLO; 5 ('auto') (line 73536) std::vector<uint32_t> const cps = { 0x0020, 0x05BE, 0x00AD, 0x202E }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), -1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), -1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, -1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS R BN RLO; 5 ('RTL') (line 73536) std::vector<uint32_t> const cps = { 0x0020, 0x05BE, 0x00AD, 0x202E }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS R BN PDF; 5 ('auto') (line 73537) std::vector<uint32_t> const cps = { 0x0020, 0x05BE, 0x00AD, 0x202C }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), -1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), -1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, -1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS R BN PDF; 5 ('RTL') (line 73537) std::vector<uint32_t> const cps = { 0x0020, 0x05BE, 0x00AD, 0x202C }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS R BN BN; 5 ('auto') (line 73538) std::vector<uint32_t> const cps = { 0x0020, 0x05BE, 0x00AD, 0x00AD }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), -1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), -1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, -1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS R BN BN; 5 ('RTL') (line 73538) std::vector<uint32_t> const cps = { 0x0020, 0x05BE, 0x00AD, 0x00AD }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS AL LRE LRE; 5 ('auto') (line 73539) std::vector<uint32_t> const cps = { 0x0020, 0x0608, 0x202A, 0x202A }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), -1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), -1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, -1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS AL LRE LRE; 5 ('RTL') (line 73539) std::vector<uint32_t> const cps = { 0x0020, 0x0608, 0x202A, 0x202A }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS AL LRE LRO; 5 ('auto') (line 73540) std::vector<uint32_t> const cps = { 0x0020, 0x0608, 0x202A, 0x202D }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), -1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), -1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, -1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS AL LRE LRO; 5 ('RTL') (line 73540) std::vector<uint32_t> const cps = { 0x0020, 0x0608, 0x202A, 0x202D }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } } TEST(bidi, bidi_147_004) { expected_levels = { 1, 1, -1, -1 }; expected_reordered_indices = { 1, 0 }; { // WS AL LRE RLE; 5 ('auto') (line 73541) std::vector<uint32_t> const cps = { 0x0020, 0x0608, 0x202A, 0x202B }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), -1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), -1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, -1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS AL LRE RLE; 5 ('RTL') (line 73541) std::vector<uint32_t> const cps = { 0x0020, 0x0608, 0x202A, 0x202B }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS AL LRE RLO; 5 ('auto') (line 73542) std::vector<uint32_t> const cps = { 0x0020, 0x0608, 0x202A, 0x202E }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), -1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), -1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, -1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS AL LRE RLO; 5 ('RTL') (line 73542) std::vector<uint32_t> const cps = { 0x0020, 0x0608, 0x202A, 0x202E }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS AL LRE PDF; 5 ('auto') (line 73543) std::vector<uint32_t> const cps = { 0x0020, 0x0608, 0x202A, 0x202C }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), -1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), -1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, -1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS AL LRE PDF; 5 ('RTL') (line 73543) std::vector<uint32_t> const cps = { 0x0020, 0x0608, 0x202A, 0x202C }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS AL LRE BN; 5 ('auto') (line 73544) std::vector<uint32_t> const cps = { 0x0020, 0x0608, 0x202A, 0x00AD }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), -1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), -1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, -1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS AL LRE BN; 5 ('RTL') (line 73544) std::vector<uint32_t> const cps = { 0x0020, 0x0608, 0x202A, 0x00AD }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS AL LRO LRE; 5 ('auto') (line 73545) std::vector<uint32_t> const cps = { 0x0020, 0x0608, 0x202D, 0x202A }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), -1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), -1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, -1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS AL LRO LRE; 5 ('RTL') (line 73545) std::vector<uint32_t> const cps = { 0x0020, 0x0608, 0x202D, 0x202A }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS AL LRO LRO; 5 ('auto') (line 73546) std::vector<uint32_t> const cps = { 0x0020, 0x0608, 0x202D, 0x202D }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), -1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), -1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, -1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS AL LRO LRO; 5 ('RTL') (line 73546) std::vector<uint32_t> const cps = { 0x0020, 0x0608, 0x202D, 0x202D }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS AL LRO RLE; 5 ('auto') (line 73547) std::vector<uint32_t> const cps = { 0x0020, 0x0608, 0x202D, 0x202B }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), -1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), -1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, -1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS AL LRO RLE; 5 ('RTL') (line 73547) std::vector<uint32_t> const cps = { 0x0020, 0x0608, 0x202D, 0x202B }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS AL LRO RLO; 5 ('auto') (line 73548) std::vector<uint32_t> const cps = { 0x0020, 0x0608, 0x202D, 0x202E }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), -1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), -1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, -1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS AL LRO RLO; 5 ('RTL') (line 73548) std::vector<uint32_t> const cps = { 0x0020, 0x0608, 0x202D, 0x202E }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS AL LRO PDF; 5 ('auto') (line 73549) std::vector<uint32_t> const cps = { 0x0020, 0x0608, 0x202D, 0x202C }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), -1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), -1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, -1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS AL LRO PDF; 5 ('RTL') (line 73549) std::vector<uint32_t> const cps = { 0x0020, 0x0608, 0x202D, 0x202C }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS AL LRO BN; 5 ('auto') (line 73550) std::vector<uint32_t> const cps = { 0x0020, 0x0608, 0x202D, 0x00AD }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), -1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), -1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, -1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS AL LRO BN; 5 ('RTL') (line 73550) std::vector<uint32_t> const cps = { 0x0020, 0x0608, 0x202D, 0x00AD }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } } TEST(bidi, bidi_147_005) { expected_levels = { 1, 1, -1, -1 }; expected_reordered_indices = { 1, 0 }; { // WS AL RLE LRE; 5 ('auto') (line 73551) std::vector<uint32_t> const cps = { 0x0020, 0x0608, 0x202B, 0x202A }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), -1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), -1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, -1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS AL RLE LRE; 5 ('RTL') (line 73551) std::vector<uint32_t> const cps = { 0x0020, 0x0608, 0x202B, 0x202A }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS AL RLE LRO; 5 ('auto') (line 73552) std::vector<uint32_t> const cps = { 0x0020, 0x0608, 0x202B, 0x202D }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), -1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), -1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, -1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS AL RLE LRO; 5 ('RTL') (line 73552) std::vector<uint32_t> const cps = { 0x0020, 0x0608, 0x202B, 0x202D }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS AL RLE RLE; 5 ('auto') (line 73553) std::vector<uint32_t> const cps = { 0x0020, 0x0608, 0x202B, 0x202B }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), -1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), -1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, -1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS AL RLE RLE; 5 ('RTL') (line 73553) std::vector<uint32_t> const cps = { 0x0020, 0x0608, 0x202B, 0x202B }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS AL RLE RLO; 5 ('auto') (line 73554) std::vector<uint32_t> const cps = { 0x0020, 0x0608, 0x202B, 0x202E }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), -1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), -1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, -1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS AL RLE RLO; 5 ('RTL') (line 73554) std::vector<uint32_t> const cps = { 0x0020, 0x0608, 0x202B, 0x202E }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS AL RLE PDF; 5 ('auto') (line 73555) std::vector<uint32_t> const cps = { 0x0020, 0x0608, 0x202B, 0x202C }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), -1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), -1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, -1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS AL RLE PDF; 5 ('RTL') (line 73555) std::vector<uint32_t> const cps = { 0x0020, 0x0608, 0x202B, 0x202C }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS AL RLE BN; 5 ('auto') (line 73556) std::vector<uint32_t> const cps = { 0x0020, 0x0608, 0x202B, 0x00AD }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), -1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), -1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, -1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS AL RLE BN; 5 ('RTL') (line 73556) std::vector<uint32_t> const cps = { 0x0020, 0x0608, 0x202B, 0x00AD }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS AL RLO LRE; 5 ('auto') (line 73557) std::vector<uint32_t> const cps = { 0x0020, 0x0608, 0x202E, 0x202A }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), -1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), -1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, -1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS AL RLO LRE; 5 ('RTL') (line 73557) std::vector<uint32_t> const cps = { 0x0020, 0x0608, 0x202E, 0x202A }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS AL RLO LRO; 5 ('auto') (line 73558) std::vector<uint32_t> const cps = { 0x0020, 0x0608, 0x202E, 0x202D }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), -1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), -1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, -1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS AL RLO LRO; 5 ('RTL') (line 73558) std::vector<uint32_t> const cps = { 0x0020, 0x0608, 0x202E, 0x202D }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS AL RLO RLE; 5 ('auto') (line 73559) std::vector<uint32_t> const cps = { 0x0020, 0x0608, 0x202E, 0x202B }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), -1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), -1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, -1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS AL RLO RLE; 5 ('RTL') (line 73559) std::vector<uint32_t> const cps = { 0x0020, 0x0608, 0x202E, 0x202B }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS AL RLO RLO; 5 ('auto') (line 73560) std::vector<uint32_t> const cps = { 0x0020, 0x0608, 0x202E, 0x202E }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), -1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), -1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, -1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS AL RLO RLO; 5 ('RTL') (line 73560) std::vector<uint32_t> const cps = { 0x0020, 0x0608, 0x202E, 0x202E }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } } TEST(bidi, bidi_147_006) { expected_levels = { 1, 1, -1, -1 }; expected_reordered_indices = { 1, 0 }; { // WS AL RLO PDF; 5 ('auto') (line 73561) std::vector<uint32_t> const cps = { 0x0020, 0x0608, 0x202E, 0x202C }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), -1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), -1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, -1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS AL RLO PDF; 5 ('RTL') (line 73561) std::vector<uint32_t> const cps = { 0x0020, 0x0608, 0x202E, 0x202C }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS AL RLO BN; 5 ('auto') (line 73562) std::vector<uint32_t> const cps = { 0x0020, 0x0608, 0x202E, 0x00AD }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), -1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), -1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, -1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS AL RLO BN; 5 ('RTL') (line 73562) std::vector<uint32_t> const cps = { 0x0020, 0x0608, 0x202E, 0x00AD }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS AL PDF LRE; 5 ('auto') (line 73563) std::vector<uint32_t> const cps = { 0x0020, 0x0608, 0x202C, 0x202A }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), -1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), -1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, -1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS AL PDF LRE; 5 ('RTL') (line 73563) std::vector<uint32_t> const cps = { 0x0020, 0x0608, 0x202C, 0x202A }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS AL PDF LRO; 5 ('auto') (line 73564) std::vector<uint32_t> const cps = { 0x0020, 0x0608, 0x202C, 0x202D }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), -1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), -1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, -1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS AL PDF LRO; 5 ('RTL') (line 73564) std::vector<uint32_t> const cps = { 0x0020, 0x0608, 0x202C, 0x202D }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS AL PDF RLE; 5 ('auto') (line 73565) std::vector<uint32_t> const cps = { 0x0020, 0x0608, 0x202C, 0x202B }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), -1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), -1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, -1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS AL PDF RLE; 5 ('RTL') (line 73565) std::vector<uint32_t> const cps = { 0x0020, 0x0608, 0x202C, 0x202B }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS AL PDF RLO; 5 ('auto') (line 73566) std::vector<uint32_t> const cps = { 0x0020, 0x0608, 0x202C, 0x202E }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), -1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), -1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, -1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS AL PDF RLO; 5 ('RTL') (line 73566) std::vector<uint32_t> const cps = { 0x0020, 0x0608, 0x202C, 0x202E }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS AL PDF PDF; 5 ('auto') (line 73567) std::vector<uint32_t> const cps = { 0x0020, 0x0608, 0x202C, 0x202C }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), -1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), -1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, -1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS AL PDF PDF; 5 ('RTL') (line 73567) std::vector<uint32_t> const cps = { 0x0020, 0x0608, 0x202C, 0x202C }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS AL PDF BN; 5 ('auto') (line 73568) std::vector<uint32_t> const cps = { 0x0020, 0x0608, 0x202C, 0x00AD }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), -1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), -1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, -1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS AL PDF BN; 5 ('RTL') (line 73568) std::vector<uint32_t> const cps = { 0x0020, 0x0608, 0x202C, 0x00AD }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS AL BN LRE; 5 ('auto') (line 73569) std::vector<uint32_t> const cps = { 0x0020, 0x0608, 0x00AD, 0x202A }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), -1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), -1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, -1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS AL BN LRE; 5 ('RTL') (line 73569) std::vector<uint32_t> const cps = { 0x0020, 0x0608, 0x00AD, 0x202A }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS AL BN LRO; 5 ('auto') (line 73570) std::vector<uint32_t> const cps = { 0x0020, 0x0608, 0x00AD, 0x202D }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), -1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), -1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, -1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS AL BN LRO; 5 ('RTL') (line 73570) std::vector<uint32_t> const cps = { 0x0020, 0x0608, 0x00AD, 0x202D }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } } TEST(bidi, bidi_147_007) { expected_levels = { 1, 1, -1, -1 }; expected_reordered_indices = { 1, 0 }; { // WS AL BN RLE; 5 ('auto') (line 73571) std::vector<uint32_t> const cps = { 0x0020, 0x0608, 0x00AD, 0x202B }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), -1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), -1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, -1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS AL BN RLE; 5 ('RTL') (line 73571) std::vector<uint32_t> const cps = { 0x0020, 0x0608, 0x00AD, 0x202B }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS AL BN RLO; 5 ('auto') (line 73572) std::vector<uint32_t> const cps = { 0x0020, 0x0608, 0x00AD, 0x202E }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), -1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), -1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, -1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS AL BN RLO; 5 ('RTL') (line 73572) std::vector<uint32_t> const cps = { 0x0020, 0x0608, 0x00AD, 0x202E }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS AL BN PDF; 5 ('auto') (line 73573) std::vector<uint32_t> const cps = { 0x0020, 0x0608, 0x00AD, 0x202C }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), -1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), -1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, -1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS AL BN PDF; 5 ('RTL') (line 73573) std::vector<uint32_t> const cps = { 0x0020, 0x0608, 0x00AD, 0x202C }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS AL BN BN; 5 ('auto') (line 73574) std::vector<uint32_t> const cps = { 0x0020, 0x0608, 0x00AD, 0x00AD }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), -1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), -1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, -1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS AL BN BN; 5 ('RTL') (line 73574) std::vector<uint32_t> const cps = { 0x0020, 0x0608, 0x00AD, 0x00AD }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS ES LRE LRE; 4 ('RTL') (line 73575) std::vector<uint32_t> const cps = { 0x0020, 0x002B, 0x202A, 0x202A }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS ES LRE LRO; 4 ('RTL') (line 73576) std::vector<uint32_t> const cps = { 0x0020, 0x002B, 0x202A, 0x202D }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS ES LRE RLE; 4 ('RTL') (line 73577) std::vector<uint32_t> const cps = { 0x0020, 0x002B, 0x202A, 0x202B }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS ES LRE RLO; 4 ('RTL') (line 73578) std::vector<uint32_t> const cps = { 0x0020, 0x002B, 0x202A, 0x202E }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS ES LRE PDF; 4 ('RTL') (line 73579) std::vector<uint32_t> const cps = { 0x0020, 0x002B, 0x202A, 0x202C }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS ES LRE BN; 4 ('RTL') (line 73580) std::vector<uint32_t> const cps = { 0x0020, 0x002B, 0x202A, 0x00AD }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } } TEST(bidi, bidi_147_008) { expected_levels = { 1, 1, -1, -1 }; expected_reordered_indices = { 1, 0 }; { // WS ES LRO LRE; 4 ('RTL') (line 73581) std::vector<uint32_t> const cps = { 0x0020, 0x002B, 0x202D, 0x202A }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS ES LRO LRO; 4 ('RTL') (line 73582) std::vector<uint32_t> const cps = { 0x0020, 0x002B, 0x202D, 0x202D }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS ES LRO RLE; 4 ('RTL') (line 73583) std::vector<uint32_t> const cps = { 0x0020, 0x002B, 0x202D, 0x202B }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS ES LRO RLO; 4 ('RTL') (line 73584) std::vector<uint32_t> const cps = { 0x0020, 0x002B, 0x202D, 0x202E }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS ES LRO PDF; 4 ('RTL') (line 73585) std::vector<uint32_t> const cps = { 0x0020, 0x002B, 0x202D, 0x202C }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS ES LRO BN; 4 ('RTL') (line 73586) std::vector<uint32_t> const cps = { 0x0020, 0x002B, 0x202D, 0x00AD }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS ES RLE LRE; 4 ('RTL') (line 73587) std::vector<uint32_t> const cps = { 0x0020, 0x002B, 0x202B, 0x202A }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS ES RLE LRO; 4 ('RTL') (line 73588) std::vector<uint32_t> const cps = { 0x0020, 0x002B, 0x202B, 0x202D }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS ES RLE RLE; 4 ('RTL') (line 73589) std::vector<uint32_t> const cps = { 0x0020, 0x002B, 0x202B, 0x202B }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS ES RLE RLO; 4 ('RTL') (line 73590) std::vector<uint32_t> const cps = { 0x0020, 0x002B, 0x202B, 0x202E }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } } TEST(bidi, bidi_147_009) { expected_levels = { 1, 1, -1, -1 }; expected_reordered_indices = { 1, 0 }; { // WS ES RLE PDF; 4 ('RTL') (line 73591) std::vector<uint32_t> const cps = { 0x0020, 0x002B, 0x202B, 0x202C }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS ES RLE BN; 4 ('RTL') (line 73592) std::vector<uint32_t> const cps = { 0x0020, 0x002B, 0x202B, 0x00AD }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS ES RLO LRE; 4 ('RTL') (line 73593) std::vector<uint32_t> const cps = { 0x0020, 0x002B, 0x202E, 0x202A }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS ES RLO LRO; 4 ('RTL') (line 73594) std::vector<uint32_t> const cps = { 0x0020, 0x002B, 0x202E, 0x202D }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS ES RLO RLE; 4 ('RTL') (line 73595) std::vector<uint32_t> const cps = { 0x0020, 0x002B, 0x202E, 0x202B }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS ES RLO RLO; 4 ('RTL') (line 73596) std::vector<uint32_t> const cps = { 0x0020, 0x002B, 0x202E, 0x202E }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS ES RLO PDF; 4 ('RTL') (line 73597) std::vector<uint32_t> const cps = { 0x0020, 0x002B, 0x202E, 0x202C }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS ES RLO BN; 4 ('RTL') (line 73598) std::vector<uint32_t> const cps = { 0x0020, 0x002B, 0x202E, 0x00AD }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS ES PDF LRE; 4 ('RTL') (line 73599) std::vector<uint32_t> const cps = { 0x0020, 0x002B, 0x202C, 0x202A }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS ES PDF LRO; 4 ('RTL') (line 73600) std::vector<uint32_t> const cps = { 0x0020, 0x002B, 0x202C, 0x202D }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } } TEST(bidi, bidi_147_010) { expected_levels = { 1, 1, -1, -1 }; expected_reordered_indices = { 1, 0 }; { // WS ES PDF RLE; 4 ('RTL') (line 73601) std::vector<uint32_t> const cps = { 0x0020, 0x002B, 0x202C, 0x202B }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS ES PDF RLO; 4 ('RTL') (line 73602) std::vector<uint32_t> const cps = { 0x0020, 0x002B, 0x202C, 0x202E }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS ES PDF PDF; 4 ('RTL') (line 73603) std::vector<uint32_t> const cps = { 0x0020, 0x002B, 0x202C, 0x202C }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS ES PDF BN; 4 ('RTL') (line 73604) std::vector<uint32_t> const cps = { 0x0020, 0x002B, 0x202C, 0x00AD }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS ES BN LRE; 4 ('RTL') (line 73605) std::vector<uint32_t> const cps = { 0x0020, 0x002B, 0x00AD, 0x202A }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS ES BN LRO; 4 ('RTL') (line 73606) std::vector<uint32_t> const cps = { 0x0020, 0x002B, 0x00AD, 0x202D }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS ES BN RLE; 4 ('RTL') (line 73607) std::vector<uint32_t> const cps = { 0x0020, 0x002B, 0x00AD, 0x202B }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS ES BN RLO; 4 ('RTL') (line 73608) std::vector<uint32_t> const cps = { 0x0020, 0x002B, 0x00AD, 0x202E }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS ES BN PDF; 4 ('RTL') (line 73609) std::vector<uint32_t> const cps = { 0x0020, 0x002B, 0x00AD, 0x202C }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS ES BN BN; 4 ('RTL') (line 73610) std::vector<uint32_t> const cps = { 0x0020, 0x002B, 0x00AD, 0x00AD }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } } TEST(bidi, bidi_147_011) { expected_levels = { 1, 1, -1, -1 }; expected_reordered_indices = { 1, 0 }; { // WS ET LRE LRE; 4 ('RTL') (line 73611) std::vector<uint32_t> const cps = { 0x0020, 0x0023, 0x202A, 0x202A }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS ET LRE LRO; 4 ('RTL') (line 73612) std::vector<uint32_t> const cps = { 0x0020, 0x0023, 0x202A, 0x202D }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS ET LRE RLE; 4 ('RTL') (line 73613) std::vector<uint32_t> const cps = { 0x0020, 0x0023, 0x202A, 0x202B }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS ET LRE RLO; 4 ('RTL') (line 73614) std::vector<uint32_t> const cps = { 0x0020, 0x0023, 0x202A, 0x202E }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS ET LRE PDF; 4 ('RTL') (line 73615) std::vector<uint32_t> const cps = { 0x0020, 0x0023, 0x202A, 0x202C }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS ET LRE BN; 4 ('RTL') (line 73616) std::vector<uint32_t> const cps = { 0x0020, 0x0023, 0x202A, 0x00AD }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS ET LRO LRE; 4 ('RTL') (line 73617) std::vector<uint32_t> const cps = { 0x0020, 0x0023, 0x202D, 0x202A }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS ET LRO LRO; 4 ('RTL') (line 73618) std::vector<uint32_t> const cps = { 0x0020, 0x0023, 0x202D, 0x202D }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS ET LRO RLE; 4 ('RTL') (line 73619) std::vector<uint32_t> const cps = { 0x0020, 0x0023, 0x202D, 0x202B }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS ET LRO RLO; 4 ('RTL') (line 73620) std::vector<uint32_t> const cps = { 0x0020, 0x0023, 0x202D, 0x202E }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } } TEST(bidi, bidi_147_012) { expected_levels = { 1, 1, -1, -1 }; expected_reordered_indices = { 1, 0 }; { // WS ET LRO PDF; 4 ('RTL') (line 73621) std::vector<uint32_t> const cps = { 0x0020, 0x0023, 0x202D, 0x202C }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS ET LRO BN; 4 ('RTL') (line 73622) std::vector<uint32_t> const cps = { 0x0020, 0x0023, 0x202D, 0x00AD }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS ET RLE LRE; 4 ('RTL') (line 73623) std::vector<uint32_t> const cps = { 0x0020, 0x0023, 0x202B, 0x202A }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS ET RLE LRO; 4 ('RTL') (line 73624) std::vector<uint32_t> const cps = { 0x0020, 0x0023, 0x202B, 0x202D }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS ET RLE RLE; 4 ('RTL') (line 73625) std::vector<uint32_t> const cps = { 0x0020, 0x0023, 0x202B, 0x202B }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS ET RLE RLO; 4 ('RTL') (line 73626) std::vector<uint32_t> const cps = { 0x0020, 0x0023, 0x202B, 0x202E }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS ET RLE PDF; 4 ('RTL') (line 73627) std::vector<uint32_t> const cps = { 0x0020, 0x0023, 0x202B, 0x202C }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS ET RLE BN; 4 ('RTL') (line 73628) std::vector<uint32_t> const cps = { 0x0020, 0x0023, 0x202B, 0x00AD }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS ET RLO LRE; 4 ('RTL') (line 73629) std::vector<uint32_t> const cps = { 0x0020, 0x0023, 0x202E, 0x202A }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS ET RLO LRO; 4 ('RTL') (line 73630) std::vector<uint32_t> const cps = { 0x0020, 0x0023, 0x202E, 0x202D }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } } TEST(bidi, bidi_147_013) { expected_levels = { 1, 1, -1, -1 }; expected_reordered_indices = { 1, 0 }; { // WS ET RLO RLE; 4 ('RTL') (line 73631) std::vector<uint32_t> const cps = { 0x0020, 0x0023, 0x202E, 0x202B }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS ET RLO RLO; 4 ('RTL') (line 73632) std::vector<uint32_t> const cps = { 0x0020, 0x0023, 0x202E, 0x202E }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS ET RLO PDF; 4 ('RTL') (line 73633) std::vector<uint32_t> const cps = { 0x0020, 0x0023, 0x202E, 0x202C }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS ET RLO BN; 4 ('RTL') (line 73634) std::vector<uint32_t> const cps = { 0x0020, 0x0023, 0x202E, 0x00AD }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS ET PDF LRE; 4 ('RTL') (line 73635) std::vector<uint32_t> const cps = { 0x0020, 0x0023, 0x202C, 0x202A }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS ET PDF LRO; 4 ('RTL') (line 73636) std::vector<uint32_t> const cps = { 0x0020, 0x0023, 0x202C, 0x202D }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS ET PDF RLE; 4 ('RTL') (line 73637) std::vector<uint32_t> const cps = { 0x0020, 0x0023, 0x202C, 0x202B }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS ET PDF RLO; 4 ('RTL') (line 73638) std::vector<uint32_t> const cps = { 0x0020, 0x0023, 0x202C, 0x202E }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS ET PDF PDF; 4 ('RTL') (line 73639) std::vector<uint32_t> const cps = { 0x0020, 0x0023, 0x202C, 0x202C }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS ET PDF BN; 4 ('RTL') (line 73640) std::vector<uint32_t> const cps = { 0x0020, 0x0023, 0x202C, 0x00AD }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } } TEST(bidi, bidi_147_014) { expected_levels = { 1, 1, -1, -1 }; expected_reordered_indices = { 1, 0 }; { // WS ET BN LRE; 4 ('RTL') (line 73641) std::vector<uint32_t> const cps = { 0x0020, 0x0023, 0x00AD, 0x202A }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS ET BN LRO; 4 ('RTL') (line 73642) std::vector<uint32_t> const cps = { 0x0020, 0x0023, 0x00AD, 0x202D }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS ET BN RLE; 4 ('RTL') (line 73643) std::vector<uint32_t> const cps = { 0x0020, 0x0023, 0x00AD, 0x202B }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS ET BN RLO; 4 ('RTL') (line 73644) std::vector<uint32_t> const cps = { 0x0020, 0x0023, 0x00AD, 0x202E }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS ET BN PDF; 4 ('RTL') (line 73645) std::vector<uint32_t> const cps = { 0x0020, 0x0023, 0x00AD, 0x202C }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS ET BN BN; 4 ('RTL') (line 73646) std::vector<uint32_t> const cps = { 0x0020, 0x0023, 0x00AD, 0x00AD }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS CS LRE LRE; 4 ('RTL') (line 73647) std::vector<uint32_t> const cps = { 0x0020, 0x002C, 0x202A, 0x202A }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS CS LRE LRO; 4 ('RTL') (line 73648) std::vector<uint32_t> const cps = { 0x0020, 0x002C, 0x202A, 0x202D }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS CS LRE RLE; 4 ('RTL') (line 73649) std::vector<uint32_t> const cps = { 0x0020, 0x002C, 0x202A, 0x202B }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS CS LRE RLO; 4 ('RTL') (line 73650) std::vector<uint32_t> const cps = { 0x0020, 0x002C, 0x202A, 0x202E }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } } TEST(bidi, bidi_147_015) { expected_levels = { 1, 1, -1, -1 }; expected_reordered_indices = { 1, 0 }; { // WS CS LRE PDF; 4 ('RTL') (line 73651) std::vector<uint32_t> const cps = { 0x0020, 0x002C, 0x202A, 0x202C }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS CS LRE BN; 4 ('RTL') (line 73652) std::vector<uint32_t> const cps = { 0x0020, 0x002C, 0x202A, 0x00AD }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS CS LRO LRE; 4 ('RTL') (line 73653) std::vector<uint32_t> const cps = { 0x0020, 0x002C, 0x202D, 0x202A }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS CS LRO LRO; 4 ('RTL') (line 73654) std::vector<uint32_t> const cps = { 0x0020, 0x002C, 0x202D, 0x202D }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS CS LRO RLE; 4 ('RTL') (line 73655) std::vector<uint32_t> const cps = { 0x0020, 0x002C, 0x202D, 0x202B }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS CS LRO RLO; 4 ('RTL') (line 73656) std::vector<uint32_t> const cps = { 0x0020, 0x002C, 0x202D, 0x202E }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS CS LRO PDF; 4 ('RTL') (line 73657) std::vector<uint32_t> const cps = { 0x0020, 0x002C, 0x202D, 0x202C }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS CS LRO BN; 4 ('RTL') (line 73658) std::vector<uint32_t> const cps = { 0x0020, 0x002C, 0x202D, 0x00AD }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS CS RLE LRE; 4 ('RTL') (line 73659) std::vector<uint32_t> const cps = { 0x0020, 0x002C, 0x202B, 0x202A }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS CS RLE LRO; 4 ('RTL') (line 73660) std::vector<uint32_t> const cps = { 0x0020, 0x002C, 0x202B, 0x202D }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } } TEST(bidi, bidi_147_016) { expected_levels = { 1, 1, -1, -1 }; expected_reordered_indices = { 1, 0 }; { // WS CS RLE RLE; 4 ('RTL') (line 73661) std::vector<uint32_t> const cps = { 0x0020, 0x002C, 0x202B, 0x202B }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS CS RLE RLO; 4 ('RTL') (line 73662) std::vector<uint32_t> const cps = { 0x0020, 0x002C, 0x202B, 0x202E }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS CS RLE PDF; 4 ('RTL') (line 73663) std::vector<uint32_t> const cps = { 0x0020, 0x002C, 0x202B, 0x202C }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS CS RLE BN; 4 ('RTL') (line 73664) std::vector<uint32_t> const cps = { 0x0020, 0x002C, 0x202B, 0x00AD }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS CS RLO LRE; 4 ('RTL') (line 73665) std::vector<uint32_t> const cps = { 0x0020, 0x002C, 0x202E, 0x202A }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS CS RLO LRO; 4 ('RTL') (line 73666) std::vector<uint32_t> const cps = { 0x0020, 0x002C, 0x202E, 0x202D }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS CS RLO RLE; 4 ('RTL') (line 73667) std::vector<uint32_t> const cps = { 0x0020, 0x002C, 0x202E, 0x202B }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS CS RLO RLO; 4 ('RTL') (line 73668) std::vector<uint32_t> const cps = { 0x0020, 0x002C, 0x202E, 0x202E }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS CS RLO PDF; 4 ('RTL') (line 73669) std::vector<uint32_t> const cps = { 0x0020, 0x002C, 0x202E, 0x202C }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS CS RLO BN; 4 ('RTL') (line 73670) std::vector<uint32_t> const cps = { 0x0020, 0x002C, 0x202E, 0x00AD }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } } TEST(bidi, bidi_147_017) { expected_levels = { 1, 1, -1, -1 }; expected_reordered_indices = { 1, 0 }; { // WS CS PDF LRE; 4 ('RTL') (line 73671) std::vector<uint32_t> const cps = { 0x0020, 0x002C, 0x202C, 0x202A }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS CS PDF LRO; 4 ('RTL') (line 73672) std::vector<uint32_t> const cps = { 0x0020, 0x002C, 0x202C, 0x202D }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS CS PDF RLE; 4 ('RTL') (line 73673) std::vector<uint32_t> const cps = { 0x0020, 0x002C, 0x202C, 0x202B }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS CS PDF RLO; 4 ('RTL') (line 73674) std::vector<uint32_t> const cps = { 0x0020, 0x002C, 0x202C, 0x202E }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS CS PDF PDF; 4 ('RTL') (line 73675) std::vector<uint32_t> const cps = { 0x0020, 0x002C, 0x202C, 0x202C }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS CS PDF BN; 4 ('RTL') (line 73676) std::vector<uint32_t> const cps = { 0x0020, 0x002C, 0x202C, 0x00AD }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS CS BN LRE; 4 ('RTL') (line 73677) std::vector<uint32_t> const cps = { 0x0020, 0x002C, 0x00AD, 0x202A }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS CS BN LRO; 4 ('RTL') (line 73678) std::vector<uint32_t> const cps = { 0x0020, 0x002C, 0x00AD, 0x202D }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS CS BN RLE; 4 ('RTL') (line 73679) std::vector<uint32_t> const cps = { 0x0020, 0x002C, 0x00AD, 0x202B }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS CS BN RLO; 4 ('RTL') (line 73680) std::vector<uint32_t> const cps = { 0x0020, 0x002C, 0x00AD, 0x202E }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } } TEST(bidi, bidi_147_018) { expected_levels = { 1, 1, -1, -1 }; expected_reordered_indices = { 1, 0 }; { // WS CS BN PDF; 4 ('RTL') (line 73681) std::vector<uint32_t> const cps = { 0x0020, 0x002C, 0x00AD, 0x202C }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS CS BN BN; 4 ('RTL') (line 73682) std::vector<uint32_t> const cps = { 0x0020, 0x002C, 0x00AD, 0x00AD }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS NSM LRE LRE; 4 ('RTL') (line 73683) std::vector<uint32_t> const cps = { 0x0020, 0x0300, 0x202A, 0x202A }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS NSM LRE LRO; 4 ('RTL') (line 73684) std::vector<uint32_t> const cps = { 0x0020, 0x0300, 0x202A, 0x202D }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS NSM LRE RLE; 4 ('RTL') (line 73685) std::vector<uint32_t> const cps = { 0x0020, 0x0300, 0x202A, 0x202B }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS NSM LRE RLO; 4 ('RTL') (line 73686) std::vector<uint32_t> const cps = { 0x0020, 0x0300, 0x202A, 0x202E }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS NSM LRE PDF; 4 ('RTL') (line 73687) std::vector<uint32_t> const cps = { 0x0020, 0x0300, 0x202A, 0x202C }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS NSM LRE BN; 4 ('RTL') (line 73688) std::vector<uint32_t> const cps = { 0x0020, 0x0300, 0x202A, 0x00AD }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS NSM LRO LRE; 4 ('RTL') (line 73689) std::vector<uint32_t> const cps = { 0x0020, 0x0300, 0x202D, 0x202A }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS NSM LRO LRO; 4 ('RTL') (line 73690) std::vector<uint32_t> const cps = { 0x0020, 0x0300, 0x202D, 0x202D }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } } TEST(bidi, bidi_147_019) { expected_levels = { 1, 1, -1, -1 }; expected_reordered_indices = { 1, 0 }; { // WS NSM LRO RLE; 4 ('RTL') (line 73691) std::vector<uint32_t> const cps = { 0x0020, 0x0300, 0x202D, 0x202B }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS NSM LRO RLO; 4 ('RTL') (line 73692) std::vector<uint32_t> const cps = { 0x0020, 0x0300, 0x202D, 0x202E }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS NSM LRO PDF; 4 ('RTL') (line 73693) std::vector<uint32_t> const cps = { 0x0020, 0x0300, 0x202D, 0x202C }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS NSM LRO BN; 4 ('RTL') (line 73694) std::vector<uint32_t> const cps = { 0x0020, 0x0300, 0x202D, 0x00AD }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS NSM RLE LRE; 4 ('RTL') (line 73695) std::vector<uint32_t> const cps = { 0x0020, 0x0300, 0x202B, 0x202A }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS NSM RLE LRO; 4 ('RTL') (line 73696) std::vector<uint32_t> const cps = { 0x0020, 0x0300, 0x202B, 0x202D }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS NSM RLE RLE; 4 ('RTL') (line 73697) std::vector<uint32_t> const cps = { 0x0020, 0x0300, 0x202B, 0x202B }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS NSM RLE RLO; 4 ('RTL') (line 73698) std::vector<uint32_t> const cps = { 0x0020, 0x0300, 0x202B, 0x202E }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS NSM RLE PDF; 4 ('RTL') (line 73699) std::vector<uint32_t> const cps = { 0x0020, 0x0300, 0x202B, 0x202C }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS NSM RLE BN; 4 ('RTL') (line 73700) std::vector<uint32_t> const cps = { 0x0020, 0x0300, 0x202B, 0x00AD }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } } TEST(bidi, bidi_147_020) { expected_levels = { 1, 1, -1, -1 }; expected_reordered_indices = { 1, 0 }; { // WS NSM RLO LRE; 4 ('RTL') (line 73701) std::vector<uint32_t> const cps = { 0x0020, 0x0300, 0x202E, 0x202A }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS NSM RLO LRO; 4 ('RTL') (line 73702) std::vector<uint32_t> const cps = { 0x0020, 0x0300, 0x202E, 0x202D }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS NSM RLO RLE; 4 ('RTL') (line 73703) std::vector<uint32_t> const cps = { 0x0020, 0x0300, 0x202E, 0x202B }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS NSM RLO RLO; 4 ('RTL') (line 73704) std::vector<uint32_t> const cps = { 0x0020, 0x0300, 0x202E, 0x202E }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS NSM RLO PDF; 4 ('RTL') (line 73705) std::vector<uint32_t> const cps = { 0x0020, 0x0300, 0x202E, 0x202C }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS NSM RLO BN; 4 ('RTL') (line 73706) std::vector<uint32_t> const cps = { 0x0020, 0x0300, 0x202E, 0x00AD }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS NSM PDF LRE; 4 ('RTL') (line 73707) std::vector<uint32_t> const cps = { 0x0020, 0x0300, 0x202C, 0x202A }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS NSM PDF LRO; 4 ('RTL') (line 73708) std::vector<uint32_t> const cps = { 0x0020, 0x0300, 0x202C, 0x202D }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS NSM PDF RLE; 4 ('RTL') (line 73709) std::vector<uint32_t> const cps = { 0x0020, 0x0300, 0x202C, 0x202B }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS NSM PDF RLO; 4 ('RTL') (line 73710) std::vector<uint32_t> const cps = { 0x0020, 0x0300, 0x202C, 0x202E }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } } TEST(bidi, bidi_147_021) { expected_levels = { 1, 1, -1, -1 }; expected_reordered_indices = { 1, 0 }; { // WS NSM PDF PDF; 4 ('RTL') (line 73711) std::vector<uint32_t> const cps = { 0x0020, 0x0300, 0x202C, 0x202C }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS NSM PDF BN; 4 ('RTL') (line 73712) std::vector<uint32_t> const cps = { 0x0020, 0x0300, 0x202C, 0x00AD }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS NSM BN LRE; 4 ('RTL') (line 73713) std::vector<uint32_t> const cps = { 0x0020, 0x0300, 0x00AD, 0x202A }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS NSM BN LRO; 4 ('RTL') (line 73714) std::vector<uint32_t> const cps = { 0x0020, 0x0300, 0x00AD, 0x202D }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS NSM BN RLE; 4 ('RTL') (line 73715) std::vector<uint32_t> const cps = { 0x0020, 0x0300, 0x00AD, 0x202B }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS NSM BN RLO; 4 ('RTL') (line 73716) std::vector<uint32_t> const cps = { 0x0020, 0x0300, 0x00AD, 0x202E }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS NSM BN PDF; 4 ('RTL') (line 73717) std::vector<uint32_t> const cps = { 0x0020, 0x0300, 0x00AD, 0x202C }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS NSM BN BN; 4 ('RTL') (line 73718) std::vector<uint32_t> const cps = { 0x0020, 0x0300, 0x00AD, 0x00AD }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS S LRE LRE; 4 ('RTL') (line 73719) std::vector<uint32_t> const cps = { 0x0020, 0x0009, 0x202A, 0x202A }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS S LRE LRO; 4 ('RTL') (line 73720) std::vector<uint32_t> const cps = { 0x0020, 0x0009, 0x202A, 0x202D }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } } TEST(bidi, bidi_147_022) { expected_levels = { 1, 1, -1, -1 }; expected_reordered_indices = { 1, 0 }; { // WS S LRE RLE; 4 ('RTL') (line 73721) std::vector<uint32_t> const cps = { 0x0020, 0x0009, 0x202A, 0x202B }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS S LRE RLO; 4 ('RTL') (line 73722) std::vector<uint32_t> const cps = { 0x0020, 0x0009, 0x202A, 0x202E }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS S LRE PDF; 4 ('RTL') (line 73723) std::vector<uint32_t> const cps = { 0x0020, 0x0009, 0x202A, 0x202C }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS S LRE BN; 4 ('RTL') (line 73724) std::vector<uint32_t> const cps = { 0x0020, 0x0009, 0x202A, 0x00AD }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS S LRO LRE; 4 ('RTL') (line 73725) std::vector<uint32_t> const cps = { 0x0020, 0x0009, 0x202D, 0x202A }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS S LRO LRO; 4 ('RTL') (line 73726) std::vector<uint32_t> const cps = { 0x0020, 0x0009, 0x202D, 0x202D }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS S LRO RLE; 4 ('RTL') (line 73727) std::vector<uint32_t> const cps = { 0x0020, 0x0009, 0x202D, 0x202B }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS S LRO RLO; 4 ('RTL') (line 73728) std::vector<uint32_t> const cps = { 0x0020, 0x0009, 0x202D, 0x202E }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS S LRO PDF; 4 ('RTL') (line 73729) std::vector<uint32_t> const cps = { 0x0020, 0x0009, 0x202D, 0x202C }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS S LRO BN; 4 ('RTL') (line 73730) std::vector<uint32_t> const cps = { 0x0020, 0x0009, 0x202D, 0x00AD }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } } TEST(bidi, bidi_147_023) { expected_levels = { 1, 1, -1, -1 }; expected_reordered_indices = { 1, 0 }; { // WS S RLE LRE; 4 ('RTL') (line 73731) std::vector<uint32_t> const cps = { 0x0020, 0x0009, 0x202B, 0x202A }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS S RLE LRO; 4 ('RTL') (line 73732) std::vector<uint32_t> const cps = { 0x0020, 0x0009, 0x202B, 0x202D }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS S RLE RLE; 4 ('RTL') (line 73733) std::vector<uint32_t> const cps = { 0x0020, 0x0009, 0x202B, 0x202B }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS S RLE RLO; 4 ('RTL') (line 73734) std::vector<uint32_t> const cps = { 0x0020, 0x0009, 0x202B, 0x202E }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS S RLE PDF; 4 ('RTL') (line 73735) std::vector<uint32_t> const cps = { 0x0020, 0x0009, 0x202B, 0x202C }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS S RLE BN; 4 ('RTL') (line 73736) std::vector<uint32_t> const cps = { 0x0020, 0x0009, 0x202B, 0x00AD }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS S RLO LRE; 4 ('RTL') (line 73737) std::vector<uint32_t> const cps = { 0x0020, 0x0009, 0x202E, 0x202A }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS S RLO LRO; 4 ('RTL') (line 73738) std::vector<uint32_t> const cps = { 0x0020, 0x0009, 0x202E, 0x202D }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS S RLO RLE; 4 ('RTL') (line 73739) std::vector<uint32_t> const cps = { 0x0020, 0x0009, 0x202E, 0x202B }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS S RLO RLO; 4 ('RTL') (line 73740) std::vector<uint32_t> const cps = { 0x0020, 0x0009, 0x202E, 0x202E }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } } TEST(bidi, bidi_147_024) { expected_levels = { 1, 1, -1, -1 }; expected_reordered_indices = { 1, 0 }; { // WS S RLO PDF; 4 ('RTL') (line 73741) std::vector<uint32_t> const cps = { 0x0020, 0x0009, 0x202E, 0x202C }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS S RLO BN; 4 ('RTL') (line 73742) std::vector<uint32_t> const cps = { 0x0020, 0x0009, 0x202E, 0x00AD }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS S PDF LRE; 4 ('RTL') (line 73743) std::vector<uint32_t> const cps = { 0x0020, 0x0009, 0x202C, 0x202A }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS S PDF LRO; 4 ('RTL') (line 73744) std::vector<uint32_t> const cps = { 0x0020, 0x0009, 0x202C, 0x202D }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS S PDF RLE; 4 ('RTL') (line 73745) std::vector<uint32_t> const cps = { 0x0020, 0x0009, 0x202C, 0x202B }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS S PDF RLO; 4 ('RTL') (line 73746) std::vector<uint32_t> const cps = { 0x0020, 0x0009, 0x202C, 0x202E }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS S PDF PDF; 4 ('RTL') (line 73747) std::vector<uint32_t> const cps = { 0x0020, 0x0009, 0x202C, 0x202C }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS S PDF BN; 4 ('RTL') (line 73748) std::vector<uint32_t> const cps = { 0x0020, 0x0009, 0x202C, 0x00AD }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS S BN LRE; 4 ('RTL') (line 73749) std::vector<uint32_t> const cps = { 0x0020, 0x0009, 0x00AD, 0x202A }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS S BN LRO; 4 ('RTL') (line 73750) std::vector<uint32_t> const cps = { 0x0020, 0x0009, 0x00AD, 0x202D }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } } TEST(bidi, bidi_147_025) { expected_levels = { 1, 1, -1, -1 }; expected_reordered_indices = { 1, 0 }; { // WS S BN RLE; 4 ('RTL') (line 73751) std::vector<uint32_t> const cps = { 0x0020, 0x0009, 0x00AD, 0x202B }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS S BN RLO; 4 ('RTL') (line 73752) std::vector<uint32_t> const cps = { 0x0020, 0x0009, 0x00AD, 0x202E }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS S BN PDF; 4 ('RTL') (line 73753) std::vector<uint32_t> const cps = { 0x0020, 0x0009, 0x00AD, 0x202C }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS S BN BN; 4 ('RTL') (line 73754) std::vector<uint32_t> const cps = { 0x0020, 0x0009, 0x00AD, 0x00AD }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS WS LRE LRE; 4 ('RTL') (line 73755) std::vector<uint32_t> const cps = { 0x0020, 0x0020, 0x202A, 0x202A }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS WS LRE LRO; 4 ('RTL') (line 73756) std::vector<uint32_t> const cps = { 0x0020, 0x0020, 0x202A, 0x202D }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS WS LRE RLE; 4 ('RTL') (line 73757) std::vector<uint32_t> const cps = { 0x0020, 0x0020, 0x202A, 0x202B }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS WS LRE RLO; 4 ('RTL') (line 73758) std::vector<uint32_t> const cps = { 0x0020, 0x0020, 0x202A, 0x202E }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS WS LRE PDF; 4 ('RTL') (line 73759) std::vector<uint32_t> const cps = { 0x0020, 0x0020, 0x202A, 0x202C }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS WS LRE BN; 4 ('RTL') (line 73760) std::vector<uint32_t> const cps = { 0x0020, 0x0020, 0x202A, 0x00AD }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } } TEST(bidi, bidi_147_026) { expected_levels = { 1, 1, -1, -1 }; expected_reordered_indices = { 1, 0 }; { // WS WS LRO LRE; 4 ('RTL') (line 73761) std::vector<uint32_t> const cps = { 0x0020, 0x0020, 0x202D, 0x202A }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS WS LRO LRO; 4 ('RTL') (line 73762) std::vector<uint32_t> const cps = { 0x0020, 0x0020, 0x202D, 0x202D }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS WS LRO RLE; 4 ('RTL') (line 73763) std::vector<uint32_t> const cps = { 0x0020, 0x0020, 0x202D, 0x202B }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS WS LRO RLO; 4 ('RTL') (line 73764) std::vector<uint32_t> const cps = { 0x0020, 0x0020, 0x202D, 0x202E }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS WS LRO PDF; 4 ('RTL') (line 73765) std::vector<uint32_t> const cps = { 0x0020, 0x0020, 0x202D, 0x202C }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS WS LRO BN; 4 ('RTL') (line 73766) std::vector<uint32_t> const cps = { 0x0020, 0x0020, 0x202D, 0x00AD }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS WS RLE LRE; 4 ('RTL') (line 73767) std::vector<uint32_t> const cps = { 0x0020, 0x0020, 0x202B, 0x202A }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS WS RLE LRO; 4 ('RTL') (line 73768) std::vector<uint32_t> const cps = { 0x0020, 0x0020, 0x202B, 0x202D }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS WS RLE RLE; 4 ('RTL') (line 73769) std::vector<uint32_t> const cps = { 0x0020, 0x0020, 0x202B, 0x202B }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS WS RLE RLO; 4 ('RTL') (line 73770) std::vector<uint32_t> const cps = { 0x0020, 0x0020, 0x202B, 0x202E }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } } TEST(bidi, bidi_147_027) { expected_levels = { 1, 1, -1, -1 }; expected_reordered_indices = { 1, 0 }; { // WS WS RLE PDF; 4 ('RTL') (line 73771) std::vector<uint32_t> const cps = { 0x0020, 0x0020, 0x202B, 0x202C }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS WS RLE BN; 4 ('RTL') (line 73772) std::vector<uint32_t> const cps = { 0x0020, 0x0020, 0x202B, 0x00AD }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS WS RLO LRE; 4 ('RTL') (line 73773) std::vector<uint32_t> const cps = { 0x0020, 0x0020, 0x202E, 0x202A }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS WS RLO LRO; 4 ('RTL') (line 73774) std::vector<uint32_t> const cps = { 0x0020, 0x0020, 0x202E, 0x202D }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS WS RLO RLE; 4 ('RTL') (line 73775) std::vector<uint32_t> const cps = { 0x0020, 0x0020, 0x202E, 0x202B }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS WS RLO RLO; 4 ('RTL') (line 73776) std::vector<uint32_t> const cps = { 0x0020, 0x0020, 0x202E, 0x202E }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS WS RLO PDF; 4 ('RTL') (line 73777) std::vector<uint32_t> const cps = { 0x0020, 0x0020, 0x202E, 0x202C }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS WS RLO BN; 4 ('RTL') (line 73778) std::vector<uint32_t> const cps = { 0x0020, 0x0020, 0x202E, 0x00AD }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS WS PDF LRE; 4 ('RTL') (line 73779) std::vector<uint32_t> const cps = { 0x0020, 0x0020, 0x202C, 0x202A }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS WS PDF LRO; 4 ('RTL') (line 73780) std::vector<uint32_t> const cps = { 0x0020, 0x0020, 0x202C, 0x202D }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } } TEST(bidi, bidi_147_028) { expected_levels = { 1, 1, -1, -1 }; expected_reordered_indices = { 1, 0 }; { // WS WS PDF RLE; 4 ('RTL') (line 73781) std::vector<uint32_t> const cps = { 0x0020, 0x0020, 0x202C, 0x202B }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS WS PDF RLO; 4 ('RTL') (line 73782) std::vector<uint32_t> const cps = { 0x0020, 0x0020, 0x202C, 0x202E }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS WS PDF PDF; 4 ('RTL') (line 73783) std::vector<uint32_t> const cps = { 0x0020, 0x0020, 0x202C, 0x202C }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS WS PDF BN; 4 ('RTL') (line 73784) std::vector<uint32_t> const cps = { 0x0020, 0x0020, 0x202C, 0x00AD }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS WS BN LRE; 4 ('RTL') (line 73785) std::vector<uint32_t> const cps = { 0x0020, 0x0020, 0x00AD, 0x202A }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS WS BN LRO; 4 ('RTL') (line 73786) std::vector<uint32_t> const cps = { 0x0020, 0x0020, 0x00AD, 0x202D }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS WS BN RLE; 4 ('RTL') (line 73787) std::vector<uint32_t> const cps = { 0x0020, 0x0020, 0x00AD, 0x202B }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS WS BN RLO; 4 ('RTL') (line 73788) std::vector<uint32_t> const cps = { 0x0020, 0x0020, 0x00AD, 0x202E }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS WS BN PDF; 4 ('RTL') (line 73789) std::vector<uint32_t> const cps = { 0x0020, 0x0020, 0x00AD, 0x202C }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS WS BN BN; 4 ('RTL') (line 73790) std::vector<uint32_t> const cps = { 0x0020, 0x0020, 0x00AD, 0x00AD }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } } TEST(bidi, bidi_147_029) { expected_levels = { 1, 1, -1, -1 }; expected_reordered_indices = { 1, 0 }; { // WS ON LRE LRE; 4 ('RTL') (line 73791) std::vector<uint32_t> const cps = { 0x0020, 0x0021, 0x202A, 0x202A }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS ON LRE LRO; 4 ('RTL') (line 73792) std::vector<uint32_t> const cps = { 0x0020, 0x0021, 0x202A, 0x202D }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS ON LRE RLE; 4 ('RTL') (line 73793) std::vector<uint32_t> const cps = { 0x0020, 0x0021, 0x202A, 0x202B }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS ON LRE RLO; 4 ('RTL') (line 73794) std::vector<uint32_t> const cps = { 0x0020, 0x0021, 0x202A, 0x202E }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS ON LRE PDF; 4 ('RTL') (line 73795) std::vector<uint32_t> const cps = { 0x0020, 0x0021, 0x202A, 0x202C }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS ON LRE BN; 4 ('RTL') (line 73796) std::vector<uint32_t> const cps = { 0x0020, 0x0021, 0x202A, 0x00AD }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS ON LRO LRE; 4 ('RTL') (line 73797) std::vector<uint32_t> const cps = { 0x0020, 0x0021, 0x202D, 0x202A }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS ON LRO LRO; 4 ('RTL') (line 73798) std::vector<uint32_t> const cps = { 0x0020, 0x0021, 0x202D, 0x202D }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS ON LRO RLE; 4 ('RTL') (line 73799) std::vector<uint32_t> const cps = { 0x0020, 0x0021, 0x202D, 0x202B }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS ON LRO RLO; 4 ('RTL') (line 73800) std::vector<uint32_t> const cps = { 0x0020, 0x0021, 0x202D, 0x202E }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } } TEST(bidi, bidi_147_030) { expected_levels = { 1, 1, -1, -1 }; expected_reordered_indices = { 1, 0 }; { // WS ON LRO PDF; 4 ('RTL') (line 73801) std::vector<uint32_t> const cps = { 0x0020, 0x0021, 0x202D, 0x202C }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS ON LRO BN; 4 ('RTL') (line 73802) std::vector<uint32_t> const cps = { 0x0020, 0x0021, 0x202D, 0x00AD }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS ON RLE LRE; 4 ('RTL') (line 73803) std::vector<uint32_t> const cps = { 0x0020, 0x0021, 0x202B, 0x202A }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS ON RLE LRO; 4 ('RTL') (line 73804) std::vector<uint32_t> const cps = { 0x0020, 0x0021, 0x202B, 0x202D }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS ON RLE RLE; 4 ('RTL') (line 73805) std::vector<uint32_t> const cps = { 0x0020, 0x0021, 0x202B, 0x202B }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS ON RLE RLO; 4 ('RTL') (line 73806) std::vector<uint32_t> const cps = { 0x0020, 0x0021, 0x202B, 0x202E }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS ON RLE PDF; 4 ('RTL') (line 73807) std::vector<uint32_t> const cps = { 0x0020, 0x0021, 0x202B, 0x202C }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS ON RLE BN; 4 ('RTL') (line 73808) std::vector<uint32_t> const cps = { 0x0020, 0x0021, 0x202B, 0x00AD }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS ON RLO LRE; 4 ('RTL') (line 73809) std::vector<uint32_t> const cps = { 0x0020, 0x0021, 0x202E, 0x202A }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS ON RLO LRO; 4 ('RTL') (line 73810) std::vector<uint32_t> const cps = { 0x0020, 0x0021, 0x202E, 0x202D }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } } TEST(bidi, bidi_147_031) { expected_levels = { 1, 1, -1, -1 }; expected_reordered_indices = { 1, 0 }; { // WS ON RLO RLE; 4 ('RTL') (line 73811) std::vector<uint32_t> const cps = { 0x0020, 0x0021, 0x202E, 0x202B }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS ON RLO RLO; 4 ('RTL') (line 73812) std::vector<uint32_t> const cps = { 0x0020, 0x0021, 0x202E, 0x202E }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS ON RLO PDF; 4 ('RTL') (line 73813) std::vector<uint32_t> const cps = { 0x0020, 0x0021, 0x202E, 0x202C }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS ON RLO BN; 4 ('RTL') (line 73814) std::vector<uint32_t> const cps = { 0x0020, 0x0021, 0x202E, 0x00AD }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS ON PDF LRE; 4 ('RTL') (line 73815) std::vector<uint32_t> const cps = { 0x0020, 0x0021, 0x202C, 0x202A }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS ON PDF LRO; 4 ('RTL') (line 73816) std::vector<uint32_t> const cps = { 0x0020, 0x0021, 0x202C, 0x202D }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS ON PDF RLE; 4 ('RTL') (line 73817) std::vector<uint32_t> const cps = { 0x0020, 0x0021, 0x202C, 0x202B }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS ON PDF RLO; 4 ('RTL') (line 73818) std::vector<uint32_t> const cps = { 0x0020, 0x0021, 0x202C, 0x202E }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS ON PDF PDF; 4 ('RTL') (line 73819) std::vector<uint32_t> const cps = { 0x0020, 0x0021, 0x202C, 0x202C }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS ON PDF BN; 4 ('RTL') (line 73820) std::vector<uint32_t> const cps = { 0x0020, 0x0021, 0x202C, 0x00AD }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } } TEST(bidi, bidi_147_032) { expected_levels = { 1, 1, -1, -1 }; expected_reordered_indices = { 1, 0 }; { // WS ON BN LRE; 4 ('RTL') (line 73821) std::vector<uint32_t> const cps = { 0x0020, 0x0021, 0x00AD, 0x202A }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS ON BN LRO; 4 ('RTL') (line 73822) std::vector<uint32_t> const cps = { 0x0020, 0x0021, 0x00AD, 0x202D }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS ON BN RLE; 4 ('RTL') (line 73823) std::vector<uint32_t> const cps = { 0x0020, 0x0021, 0x00AD, 0x202B }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS ON BN RLO; 4 ('RTL') (line 73824) std::vector<uint32_t> const cps = { 0x0020, 0x0021, 0x00AD, 0x202E }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS ON BN PDF; 4 ('RTL') (line 73825) std::vector<uint32_t> const cps = { 0x0020, 0x0021, 0x00AD, 0x202C }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS ON BN BN; 4 ('RTL') (line 73826) std::vector<uint32_t> const cps = { 0x0020, 0x0021, 0x00AD, 0x00AD }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS LRI LRE LRE; 4 ('RTL') (line 73827) std::vector<uint32_t> const cps = { 0x0020, 0x2066, 0x202A, 0x202A }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS LRI LRE LRO; 4 ('RTL') (line 73828) std::vector<uint32_t> const cps = { 0x0020, 0x2066, 0x202A, 0x202D }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS LRI LRE RLE; 4 ('RTL') (line 73829) std::vector<uint32_t> const cps = { 0x0020, 0x2066, 0x202A, 0x202B }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS LRI LRE RLO; 4 ('RTL') (line 73830) std::vector<uint32_t> const cps = { 0x0020, 0x2066, 0x202A, 0x202E }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } } TEST(bidi, bidi_147_033) { expected_levels = { 1, 1, -1, -1 }; expected_reordered_indices = { 1, 0 }; { // WS LRI LRE PDF; 4 ('RTL') (line 73831) std::vector<uint32_t> const cps = { 0x0020, 0x2066, 0x202A, 0x202C }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS LRI LRE BN; 4 ('RTL') (line 73832) std::vector<uint32_t> const cps = { 0x0020, 0x2066, 0x202A, 0x00AD }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS LRI LRO LRE; 4 ('RTL') (line 73833) std::vector<uint32_t> const cps = { 0x0020, 0x2066, 0x202D, 0x202A }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS LRI LRO LRO; 4 ('RTL') (line 73834) std::vector<uint32_t> const cps = { 0x0020, 0x2066, 0x202D, 0x202D }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS LRI LRO RLE; 4 ('RTL') (line 73835) std::vector<uint32_t> const cps = { 0x0020, 0x2066, 0x202D, 0x202B }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS LRI LRO RLO; 4 ('RTL') (line 73836) std::vector<uint32_t> const cps = { 0x0020, 0x2066, 0x202D, 0x202E }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS LRI LRO PDF; 4 ('RTL') (line 73837) std::vector<uint32_t> const cps = { 0x0020, 0x2066, 0x202D, 0x202C }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS LRI LRO BN; 4 ('RTL') (line 73838) std::vector<uint32_t> const cps = { 0x0020, 0x2066, 0x202D, 0x00AD }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS LRI RLE LRE; 4 ('RTL') (line 73839) std::vector<uint32_t> const cps = { 0x0020, 0x2066, 0x202B, 0x202A }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS LRI RLE LRO; 4 ('RTL') (line 73840) std::vector<uint32_t> const cps = { 0x0020, 0x2066, 0x202B, 0x202D }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } } TEST(bidi, bidi_147_034) { expected_levels = { 1, 1, -1, -1 }; expected_reordered_indices = { 1, 0 }; { // WS LRI RLE RLE; 4 ('RTL') (line 73841) std::vector<uint32_t> const cps = { 0x0020, 0x2066, 0x202B, 0x202B }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS LRI RLE RLO; 4 ('RTL') (line 73842) std::vector<uint32_t> const cps = { 0x0020, 0x2066, 0x202B, 0x202E }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS LRI RLE PDF; 4 ('RTL') (line 73843) std::vector<uint32_t> const cps = { 0x0020, 0x2066, 0x202B, 0x202C }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS LRI RLE BN; 4 ('RTL') (line 73844) std::vector<uint32_t> const cps = { 0x0020, 0x2066, 0x202B, 0x00AD }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS LRI RLO LRE; 4 ('RTL') (line 73845) std::vector<uint32_t> const cps = { 0x0020, 0x2066, 0x202E, 0x202A }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS LRI RLO LRO; 4 ('RTL') (line 73846) std::vector<uint32_t> const cps = { 0x0020, 0x2066, 0x202E, 0x202D }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS LRI RLO RLE; 4 ('RTL') (line 73847) std::vector<uint32_t> const cps = { 0x0020, 0x2066, 0x202E, 0x202B }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS LRI RLO RLO; 4 ('RTL') (line 73848) std::vector<uint32_t> const cps = { 0x0020, 0x2066, 0x202E, 0x202E }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS LRI RLO PDF; 4 ('RTL') (line 73849) std::vector<uint32_t> const cps = { 0x0020, 0x2066, 0x202E, 0x202C }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS LRI RLO BN; 4 ('RTL') (line 73850) std::vector<uint32_t> const cps = { 0x0020, 0x2066, 0x202E, 0x00AD }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } } TEST(bidi, bidi_147_035) { expected_levels = { 1, 1, -1, -1 }; expected_reordered_indices = { 1, 0 }; { // WS LRI PDF LRE; 4 ('RTL') (line 73851) std::vector<uint32_t> const cps = { 0x0020, 0x2066, 0x202C, 0x202A }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS LRI PDF LRO; 4 ('RTL') (line 73852) std::vector<uint32_t> const cps = { 0x0020, 0x2066, 0x202C, 0x202D }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS LRI PDF RLE; 4 ('RTL') (line 73853) std::vector<uint32_t> const cps = { 0x0020, 0x2066, 0x202C, 0x202B }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS LRI PDF RLO; 4 ('RTL') (line 73854) std::vector<uint32_t> const cps = { 0x0020, 0x2066, 0x202C, 0x202E }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS LRI PDF PDF; 4 ('RTL') (line 73855) std::vector<uint32_t> const cps = { 0x0020, 0x2066, 0x202C, 0x202C }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS LRI PDF BN; 4 ('RTL') (line 73856) std::vector<uint32_t> const cps = { 0x0020, 0x2066, 0x202C, 0x00AD }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS LRI BN LRE; 4 ('RTL') (line 73857) std::vector<uint32_t> const cps = { 0x0020, 0x2066, 0x00AD, 0x202A }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS LRI BN LRO; 4 ('RTL') (line 73858) std::vector<uint32_t> const cps = { 0x0020, 0x2066, 0x00AD, 0x202D }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS LRI BN RLE; 4 ('RTL') (line 73859) std::vector<uint32_t> const cps = { 0x0020, 0x2066, 0x00AD, 0x202B }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS LRI BN RLO; 4 ('RTL') (line 73860) std::vector<uint32_t> const cps = { 0x0020, 0x2066, 0x00AD, 0x202E }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } } TEST(bidi, bidi_147_036) { expected_levels = { 1, 1, -1, -1 }; expected_reordered_indices = { 1, 0 }; { // WS LRI BN PDF; 4 ('RTL') (line 73861) std::vector<uint32_t> const cps = { 0x0020, 0x2066, 0x00AD, 0x202C }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS LRI BN BN; 4 ('RTL') (line 73862) std::vector<uint32_t> const cps = { 0x0020, 0x2066, 0x00AD, 0x00AD }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS RLI LRE LRE; 4 ('RTL') (line 73863) std::vector<uint32_t> const cps = { 0x0020, 0x2067, 0x202A, 0x202A }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS RLI LRE LRO; 4 ('RTL') (line 73864) std::vector<uint32_t> const cps = { 0x0020, 0x2067, 0x202A, 0x202D }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS RLI LRE RLE; 4 ('RTL') (line 73865) std::vector<uint32_t> const cps = { 0x0020, 0x2067, 0x202A, 0x202B }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS RLI LRE RLO; 4 ('RTL') (line 73866) std::vector<uint32_t> const cps = { 0x0020, 0x2067, 0x202A, 0x202E }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS RLI LRE PDF; 4 ('RTL') (line 73867) std::vector<uint32_t> const cps = { 0x0020, 0x2067, 0x202A, 0x202C }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS RLI LRE BN; 4 ('RTL') (line 73868) std::vector<uint32_t> const cps = { 0x0020, 0x2067, 0x202A, 0x00AD }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS RLI LRO LRE; 4 ('RTL') (line 73869) std::vector<uint32_t> const cps = { 0x0020, 0x2067, 0x202D, 0x202A }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS RLI LRO LRO; 4 ('RTL') (line 73870) std::vector<uint32_t> const cps = { 0x0020, 0x2067, 0x202D, 0x202D }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } } TEST(bidi, bidi_147_037) { expected_levels = { 1, 1, -1, -1 }; expected_reordered_indices = { 1, 0 }; { // WS RLI LRO RLE; 4 ('RTL') (line 73871) std::vector<uint32_t> const cps = { 0x0020, 0x2067, 0x202D, 0x202B }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS RLI LRO RLO; 4 ('RTL') (line 73872) std::vector<uint32_t> const cps = { 0x0020, 0x2067, 0x202D, 0x202E }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS RLI LRO PDF; 4 ('RTL') (line 73873) std::vector<uint32_t> const cps = { 0x0020, 0x2067, 0x202D, 0x202C }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS RLI LRO BN; 4 ('RTL') (line 73874) std::vector<uint32_t> const cps = { 0x0020, 0x2067, 0x202D, 0x00AD }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS RLI RLE LRE; 4 ('RTL') (line 73875) std::vector<uint32_t> const cps = { 0x0020, 0x2067, 0x202B, 0x202A }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS RLI RLE LRO; 4 ('RTL') (line 73876) std::vector<uint32_t> const cps = { 0x0020, 0x2067, 0x202B, 0x202D }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS RLI RLE RLE; 4 ('RTL') (line 73877) std::vector<uint32_t> const cps = { 0x0020, 0x2067, 0x202B, 0x202B }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS RLI RLE RLO; 4 ('RTL') (line 73878) std::vector<uint32_t> const cps = { 0x0020, 0x2067, 0x202B, 0x202E }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS RLI RLE PDF; 4 ('RTL') (line 73879) std::vector<uint32_t> const cps = { 0x0020, 0x2067, 0x202B, 0x202C }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS RLI RLE BN; 4 ('RTL') (line 73880) std::vector<uint32_t> const cps = { 0x0020, 0x2067, 0x202B, 0x00AD }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } } TEST(bidi, bidi_147_038) { expected_levels = { 1, 1, -1, -1 }; expected_reordered_indices = { 1, 0 }; { // WS RLI RLO LRE; 4 ('RTL') (line 73881) std::vector<uint32_t> const cps = { 0x0020, 0x2067, 0x202E, 0x202A }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS RLI RLO LRO; 4 ('RTL') (line 73882) std::vector<uint32_t> const cps = { 0x0020, 0x2067, 0x202E, 0x202D }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS RLI RLO RLE; 4 ('RTL') (line 73883) std::vector<uint32_t> const cps = { 0x0020, 0x2067, 0x202E, 0x202B }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS RLI RLO RLO; 4 ('RTL') (line 73884) std::vector<uint32_t> const cps = { 0x0020, 0x2067, 0x202E, 0x202E }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS RLI RLO PDF; 4 ('RTL') (line 73885) std::vector<uint32_t> const cps = { 0x0020, 0x2067, 0x202E, 0x202C }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS RLI RLO BN; 4 ('RTL') (line 73886) std::vector<uint32_t> const cps = { 0x0020, 0x2067, 0x202E, 0x00AD }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS RLI PDF LRE; 4 ('RTL') (line 73887) std::vector<uint32_t> const cps = { 0x0020, 0x2067, 0x202C, 0x202A }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS RLI PDF LRO; 4 ('RTL') (line 73888) std::vector<uint32_t> const cps = { 0x0020, 0x2067, 0x202C, 0x202D }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS RLI PDF RLE; 4 ('RTL') (line 73889) std::vector<uint32_t> const cps = { 0x0020, 0x2067, 0x202C, 0x202B }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS RLI PDF RLO; 4 ('RTL') (line 73890) std::vector<uint32_t> const cps = { 0x0020, 0x2067, 0x202C, 0x202E }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } } TEST(bidi, bidi_147_039) { expected_levels = { 1, 1, -1, -1 }; expected_reordered_indices = { 1, 0 }; { // WS RLI PDF PDF; 4 ('RTL') (line 73891) std::vector<uint32_t> const cps = { 0x0020, 0x2067, 0x202C, 0x202C }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS RLI PDF BN; 4 ('RTL') (line 73892) std::vector<uint32_t> const cps = { 0x0020, 0x2067, 0x202C, 0x00AD }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS RLI BN LRE; 4 ('RTL') (line 73893) std::vector<uint32_t> const cps = { 0x0020, 0x2067, 0x00AD, 0x202A }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS RLI BN LRO; 4 ('RTL') (line 73894) std::vector<uint32_t> const cps = { 0x0020, 0x2067, 0x00AD, 0x202D }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS RLI BN RLE; 4 ('RTL') (line 73895) std::vector<uint32_t> const cps = { 0x0020, 0x2067, 0x00AD, 0x202B }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS RLI BN RLO; 4 ('RTL') (line 73896) std::vector<uint32_t> const cps = { 0x0020, 0x2067, 0x00AD, 0x202E }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS RLI BN PDF; 4 ('RTL') (line 73897) std::vector<uint32_t> const cps = { 0x0020, 0x2067, 0x00AD, 0x202C }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS RLI BN BN; 4 ('RTL') (line 73898) std::vector<uint32_t> const cps = { 0x0020, 0x2067, 0x00AD, 0x00AD }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS FSI LRE LRE; 4 ('RTL') (line 73899) std::vector<uint32_t> const cps = { 0x0020, 0x2068, 0x202A, 0x202A }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS FSI LRE LRO; 4 ('RTL') (line 73900) std::vector<uint32_t> const cps = { 0x0020, 0x2068, 0x202A, 0x202D }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } } TEST(bidi, bidi_147_040) { expected_levels = { 1, 1, -1, -1 }; expected_reordered_indices = { 1, 0 }; { // WS FSI LRE RLE; 4 ('RTL') (line 73901) std::vector<uint32_t> const cps = { 0x0020, 0x2068, 0x202A, 0x202B }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS FSI LRE RLO; 4 ('RTL') (line 73902) std::vector<uint32_t> const cps = { 0x0020, 0x2068, 0x202A, 0x202E }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS FSI LRE PDF; 4 ('RTL') (line 73903) std::vector<uint32_t> const cps = { 0x0020, 0x2068, 0x202A, 0x202C }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS FSI LRE BN; 4 ('RTL') (line 73904) std::vector<uint32_t> const cps = { 0x0020, 0x2068, 0x202A, 0x00AD }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS FSI LRO LRE; 4 ('RTL') (line 73905) std::vector<uint32_t> const cps = { 0x0020, 0x2068, 0x202D, 0x202A }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS FSI LRO LRO; 4 ('RTL') (line 73906) std::vector<uint32_t> const cps = { 0x0020, 0x2068, 0x202D, 0x202D }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS FSI LRO RLE; 4 ('RTL') (line 73907) std::vector<uint32_t> const cps = { 0x0020, 0x2068, 0x202D, 0x202B }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS FSI LRO RLO; 4 ('RTL') (line 73908) std::vector<uint32_t> const cps = { 0x0020, 0x2068, 0x202D, 0x202E }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS FSI LRO PDF; 4 ('RTL') (line 73909) std::vector<uint32_t> const cps = { 0x0020, 0x2068, 0x202D, 0x202C }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS FSI LRO BN; 4 ('RTL') (line 73910) std::vector<uint32_t> const cps = { 0x0020, 0x2068, 0x202D, 0x00AD }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } } TEST(bidi, bidi_147_041) { expected_levels = { 1, 1, -1, -1 }; expected_reordered_indices = { 1, 0 }; { // WS FSI RLE LRE; 4 ('RTL') (line 73911) std::vector<uint32_t> const cps = { 0x0020, 0x2068, 0x202B, 0x202A }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS FSI RLE LRO; 4 ('RTL') (line 73912) std::vector<uint32_t> const cps = { 0x0020, 0x2068, 0x202B, 0x202D }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS FSI RLE RLE; 4 ('RTL') (line 73913) std::vector<uint32_t> const cps = { 0x0020, 0x2068, 0x202B, 0x202B }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS FSI RLE RLO; 4 ('RTL') (line 73914) std::vector<uint32_t> const cps = { 0x0020, 0x2068, 0x202B, 0x202E }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS FSI RLE PDF; 4 ('RTL') (line 73915) std::vector<uint32_t> const cps = { 0x0020, 0x2068, 0x202B, 0x202C }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS FSI RLE BN; 4 ('RTL') (line 73916) std::vector<uint32_t> const cps = { 0x0020, 0x2068, 0x202B, 0x00AD }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS FSI RLO LRE; 4 ('RTL') (line 73917) std::vector<uint32_t> const cps = { 0x0020, 0x2068, 0x202E, 0x202A }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS FSI RLO LRO; 4 ('RTL') (line 73918) std::vector<uint32_t> const cps = { 0x0020, 0x2068, 0x202E, 0x202D }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS FSI RLO RLE; 4 ('RTL') (line 73919) std::vector<uint32_t> const cps = { 0x0020, 0x2068, 0x202E, 0x202B }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS FSI RLO RLO; 4 ('RTL') (line 73920) std::vector<uint32_t> const cps = { 0x0020, 0x2068, 0x202E, 0x202E }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } } TEST(bidi, bidi_147_042) { expected_levels = { 1, 1, -1, -1 }; expected_reordered_indices = { 1, 0 }; { // WS FSI RLO PDF; 4 ('RTL') (line 73921) std::vector<uint32_t> const cps = { 0x0020, 0x2068, 0x202E, 0x202C }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS FSI RLO BN; 4 ('RTL') (line 73922) std::vector<uint32_t> const cps = { 0x0020, 0x2068, 0x202E, 0x00AD }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS FSI PDF LRE; 4 ('RTL') (line 73923) std::vector<uint32_t> const cps = { 0x0020, 0x2068, 0x202C, 0x202A }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS FSI PDF LRO; 4 ('RTL') (line 73924) std::vector<uint32_t> const cps = { 0x0020, 0x2068, 0x202C, 0x202D }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS FSI PDF RLE; 4 ('RTL') (line 73925) std::vector<uint32_t> const cps = { 0x0020, 0x2068, 0x202C, 0x202B }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS FSI PDF RLO; 4 ('RTL') (line 73926) std::vector<uint32_t> const cps = { 0x0020, 0x2068, 0x202C, 0x202E }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS FSI PDF PDF; 4 ('RTL') (line 73927) std::vector<uint32_t> const cps = { 0x0020, 0x2068, 0x202C, 0x202C }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS FSI PDF BN; 4 ('RTL') (line 73928) std::vector<uint32_t> const cps = { 0x0020, 0x2068, 0x202C, 0x00AD }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS FSI BN LRE; 4 ('RTL') (line 73929) std::vector<uint32_t> const cps = { 0x0020, 0x2068, 0x00AD, 0x202A }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS FSI BN LRO; 4 ('RTL') (line 73930) std::vector<uint32_t> const cps = { 0x0020, 0x2068, 0x00AD, 0x202D }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } } TEST(bidi, bidi_147_043) { expected_levels = { 1, 1, -1, -1 }; expected_reordered_indices = { 1, 0 }; { // WS FSI BN RLE; 4 ('RTL') (line 73931) std::vector<uint32_t> const cps = { 0x0020, 0x2068, 0x00AD, 0x202B }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS FSI BN RLO; 4 ('RTL') (line 73932) std::vector<uint32_t> const cps = { 0x0020, 0x2068, 0x00AD, 0x202E }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS FSI BN PDF; 4 ('RTL') (line 73933) std::vector<uint32_t> const cps = { 0x0020, 0x2068, 0x00AD, 0x202C }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS FSI BN BN; 4 ('RTL') (line 73934) std::vector<uint32_t> const cps = { 0x0020, 0x2068, 0x00AD, 0x00AD }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS PDI LRE LRE; 4 ('RTL') (line 73935) std::vector<uint32_t> const cps = { 0x0020, 0x2069, 0x202A, 0x202A }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS PDI LRE LRO; 4 ('RTL') (line 73936) std::vector<uint32_t> const cps = { 0x0020, 0x2069, 0x202A, 0x202D }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS PDI LRE RLE; 4 ('RTL') (line 73937) std::vector<uint32_t> const cps = { 0x0020, 0x2069, 0x202A, 0x202B }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS PDI LRE RLO; 4 ('RTL') (line 73938) std::vector<uint32_t> const cps = { 0x0020, 0x2069, 0x202A, 0x202E }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS PDI LRE PDF; 4 ('RTL') (line 73939) std::vector<uint32_t> const cps = { 0x0020, 0x2069, 0x202A, 0x202C }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS PDI LRE BN; 4 ('RTL') (line 73940) std::vector<uint32_t> const cps = { 0x0020, 0x2069, 0x202A, 0x00AD }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } } TEST(bidi, bidi_147_044) { expected_levels = { 1, 1, -1, -1 }; expected_reordered_indices = { 1, 0 }; { // WS PDI LRO LRE; 4 ('RTL') (line 73941) std::vector<uint32_t> const cps = { 0x0020, 0x2069, 0x202D, 0x202A }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS PDI LRO LRO; 4 ('RTL') (line 73942) std::vector<uint32_t> const cps = { 0x0020, 0x2069, 0x202D, 0x202D }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS PDI LRO RLE; 4 ('RTL') (line 73943) std::vector<uint32_t> const cps = { 0x0020, 0x2069, 0x202D, 0x202B }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS PDI LRO RLO; 4 ('RTL') (line 73944) std::vector<uint32_t> const cps = { 0x0020, 0x2069, 0x202D, 0x202E }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS PDI LRO PDF; 4 ('RTL') (line 73945) std::vector<uint32_t> const cps = { 0x0020, 0x2069, 0x202D, 0x202C }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS PDI LRO BN; 4 ('RTL') (line 73946) std::vector<uint32_t> const cps = { 0x0020, 0x2069, 0x202D, 0x00AD }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS PDI RLE LRE; 4 ('RTL') (line 73947) std::vector<uint32_t> const cps = { 0x0020, 0x2069, 0x202B, 0x202A }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS PDI RLE LRO; 4 ('RTL') (line 73948) std::vector<uint32_t> const cps = { 0x0020, 0x2069, 0x202B, 0x202D }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS PDI RLE RLE; 4 ('RTL') (line 73949) std::vector<uint32_t> const cps = { 0x0020, 0x2069, 0x202B, 0x202B }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS PDI RLE RLO; 4 ('RTL') (line 73950) std::vector<uint32_t> const cps = { 0x0020, 0x2069, 0x202B, 0x202E }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } } TEST(bidi, bidi_147_045) { expected_levels = { 1, 1, -1, -1 }; expected_reordered_indices = { 1, 0 }; { // WS PDI RLE PDF; 4 ('RTL') (line 73951) std::vector<uint32_t> const cps = { 0x0020, 0x2069, 0x202B, 0x202C }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS PDI RLE BN; 4 ('RTL') (line 73952) std::vector<uint32_t> const cps = { 0x0020, 0x2069, 0x202B, 0x00AD }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS PDI RLO LRE; 4 ('RTL') (line 73953) std::vector<uint32_t> const cps = { 0x0020, 0x2069, 0x202E, 0x202A }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS PDI RLO LRO; 4 ('RTL') (line 73954) std::vector<uint32_t> const cps = { 0x0020, 0x2069, 0x202E, 0x202D }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS PDI RLO RLE; 4 ('RTL') (line 73955) std::vector<uint32_t> const cps = { 0x0020, 0x2069, 0x202E, 0x202B }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS PDI RLO RLO; 4 ('RTL') (line 73956) std::vector<uint32_t> const cps = { 0x0020, 0x2069, 0x202E, 0x202E }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS PDI RLO PDF; 4 ('RTL') (line 73957) std::vector<uint32_t> const cps = { 0x0020, 0x2069, 0x202E, 0x202C }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS PDI RLO BN; 4 ('RTL') (line 73958) std::vector<uint32_t> const cps = { 0x0020, 0x2069, 0x202E, 0x00AD }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS PDI PDF LRE; 4 ('RTL') (line 73959) std::vector<uint32_t> const cps = { 0x0020, 0x2069, 0x202C, 0x202A }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS PDI PDF LRO; 4 ('RTL') (line 73960) std::vector<uint32_t> const cps = { 0x0020, 0x2069, 0x202C, 0x202D }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } } TEST(bidi, bidi_147_046) { expected_levels = { 1, 1, -1, -1 }; expected_reordered_indices = { 1, 0 }; { // WS PDI PDF RLE; 4 ('RTL') (line 73961) std::vector<uint32_t> const cps = { 0x0020, 0x2069, 0x202C, 0x202B }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS PDI PDF RLO; 4 ('RTL') (line 73962) std::vector<uint32_t> const cps = { 0x0020, 0x2069, 0x202C, 0x202E }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS PDI PDF PDF; 4 ('RTL') (line 73963) std::vector<uint32_t> const cps = { 0x0020, 0x2069, 0x202C, 0x202C }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS PDI PDF BN; 4 ('RTL') (line 73964) std::vector<uint32_t> const cps = { 0x0020, 0x2069, 0x202C, 0x00AD }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS PDI BN LRE; 4 ('RTL') (line 73965) std::vector<uint32_t> const cps = { 0x0020, 0x2069, 0x00AD, 0x202A }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS PDI BN LRO; 4 ('RTL') (line 73966) std::vector<uint32_t> const cps = { 0x0020, 0x2069, 0x00AD, 0x202D }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS PDI BN RLE; 4 ('RTL') (line 73967) std::vector<uint32_t> const cps = { 0x0020, 0x2069, 0x00AD, 0x202B }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS PDI BN RLO; 4 ('RTL') (line 73968) std::vector<uint32_t> const cps = { 0x0020, 0x2069, 0x00AD, 0x202E }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS PDI BN PDF; 4 ('RTL') (line 73969) std::vector<uint32_t> const cps = { 0x0020, 0x2069, 0x00AD, 0x202C }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // WS PDI BN BN; 4 ('RTL') (line 73970) std::vector<uint32_t> const cps = { 0x0020, 0x2069, 0x00AD, 0x00AD }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } } TEST(bidi, bidi_147_047) { expected_levels = { 1, 1, -1, -1 }; expected_reordered_indices = { 1, 0 }; { // ON R LRE LRE; 5 ('auto') (line 73971) std::vector<uint32_t> const cps = { 0x0021, 0x05BE, 0x202A, 0x202A }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), -1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), -1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, -1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // ON R LRE LRE; 5 ('RTL') (line 73971) std::vector<uint32_t> const cps = { 0x0021, 0x05BE, 0x202A, 0x202A }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // ON R LRE LRO; 5 ('auto') (line 73972) std::vector<uint32_t> const cps = { 0x0021, 0x05BE, 0x202A, 0x202D }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), -1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), -1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, -1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // ON R LRE LRO; 5 ('RTL') (line 73972) std::vector<uint32_t> const cps = { 0x0021, 0x05BE, 0x202A, 0x202D }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // ON R LRE RLE; 5 ('auto') (line 73973) std::vector<uint32_t> const cps = { 0x0021, 0x05BE, 0x202A, 0x202B }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), -1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), -1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, -1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // ON R LRE RLE; 5 ('RTL') (line 73973) std::vector<uint32_t> const cps = { 0x0021, 0x05BE, 0x202A, 0x202B }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // ON R LRE RLO; 5 ('auto') (line 73974) std::vector<uint32_t> const cps = { 0x0021, 0x05BE, 0x202A, 0x202E }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), -1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), -1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, -1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // ON R LRE RLO; 5 ('RTL') (line 73974) std::vector<uint32_t> const cps = { 0x0021, 0x05BE, 0x202A, 0x202E }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // ON R LRE PDF; 5 ('auto') (line 73975) std::vector<uint32_t> const cps = { 0x0021, 0x05BE, 0x202A, 0x202C }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), -1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), -1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, -1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // ON R LRE PDF; 5 ('RTL') (line 73975) std::vector<uint32_t> const cps = { 0x0021, 0x05BE, 0x202A, 0x202C }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // ON R LRE BN; 5 ('auto') (line 73976) std::vector<uint32_t> const cps = { 0x0021, 0x05BE, 0x202A, 0x00AD }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), -1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), -1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, -1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // ON R LRE BN; 5 ('RTL') (line 73976) std::vector<uint32_t> const cps = { 0x0021, 0x05BE, 0x202A, 0x00AD }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // ON R LRO LRE; 5 ('auto') (line 73977) std::vector<uint32_t> const cps = { 0x0021, 0x05BE, 0x202D, 0x202A }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), -1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), -1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, -1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // ON R LRO LRE; 5 ('RTL') (line 73977) std::vector<uint32_t> const cps = { 0x0021, 0x05BE, 0x202D, 0x202A }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // ON R LRO LRO; 5 ('auto') (line 73978) std::vector<uint32_t> const cps = { 0x0021, 0x05BE, 0x202D, 0x202D }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), -1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), -1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, -1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // ON R LRO LRO; 5 ('RTL') (line 73978) std::vector<uint32_t> const cps = { 0x0021, 0x05BE, 0x202D, 0x202D }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // ON R LRO RLE; 5 ('auto') (line 73979) std::vector<uint32_t> const cps = { 0x0021, 0x05BE, 0x202D, 0x202B }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), -1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), -1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, -1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // ON R LRO RLE; 5 ('RTL') (line 73979) std::vector<uint32_t> const cps = { 0x0021, 0x05BE, 0x202D, 0x202B }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // ON R LRO RLO; 5 ('auto') (line 73980) std::vector<uint32_t> const cps = { 0x0021, 0x05BE, 0x202D, 0x202E }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), -1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), -1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, -1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // ON R LRO RLO; 5 ('RTL') (line 73980) std::vector<uint32_t> const cps = { 0x0021, 0x05BE, 0x202D, 0x202E }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } } TEST(bidi, bidi_147_048) { expected_levels = { 1, 1, -1, -1 }; expected_reordered_indices = { 1, 0 }; { // ON R LRO PDF; 5 ('auto') (line 73981) std::vector<uint32_t> const cps = { 0x0021, 0x05BE, 0x202D, 0x202C }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), -1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), -1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, -1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // ON R LRO PDF; 5 ('RTL') (line 73981) std::vector<uint32_t> const cps = { 0x0021, 0x05BE, 0x202D, 0x202C }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // ON R LRO BN; 5 ('auto') (line 73982) std::vector<uint32_t> const cps = { 0x0021, 0x05BE, 0x202D, 0x00AD }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), -1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), -1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, -1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // ON R LRO BN; 5 ('RTL') (line 73982) std::vector<uint32_t> const cps = { 0x0021, 0x05BE, 0x202D, 0x00AD }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // ON R RLE LRE; 5 ('auto') (line 73983) std::vector<uint32_t> const cps = { 0x0021, 0x05BE, 0x202B, 0x202A }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), -1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), -1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, -1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // ON R RLE LRE; 5 ('RTL') (line 73983) std::vector<uint32_t> const cps = { 0x0021, 0x05BE, 0x202B, 0x202A }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // ON R RLE LRO; 5 ('auto') (line 73984) std::vector<uint32_t> const cps = { 0x0021, 0x05BE, 0x202B, 0x202D }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), -1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), -1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, -1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // ON R RLE LRO; 5 ('RTL') (line 73984) std::vector<uint32_t> const cps = { 0x0021, 0x05BE, 0x202B, 0x202D }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // ON R RLE RLE; 5 ('auto') (line 73985) std::vector<uint32_t> const cps = { 0x0021, 0x05BE, 0x202B, 0x202B }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), -1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), -1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, -1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // ON R RLE RLE; 5 ('RTL') (line 73985) std::vector<uint32_t> const cps = { 0x0021, 0x05BE, 0x202B, 0x202B }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // ON R RLE RLO; 5 ('auto') (line 73986) std::vector<uint32_t> const cps = { 0x0021, 0x05BE, 0x202B, 0x202E }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), -1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), -1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, -1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // ON R RLE RLO; 5 ('RTL') (line 73986) std::vector<uint32_t> const cps = { 0x0021, 0x05BE, 0x202B, 0x202E }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // ON R RLE PDF; 5 ('auto') (line 73987) std::vector<uint32_t> const cps = { 0x0021, 0x05BE, 0x202B, 0x202C }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), -1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), -1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, -1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // ON R RLE PDF; 5 ('RTL') (line 73987) std::vector<uint32_t> const cps = { 0x0021, 0x05BE, 0x202B, 0x202C }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // ON R RLE BN; 5 ('auto') (line 73988) std::vector<uint32_t> const cps = { 0x0021, 0x05BE, 0x202B, 0x00AD }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), -1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), -1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, -1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // ON R RLE BN; 5 ('RTL') (line 73988) std::vector<uint32_t> const cps = { 0x0021, 0x05BE, 0x202B, 0x00AD }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // ON R RLO LRE; 5 ('auto') (line 73989) std::vector<uint32_t> const cps = { 0x0021, 0x05BE, 0x202E, 0x202A }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), -1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), -1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, -1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // ON R RLO LRE; 5 ('RTL') (line 73989) std::vector<uint32_t> const cps = { 0x0021, 0x05BE, 0x202E, 0x202A }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // ON R RLO LRO; 5 ('auto') (line 73990) std::vector<uint32_t> const cps = { 0x0021, 0x05BE, 0x202E, 0x202D }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), -1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), -1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, -1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // ON R RLO LRO; 5 ('RTL') (line 73990) std::vector<uint32_t> const cps = { 0x0021, 0x05BE, 0x202E, 0x202D }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } } TEST(bidi, bidi_147_049) { expected_levels = { 1, 1, -1, -1 }; expected_reordered_indices = { 1, 0 }; { // ON R RLO RLE; 5 ('auto') (line 73991) std::vector<uint32_t> const cps = { 0x0021, 0x05BE, 0x202E, 0x202B }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), -1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), -1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, -1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // ON R RLO RLE; 5 ('RTL') (line 73991) std::vector<uint32_t> const cps = { 0x0021, 0x05BE, 0x202E, 0x202B }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // ON R RLO RLO; 5 ('auto') (line 73992) std::vector<uint32_t> const cps = { 0x0021, 0x05BE, 0x202E, 0x202E }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), -1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), -1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, -1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // ON R RLO RLO; 5 ('RTL') (line 73992) std::vector<uint32_t> const cps = { 0x0021, 0x05BE, 0x202E, 0x202E }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // ON R RLO PDF; 5 ('auto') (line 73993) std::vector<uint32_t> const cps = { 0x0021, 0x05BE, 0x202E, 0x202C }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), -1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), -1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, -1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // ON R RLO PDF; 5 ('RTL') (line 73993) std::vector<uint32_t> const cps = { 0x0021, 0x05BE, 0x202E, 0x202C }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // ON R RLO BN; 5 ('auto') (line 73994) std::vector<uint32_t> const cps = { 0x0021, 0x05BE, 0x202E, 0x00AD }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), -1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), -1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, -1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // ON R RLO BN; 5 ('RTL') (line 73994) std::vector<uint32_t> const cps = { 0x0021, 0x05BE, 0x202E, 0x00AD }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // ON R PDF LRE; 5 ('auto') (line 73995) std::vector<uint32_t> const cps = { 0x0021, 0x05BE, 0x202C, 0x202A }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), -1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), -1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, -1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // ON R PDF LRE; 5 ('RTL') (line 73995) std::vector<uint32_t> const cps = { 0x0021, 0x05BE, 0x202C, 0x202A }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // ON R PDF LRO; 5 ('auto') (line 73996) std::vector<uint32_t> const cps = { 0x0021, 0x05BE, 0x202C, 0x202D }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), -1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), -1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, -1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // ON R PDF LRO; 5 ('RTL') (line 73996) std::vector<uint32_t> const cps = { 0x0021, 0x05BE, 0x202C, 0x202D }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // ON R PDF RLE; 5 ('auto') (line 73997) std::vector<uint32_t> const cps = { 0x0021, 0x05BE, 0x202C, 0x202B }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), -1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), -1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, -1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // ON R PDF RLE; 5 ('RTL') (line 73997) std::vector<uint32_t> const cps = { 0x0021, 0x05BE, 0x202C, 0x202B }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // ON R PDF RLO; 5 ('auto') (line 73998) std::vector<uint32_t> const cps = { 0x0021, 0x05BE, 0x202C, 0x202E }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), -1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), -1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, -1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // ON R PDF RLO; 5 ('RTL') (line 73998) std::vector<uint32_t> const cps = { 0x0021, 0x05BE, 0x202C, 0x202E }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // ON R PDF PDF; 5 ('auto') (line 73999) std::vector<uint32_t> const cps = { 0x0021, 0x05BE, 0x202C, 0x202C }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), -1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), -1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, -1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // ON R PDF PDF; 5 ('RTL') (line 73999) std::vector<uint32_t> const cps = { 0x0021, 0x05BE, 0x202C, 0x202C }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // ON R PDF BN; 5 ('auto') (line 74000) std::vector<uint32_t> const cps = { 0x0021, 0x05BE, 0x202C, 0x00AD }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), -1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), -1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, -1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } { // ON R PDF BN; 5 ('RTL') (line 74000) std::vector<uint32_t> const cps = { 0x0021, 0x05BE, 0x202C, 0x00AD }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { // Skip FSI, LRI, RLI, and PDI. if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } std::vector<int> reordered_2; for (auto subrange : boost::text::bidirectional_subranges(cps, 1)) { for (auto cp : subrange) { reordered_2.push_back(cp); } } i = 0; for (int idx : expected_reordered_indices) { if (cps[idx] < 0x2066 || 0x2069 < cps[idx]) { EXPECT_EQ(reordered_2[i], cps[idx]) << std::hex << " 0x" << reordered_2[i] << " 0x" << cps[idx] << std::dec << " i=" << i; } ++i; } EXPECT_EQ(i, (int)reordered_2.size()); } }
32.966124
77
0.403859
eightysquirrels
731a636f01532dd8c90e3c135801e84941f53c85
1,833
cpp
C++
EZOJ/Contests/1046/A.cpp
sshockwave/Online-Judge-Solutions
9d0bc7fd68c3d1f661622929c1cb3752601881d3
[ "MIT" ]
6
2019-09-30T16:11:00.000Z
2021-11-01T11:42:33.000Z
EZOJ/Contests/1046/A.cpp
sshockwave/Online-Judge-Solutions
9d0bc7fd68c3d1f661622929c1cb3752601881d3
[ "MIT" ]
4
2017-11-21T08:17:42.000Z
2020-07-28T12:09:52.000Z
EZOJ/Contests/1046/A.cpp
sshockwave/Online-Judge-Solutions
9d0bc7fd68c3d1f661622929c1cb3752601881d3
[ "MIT" ]
4
2017-07-26T05:54:06.000Z
2020-09-30T13:35:38.000Z
#include <iostream> #include <cstdio> #include <cstring> #include <cassert> #include <cctype> #include <vector> using namespace std; typedef long long lint; #define cout cerr #define ni (next_num<int>()) template<class T>inline T next_num(){ T i=0;char c; while(!isdigit(c=getchar())&&c!='-'); bool flag=c=='-'; flag?(c=getchar()):0; while(i=i*10-'0'+c,isdigit(c=getchar())); return flag?-i:i; } const int N=100000010,rtN=10010,K=110,MOD=1000000007,F=1<<15; inline int add(const int &a,const int &b){ return (a+b)%MOD; } inline int mul(const int &a,const int &b){ return (lint)a*b%MOD; } inline void apmul(int &a,const int &b){ a=mul(a,b); } inline int fpow(int x,int n){ int ret=1; for(;n;n>>=1,apmul(x,x)){ if(n&1){ apmul(ret,x); } } return ret; } inline int inv(int x){ return fpow(x,MOD-2); } int fct[F],fphi[F],fs; inline void spwn(int x,int e){ int n=fs; for(int i=1,v=1,lst;i<=e;i++){ lst=v,v*=x; for(int j=0;j<n;j++){ fct[fs]=fct[j]*v,fphi[fs]=fphi[j]*(v-lst),fs++; } } } inline void tear(int n){ fs=0; fct[fs]=1,fphi[fs]=1,fs++; for(int i=2;i*i<=n;i++){ int e=0; for(;n%i==0;n/=i,e++); spwn(i,e); } if(n!=1){ spwn(n,1); } } int c[K][K]; inline void gc(int n){ memset(c,0,sizeof(c)); c[0][0]=1; for(int i=1;i<=n;i++){ c[i][0]=1; for(int j=1;j<=i;j++){ c[i][j]=add(c[i-1][j-1],c[i-1][j]); } } } inline int Main(){ int n=ni,k=ni; tear(n); lint ans=0; for(int i=0;i<=k;i++){ lint cur=0; for(int j=0;j<fs;j++){ cur+=mul(fpow(i,n/fct[j]),fphi[j]); } cur=mul(cur%MOD,c[k][i]); if((k-i)&1){ ans-=cur; }else{ ans+=cur; } } return mul((ans%MOD+MOD)%MOD,inv(n)); } int main(){ #ifndef ONLINE_JUDGE freopen("necklace.in","r",stdin); freopen("necklace.out","w",stdout); #endif gc(K-1); for(int tot=ni;tot--;printf("%d\n",Main())); return 0; }
18.148515
61
0.575559
sshockwave
731b64739268775e4a0cce56af12df7e76201772
4,979
cc
C++
src/AutoPilotPlugins/Common/SyslinkComponentController.cc
uav-operation-system/qgroundcontrol
c24029938e88d7a45a04f4e4e64bf588f595afed
[ "Apache-2.0" ]
2,133
2015-01-04T03:10:22.000Z
2022-03-31T01:51:07.000Z
src/AutoPilotPlugins/Common/SyslinkComponentController.cc
uav-operation-system/qgroundcontrol
c24029938e88d7a45a04f4e4e64bf588f595afed
[ "Apache-2.0" ]
6,166
2015-01-02T18:47:42.000Z
2022-03-31T03:44:10.000Z
src/AutoPilotPlugins/Common/SyslinkComponentController.cc
uav-operation-system/qgroundcontrol
c24029938e88d7a45a04f4e4e64bf588f595afed
[ "Apache-2.0" ]
2,980
2015-01-01T03:09:18.000Z
2022-03-31T04:13:55.000Z
/**************************************************************************** * * (c) 2009-2020 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org> * * QGroundControl is licensed according to the terms in the file * COPYING.md in the root of the source code directory. * ****************************************************************************/ #include "SyslinkComponentController.h" #include "QGCApplication.h" #include "UAS.h" #include "ParameterManager.h" #include <QHostAddress> #include <QtEndian> QGC_LOGGING_CATEGORY(SyslinkComponentControllerLog, "SyslinkComponentControllerLog") //----------------------------------------------------------------------------- SyslinkComponentController::SyslinkComponentController() { _dataRates.append(QStringLiteral("750Kb/s")); _dataRates.append(QStringLiteral("1Mb/s")); _dataRates.append(QStringLiteral("2Mb/s")); Fact* chan = getParameterFact(_vehicle->id(), QStringLiteral("SLNK_RADIO_CHAN")); connect(chan, &Fact::valueChanged, this, &SyslinkComponentController::_channelChanged); Fact* rate = getParameterFact(_vehicle->id(), QStringLiteral("SLNK_RADIO_RATE")); connect(rate, &Fact::valueChanged, this, &SyslinkComponentController::_rateChanged); Fact* addr1 = getParameterFact(_vehicle->id(), QStringLiteral("SLNK_RADIO_ADDR1")); connect(addr1, &Fact::valueChanged, this, &SyslinkComponentController::_addressChanged); Fact* addr2 = getParameterFact(_vehicle->id(), QStringLiteral("SLNK_RADIO_ADDR2")); connect(addr2, &Fact::valueChanged, this, &SyslinkComponentController::_addressChanged); } //----------------------------------------------------------------------------- SyslinkComponentController::~SyslinkComponentController() { } //----------------------------------------------------------------------------- int SyslinkComponentController::radioChannel() { return getParameterFact(_vehicle->id(), QStringLiteral("SLNK_RADIO_CHAN"))->rawValue().toUInt(); } //----------------------------------------------------------------------------- void SyslinkComponentController::setRadioChannel(int num) { Fact* f = getParameterFact(_vehicle->id(), QStringLiteral("SLNK_RADIO_CHAN")); f->setRawValue(QVariant(num)); } //----------------------------------------------------------------------------- QString SyslinkComponentController::radioAddress() { uint32_t val_uh = getParameterFact(_vehicle->id(), QStringLiteral("SLNK_RADIO_ADDR1"))->rawValue().toUInt(); uint32_t val_lh = getParameterFact(_vehicle->id(), QStringLiteral("SLNK_RADIO_ADDR2"))->rawValue().toUInt(); uint64_t val = (((uint64_t) val_uh) << 32) | ((uint64_t) val_lh); return QString().number(val, 16); } //----------------------------------------------------------------------------- void SyslinkComponentController::setRadioAddress(QString str) { Fact *uh = getParameterFact(_vehicle->id(), QStringLiteral("SLNK_RADIO_ADDR1")); Fact *lh = getParameterFact(_vehicle->id(), QStringLiteral("SLNK_RADIO_ADDR2")); uint64_t val = str.toULongLong(0, 16); uint32_t val_uh = val >> 32; uint32_t val_lh = val & 0xFFFFFFFF; uh->setRawValue(QVariant(val_uh)); lh->setRawValue(QVariant(val_lh)); } //----------------------------------------------------------------------------- int SyslinkComponentController::radioRate() { return getParameterFact(_vehicle->id(), QStringLiteral("SLNK_RADIO_RATE"))->rawValue().toInt(); } //----------------------------------------------------------------------------- void SyslinkComponentController::setRadioRate(int idx) { if(idx >= 0 && idx <= 2 && idx != radioRate()) { Fact* r = getParameterFact(_vehicle->id(), QStringLiteral("SLNK_RADIO_RATE")); r->setRawValue(idx); } } //----------------------------------------------------------------------------- void SyslinkComponentController::resetDefaults() { Fact* chan = getParameterFact(_vehicle->id(), QStringLiteral("SLNK_RADIO_CHAN")); Fact* rate = getParameterFact(_vehicle->id(), QStringLiteral("SLNK_RADIO_RATE")); Fact* addr1 = getParameterFact(_vehicle->id(), QStringLiteral("SLNK_RADIO_ADDR1")); Fact* addr2 = getParameterFact(_vehicle->id(), QStringLiteral("SLNK_RADIO_ADDR2")); chan->setRawValue(chan->rawDefaultValue()); rate->setRawValue(rate->rawDefaultValue()); addr1->setRawValue(addr1->rawDefaultValue()); addr2->setRawValue(addr2->rawDefaultValue()); } //----------------------------------------------------------------------------- void SyslinkComponentController::_channelChanged(QVariant) { emit radioChannelChanged(); } //----------------------------------------------------------------------------- void SyslinkComponentController::_addressChanged(QVariant) { emit radioAddressChanged(); } //----------------------------------------------------------------------------- void SyslinkComponentController::_rateChanged(QVariant) { emit radioRateChanged(); }
36.07971
112
0.573408
uav-operation-system
731d865dfa99b5897ff8777ef1c573abe68940d4
480
hpp
C++
qflow/system.hpp
johanere/qflow
5453cd5c3230ad7f082adf9ec1aea63ab0a4312a
[ "MIT" ]
5
2019-07-24T21:46:24.000Z
2021-06-11T18:18:24.000Z
qflow/system.hpp
johanere/qflow
5453cd5c3230ad7f082adf9ec1aea63ab0a4312a
[ "MIT" ]
22
2019-02-19T10:49:26.000Z
2019-07-18T09:42:13.000Z
qflow/system.hpp
bsamseth/FYS4411
72b879e7978364498c48fc855b5df676c205f211
[ "MIT" ]
2
2020-11-04T15:17:24.000Z
2021-11-03T16:37:38.000Z
#pragma once #include "definitions.hpp" #include "vector.hpp" #include <Eigen/Dense> using System = Matrix; namespace Distance { void init(const System&); Real probe(const System&, int i, int j); void invalidate_cache(int i); // The plain, non-memoized euclidian norm. // Fall back to this if not initialized, or when cache is invalidated. inline Real distance(const System& system, int i, int j) { return norm(system.row(i) - system.row(j)); } } // namespace Distance
20
70
0.71875
johanere
732198936b16b5117cc7dcfd2dd2ace65dae8bc4
1,235
cpp
C++
src/expectation.cpp
xchrishawk/spookshow
139910e97330a387213a504ae77c2f3dbcb06134
[ "MIT" ]
null
null
null
src/expectation.cpp
xchrishawk/spookshow
139910e97330a387213a504ae77c2f3dbcb06134
[ "MIT" ]
null
null
null
src/expectation.cpp
xchrishawk/spookshow
139910e97330a387213a504ae77c2f3dbcb06134
[ "MIT" ]
null
null
null
/** * @file expectation.cpp * @author Chris Vig ([email protected]) * @date 2016/12/30 */ /* -- Includes -- */ #include <sstream> #include <string> #include <spookshow/spookshow.hpp> /* -- Namespaces -- */ using namespace spookshow; /* -- Procedures -- */ expectation::expectation(const std::string& name, int required_count) : m_name(name), m_required_count(required_count), m_order(expectation_order::current_order()), m_count(0) { if (m_order) m_order->enqueue_expectation(this); } expectation::~expectation() { if (is_fulfilled()) return; std::ostringstream message; message << "Unfulfilled expectation! [" << name() << "] Expected " << m_required_count << " call" << (m_required_count == 1 ? "" : "s") << ", received " << m_count << " call" << (m_count == 1 ? "" : "s") << "."; internal::handle_failure(message.str()); } void expectation::fulfill() { if (m_order && m_count == 0) { if (m_order->is_expectation_next(this)) m_order->dequeue_expectation(); else { std::ostringstream message; message << "Expectation fulfilled out of order! [" << name() << "]"; internal::handle_failure(message.str()); } } ++m_count; }
21.666667
95
0.610526
xchrishawk
732d7fb51c8b50ec5af805bb6831d3ce0aaf348a
8,977
hpp
C++
Libraries/Zilch/Project/Zilch/Any.hpp
jodavis42/ZilchShaders
a161323165c54d2824fe184f5d540e0a008b4d59
[ "MIT" ]
1
2019-08-31T00:45:45.000Z
2019-08-31T00:45:45.000Z
Libraries/Zilch/Project/Zilch/Any.hpp
jodavis42/ZilchShaders
a161323165c54d2824fe184f5d540e0a008b4d59
[ "MIT" ]
5
2020-04-13T00:17:11.000Z
2021-04-20T23:11:42.000Z
Libraries/Zilch/Project/Zilch/Any.hpp
jodavis42/ZilchShaders
a161323165c54d2824fe184f5d540e0a008b4d59
[ "MIT" ]
null
null
null
/**************************************************************\ * Author: Trevor Sundberg * Copyright 2016, DigiPen Institute of Technology \**************************************************************/ #pragma once #ifndef ZILCH_ANY_HPP #define ZILCH_ANY_HPP namespace Zilch { // Returns an invalid type that is zeroed out (only used for not-crashing after an assert) // This places no requirement on default construction or copy construction template <typename T> T& GetInvalid() { // Remove the reference qualifier if it has one typedef typename Zero::Decay<T>::Type TNonReference; static byte InvalidBuffer[sizeof(TNonReference)] = { 0 }; // Clear out the buffer every time we request it memset(InvalidBuffer, 0, sizeof(InvalidBuffer)); // Cast the buffer into a pointer then into a reference of the requested type return *(TNonReference*)InvalidBuffer; } // Stores any type of object (handles, delegates, or even value types) class Any { public: // Constructor that initializes the Any to null (a handle, set to NullType) Any(); Any(nullptr_t); Any(Zero::MoveReference<Any> rhs) { Error("Not implemented."); } template <typename T> Any(const T& value, ExecutableState* state = nullptr, P_DISABLE_IF((Zero::is_base_of<Type, typename Zero::remove_pointer<typename Zero::remove_const_and_volatile<T>::type>::type>::value))) { typedef typename TypeBinding::StripQualifiers<T>::Type UnqualifiedType; const UnqualifiedType* pointer = TypeBinding::ReferenceCast<T&, const UnqualifiedType*>::Cast((T&)value); BoundType* type = ZilchVirtualTypeId(pointer); type->IsInitializedAssert(); ZilchTypeId(T)->IsInitializedAssert(); // Get how big the copyable size of the object is (size of a handle, or the entire value size) size_t copyableSize = type->GetCopyableSize(); // Allocate room to store this type (may store locally and not actually allocate) byte* destination = this->AllocateData(copyableSize); // Store the type and copy construct the data into us this->StoredType = type; // If the type is a reference type... (this is always a handle) if (type->CopyMode == TypeCopyMode::ReferenceType) { if (state == nullptr) state = ExecutableState::CallingState; InternalWriteRef<T>(value, destination, state); } // Otherwise it must be a value type... else { InternalWriteValue<T>(value, destination); } } Any(cstr value, ExecutableState* state = nullptr) : Any(String(value), state) { } template <typename T> T Get(GetOptions::Enum options = GetOptions::ReturnDefaultOrNull) const { if (this->StoredType == nullptr) { ErrorIf(options == GetOptions::AssertOnNull, "The value inside the Any was null"); return GetInvalid<T>(); } // Check if we can directly convert the stored type into the requested type // This supports derived -> base class casting (but not visa versa), enums to integers, etc BoundType* toType = ZilchTypeId(T); if (this->StoredType->IsRawCastableTo(toType) == false) { ErrorIf(options == GetOptions::AssertOnNull, "There was a value inside the Any of type '%s' but it cannot be converted to '%s'", this->StoredType->ToString().c_str(), toType->Name.c_str()); return GetInvalid<T>(); } byte* data = (byte*)this->GetData(); // If the type is a reference type... (this is always a handle) if (toType->CopyMode == TypeCopyMode::ReferenceType) { return InternalReadRef<T>(data); } // Otherwise it must be a value type... else { return InternalReadValue<T>(data); } } template <typename T> bool Is() const { BoundType* checkType = ZilchTypeId(T); return this->StoredType->IsRawCastableTo(checkType); } // Copying will properly reference count handles, delegates this handle, and memcpy value types Any(const Any& other); // Creates an any from a handle and reference counts Any(const Handle& other); // Creates an any from a delegate and reference counts Any(const Delegate& other); // Constructor that initializes to the given data and type (the data is copied in using GenericCopyConstruct) Any(const byte* data, Type* type); // Construct a default instance of a particular type (equivalent of default(T)) explicit Any(Type* type); // Destructor that decrements reference counts and properly handles stored data ~Any(); // Copying will properly reference count handles, delegates this handle, and memcpy value types Any& operator=(const Any& rhs); // Checks if the internal handle/delegate/value is the same bool operator==(const Any& rhs) const; bool operator==(Zero::NullPointerType) const; // Checks if the internal handle/delegate/value is the different bool operator!=(const Any& rhs) const; bool operator!=(Zero::NullPointerType) const; // Hashes a handle (generally used by hashable containers) size_t Hash() const; // Checks if the any itself is holding no value, or if the value stored within the any // is null. This specifically checks Handles and Delegates for a null value bool IsNull() const; bool IsNotNull() const; // Converts the internal value to string (used for debugging) String ToString() const; // Converts the internal value to a Handle. If it does not store a handle type, it will // return an empty Handle. Handle ToHandle() const; // If the type stored internally is a Handle then this will invoke Dereference on the handle // Otherwise this will return the same value as GetData byte* Dereference() const; // Destruct any data stored by the any // This also clears the entire any out to zero void Clear(); // Allocates data if the size goes past the sizeof(this->Data), or returns a pointer to this->Data byte* AllocateData(size_t size); // Get the raw type data that we point at (may be our internal Data, or may be allocated) const byte* GetData() const; // Much like the copy constructor or assignment of an any, except it avoids // creating an extra 'any' in cases where we just have the memory and the type void AssignFrom(const byte* data, Type* type); // Replaces our stored definition with a default constructed version of the given type (equivalent of default(T)) // Typically makes handles null, delegates null, and value types cleared to 0 void DefaultConstruct(Type* type); // Generically copies the value of this any to another location // This will NOT copy the 'Any' but rather the stored type // Make sure the size and type of destination matches! void CopyStoredValueTo(byte* to) const; // Checks if the any is currently holding a value // Note that the value MAY be null, which is still technically a value stored within the any // If you wish to check for null for various stored types, use IsNull bool IsHoldingValue() const; public: // We want to store the largest type (the delegate, handle, etc) // The delegate stores the handle, so we know delegate is the biggest // If the size of the type is bigger then can fit here, then we allocate a pointer instead byte Data[sizeof(Delegate)]; // The type that we're storing inside the data Type* StoredType; }; // Type defines for ease of use typedef const Any& AnyParam; // Given a type we know natively, return a value pointed at by a data pointer // If the data is not given, this will default construct the type // This is specialized by the Any type to return an Any that encapsulates the value template <typename T> T CopyToAnyOrActualType(byte* data, Type* dataType) { // If no data was provided, then return the default value for T if (data == nullptr) { // Not all primitive constructors zero out the memory, so do that first byte memory[sizeof(T)] = {0}; new (memory) T(); return *(T*)memory; } // Otherwise just cast data into the T type return *(T*)data; } // Specialization for the Any type, which will copy the value into an Any template <> Any CopyToAnyOrActualType<Any>(byte* data, Type* dataType); // Given a type we know natively, just directly copy it to a location // This is specialized by the Any type to only copy its inner value template <typename T> ZeroSharedTemplate void CopyFromAnyOrActualType(const T& value, byte* to) { // Just directly construct the value new (to) T(value); } // Specialization for the Any type, which will copy the value out of an Any template <> void CopyFromAnyOrActualType<Any>(const Any& any, byte* to); } #endif
35.908
192
0.670046
jodavis42
73310779d3c6123b480f17b97154b7eca5a24326
1,977
cpp
C++
spoj/classical/is_it_a_tree.cpp
Rkhoiwal/Competitive-prog-Archive
18a95a8b2b9ca1a28d6fe939c1db5450d541ddc9
[ "MIT" ]
null
null
null
spoj/classical/is_it_a_tree.cpp
Rkhoiwal/Competitive-prog-Archive
18a95a8b2b9ca1a28d6fe939c1db5450d541ddc9
[ "MIT" ]
null
null
null
spoj/classical/is_it_a_tree.cpp
Rkhoiwal/Competitive-prog-Archive
18a95a8b2b9ca1a28d6fe939c1db5450d541ddc9
[ "MIT" ]
null
null
null
#include <iostream> #include <vector> using namespace std; inline void use_io_optimizations() { ios_base::sync_with_stdio(false); cin.tie(nullptr); } class UnionFind { public: UnionFind(unsigned int items): components(items), parents(items), ranks(items) { for (unsigned int i {0}; i < components; ++i) { parents[i] = i; } } void link(unsigned int item, unsigned int another_item) { auto root_i = find(item); auto root_j = find(another_item); if (root_i == root_j) { return; } if (ranks[root_i] < ranks[root_j]) { parents[root_i] = root_j; } else { parents[root_j] = root_i; if (ranks[root_i] == ranks[root_j]) { ++ranks[root_i]; } } --components; } unsigned int find(unsigned int item) { auto root = item; while (root != parents[root]) { root = parents[root]; } while (item != root) { auto parent = parents[item]; parents[item] = root; item = parent; } return root; } unsigned int size() const { return components; } private: unsigned int components; vector<unsigned int> parents; vector<unsigned int> ranks; }; int main() { use_io_optimizations(); unsigned int nodes; unsigned int edges; cin >> nodes >> edges; UnionFind graph(nodes); for (unsigned int i {0}; i < edges; ++i) { unsigned int source; unsigned int destination; cin >> source >> destination; graph.link(source - 1, destination - 1); } if (nodes == edges + 1 && graph.size() == 1) { cout << "YES\n"; } else { cout << "NO\n"; } return 0; }
16.754237
59
0.486596
Rkhoiwal
7331bc71b35fc7565e2f49b2c05132709eab4e38
237
hpp
C++
sdk/procmonsdk/logger.hpp
Syr0/openprocmon
2a4b7b9f5da97215fcb59354a2951a62a3aa41a7
[ "MIT" ]
90
2020-07-28T06:44:56.000Z
2022-03-10T03:59:33.000Z
sdk/procmonsdk/logger.hpp
L4ys/openprocmon
44fb542922f31f9548739dc81d7a7269a564ea41
[ "MIT" ]
4
2021-02-24T09:13:27.000Z
2022-01-18T08:44:52.000Z
sdk/procmonsdk/logger.hpp
L4ys/openprocmon
44fb542922f31f9548739dc81d7a7269a564ea41
[ "MIT" ]
27
2020-07-28T06:49:22.000Z
2022-02-14T05:09:56.000Z
#pragma once #include <windows.h> typedef enum { L_DEBUG, L_INFO, L_WARN, L_ERROR } LEVEL, *PLEVEL; // // A quick logging routine for debug messages. // #define MAX_LOG_MESSAGE 1024 BOOL LogMessage(LEVEL Level, LPCTSTR Format, ...);
18.230769
65
0.721519
Syr0
7332011fd8ef0f0410b36e59d441bb91b8c0ed3b
4,415
cc
C++
src/sst/core/cfgoutput/dotConfigOutput.cc
gvoskuilen/sst-core
6fe68d7b2a0b306d78ca39e7a4a822f1582ca86e
[ "BSD-3-Clause" ]
null
null
null
src/sst/core/cfgoutput/dotConfigOutput.cc
gvoskuilen/sst-core
6fe68d7b2a0b306d78ca39e7a4a822f1582ca86e
[ "BSD-3-Clause" ]
10
2020-04-24T15:24:14.000Z
2020-11-07T20:41:07.000Z
src/sst/core/cfgoutput/dotConfigOutput.cc
gvoskuilen/sst-core
6fe68d7b2a0b306d78ca39e7a4a822f1582ca86e
[ "BSD-3-Clause" ]
2
2021-08-17T19:36:15.000Z
2021-08-19T13:38:14.000Z
// Copyright 2009-2020 NTESS. Under the terms // of Contract DE-NA0003525 with NTESS, the U.S. // Government retains certain rights in this software. // // Copyright (c) 2009-2020, NTESS // All rights reserved. // // This file is part of the SST software package. For license // information, see the LICENSE file in the top level directory of the // distribution. // #include "sst_config.h" #include "dotConfigOutput.h" #include "sst/core/configGraphOutput.h" #include "sst/core/config.h" using namespace SST::Core; DotConfigGraphOutput::DotConfigGraphOutput(const char* path) : ConfigGraphOutput(path) { } void DotConfigGraphOutput::generate(const Config* cfg, ConfigGraph* graph) { if ( nullptr == outputFile ) { throw ConfigGraphOutputException("Output file is not open for writing"); } fprintf(outputFile, "graph \"connections\" {\noverlap=scale;\nsplines=spline;\n"); fprintf(outputFile, "node [shape=record];\ngraph [style=invis];\n\n"); const auto compMap = graph->getComponentMap(); const auto linkMap = graph->getLinkMap(); for ( auto compItr : compMap ) { fprintf(outputFile, "subgraph cluster_%" PRIu64 " {\n", compItr.id); generateDot( compItr, linkMap ); fprintf(outputFile, "}\n\n"); } fprintf(outputFile, "\n"); for ( auto linkItr : linkMap ) { generateDot( linkItr ); } fprintf(outputFile, "\n}\n\n"); fprintf(outputFile, "graph \"sst_simulation\" {\noverlap=scale;\nsplines=spline;\n"); fprintf(outputFile, "newrank = true;\n"); fprintf(outputFile, "node [shape=record];\n"); // Find the maximum rank which is marked for the graph partitioning for ( uint32_t r = 0; r < cfg->world_size.rank ; r++ ) { fprintf(outputFile, "subgraph cluster_%u {\n", r); fprintf(outputFile, "label=\"Rank %u\";\n", r); for ( uint32_t t = 0 ; t < cfg->world_size.thread ; t++ ) { fprintf(outputFile, "subgraph cluster_%u_%u {\n", r, t); fprintf(outputFile, "label=\"Thread %u\";\n", t); for ( auto compItr : compMap ) { if ( compItr.rank.rank == r && compItr.rank.thread == t ) { generateDot( compItr, linkMap ); } } fprintf(outputFile, "};\n"); } fprintf(outputFile, "};\n"); } fprintf(outputFile, "\n"); for ( auto linkItr = linkMap.begin(); linkItr != linkMap.end(); linkItr++ ) { generateDot( *linkItr ); } fprintf(outputFile, "\n}\n"); } void DotConfigGraphOutput::generateDot(const ConfigComponent& comp, const ConfigLinkMap_t& linkMap) const { fprintf(outputFile, "%" PRIu64 " [label=\"{<main> %s\\n%s", comp.id, comp.name.c_str(), comp.type.c_str()); int j = comp.links.size(); if(j != 0){ fprintf(outputFile, " |\n"); } for(LinkId_t i : comp.links) { const ConfigLink &link = linkMap[i]; const int port = (link.component[0] == comp.id) ? 0 : 1; fprintf(outputFile, "<%s> Port: %s", link.port[port].c_str(), link.port[port].c_str()); if(j > 1){ fprintf(outputFile, " |\n"); } j--; } fprintf(outputFile, "}\"];\n\n"); for ( auto &sc : comp.subComponents ) { fprintf(outputFile, "%" PRIu64 " [color=gray,label=\"{<main> %s\\n%s", sc.id, sc.name.c_str(), sc.type.c_str()); j = sc.links.size(); if(j != 0){ fprintf(outputFile, " |\n"); } for(LinkId_t i : sc.links) { const ConfigLink &link = linkMap[i]; const int port = (link.component[0] == sc.id) ? 0 : 1; fprintf(outputFile, "<%s> Port: %s", link.port[port].c_str(), link.port[port].c_str()); if(j > 1){ fprintf(outputFile, " |\n"); } j--; } fprintf(outputFile, "}\"];\n"); fprintf(outputFile, "%" PRIu64 ":\"main\" -- %" PRIu64 ":\"main\" [style=dotted];\n\n", comp.id, sc.id); } } void DotConfigGraphOutput::generateDot(const ConfigLink& link) const { int minLatIdx = (link.latency[0] <= link.latency[1]) ? 0 : 1; fprintf(outputFile, "%" PRIu64 ":\"%s\" -- %" PRIu64 ":\"%s\" [label=\"%s\\n%s\"]; \n", link.component[0], link.port[0].c_str(), link.component[1], link.port[1].c_str(), link.name.c_str(), link.latency_str[minLatIdx].c_str()); }
36.487603
120
0.577576
gvoskuilen
73394a30c9d65051b6f05a321260f387a2f93fcb
316
cc
C++
python/src/main.cc
jareddk/triton
ea03d6207728315312d9cb6fa014f6a394b79c71
[ "MIT" ]
null
null
null
python/src/main.cc
jareddk/triton
ea03d6207728315312d9cb6fa014f6a394b79c71
[ "MIT" ]
null
null
null
python/src/main.cc
jareddk/triton
ea03d6207728315312d9cb6fa014f6a394b79c71
[ "MIT" ]
null
null
null
#include <pybind11/pybind11.h> void init_superblocking(pybind11::module &m); void init_torch_utils(pybind11::module &m); void init_triton(pybind11::module &m); PYBIND11_MODULE(libtriton, m) { m.doc() = "Python bindings to the C++ Triton API"; init_triton(m); init_torch_utils(m); init_superblocking(m); }
24.307692
52
0.734177
jareddk
733a9d52bd96985bf4be21d4aaa0a2d18e70ffa9
4,835
hpp
C++
Testbed/Tests/Tiles.hpp
louis-langholtz/Box2D
7c74792bf177cf36640d735de2bba0225bf7f852
[ "Zlib" ]
32
2016-10-20T05:55:04.000Z
2021-11-25T16:34:41.000Z
Testbed/Tests/Tiles.hpp
louis-langholtz/Box2D
7c74792bf177cf36640d735de2bba0225bf7f852
[ "Zlib" ]
50
2017-01-07T21:40:16.000Z
2018-01-31T10:04:05.000Z
Testbed/Tests/Tiles.hpp
louis-langholtz/Box2D
7c74792bf177cf36640d735de2bba0225bf7f852
[ "Zlib" ]
7
2017-02-09T10:02:02.000Z
2020-07-23T22:49:04.000Z
/* * Original work Copyright (c) 2006-2009 Erin Catto http://www.box2d.org * Modified work Copyright (c) 2017 Louis Langholtz https://github.com/louis-langholtz/Box2D * * This software is provided 'as-is', without any express or implied * warranty. In no event will the authors be held liable for any damages * arising from the use of this software. * Permission is granted to anyone to use this software for any purpose, * including commercial applications, and to alter it and redistribute it * freely, subject to the following restrictions: * 1. The origin of this software must not be misrepresented; you must not * claim that you wrote the original software. If you use this software * in a product, an acknowledgment in the product documentation would be * appreciated but is not required. * 2. Altered source versions must be plainly marked as such, and must not be * misrepresented as being the original software. * 3. This notice may not be removed or altered from any source distribution. */ #ifndef TILES_H #define TILES_H #include "../Framework/Test.hpp" namespace box2d { /// This stress tests the dynamic tree broad-phase. This also shows that tile /// based collision is _not_ smooth due to Box2D not knowing about adjacency. class Tiles : public Test { public: enum { e_count = 20 }; Tiles() { m_fixtureCount = 0; const auto start = std::chrono::high_resolution_clock::now(); { const auto a = Real{0.5f}; BodyDef bd; bd.position.y = -a * Meter; const auto ground = m_world->CreateBody(bd); const auto N = 200; const auto M = 10; Vec2 position; position.y = 0.0f; for (auto j = 0; j < M; ++j) { position.x = -N * a; for (auto i = 0; i < N; ++i) { PolygonShape shape; SetAsBox(shape, a * Meter, a * Meter, position * Meter, Angle{0}); ground->CreateFixture(std::make_shared<PolygonShape>(shape)); ++m_fixtureCount; position.x += 2.0f * a; } position.y -= 2.0f * a; } } { const auto a = Real{0.5f}; const auto shape = std::make_shared<PolygonShape>(a * Meter, a * Meter); shape->SetDensity(Real{5} * KilogramPerSquareMeter); Vec2 x(-7.0f, 0.75f); Vec2 y; const auto deltaX = Vec2(0.5625f, 1.25f); const auto deltaY = Vec2(1.125f, 0.0f); for (auto i = 0; i < e_count; ++i) { y = x; for (auto j = i; j < e_count; ++j) { BodyDef bd; bd.type = BodyType::Dynamic; bd.position = y * Meter; const auto body = m_world->CreateBody(bd); body->CreateFixture(shape); ++m_fixtureCount; y += deltaY; } x += deltaX; } } const auto end = std::chrono::high_resolution_clock::now(); const auto elapsed_secs = std::chrono::duration<Real>{end - start}; m_createTime = elapsed_secs.count(); } void PostStep(const Settings&, Drawer& drawer) override { const auto height = m_world->GetTreeHeight(); const auto leafCount = m_world->GetProxyCount(); if (leafCount > 0) { const auto minimumNodeCount = 2 * leafCount - 1; const auto minimumHeight = ceilf(logf(float(minimumNodeCount)) / logf(2.0f)); drawer.DrawString(5, m_textLine, "dynamic tree height = %d, min = %d", height, int(minimumHeight)); m_textLine += DRAW_STRING_NEW_LINE; } drawer.DrawString(5, m_textLine, "create time = %6.2f ms, fixture count = %d", static_cast<double>(m_createTime * Real(1000)), m_fixtureCount); m_textLine += DRAW_STRING_NEW_LINE; //DynamicTree* tree = &m_world->m_contactManager.m_broadPhase.m_tree; //if (GetStepCount() == 400) //{ // tree->RebuildBottomUp(); //} } void KeyboardDown(Key key) override { switch (key) { case Key_C: m_snapshot = *m_world; break; case Key_Backspace: if (m_snapshot.GetBodies().size() > 0) { ResetWorld(m_snapshot); } break; default: break; } } int m_fixtureCount; Real m_createTime; World m_snapshot; }; } // namespace box2d #endif
31.601307
91
0.543123
louis-langholtz
733bc8cee3fc21b6dd27ea32daf1a64358b6eb66
23,145
cpp
C++
Pod/Classes/algorithms/extractor/lowlevelspectralextractor.cpp
jbloit/iosEssentia
785ba29e8178942b396575dd3872bdf3d5d63cd5
[ "MIT" ]
null
null
null
Pod/Classes/algorithms/extractor/lowlevelspectralextractor.cpp
jbloit/iosEssentia
785ba29e8178942b396575dd3872bdf3d5d63cd5
[ "MIT" ]
null
null
null
Pod/Classes/algorithms/extractor/lowlevelspectralextractor.cpp
jbloit/iosEssentia
785ba29e8178942b396575dd3872bdf3d5d63cd5
[ "MIT" ]
null
null
null
/* * Copyright (C) 2006-2013 Music Technology Group - Universitat Pompeu Fabra * * This file is part of Essentia * * Essentia is free software: you can redistribute it and/or modify it under * the terms of the GNU Affero General Public License as published by the Free * Software Foundation (FSF), either version 3 of the License, or (at your * option) any later version. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * * You should have received a copy of the Affero GNU General Public License * version 3 along with this program. If not, see http://www.gnu.org/licenses/ */ #include "lowlevelspectralextractor.h" #include "algorithmfactory.h" #include "essentiamath.h" #include "poolstorage.h" #include "copy.h" using namespace std; using namespace essentia; using namespace essentia::streaming; const char* LowLevelSpectralExtractor::name = "LowLevelSpectralExtractor"; const char* LowLevelSpectralExtractor::description = DOC("This algorithm extracts all low level spectral features, which do not require an equal-loudness filter for their computation, from an audio signal"); LowLevelSpectralExtractor::LowLevelSpectralExtractor() : _configured(false) { // input: declareInput(_signal, "signal", "the input audio signal"); // outputs: declareOutput(_bbands, "barkbands", "spectral energy at each bark band. See BarkBands alogithm"); declareOutput(_bbandsKurtosis, "barkbands_kurtosis", "kurtosis from bark bands. See DistributionShape algorithm documentation"); declareOutput(_bbandsSkewness, "barkbands_skewness", "skewness from bark bands. See DistributionShape algorithm documentation"); declareOutput(_bbandsSpread, "barkbands_spread", "spread from barkbands. See DistributionShape algorithm documentation"); declareOutput(_hfcValue, "hfc", "See HFC algorithm documentation"); declareOutput(_mfccs, "mfcc", "See MFCC algorithm documentation"); declareOutput(_pitchValue, "pitch", "See PitchYinFFT algorithm documentation"); declareOutput(_pitchConfidence, "pitch_instantaneous_confidence", "See PitchYinFFT algorithm documentation"); declareOutput(_pitchSalienceValue, "pitch_salience", "See PitchSalience algorithm documentation"); declareOutput(_silence20, "silence_rate_20dB", "See SilenceRate algorithm documentation"); declareOutput(_silence30, "silence_rate_30dB", "See SilenceRate algorithm documentation"); declareOutput(_silence60, "silence_rate_60dB", "See SilenceRate algorithm documentation"); declareOutput(_spectralComplexityValue, "spectral_complexity", "See Spectral algorithm documentation"); declareOutput(_crestValue, "spectral_crest", "See Crest algorithm documentation"); declareOutput(_decreaseValue, "spectral_decrease", "See Decrease algorithm documentation"); declareOutput(_energyValue, "spectral_energy", "See Energy algorithm documentation"); declareOutput(_ebandLow, "spectral_energyband_low", "Energy in band (20,150] Hz. See EnergyBand algorithm documentation"); declareOutput(_ebandMidLow, "spectral_energyband_middle_low", "Energy in band (150,800] Hz.See EnergyBand algorithm documentation"); declareOutput(_ebandMidHigh, "spectral_energyband_middle_high", "Energy in band (800,4000] Hz. See EnergyBand algorithm documentation"); declareOutput(_ebandHigh, "spectral_energyband_high", "Energy in band (4000,20000] Hz. See EnergyBand algorithm documentation"); declareOutput(_flatness, "spectral_flatness_db", "See flatnessDB algorithm documentation"); declareOutput(_fluxValue, "spectral_flux", "See Flux algorithm documentation"); declareOutput(_rmsValue, "spectral_rms", "See RMS algorithm documentation"); declareOutput(_rolloffValue, "spectral_rolloff", "See RollOff algorithm documentation"); declareOutput(_strongPeakValue, "spectral_strongpeak", "See StrongPeak algorithm documentation"); declareOutput(_zeroCrossingRate, "zerocrossingrate", "See ZeroCrossingRate algorithm documentation"); // sfx: declareOutput(_inharmonicityValue, "inharmonicity", "See Inharmonicity algorithm documentation"); declareOutput(_tristimulusValue, "tristimulus", "See Tristimulus algorithm documentation"); declareOutput(_odd2even, "oddtoevenharmonicenergyratio", "See OddToEvenHarmonicEnergyRatio algorithm documentation"); // create network (instantiate algorithms) createInnerNetwork(); // wire all this up! // connections: _signal >> _frameCutter->input("signal"); // connecting temporal descriptors _frameCutter->output("frame") >> _silenceRate->input("frame"); _silenceRate->output("threshold_0") >> _silence20; _silenceRate->output("threshold_1") >> _silence30; _silenceRate->output("threshold_2") >> _silence60; _frameCutter->output("frame") >> _zcr->input("signal"); _zcr->output("zeroCrossingRate") >> _zeroCrossingRate; // connecting spectral descriptors _frameCutter->output("frame") >> _windowing->input("frame"); _windowing->output("frame") >> _spectrum->input("frame"); _spectrum->output("spectrum") >> _mfcc->input("spectrum"); _mfcc->output("mfcc") >> _mfccs; _mfcc->output("bands") >> NOWHERE; _spectrum->output("spectrum") >> _energy->input("array"); _spectrum->output("spectrum") >> _energyBand_0->input("spectrum"); _spectrum->output("spectrum") >> _energyBand_1->input("spectrum"); _spectrum->output("spectrum") >> _energyBand_2->input("spectrum"); _spectrum->output("spectrum") >> _energyBand_3->input("spectrum"); _energy->output("energy") >> _energyValue; _energyBand_0->output("energyBand") >> _ebandLow; _energyBand_1->output("energyBand") >> _ebandMidLow; _energyBand_2->output("energyBand") >> _ebandMidHigh; _energyBand_3->output("energyBand") >> _ebandHigh; _spectrum->output("spectrum") >> _hfc->input("spectrum"); _hfc->output("hfc") >> _hfcValue; _spectrum->output("spectrum") >> _rms->input("array"); _rms->output("rms") >> _rmsValue; _spectrum->output("spectrum") >> _flux->input("spectrum"); _flux->output("flux") >> _fluxValue; _spectrum->output("spectrum") >> _rollOff->input("spectrum"); _rollOff->output("rollOff") >> _rolloffValue; _spectrum->output("spectrum") >> _strongPeak->input("spectrum"); _strongPeak->output("strongPeak") >> _strongPeakValue; _spectrum->output("spectrum") >> _square->input("array"); _square->output("array") >> _decrease->input("array"); _spectrum->output("spectrum") >> _spectralComplexity->input("spectrum"); _spectralComplexity->output("spectralComplexity") >> _spectralComplexityValue; _spectrum->output("spectrum") >> _pitchDetection->input("spectrum"); _pitchDetection->output("pitch") >> _pitchValue; _pitchDetection->output("pitchConfidence") >> _pitchConfidence; _spectrum->output("spectrum") >> _pitchSalience->input("spectrum"); _pitchSalience->output("pitchSalience") >> _pitchSalienceValue; _spectrum->output("spectrum") >> _barkBands->input("spectrum"); _barkBands->output("bands") >> _bbands; _barkBands->output("bands") >> _crest->input("array"); _barkBands->output("bands") >> _flatnessdb->input("array"); _barkBands->output("bands") >> _centralMoments->input("array"); _crest->output("crest") >> _crestValue; _decrease->output("decrease") >> _decreaseValue; _flatnessdb->output("flatnessDB") >> _flatness; _centralMoments->output("centralMoments") >> _distributionShape->input("centralMoments"); _distributionShape->output("kurtosis") >> _bbandsKurtosis; _distributionShape->output("skewness") >> _bbandsSkewness; _distributionShape->output("spread") >> _bbandsSpread; // sfx: _pitchDetection->output("pitch") >> _harmonicPeaks->input("pitch"); _spectrum->output("spectrum") >> _spectralPeaks->input("spectrum"); _spectralPeaks->output("frequencies") >> _harmonicPeaks->input("frequencies"); _spectralPeaks->output("magnitudes") >> _harmonicPeaks->input("magnitudes"); _harmonicPeaks->output("harmonicMagnitudes") >> _tristimulus->input("magnitudes"); _harmonicPeaks->output("harmonicFrequencies") >> _tristimulus->input("frequencies"); _harmonicPeaks->output("harmonicMagnitudes") >> _oddToEvenHarmonicEnergyRatio->input("magnitudes"); _harmonicPeaks->output("harmonicFrequencies") >> _oddToEvenHarmonicEnergyRatio->input("frequencies"); _harmonicPeaks->output("harmonicMagnitudes") >> _inharmonicity->input("magnitudes"); _harmonicPeaks->output("harmonicFrequencies") >> _inharmonicity->input("frequencies"); _inharmonicity->output("inharmonicity") >> _inharmonicityValue; _tristimulus->output("tristimulus") >> _tristimulusValue; _oddToEvenHarmonicEnergyRatio->output("oddToEvenHarmonicEnergyRatio") >> _odd2even; _network = new scheduler::Network(_frameCutter); } void LowLevelSpectralExtractor::createInnerNetwork() { AlgorithmFactory& factory = AlgorithmFactory::instance(); _barkBands = factory.create("BarkBands", "numberBands", 27); _centralMoments = factory.create("CentralMoments", "range", 26); _crest = factory.create("Crest"); _decrease = factory.create("Decrease"); _distributionShape = factory.create("DistributionShape"); _energyBand_0 = factory.create("EnergyBand", "startCutoffFrequency", 20, "stopCutoffFrequency", 150); _energyBand_1 = factory.create("EnergyBand", "startCutoffFrequency", 150, "stopCutoffFrequency", 800); _energyBand_2 = factory.create("EnergyBand", "startCutoffFrequency", 800, "stopCutoffFrequency", 4000); _energyBand_3 = factory.create("EnergyBand", "startCutoffFrequency", 4000, "stopCutoffFrequency", 20000); _energy = factory.create("Energy"); _flatnessdb = factory.create("FlatnessDB"); _flux = factory.create("Flux"); _frameCutter = factory.create("FrameCutter"); _hfc = factory.create("HFC"); _harmonicPeaks = factory.create("HarmonicPeaks"); _inharmonicity = factory.create("Inharmonicity"); _mfcc = factory.create("MFCC"); _oddToEvenHarmonicEnergyRatio = factory.create("OddToEvenHarmonicEnergyRatio"); _pitchDetection = factory.create("PitchYinFFT"); _pitchSalience = factory.create("PitchSalience"); _rms = factory.create("RMS"); _rollOff = factory.create("RollOff"); _silenceRate = factory.create("SilenceRate"); _spectralComplexity = factory.create("SpectralComplexity", "magnitudeThreshold", 0.005); _spectralPeaks = factory.create("SpectralPeaks"); _spectrum = factory.create("Spectrum"); _strongPeak = factory.create("StrongPeak"); _tristimulus = factory.create("Tristimulus"); _square = factory.create("UnaryOperator", "type", "square"); _windowing = factory.create("Windowing", "type", "blackmanharris62"); _zcr = factory.create("ZeroCrossingRate"); Real thresholds_dB[] = { -20, -30, -60 }; vector<Real> thresholds(ARRAY_SIZE(thresholds_dB)); for (int i=0; i<(int)thresholds.size(); i++) { thresholds[i] = db2lin(thresholds_dB[i]/2.0); } _silenceRate->configure("thresholds", thresholds); } void LowLevelSpectralExtractor::configure() { int frameSize = parameter("frameSize").toInt(); int hopSize = parameter("hopSize").toInt(); Real sampleRate = parameter("sampleRate").toReal(); _decrease->configure("range", 0.5 * sampleRate); _frameCutter->configure("silentFrames", "noise", "hopSize", hopSize, "frameSize", frameSize); _pitchDetection->configure("frameSize", frameSize); _spectralPeaks->configure("orderBy", "frequency", "minFrequency", sampleRate/Real(frameSize)); } LowLevelSpectralExtractor::~LowLevelSpectralExtractor() { clearAlgos(); } void LowLevelSpectralExtractor::clearAlgos() { if (!_configured) return; delete _network; } namespace essentia { namespace standard { const char* LowLevelSpectralExtractor::name = "LowLevelSpectralExtractor"; const char* LowLevelSpectralExtractor::description = DOC("This algorithm extracts all low level spectral features from an audio signal"); LowLevelSpectralExtractor::LowLevelSpectralExtractor() { declareInput(_signal, "signal", "the audio input signal"); declareOutput(_barkBands, "barkbands", "spectral energy at each bark band. See BarkBands alogithm"); declareOutput(_kurtosis, "barkbands_kurtosis", "kurtosis from bark bands. See DistributionShape algorithm documentation"); declareOutput(_skewness, "barkbands_skewness", "skewness from bark bands. See DistributionShape algorithm documentation"); declareOutput(_spread, "barkbands_spread", "spread from barkbands. See DistributionShape algorithm documentation"); declareOutput(_hfc, "hfc", "See HFC algorithm documentation"); declareOutput(_mfcc, "mfcc", "See MFCC algorithm documentation"); declareOutput(_pitch, "pitch", "See PitchYinFFT algorithm documentation"); declareOutput(_pitchConfidence, "pitch_instantaneous_confidence", "See PitchYinFFT algorithm documentation"); declareOutput(_pitchSalience, "pitch_salience", "See PitchSalience algorithm documentation"); declareOutput(_threshold_0, "silence_rate_20dB", "See SilenceRate algorithm documentation"); declareOutput(_threshold_1, "silence_rate_30dB", "See SilenceRate algorithm documentation"); declareOutput(_threshold_2, "silence_rate_60dB", "See SilenceRate algorithm documentation"); declareOutput(_spectralComplexity, "spectral_complexity", "See Spectral algorithm documentation"); declareOutput(_crest, "spectral_crest", "See Crest algorithm documentation"); declareOutput(_decrease, "spectral_decrease", "See Decrease algorithm documentation"); declareOutput(_energy, "spectral_energy", "See Energy algorithm documentation"); declareOutput(_energyBand_0, "spectral_energyband_low", "Energy in band (20,150] Hz. See EnergyBand algorithm documentation"); declareOutput(_energyBand_1, "spectral_energyband_middle_low", "Energy in band (150,800] Hz.See EnergyBand algorithm documentation"); declareOutput(_energyBand_2, "spectral_energyband_middle_high", "Energy in band (800,4000] Hz. See EnergyBand algorithm documentation"); declareOutput(_energyBand_3, "spectral_energyband_high", "Energy in band (4000,20000] Hz. See EnergyBand algorithm documentation"); declareOutput(_flatnessdb, "spectral_flatness_db", "See flatnessDB algorithm documentation"); declareOutput(_flux, "spectral_flux", "See Flux algorithm documentation"); declareOutput(_rms, "spectral_rms", "See RMS algorithm documentation"); declareOutput(_rollOff, "spectral_rolloff", "See RollOff algorithm documentation"); declareOutput(_strongPeak, "spectral_strongpeak", "See StrongPeak algorithm documentation"); declareOutput(_zeroCrossingRate, "zerocrossingrate", "See ZeroCrossingRate algorithm documentation"); // sfx: declareOutput(_inharmonicity, "inharmonicity", "See Inharmonicity algorithm documentation"); declareOutput(_tristimulus, "tristimulus", "See Tristimulus algorithm documentation"); declareOutput(_oddToEvenHarmonicEnergyRatio, "oddtoevenharmonicenergyratio", "See OddToEvenHarmonicEnergyRatio algorithm documentation"); _lowLevelExtractor = streaming::AlgorithmFactory::create("LowLevelSpectralExtractor"); _vectorInput = new streaming::VectorInput<Real>(); createInnerNetwork(); } LowLevelSpectralExtractor::~LowLevelSpectralExtractor() { delete _network; } void LowLevelSpectralExtractor::reset() { _network->reset(); } void LowLevelSpectralExtractor::configure() { _lowLevelExtractor->configure(INHERIT("frameSize"), INHERIT("hopSize"), INHERIT("sampleRate")); } void LowLevelSpectralExtractor::createInnerNetwork() { streaming::connect(*_vectorInput, _lowLevelExtractor->input("signal")); streaming::connect(_lowLevelExtractor->output("barkbands"), _pool, "barkbands"); streaming::connect(_lowLevelExtractor->output("barkbands_kurtosis"), _pool, "kurtosis"); streaming::connect(_lowLevelExtractor->output("barkbands_skewness"), _pool, "skewness"); streaming::connect(_lowLevelExtractor->output("barkbands_spread"), _pool, "spread"); streaming::connect(_lowLevelExtractor->output("hfc"), _pool, "hfc"); streaming::connect(_lowLevelExtractor->output("mfcc"), _pool, "mfcc"); streaming::connect(_lowLevelExtractor->output("pitch"), _pool, "pitch"); streaming::connect(_lowLevelExtractor->output("pitch_instantaneous_confidence"), _pool, "pitchConfidence"); streaming::connect(_lowLevelExtractor->output("pitch_salience"), _pool, "pitchSalience"); streaming::connect(_lowLevelExtractor->output("silence_rate_20dB"), _pool, "silence_rate_20dB"); streaming::connect(_lowLevelExtractor->output("silence_rate_30dB"), _pool, "silence_rate_30dB"); streaming::connect(_lowLevelExtractor->output("silence_rate_60dB"), _pool, "silence_rate_60dB"); streaming::connect(_lowLevelExtractor->output("spectral_complexity"), _pool, "spectralComplexity"); streaming::connect(_lowLevelExtractor->output("spectral_crest"), _pool, "crest"); streaming::connect(_lowLevelExtractor->output("spectral_decrease"), _pool, "decrease"); streaming::connect(_lowLevelExtractor->output("spectral_energy"), _pool, "energy"); streaming::connect(_lowLevelExtractor->output("spectral_energyband_low"), _pool, "energyBand_0"); streaming::connect(_lowLevelExtractor->output("spectral_energyband_middle_low"), _pool, "energyBand_1"); streaming::connect(_lowLevelExtractor->output("spectral_energyband_middle_high"), _pool, "energyBand_2"); streaming::connect(_lowLevelExtractor->output("spectral_energyband_high"), _pool, "energyBand_3"); streaming::connect(_lowLevelExtractor->output("spectral_flatness_db"), _pool, "flatnessdb"); streaming::connect(_lowLevelExtractor->output("spectral_flux"), _pool, "flux"); streaming::connect(_lowLevelExtractor->output("spectral_rms"), _pool, "rms"); streaming::connect(_lowLevelExtractor->output("spectral_rolloff"), _pool, "rollOff"); streaming::connect(_lowLevelExtractor->output("spectral_strongpeak"), _pool, "strongPeak"); streaming::connect(_lowLevelExtractor->output("zerocrossingrate"), _pool, "zeroCrossingRate"); streaming::connect(_lowLevelExtractor->output("inharmonicity"), _pool, "inharmonicity"); streaming::connect(_lowLevelExtractor->output("tristimulus"), _pool, "tristimulus"); streaming::connect(_lowLevelExtractor->output("oddtoevenharmonicenergyratio"), _pool, "oddToEvenHarmonicEnergyRatio"); _network = new scheduler::Network(_vectorInput); } void LowLevelSpectralExtractor::compute() { const vector<Real>& signal = _signal.get(); _vectorInput->setVector(&signal); _network->run(); vector<vector<Real> > & barkBands = _barkBands.get(); vector<Real> & kurtosis = _kurtosis.get(); vector<Real> & skewness = _skewness.get(); vector<Real> & spread = _spread.get(); vector<Real> & hfc = _hfc.get(); vector<vector<Real> > & mfcc = _mfcc.get(); vector<Real> & pitch = _pitch.get(); vector<Real> & pitchConfidence = _pitchConfidence.get(); vector<Real> & pitchSalience = _pitchSalience.get(); vector<Real> & threshold_0 = _threshold_0.get(); vector<Real> & threshold_1 = _threshold_1.get(); vector<Real> & threshold_2 = _threshold_2.get(); vector<Real> & spectralComplexity = _spectralComplexity.get(); vector<Real> & crest = _crest.get(); vector<Real> & decrease = _decrease.get(); vector<Real> & energy = _energy.get(); vector<Real> & energyBand_0 = _energyBand_0.get(); vector<Real> & energyBand_1 = _energyBand_1.get(); vector<Real> & energyBand_2 = _energyBand_2.get(); vector<Real> & energyBand_3 = _energyBand_3.get(); vector<Real> & flatnessdb = _flatnessdb.get(); vector<Real> & flux = _flux.get(); vector<Real> & rms = _rms.get(); vector<Real> & rollOff = _rollOff.get(); vector<Real> & strongPeak = _strongPeak.get(); vector<Real> & zeroCrossingRate = _zeroCrossingRate.get(); vector<Real> & inharmonicity = _inharmonicity.get(); vector<vector<Real> > & tristimulus = _tristimulus.get(); vector<Real> & oddToEvenHarmonicEnergyRatio = _oddToEvenHarmonicEnergyRatio.get(); barkBands = _pool.value<vector<vector<Real> > >("barkbands"); kurtosis = _pool.value<vector<Real> >("kurtosis"); skewness = _pool.value<vector<Real> >("skewness"); spread = _pool.value<vector<Real> >("spread"); hfc = _pool.value<vector<Real> >("hfc"); mfcc = _pool.value<vector<vector<Real> > >("mfcc"); pitch = _pool.value<vector<Real> >("pitch"); pitchConfidence = _pool.value<vector<Real> >("pitchConfidence"); pitchSalience = _pool.value<vector<Real> >("pitchSalience"); threshold_0 = _pool.value<vector<Real> >("silence_rate_20dB"); threshold_1 = _pool.value<vector<Real> >("silence_rate_30dB"); threshold_2 = _pool.value<vector<Real> >("silence_rate_60dB"); spectralComplexity = _pool.value<vector<Real> >("spectralComplexity"); crest = _pool.value<vector<Real> >("crest"); decrease = _pool.value<vector<Real> >("decrease"); energy = _pool.value<vector<Real> >("energy"); energyBand_0 = _pool.value<vector<Real> >("energyBand_0"); energyBand_1 = _pool.value<vector<Real> >("energyBand_1"); energyBand_2 = _pool.value<vector<Real> >("energyBand_2"); energyBand_3 = _pool.value<vector<Real> >("energyBand_3"); flatnessdb = _pool.value<vector<Real> >("flatnessdb"); flux = _pool.value<vector<Real> >("flux"); rms = _pool.value<vector<Real> >("rms"); rollOff = _pool.value<vector<Real> >("rollOff"); strongPeak = _pool.value<vector<Real> >("strongPeak"); zeroCrossingRate = _pool.value<vector<Real> >("zeroCrossingRate"); inharmonicity = _pool.value<vector<Real> >("inharmonicity"); tristimulus = _pool.value<vector<vector<Real> > >("tristimulus"); oddToEvenHarmonicEnergyRatio = _pool.value<vector<Real> >("oddToEvenHarmonicEnergyRatio"); } } // namespace standard } // namespace essentia
57.574627
207
0.710002
jbloit
734069140143a9873c0f3f6ae8b77658fbe7345c
1,414
cpp
C++
lintcode/strstr.cpp
Broadroad/learnLeetcode
c4af121b3451caa4d53819c5f8c62b38e8e5fb87
[ "Apache-2.0" ]
null
null
null
lintcode/strstr.cpp
Broadroad/learnLeetcode
c4af121b3451caa4d53819c5f8c62b38e8e5fb87
[ "Apache-2.0" ]
null
null
null
lintcode/strstr.cpp
Broadroad/learnLeetcode
c4af121b3451caa4d53819c5f8c62b38e8e5fb87
[ "Apache-2.0" ]
null
null
null
class Solution { public: int BASE = 1000000; /** * @param source: * @param target: * @return: return the index */ int strStr(string &source, string &target) { // Write your code here int tLength = target.size(); if (tLength == 0) { return 0; } // 31 ^ m; int power = 1; for (int i = 0; i < tLength; i++) { power = (power * 31) % BASE; } // compute target hashcode int targetCode = 0; for (int i = 0; i < tLength; i++) { targetCode = (targetCode * 31 + target[i]) % BASE; } int hashcode = 0; for (int i = 0; i < source.size(); i++) { // abc + d hashcode = (hashcode * 31 + source[i]) % BASE; if (i < tLength - 1) { continue; } if (i >= tLength) { // abcd - a hashcode = (hashcode - source[i - tLength] * power) % BASE; if (hashcode < 0) { hashcode += BASE; } } if (hashcode == targetCode) { if (source.substr(i-tLength+1, tLength) == target) { return i-tLength+1; } } } return -1; } };
26.185185
75
0.37553
Broadroad
73426bc70010195b7165a0466a2d9fe8a2ac35d9
2,031
hpp
C++
src/limonp/CastFloat.hpp
ultimate010/cppjieba
ada3f5cf76d1f99570d92bc38d5e42a573839a88
[ "MIT" ]
2
2015-10-25T17:41:22.000Z
2015-10-28T08:46:12.000Z
Jieba/src/limonp/CastFloat.hpp
sakamoto-poteko/neko
642cbc59e1c1241a835f8d9c2590c1935a9e321b
[ "MIT", "Unlicense" ]
null
null
null
Jieba/src/limonp/CastFloat.hpp
sakamoto-poteko/neko
642cbc59e1c1241a835f8d9c2590c1935a9e321b
[ "MIT", "Unlicense" ]
null
null
null
#ifndef LIMONP_CAST_FUNCTS_H #define LIMONP_CAST_FUNCTS_H namespace limonp { namespace CastFloat { //logical and or static const int sign_32 = 0xC0000000; static const int exponent_32 = 0x07800000; static const int mantissa_32 = 0x007FE000; static const int sign_exponent_32 = 0x40000000; static const int loss_32 = 0x38000000; static const short sign_16 = (short)0xC000; static const short exponent_16 = (short)0x3C00; static const short mantissa_16 = (short)0x03FF; static const short sign_exponent_16 = (short)0x4000; static const int exponent_fill_32 = 0x38000000; //infinite static const short infinite_16 = (short) 0x7FFF; static const short infinitesmall_16 = (short) 0x0000; inline float intBitsToFloat(unsigned int x) { union { float f; int i; } u; u.i = x; return u.f; } inline int floatToIntBits(float f) { union { float f; int i ; } u; u.f = f; return u.i; } inline short floatToShortBits(float f) { int fi = floatToIntBits(f); // 提取关键信息 short sign = (short) ((unsigned int)(fi & sign_32) >> 16); short exponent = (short) ((unsigned int)(fi & exponent_32) >> 13); short mantissa = (short) ((unsigned int)(fi & mantissa_32) >> 13); // 生成编码结果 short code = (short) (sign | exponent | mantissa); // 无穷大量、无穷小量的处理 if ((fi & loss_32) > 0 && (fi & sign_exponent_32) > 0) { // 当指数符号为1时(正次方),且左234位为1,返回无穷大量 return (short) (code | infinite_16); } if (((fi & loss_32) ^ loss_32) > 0 && (fi & sign_exponent_32) == 0) { // 当指数符号位0时(负次方),且左234位为0(与111异或>0),返回无穷小量 return infinitesmall_16; } return code; } inline float shortBitsToFloat(short s) { /* * 指数空余3位:若符号位为1,补0;若符号位为0,补1。 尾数位在后补0(13个) */ int sign = ((int) (s & sign_16)) << 16; int exponent = ((int) (s & exponent_16)) << 13; // 指数符号位为0,234位补1 if ((s & sign_exponent_16) == 0 && s != 0) { exponent |= exponent_fill_32; } int mantissa = ((int) (s & mantissa_16)) << 13; // 生成解码结果 int code = sign | exponent | mantissa; return intBitsToFloat(code); } } } #endif
24.46988
71
0.66519
ultimate010
734492a91e88681108a94ec80c3213c341e6f064
4,887
cpp
C++
cocos2d/cocos/editor-support/spine/spine-cocos2dx.cpp
davidyuan/WagonWar
a52211c0e5490dffaacfa1c722d321d969ae612c
[ "MIT" ]
174
2015-01-01T15:12:53.000Z
2022-03-23T03:06:07.000Z
cocos2d/cocos/editor-support/spine/spine-cocos2dx.cpp
davidyuan/WagonWar
a52211c0e5490dffaacfa1c722d321d969ae612c
[ "MIT" ]
2
2015-05-20T14:34:48.000Z
2019-08-14T00:54:40.000Z
cocos2d/cocos/editor-support/spine/spine-cocos2dx.cpp
davidyuan/WagonWar
a52211c0e5490dffaacfa1c722d321d969ae612c
[ "MIT" ]
103
2015-01-10T13:34:24.000Z
2022-01-10T00:55:33.000Z
/****************************************************************************** * Spine Runtime Software License - Version 1.1 * * Copyright (c) 2013, Esoteric Software * All rights reserved. * * Redistribution and use in source and binary forms in whole or in part, with * or without modification, are permitted provided that the following conditions * are met: * * 1. A Spine Essential, Professional, Enterprise, or Education License must * be purchased from Esoteric Software and the license must remain valid: * http://esotericsoftware.com/ * 2. Redistributions of source code must retain this license, which is the * above copyright notice, this declaration of conditions and the following * disclaimer. * 3. Redistributions in binary form must reproduce this license, which is the * above copyright notice, this declaration of conditions and the following * disclaimer, in the documentation and/or other materials provided with the * distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *****************************************************************************/ #include <spine/spine-cocos2dx.h> #include <spine/extension.h> USING_NS_CC; void _spAtlasPage_createTexture (spAtlasPage* self, const char* path) { Texture2D* texture = Director::getInstance()->getTextureCache()->addImage(path); TextureAtlas* textureAtlas = TextureAtlas::createWithTexture(texture, 4); textureAtlas->retain(); self->rendererObject = textureAtlas; // Using getContentSize to make it supports the strategy of loading resources in cocos2d-x. // self->width = texture->getPixelsWide(); // self->height = texture->getPixelsHigh(); self->width = texture->getContentSize().width; self->height = texture->getContentSize().height; } void _spAtlasPage_disposeTexture (spAtlasPage* self) { ((TextureAtlas*)self->rendererObject)->release(); } char* _spUtil_readFile (const char* path, int* length) { char* ret = nullptr; int size = 0; Data data = FileUtils::getInstance()->getDataFromFile(path); if (!data.isNull()) { size = static_cast<int>(data.getSize()); *length = size; // Allocates one more byte for string terminal, it will be safe when parsing JSON file in Spine runtime. ret = (char*)malloc(size + 1); ret[size] = '\0'; memcpy(ret, data.getBytes(), size); } return ret; } /**/ void spRegionAttachment_updateQuad (spRegionAttachment* self, spSlot* slot, V3F_C4B_T2F_Quad* quad, bool premultipliedAlpha) { float vertices[8]; spRegionAttachment_computeWorldVertices(self, slot->skeleton->x, slot->skeleton->y, slot->bone, vertices); GLubyte r = slot->skeleton->r * slot->r * 255; GLubyte g = slot->skeleton->g * slot->g * 255; GLubyte b = slot->skeleton->b * slot->b * 255; float normalizedAlpha = slot->skeleton->a * slot->a; if (premultipliedAlpha) { r *= normalizedAlpha; g *= normalizedAlpha; b *= normalizedAlpha; } GLubyte a = normalizedAlpha * 255; quad->bl.colors.r = r; quad->bl.colors.g = g; quad->bl.colors.b = b; quad->bl.colors.a = a; quad->tl.colors.r = r; quad->tl.colors.g = g; quad->tl.colors.b = b; quad->tl.colors.a = a; quad->tr.colors.r = r; quad->tr.colors.g = g; quad->tr.colors.b = b; quad->tr.colors.a = a; quad->br.colors.r = r; quad->br.colors.g = g; quad->br.colors.b = b; quad->br.colors.a = a; quad->bl.vertices.x = vertices[VERTEX_X1]; quad->bl.vertices.y = vertices[VERTEX_Y1]; quad->tl.vertices.x = vertices[VERTEX_X2]; quad->tl.vertices.y = vertices[VERTEX_Y2]; quad->tr.vertices.x = vertices[VERTEX_X3]; quad->tr.vertices.y = vertices[VERTEX_Y3]; quad->br.vertices.x = vertices[VERTEX_X4]; quad->br.vertices.y = vertices[VERTEX_Y4]; quad->bl.texCoords.u = self->uvs[VERTEX_X1]; quad->bl.texCoords.v = self->uvs[VERTEX_Y1]; quad->tl.texCoords.u = self->uvs[VERTEX_X2]; quad->tl.texCoords.v = self->uvs[VERTEX_Y2]; quad->tr.texCoords.u = self->uvs[VERTEX_X3]; quad->tr.texCoords.v = self->uvs[VERTEX_Y3]; quad->br.texCoords.u = self->uvs[VERTEX_X4]; quad->br.texCoords.v = self->uvs[VERTEX_Y4]; }
39.096
126
0.683855
davidyuan
7346fb41b297d5a0520770ad4d0fcc0e746e143e
5,897
cpp
C++
corelib/src/OdometryICP.cpp
redater/PAM-BATR
3fc8f95972ec13963a53c5448921b59df80a8c8b
[ "BSD-3-Clause" ]
1
2017-05-25T20:41:33.000Z
2017-05-25T20:41:33.000Z
corelib/src/OdometryICP.cpp
redater/PAM-BATR
3fc8f95972ec13963a53c5448921b59df80a8c8b
[ "BSD-3-Clause" ]
null
null
null
corelib/src/OdometryICP.cpp
redater/PAM-BATR
3fc8f95972ec13963a53c5448921b59df80a8c8b
[ "BSD-3-Clause" ]
null
null
null
/* Copyright (c) 2010-2014, Mathieu Labbe - IntRoLab - Universite de Sherbrooke All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of the Universite de Sherbrooke nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "rtabmap/core/Odometry.h" #include "rtabmap/core/util3d.h" #include "rtabmap/core/OdometryInfo.h" #include "rtabmap/utilite/ULogger.h" #include "rtabmap/utilite/UTimer.h" namespace rtabmap { OdometryICP::OdometryICP(int decimation, float voxelSize, int samples, float maxCorrespondenceDistance, int maxIterations, float correspondenceRatio, bool pointToPlane, const ParametersMap & odometryParameter) : Odometry(odometryParameter), _decimation(decimation), _voxelSize(voxelSize), _samples(samples), _maxCorrespondenceDistance(maxCorrespondenceDistance), _maxIterations(maxIterations), _correspondenceRatio(correspondenceRatio), _pointToPlane(pointToPlane), _previousCloudNormal(new pcl::PointCloud<pcl::PointNormal>), _previousCloud(new pcl::PointCloud<pcl::PointXYZ>) { } void OdometryICP::reset(const Transform & initialPose) { Odometry::reset(initialPose); _previousCloudNormal.reset(new pcl::PointCloud<pcl::PointNormal>); _previousCloud.reset(new pcl::PointCloud<pcl::PointXYZ>); } // return not null transform if odometry is correctly computed Transform OdometryICP::computeTransform(const SensorData & data, OdometryInfo * info) { UTimer timer; Transform output; bool hasConverged = false; double variance = 0; unsigned int minPoints = 100; if(!data.depth().empty()) { if(data.depth().type() == CV_8UC1) { UERROR("ICP 3D cannot be done on stereo images!"); return output; } pcl::PointCloud<pcl::PointXYZ>::Ptr newCloudXYZ = util3d::getICPReadyCloud( data.depth(), data.fx(), data.fy(), data.cx(), data.cy(), _decimation, this->getMaxDepth(), _voxelSize, _samples, data.localTransform()); if(_pointToPlane) { pcl::PointCloud<pcl::PointNormal>::Ptr newCloud = util3d::computeNormals(newCloudXYZ); std::vector<int> indices; newCloud = util3d::removeNaNNormalsFromPointCloud<pcl::PointNormal>(newCloud); if(newCloudXYZ->size() != newCloud->size()) { UWARN("removed nan normals..."); } if(_previousCloudNormal->size() > minPoints && newCloud->size() > minPoints) { int correspondences = 0; Transform transform = util3d::icpPointToPlane(newCloud, _previousCloudNormal, _maxCorrespondenceDistance, _maxIterations, &hasConverged, &variance, &correspondences); // verify if there are enough correspondences float correspondencesRatio = float(correspondences)/float(_previousCloudNormal->size()>newCloud->size()?_previousCloudNormal->size():newCloud->size()); if(!transform.isNull() && hasConverged && correspondencesRatio >= _correspondenceRatio) { output = transform; _previousCloudNormal = newCloud; } else { UWARN("Transform not valid (hasConverged=%s variance = %f)", hasConverged?"true":"false", variance); } } else if(newCloud->size() > minPoints) { output.setIdentity(); _previousCloudNormal = newCloud; } } else { //point to point if(_previousCloud->size() > minPoints && newCloudXYZ->size() > minPoints) { int correspondences = 0; Transform transform = util3d::icp(newCloudXYZ, _previousCloud, _maxCorrespondenceDistance, _maxIterations, &hasConverged, &variance, &correspondences); // verify if there are enough correspondences float correspondencesRatio = float(correspondences)/float(_previousCloud->size()>newCloudXYZ->size()?_previousCloud->size():newCloudXYZ->size()); if(!transform.isNull() && hasConverged && correspondencesRatio >= _correspondenceRatio) { output = transform; _previousCloud = newCloudXYZ; } else { UWARN("Transform not valid (hasConverged=%s variance = %f)", hasConverged?"true":"false", variance); } } else if(newCloudXYZ->size() > minPoints) { output.setIdentity(); _previousCloud = newCloudXYZ; } } } else { UERROR("Depth is empty?!?"); } if(info) { info->variance = variance; } UINFO("Odom update time = %fs hasConverged=%s variance=%f cloud=%d", timer.elapsed(), hasConverged?"true":"false", variance, (int)(_pointToPlane?_previousCloudNormal->size():_previousCloud->size())); return output; } } // namespace rtabmap
30.713542
155
0.716636
redater
734850c46ab274fe820c5910550cbfbf2dd11176
4,082
hpp
C++
source/pattern/Map.hpp
Superone77/PMPP-Compositional-GPU
e1f5a24563572604880a73db55757363cd3c5b3c
[ "CECILL-B" ]
1
2022-02-13T13:14:08.000Z
2022-02-13T13:14:08.000Z
source/pattern/Map.hpp
Superone77/PMPP-Compositional-GPU
e1f5a24563572604880a73db55757363cd3c5b3c
[ "CECILL-B" ]
null
null
null
source/pattern/Map.hpp
Superone77/PMPP-Compositional-GPU
e1f5a24563572604880a73db55757363cd3c5b3c
[ "CECILL-B" ]
null
null
null
#pragma once #include "../Commons.hpp" #include "../interfaces/PatternInterface.hpp" #include "../interfaces/ThreadSafeQueue.hpp" #include "../interfaces/Executor.hpp" #include "../interfaces/LoadBalancer.hpp" #include <cassert> #include <future> #include <thread> #include <vector> template<typename T_input, typename T_output> class Map : public PatternInterface<FutVec<T_input>, FutVec<T_output>> { std::vector<std::thread> threads; Executor<T_input, T_output> executor; TSQueue<std::tuple<std::future<T_input>, std::promise<T_output>>> inner_queue; friend class LoadBalancingCapabilities<Map>; void PerformTask() { while (!this->dying) { if (!doWork()) { if (this->dying) { break; } if (this->load_balancer) { if (!this->load_balancer->provideWork()) { std::this_thread::yield(); } } else { std::this_thread::yield(); } continue; } } } bool doWork() { std::tuple<std::future<T_input>, std::promise<T_output>> data; auto success = this->inner_queue.try_pop(data); if (!success) return false; auto future = std::move(std::get<0>(data)); auto promise = std::move(std::get<1>(data)); if (this->load_balancer) if (future.wait_for(std::chrono::seconds(0)) != std::future_status::ready) { this->inner_queue.push(std::move(std::tuple<std::future<T_input>, std::promise<T_output>>(std::move(future), std::move(promise)))); return false; } executor.Compute(std::move(future), std::move(promise)); return true; } Map(PatIntPtr<T_input, T_output> task, size_t thread_count) : threads(thread_count), executor(task, thread_count) { } protected: void InternallyCompute(std::future<FutVec<T_input>> futValue, std::promise<FutVec<T_output>> prom) override { FutVec<T_input> value = futValue.get(); size_t count = value.size(); assert(count > 0); FutVec<T_output> results(count); for (size_t i = 0; i < count; i++) { std::promise<T_output> promise; std::future<T_output> fut = promise.get_future(); results[i] = std::move(fut); std::future<T_input> single_future = std::move(value[i]); inner_queue.push(std::make_tuple(std::move(single_future), std::move(promise))); } prom.set_value(std::move(results)); } public: static PatIntPtr<FutVec<T_input>, FutVec<T_output>> create(PatIntPtr<T_input, T_output> task, size_t thread_count, std::shared_ptr<LoadBalancer> load_balancer = nullptr) { assert(thread_count > 0); auto map = new Map(task, thread_count); auto s_ptr = std::shared_ptr<PatternInterface<FutVec<T_input>, FutVec<T_output>>>(map); s_ptr->self = s_ptr; s_ptr->load_balancer = load_balancer; return s_ptr; } Map(Map& other) = delete; Map(Map&& other) = delete; Map& operator=(const Map& other) = delete; Map& operator=(Map&& other) = delete; PatIntPtr<FutVec<T_input>, FutVec<T_output>> create_copy() override { this->assertNoInit(); return create(executor.GetTask(), threads.size(), this->load_balancer); } bool doTask() override { return doWork(); } size_t ThreadCount() const noexcept override { return threads.size() * executor.ThreadCount(); } std::string Name() const override { return std::string("map(") + std::to_string(threads.size()) + std::string(",") + executor.Name() + std::string(")"); } void Init() override { if (!this->initialized) { this->dying = false; if (this->load_balancer) LoadBalancer::registerLoadBalancer(this->self, this->load_balancer); executor.Init(); for (size_t i = 0; i < threads.size(); i++) { threads[i] = std::thread(&Map::PerformTask, this); } this->initialized = true; } } void Dispose() override { if (this->initialized) { this->dying = true; if (this->load_balancer) LoadBalancer::deregisterLoadBalancer(this->self, this->load_balancer); for (std::thread& thread : threads) { if (thread.joinable()) { thread.join(); } } executor.Dispose(); this->initialized = false; } } ~Map() { Map<T_input, T_output>::Dispose(); } };
23.45977
172
0.66291
Superone77
734a4641678a890b978562fb5146e6b52dbbfe72
1,505
cpp
C++
apps/scheduler/client/assfire/scheduler/RemoteWaybillSchedulingAlgorithm.cpp
Eaglegor/assfire-suite
6c8140e848932b6ce22b6addd07a93abba652c01
[ "MIT" ]
null
null
null
apps/scheduler/client/assfire/scheduler/RemoteWaybillSchedulingAlgorithm.cpp
Eaglegor/assfire-suite
6c8140e848932b6ce22b6addd07a93abba652c01
[ "MIT" ]
null
null
null
apps/scheduler/client/assfire/scheduler/RemoteWaybillSchedulingAlgorithm.cpp
Eaglegor/assfire-suite
6c8140e848932b6ce22b6addd07a93abba652c01
[ "MIT" ]
null
null
null
#include "RemoteWaybillSchedulingAlgorithm.hpp" #include "assfire/api/v1/scheduler/translators/Translators.hpp" #include "assfire/api/v1/router/translators/Translators.hpp" using namespace assfire::scheduler; using namespace assfire::api::v1::scheduler; RemoteWaybillSchedulingAlgorithm::RemoteWaybillSchedulingAlgorithm(const SchedulerGrpcConnector &connector, WaybillSchedulingAlgorithmType algorithm_type, const WaybillSchedulerSettings& settings, const router::RoutingProfile& routing_profile) : connector(connector), algorithm_type(algorithm_type), settings(settings), routing_profile(routing_profile) { } void RemoteWaybillSchedulingAlgorithm::scheduleWaybill(Waybill &waybill) const { ScheduleWaybillRequest request; request.set_algorithm_type(WaybillSchedulingAlgorithmTypeTranslator::toProto(algorithm_type)); request.mutable_waybill()->CopyFrom(WaybillTranslator::toProto(waybill)); request.mutable_routing_profile()->CopyFrom(RoutingProfileTranslator::toProto(routing_profile)); request.mutable_settings()->CopyFrom(WaybillSchedulerSettingsTranslator::toProto(settings)); ScheduleWaybillResponse response = connector.scheduleWaybill(request); if(response.status().code() != ScheduleWaybillResponseStatus::SCHEDULE_WAYBILL_RESPONSE_STATUS_CODE_OK) { throw std::runtime_error(response.status().message()); } waybill = WaybillTranslator::fromProto(response.waybill()); }
51.896552
196
0.780066
Eaglegor
734a5413924f3b88dfeea748e2162f43cbbf7a73
503
cpp
C++
3-Behavioral/14.Command/src/Command/Factory/DivideFactory.cpp
gfa99/gof_design_patterns
a33ee7f344f8e382bb9fc676b77b22a5a123bca0
[ "Apache-2.0" ]
21
2017-11-08T11:32:48.000Z
2021-03-29T08:58:04.000Z
3-Behavioral/14.Command/src/Command/Factory/DivideFactory.cpp
gfa99/gof_design_patterns
a33ee7f344f8e382bb9fc676b77b22a5a123bca0
[ "Apache-2.0" ]
null
null
null
3-Behavioral/14.Command/src/Command/Factory/DivideFactory.cpp
gfa99/gof_design_patterns
a33ee7f344f8e382bb9fc676b77b22a5a123bca0
[ "Apache-2.0" ]
8
2017-11-26T13:57:50.000Z
2021-08-23T06:52:57.000Z
#include "Command/Factory/DivideFactory.h" namespace GoF { namespace Command { namespace Factory { Command * DivideFactory::createCommand(double _operand, double _operator) { return new Divide(this->createReceiver(_operand, _operator)); } Receiver * DivideFactory::createReceiver(double _operand, double _operator) { return new Division(_operand, _operator); } } } }
20.958333
87
0.574553
gfa99
734bf82529614ce4230de06837fae7e75d94dad3
5,460
cpp
C++
src/extralibs/sdl_draw/src/draw_line.cpp
SamuraiCrow/protrekkr
4bf6f52635ac722e7a9370dacfbc8807a4043c4a
[ "BSD-3-Clause" ]
22
2018-02-13T12:29:23.000Z
2022-02-21T16:18:15.000Z
src/extralibs/sdl_draw/src/draw_line.cpp
PaulBatchelor/protrekkr
0f93032913bf111b0721901691dd351a165c3d61
[ "BSD-2-Clause" ]
5
2018-02-13T13:43:55.000Z
2021-12-14T07:55:07.000Z
src/extralibs/sdl_draw/src/draw_line.cpp
hitchhikr/protrekkr
d14b83f1a2570ea31deced97972839b621710c9e
[ "BSD-3-Clause" ]
5
2019-05-02T13:07:28.000Z
2022-01-07T17:51:37.000Z
/*! \file Draw_Line.c \author Mario Palomo <[email protected]> \author Jose M. de la Huerga Fern�ndez \author Pepe Gonz�lez Mora \date 05-2002 Based in Kenny Hoff sourcer. */ /* This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #if defined(__GCC__) #include "../include/sdl_draw.h" #else #include "../../include/sdl_draw.h" #endif #define SDL_DRAW_PUTPIXEL_BPP(A, B, C, D) *(A(B(Uint8*)D))=C; #if SDL_DRAW_BPP == 1 #define SDL_DRAW_PUTPIXEL(D) SDL_DRAW_PUTPIXEL_BPP(0+,0+,color,D) #elif SDL_DRAW_BPP == 4 #define SDL_DRAW_PUTPIXEL(D) SDL_DRAW_PUTPIXEL_BPP((Uint32*),0+,color,D) #endif /*SDL_DRAW_BPP*/ void STDCALL Draw_Line(SDL_Surface *super, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Uint32 color) { register Sint16 dx; register Sint16 dy; Sint16 fbXincr, fbYincr, fbXYincr; Sint16 dPr, dPru, P; Sint16 pixx = super->format->BytesPerPixel; Sint16 pixy = super->pitch; Uint8 *AfbAddr, *BfbAddr; /* Clip line and test if we have to draw only if we need to do it */ /* It is in next version. #ifdef SDL_DRAW_CLIP if (!(clipLine(super, &x1, &y1, &x2, &y2))) { return; } #endif */ /* Store the fremebuffer Endpoint-Addresses (A and B) */ AfbAddr = ((Uint8*)super->pixels) + pixx * (int)x1 + pixy * (int)y1; BfbAddr = ((Uint8*)super->pixels) + pixx * (int)x2 + pixy * (int)y2; /* Lock surface */ if (SDL_MUSTLOCK(super)) { if (SDL_LockSurface(super) < 0) { return; } } fbXincr=pixx; if ( (dx=x2-x1) >= 0 ) goto AFTERNEGX; dx = -dx; fbXincr = -pixx; AFTERNEGX: fbYincr=pixy; //debug if ( (dy=y2-y1) >= 0) goto AFTERNEGY; fbYincr = -pixy; dy = -dy; AFTERNEGY: fbXYincr = fbXincr+fbYincr; if (dy > dx) goto YisIndependent; /*Check if X or Y is independent vaiable */ /*XisIndependent;*/ dPr = dy+dy; P = -dx; dPru = P+P; dy = dx>>1; XLOOP: SDL_DRAW_PUTPIXEL(AfbAddr); /*Plot the pixel from end of pointer one*/ SDL_DRAW_PUTPIXEL(BfbAddr); /*Plot the pixel from end of pointer two*/ if ((P+=dPr) > 0) goto RightAndUp; /*Up:*/ AfbAddr+=fbXincr; BfbAddr-=fbXincr; if ((dy=dy-1) > 0) goto XLOOP; SDL_DRAW_PUTPIXEL(AfbAddr) /*(Fix midpoint problem) Plot last PT from end pointer one*/ if (( dx & 1) == 0) goto END_P; SDL_DRAW_PUTPIXEL(BfbAddr); /*Plot last PT from end of pointer two if independent is odd*/ goto END_P; RightAndUp: AfbAddr+=fbXYincr; /*Advance to next point from end of pointer one*/ BfbAddr-=fbXYincr; /*Advance to next point from end of pointer two*/ P+=dPru; if ((dy=dy-1) > 0) goto XLOOP; SDL_DRAW_PUTPIXEL(AfbAddr); /*(Fix midpoint problem) Plot last PT from end of pointer one*/ if ((dx & 1) == 0) goto END_P; SDL_DRAW_PUTPIXEL(BfbAddr); /*Plot last PT from end of pointer two if indepent is odd*/ goto END_P; YisIndependent: dPr = dx+dx; P = -dy; dPru = P+P; dx = dy >>1; YLOOP: /* PROCESS EACH POINT IN THE LINE ONE AT A TIME (use dX as loop counter) */ SDL_DRAW_PUTPIXEL(AfbAddr); /* PLOT THE PIXEL FROM END A */ SDL_DRAW_PUTPIXEL(BfbAddr); /* PLOT THE PIXEL FROM END B */ if ((P+=dPr) > 0) goto RightAndUp2; /* INCREMENT DECISION, CHECK IF THE PIXEL IS GOING RIGHT AND UP */ /*Up:*/ AfbAddr+=fbYincr; /* ADVANCE TO NEXT POINT FROM END A */ BfbAddr-=fbYincr; /* ADVANCE TO NEXT POINT FROM END B */ if ((dx=dx-1) > 0) goto YLOOP; /* DECREMENT LOOP VARIABLE AND LOOP */ SDL_DRAW_PUTPIXEL(AfbAddr); /* (FIX MIDPOINT PROBLEM) PLOT THE LAST POINT FROM END A */ if ((dy & 1) == 0) goto END_P; /* FINISHED IF INDEPENDENT IS EVEN (ODD # STEPS) */ SDL_DRAW_PUTPIXEL(BfbAddr); /* PLOT LAST PT FROM END B IF INDEPENDENT IS ODD (EVEN # STEPS) */ goto END_P; RightAndUp2: AfbAddr+=fbXYincr; /* ADVANCE TO NEXT POINT FROM END A */ BfbAddr-=fbXYincr; /* ADVANCE TO NEXT POINT FROM END B */ P+=dPru; /* INCREMENT DECISION (for up) */ if ((dx=dx-1) > 0) goto YLOOP; /* DECREMENT LOOP VARIABLE AND LOOP */ SDL_DRAW_PUTPIXEL(AfbAddr); /* (FIX MIDPOINT PROBLEM) PLOT THE LAST POINT FROM END A */ if ((dy & 1) == 0) goto END_P; /* FINISHED IF INDEPENDENT IS EVEN (ODD # STEPS) */ SDL_DRAW_PUTPIXEL(BfbAddr); /* PLOT LAST PT FROM END B IF INDEPENDENT IS ODD (EVEN # STEPS) */ END_P: /* Unlock surface */ if (SDL_MUSTLOCK(super)) { SDL_UnlockSurface(super); } }/*Draw_Line*/ #undef SDL_DRAW_PUTPIXEL #undef SDL_DRAW_PUTPIXEL_BPP
35.225806
119
0.621062
SamuraiCrow
734ce4bd9eaaac6d65d346567b122ea6fce575f4
4,897
cpp
C++
src/goto-diff/goto_diff_base.cpp
DamonLiuTHU/cbmc
67f8c916672347ab05418db45eebbd93885efdec
[ "BSD-4-Clause" ]
null
null
null
src/goto-diff/goto_diff_base.cpp
DamonLiuTHU/cbmc
67f8c916672347ab05418db45eebbd93885efdec
[ "BSD-4-Clause" ]
null
null
null
src/goto-diff/goto_diff_base.cpp
DamonLiuTHU/cbmc
67f8c916672347ab05418db45eebbd93885efdec
[ "BSD-4-Clause" ]
null
null
null
/*******************************************************************\ Module: GOTO-DIFF Base Class Author: Peter Schrammel \*******************************************************************/ /// \file /// GOTO-DIFF Base Class #include "goto_diff.h" #include <util/json_expr.h> #include <util/options.h> #include <goto-programs/goto_model.h> #include <goto-programs/show_properties.h> /// Output diff result void goto_difft::output_functions() const { messaget msg(message_handler); switch(message_handler.get_ui()) { case ui_message_handlert::uit::PLAIN: { msg.result() << "total number of functions: " << total_functions_count << '\n' << messaget::eom; output_function_group("new functions", new_functions, goto_model2); output_function_group( "modified functions", modified_functions, goto_model2); output_function_group( "deleted functions", deleted_functions, goto_model1); msg.result() << messaget::eom; break; } case ui_message_handlert::uit::JSON_UI: { json_objectt json_result; json_result["totalNumberOfFunctions"]= json_stringt(std::to_string(total_functions_count)); convert_function_group_json( json_result["newFunctions"].make_array(), new_functions, goto_model2); convert_function_group_json( json_result["modifiedFunctions"].make_array(), modified_functions, goto_model2); convert_function_group_json( json_result["deletedFunctions"].make_array(), deleted_functions, goto_model1); msg.result() << json_result << messaget::eom; break; } case ui_message_handlert::uit::XML_UI: { msg.error() << "XML output not supported yet" << messaget::eom; } } } /// Output group of functions in plain text format /// \param group_name: the name of the group, e.g. "modified functions" /// \param function_group: set of function ids in the group /// \param goto_model: the goto model void goto_difft::output_function_group( const std::string &group_name, const std::set<irep_idt> &function_group, const goto_modelt &goto_model) const { messaget(message_handler).result() << group_name << ':' << messaget::eom; for(const auto &function_name : function_group) { output_function(function_name, goto_model); } } /// Output function information in plain text format /// \param function_name: the function id /// \param goto_model: the goto model void goto_difft::output_function( const irep_idt &function_name, const goto_modelt &goto_model) const { messaget msg(message_handler); namespacet ns(goto_model.symbol_table); const symbolt &symbol = ns.lookup(function_name); msg.result() << " " << symbol.location.get_file() << ": " << function_name; if(options.get_bool_option("show-properties")) { const auto goto_function_it = goto_model.goto_functions.function_map.find(function_name); CHECK_RETURN( goto_function_it != goto_model.goto_functions.function_map.end()); const goto_programt &goto_program = goto_function_it->second.body; for(const auto &ins : goto_program.instructions) { if(!ins.is_assert()) continue; const source_locationt &source_location = ins.source_location; irep_idt property_id = source_location.get_property_id(); msg.result() << "\n " << property_id; } } msg.result() << messaget::eom; } /// Convert a function group to JSON /// \param result: the JSON array to be populated /// \param function_group: set of function ids in the group /// \param goto_model: the goto model void goto_difft::convert_function_group_json( json_arrayt &result, const std::set<irep_idt> &function_group, const goto_modelt &goto_model) const { for(const auto &function_name : function_group) { convert_function_json( result.push_back(jsont()).make_object(), function_name, goto_model); } } /// Convert function information to JSON /// \param result: the JSON object to be populated /// \param function_name: the function id /// \param goto_model: the goto model void goto_difft::convert_function_json( json_objectt &result, const irep_idt &function_name, const goto_modelt &goto_model) const { namespacet ns(goto_model.symbol_table); const symbolt &symbol = ns.lookup(function_name); result["name"] = json_stringt(function_name); result["sourceLocation"] = json(symbol.location); if(options.get_bool_option("show-properties")) { const auto goto_function_it = goto_model.goto_functions.function_map.find(function_name); CHECK_RETURN( goto_function_it != goto_model.goto_functions.function_map.end()); const goto_programt &goto_program = goto_function_it->second.body; convert_properties_json( result["properties"].make_array(), ns, function_name, goto_program); } }
30.798742
78
0.687768
DamonLiuTHU
734eb180fcc67783c5a416b81f6120750a9dc422
12,088
cpp
C++
win32/VandaEngine1/GraphicsEngine/ActionsAPI.cpp
ehsankamrani/vandaengine
854430e41db6df1f4fcad9c19718fd8dfcc2c3cb
[ "MIT" ]
12
2021-06-22T11:28:12.000Z
2022-03-21T00:56:33.000Z
win32/VandaEngine1/GraphicsEngine/ActionsAPI.cpp
ehsankamrani/vandaengine
854430e41db6df1f4fcad9c19718fd8dfcc2c3cb
[ "MIT" ]
null
null
null
win32/VandaEngine1/GraphicsEngine/ActionsAPI.cpp
ehsankamrani/vandaengine
854430e41db6df1f4fcad9c19718fd8dfcc2c3cb
[ "MIT" ]
1
2018-10-05T08:17:29.000Z
2018-10-05T08:17:29.000Z
/// ActionsAPI.cpp /// /// Copyright 1997-2007 by David K. McAllister /// http://www.ParticleSystems.org /// /// This file implements the action API calls by creating action class instances, /// which are either executed or added to an action list. #include "stdafx.h" #include "pAPI.h" #include "PInternalState.h" namespace PAPI { void PContextActions_t::Avoid(const float magnitude, const float epsilon, const float look_ahead, const pDomain &dom) { PAAvoid *A = new PAAvoid; A->position = dom.copy(); A->magnitude = magnitude; A->epsilon = epsilon; A->look_ahead = look_ahead; A->SetKillsParticles(false); A->SetDoNotSegment(false); PS->SendAction(A); } void PContextActions_t::Bounce(const float friction, const float resilience, const float cutoff, const pDomain &dom) { PABounce *A = new PABounce; A->position = dom.copy(); A->oneMinusFriction = 1.0f - friction; A->resilience = resilience; A->cutoffSqr = fsqr(cutoff); A->SetKillsParticles(false); A->SetDoNotSegment(false); PS->SendAction(A); } void PContextActions_t::Callback(P_PARTICLE_CALLBACK callback, puint64 data) { PACallback *A = new PACallback; A->callback = callback; A->Data = data; A->SetKillsParticles(false); A->SetDoNotSegment(false); PS->SendAction(A); } void PContextActions_t::CopyVertexB(const bool copy_pos, const bool copy_vel) { PACopyVertexB *A = new PACopyVertexB; A->copy_pos = copy_pos; A->copy_vel = copy_vel; A->SetKillsParticles(false); A->SetDoNotSegment(false); PS->SendAction(A); } void PContextActions_t::Damping(const pVec &damping, const float vlow, const float vhigh) { PADamping *A = new PADamping; A->damping = damping; A->vlowSqr = fsqr(vlow); A->vhighSqr = fsqr(vhigh); A->SetKillsParticles(false); A->SetDoNotSegment(false); PS->SendAction(A); } void PContextActions_t::RotDamping(const pVec &damping, const float vlow, const float vhigh) { PARotDamping *A = new PARotDamping; A->damping = damping; A->vlowSqr = fsqr(vlow); A->vhighSqr = fsqr(vhigh); A->SetKillsParticles(false); A->SetDoNotSegment(false); PS->SendAction(A); } void PContextActions_t::Explosion(const pVec &center, const float radius, const float magnitude, const float stdev, const float epsilon) { PAExplosion *A = new PAExplosion; A->center = center; A->radius = radius; A->magnitude = magnitude; A->stdev = stdev; A->epsilon = epsilon; if(A->epsilon < 0.0f) A->epsilon = P_EPS; A->SetKillsParticles(false); A->SetDoNotSegment(false); PS->SendAction(A); } void PContextActions_t::Follow(const float magnitude, const float epsilon, const float max_radius) { PAFollow *A = new PAFollow; A->magnitude = magnitude; A->epsilon = epsilon; A->max_radius = max_radius; A->SetKillsParticles(false); A->SetDoNotSegment(true); PS->SendAction(A); } void PContextActions_t::Gravitate(const float magnitude, const float epsilon, const float max_radius) { PAGravitate *A = new PAGravitate; A->magnitude = magnitude; A->epsilon = epsilon; A->max_radius = max_radius; A->SetKillsParticles(false); A->SetDoNotSegment(true); PS->SendAction(A); } void PContextActions_t::Gravity(const pVec &dir) { PAGravity *A = new PAGravity; A->direction = dir; A->SetKillsParticles(false); A->SetDoNotSegment(false); PS->SendAction(A); } void PContextActions_t::Jet(const pDomain &dom, const pDomain &accel) { PAJet *A = new PAJet; A->dom = dom.copy(); A->acc = accel.copy(); A->SetKillsParticles(false); A->SetDoNotSegment(false); PS->SendAction(A); } void PContextActions_t::KillOld(const float age_limit, const bool kill_less_than) { PAKillOld *A = new PAKillOld; A->age_limit = age_limit; A->kill_less_than = kill_less_than; A->SetKillsParticles(true); A->SetDoNotSegment(false); PS->SendAction(A); } void PContextActions_t::MatchVelocity(const float magnitude, const float epsilon, const float max_radius) { PAMatchVelocity *A = new PAMatchVelocity; A->magnitude = magnitude; A->epsilon = epsilon; A->max_radius = max_radius; A->SetKillsParticles(false); A->SetDoNotSegment(true); PS->SendAction(A); } void PContextActions_t::MatchRotVelocity(const float magnitude, const float epsilon, const float max_radius) { PAMatchRotVelocity *A = new PAMatchRotVelocity; A->magnitude = magnitude; A->epsilon = epsilon; A->max_radius = max_radius; A->SetKillsParticles(false); A->SetDoNotSegment(true); PS->SendAction(A); } void PContextActions_t::Move(const bool move_velocity, const bool move_rotational_velocity) { PAMove *A = new PAMove; A->move_velocity = move_velocity; A->move_rotational_velocity = move_rotational_velocity; A->SetKillsParticles(false); A->SetDoNotSegment(false); PS->SendAction(A); } void PContextActions_t::OrbitLine(const pVec &p, const pVec &axis, const float magnitude, const float epsilon, const float max_radius) { PAOrbitLine *A = new PAOrbitLine; A->p = p; A->axis = axis; A->axis.normalize(); A->magnitude = magnitude; A->epsilon = epsilon; A->max_radius = max_radius; A->SetKillsParticles(false); A->SetDoNotSegment(false); PS->SendAction(A); } void PContextActions_t::OrbitPoint(const pVec &center, const float magnitude, const float epsilon, const float max_radius) { PAOrbitPoint *A = new PAOrbitPoint; A->center = center; A->magnitude = magnitude; A->epsilon = epsilon; A->max_radius = max_radius; A->SetKillsParticles(false); A->SetDoNotSegment(false); PS->SendAction(A); } void PContextActions_t::RandomAccel(const pDomain &dom) { PARandomAccel *A = new PARandomAccel; A->gen_acc = dom.copy(); A->SetKillsParticles(false); A->SetDoNotSegment(false); PS->SendAction(A); } void PContextActions_t::RandomDisplace(const pDomain &dom) { PARandomDisplace *A = new PARandomDisplace; A->gen_disp = dom.copy(); A->SetKillsParticles(false); A->SetDoNotSegment(false); PS->SendAction(A); } void PContextActions_t::RandomVelocity(const pDomain &dom) { PARandomVelocity *A = new PARandomVelocity; A->gen_vel = dom.copy(); A->SetKillsParticles(false); A->SetDoNotSegment(false); PS->SendAction(A); } void PContextActions_t::RandomRotVelocity(const pDomain &dom) { PARandomRotVelocity *A = new PARandomRotVelocity; A->gen_vel = dom.copy(); A->SetKillsParticles(false); A->SetDoNotSegment(false); PS->SendAction(A); } void PContextActions_t::Restore(const float time_left, const bool vel, const bool rvel) { PARestore *A = new PARestore; A->time_left = time_left; A->restore_velocity = vel; A->restore_rvelocity = rvel; A->SetKillsParticles(false); A->SetDoNotSegment(false); PS->SendAction(A); } void PContextActions_t::Sink(const bool kill_inside, const pDomain &dom) { PASink *A = new PASink; A->position = dom.copy(); A->kill_inside = kill_inside; A->SetKillsParticles(true); A->SetDoNotSegment(false); PS->SendAction(A); } void PContextActions_t::SinkVelocity(const bool kill_inside, const pDomain &dom) { PASinkVelocity *A = new PASinkVelocity; A->velocity = dom.copy(); A->kill_inside = kill_inside; A->SetKillsParticles(true); A->SetDoNotSegment(false); PS->SendAction(A); } void PContextActions_t::Sort(const pVec &eye, const pVec &look, const bool front_to_back, const bool clamp_negative) { PASort *A = new PASort; A->Eye = eye; A->Look= look; A->front_to_back = front_to_back; A->clamp_negative = clamp_negative; A->SetKillsParticles(false); A->SetDoNotSegment(true); // WARNING: Particles aren't a function of other particles, but since it can screw up the working set thing, I'm setting it true. PS->SendAction(A); } void PContextActions_t::Source(const float particle_rate, const pDomain &dom) { PASource *A = new PASource; A->position = dom.copy(); A->particle_rate = particle_rate; A->SrcSt.set(PS->SrcSt); A->SetKillsParticles(false); A->SetDoNotSegment(true); // WARNING: Particles aren't a function of other particles, but does affect the working sets optimizations PS->SendAction(A); } void PContextActions_t::SpeedLimit(const float min_speed, const float max_speed) { PASpeedLimit *A = new PASpeedLimit; A->min_speed = min_speed; A->max_speed = max_speed; A->SetKillsParticles(false); A->SetDoNotSegment(false); PS->SendAction(A); } void PContextActions_t::TargetColor(const pVec &color, const float alpha, const float scale) { PATargetColor *A = new PATargetColor; A->color = color; A->alpha = alpha; A->scale = scale; A->SetKillsParticles(false); A->SetDoNotSegment(false); PS->SendAction(A); } void PContextActions_t::TargetSize(const pVec &size, const pVec &scale) { PATargetSize *A = new PATargetSize; A->size = size; A->scale = scale; A->SetKillsParticles(false); A->SetDoNotSegment(false); PS->SendAction(A); } void PContextActions_t::TargetVelocity(const pVec &vel, const float scale) { PATargetVelocity *A = new PATargetVelocity; A->velocity = vel; A->scale = scale; A->SetKillsParticles(false); A->SetDoNotSegment(false); PS->SendAction(A); } void PContextActions_t::TargetRotVelocity(const pVec &vel, const float scale) { PATargetRotVelocity *A = new PATargetRotVelocity; A->velocity = vel; A->scale = scale; A->SetKillsParticles(false); A->SetDoNotSegment(false); PS->SendAction(A); } // If in immediate mode, quickly add a vertex. // If building an action list, call Source(). void PContextActions_t::Vertex(const pVec &pos, const puint64 data) { if(PS->in_new_list) { Source(1, PDPoint(pos)); return; } // Immediate mode. Quickly add the vertex. Particle_t P; P.pos = pos; P.posB = PS->SrcSt.vertexB_tracks ? pos : PS->SrcSt.VertexB->Generate(); P.size = PS->SrcSt.Size->Generate(); P.up = PS->SrcSt.Up->Generate(); P.vel = PS->SrcSt.Vel->Generate(); P.rvel = PS->SrcSt.RotVel->Generate(); P.color = PS->SrcSt.Color->Generate(); P.alpha = PS->SrcSt.Alpha->Generate().x(); P.age = PS->SrcSt.Age + pNRandf(PS->SrcSt.AgeSigma); P.mass = PS->SrcSt.Mass; P.data = data; // Note that we pass in the particle user data of the Vertex call, even if it's the default value. // We don't pass the PS->SrcSt data. Note that this creates an inconsistency if building an action list. PS->PGroups[PS->pgroup_id].Add(P); } void PContextActions_t::Vortex( const pVec &center, ///< tip of the vortex const pVec &axis, ///< the ray along the center of the vortex const float tightnessExponent, ///< like a Phong exponent that gives a curve to the vortex silhouette; 1.8 is good. const float max_radius, ///< defines the infinite cylinder of influence of this action. No particle further than max_radius from the axis is affected. const float inSpeed, ///< inward acceleration of particles outside the vortex const float upSpeed, ///< vertical acceleration of particles inside the vortex. Can be negative to counteract gravity. const float aroundSpeed) ///< acceleration around vortex of particles inside the vortex { PAVortex *A = new PAVortex; A->tip = center; A->axis = axis; A->tightnessExponent = tightnessExponent; A->max_radius = max_radius; A->inSpeed = inSpeed; A->upSpeed = upSpeed; A->aroundSpeed = aroundSpeed; A->SetKillsParticles(false); A->SetDoNotSegment(false); PS->SendAction(A); } };
24.51927
162
0.669838
ehsankamrani
73572cf8f43a6a762ad86c09396af4ce7b8ed709
29,831
cpp
C++
src/signalrclient/connection_impl.cpp
tonerdo/SignalR-Client-Cpp
ea4ad5b0a50a7483aec4b4dcfd316c635ccdfdfd
[ "MIT" ]
null
null
null
src/signalrclient/connection_impl.cpp
tonerdo/SignalR-Client-Cpp
ea4ad5b0a50a7483aec4b4dcfd316c635ccdfdfd
[ "MIT" ]
null
null
null
src/signalrclient/connection_impl.cpp
tonerdo/SignalR-Client-Cpp
ea4ad5b0a50a7483aec4b4dcfd316c635ccdfdfd
[ "MIT" ]
null
null
null
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. #include "stdafx.h" #include <thread> #include <algorithm> #include "constants.h" #include "connection_impl.h" #include "negotiate.h" #include "url_builder.h" #include "trace_log_writer.h" #include "signalrclient/signalr_exception.h" #include "default_http_client.h" #include "case_insensitive_comparison_utils.h" #include "completion_event.h" #include <assert.h> #include "signalrclient/websocket_client.h" #include "default_websocket_client.h" namespace signalr { std::shared_ptr<connection_impl> connection_impl::create(const std::string& url, trace_level trace_level, const std::shared_ptr<log_writer>& log_writer) { return connection_impl::create(url, trace_level, log_writer, nullptr, nullptr, false); } std::shared_ptr<connection_impl> connection_impl::create(const std::string& url, trace_level trace_level, const std::shared_ptr<log_writer>& log_writer, std::shared_ptr<http_client> http_client, std::function<std::shared_ptr<websocket_client>(const signalr_client_config&)> websocket_factory, const bool skip_negotiation) { return std::shared_ptr<connection_impl>(new connection_impl(url, trace_level, log_writer ? log_writer : std::make_shared<trace_log_writer>(), http_client, websocket_factory, skip_negotiation)); } connection_impl::connection_impl(const std::string& url, trace_level trace_level, const std::shared_ptr<log_writer>& log_writer, std::unique_ptr<http_client> http_client, std::unique_ptr<transport_factory> transport_factory, const bool skip_negotiation) : m_base_url(url), m_connection_state(connection_state::disconnected), m_logger(log_writer, trace_level), m_transport(nullptr), m_transport_factory(std::move(transport_factory)), m_skip_negotiation(skip_negotiation), m_message_received([](const std::string&) noexcept {}), m_disconnected([]() noexcept {}) { if (http_client != nullptr) { m_http_client = std::move(http_client); } else { #ifdef USE_CPPRESTSDK m_http_client = std::unique_ptr<class http_client>(new default_http_client()); #endif } } connection_impl::connection_impl(const std::string& url, trace_level trace_level, const std::shared_ptr<log_writer>& log_writer, std::shared_ptr<http_client> http_client, std::function<std::shared_ptr<websocket_client>(const signalr_client_config&)> websocket_factory, const bool skip_negotiation) : m_base_url(url), m_connection_state(connection_state::disconnected), m_logger(log_writer, trace_level), m_transport(nullptr), m_skip_negotiation(skip_negotiation), m_message_received([](const std::string&) noexcept {}), m_disconnected([]() noexcept {}) { if (http_client != nullptr) { m_http_client = std::move(http_client); } else { #ifdef USE_CPPRESTSDK m_http_client = std::unique_ptr<class http_client>(new default_http_client()); #endif } if (websocket_factory == nullptr) { #ifdef USE_CPPRESTSDK websocket_factory = [](const signalr_client_config& signalr_client_config) { return std::make_shared<default_websocket_client>(signalr_client_config); }; #endif } m_transport_factory = std::unique_ptr<transport_factory>(new transport_factory(m_http_client, websocket_factory)); } connection_impl::~connection_impl() { try { // Signaling the event is safe here. We are in the dtor so noone is using this instance. There might be some // outstanding threads that hold on to the connection via a weak pointer but they won't be able to acquire // the instance since it is being destroyed. Note that the event may actually be in non-signaled state here. m_start_completed_event.cancel(); completion_event completion; auto logger = m_logger; shutdown([completion, logger](std::exception_ptr exception) mutable { if (exception != nullptr) { // TODO: Log? try { std::rethrow_exception(exception); } catch (const std::exception& e) { logger.log( trace_level::errors, std::string("shutdown threw an exception: ") .append(e.what())); } catch (...) { logger.log( trace_level::errors, std::string("shutdown threw an unknown exception.")); } } // make sure this is last as it will unblock the destructor completion.set(); }); completion.get(); } catch (...) // must not throw from destructors { } m_transport = nullptr; change_state(connection_state::disconnected); } void connection_impl::start(std::function<void(std::exception_ptr)> callback) noexcept { { std::lock_guard<std::mutex> lock(m_stop_lock); if (!change_state(connection_state::disconnected, connection_state::connecting)) { callback(std::make_exception_ptr(signalr_exception("cannot start a connection that is not in the disconnected state"))); return; } // there should not be any active transport at this point assert(!m_transport); m_disconnect_cts = std::make_shared<cancellation_token>(); m_start_completed_event.reset(); m_connection_id = ""; } start_negotiate(m_base_url, 0, callback); } void connection_impl::start_negotiate(const std::string& url, int redirect_count, std::function<void(std::exception_ptr)> callback) { if (redirect_count >= MAX_NEGOTIATE_REDIRECTS) { change_state(connection_state::disconnected); m_start_completed_event.cancel(); callback(std::make_exception_ptr(signalr_exception("Negotiate redirection limit exceeded."))); return; } std::weak_ptr<connection_impl> weak_connection = shared_from_this(); const auto& token = m_disconnect_cts; const auto transport_started = [weak_connection, callback, token](std::shared_ptr<transport> transport, std::exception_ptr exception) { auto connection = weak_connection.lock(); if (!connection) { callback(std::make_exception_ptr(signalr_exception("connection no longer exists"))); return; } try { if (exception != nullptr) { std::rethrow_exception(exception); } token->throw_if_cancellation_requested(); } catch (const std::exception& e) { if (token->is_canceled()) { connection->m_logger.log(trace_level::info, "starting the connection has been canceled."); } else { connection->m_logger.log(trace_level::errors, std::string("connection could not be started due to: ") .append(e.what())); } connection->m_transport = nullptr; connection->change_state(connection_state::disconnected); connection->m_start_completed_event.cancel(); callback(std::current_exception()); return; } connection->m_transport = transport; if (!connection->change_state(connection_state::connecting, connection_state::connected)) { connection->m_logger.log(trace_level::errors, std::string("internal error - transition from an unexpected state. expected state: connecting, actual state: ") .append(translate_connection_state(connection->get_connection_state()))); assert(false); } connection->m_start_completed_event.cancel(); callback(nullptr); }; if (m_skip_negotiation) { // TODO: check that the websockets transport is explicitly selected return start_transport(url, transport_started); } negotiate::negotiate(*m_http_client, url, m_signalr_client_config, [callback, weak_connection, redirect_count, token, url, transport_started](negotiation_response&& response, std::exception_ptr exception) { auto connection = weak_connection.lock(); if (!connection) { callback(std::make_exception_ptr(signalr_exception("connection no longer exists"))); return; } if (exception != nullptr) { try { std::rethrow_exception(exception); } catch (const std::exception& e) { connection->m_logger.log(trace_level::errors, std::string("connection could not be started due to: ") .append(e.what())); } connection->change_state(connection_state::disconnected); connection->m_start_completed_event.cancel(); callback(exception); return; } if (!response.error.empty()) { connection->change_state(connection_state::disconnected); connection->m_start_completed_event.cancel(); callback(std::make_exception_ptr(signalr_exception(response.error))); return; } if (!response.url.empty()) { if (!response.accessToken.empty()) { auto& headers = connection->m_signalr_client_config.get_http_headers(); headers["Authorization"] = "Bearer " + response.accessToken; } connection->start_negotiate(response.url, redirect_count + 1, callback); return; } connection->m_connection_id = std::move(response.connectionId); connection->m_connection_token = std::move(response.connectionToken); // TODO: fallback logic bool foundWebsockets = false; for (auto& availableTransport : response.availableTransports) { case_insensitive_equals comparer; if (comparer(availableTransport.transport, "WebSockets")) { foundWebsockets = true; break; } } if (!foundWebsockets) { connection->change_state(connection_state::disconnected); connection->m_start_completed_event.cancel(); callback(std::make_exception_ptr(signalr_exception("The server does not support WebSockets which is currently the only transport supported by this client."))); return; } // TODO: use transfer format if (token->is_canceled()) { connection->change_state(connection_state::disconnected); callback(std::make_exception_ptr(canceled_exception())); return; } connection->start_transport(url, transport_started); }); } void connection_impl::start_transport(const std::string& url, std::function<void(std::shared_ptr<transport>, std::exception_ptr)> callback) { auto connection = shared_from_this(); std::shared_ptr<bool> connect_request_done = std::make_shared<bool>(); std::shared_ptr<std::mutex> connect_request_lock = std::make_shared<std::mutex>(); auto weak_connection = std::weak_ptr<connection_impl>(connection); const auto& disconnect_cts = m_disconnect_cts; const auto& logger = m_logger; auto transport = connection->m_transport_factory->create_transport( transport_type::websockets, connection->m_logger, connection->m_signalr_client_config); transport->on_close([weak_connection](std::exception_ptr exception) { auto connection = weak_connection.lock(); if (!connection) { return; } // close callback will only be called if start on the transport has already returned // wait for the event in order to avoid a race where the state hasn't changed from connecting // yet and the transport errors out connection->m_start_completed_event.wait(); connection->stop_connection(exception); }); transport->on_receive([disconnect_cts, connect_request_done, connect_request_lock, logger, weak_connection, callback](std::string&& message, std::exception_ptr exception) { if (exception == nullptr) { if (disconnect_cts->is_canceled()) { logger.log(trace_level::info, std::string{ "ignoring stray message received after connection was restarted. message: " } .append(message)); return; } auto connection = weak_connection.lock(); if (connection) { connection->process_response(std::move(message)); } } else { try { // Rethrowing the exception so we can log it std::rethrow_exception(exception); } catch (const std::exception & e) { // When a connection is stopped we don't wait for its transport to stop. As a result if the same connection // is immediately re-started the old transport can still invoke this callback. To prevent this we capture // the disconnect_cts by value which allows distinguishing if the error is for the running connection // or for the one that was already stopped. If this is the latter we just ignore it. if (disconnect_cts->is_canceled()) { logger.log(trace_level::info, std::string{ "ignoring stray error received after connection was restarted. error: " } .append(e.what())); return; } bool run_callback = false; { std::lock_guard<std::mutex> lock(*connect_request_lock); // no op after connection started successfully if (*connect_request_done == false) { *connect_request_done = true; run_callback = true; } } if (run_callback) { callback({}, exception); } } } }); std::thread([disconnect_cts, connect_request_done, connect_request_lock, callback, weak_connection]() { disconnect_cts->wait(5000); bool run_callback = false; { std::lock_guard<std::mutex> lock(*connect_request_lock); // no op after connection started successfully if (*connect_request_done == false) { *connect_request_done = true; run_callback = true; } } // if the disconnect_cts is canceled it means that the connection has been stopped or went out of scope in // which case we should not throw due to timeout. if (disconnect_cts->is_canceled()) { if (run_callback) { // The callback checks the disconnect_cts token and will handle it appropriately callback({}, nullptr); } } else { if (run_callback) { callback({}, std::make_exception_ptr(signalr_exception("transport timed out when trying to connect"))); } } }).detach(); connection->send_connect_request(transport, url, [callback, connect_request_done, connect_request_lock, transport](std::exception_ptr exception) { bool run_callback = false; { std::lock_guard<std::mutex> lock(*connect_request_lock); // no op after connection started successfully if (*connect_request_done == false) { *connect_request_done = true; run_callback = true; } } if (run_callback) { if (exception == nullptr) { callback(transport, nullptr); } else { callback({}, exception); } } }); } void connection_impl::send_connect_request(const std::shared_ptr<transport>& transport, const std::string& url, std::function<void(std::exception_ptr)> callback) { auto logger = m_logger; auto query_string = "id=" + m_connection_token; auto connect_url = url_builder::build_connect(url, transport->get_transport_type(), query_string); transport->start(connect_url, transfer_format::text, [callback, logger](std::exception_ptr exception) mutable { try { if (exception != nullptr) { std::rethrow_exception(exception); } callback(nullptr); } catch (const std::exception& e) { logger.log( trace_level::errors, std::string("transport could not connect due to: ") .append(e.what())); callback(exception); } }); } void connection_impl::process_response(std::string&& response) { m_logger.log(trace_level::messages, std::string("processing message: ").append(response)); invoke_message_received(std::move(response)); } void connection_impl::invoke_message_received(std::string&& message) { try { m_message_received(std::move(message)); } catch (const std::exception &e) { m_logger.log( trace_level::errors, std::string("message_received callback threw an exception: ") .append(e.what())); } catch (...) { m_logger.log(trace_level::errors, "message_received callback threw an unknown exception"); } } void connection_impl::send(const std::string& data, std::function<void(std::exception_ptr)> callback) noexcept { // To prevent an (unlikely) condition where the transport is nulled out after we checked the connection_state // and before sending data we store the pointer in the local variable. In this case `send()` will throw but // we won't crash. auto transport = m_transport; const auto connection_state = get_connection_state(); if (connection_state != signalr::connection_state::connected || !transport) { callback(std::make_exception_ptr(signalr_exception( std::string("cannot send data when the connection is not in the connected state. current connection state: ") .append(translate_connection_state(connection_state))))); return; } auto logger = m_logger; logger.log(trace_level::info, std::string("sending data: ").append(data)); transport->send(data, [logger, callback](std::exception_ptr exception) mutable { try { if (exception != nullptr) { std::rethrow_exception(exception); } callback(nullptr); } catch (const std::exception &e) { logger.log( trace_level::errors, std::string("error sending data: ") .append(e.what())); callback(exception); } }); } void connection_impl::stop(std::function<void(std::exception_ptr)> callback) noexcept { m_logger.log(trace_level::info, "stopping connection"); shutdown(callback); } // This function is called from the dtor so you must not use `shared_from_this` here (it will throw). void connection_impl::shutdown(std::function<void(std::exception_ptr)> callback) { { std::lock_guard<std::mutex> lock(m_stop_lock); m_logger.log(trace_level::info, "acquired lock in shutdown()"); const auto current_state = get_connection_state(); if (current_state == connection_state::disconnected) { callback(nullptr); return; } if (current_state == connection_state::disconnecting) { // canceled task will be returned if `stop` was called while another `stop` was already in progress. // This is to prevent from resetting the `m_transport` in the upstream callers because doing so might // affect the other invocation which is using it. callback(std::make_exception_ptr(canceled_exception())); return; } // we request a cancellation of the ongoing start (if any) and wait until it is canceled m_disconnect_cts->cancel(); while (m_start_completed_event.wait(60000) != 0) { m_logger.log(trace_level::errors, "internal error - stopping the connection is still waiting for the start operation to finish which should have already finished or timed out"); } // at this point we are either in the connected or disconnected state. If we are in the disconnected state // we must break because the transport has already been nulled out. if (m_connection_state == connection_state::disconnected) { callback(nullptr); return; } assert(m_connection_state == connection_state::connected); change_state(connection_state::disconnecting); } m_transport->stop(callback); } // do not use `shared_from_this` as it can be called via the destructor void connection_impl::stop_connection(std::exception_ptr error) { { // the lock prevents a race where the user calls `stop` on a disconnected connection and calls `start` // on a different thread at the same time. In this case we must not null out the transport if we are // not in the `disconnecting` state to not affect the 'start' invocation. std::lock_guard<std::mutex> lock(m_stop_lock); if (m_connection_state == connection_state::disconnected) { m_logger.log(trace_level::info, "Stopping was ignored because the connection is already in the disconnected state."); return; } change_state(connection_state::disconnected); m_transport = nullptr; } if (error) { try { std::rethrow_exception(error); } catch (const std::exception & ex) { m_logger.log(trace_level::errors, std::string("Connection closed with error: ").append(ex.what())); } } else { m_logger.log(trace_level::info, "Connection closed."); } try { m_disconnected(); } catch (const std::exception & e) { m_logger.log( trace_level::errors, std::string("disconnected callback threw an exception: ") .append(e.what())); } catch (...) { m_logger.log( trace_level::errors, std::string("disconnected callback threw an unknown exception")); } } connection_state connection_impl::get_connection_state() const noexcept { return m_connection_state.load(); } std::string connection_impl::get_connection_id() const noexcept { if (m_connection_state.load() == connection_state::connecting) { return ""; } return m_connection_id; } void connection_impl::set_message_received(const std::function<void(std::string&&)>& message_received) { ensure_disconnected("cannot set the callback when the connection is not in the disconnected state. "); m_message_received = message_received; } void connection_impl::set_client_config(const signalr_client_config& config) { ensure_disconnected("cannot set client config when the connection is not in the disconnected state. "); m_signalr_client_config = config; } void connection_impl::set_disconnected(const std::function<void()>& disconnected) { ensure_disconnected("cannot set the disconnected callback when the connection is not in the disconnected state. "); m_disconnected = disconnected; } void connection_impl::ensure_disconnected(const std::string& error_message) const { const auto state = get_connection_state(); if (state != connection_state::disconnected) { throw signalr_exception( error_message + "current connection state: " + translate_connection_state(state)); } } bool connection_impl::change_state(connection_state old_state, connection_state new_state) { if (m_connection_state.compare_exchange_strong(old_state, new_state, std::memory_order_seq_cst)) { handle_connection_state_change(old_state, new_state); return true; } return false; } connection_state connection_impl::change_state(connection_state new_state) { auto old_state = m_connection_state.exchange(new_state); if (old_state != new_state) { handle_connection_state_change(old_state, new_state); } return old_state; } void connection_impl::handle_connection_state_change(connection_state old_state, connection_state new_state) { m_logger.log( trace_level::state_changes, translate_connection_state(old_state) .append(" -> ") .append(translate_connection_state(new_state))); // Words of wisdom (if we decide to add a state_changed callback and invoke it from here): // "Be extra careful when you add this callback, because this is sometimes being called with the m_stop_lock. // This could lead to interesting problems.For example, you could run into a segfault if the connection is // stopped while / after transitioning into the connecting state." } std::string connection_impl::translate_connection_state(connection_state state) { switch (state) { case connection_state::connecting: return "connecting"; case connection_state::connected: return "connected"; case connection_state::disconnecting: return "disconnecting"; case connection_state::disconnected: return "disconnected"; default: assert(false); return "(unknown)"; } } }
39.511258
185
0.554457
tonerdo
735739922baebe75d65a9e4911c708981faf4497
1,569
hpp
C++
SDK/ARKSurvivalEvolved_Buff_BrainSlugShoulderVisualCient_classes.hpp
2bite/ARK-SDK
c38ca9925309516b2093ad8c3a70ed9489e1d573
[ "MIT" ]
10
2020-02-17T19:08:46.000Z
2021-07-31T11:07:19.000Z
SDK/ARKSurvivalEvolved_Buff_BrainSlugShoulderVisualCient_classes.hpp
2bite/ARK-SDK
c38ca9925309516b2093ad8c3a70ed9489e1d573
[ "MIT" ]
9
2020-02-17T18:15:41.000Z
2021-06-06T19:17:34.000Z
SDK/ARKSurvivalEvolved_Buff_BrainSlugShoulderVisualCient_classes.hpp
2bite/ARK-SDK
c38ca9925309516b2093ad8c3a70ed9489e1d573
[ "MIT" ]
3
2020-07-22T17:42:07.000Z
2021-06-19T17:16:13.000Z
#pragma once // ARKSurvivalEvolved (329.9) SDK #ifdef _MSC_VER #pragma pack(push, 0x8) #endif #include "ARKSurvivalEvolved_Buff_BrainSlugShoulderVisualCient_structs.hpp" namespace sdk { //--------------------------------------------------------------------------- //Classes //--------------------------------------------------------------------------- // BlueprintGeneratedClass Buff_BrainSlugShoulderVisualCient.Buff_BrainSlugShoulderVisualCient_C // 0x0014 (0x0974 - 0x0960) class ABuff_BrainSlugShoulderVisualCient_C : public ABuff_Base_C { public: struct FLinearColor CrosshairColor; // 0x0960(0x0010) (Edit, BlueprintVisible, ZeroConstructor, DisableEditOnInstance, IsPlainOldData) float K2Node_Event_DeltaTime; // 0x0970(0x0004) (ZeroConstructor, Transient, DuplicateTransient, IsPlainOldData) static UClass* StaticClass() { static auto ptr = UObject::FindClass("BlueprintGeneratedClass Buff_BrainSlugShoulderVisualCient.Buff_BrainSlugShoulderVisualCient_C"); return ptr; } void BPGetHUDElements(class APlayerController** ForPC, TArray<struct FHUDElement>* OutElements); void STATIC_DrawBuffFloatingHUD(int* BuffIndex, class AShooterHUD** HUD, float* CenterX, float* CenterY, float* DrawScale); void UserConstructionScript(); void BuffTickClient(float* DeltaTime); void ExecuteUbergraph_Buff_BrainSlugShoulderVisualCient(int EntryPoint); }; } #ifdef _MSC_VER #pragma pack(pop) #endif
34.866667
208
0.656469
2bite
735a91fc08d33d73a2499cfb32fdf0824c242084
6,059
cpp
C++
tests/test_buffer.cpp
ximenpo/simple-cpp
0779674dbea5cd8f4081140cad90edeaa31da7c8
[ "MIT" ]
2
2015-04-10T04:07:24.000Z
2015-10-21T07:13:11.000Z
tests/test_buffer.cpp
ximenpo/simple_cpp
0779674dbea5cd8f4081140cad90edeaa31da7c8
[ "MIT" ]
1
2015-04-18T02:31:22.000Z
2015-04-21T20:21:02.000Z
tests/test_buffer.cpp
ximenpo/simple_cpp
0779674dbea5cd8f4081140cad90edeaa31da7c8
[ "MIT" ]
null
null
null
#include "simple/igloo.h" using namespace igloo; #include <map> #include <set> #include <list> #include <deque> #include <vector> #include "simple/buffer.h" struct testBufferMsg1 { enum {ID = 1}; int n; std::string s; }; buffer& operator>>(buffer& buf, testBufferMsg1& obj) { uintmax_t size; uintmax_t ver = 0; buffer_tag tag; if( !buffer_read_tag(buf, tag) || tag.data_type != buffer_tag::TYPE_OBJECT || (tag.version_tag && !buffer_read_uint_value(buf, buffer_tag::TAG_1, ver)) || !buffer_read_uint_value(buf, tag.size_tag, size) //|| (tag.version_tag && ver>=0 && size < 0) || (tag.version_tag && ver<=0 && size > 0) ) { buf.set_failure(); return buf; } if(!tag.version_tag || ver == 0) { return buf >> obj.n >> obj.s ; } size_t count = 0; for(size_t i = count; count < size; ++i) { buffer_read_and_ignore(buf);// ignore extended fields } return buf; } buffer& operator<<(buffer& buf, const testBufferMsg1& obj) { uintmax_t size = 0; buffer_tag tag = { buffer_tag::TYPE_OBJECT, buffer_size_tag(size), 0 != 0, }; if( !buffer_write_tag(buf, tag) || (tag.version_tag && !buffer_write_uint_value(buf, buffer_tag::TAG_1, 0)) || !buffer_write_uint_value(buf, tag.size_tag, size) ) { buf.set_failure(); return buf; } buf << obj.n << obj.s ; return buf; } Context(buffer_context) { Spec(simple_msg_usage) { testBufferMsg1 m1 = { 35, "XiMenPo", }; testBufferMsg1 m2; buffer buf; buf << m1; buf.rewind(); buf >> m2; AssertThat(m2.n, Equals(m1.n)); AssertThat(m2.s, Equals(m1.s)); } Spec(map_usage) { std::map<int, std::string> v1, v2; v1[0] = "000"; v1[1] = "111"; v1[2] = "222"; buffer buf; buf << v1; buf.rewind(); buf >> v2; AssertThat(v2.size(), Equals(3)); AssertThat(v2[0], Equals(v1[0])); AssertThat(v2[1], Equals(v1[1])); AssertThat(v2[2], Equals(v1[2])); } Spec(deque_usage) { std::deque<std::string> v1, v2; v1.push_back("000"); v1.push_back("111"); v1.push_back("222"); buffer buf; buf << v1; buf.rewind(); buf >> v2; AssertThat(v2, EqualsContainer(v1)); } Spec(vector_usage) { std::vector<std::string> v1, v2; v1.push_back("000"); v1.push_back("111"); v1.push_back("222"); buffer buf; buf << v1; buf.rewind(); buf >> v2; AssertThat(v2, EqualsContainer(v1)); } Spec(list_usage) { std::list<std::string> v1, v2; v1.push_back("000"); v1.push_back("111"); v1.push_back("222"); buffer buf; buf << v1; buf.rewind(); buf >> v2; AssertThat(v2, EqualsContainer(v1)); } Spec(set_usage) { std::set<std::string> v1, v2; v1.insert("000"); v1.insert("111"); v1.insert("222"); buffer buf; buf << v1; buf.rewind(); buf >> v2; AssertThat(v2, EqualsContainer(v1)); } Spec(safe_array_usage) { safe_array<std::string, 3> v1, v2; v1[0] = "000"; v1[1] = "111"; v1[2] = "222"; buffer buf; buf << v1; buf.rewind(); buf >> v2; AssertThat(v2[0], Equals(v1[0])); AssertThat(v2[1], Equals(v1[1])); AssertThat(v2[2], Equals(v1[2])); } Spec(queue_mergeable_usage) { buffer_queue q(true); int n; buffer *r1, *r2, *r3, *r4, *r5; buffer *b1 = q.create(), *b2 = q.create(), *b3 = q.create(), *b4 = q.create(); (*b1) << 1; (*b2) << 2; (*b3) << 3; (*b4) << 4; AssertThat(q.get(r1), Equals(false)); q.push(b1); q.push(b2); q.push(b3); q.push(b4); AssertThat(q.get(r1), Equals(true)); (*r1) >> n; AssertThat(n, Equals(1)); AssertThat(q.get(r2), Equals(true)); (*r2) >> n; AssertThat(n, Equals(2)); AssertThat(q.get(r3), Equals(true)); (*r3) >> n; AssertThat(n, Equals(3)); AssertThat(q.get(r4), Equals(true)); (*r4) >> n; AssertThat(n, Equals(4)); AssertThat(q.get(r5), Equals(false)); AssertThat(r1, Equals(r2)); AssertThat(r2, Equals(r3)); AssertThat(r3, Equals(r4)); } Spec(queue_not_mergeable_usage) { buffer_queue q(false); int n; buffer *r1, *r2, *r3, *r4, *r5; buffer *b1 = q.create(), *b2 = q.create(), *b3 = q.create(), *b4 = q.create(); (*b1) << 1; (*b2) << 2; (*b3) << 3; (*b4) << 4; AssertThat(q.get(r1), Equals(false)); q.push(b1); q.push(b2); q.push(b3); q.push(b4); AssertThat(q.get(r1), Equals(true)); (*r1) >> n; AssertThat(n, Equals(1)); AssertThat(q.get(r2), Equals(true)); (*r2) >> n; AssertThat(n, Equals(2)); AssertThat(q.get(r3), Equals(true)); (*r3) >> n; AssertThat(n, Equals(3)); AssertThat(q.get(r4), Equals(true)); (*r4) >> n; AssertThat(n, Equals(4)); AssertThat(q.get(r5), Equals(false)); AssertThat(r1, !Equals(r2)); AssertThat(r2, !Equals(r3)); AssertThat(r3, !Equals(r4)); } Spec(dump_usage) { buffer buf; for(size_t i = 0; i < 32; ++i) { buf << i; } std::ostringstream os; buf.dump(os); AssertThat(os.str(), EqualsContainer(buf.dump())); } };
23.484496
88
0.474006
ximenpo
735b8df02e43154b2ba8d201d130aaeca3d79db3
2,036
cpp
C++
src/llvmir2hll/ir/unary_op_expr.cpp
Andrik-555/retdec
1ac63a520da02912daf836b924f41d95b1b5fa10
[ "MIT", "BSD-3-Clause" ]
521
2019-03-29T15:44:08.000Z
2022-03-22T09:46:19.000Z
src/llvmir2hll/ir/unary_op_expr.cpp
Andrik-555/retdec
1ac63a520da02912daf836b924f41d95b1b5fa10
[ "MIT", "BSD-3-Clause" ]
30
2019-06-04T17:00:49.000Z
2021-09-08T20:44:19.000Z
src/llvmir2hll/ir/unary_op_expr.cpp
Andrik-555/retdec
1ac63a520da02912daf836b924f41d95b1b5fa10
[ "MIT", "BSD-3-Clause" ]
99
2019-03-29T16:04:13.000Z
2022-03-28T16:59:34.000Z
/** * @file src/llvmir2hll/ir/unary_op_expr.cpp * @brief Implementation of UnaryOpExpr. * @copyright (c) 2017 Avast Software, licensed under the MIT license */ #include "retdec/llvmir2hll/ir/unary_op_expr.h" #include "retdec/llvmir2hll/support/debug.h" namespace retdec { namespace llvmir2hll { /** * @brief Constructs a unary operator. * * @param[in] op Operand. * * @par Preconditions * - @a op is non-null */ UnaryOpExpr::UnaryOpExpr(ShPtr<Expression> op): op(op) { PRECONDITION_NON_NULL(op); } /** * @brief Destructs the operator. */ UnaryOpExpr::~UnaryOpExpr() {} ShPtr<Type> UnaryOpExpr::getType() const { return op->getType(); } void UnaryOpExpr::replace(ShPtr<Expression> oldExpr, ShPtr<Expression> newExpr) { PRECONDITION_NON_NULL(oldExpr); if (op == oldExpr) { setOperand(newExpr); } else if (op) { op->replace(oldExpr, newExpr); } } /** * @brief Returns the operand. */ ShPtr<Expression> UnaryOpExpr::getOperand() const { return op; } /** * @brief Sets a new operand. * * @par Preconditions * - @a operand is non-null */ void UnaryOpExpr::setOperand(ShPtr<Expression> newOp) { PRECONDITION_NON_NULL(newOp); op->removeObserver(shared_from_this()); newOp->addObserver(shared_from_this()); op = newOp; } /** * @brief Updates the operator according to the changes of @a subject. * * @param[in] subject Observable object. * @param[in] arg Optional argument. * * Replaces @a subject with @arg. For example, if @a subject is the operand of * the operator, this function replaces it with @a arg. * * This function does nothing when: * - @a subject does not correspond to the operand * - @a arg is not an expression * * @par Preconditions * - both operands are non-null * * @see Subject::update() */ void UnaryOpExpr::update(ShPtr<Value> subject, ShPtr<Value> arg) { PRECONDITION_NON_NULL(subject); PRECONDITION_NON_NULL(arg); ShPtr<Expression> newOperand = cast<Expression>(arg); if (subject == op && newOperand) { setOperand(newOperand); } } } // namespace llvmir2hll } // namespace retdec
21.208333
81
0.711198
Andrik-555
735cc339feadfdb26e310462205e801aa6cf08f4
943
hpp
C++
include/mizuiro/color/format/homogenous_dynamic_ns/tag_of.hpp
cpreh/mizuiro
5ab15bde4e72e3a4978c034b8ff5700352932485
[ "BSL-1.0" ]
1
2015-08-22T04:19:39.000Z
2015-08-22T04:19:39.000Z
include/mizuiro/color/format/homogenous_dynamic_ns/tag_of.hpp
freundlich/mizuiro
5ab15bde4e72e3a4978c034b8ff5700352932485
[ "BSL-1.0" ]
null
null
null
include/mizuiro/color/format/homogenous_dynamic_ns/tag_of.hpp
freundlich/mizuiro
5ab15bde4e72e3a4978c034b8ff5700352932485
[ "BSL-1.0" ]
null
null
null
// Copyright Carl Philipp Reh 2009 - 2016. // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) #ifndef MIZUIRO_COLOR_FORMAT_HOMOGENOUS_DYNAMIC_NS_TAG_OF_HPP_INCLUDED #define MIZUIRO_COLOR_FORMAT_HOMOGENOUS_DYNAMIC_NS_TAG_OF_HPP_INCLUDED #include <mizuiro/size_type.hpp> #include <mizuiro/color/format/homogenous_dynamic_fwd.hpp> #include <mizuiro/color/format/tag_of_fwd.hpp> #include <mizuiro/color/format/homogenous_dynamic_ns/tag.hpp> namespace mizuiro::color::format { template <typename ChannelType, typename Space, mizuiro::size_type ChannelCount> struct tag_of<mizuiro::color::format::homogenous_dynamic<ChannelType, Space, ChannelCount>> { using type = mizuiro::color::format::homogenous_dynamic_ns::tag< mizuiro::color::format::homogenous_dynamic<ChannelType, Space, ChannelCount>>; }; } #endif
34.925926
91
0.78685
cpreh
735d2a1d595e33ce6a12e792ba751952e6ec9ab9
120,271
hpp
C++
zeccup/zeccup/military/desert/construction.hpp
LISTINGS09/ZECCUP
e0ad1fae580dde6e5d90903b1295fecc41684f63
[ "Naumen", "Condor-1.1", "MS-PL" ]
3
2016-08-29T09:23:49.000Z
2019-06-13T20:29:28.000Z
zeccup/zeccup/military/desert/construction.hpp
LISTINGS09/ZECCUP
e0ad1fae580dde6e5d90903b1295fecc41684f63
[ "Naumen", "Condor-1.1", "MS-PL" ]
null
null
null
zeccup/zeccup/military/desert/construction.hpp
LISTINGS09/ZECCUP
e0ad1fae580dde6e5d90903b1295fecc41684f63
[ "Naumen", "Condor-1.1", "MS-PL" ]
null
null
null
class ConstructionLarge { name = $STR_ZECCUP_ConstructionLarge; // EAST class LightFactory_CUP_O_TK { name = $STR_ZECCUP_MilitaryDesert_ConstructionLarge_LightFactory_CUP_O_TK; // Credit: 2600K icon = "\ca\data\flag_rus_co.paa"; side = 8; class Object0 {side = 8; vehicle = "Land_tent_east"; rank = ""; position[] = {-6.24951,-0.626953,0}; dir = 210;}; class Object1 {side = 8; vehicle = "Land_fort_bagfence_corner"; rank = ""; position[] = {-3.87927,-4.94629,0}; dir = 300;}; class Object2 {side = 8; vehicle = "Land_fort_bagfence_corner"; rank = ""; position[] = {-11.1371,-1.33496,0}; dir = 30;}; class Object3 {side = 8; vehicle = "AmmoCrates_NoInteractive_Large"; rank = ""; position[] = {-11.2335,-3.09961,0}; dir = 210;}; class Object4 {side = 8; vehicle = "Land_fort_bagfence_long"; rank = ""; position[] = {-9.89526,-2.75439,0}; dir = 30;}; class Object5 {side = 8; vehicle = "Land_fort_bagfence_long"; rank = ""; position[] = {-7.39526,-4.25439,0}; dir = 30;}; class Object6 {side = 8; vehicle = "CUP_vojenska_palanda"; rank = ""; position[] = {-10.125,-0.875,0}; dir = 300;}; class Object7 {side = 8; vehicle = "CUP_vojenska_palanda"; rank = ""; position[] = {-4.5,-4.125,0}; dir = 120;}; class Object8 {side = 8; vehicle = "Land_WaterBarrel_F"; rank = ""; position[] = {-2.125,1.625,0}; dir = 359.998;}; class Object9 {side = 8; vehicle = "Land_MetalCase_01_small_F"; rank = ""; position[] = {-5.73694,-3.2666,0}; dir = 29.9944;}; class Object10 {side = 8; vehicle = "Land_MetalCase_01_small_F"; rank = ""; position[] = {-8.88806,-1.7334,0}; dir = 209.995;}; class Object11 {side = 8; vehicle = "AmmoCrates_NoInteractive_Small"; rank = ""; position[] = {-12.254,-2.48975,0}; dir = 300;}; class Object12 {side = 8; vehicle = "TK_WarfareBLightFactory_base_EP1"; rank = ""; position[] = {-3.74146,10.8384,0}; dir = 180;}; class Object13 {side = 8; vehicle = "Land_fort_bagfence_round"; rank = ""; position[] = {2.01611,-1.64453,0}; dir = 135;}; class Object15 {side = 8; vehicle = "Land_fort_bagfence_long"; rank = ""; position[] = {2.36108,3.51514,0}; dir = 90;}; class Object16 {side = 8; vehicle = "GunrackTK_EP1"; rank = ""; position[] = {3.35596,3.33057,0}; dir = 0;}; class Object17 {side = 8; vehicle = "Land_WaterBarrel_F"; rank = ""; position[] = {-1,0.625,0}; dir = 119.991;}; class Object18 {side = 8; vehicle = "MetalBarrel_burning_F"; rank = ""; position[] = {3.25,2.375,0}; dir = 135;}; class Object19 {side = 8; vehicle = "Land_Pallets_F"; rank = ""; position[] = {8.74744,0.653809,0}; dir = 90;}; class Object20 {side = 8; vehicle = "Land_Pallet_F"; rank = ""; position[] = {8.24219,-1.00781,0}; dir = 224.289;}; class Object21 {side = 8; vehicle = "Land_CamoNet_EAST_EP1"; rank = ""; position[] = {5.30054,11.7256,0}; dir = 270;}; class Object22 {side = 8; vehicle = "Land_fort_rampart_EP1"; rank = ""; position[] = {9.64954,11.5,0}; dir = 270;}; class Object23 {side = 8; vehicle = "Land_fort_bagfence_long"; rank = ""; position[] = {2.36108,6.39014,0}; dir = 90;}; class Object24 {side = 8; vehicle = "AmmoCrates_NoInteractive_Medium"; rank = ""; position[] = {6.29675,11.5298,0}; dir = 195;}; class Object25 {side = 8; vehicle = "Land_CratesWooden_F"; rank = ""; position[] = {8.375,8.75,0}; dir = 270;}; class Object26 {side = 8; vehicle = "Land_Sacks_goods_F"; rank = ""; position[] = {8.36426,15.0073,0}; dir = 300;}; class Object27 {side = 8; vehicle = "Land_Sacks_heap_F"; rank = ""; position[] = {8.31689,13.769,0}; dir = 0;}; class Object28 {side = 8; vehicle = "Land_WoodenBox_F"; rank = ""; position[] = {8.63647,17.2515,0}; dir = 330;}; class Object29 {side = 8; vehicle = "Land_WoodenBox_F"; rank = ""; position[] = {7.3197,8.43506,0}; dir = 270.001;}; class Object30 {side = 8; vehicle = "AmmoCrate_NoInteractive_"; rank = ""; position[] = {7.34302,10.3682,0}; dir = 135;}; class Object31 {side = 8; vehicle = "Barrel1"; rank = ""; position[] = {7.66821,6.90967,0}; dir = 225;}; class Object32 {side = 8; vehicle = "Barrel4"; rank = ""; position[] = {8.375,7,0}; dir = 330;}; class Object33 {side = 8; vehicle = "Barrel4"; rank = ""; position[] = {8.875,12.625,0}; dir = 330;}; class Object34 {side = 8; vehicle = "Land_Pallets_stack_F"; rank = ""; position[] = {10.6986,17.6494,0}; dir = 359.594;}; }; class HeavyFactory_CUP_O_TK { name = $STR_ZECCUP_MilitaryDesert_ConstructionLarge_HeavyFactory_CUP_O_TK; // Credit: 2600K icon = "\ca\data\flag_rus_co.paa"; side = 8; class Object0 {side = 8; vehicle = "Land_HBarrier_large"; rank = ""; position[] = {1.07666,-11.5718,0}; dir = 180;}; class Object1 {side = 8; vehicle = "Land_fort_bagfence_corner"; rank = ""; position[] = {-7.52441,-11.187,0}; dir = 0;}; class Object2 {side = 8; vehicle = "AmmoCrates_NoInteractive_Large"; rank = ""; position[] = {1.68335,-9.82275,0}; dir = 90;}; class Object3 {side = 8; vehicle = "AmmoCrates_NoInteractive_Large"; rank = ""; position[] = {0.354614,-9.9126,0}; dir = 0;}; class Object5 {side = 8; vehicle = "Land_fort_bagfence_long"; rank = ""; position[] = {-4.32642,-11.7964,0}; dir = 0;}; class Object6 {side = 8; vehicle = "AmmoCrates_NoInteractive_Small"; rank = ""; position[] = {0.462402,-8.92773,0}; dir = 0;}; class Object7 {side = 8; vehicle = "AmmoCrate_NoInteractive_"; rank = ""; position[] = {-5.40479,3.83301,0}; dir = 345;}; class Object8 {side = 8; vehicle = "Barrel4"; rank = ""; position[] = {-6.43604,2.21777,0}; dir = 285;}; class Object9 {side = 8; vehicle = "Barrel4"; rank = ""; position[] = {-7.84241,1.31494,0}; dir = 285;}; class Object10 {side = 8; vehicle = "Barrel4"; rank = ""; position[] = {2.93896,-10.0322,0}; dir = 240;}; class Object11 {side = 8; vehicle = "Barrel4"; rank = ""; position[] = {-6.91357,1.65039,0}; dir = 285;}; class Object12 {side = 8; vehicle = "Barrel4"; rank = ""; position[] = {-9.56104,3.21777,0}; dir = 240;}; class Object13 {side = 8; vehicle = "Barrel4"; rank = ""; position[] = {-9.14148,4.11182,0}; dir = 240;}; class Object14 {side = 8; vehicle = "Barrel4"; rank = ""; position[] = {-10.186,3.59277,0}; dir = 195;}; class Object15 {side = 8; vehicle = "Barrel1"; rank = ""; position[] = {-8.56104,1.59277,0}; dir = 180;}; class Object16 {side = 8; vehicle = "Land_Pallets_F"; rank = ""; position[] = {0.398438,-13.5225,0}; dir = 75;}; class Object17 {side = 8; vehicle = "Land_Pallet_F"; rank = ""; position[] = {-0.37793,-13.8491,0}; dir = 179.258;}; class Object18 {side = 8; vehicle = "TK_WarfareBHeavyFactory_Base_EP1"; rank = ""; position[] = {1.18896,13.0928,0}; dir = 0;}; class Object19 {side = 8; vehicle = "Land_CamoNet_EAST_EP1"; rank = ""; position[] = {-7.98718,8.06445,0}; dir = 105;}; class Object20 {side = 8; vehicle = "Land_HBarrier_large"; rank = ""; position[] = {-6.24341,5.78906,0}; dir = 300;}; class Object21 {side = 8; vehicle = "AmmoCrates_NoInteractive_Large"; rank = ""; position[] = {-7.65356,7.56738,0}; dir = 30;}; class Object22 {side = 8; vehicle = "AmmoCrates_NoInteractive_Medium"; rank = ""; position[] = {-4.85107,4.67334,0}; dir = 30;}; class Object23 {side = 8; vehicle = "MetalBarrel_burning_F"; rank = ""; position[] = {-12.561,10.2178,0}; dir = 180;}; class Object24 {side = 8; vehicle = "AmmoCrates_NoInteractive_Large"; rank = ""; position[] = {-8.03589,6.375,0}; dir = 300;}; class Object25 {side = 8; vehicle = "Barrel4"; rank = ""; position[] = {-9.76648,4.48682,0}; dir = 45;}; class Object26 {side = 8; vehicle = "Land_Pallets_stack_F"; rank = ""; position[] = {-8.90344,11.749,0}; dir = 194.999;}; class Object27 {side = 8; vehicle = "Land_Pallets_stack_F"; rank = ""; position[] = {-8.31104,13.3428,0}; dir = 269.999;}; class Object28 {side = 8; vehicle = "Land_fort_rampart_EP1"; rank = ""; position[] = {10.189,-10.9316,0}; dir = 0;}; class Object29 {side = 8; vehicle = "Land_HBarrier_large"; rank = ""; position[] = {13.9785,-6.39453,0}; dir = 90;}; class Object30 {side = 8; vehicle = "Land_fort_rampart_EP1"; rank = ""; position[] = {12.2893,2.7666,0}; dir = 255;}; class Object31 {side = 8; vehicle = "Barrels"; rank = ""; position[] = {12.064,-1.78223,0}; dir = 135;}; class Object32 {side = 8; vehicle = "Barrels"; rank = ""; position[] = {11.564,-0.0322266,0}; dir = 180;}; class Object33 {side = 8; vehicle = "Barrels"; rank = ""; position[] = {10.689,3.59277,0}; dir = 255;}; class Object34 {side = 8; vehicle = "Land_WaterBarrel_F"; rank = ""; position[] = {11.314,1.59277,0}; dir = 119.991;}; class Object35 {side = 8; vehicle = "Barrel1"; rank = ""; position[] = {12.314,-8.53223,0}; dir = 135;}; class Object36 {side = 8; vehicle = "Barrel4"; rank = ""; position[] = {12.3755,-9.41846,0}; dir = 120;}; class Object37 {side = 8; vehicle = "Barrel4"; rank = ""; position[] = {12.439,-10.1572,0}; dir = 240;}; class Object38 {side = 8; vehicle = "Barrel4"; rank = ""; position[] = {11.439,-9.40723,0}; dir = 270;}; class Object39 {side = 8; vehicle = "Barrel4"; rank = ""; position[] = {11.314,-10.1572,0}; dir = 255;}; class Object40 {side = 8; vehicle = "Land_MetalBarrel_F"; rank = ""; position[] = {11.939,-5.03223,0}; dir = 29.9472;}; class Object41 {side = 8; vehicle = "Land_MetalBarrel_F"; rank = ""; position[] = {12.3138,-4.28223,0}; dir = 359.991;}; class Object42 {side = 8; vehicle = "Land_MetalBarrel_empty_F"; rank = ""; position[] = {11.5642,-4.28223,0}; dir = 150;}; }; // WEST class LightFactory_CUP_B_USMC { name = $STR_ZECCUP_MilitaryDesert_ConstructionLarge_LightFactory_CUP_B_USMC; // Credit: 2600K icon = "\ca\data\flag_usa_co.paa"; side = 8; class Object0 {side = 8; vehicle = "Land_HBarrier3"; rank = ""; position[] = {-8.71423,-8.78174,0}; dir = 270;}; class Object1 {side = 8; vehicle = "Land_HBarrier3"; rank = ""; position[] = {-4.09326,3.78564,0}; dir = 180;}; class Object2 {side = 8; vehicle = "Land_HBarrier3"; rank = ""; position[] = {-7.40674,-8.53564,0}; dir = 0;}; class Object3 {side = 8; vehicle = "Land_Garbage_square5_F"; rank = ""; position[] = {-4.89001,-6.74512,0}; dir = 0;}; class Object4 {side = 8; vehicle = "Land_HBarrier1"; rank = ""; position[] = {-8.74243,-9.61914,0}; dir = 300;}; class Object5 {side = 8; vehicle = "Land_JunkPile_F"; rank = ""; position[] = {-4.77966,-6.73486,0}; dir = 0;}; class Object6 {side = 8; vehicle = "Land_ToiletBox_F"; rank = ""; position[] = {-7.25,-6.5,0}; dir = 180.002;}; class Object7 {side = 8; vehicle = "Land_WaterTank_F"; rank = ""; position[] = {-5.75,2.25,0}; dir = 9.30621e-006;}; class Object8 {side = 8; vehicle = "Land_PaperBox_open_empty_F"; rank = ""; position[] = {-1.8103,-6.56055,0}; dir = 180;}; class Object9 {side = 8; vehicle = "Land_GarbageBarrel_01_F"; rank = ""; position[] = {-5.89197,-5.46094,0}; dir = 27.556;}; class Object10 {side = 8; vehicle = "Land_MetalBarrel_F"; rank = ""; position[] = {-3.12512,-6.875,0}; dir = 315.007;}; class Object11 {side = 8; vehicle = "Land_MetalBarrel_F"; rank = ""; position[] = {-8.02893,4.02734,0}; dir = 254.82;}; // Z: 0.0966296 class Object12 {side = 8; vehicle = "AmmoCrates_NoInteractive_Large"; rank = ""; position[] = {-7.61938,2.91553,0}; dir = 270;}; class Object13 {side = 8; vehicle = "Land_Pallets_stack_F"; rank = ""; position[] = {-7.125,-10.375,0}; dir = 194.999;}; class Object14 {side = 8; vehicle = "Land_fort_artillery_nest_EP1"; rank = ""; position[] = {-9.00195,17.877,0}; dir = 315;}; class Object15 {side = 8; vehicle = "Land_CamoNetVar_NATO_EP1"; rank = ""; position[] = {-6.12805,14.1133,0}; dir = 135;}; class Object16 {side = 8; vehicle = "Land_PaperBox_open_empty_F"; rank = ""; position[] = {-9.12512,15.2495,0}; dir = 210;}; class Object17 {side = 8; vehicle = "Land_WoodenTable_large_F"; rank = ""; position[] = {-6.40649,11.3286,0}; dir = 224.692;}; class Object18 {side = 8; vehicle = "Land_WoodenTable_large_F"; rank = ""; position[] = {-4.05261,15.3276,0}; dir = 150.502;}; class Object19 {side = 8; vehicle = "Land_PaperBox_closed_F"; rank = ""; position[] = {-9.49756,13.4873,0}; dir = 180;}; class Object20 {side = 8; vehicle = "Land_CampingChair_V2_F"; rank = ""; position[] = {-3.11938,15.2861,0}; dir = 45.4717;}; class Object21 {side = 8; vehicle = "Land_CampingChair_V2_F"; rank = ""; position[] = {-3.60193,16.0317,0}; dir = 59.9813;}; class Object22 {side = 8; vehicle = "Land_CampingChair_V2_F"; rank = ""; position[] = {-6.75,12.375,0}; dir = 240.012;}; class Object23 {side = 8; vehicle = "Land_CampingChair_V2_F"; rank = ""; position[] = {-6.21973,10.4307,0}; dir = 120.011;}; class Object24 {side = 8; vehicle = "Land_CampingChair_V2_F"; rank = ""; position[] = {-5.60083,11.1411,0}; dir = 134.981;}; class Object25 {side = 8; vehicle = "Land_CampingChair_V2_F"; rank = ""; position[] = {-7.2804,11.4912,0}; dir = 300.012;}; class Object26 {side = 8; vehicle = "Land_CampingChair_V2_F"; rank = ""; position[] = {-5.09143,15.2412,0}; dir = 165.012;}; class Object27 {side = 8; vehicle = "Land_CampingChair_V2_F"; rank = ""; position[] = {-4.375,14.5,0}; dir = 225.011;}; class Object28 {side = 8; vehicle = "AmmoCrates_NoInteractive_Large"; rank = ""; position[] = {-5.29077,18.7446,0}; dir = 165;}; class Object29 {side = 8; vehicle = "Land_MetalBarrel_F"; rank = ""; position[] = {-9.75,12.25,0}; dir = 299.995;}; class Object30 {side = 8; vehicle = "Land_HBarrier_large"; rank = ""; position[] = {-0.362305,-8.41455,0}; dir = 180;}; class Object31 {side = 8; vehicle = "Land_HBarrier5"; rank = ""; position[] = {7.07556,-3.24365,0}; dir = 90;}; class Object33 {side = 8; vehicle = "Land_HBarrier1"; rank = ""; position[] = {6.75757,-8.49414,0}; dir = 300;}; class Object34 {side = 8; vehicle = "Land_HBarrier1"; rank = ""; position[] = {10.2443,-0.867676,0}; dir = 210;}; class Object35 {side = 8; vehicle = "Land_PaperBox_closed_F"; rank = ""; position[] = {-0.237549,-6.62256,0}; dir = 90;}; class Object36 {side = 8; vehicle = "Land_Sacks_heap_F"; rank = ""; position[] = {5.625,-3.875,0}; dir = 270;}; class Object37 {side = 8; vehicle = "Land_Sacks_heap_F"; rank = ""; position[] = {5.5,-4.875,0}; dir = 0;}; class Object38 {side = 8; vehicle = "Land_CratesPlastic_F"; rank = ""; position[] = {4.62305,-3.75391,0}; dir = 90;}; class Object39 {side = 8; vehicle = "MetalBarrel_burning_F"; rank = ""; position[] = {5.625,-2,0}; dir = 135;}; class Object40 {side = 8; vehicle = "Land_MetalBarrel_F"; rank = ""; position[] = {6.44971,-2.28809,0}; dir = 29.98;}; class Object41 {side = 8; vehicle = "Land_MetalBarrel_F"; rank = ""; position[] = {5.74988,-2.75,0}; dir = 59.9769;}; class Object42 {side = 8; vehicle = "AmmoCrates_NoInteractive_Medium"; rank = ""; position[] = {0.987305,-6.6001,0}; dir = 90;}; class Object43 {side = 8; vehicle = "US_WarfareBLightFactory_base_EP1"; rank = ""; position[] = {6.13611,6.81006,0}; dir = 0;}; }; class HeavyFactory_CUP_B_USMC { name = $STR_ZECCUP_MilitaryDesert_ConstructionLarge_HeavyFactory_CUP_B_USMC; // Credit: 2600K icon = "\ca\data\flag_usa_co.paa"; side = 8; class Object0 {side = 8; vehicle = "Land_HBarrier_large"; rank = ""; position[] = {-1.67334,-14.8218,0}; dir = 180;}; class Object1 {side = 8; vehicle = "Land_HBarrier3"; rank = ""; position[] = {-9.16638,-1.95459,0}; dir = 210;}; class Object2 {side = 8; vehicle = "AmmoCrates_NoInteractive_Large"; rank = ""; position[] = {-2.56665,-13.1978,0}; dir = 90;}; class Object3 {side = 8; vehicle = "AmmoCrates_NoInteractive_Large"; rank = ""; position[] = {-3.89539,-13.1626,0}; dir = 0;}; class Object5 {side = 8; vehicle = "Land_HBarrier1"; rank = ""; position[] = {-8.4303,-0.789551,0}; dir = 30;}; class Object6 {side = 8; vehicle = "Land_HBarrier1"; rank = ""; position[] = {-12.9303,-12.5249,0}; dir = 285;}; class Object7 {side = 8; vehicle = "Land_HBarrier1"; rank = ""; position[] = {-11.1873,0.102051,0}; dir = 240;}; class Object8 {side = 8; vehicle = "AmmoCrates_NoInteractive_Small"; rank = ""; position[] = {-3.9126,-12.1777,0}; dir = 0;}; class Object9 {side = 8; vehicle = "Land_BagFence_Round_F"; rank = ""; position[] = {-12.8102,-14.7368,0}; dir = 45;}; class Object10 {side = 8; vehicle = "Land_BagFence_Long_F"; rank = ""; position[] = {-7.30713,-15.2979,0}; dir = 180;}; class Object11 {side = 8; vehicle = "Land_BagFence_Long_F"; rank = ""; position[] = {-10.1821,-15.2979,0}; dir = 180;}; class Object12 {side = 8; vehicle = "Land_PaperBox_open_empty_F"; rank = ""; position[] = {-5.93628,1.46729,0}; dir = 240;}; class Object13 {side = 8; vehicle = "CargoNet_01_barrels_F"; rank = ""; position[] = {-5.81897,-13.2622,0}; dir = 164.852;}; class Object14 {side = 8; vehicle = "Land_BagFence_End_F"; rank = ""; position[] = {-13.1628,-12.5933,0}; dir = 270;}; class Object15 {side = 8; vehicle = "Land_MetalBarrel_F"; rank = ""; position[] = {0.499634,-12.2222,0}; dir = 179.991;}; class Object16 {side = 8; vehicle = "Land_MetalBarrel_F"; rank = ""; position[] = {1.68994,-13.1533,0}; dir = 135.042;}; class Object17 {side = 8; vehicle = "Land_MetalBarrel_F"; rank = ""; position[] = {0.688843,-13.1572,0}; dir = 14.982;}; class Object18 {side = 8; vehicle = "Land_MetalBarrel_F"; rank = ""; position[] = {-0.186035,-13.1572,0}; dir = 105.016;}; class Object19 {side = 8; vehicle = "Land_Pallets_F"; rank = ""; position[] = {-0.592163,-18.4189,0}; dir = 45;}; class Object20 {side = 8; vehicle = "Land_Pallet_F"; rank = ""; position[] = {-1.68604,-17.1572,0}; dir = 149.332;}; class Object21 {side = 8; vehicle = "Land_CamoNet_NATO_EP1"; rank = ""; position[] = {-8.61218,7.68945,0}; dir = 105;}; class Object22 {side = 8; vehicle = "Land_HBarrier_large"; rank = ""; position[] = {-7.74341,2.91406,0}; dir = 300;}; class Object23 {side = 8; vehicle = "Land_HBarrier1"; rank = ""; position[] = {-11.0685,13.9736,0}; dir = 195;}; class Object24 {side = 8; vehicle = "Land_HBarrier1"; rank = ""; position[] = {-13.4447,4.22119,0}; dir = 180;}; class Object25 {side = 8; vehicle = "AmmoCrates_NoInteractive_Medium"; rank = ""; position[] = {-9.771,3.01221,0}; dir = 210;}; class Object26 {side = 8; vehicle = "Land_PaperBox_open_empty_F"; rank = ""; position[] = {-13.6857,5.84277,0}; dir = 75;}; class Object27 {side = 8; vehicle = "Land_PaperBox_closed_F"; rank = ""; position[] = {-9.69849,9.46533,0}; dir = 270;}; class Object28 {side = 8; vehicle = "Land_PaperBox_closed_F"; rank = ""; position[] = {-11.5619,12.2051,0}; dir = 195;}; class Object29 {side = 8; vehicle = "Land_PaperBox_closed_F"; rank = ""; position[] = {-10.1733,11.0918,0}; dir = 105;}; class Object30 {side = 8; vehicle = "Land_PaperBox_closed_F"; rank = ""; position[] = {-9.32373,4.34375,0}; dir = 285;}; class Object31 {side = 8; vehicle = "MetalBarrel_burning_F"; rank = ""; position[] = {-14.186,3.09277,0}; dir = 345;}; class Object32 {side = 8; vehicle = "Land_MetalBarrel_F"; rank = ""; position[] = {-10.3112,12.5928,0}; dir = 29.9747;}; class Object33 {side = 8; vehicle = "Land_MetalBarrel_F"; rank = ""; position[] = {-10.0845,13.438,0}; dir = 299.995;}; class Object34 {side = 8; vehicle = "Land_MetalBarrel_F"; rank = ""; position[] = {-11.9362,14.8428,0}; dir = 60.0024;}; class Object35 {side = 8; vehicle = "AmmoCrate_NoInteractive_"; rank = ""; position[] = {-11.7012,10.8721,0}; dir = 210;}; class Object36 {side = 8; vehicle = "Land_Pallets_stack_F"; rank = ""; position[] = {-7.81104,17.7178,0}; dir = 254.999;}; class Object37 {side = 8; vehicle = "Land_HBarrier_large"; rank = ""; position[] = {12.2285,-1.01953,0}; dir = 90;}; class Object38 {side = 8; vehicle = "Land_HBarrier_large"; rank = ""; position[] = {12.4785,-9.26953,0}; dir = 90;}; class Object39 {side = 8; vehicle = "Land_BagFence_Round_F"; rank = ""; position[] = {12.2776,-14.541,0}; dir = 315;}; class Object40 {side = 8; vehicle = "Land_BagFence_Long_F"; rank = ""; position[] = {3.69287,-14.9229,0}; dir = 180;}; class Object41 {side = 8; vehicle = "Land_BagFence_Long_F"; rank = ""; position[] = {9.44287,-14.9229,0}; dir = 180;}; class Object42 {side = 8; vehicle = "Land_BagFence_Long_F"; rank = ""; position[] = {6.56787,-14.9229,0}; dir = 180;}; class Object43 {side = 8; vehicle = "Land_PaperBox_closed_F"; rank = ""; position[] = {10.5615,-11.3945,0}; dir = 0;}; class Object44 {side = 8; vehicle = "Land_PaperBox_closed_F"; rank = ""; position[] = {10.5764,-8.15479,0}; dir = 90;}; class Object45 {side = 8; vehicle = "CargoNet_01_barrels_F"; rank = ""; position[] = {10.4313,-4.28711,0}; dir = 179.883;}; class Object46 {side = 8; vehicle = "CargoNet_01_barrels_F"; rank = ""; position[] = {10.4086,-2.55127,0}; dir = 269.189;}; class Object47 {side = 8; vehicle = "Land_Sacks_heap_F"; rank = ""; position[] = {10.814,-9.78223,0}; dir = 270;}; class Object48 {side = 8; vehicle = "US_WarfareBHeavyFactory_Base_EP1"; rank = ""; position[] = {4.92065,8.53809,0}; dir = 0;}; }; }; class ConstructionMedium { name = $STR_ZECCUP_ConstructionMedium; // EAST class Yard_CUP_O_TK { name = $STR_ZECCUP_MilitaryDesert_ConstructionMedium_Yard_CUP_O_TK; // Credit: 2600K icon = "\ca\data\flag_rus_co.paa"; side = 8; class Object1 {side = 8; vehicle = "Land_Misc_Cargo2a_EP1"; rank = ""; position[] = {-5.40344,-4.72339,0}; dir = 180;}; class Object2 {side = 8; vehicle = "Land_Cargo20_grey_F"; rank = ""; position[] = {-7.95825,-4.75024,0}; dir = 270.005;}; class Object3 {side = 8; vehicle = "Land_Misc_Cargo2b"; rank = ""; position[] = {-5.25122,9.09839,0}; dir = 0;}; class Object4 {side = 8; vehicle = "Land_Misc_Cargo1e"; rank = ""; position[] = {-7.75122,9.09839,0}; dir = 0;}; class Object5 {side = 8; vehicle = "Land_fort_bagfence_corner"; rank = ""; position[] = {-6.15454,17.0884,0}; dir = 90;}; class Object6 {side = 8; vehicle = "Land_Ind_Shed_01_EP1"; rank = ""; position[] = {-1.375,-8.05176,0}; dir = 0;}; class Object7 {side = 8; vehicle = "Land_Misc_Cargo2a_EP1"; rank = ""; position[] = {4.84656,-4.47339,0}; dir = 180;}; class Object8 {side = 8; vehicle = "Land_Misc_Cargo1f"; rank = ""; position[] = {-0.251221,-4.40161,0}; dir = 0;}; class Object9 {side = 8; vehicle = "Land_Cargo20_light_blue_F"; rank = ""; position[] = {-2.78113,-4.49878,0}; dir = 89.7722;}; class Object10 {side = 8; vehicle = "Land_fort_bagfence_corner"; rank = ""; position[] = {0.0366211,-13.4045,0}; dir = 0;}; class Object11 {side = 8; vehicle = "Land_fort_bagfence_corner"; rank = ""; position[] = {3.90454,-12.8384,0}; dir = 270;}; class Object12 {side = 8; vehicle = "Land_PaperBox_closed_F"; rank = ""; position[] = {-0.122559,1.86255,0}; dir = 180;}; class Object14 {side = 8; vehicle = "Land_Cargo20_red_F"; rank = ""; position[] = {-2.80615,9.14014,0}; dir = 90;}; class Object15 {side = 8; vehicle = "Land_Misc_Cargo2c"; rank = ""; position[] = {4.77844,9.22339,0}; dir = 0;}; class Object16 {side = 8; vehicle = "Land_Misc_Cargo2a_EP1"; rank = ""; position[] = {-0.278442,8.90161,0}; dir = 180;}; class Object17 {side = 8; vehicle = "Land_fort_bagfence_corner"; rank = ""; position[] = {0.713379,17.5295,0}; dir = 180;}; class Object18 {side = 8; vehicle = "Land_GarbageBags_F"; rank = ""; position[] = {5.95996,12.7351,0}; dir = 0;}; class Object19 {side = 8; vehicle = "Land_PaperBox_closed_F"; rank = ""; position[] = {1.38647,2.63062,0}; dir = 75;}; class Object20 {side = 8; vehicle = "Land_fort_bagfence_long"; rank = ""; position[] = {-2.51538,18.1111,0}; dir = 0;}; class Object21 {side = 8; vehicle = "Land_Cargo20_yellow_F"; rank = ""; position[] = {2.25,9.125,0}; dir = 90;}; }; //WEST class Yard_CUP_B_USMC { name = $STR_ZECCUP_MilitaryDesert_ConstructionMedium_Yard_CUP_B_USMC; // Credit: 2600K icon = "\ca\data\flag_usa_co.paa"; side = 8; class Object1 {side = 8; vehicle = "Land_Misc_Cargo1f"; rank = ""; position[] = {-4.27429,-0.595459,0}; dir = 195;}; class Object2 {side = 8; vehicle = "Land_BagFence_Round_F"; rank = ""; position[] = {-6.91858,-11.1331,0}; dir = 60;}; class Object3 {side = 8; vehicle = "Land_BagFence_Long_F"; rank = ""; position[] = {-7.0155,-8.37891,0}; dir = 270;}; class Object4 {side = 8; vehicle = "Land_BagFence_End_F"; rank = ""; position[] = {-4.96143,-12.1682,0}; dir = 15;}; class Object5 {side = 8; vehicle = "Land_Misc_Cargo2a_EP1"; rank = ""; position[] = {-6.84656,7.47339,0}; dir = 0;}; class Object6 {side = 8; vehicle = "Land_PaperBox_closed_F"; rank = ""; position[] = {-4.61255,7.12744,0}; dir = 90;}; class Object7 {side = 8; vehicle = "Land_PaperBox_closed_F"; rank = ""; position[] = {-4.62744,8.88745,0}; dir = 0;}; class Object8 {side = 8; vehicle = "Land_BagFence_End_F"; rank = ""; position[] = {-4.24988,11.7383,0}; dir = 150;}; class Object9 {side = 8; vehicle = "Land_Ind_Shed_01_EP1"; rank = ""; position[] = {-1.125,-10.3018,0}; dir = 0;}; class Object10 {side = 8; vehicle = "Land_Cargo20_orange_F"; rank = ""; position[] = {-1.43115,-9.23486,0}; dir = 90;}; class Object11 {side = 8; vehicle = "Land_Misc_Cargo2e"; rank = ""; position[] = {1.12378,-9.27661,0}; dir = 0;}; class Object12 {side = 8; vehicle = "Land_Cargo20_white_F"; rank = ""; position[] = {3.75,-8,0}; dir = 90;}; class Object13 {side = 8; vehicle = "Land_GarbageBags_F"; rank = ""; position[] = {6.45996,-13.5149,0}; dir = 0;}; class Object14 {side = 8; vehicle = "Misc_cargo_cont_small"; rank = ""; position[] = {4.23645,-0.13501,0}; dir = 225;}; class Object15 {side = 8; vehicle = "Land_PaperBox_closed_F"; rank = ""; position[] = {5.87256,-5.36255,0}; dir = 0;}; class Object16 {side = 8; vehicle = "Land_PaperBox_closed_F"; rank = ""; position[] = {5.88745,-7.12256,0}; dir = 90;}; class Object18 {side = 8; vehicle = "Land_Misc_Cargo2c"; rank = ""; position[] = {2.40344,7.34839,0}; dir = 0;}; class Object19 {side = 8; vehicle = "Land_Misc_Cargo1c"; rank = ""; position[] = {4.87622,8.02661,0}; dir = 180;}; class Object20 {side = 8; vehicle = "Land_BagFence_Round_F"; rank = ""; position[] = {-2.75793,13.1685,0}; dir = 150;}; class Object21 {side = 8; vehicle = "Land_BagFence_Long_F"; rank = ""; position[] = {-0.00390625,13.2656,0}; dir = 360;}; class Object22 {side = 8; vehicle = "Land_BagFence_End_F"; rank = ""; position[] = {2.10168,12.823,0}; dir = 30;}; }; }; class ConstructionSmall { name = $STR_ZECCUP_ConstructionSmall; }; class ConstructionSuppliesLarge { name = $STR_ZECCUP_ConstructionSuppliesLarge; class BaseObjects { name = $STR_ZECCUP_MilitaryDesert_ConstructionSuppliesLarge_BaseObjects; // Credit: 2600K icon = "\a3\Ui_f\data\Map\Markers\Military\unknown_ca.paa"; side = 8; class Object1 {side = 8; vehicle = "CUP_A2_tent_east_ep1"; rank = ""; position[] = {-27.0012,-16.9985,0}; dir = 0;}; class Object2 {side = 8; vehicle = "Land_fortified_nest_small_EP1"; rank = ""; position[] = {-13.541,-18.6165,0}; dir = 0;}; class Object3 {side = 8; vehicle = "Land_Barrack2_EP1"; rank = ""; position[] = {-21,-31.9775,0}; dir = 0;}; class Object4 {side = 8; vehicle = "Land_CamoNetB_EAST_EP1"; rank = ""; position[] = {-29.0452,-0.264404,0}; dir = 0;}; class Object5 {side = 8; vehicle = "Land_CamoNet_EAST_EP1"; rank = ""; position[] = {-29.0242,16.1995,0}; dir = 0;}; class Object6 {side = 8; vehicle = "Land_fortified_nest_big_EP1"; rank = ""; position[] = {-13.4644,-6.72729,0}; dir = 0;}; class Object7 {side = 8; vehicle = "Land_fort_bagfence_round"; rank = ""; position[] = {-4.16406,14.3726,0}; dir = 90;}; class Object8 {side = 8; vehicle = "Land_fort_bagfence_round"; rank = ""; position[] = {-17.3359,14.3774,0}; dir = 270;}; class Object9 {side = 8; vehicle = "Land_fort_bagfence_corner"; rank = ""; position[] = {-15.6545,6.83838,0}; dir = 90;}; class Object10 {side = 8; vehicle = "Land_fort_bagfence_corner"; rank = ""; position[] = {-5.78662,7.40454,0}; dir = 180;}; class Object11 {side = 8; vehicle = "Land_fort_bagfence_long"; rank = ""; position[] = {-13.6096,11.6389,0}; dir = 180;}; class Object12 {side = 8; vehicle = "Land_fort_bagfence_long"; rank = ""; position[] = {-8.98462,8.01392,0}; dir = 180;}; class Object13 {side = 8; vehicle = "Land_fort_bagfence_long"; rank = ""; position[] = {-11.9846,8.01392,0}; dir = 180;}; class Object14 {side = 8; vehicle = "Land_fort_bagfence_long"; rank = ""; position[] = {-10.7346,11.6389,0}; dir = 180;}; class Object15 {side = 8; vehicle = "Land_fort_bagfence_long"; rank = ""; position[] = {-7.85962,11.6389,0}; dir = 180;}; class Object16 {side = 8; vehicle = "FenceWood"; rank = ""; position[] = {-11.0071,16.8921,0}; dir = 270;}; class Object17 {side = 8; vehicle = "Land_CamoNetVar_EAST_EP1"; rank = ""; position[] = {-28.9011,27.3875,0}; dir = 0;}; class Object18 {side = 8; vehicle = "Land_fort_artillery_nest_EP1"; rank = ""; position[] = {-1,-28.6384,0}; dir = 0;}; class Object19 {side = 8; vehicle = "CUP_A2_tent2_west_ep1"; rank = ""; position[] = {27.4854,-22.3569,0}; dir = 0;}; class Object20 {side = 8; vehicle = "Land_Fort_Watchtower_EP1"; rank = ""; position[] = {10.9832,-18.7327,0}; dir = 0;}; class Object21 {side = 8; vehicle = "Land_HBarrier1"; rank = ""; position[] = {-2.99121,-15.0037,0}; dir = 0;}; class Object22 {side = 8; vehicle = "Land_HBarrier1"; rank = ""; position[] = {1.00879,-15.0037,0}; dir = 0;}; class Object23 {side = 8; vehicle = "Land_fort_rampart_EP1"; rank = ""; position[] = {-1,-17.7744,0}; dir = 0;}; class Object24 {side = 8; vehicle = "Land_CamoNetB_NATO_EP1"; rank = ""; position[] = {26.9548,-0.264404,0}; dir = 0;}; class Object25 {side = 8; vehicle = "Land_CamoNet_NATO_EP1"; rank = ""; position[] = {26.9758,16.1995,0}; dir = 0;}; class Object26 {side = 8; vehicle = "Land_HBarrier_large"; rank = ""; position[] = {-1.0127,-4.08545,0}; dir = 0;}; class Object27 {side = 8; vehicle = "Land_HBarrier5"; rank = ""; position[] = {-3.25635,-7.92456,0}; dir = 0;}; class Object28 {side = 8; vehicle = "Land_CncWall4_F"; rank = ""; position[] = {9.03174,-4.26978,0}; dir = 0;}; class Object29 {side = 8; vehicle = "Land_HBarrier3"; rank = ""; position[] = {-2.15674,-12.0356,0}; dir = 0;}; class Object31 {side = 8; vehicle = "Land_CncWall1_F"; rank = ""; position[] = {12.9329,-4.2749,0}; dir = 0;}; class Object32 {side = 8; vehicle = "Land_CncBarrierMedium_F"; rank = ""; position[] = {15,-8.98242,0}; dir = 0;}; class Object33 {side = 8; vehicle = "Land_BagFence_Round_F"; rank = ""; position[] = {3.33984,17.9202,0}; dir = 0;}; class Object34 {side = 8; vehicle = "Land_BagFence_Round_F"; rank = ""; position[] = {11.7075,12.3677,0}; dir = 315;}; class Object35 {side = 8; vehicle = "Land_BagFence_Round_F"; rank = ""; position[] = {10.5898,17.9211,0}; dir = 0;}; class Object36 {side = 8; vehicle = "Land_BagFence_Round_F"; rank = ""; position[] = {6.91016,20.3289,0}; dir = 180;}; class Object37 {side = 8; vehicle = "Land_BagFence_Round_F"; rank = ""; position[] = {3.11768,12.417,0}; dir = 45;}; class Object38 {side = 8; vehicle = "Land_BagFence_Long_F"; rank = ""; position[] = {8.8728,11.9856,0}; dir = 180;}; class Object39 {side = 8; vehicle = "Land_BagFence_Long_F"; rank = ""; position[] = {5.9978,11.9856,0}; dir = 180;}; class Object40 {side = 8; vehicle = "Land_BagFence_Long_F"; rank = ""; position[] = {8.8772,8.0144,0}; dir = 0;}; class Object41 {side = 8; vehicle = "Land_BagFence_Long_F"; rank = ""; position[] = {6.0022,8.01343,0}; dir = 0;}; class Object42 {side = 8; vehicle = "Land_BagFence_Short_F"; rank = ""; position[] = {8.74829,19.136,0}; dir = 225;}; class Object43 {side = 8; vehicle = "Land_BagFence_Short_F"; rank = ""; position[] = {3.86865,6.24048,0}; dir = 90;}; class Object44 {side = 8; vehicle = "Land_BagFence_Short_F"; rank = ""; position[] = {5.11401,19.1233,0}; dir = 135;}; class Object45 {side = 8; vehicle = "Land_BagFence_Short_F"; rank = ""; position[] = {11.2437,6.49097,0}; dir = 90;}; class Object46 {side = 8; vehicle = "Land_BagFence_Corner_F"; rank = ""; position[] = {11.2905,8.00098,0}; dir = 0;}; class Object47 {side = 8; vehicle = "Land_BagFence_Corner_F"; rank = ""; position[] = {3.87402,8.04004,0}; dir = 270;}; class Object48 {side = 8; vehicle = "Land_BagFence_End_F"; rank = ""; position[] = {2.76099,14.699,0}; dir = 270;}; class Object49 {side = 8; vehicle = "Land_BagFence_End_F"; rank = ""; position[] = {4.13794,4.56616,0}; dir = 75;}; class Object50 {side = 8; vehicle = "Land_BagFence_End_F"; rank = ""; position[] = {12.136,14.6995,0}; dir = 270;}; class Object51 {side = 8; vehicle = "Land_BagFence_End_F"; rank = ""; position[] = {11.5129,4.81665,0}; dir = 75;}; class Object52 {side = 8; vehicle = "Land_BagFence_End_F"; rank = ""; position[] = {12.5391,19.2739,0}; dir = 315;}; class Object53 {side = 8; vehicle = "Land_BagFence_End_F"; rank = ""; position[] = {1.86206,19.5574,0}; dir = 255;}; class Object54 {side = 8; vehicle = "Land_CncBarrierMedium4_F"; rank = ""; position[] = {8.97583,-8.98242,0}; dir = 0;}; class Object55 {side = 8; vehicle = "Land_CamoNetVar_NATO_EP1"; rank = ""; position[] = {27.0989,27.3875,0}; dir = 0;}; class Object56 {side = 8; vehicle = "76n6ClamShell_EP1"; rank = ""; position[] = {-1,26.7,0}; dir = 0;}; }; class MiscItems { name = $STR_ZECCUP_MilitaryDesert_ConstructionSuppliesLarge_MiscItems; // Credit: 2600K icon = "\a3\Ui_f\data\Map\Markers\Military\unknown_ca.paa"; side = 8; class Object0 {side = 8; vehicle = "Gunrack1"; rank = ""; position[] = {-2.05981,-13.9353,0}; dir = 90;}; class Object1 {side = 8; vehicle = "Gunrack1"; rank = ""; position[] = {-2.05981,-12.9353,0}; dir = 90;}; class Object2 {side = 8; vehicle = "Land_WoodenTable_large_F"; rank = ""; position[] = {-14.2495,-19,0}; dir = 179.69;}; class Object3 {side = 8; vehicle = "Land_Sacks_heap_F"; rank = ""; position[] = {-14.3098,-13.6853,0}; dir = 0;}; class Object4 {side = 8; vehicle = "FoldTable"; rank = ""; position[] = {-8.12451,-18.5,0}; dir = 270;}; class Object5 {side = 8; vehicle = "Land_CampingTable_F"; rank = ""; position[] = {-1.69043,-18.376,0}; dir = 89.7963;}; class Object6 {side = 8; vehicle = "Land_CampingTable_F"; rank = ""; position[] = {-2.49951,-18.375,0}; dir = 270.001;}; class Object7 {side = 8; vehicle = "Land_Sack_F"; rank = ""; position[] = {-13.8147,-14.4373,0}; dir = 285;}; class Object8 {side = 8; vehicle = "Land_CampingChair_V1_F"; rank = ""; position[] = {-3.05981,-18.8145,0}; dir = 284.979;}; class Object9 {side = 8; vehicle = "Land_CampingChair_V1_F"; rank = ""; position[] = {-1.25122,-18.874,0}; dir = 74.9631;}; class Object10 {side = 8; vehicle = "Land_CampingChair_V1_F"; rank = ""; position[] = {-2.99951,-17.875,0}; dir = 269.967;}; class Object11 {side = 8; vehicle = "Land_CampingChair_V1_F"; rank = ""; position[] = {-0.999512,-17.875,0}; dir = 119.946;}; class Object12 {side = 8; vehicle = "Land_CampingChair_V2_F"; rank = ""; position[] = {-15.2324,-18.5027,0}; dir = 195.009;}; class Object13 {side = 8; vehicle = "Land_CampingChair_V2_F"; rank = ""; position[] = {-13.4824,-19.5027,0}; dir = 75.0083;}; class Object14 {side = 8; vehicle = "Land_CampingChair_V2_F"; rank = ""; position[] = {-13.5471,-18.563,0}; dir = 89.9785;}; class Object15 {side = 8; vehicle = "Land_CampingChair_V2_F"; rank = ""; position[] = {-14.9824,-19.5027,0}; dir = 255.009;}; class Object16 {side = 8; vehicle = "FoldChair"; rank = ""; position[] = {-8.87354,-17.9993,0}; dir = 330;}; class Object17 {side = 8; vehicle = "FoldChair"; rank = ""; position[] = {-8.62549,-18.9988,0}; dir = 255;}; class Object18 {side = 8; vehicle = "FoldChair"; rank = ""; position[] = {-7.37402,-19.0017,0}; dir = 60;}; class Object19 {side = 8; vehicle = "FoldChair"; rank = ""; position[] = {-7.625,-18.0017,0}; dir = 90;}; class Object20 {side = 8; vehicle = "CUP_metalcrate"; rank = ""; position[] = {-7.55981,-13.6853,0}; dir = 0;}; class Object21 {side = 8; vehicle = "CUP_metalcrate_02"; rank = ""; position[] = {-8.30981,-13.6853,0}; dir = 150;}; class Object22 {side = 8; vehicle = "Land_Sack_EP1"; rank = ""; position[] = {-14.4338,-14.5549,0}; dir = 75;}; class Object23 {side = 8; vehicle = "Land_Sacks_heap_F"; rank = ""; position[] = {-15.2495,-13.875,0}; dir = 270;}; class Object24 {side = 8; vehicle = "Land_WoodenTable_large_F"; rank = ""; position[] = {-14.2495,-21.25,0}; dir = 179.69;}; class Object25 {side = 8; vehicle = "Land_CampingChair_V2_F"; rank = ""; position[] = {-15.2495,-21.75,0}; dir = 225.008;}; class Object26 {side = 8; vehicle = "Land_CampingChair_V2_F"; rank = ""; position[] = {-14.8745,-20.75,0}; dir = 270.009;}; class Object27 {side = 8; vehicle = "Land_CampingChair_V2_F"; rank = ""; position[] = {-13.2495,-20.75,0}; dir = 149.977;}; class Object28 {side = 8; vehicle = "Land_CampingChair_V2_F"; rank = ""; position[] = {-13.1245,-21.75,0}; dir = 330.007;}; class Object29 {side = 8; vehicle = "FoldTable"; rank = ""; position[] = {-8.12451,-20.625,0}; dir = 270;}; class Object30 {side = 8; vehicle = "Land_CampingTable_F"; rank = ""; position[] = {-1.69116,-20.3777,0}; dir = 89.9993;}; class Object31 {side = 8; vehicle = "Land_CampingTable_F"; rank = ""; position[] = {-2.49951,-20.375,0}; dir = 270.001;}; class Object32 {side = 8; vehicle = "Land_CampingChair_V1_F"; rank = ""; position[] = {-1.12451,-19.875,0}; dir = 74.9502;}; class Object33 {side = 8; vehicle = "Land_CampingChair_V1_F"; rank = ""; position[] = {-0.874512,-21,0}; dir = 164.972;}; class Object34 {side = 8; vehicle = "Land_CampingChair_V1_F"; rank = ""; position[] = {-3.12451,-19.875,0}; dir = 254.969;}; class Object35 {side = 8; vehicle = "Land_CampingChair_V1_F"; rank = ""; position[] = {-3.24951,-20.875,0}; dir = 239.983;}; class Object36 {side = 8; vehicle = "FoldChair"; rank = ""; position[] = {-8.74951,-20.125,0}; dir = 285;}; class Object37 {side = 8; vehicle = "FoldChair"; rank = ""; position[] = {-8.62549,-21.1238,0}; dir = 255;}; class Object38 {side = 8; vehicle = "FoldChair"; rank = ""; position[] = {-7.49951,-21.125,0}; dir = 120;}; class Object39 {side = 8; vehicle = "FoldChair"; rank = ""; position[] = {-7.24951,-20.125,0}; dir = 195;}; class Object40 {side = 8; vehicle = "Land_TentA_F"; rank = ""; position[] = {-8.91187,-9.38525,0}; dir = 0;}; class Object41 {side = 8; vehicle = "Land_TentA_F"; rank = ""; position[] = {-6.91187,-9.38525,0}; dir = 0;}; class Object42 {side = 8; vehicle = "Misc_concrete_High"; rank = ""; position[] = {-13.8413,-3.57544,0}; dir = 0;}; class Object43 {side = 8; vehicle = "Land_TentDome_F"; rank = ""; position[] = {-8.90405,-4.00806,0}; dir = 225;}; class Object45 {side = 8; vehicle = "Land_CratesWooden_F"; rank = ""; position[] = {-14.0598,-8.6853,0}; dir = 0;}; class Object46 {side = 8; vehicle = "Land_Pallets_F"; rank = ""; position[] = {-8.78857,11.0574,0}; dir = 120;}; class Object47 {side = 8; vehicle = "CUP_vojenska_palanda"; rank = ""; position[] = {-6.79492,1.2439,0}; dir = 0;}; class Object48 {side = 8; vehicle = "CUP_vojenska_palanda"; rank = ""; position[] = {-8.79492,1.3689,0}; dir = 0;}; class Object49 {side = 8; vehicle = "Misc_Backpackheap"; rank = ""; position[] = {-7.62988,6.07959,0}; dir = 210;}; class Object50 {side = 8; vehicle = "Misc_Backpackheap"; rank = ""; position[] = {-8.50073,5.22949,0}; dir = 0;}; class Object51 {side = 8; vehicle = "Land_Pallet_F"; rank = ""; position[] = {-9.56567,11.3743,0}; dir = 224.332;}; class Object52 {side = 8; vehicle = "Land_PaperBox_open_full_F"; rank = ""; position[] = {-2.05981,-3.31958,0}; dir = 0;}; class Object53 {side = 8; vehicle = "Land_PaperBox_open_empty_F"; rank = ""; position[] = {-2.05981,1.31421,0}; dir = 180;}; class Object54 {side = 8; vehicle = "Land_PaperBox_open_empty_F"; rank = ""; position[] = {-0.499512,-3.37549,0}; dir = 180;}; class Object55 {side = 8; vehicle = "CargoNet_01_box_F"; rank = ""; position[] = {-2.30981,-8.1853,0}; dir = 165.001;}; class Object56 {side = 8; vehicle = "CargoNet_01_box_F"; rank = ""; position[] = {-0.624512,-7.75,0}; dir = 180.001;}; class Object57 {side = 8; vehicle = "Land_PaperBox_closed_F"; rank = ""; position[] = {-0.487061,1.25244,0}; dir = 90;}; class Object58 {side = 8; vehicle = "Land_PaperBox_closed_F"; rank = ""; position[] = {-0.862061,6.50244,0}; dir = 90;}; class Object59 {side = 8; vehicle = "Land_PaperBox_closed_F"; rank = ""; position[] = {-2.4939,6.48853,0}; dir = 165;}; class Object60 {side = 8; vehicle = "Land_Pallets_stack_F"; rank = ""; position[] = {-8.80859,15.4382,0}; dir = 360;}; class Object61 {side = 8; vehicle = "Land_Pallets_stack_F"; rank = ""; position[] = {-7.12451,15,0}; dir = 194.999;}; class Object62 {side = 8; vehicle = "Land_WaterBarrel_F"; rank = ""; position[] = {-14.3745,10,0}; dir = 359.995;}; class Object63 {side = 8; vehicle = "Land_WaterBarrel_F"; rank = ""; position[] = {-13.2495,10.625,0}; dir = 359.995;}; class Object64 {side = 8; vehicle = "Body"; rank = ""; position[] = {-14.3918,19.7126,0}; dir = 345;}; class Object65 {side = 8; vehicle = "Land_CratesShabby_F"; rank = ""; position[] = {-15.623,-8.49219,0}; dir = 180;}; class Object66 {side = 8; vehicle = "Body"; rank = ""; position[] = {-13.2449,15.8682,0}; dir = 0;}; class Object67 {side = 8; vehicle = "Body"; rank = ""; position[] = {-14.1199,15.8682,0}; dir = 0;}; class Object68 {side = 8; vehicle = "Body"; rank = ""; position[] = {-14.9949,15.8682,0}; dir = 0;}; class Object69 {side = 8; vehicle = "Land_Pallet_vertical_F"; rank = ""; position[] = {-8.80981,16.4431,0}; dir = 359.996;}; class Object70 {side = 8; vehicle = "Land_PalletTrolley_01_khaki_F"; rank = ""; position[] = {-1.78442,5.51953,0}; dir = 209.324;}; class Object71 {side = 8; vehicle = "Land_PlasticCase_01_large_F"; rank = ""; position[] = {-13.4199,6.1189,0}; dir = 299.997;}; class Object72 {side = 8; vehicle = "Land_MetalCase_01_large_F"; rank = ""; position[] = {-13.6699,0.743896,0}; dir = 299.998;}; class Object73 {side = 8; vehicle = "Barrel5"; rank = ""; position[] = {-1.37451,16.875,0}; dir = 330;}; class Object74 {side = 8; vehicle = "Barrel5"; rank = ""; position[] = {-2.24951,16.875,0}; dir = 195;}; class Object75 {side = 8; vehicle = "Barrel5"; rank = ""; position[] = {-2.0083,15.3235,0}; dir = 300;}; class Object76 {side = 8; vehicle = "Barrel5"; rank = ""; position[] = {-2.68481,15.8147,0}; dir = 120;}; class Object77 {side = 8; vehicle = "Barrel5"; rank = ""; position[] = {-1.93481,16.0647,0}; dir = 0;}; class Object78 {side = 8; vehicle = "Barrel5"; rank = ""; position[] = {-3.12451,16.875,0}; dir = 0;}; class Object79 {side = 8; vehicle = "Barrel1"; rank = ""; position[] = {-2.9353,20.3054,0}; dir = 180;}; class Object80 {side = 8; vehicle = "Barrel1"; rank = ""; position[] = {-2.30981,19.8147,0}; dir = 0;}; class Object81 {side = 8; vehicle = "Land_CratesPlastic_F"; rank = ""; position[] = {-8.93579,9.6936,0}; dir = 225;}; class Object82 {side = 8; vehicle = "Land_MetalBarrel_F"; rank = ""; position[] = {-2.31006,10.1897,0}; dir = 29.9735;}; class Object83 {side = 8; vehicle = "Land_MetalBarrel_F"; rank = ""; position[] = {-1.24951,11.875,0}; dir = 285.006;}; class Object84 {side = 8; vehicle = "Land_MetalBarrel_F"; rank = ""; position[] = {-1.93506,10.9397,0}; dir = 0.00614924;}; class Object85 {side = 8; vehicle = "Land_MetalBarrel_F"; rank = ""; position[] = {-3.12451,11.875,0}; dir = 314.999;}; class Object86 {side = 8; vehicle = "Land_MetalBarrel_F"; rank = ""; position[] = {-2.12451,11.875,0}; dir = 195;}; class Object87 {side = 8; vehicle = "MetalBarrel_burning_F"; rank = ""; position[] = {-1.12451,8.875,0}; dir = 0;}; class Object88 {side = 8; vehicle = "Land_MetalBarrel_empty_F"; rank = ""; position[] = {-2.68481,10.9397,0}; dir = 150;}; class Object89 {side = 8; vehicle = "Land_MetalCase_01_medium_F"; rank = ""; position[] = {-14.5449,0.243896,0}; dir = 209.999;}; class Object90 {side = 8; vehicle = "Land_PlasticCase_01_medium_F"; rank = ""; position[] = {-14.4199,5.8689,0}; dir = 330.001;}; class Object91 {side = 8; vehicle = "Land_MetalCase_01_small_F"; rank = ""; position[] = {-6.91992,-0.256104,0}; dir = 269.993;}; class Object92 {side = 8; vehicle = "Land_MetalCase_01_small_F"; rank = ""; position[] = {-8.91992,-0.131104,0}; dir = 269.994;}; class Object93 {side = 8; vehicle = "Land_MetalCase_01_small_F"; rank = ""; position[] = {-13.7949,-0.131104,0}; dir = 254.995;}; class Object94 {side = 8; vehicle = "Land_PlasticCase_01_small_F"; rank = ""; position[] = {-13.8745,5.375,0}; dir = 59.9988;}; class Object95 {side = 8; vehicle = "Land_TentDome_F"; rank = ""; position[] = {-5.78149,-3.36401,0}; dir = 285;}; class Object96 {side = 8; vehicle = "Misc_cargo_cont_net1"; rank = ""; position[] = {-8.1687,20.6196,0}; dir = 0;}; class Object97 {side = 8; vehicle = "Body"; rank = ""; position[] = {-14.3833,20.7332,0}; dir = 0;}; class Object98 {side = 8; vehicle = "Body"; rank = ""; position[] = {-14.3833,25.8582,0}; dir = 0;}; class Object99 {side = 8; vehicle = "Body"; rank = ""; position[] = {-14.3691,24.8757,0}; dir = 15;}; class Object100 {side = 8; vehicle = "Fort_Crate_wood"; rank = ""; position[] = {-8.81128,25.3167,0}; dir = 0;}; class Object101 {side = 8; vehicle = "Fort_Crate_wood"; rank = ""; position[] = {-7.55371,24.949,0}; dir = 210;}; class Object102 {side = 8; vehicle = "Barrel2"; rank = ""; position[] = {-2.71533,24.9539,0}; dir = 0;}; class Object103 {side = 8; vehicle = "Land_Sack_F"; rank = ""; position[] = {-8.50342,24.4968,0}; dir = 270;}; class Object104 {side = 8; vehicle = "Barrel1"; rank = ""; position[] = {-2.20361,20.6584,0}; dir = 225;}; class Object105 {side = 8; vehicle = "Barrel2"; rank = ""; position[] = {-2.37451,25.625,0}; dir = 0;}; class Object106 {side = 8; vehicle = "Barrel2"; rank = ""; position[] = {-1.82129,25.0667,0}; dir = 0;}; class Object107 {side = 8; vehicle = "Barrel1"; rank = ""; position[] = {-3.24951,21.375,0}; dir = 225;}; class Object108 {side = 8; vehicle = "Barrel1"; rank = ""; position[] = {-2.37451,21.375,0}; dir = 150;}; class Object109 {side = 8; vehicle = "Barrel1"; rank = ""; position[] = {-1.49951,21.375,0}; dir = 45;}; class Object110 {side = 8; vehicle = "Barrel2"; rank = ""; position[] = {-2.37451,26.625,0}; dir = 0;}; class Object111 {side = 8; vehicle = "Barrel2"; rank = ""; position[] = {-3.16772,26.6172,0}; dir = 240;}; class Object112 {side = 8; vehicle = "Barrel2"; rank = ""; position[] = {-1.49951,26.625,0}; dir = 120;}; class Object113 {side = 8; vehicle = "AmmoCrates_NoInteractive_Large"; rank = ""; position[] = {3.41626,-18.1306,0}; dir = 0;}; class Object114 {side = 8; vehicle = "Gunrack1"; rank = ""; position[] = {3.97998,-12.9475,0}; dir = 90;}; class Object115 {side = 8; vehicle = "Gunrack1"; rank = ""; position[] = {3.97998,-13.9475,0}; dir = 90;}; class Object116 {side = 8; vehicle = "AmmoCrates_NoInteractive_Medium"; rank = ""; position[] = {4.23779,-19.7253,0}; dir = 90;}; class Object117 {side = 8; vehicle = "Land_PowerGenerator_F"; rank = ""; position[] = {11.1257,-14.1406,0}; dir = 180;}; class Object118 {side = 8; vehicle = "PowerGenerator"; rank = ""; position[] = {8.62549,-14.125,0}; dir = 0;}; class Object119 {side = 8; vehicle = "PowerGenerator_EP1"; rank = ""; position[] = {9.87549,-14.125,0}; dir = 0;}; class Object120 {side = 8; vehicle = "AmmoCrate_NoInteractive_"; rank = ""; position[] = {3.35791,-19.6526,0}; dir = 90;}; class Object121 {side = 8; vehicle = "Land_Sleeping_bag_F"; rank = ""; position[] = {8.5708,-19.6721,0}; dir = 330;}; class Object122 {side = 8; vehicle = "Land_Sleeping_bag_brown_F"; rank = ""; position[] = {10.9802,-18.5894,0}; dir = 15;}; class Object123 {side = 8; vehicle = "Land_Ground_sheet_yellow_F"; rank = ""; position[] = {11.376,-20.6255,0}; dir = 225;}; class Object124 {side = 8; vehicle = "Land_Ground_sheet_blue_F"; rank = ""; position[] = {9.68945,-18.9353,0}; dir = 0;}; class Object125 {side = 8; vehicle = "Land_Sleeping_bag_folded_F"; rank = ""; position[] = {11.7505,-19.9761,0}; dir = 180;}; class Object126 {side = 8; vehicle = "Land_Sleeping_bag_brown_folded_F"; rank = ""; position[] = {9.43945,-18.6846,0}; dir = 134.999;}; class Object127 {side = 8; vehicle = "Land_Ground_sheet_folded_yellow_F"; rank = ""; position[] = {11.3394,-18.4688,0}; dir = 255.027;}; class Object128 {side = 8; vehicle = "Land_Ground_sheet_folded_F"; rank = ""; position[] = {8.06763,-19.7253,0}; dir = 285.006;}; class Object129 {side = 8; vehicle = "Land_Pillow_old_F"; rank = ""; position[] = {10.8479,-18.3123,0}; dir = 210.032;}; class Object130 {side = 8; vehicle = "Land_Pillow_old_F"; rank = ""; position[] = {8.38696,-19.688,0}; dir = 119.974;}; class Object131 {side = 8; vehicle = "Land_Pillow_F"; rank = ""; position[] = {11.8611,-20.3379,0}; dir = 180.056;}; class Object132 {side = 8; vehicle = "Land_Pillow_camouflage_F"; rank = ""; position[] = {9.85059,-18.1877,0}; dir = 195.057;}; class Object133 {side = 8; vehicle = "AmmoCrates_NoInteractive_Small"; rank = ""; position[] = {4.60498,-18.1484,0}; dir = 90;}; class Object134 {side = 8; vehicle = "GunrackUS_EP1"; rank = ""; position[] = {3.84009,-8.62671,0}; dir = 90;}; class Object135 {side = 8; vehicle = "GunrackUS_EP1"; rank = ""; position[] = {3.84009,-7.62671,0}; dir = 90;}; class Object136 {side = 8; vehicle = "Land_WaterTank_F"; rank = ""; position[] = {9.75049,1,0}; dir = 0.000245535;}; class Object137 {side = 8; vehicle = "CUP_hromada_beden_dekorativniX"; rank = ""; position[] = {3.44019,5.5647,0}; dir = 0;}; class Object138 {side = 8; vehicle = "GunrackTK_EP1"; rank = ""; position[] = {4.02051,-3.91626,0}; dir = 90;}; class Object139 {side = 8; vehicle = "GunrackTK_EP1"; rank = ""; position[] = {4.02051,-2.91626,0}; dir = 90;}; class Object140 {side = 8; vehicle = "CUP_ammobednaX"; rank = ""; position[] = {3.69458,1.54272,0}; dir = 0;}; class Object141 {side = 8; vehicle = "Land_Pallet_MilBoxes_F"; rank = ""; position[] = {10.615,-4.37744,0}; dir = 90;}; class Object142 {side = 8; vehicle = "Land_Pallet_MilBoxes_F"; rank = ""; position[] = {10.636,-2.74756,0}; dir = 270;}; class Object143 {side = 8; vehicle = "Land_Pallet_MilBoxes_F"; rank = ""; position[] = {9.00293,-4.3855,0}; dir = 0;}; class Object144 {side = 8; vehicle = "Land_MapBoard_F"; rank = ""; position[] = {8.74927,-7.61963,0}; dir = 345.035;}; class Object145 {side = 8; vehicle = "CUP_A2_barels2"; rank = ""; position[] = {9.83374,16.4065,0}; dir = 45;}; class Object146 {side = 8; vehicle = "CUP_A2_barels3"; rank = ""; position[] = {8.42212,15.4233,0}; dir = 75;}; class Object147 {side = 8; vehicle = "Barrels"; rank = ""; position[] = {8.87549,19.875,0}; dir = 60;}; class Object148 {side = 8; vehicle = "Barrels"; rank = ""; position[] = {10.6738,19.8572,0}; dir = 105;}; class Object149 {side = 8; vehicle = "Land_Sacks_goods_F"; rank = ""; position[] = {9.69092,6.32788,0}; dir = 0;}; class Object150 {side = 8; vehicle = "CargoNet_01_barrels_F"; rank = ""; position[] = {10.7505,9.625,0}; dir = 105.001;}; class Object151 {side = 8; vehicle = "CargoNet_01_barrels_F"; rank = ""; position[] = {9.12549,10.375,0}; dir = 165.002;}; class Object152 {side = 8; vehicle = "Notice_board"; rank = ""; position[] = {9.00049,-9,0}; dir = 15;}; class Object153 {side = 8; vehicle = "CUP_bedna_ammo2X"; rank = ""; position[] = {4.19019,-0.435303,0}; dir = 270;}; class Object154 {side = 8; vehicle = "Barrel6"; rank = ""; position[] = {4.06519,11.1897,0}; dir = 0;}; class Object155 {side = 8; vehicle = "Barrel6"; rank = ""; position[] = {3.75049,12.125,0}; dir = 120;}; class Object156 {side = 8; vehicle = "Barrel6"; rank = ""; position[] = {3.99707,10.3611,0}; dir = 135;}; class Object157 {side = 8; vehicle = "Barrel6"; rank = ""; position[] = {3.31519,10.8147,0}; dir = 120;}; class Object158 {side = 8; vehicle = "Barrel6"; rank = ""; position[] = {3.00049,12.125,0}; dir = 210;}; class Object159 {side = 8; vehicle = "Barrel6"; rank = ""; position[] = {4.50049,12.125,0}; dir = 60;}; class Object160 {side = 8; vehicle = "Barrel4"; rank = ""; position[] = {2.87549,16.875,0}; dir = 0;}; class Object161 {side = 8; vehicle = "Barrel4"; rank = ""; position[] = {4.11182,15.7507,0}; dir = 0;}; class Object162 {side = 8; vehicle = "Barrel4"; rank = ""; position[] = {4.50049,16.875,0}; dir = 150;}; class Object163 {side = 8; vehicle = "Barrel4"; rank = ""; position[] = {3.44019,16.0647,0}; dir = 0;}; class Object164 {side = 8; vehicle = "Barrel4"; rank = ""; position[] = {3.75049,16.875,0}; dir = 315;}; class Object165 {side = 8; vehicle = "Barrel4"; rank = ""; position[] = {3.34204,15.3469,0}; dir = 105;}; class Object166 {side = 8; vehicle = "Barrel3"; rank = ""; position[] = {3.39478,19.9353,0}; dir = 60;}; class Object167 {side = 8; vehicle = "Barrel3"; rank = ""; position[] = {3.94019,20.4397,0}; dir = 15;}; class Object168 {side = 8; vehicle = "Land_Sack_EP1"; rank = ""; position[] = {9.06592,5.69507,0}; dir = 75;}; class Object169 {side = 8; vehicle = "Land_Ammobox_rounds_F"; rank = ""; position[] = {4.43994,0.814697,0}; dir = 329.986;}; class Object170 {side = 8; vehicle = "Land_Ammobox_rounds_F"; rank = ""; position[] = {4.06519,0.939697,0}; dir = 119.984;}; class Object171 {side = 8; vehicle = "Land_stand_small_EP1"; rank = ""; position[] = {9.87549,4.86792,0}; dir = 0;}; class Object172 {side = 8; vehicle = "MapBoard_seismic_F"; rank = ""; position[] = {10.5005,-7.36963,0}; dir = 0.00945563;}; class Object173 {side = 8; vehicle = "MapBoard_altis_F"; rank = ""; position[] = {11.0032,-8.87061,0}; dir = 29.9983;}; class Object174 {side = 8; vehicle = "Barrel3"; rank = ""; position[] = {2.62549,21.375,0}; dir = 15;}; class Object175 {side = 8; vehicle = "Barrel3"; rank = ""; position[] = {3.06519,20.6897,0}; dir = 0;}; class Object176 {side = 8; vehicle = "Barrel3"; rank = ""; position[] = {3.37549,21.375,0}; dir = 210;}; class Object177 {side = 8; vehicle = "Land_BarrelEmpty_grey_F"; rank = ""; position[] = {10.1899,25.8147,0}; dir = 359.981;}; class Object178 {side = 8; vehicle = "Land_BarrelTrash_F"; rank = ""; position[] = {4.18994,26.0647,0}; dir = 359.981;}; class Object179 {side = 8; vehicle = "Land_BarrelWater_grey_F"; rank = ""; position[] = {8.93994,24.5647,0}; dir = 359.981;}; class Object180 {side = 8; vehicle = "Land_BarrelSand_grey_F"; rank = ""; position[] = {10.1899,24.5647,0}; dir = 359.981;}; class Object181 {side = 8; vehicle = "Land_BarrelWater_F"; rank = ""; position[] = {4.18994,24.8147,0}; dir = 359.981;}; class Object182 {side = 8; vehicle = "Land_BarrelSand_F"; rank = ""; position[] = {2.93994,26.0647,0}; dir = 359.981;}; class Object183 {side = 8; vehicle = "Land_BarrelEmpty_F"; rank = ""; position[] = {2.93994,24.8147,0}; dir = 359.981;}; class Object184 {side = 8; vehicle = "Land_BarrelTrash_grey_F"; rank = ""; position[] = {8.93994,25.8147,0}; dir = 359.981;}; class Object185 {side = 8; vehicle = "Barrel3"; rank = ""; position[] = {4.12549,21.375,0}; dir = 270;}; }; class ExternalItems { name = $STR_ZECCUP_MilitaryDesert_ConstructionSuppliesLarge_ExternalItems; // Credit: 2600K icon = "\a3\Ui_f\data\Map\Markers\Military\unknown_ca.paa"; side = 8; class Object0 {side = 8; vehicle = "Land_ScrapHeap_1_F"; rank = ""; position[] = {-12.1576,-17.9597,0}; dir = 0;}; class Object1 {side = 8; vehicle = "WaterPump_01_forest_F"; rank = ""; position[] = {-3.25,-18.125,0}; dir = 0.00178549;}; class Object2 {side = 8; vehicle = "WaterPump_01_sand_F"; rank = ""; position[] = {-7.25,-18.125,0}; dir = 0.00329663;}; class Object3 {side = 8; vehicle = "Misc_cargo_cont_small2"; rank = ""; position[] = {-12.2482,-12.1199,0}; dir = 0;}; class Object4 {side = 8; vehicle = "Land_HBarrier_1_F"; rank = ""; position[] = {-4.37549,-12.877,0}; dir = 0;}; class Object5 {side = 8; vehicle = "Land_HBarrier_1_F"; rank = ""; position[] = {-6.37549,-12.877,0}; dir = 0;}; class Object6 {side = 8; vehicle = "Land_Cargo20_military_green_F"; rank = ""; position[] = {-17.25,-12.875,0}; dir = 270;}; class Object7 {side = 8; vehicle = "Land_Cargo10_military_green_F"; rank = ""; position[] = {-17.25,-18.125,0}; dir = 270;}; class Object8 {side = 8; vehicle = "Land_HBarrier5"; rank = ""; position[] = {-7.88171,7.70605,0}; dir = 0;}; class Object9 {side = 8; vehicle = "Land_Ind_TankSmall2"; rank = ""; position[] = {-12.2843,1.87646,0}; dir = 90;}; class Object10 {side = 8; vehicle = "Land_Cargo20_sand_F"; rank = ""; position[] = {-17.25,15.125,0}; dir = 270;}; class Object11 {side = 8; vehicle = "Land_Cargo20_grey_F"; rank = ""; position[] = {-17.25,0.125,0}; dir = 270;}; class Object12 {side = 8; vehicle = "Land_obstacle_run_duck"; rank = ""; position[] = {-5.84155,18.6313,0}; dir = 0;}; class Object13 {side = 8; vehicle = "Land_HBarrier_5_F"; rank = ""; position[] = {-7.62427,-5.62354,0}; dir = 0;}; class Object14 {side = 8; vehicle = "Land_HBarrier3"; rank = ""; position[] = {-6.7821,3.84473,0}; dir = 0;}; class Object15 {side = 8; vehicle = "Misc_cargo_cont_small"; rank = ""; position[] = {-12.2512,-5.12622,0}; dir = 0;}; class Object16 {side = 8; vehicle = "Land_Cargo10_sand_F"; rank = ""; position[] = {-17.25,9.875,0}; dir = 270;}; class Object17 {side = 8; vehicle = "Land_Cargo10_grey_F"; rank = ""; position[] = {-17.25,-5.125,0}; dir = 270;}; class Object18 {side = 8; vehicle = "Land_obstacle_get_over"; rank = ""; position[] = {-5.02881,13.2407,0}; dir = 0;}; class Object19 {side = 8; vehicle = "Land_HBarrier_3_F"; rank = ""; position[] = {-6.48938,-9.14258,0}; dir = 0;}; class Object20 {side = 8; vehicle = "Land_HBarrier1"; rank = ""; position[] = {-4.6167,1.12695,0}; dir = 0;}; class Object21 {side = 8; vehicle = "Land_HBarrier1"; rank = ""; position[] = {-6.8667,1.12695,0}; dir = 0;}; class Object22 {side = 8; vehicle = "Land_Pipes_large_F"; rank = ""; position[] = {-10.1986,11.8413,0}; dir = 90;}; class Object23 {side = 8; vehicle = "Land_Pipes_small_F"; rank = ""; position[] = {-10.2567,17.8672,0}; dir = 89.9999;}; class Object24 {side = 8; vehicle = "Land_Ind_TankSmall"; rank = ""; position[] = {-12.2843,11.8765,0}; dir = 90;}; class Object25 {side = 8; vehicle = "Misc_cargo_cont_net3"; rank = ""; position[] = {-12.8037,33.6946,0}; dir = 0;}; class Object26 {side = 8; vehicle = "Land_obstacle_prone"; rank = ""; position[] = {-5.42224,25.4561,0}; dir = 0;}; class Object27 {side = 8; vehicle = "Land_IronPipes_F"; rank = ""; position[] = {-11.9547,25.9565,0}; dir = 270;}; class Object28 {side = 8; vehicle = "Misc_cargo_cont_net2"; rank = ""; position[] = {-6.22131,32.1306,0}; dir = 0;}; class Object29 {side = 8; vehicle = "Land_Misc_IronPipes_EP1"; rank = ""; position[] = {-14.4607,24.6724,0}; dir = 90;}; class Object30 {side = 8; vehicle = "Land_BagFence_Round_F"; rank = ""; position[] = {11.4988,-14.7092,0}; dir = 45;}; class Object31 {side = 8; vehicle = "Land_BagFence_Round_F"; rank = ""; position[] = {20.0886,-14.7588,0}; dir = 315;}; class Object32 {side = 8; vehicle = "Land_BagFenceRound"; rank = ""; position[] = {7.20386,-14.3687,0}; dir = 315;}; class Object33 {side = 8; vehicle = "Land_BagFenceRound"; rank = ""; position[] = {1.75024,-14.324,0}; dir = 45;}; class Object34 {side = 8; vehicle = "Land_BagFence_Long_F"; rank = ""; position[] = {17.1211,-17.6089,0}; dir = 0;}; class Object35 {side = 8; vehicle = "Land_BagFence_Long_F"; rank = ""; position[] = {14.2461,-17.6094,0}; dir = 0;}; class Object36 {side = 8; vehicle = "Land_BagFence_Long_F"; rank = ""; position[] = {17.2539,-15.1406,0}; dir = 180;}; class Object37 {side = 8; vehicle = "Land_BagFence_Long_F"; rank = ""; position[] = {14.3789,-15.1406,0}; dir = 180;}; class Object38 {side = 8; vehicle = "Land_BagFenceLong"; rank = ""; position[] = {4.37061,-17.729,0}; dir = 0;}; class Object39 {side = 8; vehicle = "Land_BagFenceLong"; rank = ""; position[] = {4.49561,-14.729,0}; dir = 0;}; class Object40 {side = 8; vehicle = "Land_BagFence_Short_F"; rank = ""; position[] = {12.1125,-19.3826,0}; dir = 90;}; class Object41 {side = 8; vehicle = "Land_BagFence_Short_F"; rank = ""; position[] = {19.4875,-19.1321,0}; dir = 90;}; class Object42 {side = 8; vehicle = "Land_BagFenceShort"; rank = ""; position[] = {2.37598,-19.6091,0}; dir = 90;}; class Object43 {side = 8; vehicle = "Land_BagFenceShort"; rank = ""; position[] = {6.62598,-19.2341,0}; dir = 90;}; class Object44 {side = 8; vehicle = "Land_BagFence_Corner_F"; rank = ""; position[] = {19.5344,-17.6218,0}; dir = 0;}; class Object45 {side = 8; vehicle = "Land_BagFence_Corner_F"; rank = ""; position[] = {12.1179,-17.583,0}; dir = 270;}; class Object46 {side = 8; vehicle = "Land_BagFenceCorner"; rank = ""; position[] = {2.38916,-17.7344,0}; dir = 270;}; class Object47 {side = 8; vehicle = "Land_BagFenceCorner"; rank = ""; position[] = {6.65845,-17.7097,0}; dir = 0;}; class Object48 {side = 8; vehicle = "Land_BagFence_End_F"; rank = ""; position[] = {11.1421,-12.4275,0}; dir = 270;}; class Object49 {side = 8; vehicle = "Land_BagFence_End_F"; rank = ""; position[] = {20.5171,-12.427,0}; dir = 270;}; class Object50 {side = 8; vehicle = "Land_BagFence_End_F"; rank = ""; position[] = {12.3818,-21.0569,0}; dir = 75;}; class Object51 {side = 8; vehicle = "Land_BagFenceEnd"; rank = ""; position[] = {6.87305,-20.9202,0}; dir = 75;}; class Object52 {side = 8; vehicle = "Land_BagFenceEnd"; rank = ""; position[] = {0.987793,-12.2449,0}; dir = 240;}; class Object53 {side = 8; vehicle = "Land_BagFence_End_F"; rank = ""; position[] = {19.7568,-20.8064,0}; dir = 75;}; class Object54 {side = 8; vehicle = "Hhedgehog_concreteBig"; rank = ""; position[] = {15.1245,8.38037,0}; dir = 0;}; class Object55 {side = 8; vehicle = "Hhedgehog_concreteBig"; rank = ""; position[] = {5.62451,8.38037,0}; dir = 0;}; class Object56 {side = 8; vehicle = "Hhedgehog_concrete"; rank = ""; position[] = {5.62231,13.6304,0}; dir = 0;}; class Object57 {side = 8; vehicle = "Hhedgehog_concrete"; rank = ""; position[] = {14.7473,13.6304,0}; dir = 0;}; class Object58 {side = 8; vehicle = "Land_Razorwire_F"; rank = ""; position[] = {3.02075,-0.802246,0}; dir = 0;}; class Object59 {side = 8; vehicle = "Land_Razorwire_F"; rank = ""; position[] = {11.5208,-0.802246,0}; dir = 0;}; class Object60 {side = 8; vehicle = "Fort_RazorWire"; rank = ""; position[] = {11.3958,-3.30225,0}; dir = 0;}; class Object61 {side = 8; vehicle = "Fort_RazorWire"; rank = ""; position[] = {3.02075,-3.30225,0}; dir = 0;}; class Object62 {side = 8; vehicle = "Wire"; rank = ""; position[] = {1.78223,2.6958,0}; dir = 0;}; class Object63 {side = 8; vehicle = "Wire"; rank = ""; position[] = {8.91455,2.49536,0}; dir = 15;}; class Object64 {side = 8; vehicle = "Wire"; rank = ""; position[] = {14.8684,2.6189,0}; dir = 165;}; class Object65 {side = 8; vehicle = "Land_fort_bagfence_corner"; rank = ""; position[] = {1.91113,17.7258,0}; dir = 0;}; class Object66 {side = 8; vehicle = "Land_Garbage_square5_F"; rank = ""; position[] = {17.0374,19.9521,0}; dir = 0;}; class Object67 {side = 8; vehicle = "Land_GarbagePallet_F"; rank = ""; position[] = {17.0244,19.8438,0}; dir = 0;}; class Object68 {side = 8; vehicle = "Land_fort_bagfence_long"; rank = ""; position[] = {6.3606,18.3958,0}; dir = 90;}; class Object69 {side = 8; vehicle = "FenceWoodPalet"; rank = ""; position[] = {15.3674,-5.53516,0}; dir = 270;}; class Object70 {side = 8; vehicle = "Land_BagFence_Round_F"; rank = ""; position[] = {19.4709,-11.2056,0}; dir = 0;}; class Object71 {side = 8; vehicle = "Land_BagFence_Round_F"; rank = ""; position[] = {12.2209,-11.2061,0}; dir = 0;}; class Object72 {side = 8; vehicle = "Land_BagFence_Round_F"; rank = ""; position[] = {15.7913,-8.79736,0}; dir = 180;}; class Object73 {side = 8; vehicle = "Land_BagFenceRound"; rank = ""; position[] = {7.09277,-10.0654,0}; dir = 0;}; class Object74 {side = 8; vehicle = "Land_BagFenceRound"; rank = ""; position[] = {4.65625,-8.67383,0}; dir = 180;}; class Object75 {side = 8; vehicle = "Land_BagFenceRound"; rank = ""; position[] = {2.21777,-9.81543,0}; dir = 0;}; class Object76 {side = 8; vehicle = "CUP_A2_ohrada_popelnice_roh"; rank = ""; position[] = {7.82446,-5.79468,0}; dir = 0;}; class Object77 {side = 8; vehicle = "FenceWood"; rank = ""; position[] = {11.8821,-5.39209,0}; dir = 90;}; class Object78 {side = 8; vehicle = "Land_CncBarrier_F"; rank = ""; position[] = {9.7478,17.8672,0}; dir = 0;}; class Object79 {side = 8; vehicle = "Land_CncBarrier_F"; rank = ""; position[] = {12.7478,17.8672,0}; dir = 0;}; class Object80 {side = 8; vehicle = "Land_CncBarrier_stripes_F"; rank = ""; position[] = {12.75,18.8672,0}; dir = 0;}; class Object81 {side = 8; vehicle = "Land_CncBarrier_stripes_F"; rank = ""; position[] = {9.75,18.8672,0}; dir = 0;}; class Object82 {side = 8; vehicle = "Land_CncBlock_D"; rank = ""; position[] = {12.741,16.9924,0}; dir = 0;}; class Object83 {side = 8; vehicle = "Land_CncBlock_D"; rank = ""; position[] = {9.74097,16.9924,0}; dir = 0;}; class Object84 {side = 8; vehicle = "Land_CncBlock_Stripes"; rank = ""; position[] = {12.7622,19.9448,0}; dir = 0;}; class Object85 {side = 8; vehicle = "Land_CncBlock_Stripes"; rank = ""; position[] = {9.76221,19.9448,0}; dir = 0;}; class Object86 {side = 8; vehicle = "Land_BagFence_Short_F"; rank = ""; position[] = {17.6294,-9.99048,0}; dir = 225;}; class Object87 {side = 8; vehicle = "Land_BagFence_Short_F"; rank = ""; position[] = {13.9951,-10.0029,0}; dir = 135;}; class Object88 {side = 8; vehicle = "Land_Pneu"; rank = ""; position[] = {18.25,18.375,0}; dir = 0;}; class Object89 {side = 8; vehicle = "CUP_A2_ohrada_popelnice"; rank = ""; position[] = {5.4231,-5.93555,0}; dir = 90;}; class Object90 {side = 8; vehicle = "CUP_A2_ohrada_popelnice"; rank = ""; position[] = {5.41309,-5.78564,0}; dir = 270;}; class Object91 {side = 8; vehicle = "CUP_A2_ohrada_popelnice"; rank = ""; position[] = {4.4231,-5.93555,0}; dir = 90;}; class Object92 {side = 8; vehicle = "CUP_A2_ohrada_popelnice"; rank = ""; position[] = {3.4231,-5.93555,0}; dir = 90;}; class Object93 {side = 8; vehicle = "Land_BagFence_End_F"; rank = ""; position[] = {10.7432,-9.56909,0}; dir = 255;}; class Object94 {side = 8; vehicle = "Land_BagFence_End_F"; rank = ""; position[] = {21.4202,-9.85254,0}; dir = 315;}; class Object95 {side = 8; vehicle = "Land_BagFenceEnd"; rank = ""; position[] = {9.18823,-9.51782,0}; dir = 0;}; class Object97 {side = 8; vehicle = "Land_fort_rampart_EP1"; rank = ""; position[] = {5.52441,28.875,0}; dir = 270;}; class Object98 {side = 8; vehicle = "Land_fort_bagfence_round"; rank = ""; position[] = {3.63647,22.2454,0}; dir = 0;}; class Object99 {side = 8; vehicle = "Land_GarbageBags_F"; rank = ""; position[] = {16.8347,30.9905,0}; dir = 0;}; class Object100 {side = 8; vehicle = "Land_Garbage_square5_F"; rank = ""; position[] = {17.1624,31.7021,0}; dir = 0;}; class Object101 {side = 8; vehicle = "Land_Garbage_square5_F"; rank = ""; position[] = {16.9124,25.9521,0}; dir = 0;}; class Object102 {side = 8; vehicle = "Land_GarbageWashingMachine_F"; rank = ""; position[] = {16.8801,25.7026,0}; dir = 0;}; class Object103 {side = 8; vehicle = "CUP_A2_windbreak"; rank = ""; position[] = {11.1621,21.8574,0}; dir = 180;}; class Object104 {side = 8; vehicle = "Hedgehog"; rank = ""; position[] = {10.9116,28.7188,0}; dir = 30;}; class Object105 {side = 8; vehicle = "Hedgehog"; rank = ""; position[] = {11.8438,24.9634,0}; dir = 120;}; class Object106 {side = 8; vehicle = "Hedgehog"; rank = ""; position[] = {12.4961,32.4963,0}; dir = 255;}; class Object107 {side = 8; vehicle = "Land_fort_rampart"; rank = ""; position[] = {1.97559,28.875,0}; dir = 90;}; class Object108 {side = 8; vehicle = "Land_Pneu"; rank = ""; position[] = {15.5,24.375,0}; dir = 0;}; }; class Walls { name = $STR_ZECCUP_MilitaryDesert_ConstructionSuppliesLarge_Walls; // Credit: 2600K icon = "\a3\Ui_f\data\Map\Markers\Military\unknown_ca.paa"; side = 8; class Object1 {side = 8; vehicle = "Hhedgehog_concreteBig"; rank = ""; position[] = {-17,-10,0}; dir = 0;}; class Object2 {side = 8; vehicle = "Hhedgehog_concreteBig"; rank = ""; position[] = {-27,-10,0}; dir = 0;}; class Object3 {side = 8; vehicle = "Hhedgehog_concreteBig"; rank = ""; position[] = {-37,-10,0}; dir = 0;}; class Object4 {side = 8; vehicle = "Hhedgehog_concrete"; rank = ""; position[] = {-28.002,-2,0}; dir = 0;}; class Object5 {side = 8; vehicle = "Hhedgehog_concrete"; rank = ""; position[] = {-37.002,-2,0}; dir = 0;}; class Object6 {side = 8; vehicle = "Hhedgehog_concrete"; rank = ""; position[] = {-19.002,-2,0}; dir = 0;}; class Object7 {side = 8; vehicle = "Land_Razorwire_F"; rank = ""; position[] = {-22.7288,2.06738,0}; dir = 0;}; class Object8 {side = 8; vehicle = "Land_Razorwire_F"; rank = ""; position[] = {-30.7288,2.06738,0}; dir = 0;}; class Object9 {side = 8; vehicle = "Land_Razorwire_F"; rank = ""; position[] = {-38.7288,2.06738,0}; dir = 0;}; class Object10 {side = 8; vehicle = "Fort_RazorWire"; rank = ""; position[] = {-38.7288,6.06738,0}; dir = 0;}; class Object11 {side = 8; vehicle = "Fort_RazorWire"; rank = ""; position[] = {-30.7288,6.06738,0}; dir = 0;}; class Object12 {side = 8; vehicle = "Fort_RazorWire"; rank = ""; position[] = {-22.7288,6.06738,0}; dir = 0;}; class Object13 {side = 8; vehicle = "Wire"; rank = ""; position[] = {-30.2173,-5.93457,0}; dir = 0;}; class Object14 {side = 8; vehicle = "Wire"; rank = ""; position[] = {-37.2173,-5.93457,0}; dir = 0;}; class Object15 {side = 8; vehicle = "CUP_A2_pletivo_wired_hole"; rank = ""; position[] = {-30.9827,10.1724,0}; dir = 0;}; class Object16 {side = 8; vehicle = "CUP_A2_pletivo_wired"; rank = ""; position[] = {-24.9827,10.1147,0}; dir = 0;}; class Object17 {side = 8; vehicle = "CUP_A2_pletivo_wired"; rank = ""; position[] = {-36.9827,10.1147,0}; dir = 0;}; class Object18 {side = 8; vehicle = "CUP_A2_pletivo_wired_branap"; rank = ""; position[] = {-19.5208,10.1147,0}; dir = 0;}; class Object19 {side = 8; vehicle = "CUP_A2_pletivo_wired_slope"; rank = ""; position[] = {-14.9897,10.1147,0}; dir = 0;}; class Object20 {side = 8; vehicle = "Wire"; rank = ""; position[] = {-22.2173,-5.93457,0}; dir = 0;}; class Object21 {side = 8; vehicle = "Land_IndFnc_9_F"; rank = ""; position[] = {-34.4976,17.9402,0}; dir = 0;}; class Object22 {side = 8; vehicle = "Land_Net_FenceD_8m_F"; rank = ""; position[] = {-15.0178,20.8816,0}; dir = 0;}; class Object23 {side = 8; vehicle = "Land_Net_Fence_8m_F"; rank = ""; position[] = {-33.0137,21,0}; dir = 0;}; class Object24 {side = 8; vehicle = "Land_Net_Fence_Gate_F"; rank = ""; position[] = {-25,21,0}; dir = 0;}; class Object25 {side = 8; vehicle = "Land_IndFnc_Corner_F"; rank = ""; position[] = {-21.0022,16.4192,0}; dir = 90;}; class Object26 {side = 8; vehicle = "Land_IndFnc_3_Hole_F"; rank = ""; position[] = {-22.4971,17.9683,0}; dir = 0;}; class Object27 {side = 8; vehicle = "Land_IndFnc_3_F"; rank = ""; position[] = {-37.4976,17.9978,0}; dir = 0;}; class Object28 {side = 8; vehicle = "Land_IndFnc_3_F"; rank = ""; position[] = {-25.4976,17.9978,0}; dir = 0;}; class Object29 {side = 8; vehicle = "Fence_Ind"; rank = ""; position[] = {-36.9976,13.9978,0}; dir = 0;}; class Object30 {side = 8; vehicle = "Land_Net_Fence_4m_F"; rank = ""; position[] = {-23.012,21,0}; dir = 0;}; class Object31 {side = 8; vehicle = "Fence_Ind_long"; rank = ""; position[] = {-32.4976,13.9368,0}; dir = 0;}; class Object32 {side = 8; vehicle = "Land_fort_rampart_EP1"; rank = ""; position[] = {16.2256,-8,0}; dir = 90;}; class Object33 {side = 8; vehicle = "Base_WarfareBBarrier10x"; rank = ""; position[] = {0.0441895,11.0581,0}; dir = 0;}; class Object34 {side = 8; vehicle = "Land_HBarrier_large"; rank = ""; position[] = {5.9873,-4.08545,0}; dir = 0;}; class Object35 {side = 8; vehicle = "Land_HBarrier_Big_F"; rank = ""; position[] = {-6.03516,-4.08228,0}; dir = 0;}; class Object36 {side = 8; vehicle = "Land_HBarrier5"; rank = ""; position[] = {3.74365,-7.92456,0}; dir = 0;}; class Object37 {side = 8; vehicle = "Land_HBarrier_5_F"; rank = ""; position[] = {-8.24878,-8.00391,0}; dir = 0;}; class Object38 {side = 8; vehicle = "Land_HBarrier3"; rank = ""; position[] = {4.84326,-12.0356,0}; dir = 0;}; class Object39 {side = 8; vehicle = "zed_kamenna"; rank = ""; position[] = {-0.44043,5.83081,0}; dir = 0;}; class Object40 {side = 8; vehicle = "zed_kamenna"; rank = ""; position[] = {-4.44043,5.83081,0}; dir = 0;}; class Object41 {side = 8; vehicle = "zed_kamenna"; rank = ""; position[] = {7.55957,5.83081,0}; dir = 0;}; class Object42 {side = 8; vehicle = "zed_kamenna"; rank = ""; position[] = {-8.44043,5.83081,0}; dir = 0;}; class Object43 {side = 8; vehicle = "zed_kamenna"; rank = ""; position[] = {3.55957,5.83081,0}; dir = 0;}; class Object44 {side = 8; vehicle = "zed_kamenna_desert"; rank = ""; position[] = {3.55957,1.83081,0}; dir = 0;}; class Object45 {side = 8; vehicle = "zed_kamenna_desert"; rank = ""; position[] = {-0.44043,1.83081,0}; dir = 0;}; class Object46 {side = 8; vehicle = "zed_kamenna_desert"; rank = ""; position[] = {7.55957,1.83081,0}; dir = 0;}; class Object47 {side = 8; vehicle = "zed_kamenna_desert"; rank = ""; position[] = {-8.44043,1.83081,0}; dir = 0;}; class Object48 {side = 8; vehicle = "zed_kamenna_desert"; rank = ""; position[] = {-4.44043,1.83081,0}; dir = 0;}; class Object50 {side = 8; vehicle = "Land_HBarrier_3_F"; rank = ""; position[] = {-7.11401,-12.0229,0}; dir = 0;}; class Object51 {side = 8; vehicle = "Land_HBarrier1"; rank = ""; position[] = {6.00879,-15.0037,0}; dir = 0;}; class Object52 {side = 8; vehicle = "Land_HBarrier_1_F"; rank = ""; position[] = {-6,-15.0076,0}; dir = 0;}; class Object53 {side = 8; vehicle = "Land_fort_rampart"; rank = ""; position[] = {16.2256,8,0}; dir = 90;}; class Object54 {side = 8; vehicle = "Base_WarfareBBarrier5x"; rank = ""; position[] = {-9.94189,14.0061,0}; dir = 90;}; class Object55 {side = 8; vehicle = "Base_WarfareBBarrier10xTall"; rank = ""; position[] = {0.0761719,15.3994,0}; dir = 0;}; class Object56 {side = 8; vehicle = "zed_civil_dira"; rank = ""; position[] = {33.9893,6.05103,0}; dir = 0;}; class Object57 {side = 8; vehicle = "zed_dira_desert"; rank = ""; position[] = {33.9893,1.97681,0}; dir = 0;}; class Object58 {side = 8; vehicle = "zed_dira"; rank = ""; position[] = {33.9893,9.97681,0}; dir = 0;}; class Object59 {side = 8; vehicle = "zed2_civil"; rank = ""; position[] = {24.9033,-2.06885,0}; dir = 0;}; class Object60 {side = 8; vehicle = "zed2_civil"; rank = ""; position[] = {18.9033,-2.06885,0}; dir = 0;}; class Object61 {side = 8; vehicle = "zed2_civil"; rank = ""; position[] = {30.9033,-2.06885,0}; dir = 0;}; class Object62 {side = 8; vehicle = "zed_desert"; rank = ""; position[] = {21.9856,1.93115,0}; dir = 0;}; class Object63 {side = 8; vehicle = "zed"; rank = ""; position[] = {21.9893,9.93115,0}; dir = 0;}; class Object64 {side = 8; vehicle = "zed_podplaz"; rank = ""; position[] = {27.9893,9.93115,0}; dir = 0;}; class Object65 {side = 8; vehicle = "zed_podplaz_desert"; rank = ""; position[] = {27.9893,1.93115,0}; dir = 0;}; class Object66 {side = 8; vehicle = "zed_civil"; rank = ""; position[] = {21.9893,5.93115,0}; dir = 0;}; class Object67 {side = 8; vehicle = "zed_podplaz_civil"; rank = ""; position[] = {27.9893,5.93115,0}; dir = 0;}; class Object68 {side = 8; vehicle = "Land_Wall_IndCnc_2deco_F"; rank = ""; position[] = {24,-6,0}; dir = 0;}; class Object69 {side = 8; vehicle = "Land_Wall_IndCnc_2deco_F"; rank = ""; position[] = {29.5,-6,0}; dir = 165;}; class Object70 {side = 8; vehicle = "Land_Wall_IndCnc_2deco_F"; rank = ""; position[] = {21,-6,0}; dir = 0;}; class Object71 {side = 8; vehicle = "Land_Wall_IndCnc_2deco_F"; rank = ""; position[] = {32.375,-5.875,0}; dir = 0;}; class Object72 {side = 8; vehicle = "Land_Wall_IndCnc_2deco_F"; rank = ""; position[] = {26.75,-5.875,0}; dir = 190;}; class Object73 {side = 8; vehicle = "Land_Wall_IndCnc_2deco_F"; rank = ""; position[] = {35.375,-5.875,0}; dir = 0;}; class Object74 {side = 8; vehicle = "Land_Wall_IndCnc_4_D_F"; rank = ""; position[] = {26.958,17.9934,0}; dir = 0;}; class Object75 {side = 8; vehicle = "Land_Wall_IndCnc_4_F"; rank = ""; position[] = {20.9856,17.9939,0}; dir = 0;}; class Object76 {side = 8; vehicle = "Land_Wall_IndCnc_4_F"; rank = ""; position[] = {32.9858,17.9939,0}; dir = 0;}; class Object77 {side = 8; vehicle = "zed2"; rank = ""; position[] = {24.9028,13.9312,0}; dir = 0;}; class Object78 {side = 8; vehicle = "zed2"; rank = ""; position[] = {18.9028,13.9312,0}; dir = 0;}; class Object79 {side = 8; vehicle = "Land_Wall_IndCnc_End_2_F"; rank = ""; position[] = {38.9893,17.9856,0}; dir = 0;}; class Object80 {side = 8; vehicle = "zed2"; rank = ""; position[] = {30.9028,13.9312,0}; dir = 0;}; }; class Sandbags_CUP_O_TK { name = $STR_ZECCUP_MilitaryDesert_ConstructionSuppliesLarge_Sandbags_CUP_O_TK; // Credit: 2600K icon = "\ca\data\flag_rus_co.paa"; side = 8; class Object0 {side = 8; vehicle = "Land_fort_bagfence_long"; rank = ""; position[] = {-16.6403,-17.3892,0}; dir = 0;}; class Object1 {side = 8; vehicle = "Land_fort_bagfence_long"; rank = ""; position[] = {-19.6403,-17.3892,0}; dir = 0;}; class Object2 {side = 8; vehicle = "Land_fort_bagfence_corner"; rank = ""; position[] = {-7.34546,-15.2134,0}; dir = 270;}; class Object3 {side = 8; vehicle = "Land_fort_bagfence_corner"; rank = ""; position[] = {-22.8383,-16.7793,0}; dir = 0;}; class Object4 {side = 8; vehicle = "Land_fort_bagfence_corner"; rank = ""; position[] = {-12.9705,-16.2134,0}; dir = 270;}; class Object5 {side = 8; vehicle = "Land_fort_bagfence_round"; rank = ""; position[] = {3.31976,-19.5498,0}; dir = 225;}; class Object6 {side = 8; vehicle = "Land_fort_bagfence_long"; rank = ""; position[] = {3.8717,-14.8921,0}; dir = 135;}; class Object7 {side = 8; vehicle = "Land_fort_bagfence_long"; rank = ""; position[] = {-9.01392,13.7651,0}; dir = 90;}; class Object8 {side = 8; vehicle = "Land_fort_bagfence_long"; rank = ""; position[] = {-5.01532,9.61084,0}; dir = 0;}; class Object9 {side = 8; vehicle = "Land_fort_bagfence_long"; rank = ""; position[] = {-18.2347,13.1392,0}; dir = 180;}; class Object10 {side = 8; vehicle = "Land_fort_bagfence_long"; rank = ""; position[] = {-18.2347,-10.6108,0}; dir = 180;}; class Object11 {side = 8; vehicle = "Land_fort_bagfence_long"; rank = ""; position[] = {-16.7347,15.8892,0}; dir = 180;}; class Object12 {side = 8; vehicle = "Land_fort_bagfence_long"; rank = ""; position[] = {-18.1097,7.51416,0}; dir = 180;}; class Object13 {side = 8; vehicle = "Land_fort_bagfence_long"; rank = ""; position[] = {-19.4847,15.8892,0}; dir = 180;}; class Object14 {side = 8; vehicle = "Land_fort_bagfence_long"; rank = ""; position[] = {-0.763916,13.8901,0}; dir = 90;}; class Object15 {side = 8; vehicle = "Land_fort_bagfence_long"; rank = ""; position[] = {-3.38892,5.51514,0}; dir = 90;}; class Object16 {side = 8; vehicle = "Land_fort_bagfence_long"; rank = ""; position[] = {-4.13892,-3.48486,0}; dir = 90;}; class Object17 {side = 8; vehicle = "Land_fort_bagfence_long"; rank = ""; position[] = {-0.763916,16.7651,0}; dir = 90;}; class Object18 {side = 8; vehicle = "Land_fort_bagfence_corner"; rank = ""; position[] = {-8.19177,5.68359,0}; dir = 90;}; class Object19 {side = 8; vehicle = "Land_fort_bagfence_corner"; rank = ""; position[] = {-8.15454,-3.28662,0}; dir = 90;}; class Object20 {side = 8; vehicle = "Land_fort_bagfence_corner"; rank = ""; position[] = {-4.72046,-5.21338,0}; dir = 270;}; class Object21 {side = 8; vehicle = "Land_fort_bagfence_corner"; rank = ""; position[] = {-4.84546,-12.2134,0}; dir = 270;}; class Object22 {side = 8; vehicle = "Land_fort_bagfence_corner"; rank = ""; position[] = {-7.96332,10.2202,0}; dir = 0;}; class Object23 {side = 8; vehicle = "Land_fort_bagfence_corner"; rank = ""; position[] = {-7.71332,1.84521,0}; dir = 0;}; class Object24 {side = 8; vehicle = "Land_fort_bagfence_corner"; rank = ""; position[] = {-3.97046,2.41162,0}; dir = 270;}; class Object25 {side = 8; vehicle = "Land_fort_bagfence_corner"; rank = ""; position[] = {-1.34546,10.7866,0}; dir = 270;}; class Object26 {side = 8; vehicle = "Land_fort_bagfence_corner"; rank = ""; position[] = {-7.58832,-5.77979,0}; dir = 0;}; class Object27 {side = 8; vehicle = "Land_fort_bagfence_corner"; rank = ""; position[] = {-8.40454,16.8384,0}; dir = 90;}; class Object28 {side = 8; vehicle = "Land_fort_bagfence_round"; rank = ""; position[] = {-15.2892,1.12256,0}; dir = 90;}; class Object29 {side = 8; vehicle = "Land_fort_bagfence_round"; rank = ""; position[] = {-13.9518,-8.5332,0}; dir = 105;}; class Object30 {side = 8; vehicle = "Land_fort_bagfence_round"; rank = ""; position[] = {-14.4142,10.2476,0}; dir = 90;}; class Object31 {side = 8; vehicle = "Land_fort_bagfence_round"; rank = ""; position[] = {-21.9608,10.2524,0}; dir = 270;}; class Object32 {side = 8; vehicle = "Land_fort_bagfence_round"; rank = ""; position[] = {-22.6744,-8.52881,0}; dir = 255;}; class Object33 {side = 8; vehicle = "Land_fort_bagfence_round"; rank = ""; position[] = {1.67041,-3.18555,0}; dir = 300;}; class Object34 {side = 8; vehicle = "Land_fort_bagfence_round"; rank = ""; position[] = {-21.5858,1.12744,0}; dir = 270;}; class Object36 {side = 8; vehicle = "Land_fort_bagfence_long"; rank = ""; position[] = {3.47546,-7.54199,0}; dir = 30;}; class Object37 {side = 8; vehicle = "Land_fort_bagfence_long"; rank = ""; position[] = {-19.6097,21.5142,0}; dir = 180;}; class Object38 {side = 8; vehicle = "Land_fort_bagfence_long"; rank = ""; position[] = {-16.8597,21.5142,0}; dir = 180;}; class Object39 {side = 8; vehicle = "Land_fort_bagfence_round"; rank = ""; position[] = {-23.3358,18.6274,0}; dir = 270;}; class Object40 {side = 8; vehicle = "Land_fort_bagfence_round"; rank = ""; position[] = {-13.0392,18.6226,0}; dir = 90;}; class Object41 {side = 8; vehicle = "Land_fort_bagfence_long"; rank = ""; position[] = {-4.85968,17.8892,0}; dir = 180;}; class Object42 {side = 8; vehicle = "Land_fort_bagfence_long"; rank = ""; position[] = {15.6512,-18.8218,0}; dir = 45;}; class Object43 {side = 8; vehicle = "Land_fort_bagfence_long"; rank = ""; position[] = {19.6925,-14.6987,0}; dir = 225;}; class Object44 {side = 8; vehicle = "Land_fort_bagfence_round"; rank = ""; position[] = {11.8774,-15.6641,0}; dir = 0;}; class Object45 {side = 8; vehicle = "Land_fort_bagfence_round"; rank = ""; position[] = {20.3086,-19.374,0}; dir = 135;}; class Object46 {side = 8; vehicle = "Land_fort_bagfence_long"; rank = ""; position[] = {7.99457,-18.9331,0}; dir = 315;}; class Object47 {side = 8; vehicle = "Land_fort_bagfence_long"; rank = ""; position[] = {11.5153,2.63916,0}; dir = 180;}; class Object48 {side = 8; vehicle = "Land_fort_bagfence_long"; rank = ""; position[] = {21.2121,-7.49658,0}; dir = 330;}; class Object49 {side = 8; vehicle = "Land_fort_bagfence_long"; rank = ""; position[] = {6.11108,8.14014,0}; dir = 90;}; class Object50 {side = 8; vehicle = "Land_fort_bagfence_long"; rank = ""; position[] = {18.2755,-2.52637,0}; dir = 150;}; class Object51 {side = 8; vehicle = "Land_fort_bagfence_long"; rank = ""; position[] = {16.8889,8.10986,0}; dir = 270;}; class Object52 {side = 8; vehicle = "Land_fort_bagfence_long"; rank = ""; position[] = {11.4847,13.6108,0}; dir = 0;}; class Object53 {side = 8; vehicle = "Land_fort_bagfence_round"; rank = ""; position[] = {6.60553,3.10889,0}; dir = 225;}; class Object54 {side = 8; vehicle = "Land_fort_bagfence_round"; rank = ""; position[] = {22.9509,-3.14063,0}; dir = 60;}; class Object55 {side = 8; vehicle = "Land_fort_bagfence_round"; rank = ""; position[] = {16.5161,3.10547,0}; dir = 135;}; class Object56 {side = 8; vehicle = "Land_fort_bagfence_round"; rank = ""; position[] = {6.48389,13.1445,0}; dir = 315;}; class Object57 {side = 8; vehicle = "Land_fort_bagfence_round"; rank = ""; position[] = {16.3945,13.1411,0}; dir = 45;}; class Object58 {side = 8; vehicle = "Land_fort_bagfence_round"; rank = ""; position[] = {17.147,-10.2661,0}; dir = 285;}; class Object59 {side = 8; vehicle = "Land_fort_bagfence_round"; rank = ""; position[] = {7.08154,-11.165,0}; dir = 90;}; class Object60 {side = 8; vehicle = "Land_fort_bagfence_long"; rank = ""; position[] = {6.46771,-2.21631,0}; dir = 195;}; class Object61 {side = 8; vehicle = "Land_fort_bagfence_long"; rank = ""; position[] = {16.8611,27.7651,0}; dir = 90;}; class Object62 {side = 8; vehicle = "Land_fort_bagfence_long"; rank = ""; position[] = {10.2347,20.7358,0}; dir = 0;}; class Object63 {side = 8; vehicle = "Land_fort_bagfence_corner"; rank = ""; position[] = {15.7133,31.2798,0}; dir = 180;}; class Object64 {side = 8; vehicle = "Land_fort_bagfence_corner"; rank = ""; position[] = {10.7795,27.4116,0}; dir = 270;}; class Object65 {side = 8; vehicle = "Land_fort_bagfence_corner"; rank = ""; position[] = {11.9705,30.7134,0}; dir = 90;}; class Object66 {side = 8; vehicle = "Land_fort_bagfence_corner"; rank = ""; position[] = {7.03668,21.3452,0}; dir = 0;}; class Object67 {side = 8; vehicle = "Land_fort_bagfence_corner"; rank = ""; position[] = {6.47046,25.2134,0}; dir = 90;}; class Object68 {side = 8; vehicle = "Land_fort_bagfence_round"; rank = ""; position[] = {14.2524,23.3359,0}; dir = 0;}; class Object69 {side = 8; vehicle = "Land_fort_bagfence_long"; rank = ""; position[] = {16.9861,19.5151,0}; dir = 90;}; }; class Sandbags_CUP_B_USMC { name = $STR_ZECCUP_MilitaryDesert_ConstructionSuppliesLarge_Sandbags_CUP_B_USMC; // Credit: 2600K icon = "\ca\data\flag_usa_co.paa"; side = 8; class Object0 {side = 8; vehicle = "Land_BagFence_Corner_F"; rank = ""; position[] = {0.269531,6.55518,0}; dir = 270;}; class Object1 {side = 8; vehicle = "Land_BagFence_Corner_F"; rank = ""; position[] = {0.290527,3.23438,0}; dir = 180;}; class Object2 {side = 8; vehicle = "Land_BagFence_Corner_F"; rank = ""; position[] = {3.61145,3.25537,0}; dir = 90;}; class Object3 {side = 8; vehicle = "Land_BagFence_Corner_F"; rank = ""; position[] = {3.69055,10.7056,0}; dir = 90;}; class Object4 {side = 8; vehicle = "Land_BagFence_Corner_F"; rank = ""; position[] = {1.34448,-15.3276,0}; dir = 90;}; class Object5 {side = 8; vehicle = "Land_BagFence_Corner_F"; rank = ""; position[] = {-5.93024,-15.27,0}; dir = 180;}; class Object6 {side = 8; vehicle = "Land_BagFence_Corner_F"; rank = ""; position[] = {-0.555176,10.73,0}; dir = 180;}; class Object7 {side = 8; vehicle = "Land_BagFence_End_F"; rank = ""; position[] = {-7.10608,2.69287,0}; dir = 0;}; class Object8 {side = 8; vehicle = "Land_BagFence_End_F"; rank = ""; position[] = {-5.77173,5.2793,0}; dir = 270;}; class Object9 {side = 8; vehicle = "Land_BagFence_End_F"; rank = ""; position[] = {-6.1684,-12.1089,0}; dir = 255;}; class Object10 {side = 8; vehicle = "Land_BagFence_End_F"; rank = ""; position[] = {-1.75159,-6.74561,0}; dir = 285;}; class Object11 {side = 8; vehicle = "Land_BagFence_End_F"; rank = ""; position[] = {-11.1684,-6.60889,0}; dir = 255;}; class Object12 {side = 8; vehicle = "Land_BagFence_End_F"; rank = ""; position[] = {-8.35858,6.73877,0}; dir = 180;}; class Object13 {side = 8; vehicle = "Land_BagFence_End_F"; rank = ""; position[] = {1.62341,-10.7456,0}; dir = 285;}; class Object14 {side = 8; vehicle = "Land_BagFence_End_F"; rank = ""; position[] = {-9.69299,4.15234,0}; dir = 90;}; class Object15 {side = 8; vehicle = "Land_BagFence_Long_F"; rank = ""; position[] = {1.70117,10.7314,0}; dir = 0;}; class Object16 {side = 8; vehicle = "Land_BagFence_Long_F"; rank = ""; position[] = {1.31451,-13.0381,0}; dir = 270;}; class Object17 {side = 8; vehicle = "Land_BagFence_Long_F"; rank = ""; position[] = {-7.84082,-0.932617,0}; dir = 0;}; class Object18 {side = 8; vehicle = "Land_BagFence_Long_F"; rank = ""; position[] = {-8.08289,-4.46387,0}; dir = 180;}; class Object19 {side = 8; vehicle = "Land_BagFence_Long_F"; rank = ""; position[] = {-3.54102,-15.2998,0}; dir = 180;}; class Object20 {side = 8; vehicle = "Land_BagFence_Long_F"; rank = ""; position[] = {-5.04102,-9.2998,0}; dir = 180;}; class Object21 {side = 8; vehicle = "Land_BagFence_Long_F"; rank = ""; position[] = {-0.791016,-15.2998,0}; dir = 180;}; class Object22 {side = 8; vehicle = "Land_BagFence_Long_F"; rank = ""; position[] = {-7.91589,-9.2998,0}; dir = 180;}; class Object23 {side = 8; vehicle = "Land_BagFence_Short_F"; rank = ""; position[] = {3.62653,5.08203,0}; dir = 270;}; class Object24 {side = 8; vehicle = "Land_BagFence_Short_F"; rank = ""; position[] = {2.11749,3.21924,0}; dir = 0;}; class Object25 {side = 8; vehicle = "Land_BagFence_Short_F"; rank = ""; position[] = {-7.62762,10.228,0}; dir = 0;}; class Object26 {side = 8; vehicle = "Land_BagFence_Short_F"; rank = ""; position[] = {1.76349,6.59131,0}; dir = 180;}; class Object27 {side = 8; vehicle = "Land_BagFence_Short_F"; rank = ""; position[] = {0.254456,4.72803,0}; dir = 90;}; class Object28 {side = 8; vehicle = "Land_BagFence_Short_F"; rank = ""; position[] = {1.95361,-3.79492,0}; dir = 270;}; class Object29 {side = 8; vehicle = "Land_BagFence_Short_F"; rank = ""; position[] = {-5.92139,-13.7949,0}; dir = 270;}; class Object30 {side = 8; vehicle = "Land_BagFence_Round_F"; rank = ""; position[] = {-9.71832,10.7681,0}; dir = 45;}; class Object31 {side = 8; vehicle = "Land_BagFence_Round_F"; rank = ""; position[] = {5.03448,-1.0332,0}; dir = 315;}; class Object32 {side = 8; vehicle = "Land_BagFence_Round_F"; rank = ""; position[] = {-10.5413,-1.32422,0}; dir = 135;}; class Object33 {side = 8; vehicle = "Land_BagFence_Round_F"; rank = ""; position[] = {5.45593,-9.48828,0}; dir = 45;}; class Object34 {side = 8; vehicle = "Land_BagFence_Round_F"; rank = ""; position[] = {-2.46552,-8.9082,0}; dir = 315;}; class Object35 {side = 8; vehicle = "Land_BagFence_Round_F"; rank = ""; position[] = {4.70422,-6.82959,0}; dir = 225;}; class Object36 {side = 8; vehicle = "Land_BagFence_Round_F"; rank = ""; position[] = {2.33093,-5.86377,0}; dir = 45;}; class Object37 {side = 8; vehicle = "Land_BagFence_Round_F"; rank = ""; position[] = {-10.628,-3.94141,0}; dir = 45;}; class Object38 {side = 8; vehicle = "Land_BagFence_Round_F"; rank = ""; position[] = {-5.38239,-4.07227,0}; dir = 315;}; class Object39 {side = 8; vehicle = "Land_BagFence_Round_F"; rank = ""; position[] = {-6.21552,3.0918,0}; dir = 315;}; class Object40 {side = 8; vehicle = "Land_BagFence_Round_F"; rank = ""; position[] = {-6.17084,6.17041,0}; dir = 225;}; class Object41 {side = 8; vehicle = "Land_BagFence_Round_F"; rank = ""; position[] = {-9.29401,3.26172,0}; dir = 45;}; class Object42 {side = 8; vehicle = "Land_BagFence_Round_F"; rank = ""; position[] = {-10.544,-8.73828,0}; dir = 45;}; class Object43 {side = 8; vehicle = "Land_BagFence_Round_F"; rank = ""; position[] = {2.37567,-1.78516,0}; dir = 135;}; class Object44 {side = 8; vehicle = "Land_BagFence_Round_F"; rank = ""; position[] = {-5.29584,-1.45459,0}; dir = 225;}; class Object45 {side = 8; vehicle = "Land_BagFence_Round_F"; rank = ""; position[] = {-9.12433,6.33984,0}; dir = 135;}; class Object46 {side = 8; vehicle = "Land_BagFence_Round_F"; rank = ""; position[] = {-5.46112,10.6147,0}; dir = 315;}; class Object48 {side = 8; vehicle = "Land_BagFence_Corner_F"; rank = ""; position[] = {3.59033,6.57666,0}; dir = 0;}; class Object49 {side = 8; vehicle = "Land_BagFence_Corner_F"; rank = ""; position[] = {-1.77209,24.7383,0}; dir = 270;}; class Object50 {side = 8; vehicle = "Land_BagFence_Corner_F"; rank = ""; position[] = {4.30536,18.5786,0}; dir = 90;}; class Object51 {side = 8; vehicle = "Land_BagFence_Corner_F"; rank = ""; position[] = {4.34033,24.7012,0}; dir = 0;}; class Object52 {side = 8; vehicle = "Land_BagFence_Corner_F"; rank = ""; position[] = {-1.80707,18.6157,0}; dir = 180;}; class Object53 {side = 8; vehicle = "Land_BagFence_Long_F"; rank = ""; position[] = {-7.67383,18.6064,0}; dir = 0;}; class Object54 {side = 8; vehicle = "Land_BagFence_Long_F"; rank = ""; position[] = {0.19928,24.7417,0}; dir = 0;}; class Object55 {side = 8; vehicle = "Land_BagFence_Long_F"; rank = ""; position[] = {2.32617,18.6064,0}; dir = 0;}; class Object56 {side = 8; vehicle = "Land_BagFence_Long_F"; rank = ""; position[] = {-1.81049,20.7119,0}; dir = 270;}; class Object57 {side = 8; vehicle = "Land_BagFence_Long_F"; rank = ""; position[] = {3.68951,13.0869,0}; dir = 270;}; class Object58 {side = 8; vehicle = "Land_BagFence_Long_F"; rank = ""; position[] = {-4.43549,21.5869,0}; dir = 270;}; class Object59 {side = 8; vehicle = "Land_BagFence_Long_F"; rank = ""; position[] = {-0.529358,12.7197,0}; dir = 90;}; class Object60 {side = 8; vehicle = "Land_BagFence_Long_F"; rank = ""; position[] = {-7.54089,24.7002,0}; dir = 180;}; class Object61 {side = 8; vehicle = "Land_BagFence_Long_F"; rank = ""; position[] = {-10.7793,21.7197,0}; dir = 90;}; class Object62 {side = 8; vehicle = "Land_BagFence_Long_F"; rank = ""; position[] = {4.31451,22.7119,0}; dir = 270;}; class Object63 {side = 8; vehicle = "Land_BagFence_Short_F"; rank = ""; position[] = {4.33154,20.3511,0}; dir = 90;}; class Object64 {side = 8; vehicle = "Land_BagFence_Short_F"; rank = ""; position[] = {-1.79346,22.9761,0}; dir = 90;}; class Object65 {side = 8; vehicle = "Land_BagFence_Short_F"; rank = ""; position[] = {-4.92139,12.7051,0}; dir = 270;}; class Object66 {side = 8; vehicle = "Land_BagFence_Short_F"; rank = ""; position[] = {-0.0344238,18.5894,0}; dir = 180;}; class Object67 {side = 8; vehicle = "Land_BagFence_Short_F"; rank = ""; position[] = {-7.45868,15.3457,0}; dir = 180;}; class Object68 {side = 8; vehicle = "Land_BagFence_Short_F"; rank = ""; position[] = {0.992493,15.0942,0}; dir = 0;}; class Object69 {side = 8; vehicle = "Land_BagFence_Short_F"; rank = ""; position[] = {-10.165,12.8691,0}; dir = 90;}; class Object70 {side = 8; vehicle = "Land_BagFence_Round_F"; rank = ""; position[] = {-4.79578,24.2954,0}; dir = 225;}; class Object71 {side = 8; vehicle = "Land_BagFence_Round_F"; rank = ""; position[] = {-4.88879,18.9463,0}; dir = 315;}; class Object72 {side = 8; vehicle = "Land_BagFence_Round_F"; rank = ""; position[] = {-5.36798,14.8062,0}; dir = 225;}; class Object73 {side = 8; vehicle = "Land_BagFence_Round_F"; rank = ""; position[] = {-10.419,19.0117,0}; dir = 45;}; class Object74 {side = 8; vehicle = "Land_BagFence_Round_F"; rank = ""; position[] = {-9.62518,14.9595,0}; dir = 135;}; class Object75 {side = 8; vehicle = "Land_BagFence_Round_F"; rank = ""; position[] = {-10.3259,24.3608,0}; dir = 135;}; class Object76 {side = 8; vehicle = "Land_BagFence_Corner_F"; rank = ""; position[] = {-0.530396,15.1011,0}; dir = 270;}; class Object77 {side = 8; vehicle = "Land_BagFence_End_F"; rank = ""; position[] = {17.1306,-9.28564,0}; dir = 345;}; class Object78 {side = 8; vehicle = "Land_BagFence_End_F"; rank = ""; position[] = {11.9045,-14.6577,0}; dir = 165;}; class Object79 {side = 8; vehicle = "Land_BagFence_Long_F"; rank = ""; position[] = {13.334,-1.9248,0}; dir = 180;}; class Object80 {side = 8; vehicle = "Land_BagFence_Long_F"; rank = ""; position[] = {8.47064,9.46973,0}; dir = 90;}; class Object81 {side = 8; vehicle = "Land_BagFence_Long_F"; rank = ""; position[] = {13.2012,-6.76855,0}; dir = 0;}; class Object82 {side = 8; vehicle = "Land_BagFence_Short_F"; rank = ""; position[] = {7.46558,-9.91064,0}; dir = 180;}; class Object83 {side = 8; vehicle = "Land_BagFence_Short_F"; rank = ""; position[] = {14.5815,-12.0239,0}; dir = 90;}; class Object84 {side = 8; vehicle = "Land_BagFence_Short_F"; rank = ""; position[] = {10.9446,6.34229,0}; dir = 0;}; class Object85 {side = 8; vehicle = "Land_BagFence_Short_F"; rank = ""; position[] = {8.06958,1.71729,0}; dir = 0;}; class Object86 {side = 8; vehicle = "Land_BagFence_Short_F"; rank = ""; position[] = {16.4536,-4.29492,0}; dir = 270;}; class Object87 {side = 8; vehicle = "Land_BagFence_Round_F"; rank = ""; position[] = {10.8309,-1.36377,0}; dir = 45;}; class Object88 {side = 8; vehicle = "Land_BagFence_Round_F"; rank = ""; position[] = {15.9139,-6.38525,0}; dir = 315;}; class Object89 {side = 8; vehicle = "Land_BagFence_Round_F"; rank = ""; position[] = {14.99,-9.85742,0}; dir = 135;}; class Object90 {side = 8; vehicle = "Land_BagFence_Round_F"; rank = ""; position[] = {9.53448,-9.5332,0}; dir = 315;}; class Object91 {side = 8; vehicle = "Land_BagFence_Round_F"; rank = ""; position[] = {14.1127,-14.0039,0}; dir = 315;}; class Object92 {side = 8; vehicle = "Land_BagFence_Round_F"; rank = ""; position[] = {10.5007,-7.16016,0}; dir = 135;}; class Object93 {side = 8; vehicle = "Land_BagFence_Round_F"; rank = ""; position[] = {16.0792,-2.32959,0}; dir = 225;}; class Object94 {side = 8; vehicle = "Land_BagFence_Round_F"; rank = ""; position[] = {10.0792,1.29541,0}; dir = 225;}; class Object95 {side = 8; vehicle = "Land_BagFence_Round_F"; rank = ""; position[] = {6.00067,1.33984,0}; dir = 135;}; class Object96 {side = 8; vehicle = "Land_BagFence_Round_F"; rank = ""; position[] = {8.77826,6.75049,0}; dir = 45;}; class Object97 {side = 8; vehicle = "Land_BagFence_Round_F"; rank = ""; position[] = {13.0345,6.7168,0}; dir = 315;}; class Object98 {side = 8; vehicle = "Land_BagFence_Round_F"; rank = ""; position[] = {14.0007,9.21484,0}; dir = 135;}; class Object99 {side = 8; vehicle = "Land_BagFence_Round_F"; rank = ""; position[] = {9.00067,12.2148,0}; dir = 135;}; class Object100 {side = 8; vehicle = "Land_BagFence_Corner_F"; rank = ""; position[] = {8.44482,16.355,0}; dir = 180;}; class Object101 {side = 8; vehicle = "Land_BagFence_Corner_F"; rank = ""; position[] = {13.2153,16.3262,0}; dir = 0;}; class Object102 {side = 8; vehicle = "Land_BagFence_Corner_F"; rank = ""; position[] = {15.3156,20.7056,0}; dir = 90;}; class Object103 {side = 8; vehicle = "Land_BagFence_Corner_F"; rank = ""; position[] = {8.4696,20.7261,0}; dir = 270;}; class Object104 {side = 8; vehicle = "Land_BagFence_Corner_F"; rank = ""; position[] = {15.3446,25.3511,0}; dir = 270;}; class Object105 {side = 8; vehicle = "Land_BagFence_Long_F"; rank = ""; position[] = {11.8306,12.6294,0}; dir = 0;}; class Object106 {side = 8; vehicle = "Land_BagFence_Long_F"; rank = ""; position[] = {14.7012,12.6064,0}; dir = 0;}; class Object107 {side = 8; vehicle = "Land_BagFence_Long_F"; rank = ""; position[] = {15.3145,23.0869,0}; dir = 270;}; class Object108 {side = 8; vehicle = "Land_BagFence_Long_F"; rank = ""; position[] = {8.47064,18.3447,0}; dir = 90;}; class Object109 {side = 8; vehicle = "Land_BagFence_Long_F"; rank = ""; position[] = {13.3262,20.7314,0}; dir = 0;}; class Object110 {side = 8; vehicle = "Land_BagFence_Long_F"; rank = ""; position[] = {10.459,20.7002,0}; dir = 180;}; class Object111 {side = 8; vehicle = "Land_BagFence_Long_F"; rank = ""; position[] = {10.834,16.3252,0}; dir = 180;}; class Object112 {side = 8; vehicle = "Land_BagFence_Long_F"; rank = ""; position[] = {17.3341,25.3252,0}; dir = 180;}; class Object113 {side = 8; vehicle = "Land_BagFence_Long_F"; rank = ""; position[] = {19.7207,23.3447,0}; dir = 90;}; class Object114 {side = 8; vehicle = "Land_BagFence_Corner_F"; rank = ""; position[] = {19.7155,25.3262,0}; dir = 0;}; }; class FillerSupplies { name = $STR_ZECCUP_MilitaryDesert_ConstructionSuppliesLarge_FillerSupplies; // Credit: 2600K icon = "\a3\Ui_f\data\Map\Markers\Military\unknown_ca.paa"; side = 8; class Object0 {side = 8; vehicle = "Land_fort_rampart_EP1"; rank = ""; position[] = {-17.8438,-14.4604,0}; dir = 180;}; class Object1 {side = 8; vehicle = "Land_fort_rampart_EP1"; rank = ""; position[] = {-17.818,-6.28662,0}; dir = 180;}; class Object2 {side = 8; vehicle = "Land_WaterTank_F"; rank = ""; position[] = {-19.0786,-15.6218,0}; dir = 359.847;}; class Object3 {side = 8; vehicle = "Land_Pallet_MilBoxes_F"; rank = ""; position[] = {-21.2394,-15.6226,0}; dir = 270;}; class Object4 {side = 8; vehicle = "Land_PaperBox_open_empty_F"; rank = ""; position[] = {-17.4996,-7.625,0}; dir = 105;}; class Object5 {side = 8; vehicle = "Land_Pallet_MilBoxes_F"; rank = ""; position[] = {-19.2394,-7.49756,0}; dir = 270;}; class Object6 {side = 8; vehicle = "Barrel1"; rank = ""; position[] = {-18,-16.75,0}; dir = 345;}; class Object7 {side = 8; vehicle = "Barrel1"; rank = ""; position[] = {-19.5,-16.75,0}; dir = 180;}; class Object8 {side = 8; vehicle = "Land_MetalBarrel_F"; rank = ""; position[] = {-20.4424,-7.50537,0}; dir = 298.759;}; class Object9 {side = 8; vehicle = "Land_MetalBarrel_F"; rank = ""; position[] = {-21.2797,-7.19653,0}; dir = 134.998;}; class Object10 {side = 8; vehicle = "Land_BarrelWater_grey_F"; rank = ""; position[] = {-22.4063,-16.001,0}; dir = 359.884;}; class Object11 {side = 8; vehicle = "Land_BarrelTrash_grey_F"; rank = ""; position[] = {-22.4336,-15.25,0}; dir = 0.0141838;}; class Object12 {side = 8; vehicle = "Land_fort_rampart_EP1"; rank = ""; position[] = {-18.625,18.3994,0}; dir = 180;}; class Object13 {side = 8; vehicle = "Land_fort_rampart_EP1"; rank = ""; position[] = {-17.8094,5.59692,0}; dir = 180;}; class Object14 {side = 8; vehicle = "Land_GarbagePallet_F"; rank = ""; position[] = {-18.9601,17.1973,0}; dir = 330;}; class Object15 {side = 8; vehicle = "Land_CratesShabby_F"; rank = ""; position[] = {-22.0632,4.44312,0}; dir = 180;}; class Object16 {side = 8; vehicle = "Land_CratesWooden_F"; rank = ""; position[] = {-20.5,4.25,0}; dir = 0;}; class Object17 {side = 8; vehicle = "Misc_concrete_High"; rank = ""; position[] = {-22.75,16.25,0}; dir = 180;}; class Object18 {side = 8; vehicle = "Barrel1"; rank = ""; position[] = {-21.125,16.5,0}; dir = 255;}; class Object19 {side = 8; vehicle = "Barrel1"; rank = ""; position[] = {-17.294,3.91479,0}; dir = 270;}; class Object20 {side = 8; vehicle = "Barrel1"; rank = ""; position[] = {-21.125,17.5,0}; dir = 45;}; class Object21 {side = 8; vehicle = "Barrel1"; rank = ""; position[] = {-17.9399,4.93506,0}; dir = 300;}; class Object22 {side = 8; vehicle = "Barrel1"; rank = ""; position[] = {-18.6776,4.63892,0}; dir = 120;}; class Object23 {side = 8; vehicle = "Land_Pallets_stack_F"; rank = ""; position[] = {-16.726,16.459,0}; dir = 163.226;}; class Object24 {side = 8; vehicle = "Barrel4"; rank = ""; position[] = {-22.875,4.875,0}; dir = 0;}; class Object25 {side = 8; vehicle = "Barrel4"; rank = ""; position[] = {-17.125,4.75,0}; dir = 105;}; class Object26 {side = 8; vehicle = "Barrel4"; rank = ""; position[] = {-18,4.125,0}; dir = 0;}; class Object27 {side = 8; vehicle = "Fort_Crate_wood"; rank = ""; position[] = {-15.9994,4.4978,0}; dir = 195;}; class Object28 {side = 8; vehicle = "Land_BagFence_Long_F"; rank = ""; position[] = {-2.50391,-2.23438,0}; dir = 360;}; class Object29 {side = 8; vehicle = "Land_BagFence_Long_F"; rank = ""; position[] = {3.49609,-13.2344,0}; dir = 360;}; class Object30 {side = 8; vehicle = "Land_BagFence_Long_F"; rank = ""; position[] = {3.24609,-2.23438,0}; dir = 360;}; class Object31 {side = 8; vehicle = "Land_BagFence_Long_F"; rank = ""; position[] = {0.621094,-13.2344,0}; dir = 360;}; class Object32 {side = 8; vehicle = "Land_BagFence_Long_F"; rank = ""; position[] = {0.371094,-2.23438,0}; dir = 360;}; class Object33 {side = 8; vehicle = "Land_BagFence_Long_F"; rank = ""; position[] = {-2.25391,-13.2344,0}; dir = 360;}; class Object34 {side = 8; vehicle = "Land_BagFence_Round_F"; rank = ""; position[] = {-5.32941,-2.62598,0}; dir = 135;}; class Object35 {side = 8; vehicle = "Land_BagFence_Round_F"; rank = ""; position[] = {6.12415,-13.7957,0}; dir = 225;}; class Object36 {side = 8; vehicle = "Land_BagFence_Round_F"; rank = ""; position[] = {5.87415,-2.79565,0}; dir = 225;}; class Object37 {side = 8; vehicle = "Land_BagFence_Round_F"; rank = ""; position[] = {-5.07941,-13.626,0}; dir = 135;}; class Object38 {side = 8; vehicle = "Land_GarbagePallet_F"; rank = ""; position[] = {4.1283,-4.20264,0}; dir = 30;}; class Object39 {side = 8; vehicle = "Land_fort_bagfence_corner"; rank = ""; position[] = {13.7205,-14.5366,0}; dir = 90;}; class Object40 {side = 8; vehicle = "Land_fort_bagfence_corner"; rank = ""; position[] = {13.5955,-3.53662,0}; dir = 90;}; class Object41 {side = 8; vehicle = "Land_Pipes_large_F"; rank = ""; position[] = {-15.0734,-15.4971,0}; dir = 359.995;}; class Object42 {side = 8; vehicle = "Land_Pipes_small_F"; rank = ""; position[] = {0.493347,-16.1328,0}; dir = 344.999;}; class Object43 {side = 8; vehicle = "Land_Pipes_small_F"; rank = ""; position[] = {-13.3817,-7.13721,0}; dir = 165.006;}; class Object44 {side = 8; vehicle = "Land_Sack_F"; rank = ""; position[] = {15.7451,-15.252,0}; dir = 285;}; class Object45 {side = 8; vehicle = "Land_Sack_F"; rank = ""; position[] = {4.37115,-15.1282,0}; dir = 270;}; class Object46 {side = 8; vehicle = "Land_Sacks_heap_F"; rank = ""; position[] = {15.25,-14.5,0}; dir = 0;}; class Object47 {side = 8; vehicle = "Land_Sacks_heap_F"; rank = ""; position[] = {14.3103,-14.6897,0}; dir = 270;}; class Object48 {side = 8; vehicle = "Land_CratesShabby_F"; rank = ""; position[] = {2.61719,-15.3757,0}; dir = 75;}; class Object49 {side = 8; vehicle = "Land_CratesWooden_F"; rank = ""; position[] = {0.75,-14.75,0}; dir = 0;}; class Object50 {side = 8; vehicle = "Land_PaperBox_open_full_F"; rank = ""; position[] = {-1.37506,-14.6343,0}; dir = 0;}; class Object51 {side = 8; vehicle = "Oil_Spill_F"; rank = ""; position[] = {1.41296,-4.01221,0}; dir = 0;}; class Object52 {side = 8; vehicle = "Land_Sack_EP1"; rank = ""; position[] = {15.126,-15.3696,0}; dir = 75;}; class Object53 {side = 8; vehicle = "PowerGenerator_EP1"; rank = ""; position[] = {14,-4.125,0}; dir = 0;}; class Object54 {side = 8; vehicle = "PowerGenerator_EP1"; rank = ""; position[] = {3.375,-14.375,0}; dir = 90;}; class Object55 {side = 8; vehicle = "Gunrack1"; rank = ""; position[] = {0.316406,-3.4751,0}; dir = 0;}; class Object56 {side = 8; vehicle = "Gunrack1"; rank = ""; position[] = {-1.05859,-3.4751,0}; dir = 0;}; class Object57 {side = 8; vehicle = "Barrel3"; rank = ""; position[] = {-3.25,-3.375,0}; dir = 210;}; class Object58 {side = 8; vehicle = "Barrel3"; rank = ""; position[] = {-2.375,-3.375,0}; dir = 150;}; class Object59 {side = 8; vehicle = "Barrel3"; rank = ""; position[] = {-3.625,-14.25,0}; dir = 60;}; class Object60 {side = 8; vehicle = "Barrel3"; rank = ""; position[] = {-2.875,-4,0}; dir = 0;}; class Object61 {side = 8; vehicle = "Barrel3"; rank = ""; position[] = {-3.625,-4.375,0}; dir = 210;}; class Object62 {side = 8; vehicle = "Land_WaterBarrel_F"; rank = ""; position[] = {-4.625,-14.5,0}; dir = 359.994;}; class Object63 {side = 8; vehicle = "Barrel4"; rank = ""; position[] = {1.875,-3.875,0}; dir = 105;}; class Object64 {side = 8; vehicle = "Barrel4"; rank = ""; position[] = {-2.625,-15.125,0}; dir = 0;}; class Object65 {side = 8; vehicle = "Barrel4"; rank = ""; position[] = {1.375,-3.25,0}; dir = 315;}; class Object66 {side = 8; vehicle = "Barrel4"; rank = ""; position[] = {-2.625,-14.25,0}; dir = 270;}; class Object67 {side = 8; vehicle = "Fort_Crate_wood"; rank = ""; position[] = {15.1256,-4.7522,0}; dir = 195;}; class Object68 {side = 8; vehicle = "Fort_Crate_wood"; rank = ""; position[] = {5.12384,-14.498,0}; dir = 0;}; class Object69 {side = 8; vehicle = "Fort_Crate_wood"; rank = ""; position[] = {-4.12384,-3.37695,0}; dir = 180;}; class Object70 {side = 8; vehicle = "Fort_Crate_wood"; rank = ""; position[] = {15.0012,-3.37695,0}; dir = 180;}; class Object72 {side = 8; vehicle = "Land_PaperBox_closed_F"; rank = ""; position[] = {-15.7375,-7.49756,0}; dir = 90;}; class Object73 {side = 8; vehicle = "Land_BarrelWater_grey_F"; rank = ""; position[] = {-5.00006,-3.25,0}; dir = 359.978;}; class Object74 {side = 8; vehicle = "Land_BarrelSand_grey_F"; rank = ""; position[] = {-5.00006,-15.375,0}; dir = 359.978;}; class Object75 {side = 8; vehicle = "Land_BarrelTrash_grey_F"; rank = ""; position[] = {14.1249,-15.75,0}; dir = 359.978;}; class Object76 {side = 8; vehicle = "Land_BagFence_Long_F"; rank = ""; position[] = {2.99609,7.76563,0}; dir = 360;}; class Object77 {side = 8; vehicle = "Land_BagFence_Long_F"; rank = ""; position[] = {2.99609,19.2656,0}; dir = 360;}; class Object78 {side = 8; vehicle = "Land_BagFence_Long_F"; rank = ""; position[] = {-2.75391,19.2656,0}; dir = 360;}; class Object79 {side = 8; vehicle = "Land_BagFence_Long_F"; rank = ""; position[] = {0.121094,7.76563,0}; dir = 360;}; class Object80 {side = 8; vehicle = "Land_BagFence_Long_F"; rank = ""; position[] = {-2.75391,7.76563,0}; dir = 360;}; class Object81 {side = 8; vehicle = "Land_BagFence_Long_F"; rank = ""; position[] = {0.121094,19.2656,0}; dir = 360;}; class Object82 {side = 8; vehicle = "Land_BagFence_Round_F"; rank = ""; position[] = {-5.57941,18.874,0}; dir = 135;}; class Object83 {side = 8; vehicle = "Land_BagFence_Round_F"; rank = ""; position[] = {5.62415,18.7043,0}; dir = 225;}; class Object84 {side = 8; vehicle = "Land_BagFence_Round_F"; rank = ""; position[] = {5.62415,7.20435,0}; dir = 225;}; class Object85 {side = 8; vehicle = "Land_BagFence_Round_F"; rank = ""; position[] = {-5.57941,7.37402,0}; dir = 135;}; class Object86 {side = 8; vehicle = "Land_fort_bagfence_corner"; rank = ""; position[] = {13.5955,17.9634,0}; dir = 90;}; class Object87 {side = 8; vehicle = "Land_fort_bagfence_corner"; rank = ""; position[] = {13.5955,6.96338,0}; dir = 90;}; class Object88 {side = 8; vehicle = "Land_Pipes_small_F"; rank = ""; position[] = {-4.13165,17.2422,0}; dir = 89.9994;}; class Object89 {side = 8; vehicle = "Land_WoodenBox_F"; rank = ""; position[] = {-4.73853,17.5017,0}; dir = 90;}; class Object90 {side = 8; vehicle = "Land_PaperBox_closed_F"; rank = ""; position[] = {-1.36249,17.8774,0}; dir = 90;}; class Object91 {side = 8; vehicle = "Oil_Spill_F"; rank = ""; position[] = {0.537964,17.7378,0}; dir = 0;}; class Object92 {side = 8; vehicle = "Barrel5"; rank = ""; position[] = {-0.125,18.375,0}; dir = 195;}; class Object93 {side = 8; vehicle = "Barrel5"; rank = ""; position[] = {0.189697,17.5647,0}; dir = 0;}; class Object94 {side = 8; vehicle = "Barrel5"; rank = ""; position[] = {0.75,18.375,0}; dir = 330;}; class Object95 {side = 8; vehicle = "PowerGenerator"; rank = ""; position[] = {14.625,7,0}; dir = 90;}; class Object96 {side = 8; vehicle = "PowerGenerator"; rank = ""; position[] = {2.25,18.125,0}; dir = 270;}; class Object97 {side = 8; vehicle = "Land_WheelCart_F"; rank = ""; position[] = {4.12787,17.3777,0}; dir = 45.0077;}; class Object98 {side = 8; vehicle = "Misc_cargo_cont_tiny"; rank = ""; position[] = {15.7458,17.5,0}; dir = 0;}; class Object99 {side = 8; vehicle = "Gunrack1"; rank = ""; position[] = {-2.80859,7.0249,0}; dir = 0;}; class Object100 {side = 8; vehicle = "Gunrack1"; rank = ""; position[] = {-1.80859,7.0249,0}; dir = 0;}; class Object101 {side = 8; vehicle = "Barrel3"; rank = ""; position[] = {-3.625,7.125,0}; dir = 15;}; class Object102 {side = 8; vehicle = "Barrel1"; rank = ""; position[] = {2.75,7.125,0}; dir = 0;}; class Object103 {side = 8; vehicle = "Barrel1"; rank = ""; position[] = {3.46027,7.08105,0}; dir = 180;}; class Object104 {side = 8; vehicle = "Barrel1"; rank = ""; position[] = {3.25,6.375,0}; dir = 255;}; class Object105 {side = 8; vehicle = "Land_WaterBarrel_F"; rank = ""; position[] = {4.5,6.875,0}; dir = 359.995;}; class Object106 {side = 8; vehicle = "Land_PaperBox_open_empty_F"; rank = ""; position[] = {-2.99963,17.875,0}; dir = 90;}; class Object107 {side = 8; vehicle = "Land_Pallets_stack_F"; rank = ""; position[] = {-15.125,17.125,0}; dir = 359.999;}; class Object108 {side = 8; vehicle = "Land_Pallets_stack_F"; rank = ""; position[] = {1.5,6.75,0}; dir = 3.95778e-005;}; class Object109 {side = 8; vehicle = "Land_Pallets_stack_F"; rank = ""; position[] = {14.375,5.75,0}; dir = 360;}; class Object110 {side = 8; vehicle = "Land_Pallets_stack_F"; rank = ""; position[] = {-0.125,6.5,0}; dir = 255.001;}; class Object111 {side = 8; vehicle = "Misc_Backpackheap"; rank = ""; position[] = {-4.50531,6.07959,0}; dir = 210;}; class Object112 {side = 8; vehicle = "Land_BarrelTrash_F"; rank = ""; position[] = {2.62506,17.375,0}; dir = 359.976;}; class Object113 {side = 8; vehicle = "Land_BarrelWater_F"; rank = ""; position[] = {15.5001,6.25,0}; dir = 359.976;}; class Object114 {side = 8; vehicle = "Land_BarrelSand_F"; rank = ""; position[] = {14.4999,18.25,0}; dir = 359.978;}; class Object115 {side = 8; vehicle = "Land_BarrelEmpty_F"; rank = ""; position[] = {5.24994,6.125,0}; dir = 359.978;}; class Object116 {side = 8; vehicle = "Land_BarrelEmpty_grey_F"; rank = ""; position[] = {-15.0001,4.625,0}; dir = 359.978;}; class Object117 {side = 8; vehicle = "Land_BarrelSand_grey_F"; rank = ""; position[] = {-14.3751,4.875,0}; dir = 359.978;}; class Object118 {side = 8; vehicle = "Land_fort_bagfence_long"; rank = ""; position[] = {17.2653,-2.36108,0}; dir = 180;}; class Object119 {side = 8; vehicle = "Land_fort_bagfence_long"; rank = ""; position[] = {20.3903,-13.3611,0}; dir = 180;}; class Object120 {side = 8; vehicle = "Land_fort_bagfence_long"; rank = ""; position[] = {20.2653,-2.36108,0}; dir = 180;}; class Object121 {side = 8; vehicle = "Land_fort_bagfence_long"; rank = ""; position[] = {17.3903,-13.3611,0}; dir = 180;}; class Object122 {side = 8; vehicle = "Land_fort_bagfence_corner"; rank = ""; position[] = {23.4633,-2.97046,0}; dir = 180;}; class Object123 {side = 8; vehicle = "Land_fort_bagfence_corner"; rank = ""; position[] = {23.5883,-13.9705,0}; dir = 180;}; class Object124 {side = 8; vehicle = "Land_Pipes_small_F"; rank = ""; position[] = {23.3683,-15.7578,0}; dir = 89.9994;}; class Object125 {side = 8; vehicle = "Land_Pipes_small_F"; rank = ""; position[] = {22.4933,-15.5078,0}; dir = 285;}; class Object126 {side = 8; vehicle = "Land_WoodenBox_F"; rank = ""; position[] = {19.0115,-15.8733,0}; dir = 195;}; class Object127 {side = 8; vehicle = "Land_PaperBox_closed_F"; rank = ""; position[] = {19.6375,-14.7476,0}; dir = 90;}; class Object128 {side = 8; vehicle = "Land_PaperBox_closed_F"; rank = ""; position[] = {21.1275,-14.7625,0}; dir = 180;}; class Object129 {side = 8; vehicle = "Land_PaperBox_closed_F"; rank = ""; position[] = {18.3875,-3.62256,0}; dir = 90;}; class Object130 {side = 8; vehicle = "GunrackTK_EP1"; rank = ""; position[] = {16.2053,-3.35596,0}; dir = 90;}; class Object131 {side = 8; vehicle = "GunrackTK_EP1"; rank = ""; position[] = {18.2053,-14.481,0}; dir = 90;}; class Object132 {side = 8; vehicle = "GunrackTK_EP1"; rank = ""; position[] = {16.9553,-14.481,0}; dir = 90;}; class Object133 {side = 8; vehicle = "GunrackTK_EP1"; rank = ""; position[] = {22.9553,-3.48096,0}; dir = 90;}; class Object134 {side = 8; vehicle = "Land_WaterBarrel_F"; rank = ""; position[] = {21.75,-3.375,0}; dir = 359.994;}; class Object135 {side = 8; vehicle = "Barrel4"; rank = ""; position[] = {20.25,-3.25,0}; dir = 315;}; class Object136 {side = 8; vehicle = "Barrel4"; rank = ""; position[] = {20.75,-3.875,0}; dir = 105;}; class Object137 {side = 8; vehicle = "Land_Sack_F"; rank = ""; position[] = {17.2504,-3.37012,0}; dir = 45;}; class Object138 {side = 8; vehicle = "Land_BarrelEmpty_grey_F"; rank = ""; position[] = {19.4999,-3.25,0}; dir = 359.978;}; class Object139 {side = 8; vehicle = "Land_fort_bagfence_long"; rank = ""; position[] = {20.2653,19.1389,0}; dir = 180;}; class Object140 {side = 8; vehicle = "Land_fort_bagfence_long"; rank = ""; position[] = {17.2653,8.13892,0}; dir = 180;}; class Object141 {side = 8; vehicle = "Land_fort_bagfence_long"; rank = ""; position[] = {17.2653,19.1389,0}; dir = 180;}; class Object142 {side = 8; vehicle = "Land_fort_bagfence_long"; rank = ""; position[] = {20.2653,8.13892,0}; dir = 180;}; class Object143 {side = 8; vehicle = "Land_fort_bagfence_corner"; rank = ""; position[] = {23.4633,7.52954,0}; dir = 180;}; class Object144 {side = 8; vehicle = "Land_fort_bagfence_corner"; rank = ""; position[] = {23.4633,18.5295,0}; dir = 180;}; class Object145 {side = 8; vehicle = "Land_Pipes_small_F"; rank = ""; position[] = {22.6183,5.74219,0}; dir = 359.999;}; class Object146 {side = 8; vehicle = "Land_WoodenBox_F"; rank = ""; position[] = {21.8865,17.3767,0}; dir = 285;}; class Object147 {side = 8; vehicle = "Land_Sack_F"; rank = ""; position[] = {20.3705,17.1228,0}; dir = 285;}; class Object148 {side = 8; vehicle = "Land_Sack_F"; rank = ""; position[] = {21.1233,18.2454,0}; dir = 240;}; class Object149 {side = 8; vehicle = "Land_PaperBox_closed_F"; rank = ""; position[] = {17.5125,17.8774,0}; dir = 90;}; class Object150 {side = 8; vehicle = "Land_PaperBox_closed_F"; rank = ""; position[] = {21.8875,6.87744,0}; dir = 90;}; class Object151 {side = 8; vehicle = "Land_PaperBox_closed_F"; rank = ""; position[] = {23.3775,6.86255,0}; dir = 180;}; class Object152 {side = 8; vehicle = "Land_PaperBox_closed_F"; rank = ""; position[] = {23.3875,17.8774,0}; dir = 90;}; class Object153 {side = 8; vehicle = "Land_Sacks_goods_F"; rank = ""; position[] = {20.126,18.0129,0}; dir = 0;}; class Object154 {side = 8; vehicle = "GunrackTK_EP1"; rank = ""; position[] = {23.4553,16.644,0}; dir = 90;}; class Object155 {side = 8; vehicle = "GunrackTK_EP1"; rank = ""; position[] = {18.9553,7.14404,0}; dir = 90;}; class Object156 {side = 8; vehicle = "Barrel5"; rank = ""; position[] = {17.375,6.125,0}; dir = 195;}; class Object157 {side = 8; vehicle = "Barrel5"; rank = ""; position[] = {17.75,7.125,0}; dir = 330;}; class Object158 {side = 8; vehicle = "Barrel1"; rank = ""; position[] = {18.875,18,0}; dir = 0;}; class Object159 {side = 8; vehicle = "Barrel1"; rank = ""; position[] = {19,17,0}; dir = 255;}; class Object160 {side = 8; vehicle = "Land_WaterBarrel_F"; rank = ""; position[] = {16.625,7,0}; dir = 359.995;}; class Object161 {side = 8; vehicle = "Land_Pallets_stack_F"; rank = ""; position[] = {17.75,16.125,0}; dir = 255.002;}; class Object162 {side = 8; vehicle = "GunrackTK_EP1"; rank = ""; position[] = {20.3303,7.14404,0}; dir = 90;}; }; }; class ConstructionSuppliesMedium { name = $STR_ZECCUP_ConstructionSuppliesMedium; }; class ConstructionSuppliesSmall { name = $STR_ZECCUP_ConstructionSuppliesSmall; };
111.88
139
0.617597
LISTINGS09
7360de20d55505eeb7792ff907993656516448fd
810
hpp
C++
src/mesh/meshSetup.hpp
roystgnr/nekRS
280acd21c3088d7658a8a113e544fce05853d7b4
[ "BSD-3-Clause" ]
null
null
null
src/mesh/meshSetup.hpp
roystgnr/nekRS
280acd21c3088d7658a8a113e544fce05853d7b4
[ "BSD-3-Clause" ]
null
null
null
src/mesh/meshSetup.hpp
roystgnr/nekRS
280acd21c3088d7658a8a113e544fce05853d7b4
[ "BSD-3-Clause" ]
null
null
null
#if !defined(nekrs_meshsetup_hpp_) #define nekrs_meshsetup_hpp_ #include "nrs.hpp" mesh_t* createMeshDummy(MPI_Comm comm, int N, int cubN, setupAide &options, occa::device device, occa::properties &kernelInfo); mesh_t* createMesh(MPI_Comm comm, int N, int cubN, int isMeshT, setupAide &options, occa::device device, occa::properties &kernelInfo); mesh_t* createMeshV(MPI_Comm comm, int N, int cubN, mesh_t* meshT, setupAide &options, occa::properties &kernelInfo); #endif
28.928571
54
0.455556
roystgnr
73618c5ca41ce308cb5d7dfecd62df237fbd6307
631
cpp
C++
atcoder/abc096/D.cpp
SashiRin/protrode
c03d0a6e9a5ac87d0f3d3af5d39b05a10f58527c
[ "MIT" ]
1
2019-08-03T13:42:16.000Z
2019-08-03T13:42:16.000Z
atcoder/abc096/D.cpp
SashiRin/protrode
c03d0a6e9a5ac87d0f3d3af5d39b05a10f58527c
[ "MIT" ]
null
null
null
atcoder/abc096/D.cpp
SashiRin/protrode
c03d0a6e9a5ac87d0f3d3af5d39b05a10f58527c
[ "MIT" ]
null
null
null
#include <bits/stdc++.h> using namespace std; const int maxn = 55555; int main() { int n; cin >> n; vector<bool> primes(maxn, true); for (int i = 2; i < maxn; ++i) { if (primes[i]) { for (int j = i + i; j < maxn; j += i) { primes[j] = false; } } } vector<int> res; for (int i = 2; i < maxn; ++i) { if (primes[i] && i % 5 == 1) { res.push_back(i); if (res.size() >= n) { break; } } } for (int& x : res) { cout << x << " "; } cout << endl; return 0; }
20.354839
51
0.37401
SashiRin
736288df4279cc9a5bb7d7918ae3bb03915977d9
4,306
cpp
C++
SimulationTest/gpuTests/CollisionTestGpu.cpp
KevinMcGin/Simulation
f1dbed05d6024274f6a69e0679f529feaae1e26e
[ "MIT" ]
4
2021-12-11T17:59:07.000Z
2021-12-24T11:08:55.000Z
SimulationTest/gpuTests/CollisionTestGpu.cpp
KevinMcGin/Simulation
f1dbed05d6024274f6a69e0679f529feaae1e26e
[ "MIT" ]
121
2021-12-11T09:20:47.000Z
2022-03-13T18:36:48.000Z
SimulationTest/gpuTests/CollisionTestGpu.cpp
KevinMcGin/Simulation
f1dbed05d6024274f6a69e0679f529feaae1e26e
[ "MIT" ]
null
null
null
#include <gtest/gtest.h> #include "law/collision/Collision.h" #include "law/collision/detector/CollisionDetectorSimple.cuh" #include "law/collision/resolver/CollisionResolverCoalesce.cuh" #include "LawHelper.h" #include "CollisionTestHelper.h" TEST(CollisionTest, ParticlesCollideGpu) { auto law = std::make_shared<Collision>(std::make_shared<CollisionDetectorSimple>(), std::make_shared<CollisionResolverCoalesce>(), true); std::vector<Particle*> particles = CollisionTestHelper::getParticlesCollideParticles(); LawHelper::runGpuLaw(law, particles); CollisionTestHelper::testParticlesCollide(particles); } TEST(CollisionTest, MultipleParticlesAllCollideGpu) { auto law = std::make_shared<Collision>(std::make_shared<CollisionDetectorSimple>(), std::make_shared<CollisionResolverCoalesce>(), true); std::vector<Particle*> particles = CollisionTestHelper::getMultipleParticlesAllCollide(); LawHelper::runGpuLaw(law, particles); CollisionTestHelper::testMultipleParticlesAllCollide(particles); } TEST(CollisionTest, MultipleParticlesPartialCollideGpu) { auto law = std::make_shared<Collision>(std::make_shared<CollisionDetectorSimple>(), std::make_shared<CollisionResolverCoalesce>(), true); std::vector<Particle*> particles = CollisionTestHelper::getMultipleParticlesPartialCollide(); LawHelper::runGpuLaw(law, particles); CollisionTestHelper::testMultipleParticlesPartialCollide(particles); } TEST(CollisionTest, MultipleParticlesIndependentlyCollide) { auto law = std::make_shared<Collision>(std::make_shared<CollisionDetectorSimple>(), std::make_shared<CollisionResolverCoalesce>(), true); std::vector<Particle*> particles = CollisionTestHelper::getMultipleParticlesIndependentlyCollide(); LawHelper::runGpuLaw(law, particles); CollisionTestHelper::testMultipleParticlesIndependentlyCollide(particles); } TEST(CollisionTest, ParticlesCollideGpuLikeCpuSimple) { const int particleCount = 75; const int stepsCount = 1; auto law = std::make_shared<Collision>(std::make_shared<CollisionDetectorSimple>(), std::make_shared<CollisionResolverCoalesce>(), true); LawHelper::expectGpuLikeCpuRounded(law, particleCount, stepsCount); } TEST(CollisionTest, ParticlesCollideGpuLikeCpuMemoryLow) { CudaWithError::setMaxMemoryPerEvent(1000 * 1000); const int particleCount = 75; const int stepsCount = 1; auto law = std::make_shared<Collision>(std::make_shared<CollisionDetectorSimple>(), std::make_shared<CollisionResolverCoalesce>(), true); LawHelper::expectGpuLikeCpuRounded(law, particleCount, stepsCount); } TEST(CollisionTest, ParticlesCollideGpuLikeCpuMemoryVeryLow) { CudaWithError::setMaxMemoryPerEvent(1000); const int particleCount = 75; const int stepsCount = 1; auto law = std::make_shared<Collision>(std::make_shared<CollisionDetectorSimple>(), std::make_shared<CollisionResolverCoalesce>(), true); LawHelper::expectGpuLikeCpuRounded(law, particleCount, stepsCount); } TEST(CollisionTest, ParticlesCollideGpuLikeCpuMemoryTooLow1) { CudaWithError::setMaxMemoryPerEvent(100); const int particleCount = 75; const int stepsCount = 1; auto law = std::make_shared<Collision>(std::make_shared<CollisionDetectorSimple>(), std::make_shared<CollisionResolverCoalesce>(), true); try { LawHelper::expectGpuLikeCpuRounded(law, particleCount, stepsCount); FAIL() << "No error thrown: expected Max Loops in GpuCollision reached"; } catch(std::runtime_error const &err) { EXPECT_EQ(err.what(), std::string("Max Loops in GpuCollision reached")); } catch(...) { FAIL() << "Wrong error thrown: expected Max Loops in GpuCollision reached"; } } TEST(CollisionTest, ParticlesCollideGpuLikeCpuMemoryTooLow2) { CudaWithError::setMaxMemoryPerEvent(10); const int particleCount = 75; const int stepsCount = 1; auto law = std::make_shared<Collision>(std::make_shared<CollisionDetectorSimple>(), std::make_shared<CollisionResolverCoalesce>(), true); try { LawHelper::expectGpuLikeCpuRounded(law, particleCount, stepsCount); FAIL() << "No error thrown: expected Ran out of GPU memory"; } catch(std::runtime_error const &err) { EXPECT_EQ(err.what(), std::string("Ran out of GPU memory")); } catch(...) { FAIL() << "Wrong error thrown: expected Ran out of GPU memory"; } }
44.391753
138
0.774268
KevinMcGin
736877c8b40a7cdb42de867111f7b7484a4c1df6
357
cpp
C++
2.1 Pointer/array.cpp
arryaaas/Programming-Algorithms
f469431830cbe528feb297abd47d2d6c08e0781a
[ "MIT" ]
null
null
null
2.1 Pointer/array.cpp
arryaaas/Programming-Algorithms
f469431830cbe528feb297abd47d2d6c08e0781a
[ "MIT" ]
null
null
null
2.1 Pointer/array.cpp
arryaaas/Programming-Algorithms
f469431830cbe528feb297abd47d2d6c08e0781a
[ "MIT" ]
null
null
null
#include <iostream> using namespace std; int main(){ //Pointer declaration int *p; //Array declaration int arr[]={1, 2, 3, 4, 5, 6}; //Assignment p = arr; for(int i=0; i<6;i++){ cout<<*p<<endl; // cout<<sizeof(p)<<endl; //++ moves the pointer to next int position p++; } return 0; }
14.875
51
0.498599
arryaaas
736a350791245f317f077731db992826be4c9aa1
6,502
cpp
C++
FMU/Source/Model_ExternalShading.cpp
kwabenantim/No-MASS
843ccaa461923e227a8e854daaa6952d14cb8bed
[ "MIT" ]
null
null
null
FMU/Source/Model_ExternalShading.cpp
kwabenantim/No-MASS
843ccaa461923e227a8e854daaa6952d14cb8bed
[ "MIT" ]
1
2020-08-28T18:11:26.000Z
2020-08-28T18:11:26.000Z
FMU/Source/Model_ExternalShading.cpp
kwabenantim/No-MASS
843ccaa461923e227a8e854daaa6952d14cb8bed
[ "MIT" ]
2
2020-02-05T10:49:42.000Z
2020-08-28T08:23:28.000Z
// Copyright 2015 Jacob Chapman #include <cmath> #include <algorithm> #include "Utility.hpp" #include "Model_ExternalShading.hpp" Model_ExternalShading::Model_ExternalShading() { a01arr = -7.41; b01inarr = 0.001035; b01sarr = 2.17; // Probability of raising on arrival a10arr = -1.520; b10inarr = -0.000654; b10sarr = -3.139; // Probability of lowering during presence a01int = -8.013; b01inint = 0.000841; b01sint = 1.270; // Probability of raising during presence a10int = -3.625; b10inint = -0.000276; b10sint = -2.683; // Probability of full raising afullraise = 0.435; boutfullraise = 1.95; bsfullraise = -0.0000231; // Choice of new unshaded fraction aSFlower = -2.294; bSFlower = 1.522; shapelower = 1.708; bsfulllower = 0.00000091; boutfulllower = -2.23; afulllower = -0.27; } void Model_ExternalShading::setFullVars(float afullraise, float boutfullraise, float bsfullraise, float bsfulllower, float boutfulllower, float afulllower) { this->afullraise = afullraise; this->boutfullraise = boutfullraise; this->bsfullraise = bsfullraise; this->bsfulllower = bsfulllower; this->boutfulllower = boutfulllower; this->afulllower = afulllower; } void Model_ExternalShading::setDurationVars(float aSFlower, float bSFlower, float shapelower) { this->aSFlower = aSFlower; this->bSFlower = bSFlower; this->shapelower = shapelower; } void Model_ExternalShading::setArrivalVars(float a01arr, float b01inarr, float b01sarr, float a10arr, float b10inarr, float b10sarr) { this->a01arr = a01arr; this->b01inarr = b01inarr; this->b01sarr = b01sarr; // Probability of raising on arrival this->a10arr = a10arr; this->b10inarr = b10inarr; this->b10sarr = b10sarr; } void Model_ExternalShading::setInterVars(float a01int, float b01inint, float b01sint, float a10int, float b10inint, float b10sint) { // Probability of lowering during presence this->a01int = a01int; this->b01inint = b01inint; this->b01sint = b01sint; // Probability of raising during presence this->a10int = a10int; this->b10inint = b10inint; this->b10sint = b10sint; } double Model_ExternalShading::arrival(double state, double Lumint, double Evg) { double currentShadingState; double probraise = 0.f; if (state != 1.f) { double m_raise = a10arr + b10inarr * Lumint + b10sarr * (state); probraise = probability(m_raise); } double problower = 0.f; if (state != 0.f) { double m_lower = a01arr + b01inarr * Lumint + b01sarr * (state); problower = probability(m_lower); } if (problower >= probraise) { if (randomDouble() < problower) { currentShadingState = arrivalLowering(state, Evg); } else if (randomDouble() < probraise) { currentShadingState = arrivalRaising(state, Evg); } else { currentShadingState = state; } } else { if (randomDouble() < probraise) { currentShadingState = arrivalRaising(state, Evg); } else if (randomDouble() < problower) { currentShadingState = arrivalLowering(state, Evg); } else { currentShadingState = state; } } return currentShadingState; } double Model_ExternalShading::intermediate(bool state, double Lumint, double Evg) { return departure(state, Lumint, Evg); } double Model_ExternalShading::departure(double state, double Lumint, double Evg) { double currentShadingState; float problower = 0.f; float probraise = 0.f; if (state != 1.f) { double m_probraise = a10int + b10inint * Lumint + b10sint * (state); probraise = probability(m_probraise); } if (state != 0.f) { double m_problower = a01int + b01inint * Lumint + b01sint * (state); problower = probability(m_problower); } if (problower >= probraise) { if (randomDouble() < problower) { currentShadingState = departureLowering(state, Evg); } else if (randomDouble() < probraise) { currentShadingState = departureRaising(state, Evg); } else { currentShadingState = state; } } else { if (randomDouble() < probraise) { currentShadingState = departureRaising(state, Evg); } else if (randomDouble() < problower) { currentShadingState = departureLowering(state, Evg); } else { currentShadingState = state; } } return currentShadingState; } double Model_ExternalShading::arrivalRaising(double state, double Evg) { double currentShadingState; double m_totraise = afullraise + boutfullraise * Evg + bsfullraise * (state); float ptotraise = probability(m_totraise); double r = randomDouble(); if (r < ptotraise) { currentShadingState = 1.f; } else { currentShadingState = 0.01f * round(100.f * randomDouble((state), 1.f)); } return currentShadingState; } double Model_ExternalShading::arrivalLowering(double state, double Evg) { double currentShadingState; double m_totlow = afulllower + boutfulllower * Evg + bsfulllower * (state); float ptotlow = probability(m_totlow); if (randomDouble() < ptotlow) { currentShadingState = 0.f; } else { float Reduction = randomWeibull(exp(aSFlower + bSFlower * (state)), shapelower); currentShadingState = 0.01f * round(100.f * std::max((state) - Reduction, 0.01)); } return currentShadingState; } double Model_ExternalShading::departureLowering(double state, double Evg) { double currentShadingState; double m_ptotlow = afulllower + boutfulllower * Evg + bsfulllower * (state); float ptotlow = probability(m_ptotlow); if (randomDouble() < ptotlow) { currentShadingState = (0.f); } else { float Reduction = randomWeibull(exp(aSFlower + bSFlower * (state)), shapelower); currentShadingState = 0.01f * round(100.f * std::max((state) - Reduction, 0.01)); } return currentShadingState; } double Model_ExternalShading::departureRaising(double state, double Evg) { double currentShadingState; double m_totraise = afullraise + boutfullraise * Evg + bsfullraise * (state); float ptotraise = probability(m_totraise); if (randomDouble(0.f, 1.f) < ptotraise) { currentShadingState = (1.f); } else { currentShadingState = 0.01f * round(100.f * randomDouble((state), 1.f)); } return currentShadingState; }
30.961905
80
0.665488
kwabenantim
736dc38180ef41f17243d9ce252f186d6be1eafc
656
h++
C++
clauses/select_clause.h++
snawaz/tagsql
1b6d6c9eb9aa2d01ff3276414d714f3b6e6a9ee3
[ "MIT" ]
4
2018-03-03T13:45:35.000Z
2021-05-22T12:11:08.000Z
clauses/select_clause.h++
snawaz/tagsql
1b6d6c9eb9aa2d01ff3276414d714f3b6e6a9ee3
[ "MIT" ]
1
2018-03-03T13:49:40.000Z
2019-01-22T07:58:47.000Z
clauses/select_clause.h++
snawaz/tagsql
1b6d6c9eb9aa2d01ff3276414d714f3b6e6a9ee3
[ "MIT" ]
1
2018-03-03T13:45:36.000Z
2018-03-03T13:45:36.000Z
#pragma once #include <memory> #include <pqxx/pqxx> #include <tagsql/anatomy/table.h++> namespace tagsql { template<typename SelectQuery> class composite_table; template<typename SelectQuery> class select_clause { public: select_clause(std::shared_ptr<pqxx::connection> & connection) : _connection(connection) {} template<typename Table> auto from(Table) -> composite_table<typename SelectQuery::template add_from<table_tag_t<Table>>::type> { return { _connection, "FROM " + metaspace::meta_table<table_tag_t<Table>>::name() }; } private: std::shared_ptr<pqxx::connection> _connection; }; } //tagsql
21.16129
105
0.705793
snawaz
737448c247448c9b272305bbc67b3dde1ebbe09c
7,037
cpp
C++
src/modeler/UpdateRulesHandler/update_rules_editor.cpp
rff255/Genesis
d87ff57e2c36f39bf62b4953f5f99190e82588f8
[ "MIT" ]
7
2017-08-08T17:10:58.000Z
2020-10-02T04:33:03.000Z
src/modeler/UpdateRulesHandler/update_rules_editor.cpp
rff255/Genesis
d87ff57e2c36f39bf62b4953f5f99190e82588f8
[ "MIT" ]
1
2017-05-02T01:50:22.000Z
2017-05-02T01:50:22.000Z
src/modeler/UpdateRulesHandler/update_rules_editor.cpp
rff255/Genesis
d87ff57e2c36f39bf62b4953f5f99190e82588f8
[ "MIT" ]
3
2017-09-01T08:04:44.000Z
2020-08-21T01:38:24.000Z
#include "update_rules_editor.h" #include "nodes_editor/imguinodegrapheditor.h" #include "UpdateRulesHandler/node_graph_instance.h" #include "JSON_nlohmann/json.hpp" #include <vector> #include <string> using json = nlohmann::json; UpdateRulesEditor::UpdateRulesEditor(){ mEditor = ImGui::NodeGraphEditor(); mEditor.show_node_copy_paste_buttons = false; mEditor.show_style_editor = false; mEditor.show_top_pane = true; InitNGE(mEditor); } void UpdateRulesEditor::InitFromSerializedData(json rules_editor) { // Restore editor setup // TODO() // Restore Nodes json nodes_list = rules_editor[serialization_tags::kNodesList]; std::unordered_map<int, int> old_to_new_node_id; for (auto& node_json : nodes_list) { const int node_old_id = node_json[serialization_tags::kNodeId]; const int node_type = node_json[serialization_tags::kNodeType]; const float node_pos[2] = {node_json[serialization_tags::kNodePos][0], node_json[serialization_tags::kNodePos][1]}; const string node_data = node_json[serialization_tags::kNodeData]; const json node_meta_data = node_json[serialization_tags::kNodeMetaData]; auto new_node = mEditor.addNode(node_type, ImVec2(node_pos[0], node_pos[1])); if(node_data.size()>0) new_node->SetupFromSerializedData(node_data); if(node_meta_data.size()>0) new_node->SetupFromSerializedMetaData(node_meta_data); const int new_id = new_node->mNodeId; old_to_new_node_id[node_old_id] = new_id; } // Restore Links json links_list = rules_editor[serialization_tags::kLinksList]; for (auto& link_json : links_list) { const int in_node_id_old = link_json[serialization_tags::kLinkInNode]; const int out_node_id_old = link_json[serialization_tags::kLinkOutNode]; const int in_port = link_json[serialization_tags::kLinkInPort]; const int out_port = link_json[serialization_tags::kLinkOutPort]; const int in_node_id_new = old_to_new_node_id[in_node_id_old]; const int out_node_id_new = old_to_new_node_id[out_node_id_old]; mEditor.addLink(mEditor.getNodeById(in_node_id_new), in_port, mEditor.getNodeById(out_node_id_new), out_port); } // Restore Nodes model configuration } json UpdateRulesEditor::GetSerializedData() { // Json = { // {kEditorSetup:{}}, // {kNodesList:['Node', 'Node', ...]}, // {kLinksList:['Link', 'Link', 'Link', ...]} // } // 'Node' = {<kNodeId>:1, <kNodeType>: 2, <kNodePos>:[200,500]} // 'Link' = {<kLinkInNode>:1, <kLinkOutNode>:2, <kLinkInPort>:0, <kLinkOutPort>:0} // Get editor options json editor_setup; // TODO(): Pan, zoom, style, selected nodes, and so on.. // Get nodes data json nodes_list; for(int i=0; i<mEditor.getNumNodes(); ++i) { const ImGui::Node* node = mEditor.getNode(i); const int node_id = node->mNodeId; const int node_type = node->getType(); const float node_pos[2] = {node->GetPos().x, node->GetPos().y}; const string node_data = node->GetSerializedData(); const json node_meta_data = node->GetSerializedMetaData(); nodes_list.push_back({{serialization_tags::kNodeId, node_id}, {serialization_tags::kNodeType, node_type}, {serialization_tags::kNodePos, node_pos}, {serialization_tags::kNodeData, node_data}, {serialization_tags::kNodeMetaData, node_meta_data}}); } // Get links data json links_list; for (int i=0; i<mEditor.getNumLinks();++i) { const ImGui::NodeLink* link = mEditor.getLink(i); const int in_node_id = link->InputNode->mNodeId; const int out_node_id = link->OutputNode->mNodeId; const int in_port = link->InputSlot; const int out_port = link->OutputSlot; links_list.push_back({{serialization_tags::kLinkInNode, in_node_id}, {serialization_tags::kLinkOutNode, out_node_id}, {serialization_tags::kLinkInPort, in_port}, {serialization_tags::kLinkOutPort, out_port}, }); } // Join everything json data = {{serialization_tags::kEditorSetup, editor_setup}, {serialization_tags::kNodesList, nodes_list}, {serialization_tags::kLinksList, links_list}}; return data; } std::string UpdateRulesEditor::EvalGraphEditorStep() { // Get the step node, for initiate the code generation ImVector<ImGui::Node*> stepNodes = ImVector<ImGui::Node*>(); // There is only one step node, but the function is generic mEditor.getAllNodesOfType(ImGui::NodeTypes::kStepNode, &stepNodes); // By calling the step Eval(), all the reachable nodes will be also called recursively if(stepNodes.size() > 0) return stepNodes[0]->Eval(mEditor, 0); return "void CACell::Step(){}\n"; } std::string UpdateRulesEditor::EvalGraphEditorDefaultInit() { // Get the DefaultInit node, for initiate the code generation ImVector<ImGui::Node*> defaultInitNodes = ImVector<ImGui::Node*>(); // There is only one default initialization node at most, but the function is generic mEditor.getAllNodesOfType(ImGui::NodeTypes::kDefaultInitializationNode, &defaultInitNodes); // By calling the step Eval(), all the reachable nodes will be also called recursively if(defaultInitNodes.size() > 0) return defaultInitNodes[0]->Eval(mEditor, 0); else { // No default has been defined. The function does nothing. return "void CACell::DefaultInit(){}\n"; } } std::string UpdateRulesEditor::EvalGraphEditorInputColorNodes() { // Get the InputColor nodes, for initiate the code generation ImVector<ImGui::Node*> InputColorNodes = ImVector<ImGui::Node*>(); mEditor.getAllNodesOfType(ImGui::NodeTypes::kInputColorNode, &InputColorNodes); std::string inputColorNodesCode = ""; // By calling the step Eval(), all the reachable nodes will be also called recursively for(auto node: InputColorNodes) inputColorNodesCode += node->Eval(mEditor, 0); return inputColorNodesCode; } void UpdateRulesEditor::UpdateComboBoxes(std::vector<std::string> cellAttrNames, std::vector<std::string> modelAttrNames, std::vector<std::string> neighborhoodNames, std::vector<std::string> colAttrMappingNames, std::vector<std::string> attrColMappingNames, std::vector<int> neighborhoodSizes) { gCellAttrNames = cellAttrNames; gModelAttrNames = modelAttrNames; gNeighborhoodNames = neighborhoodNames; gColAttrMappingsNames = colAttrMappingNames; gAttrColMappingsNames = attrColMappingNames; gNeighborhoodSizes = neighborhoodSizes; UpdateEnumNames(); } void UpdateModelAttrNames(std::vector<std::string> names) { gModelAttrNames = names; } void UpdateNeighborhoodNames(std::vector<std::string> names) { gNeighborhoodNames = names; }
38.453552
155
0.68623
rff255
73748955ce3f0f2a433ed54e4ef630ed4017c670
10,852
hh
C++
EnergyPlus/PoweredInductionUnits.hh
yurigabrich/EnergyPlusShadow
396ca83aa82b842e6b177ba35c91b3f481dfbbf9
[ "BSD-3-Clause" ]
null
null
null
EnergyPlus/PoweredInductionUnits.hh
yurigabrich/EnergyPlusShadow
396ca83aa82b842e6b177ba35c91b3f481dfbbf9
[ "BSD-3-Clause" ]
1
2020-07-08T13:32:09.000Z
2020-07-08T13:32:09.000Z
EnergyPlus/PoweredInductionUnits.hh
yurigabrich/EnergyPlusShadow
396ca83aa82b842e6b177ba35c91b3f481dfbbf9
[ "BSD-3-Clause" ]
null
null
null
// EnergyPlus, Copyright (c) 1996-2018, The Board of Trustees of the University of Illinois, // The Regents of the University of California, through Lawrence Berkeley National Laboratory // (subject to receipt of any required approvals from the U.S. Dept. of Energy), Oak Ridge // National Laboratory, managed by UT-Battelle, Alliance for Sustainable Energy, LLC, and other // contributors. All rights reserved. // // NOTICE: This Software was developed under funding from the U.S. Department of Energy and the // U.S. Government consequently retains certain rights. As such, the U.S. Government has been // granted for itself and others acting on its behalf a paid-up, nonexclusive, irrevocable, // worldwide license in the Software to reproduce, distribute copies to the public, prepare // derivative works, and perform publicly and display publicly, and to permit others to do so. // // Redistribution and use in source and binary forms, with or without modification, are permitted // provided that the following conditions are met: // // (1) Redistributions of source code must retain the above copyright notice, this list of // conditions and the following disclaimer. // // (2) Redistributions in binary form must reproduce the above copyright notice, this list of // conditions and the following disclaimer in the documentation and/or other materials // provided with the distribution. // // (3) Neither the name of the University of California, Lawrence Berkeley National Laboratory, // the University of Illinois, U.S. Dept. of Energy nor the names of its contributors may be // used to endorse or promote products derived from this software without specific prior // written permission. // // (4) Use of EnergyPlus(TM) Name. If Licensee (i) distributes the software in stand-alone form // without changes from the version obtained under this License, or (ii) Licensee makes a // reference solely to the software portion of its product, Licensee must refer to the // software as "EnergyPlus version X" software, where "X" is the version number Licensee // obtained under this License and may not use a different name for the software. Except as // specifically required in this Section (4), Licensee shall not use in a company name, a // product name, in advertising, publicity, or other promotional activities any name, trade // name, trademark, logo, or other designation of "EnergyPlus", "E+", "e+" or confusingly // similar designation, without the U.S. Department of Energy's prior written consent. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR // IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY // AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR // OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE // POSSIBILITY OF SUCH DAMAGE. #ifndef PoweredInductionUnits_hh_INCLUDED #define PoweredInductionUnits_hh_INCLUDED // ObjexxFCL Headers #include <ObjexxFCL/Array1D.hh> // EnergyPlus Headers #include <DataGlobals.hh> #include <EnergyPlus.hh> namespace EnergyPlus { namespace PoweredInductionUnits { // Using/Aliasing // Data // MODULE PARAMETER DEFINITIONS extern int const SingleDuct_SeriesPIU_Reheat; extern int const SingleDuct_ParallelPIU_Reheat; // coil types in this module extern int const HCoilType_Gas; extern int const HCoilType_Electric; extern int const HCoilType_SimpleHeating; extern int const HCoilType_SteamAirHeating; // DERIVED TYPE DEFINITIONS // MODULE VARIABLE DECLARATIONS: extern Array1D_bool CheckEquipName; extern int NumPIUs; extern int NumSeriesPIUs; extern int NumParallelPIUs; // SUBROUTINE SPECIFICATIONS FOR MODULE // PRIVATE UpdatePIU // Types struct PowIndUnitData { // Members // input data std::string Name; // name of unit std::string UnitType; // type of unit int UnitType_Num; // index for type of unit std::string Sched; // availability schedule int SchedPtr; // index to schedule Real64 MaxTotAirVolFlow; // m3/s (series) Real64 MaxTotAirMassFlow; // kg/s (series) Real64 MaxPriAirVolFlow; // m3/s Real64 MaxPriAirMassFlow; // kg/s Real64 MinPriAirFlowFrac; // minimum primary air flow fraction Real64 MinPriAirMassFlow; // kg/s Real64 MaxSecAirVolFlow; // m3/s (parallel) Real64 MaxSecAirMassFlow; // kg/s (parallel) Real64 FanOnFlowFrac; // frac of primary air flow at which fan turns on (parallel) Real64 FanOnAirMassFlow; // primary air mass flow rate at which fan turns on (parallel) int PriAirInNode; // unit primary air inlet node number int SecAirInNode; // unit secondary air inlet node number int OutAirNode; // unit air outlet node number int HCoilInAirNode; // unit mixed air node number int ControlCompTypeNum; int CompErrIndex; std::string MixerName; // name of air mixer component int Mixer_Num; // index for type of mixer std::string FanName; // name of fan component int Fan_Num; // index for fan type int Fan_Index; // store index for this fan int FanAvailSchedPtr; // index to fan availability schedule std::string HCoilType; // type of heating coil component int HCoilType_Num; // index for heating coil type int HCoil_PlantTypeNum; std::string HCoil; // name of heating coil component int HCoil_Index; // index to this heating coil int HCoil_FluidIndex; Real64 MaxVolHotWaterFlow; // m3/s Real64 MaxVolHotSteamFlow; // m3/s Real64 MaxHotWaterFlow; // kg/s Real64 MaxHotSteamFlow; // kg/s Real64 MinVolHotWaterFlow; // m3/s Real64 MinHotSteamFlow; // kg/s Real64 MinVolHotSteamFlow; // m3/s Real64 MinHotWaterFlow; // kg/s int HotControlNode; // hot water control node int HotCoilOutNodeNum; // outlet of coil Real64 HotControlOffset; // control tolerance int HWLoopNum; // index for plant loop with hot plant coil int HWLoopSide; // index for plant loop side for hot plant coil int HWBranchNum; // index for plant branch for hot plant coil int HWCompNum; // index for plant component for hot plant coil int ADUNum; // index of corresponding air distribution unit bool InducesPlenumAir; // True if secondary air comes from the plenum // Report data Real64 HeatingRate; // unit heat addition rate to zone [W] Real64 HeatingEnergy; // unit heat addition to zone [J] Real64 SensCoolRate; // unit sensible heat removal rate from zone [W] Real64 SensCoolEnergy; // unit sensible heat removal from zone [J] int CtrlZoneNum; // index to control zone int ctrlZoneInNodeIndex; // index to the control zone inlet node int AirLoopNum; // index for the air loop that this terminal is connected to. // Default Constructor PowIndUnitData() : UnitType_Num(0), SchedPtr(0), MaxTotAirVolFlow(0.0), MaxTotAirMassFlow(0.0), MaxPriAirVolFlow(0.0), MaxPriAirMassFlow(0.0), MinPriAirFlowFrac(0.0), MinPriAirMassFlow(0.0), MaxSecAirVolFlow(0.0), MaxSecAirMassFlow(0.0), FanOnFlowFrac(0.0), FanOnAirMassFlow(0.0), PriAirInNode(0), SecAirInNode(0), OutAirNode(0), HCoilInAirNode(0), ControlCompTypeNum(0), CompErrIndex(0), Mixer_Num(0), Fan_Num(0), Fan_Index(0), FanAvailSchedPtr(0), HCoilType_Num(0), HCoil_PlantTypeNum(0), HCoil_Index(0), HCoil_FluidIndex(0), MaxVolHotWaterFlow(0.0), MaxVolHotSteamFlow(0.0), MaxHotWaterFlow(0.0), MaxHotSteamFlow(0.0), MinVolHotWaterFlow(0.0), MinHotSteamFlow(0.0), MinVolHotSteamFlow(0.0), MinHotWaterFlow(0.0), HotControlNode(0), HotCoilOutNodeNum(0), HotControlOffset(0.0), HWLoopNum(0), HWLoopSide(0), HWBranchNum(0), HWCompNum(0), ADUNum(0), InducesPlenumAir(false), HeatingRate(0.0), HeatingEnergy(0.0), SensCoolRate(0.0), SensCoolEnergy(0.0), CtrlZoneNum(0), AirLoopNum(0) { } }; // Object Data extern Array1D<PowIndUnitData> PIU; // Functions void clear_state(); void SimPIU(std::string const &CompName, // name of the PIU bool const FirstHVACIteration, // TRUE if first HVAC iteration in time step int const ZoneNum, // index of zone served by PIU int const ZoneNodeNum, // zone node number of zone served by PIU int &CompIndex // PIU Index in PIU names ); void GetPIUs(); void InitPIU(int const PIUNum, // number of the current fan coil unit being simulated bool const FirstHVACIteration // TRUE if first zone equip this HVAC step ); void SizePIU(int const PIUNum); void CalcSeriesPIU(int const PIUNum, // number of the current PIU being simulated int const ZoneNum, // number of zone being served int const ZoneNode, // zone node number bool const FirstHVACIteration // TRUE if 1st HVAC simulation of system timestep ); void CalcParallelPIU(int const PIUNum, // number of the current PIU being simulated int const ZoneNum, // number of zone being served int const ZoneNode, // zone node number bool const FirstHVACIteration // TRUE if 1st HVAC simulation of system timestep ); void ReportPIU(int const PIUNum); // number of the current fan coil unit being simulated // ===================== Utilities ===================================== bool PIUnitHasMixer(std::string const &CompName); // component (mixer) name void PIUInducesPlenumAir(int const NodeNum); // induced air node number } // namespace PoweredInductionUnits } // namespace EnergyPlus #endif
50.948357
149
0.670015
yurigabrich
737916aa21b542adcc8c48d41953b70d67589cfb
499
cpp
C++
test/doc/all_of.cpp
jfalcou/kumi
09116696274bd38254d89636ea3d0d4b5eb43103
[ "MIT" ]
14
2021-11-20T15:21:08.000Z
2022-03-14T21:47:22.000Z
test/doc/all_of.cpp
jfalcou/kumi
09116696274bd38254d89636ea3d0d4b5eb43103
[ "MIT" ]
6
2021-11-27T17:50:48.000Z
2022-02-01T18:17:38.000Z
test/doc/all_of.cpp
jfalcou/kumi
09116696274bd38254d89636ea3d0d4b5eb43103
[ "MIT" ]
1
2022-02-21T23:06:03.000Z
2022-02-21T23:06:03.000Z
//================================================================================================== /* KUMI - Compact Tuple Tools Copyright : KUMI Contributors & Maintainers SPDX-License-Identifier: MIT */ //================================================================================================== #include <kumi/tuple.hpp> #include <iostream> int main() { auto t = kumi::tuple{1,2.,3.f}; std::cout << std::boolalpha << kumi::all_of( t, [](auto e) { return e < 5; }) << "\n"; }
31.1875
100
0.368737
jfalcou
737be9cd1d1475cf0bcf3826189369c0bf03ac8f
2,091
cpp
C++
Sample/Sample/CustomFilter.cpp
timtianyang/PCL_region_growing
b138d257ca836bdd4d960014944d4991bfa12e79
[ "MIT" ]
null
null
null
Sample/Sample/CustomFilter.cpp
timtianyang/PCL_region_growing
b138d257ca836bdd4d960014944d4991bfa12e79
[ "MIT" ]
null
null
null
Sample/Sample/CustomFilter.cpp
timtianyang/PCL_region_growing
b138d257ca836bdd4d960014944d4991bfa12e79
[ "MIT" ]
null
null
null
#include "stdafx.h" #include "CustomFilter.h" /* CustomFilter::CustomFilter(pcl::PointCloud<pcl::PointXYZRGB>::Ptr *input, double xmin, double xmax, double ymin, double ymax){ input_cloud_XYZRGB = input; std::cout << xmin << xmax << ymin << ymax <<std::endl; std::cout << "before filtering " << (*input)->points.size() << std::endl; filtered_cloud_XYZRGB = pcl::PointCloud<pcl::PointXYZRGB>::Ptr(new pcl::PointCloud<pcl::PointXYZRGB>); pcl::PointCloud<pcl::PointXYZRGB>::Ptr temp_cloud_XYZRGB(new pcl::PointCloud<pcl::PointXYZRGB>); pcl::PassThrough<pcl::PointXYZRGB> pass; pass.setInputCloud((*input_cloud_XYZRGB));//x direction pass.setFilterFieldName("x"); pass.setFilterLimits(xmin, xmax); pass.filter(*temp_cloud_XYZRGB); pass.setInputCloud(temp_cloud_XYZRGB);//y direction pass.setFilterFieldName("y"); pass.setFilterLimits(ymin, ymax); pass.filter(*filtered_cloud_XYZRGB); std::cout << "after filtering " << filtered_cloud_XYZRGB->points.size(); } CustomFilter::CustomFilter(pcl::PointCloud<pcl::PointXYZI>::Ptr *input, double xmin, double xmax, double ymin, double ymax){ input_cloud_XYZI = input; std::cout << xmin << xmax << ymin << ymax << std::endl; std::cout << "before filtering " << (*input)->points.size() << std::endl; filtered_cloud_XYZI = pcl::PointCloud<pcl::PointXYZI>::Ptr(new pcl::PointCloud<pcl::PointXYZI>); pcl::PointCloud<pcl::PointXYZI>::Ptr temp_cloud_XYZI(new pcl::PointCloud<pcl::PointXYZI>); pcl::PassThrough<pcl::PointXYZI> pass; pass.setInputCloud((*input_cloud_XYZI));//x direction pass.setFilterFieldName("x"); pass.setFilterLimits(xmin, xmax); pass.filter(*temp_cloud_XYZI); pass.setInputCloud(temp_cloud_XYZI);//y direction pass.setFilterFieldName("y"); pass.setFilterLimits(ymin, ymax); pass.filter(*filtered_cloud_XYZI); std::cout << "after filtering " << filtered_cloud_XYZI->points.size(); } */ /* pcl::PointCloud<pcl::PointXYZI>::Ptr *CustomFilter::getOutputXYZI(){ return &filtered_cloud_XYZI; } pcl::PointCloud<pcl::PointXYZRGB>::Ptr *CustomFilter::getOutputXYZRGB(){ return &filtered_cloud_XYZRGB; }*/
37.339286
126
0.735533
timtianyang
737f32c7f1f444d613d4345d25985acd5d111aff
1,277
cpp
C++
Driver/src/AlephManager.cpp
gganis/AlphappLite
e52a184c2d39a3acdd6ff09d1d61bcfca7807460
[ "Apache-2.0" ]
null
null
null
Driver/src/AlephManager.cpp
gganis/AlphappLite
e52a184c2d39a3acdd6ff09d1d61bcfca7807460
[ "Apache-2.0" ]
null
null
null
Driver/src/AlephManager.cpp
gganis/AlphappLite
e52a184c2d39a3acdd6ff09d1d61bcfca7807460
[ "Apache-2.0" ]
null
null
null
////////////////////////////////////////////////////// // // Implementation of class AlephManager // // The Base Class for an AlephManager (IO, DB, EXE,...) // // Author : G. Dissertori , 02.11.98 // ////////////////////////////////////////////////////// #include <string> #include <iostream> #include <fstream> #include "AlephManager.h" extern ofstream fout; // // the "constructor" sets the managerType and initializes other // private members // void AlephManager::AlephManagerSetup(const string& aManagerType) { // store the manager type _thisManagerType.assign(aManagerType); // set the pointer to the session _theSession = AlephSession::TheAlephSession(); // set the status _theStatus = CREATED; } // // the "destructor" frees the heap // void AlephManager::AlephManagerShutDown() { _theStatus = DELETED; } // // get the pointer to the session // AlephSession* AlephManager::alephSession() const { return _theSession; } // // get the managerType // string AlephManager::managerType() const { return _thisManagerType; } // // set the status // void AlephManager::setStatus(const AlephStatus& statusNow) { _theStatus = statusNow; } // // get the status // AlephStatus AlephManager::status() const { return _theStatus; }
14.678161
64
0.638215
gganis
7383b64784e5cd275669abc164dd5559126314d3
90
cpp
C++
src/examples/06_module/02_shapes/circle.cpp
acc-cosc-1337-fall-2020/acc-cosc-1337-fall-2020-boscojohn-ship
7b050c896252bd7c32972728e4a0792bdf1f0fa0
[ "MIT" ]
null
null
null
src/examples/06_module/02_shapes/circle.cpp
acc-cosc-1337-fall-2020/acc-cosc-1337-fall-2020-boscojohn-ship
7b050c896252bd7c32972728e4a0792bdf1f0fa0
[ "MIT" ]
null
null
null
src/examples/06_module/02_shapes/circle.cpp
acc-cosc-1337-fall-2020/acc-cosc-1337-fall-2020-boscojohn-ship
7b050c896252bd7c32972728e4a0792bdf1f0fa0
[ "MIT" ]
null
null
null
//circle.cpp #include "circle.h" void Circle::draw() { std::cout<<"draw circle\n"; };
12.857143
31
0.611111
acc-cosc-1337-fall-2020
7387f9f8992e8b6c6a6aa4cc11eb4add18c8e617
3,159
cpp
C++
tests/test_depth_maps_pm.cpp
kpilyugin/PhotogrammetryTasks2021
7da69f04909075340a220a7021efeeb42283d9dc
[ "MIT" ]
null
null
null
tests/test_depth_maps_pm.cpp
kpilyugin/PhotogrammetryTasks2021
7da69f04909075340a220a7021efeeb42283d9dc
[ "MIT" ]
null
null
null
tests/test_depth_maps_pm.cpp
kpilyugin/PhotogrammetryTasks2021
7da69f04909075340a220a7021efeeb42283d9dc
[ "MIT" ]
null
null
null
#include <gtest/gtest.h> #include <opencv2/core.hpp> #include <opencv2/opencv.hpp> #include <fstream> #include <libutils/timer.h> #include <libutils/rasserts.h> #include <libutils/string_utils.h> #include <phg/utils/point_cloud_export.h> #include <phg/utils/cameras_bundler_import.h> #include <phg/mvs/depth_maps/pm_depth_maps.h> #include <phg/mvs/depth_maps/pm_geometry.h> #include "utils/test_utils.h" //________________________________________________________________________________ // Datasets: // достаточно чтобы у вас работало на этом датасете, тестирование на Travis CI тоже ведется на нем //#define DATASET_DIR "saharov32" //#define DATASET_DOWNSCALE 4 //#define DATASET_DIR "temple47" //#define DATASET_DOWNSCALE 2 // скачайте картинки этого датасета в папку data/src/datasets/herzjesu25/ по ссылке из файла LINK.txt в папке датасета #define DATASET_DIR "herzjesu25" #define DATASET_DOWNSCALE 8 //________________________________________________________________________________ TEST (test_depth_maps_pm, FirstStereoPair) { Dataset dataset = loadDataset(DATASET_DIR, DATASET_DOWNSCALE); phg::PMDepthMapsBuilder builder(dataset.ncameras, dataset.cameras_imgs, dataset.cameras_imgs_grey, dataset.cameras_labels, dataset.cameras_P, dataset.calibration); size_t ci = 2; size_t cameras_limit = 5; dataset.ncameras = cameras_limit; cv::Mat depth_map, normal_map, cost_map; builder.buildDepthMap(ci, depth_map, cost_map, normal_map, dataset.cameras_depth_min[ci], dataset.cameras_depth_max[ci]); } TEST (test_depth_maps_pm, AllDepthMaps) { Dataset full_dataset = loadDataset(DATASET_DIR, DATASET_DOWNSCALE); const size_t ref_camera_shift = 2; const size_t to_shift = 5; std::vector<cv::Vec3d> all_points; std::vector<cv::Vec3b> all_colors; std::vector<cv::Vec3d> all_normals; size_t ndepth_maps = 0; for (size_t from = 0; from + to_shift < full_dataset.ncameras; ++from) { size_t to = from + to_shift; Dataset dataset = full_dataset.subset(from, to); phg::PMDepthMapsBuilder builder(dataset.ncameras, dataset.cameras_imgs, dataset.cameras_imgs_grey, dataset.cameras_labels, dataset.cameras_P, dataset.calibration); cv::Mat depth_map, normal_map, cost_map; builder.buildDepthMap(ref_camera_shift, depth_map, cost_map, normal_map, dataset.cameras_depth_min[ref_camera_shift], dataset.cameras_depth_max[ref_camera_shift]); phg::PMDepthMapsBuilder::buildGoodPoints(depth_map, normal_map, cost_map, dataset.cameras_imgs[ref_camera_shift], dataset.calibration, builder.cameras_PtoWorld[ref_camera_shift], all_points, all_colors, all_normals); ++ndepth_maps; std::string tie_points_filename = std::string("data/debug/") + getTestSuiteName() + "/" + getTestName() + "/all_points_" + to_string(ndepth_maps) + ".ply"; phg::exportPointCloud(all_points, tie_points_filename, all_colors, all_normals); } }
41.565789
171
0.716682
kpilyugin
738c7f95937e3f405448f7d9b026ded9d81c9c0f
25
cc
C++
physicalBox.cc
dfyzy/simpleGL
55790726559b46be596d16c294940ba629bd838c
[ "MIT" ]
1
2016-10-16T21:19:21.000Z
2016-10-16T21:19:21.000Z
physicalBox.cc
dfyzy/simpleGL
55790726559b46be596d16c294940ba629bd838c
[ "MIT" ]
null
null
null
physicalBox.cc
dfyzy/simpleGL
55790726559b46be596d16c294940ba629bd838c
[ "MIT" ]
null
null
null
#include "physicalBox.h"
12.5
24
0.76
dfyzy
738e715543f861d974c6fb8e827a5889e462391c
7,577
cpp
C++
src/modules/events/temperature_calibration/gyro.cpp
mgkim3070/Drone_Firmware
6843061ce5eb573424424598cf3bac33e037d4d0
[ "BSD-3-Clause" ]
null
null
null
src/modules/events/temperature_calibration/gyro.cpp
mgkim3070/Drone_Firmware
6843061ce5eb573424424598cf3bac33e037d4d0
[ "BSD-3-Clause" ]
null
null
null
src/modules/events/temperature_calibration/gyro.cpp
mgkim3070/Drone_Firmware
6843061ce5eb573424424598cf3bac33e037d4d0
[ "BSD-3-Clause" ]
null
null
null
/**************************************************************************** * * Copyright (c) 2017 PX4 Development Team. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * 3. Neither the name PX4 nor the names of its contributors may be * used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************/ /** * @file gyro.cpp * Implementation of the Gyro Temperature Calibration for onboard sensors. * * @author Siddharth Bharat Purohit * @author Beat Küng <[email protected]> */ #include <mathlib/mathlib.h> #include <uORB/topics/sensor_gyro.h> #include "gyro.h" #include <drivers/drv_hrt.h> TemperatureCalibrationGyro::TemperatureCalibrationGyro(float min_temperature_rise, float min_start_temperature, float max_start_temperature, int gyro_subs[], int num_gyros) : TemperatureCalibrationCommon(min_temperature_rise, min_start_temperature, max_start_temperature) { for (int i = 0; i < num_gyros; ++i) { _sensor_subs[i] = gyro_subs[i]; } _num_sensor_instances = num_gyros; } void TemperatureCalibrationGyro::reset_calibration() { /* reset all driver level calibrations */ float offset = 0.0f; float scale = 1.0f; for (unsigned s = 0; s < 3; s++) { set_parameter("CAL_GYRO%u_XOFF", s, &offset); set_parameter("CAL_GYRO%u_YOFF", s, &offset); set_parameter("CAL_GYRO%u_ZOFF", s, &offset); set_parameter("CAL_GYRO%u_XSCALE", s, &scale); set_parameter("CAL_GYRO%u_YSCALE", s, &scale); set_parameter("CAL_GYRO%u_ZSCALE", s, &scale); } } int TemperatureCalibrationGyro::update_sensor_instance(PerSensorData &data, int sensor_sub) { bool finished = data.hot_soaked; bool updated; orb_check(sensor_sub, &updated); if (!updated) { return finished ? 0 : 1; } sensor_gyro_s gyro_data; orb_copy(ORB_ID(sensor_gyro), sensor_sub, &gyro_data); if (finished) { // if we're done, return, but we need to return after orb_copy because of poll() return 0; } data.device_id = gyro_data.device_id; data.sensor_sample_filt[0] = gyro_data.x; data.sensor_sample_filt[1] = gyro_data.y; data.sensor_sample_filt[2] = gyro_data.z; data.sensor_sample_filt[3] = gyro_data.temperature; // wait for min start temp to be reached before starting calibration if (data.sensor_sample_filt[3] < _min_start_temperature) { return 1; } if (!data.cold_soaked) { // allow time for sensors and filters to settle if (hrt_absolute_time() > 10E6) { // If intial temperature exceeds maximum declare an error condition and exit if (data.sensor_sample_filt[3] > _max_start_temperature) { return -TC_ERROR_INITIAL_TEMP_TOO_HIGH; } else { data.cold_soaked = true; data.low_temp = data.sensor_sample_filt[3]; // Record the low temperature data.high_temp = data.low_temp; // Initialise the high temperature to the initial temperature data.ref_temp = data.sensor_sample_filt[3] + 0.5f * _min_temperature_rise; return 1; } } else { return 1; } } // check if temperature increased if (data.sensor_sample_filt[3] > data.high_temp) { data.high_temp = data.sensor_sample_filt[3]; data.hot_soak_sat = 0; } else { return 1; } //TODO: Detect when temperature has stopped rising for more than TBD seconds if (data.hot_soak_sat == 10 || (data.high_temp - data.low_temp) > _min_temperature_rise) { data.hot_soaked = true; } if (sensor_sub == _sensor_subs[0]) { // debug output, but only for the first sensor TC_DEBUG("\nGyro: %.20f,%.20f,%.20f,%.20f, %.6f, %.6f, %.6f\n\n", (double)data.sensor_sample_filt[0], (double)data.sensor_sample_filt[1], (double)data.sensor_sample_filt[2], (double)data.sensor_sample_filt[3], (double)data.low_temp, (double)data.high_temp, (double)(data.high_temp - data.low_temp)); } //update linear fit matrices double relative_temperature = (double)data.sensor_sample_filt[3] - (double)data.ref_temp; data.P[0].update(relative_temperature, (double)data.sensor_sample_filt[0]); data.P[1].update(relative_temperature, (double)data.sensor_sample_filt[1]); data.P[2].update(relative_temperature, (double)data.sensor_sample_filt[2]); return 1; } int TemperatureCalibrationGyro::finish() { for (unsigned uorb_index = 0; uorb_index < _num_sensor_instances; uorb_index++) { finish_sensor_instance(_data[uorb_index], uorb_index); } int32_t enabled = 1; int result = param_set_no_notification(param_find("TC_G_ENABLE"), &enabled); if (result != PX4_OK) { PX4_ERR("unable to reset TC_G_ENABLE (%i)", result); } return result; } int TemperatureCalibrationGyro::finish_sensor_instance(PerSensorData &data, int sensor_index) { if (!data.hot_soaked || data.tempcal_complete) { return 0; } double res[3][4] = {}; data.P[0].fit(res[0]); PX4_INFO("Result Gyro %d Axis 0: %.20f %.20f %.20f %.20f", sensor_index, (double)res[0][0], (double)res[0][1], (double)res[0][2], (double)res[0][3]); data.P[1].fit(res[1]); PX4_INFO("Result Gyro %d Axis 1: %.20f %.20f %.20f %.20f", sensor_index, (double)res[1][0], (double)res[1][1], (double)res[1][2], (double)res[1][3]); data.P[2].fit(res[2]); PX4_INFO("Result Gyro %d Axis 2: %.20f %.20f %.20f %.20f", sensor_index, (double)res[2][0], (double)res[2][1], (double)res[2][2], (double)res[2][3]); data.tempcal_complete = true; char str[30]; float param = 0.0f; int result = PX4_OK; set_parameter("TC_G%d_ID", sensor_index, &data.device_id); for (unsigned axis_index = 0; axis_index < 3; axis_index++) { for (unsigned coef_index = 0; coef_index <= 3; coef_index++) { sprintf(str, "TC_G%d_X%d_%d", sensor_index, 3 - coef_index, axis_index); param = (float)res[axis_index][coef_index]; result = param_set_no_notification(param_find(str), &param); if (result != PX4_OK) { PX4_ERR("unable to reset %s", str); } } } set_parameter("TC_G%d_TMAX", sensor_index, &data.high_temp); set_parameter("TC_G%d_TMIN", sensor_index, &data.low_temp); set_parameter("TC_G%d_TREF", sensor_index, &data.ref_temp); return 0; }
35.078704
123
0.686287
mgkim3070
7393c79c57121f10e1fa8e964b56e5a068e2892d
2,926
cpp
C++
Src/Common/SceneControl/PointLightSceneNode.cpp
StavrosBizelis/NetworkDistributedDeferredShading
07c03ce9b13bb5adb164cd4321b2bba284e49b4d
[ "MIT" ]
null
null
null
Src/Common/SceneControl/PointLightSceneNode.cpp
StavrosBizelis/NetworkDistributedDeferredShading
07c03ce9b13bb5adb164cd4321b2bba284e49b4d
[ "MIT" ]
null
null
null
Src/Common/SceneControl/PointLightSceneNode.cpp
StavrosBizelis/NetworkDistributedDeferredShading
07c03ce9b13bb5adb164cd4321b2bba284e49b4d
[ "MIT" ]
null
null
null
#include "Common/SceneControl/PointLightSceneNode.h" #include <algorithm> #include <iostream> namespace SceneControl { PointLightSceneNode::PointLightSceneNode(SceneNode* a_parent, std::shared_ptr<ASphere> a_sphere ) : LightSceneNode(a_parent) { m_sphere = a_sphere; } PointLightSceneNode::~PointLightSceneNode() { } void PointLightSceneNode::Init(){ } void PointLightSceneNode::Render(glutil::MatrixStack & a_matrix) const { if (!GetEnabled()) return; // std::shared_ptr<IShaderProgram> l_material0 = GetMaterial(1); // null material std::shared_ptr<IShaderProgram> l_material1 = GetMaterial(0); // light material // cannot render without the proper materials // if (!l_material0 || !l_material1) if (!l_material1) return; // apply absolute tranformation and push it in the a_matrix.Push(); a_matrix.ApplyMatrix(m_lastAbsoluteTrans); // do the stencil test pass // // // // // // // // // // // // // // l_material0->UseProgram(); // // // // // // // // // // // // // // l_material0->SetUniform("matrices.projModelViewMatrixStack", a_matrix.Top()); // // // // // // // // // // // // // // m_sphere->Render(); // do the light pass l_material1->UseProgram(); l_material1->SetUniform("matrices.projModelViewMatrixStack", a_matrix.Top()); //l_material1->SetUniform("UInverseViewProjectionMatrix", glm::inverse( a_matrix.Top() ) ); glm::vec3 l_pos( m_lastAbsoluteTrans[3][0], m_lastAbsoluteTrans[3][1], m_lastAbsoluteTrans[3][2] ); l_material1->SetUniform("ULightData.m_position", l_pos ); // set the light state to the material ( attenuation, colour ) l_material1->SetUniform("ULightData.m_constantAtt", m_constantAtt); l_material1->SetUniform("ULightData.m_linearAtt", m_linearAtt); l_material1->SetUniform("ULightData.m_quadraticAtt", m_quadraticAtt); l_material1->SetUniform("ULightData.m_diffuse", m_difCol); l_material1->SetUniform("ULightData.m_specular", m_specCol); m_sphere->Render(); a_matrix.Pop(); } void PointLightSceneNode::Update(const double & a_deltaTime, bool a_dirty, const glm::mat4 & a_parentAbsoluteTrans) { if (!GetEnabled()) return; if (m_lightDirty) UpdateMesh(); SceneNode::Update(a_deltaTime, a_dirty, a_parentAbsoluteTrans); } void PointLightSceneNode::UpdateMesh() { float l_maxChannel = std::max(std::max(m_difCol.r, m_difCol.g), m_difCol.b); float l_intensity = 0.2126f * m_difCol.x + 0.7152f * m_difCol.y + 0.0722f * m_difCol.z;;// (m_difCol.r + m_difCol.g + m_difCol.b) ; float ret = (-m_linearAtt + sqrtf( pow(m_linearAtt, 2) - 4 * m_quadraticAtt * (m_constantAtt - (256.f) * l_maxChannel * l_intensity/*intensity*/)) ) / float(2 * m_quadraticAtt); std::cout << "POINT LIGHT SCALE: " << ret << std::endl; if (ret > 0) SetScale(glm::vec3(ret)); else SetScale(glm::vec3(.1)); m_lightDirty = false; } }
26.36036
150
0.678742
StavrosBizelis
739491676802e865170067d53256855ed137f7fe
44,364
cpp
C++
cocos2d/cocos/scripting/javascript/bindings/ScriptingCore.cpp
hiepns/OpenBird
9e0198a1a2295f03fa1e8676e216e22c9c7d380b
[ "MIT" ]
174
2015-01-01T15:12:53.000Z
2022-03-23T03:06:07.000Z
cocos2d/cocos/scripting/javascript/bindings/ScriptingCore.cpp
shuaibin-lam/OpenBird
762ab527a4a6bc7ede02ae6eb4f0702d21943f1b
[ "MIT" ]
2
2015-05-20T14:34:48.000Z
2019-08-14T00:54:40.000Z
cocos2d/cocos/scripting/javascript/bindings/ScriptingCore.cpp
shuaibin-lam/OpenBird
762ab527a4a6bc7ede02ae6eb4f0702d21943f1b
[ "MIT" ]
103
2015-01-10T13:34:24.000Z
2022-01-10T00:55:33.000Z
// // ScriptingCore.cpp // testmonkey // // Created by Rolando Abarca on 3/14/12. // Copyright (c) 2012 Zynga Inc. All rights reserved. // #include <iostream> #include <stdio.h> #include <stdlib.h> #include <sys/stat.h> #include <fcntl.h> #include <vector> #include <map> #include "ScriptingCore.h" #include "jsdbgapi.h" #include "cocos2d.h" #include "local-storage/LocalStorage.h" #include "cocos2d_specifics.hpp" #include "js_bindings_config.h" // for debug socket #if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) #include <io.h> #include <WS2tcpip.h> #else #include <sys/socket.h> #include <unistd.h> #include <netdb.h> #endif #include <thread> #ifdef ANDROID #include <android/log.h> #include <jni/JniHelper.h> #include <netinet/in.h> #endif #ifdef ANDROID #define LOG_TAG "ScriptingCore.cpp" #define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG,LOG_TAG,__VA_ARGS__) #else #define LOGD(...) js_log(__VA_ARGS__) #endif #include "js_bindings_config.h" #if COCOS2D_DEBUG #define TRACE_DEBUGGER_SERVER(...) CCLOG(__VA_ARGS__) #else #define TRACE_DEBUGGER_SERVER(...) #endif // #if DEBUG #define BYTE_CODE_FILE_EXT ".jsc" using namespace cocos2d; static std::string inData; static std::string outData; static std::vector<std::string> g_queue; static std::mutex g_qMutex; static std::mutex g_rwMutex; static int clientSocket = -1; static uint32_t s_nestedLoopLevel = 0; // server entry point for the bg thread static void serverEntryPoint(void); js_proxy_t *_native_js_global_ht = NULL; js_proxy_t *_js_native_global_ht = NULL; std::unordered_map<std::string, js_type_class_t*> _js_global_type_map; static char *_js_log_buf = NULL; static std::vector<sc_register_sth> registrationList; // name ~> JSScript map static std::unordered_map<std::string, JSScript*> filename_script; // port ~> socket map static std::unordered_map<int,int> ports_sockets; // name ~> globals static std::unordered_map<std::string, js::RootedObject*> globals; static void ReportException(JSContext *cx) { if (JS_IsExceptionPending(cx)) { if (!JS_ReportPendingException(cx)) { JS_ClearPendingException(cx); } } } static void executeJSFunctionFromReservedSpot(JSContext *cx, JSObject *obj, jsval &dataVal, jsval &retval) { jsval func = JS_GetReservedSlot(obj, 0); if (func == JSVAL_VOID) { return; } jsval thisObj = JS_GetReservedSlot(obj, 1); JSAutoCompartment ac(cx, obj); if (thisObj == JSVAL_VOID) { JS_CallFunctionValue(cx, obj, func, 1, &dataVal, &retval); } else { assert(!JSVAL_IS_PRIMITIVE(thisObj)); JS_CallFunctionValue(cx, JSVAL_TO_OBJECT(thisObj), func, 1, &dataVal, &retval); } } static void getTouchesFuncName(EventTouch::EventCode eventCode, std::string &funcName) { switch(eventCode) { case EventTouch::EventCode::BEGAN: funcName = "onTouchesBegan"; break; case EventTouch::EventCode::ENDED: funcName = "onTouchesEnded"; break; case EventTouch::EventCode::MOVED: funcName = "onTouchesMoved"; break; case EventTouch::EventCode::CANCELLED: funcName = "onTouchesCancelled"; break; } } static void getTouchFuncName(EventTouch::EventCode eventCode, std::string &funcName) { switch(eventCode) { case EventTouch::EventCode::BEGAN: funcName = "onTouchBegan"; break; case EventTouch::EventCode::ENDED: funcName = "onTouchEnded"; break; case EventTouch::EventCode::MOVED: funcName = "onTouchMoved"; break; case EventTouch::EventCode::CANCELLED: funcName = "onTouchCancelled"; break; } } static void rootObject(JSContext *cx, JSObject *obj) { JS_AddNamedObjectRoot(cx, &obj, "unnamed"); } static void unRootObject(JSContext *cx, JSObject *obj) { JS_RemoveObjectRoot(cx, &obj); } static void getJSTouchObject(JSContext *cx, Touch *x, jsval &jsret) { js_proxy_t *proxy = js_get_or_create_proxy<cocos2d::Touch>(cx, x); jsret = OBJECT_TO_JSVAL(proxy->obj); } static void removeJSTouchObject(JSContext *cx, Touch *x, jsval &jsret) { js_proxy_t* nproxy; js_proxy_t* jsproxy; void *ptr = (void*)x; nproxy = jsb_get_native_proxy(ptr); if (nproxy) { jsproxy = jsb_get_js_proxy(nproxy->obj); JS_RemoveObjectRoot(cx, &jsproxy->obj); jsb_remove_proxy(nproxy, jsproxy); } } void ScriptingCore::executeJSFunctionWithThisObj(jsval thisObj, jsval callback, uint32_t argc/* = 0*/, jsval* vp/* = NULL*/, jsval* retVal/* = NULL*/) { if (callback != JSVAL_VOID || thisObj != JSVAL_VOID) { JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET // Very important: The last parameter 'retVal' passed to 'JS_CallFunctionValue' should not be a NULL pointer. // If it's a NULL pointer, crash will be triggered in 'JS_CallFunctionValue'. To find out the reason of this crash is very difficult. // So we have to check the availability of 'retVal'. if (retVal) { JS_CallFunctionValue(_cx, JSVAL_TO_OBJECT(thisObj), callback, argc, vp, retVal); } else { jsval jsRet; JS_CallFunctionValue(_cx, JSVAL_TO_OBJECT(thisObj), callback, argc, vp, &jsRet); } } } void js_log(const char *format, ...) { if (_js_log_buf == NULL) { _js_log_buf = (char *)calloc(sizeof(char), MAX_LOG_LENGTH+1); _js_log_buf[MAX_LOG_LENGTH] = '\0'; } va_list vl; va_start(vl, format); int len = vsnprintf(_js_log_buf, MAX_LOG_LENGTH, format, vl); va_end(vl); if (len > 0) { CCLOG("JS: %s\n", _js_log_buf); } } #define JSB_COMPATIBLE_WITH_COCOS2D_HTML5_BASIC_TYPES 1 JSBool JSBCore_platform(JSContext *cx, uint32_t argc, jsval *vp) { if (argc!=0) { JS_ReportError(cx, "Invalid number of arguments in __getPlatform"); return JS_FALSE; } JSString * platform; // config.deviceType: Device Type // 'mobile' for any kind of mobile devices, 'desktop' for PCs, 'browser' for Web Browsers // #if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) || (CC_TARGET_PLATFORM == CC_PLATFORM_LINUX) || (CC_TARGET_PLATFORM == CC_PLATFORM_MAC) // platform = JS_InternString(_cx, "desktop"); // #else platform = JS_InternString(cx, "mobile"); // #endif jsval ret = STRING_TO_JSVAL(platform); JS_SET_RVAL(cx, vp, ret); return JS_TRUE; }; JSBool JSBCore_version(JSContext *cx, uint32_t argc, jsval *vp) { if (argc!=0) { JS_ReportError(cx, "Invalid number of arguments in __getVersion"); return JS_FALSE; } char version[256]; snprintf(version, sizeof(version)-1, "%s", cocos2dVersion()); JSString * js_version = JS_InternString(cx, version); jsval ret = STRING_TO_JSVAL(js_version); JS_SET_RVAL(cx, vp, ret); return JS_TRUE; }; JSBool JSBCore_os(JSContext *cx, uint32_t argc, jsval *vp) { if (argc!=0) { JS_ReportError(cx, "Invalid number of arguments in __getOS"); return JS_FALSE; } JSString * os; // osx, ios, android, windows, linux, etc.. #if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) os = JS_InternString(cx, "ios"); #elif (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) os = JS_InternString(cx, "android"); #elif (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) os = JS_InternString(cx, "windows"); #elif (CC_TARGET_PLATFORM == CC_PLATFORM_MARMALADE) os = JS_InternString(cx, "marmalade"); #elif (CC_TARGET_PLATFORM == CC_PLATFORM_LINUX) os = JS_InternString(cx, "linux"); #elif (CC_TARGET_PLATFORM == CC_PLATFORM_BADA) os = JS_InternString(cx, "bada"); #elif (CC_TARGET_PLATFORM == CC_PLATFORM_BLACKBERRY) os = JS_InternString(cx, "blackberry"); #elif (CC_TARGET_PLATFORM == CC_PLATFORM_MAC) os = JS_InternString(cx, "osx"); #else os = JS_InternString(cx, "unknown"); #endif jsval ret = STRING_TO_JSVAL(os); JS_SET_RVAL(cx, vp, ret); return JS_TRUE; }; JSBool JSB_core_restartVM(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2(argc==0, cx, JS_FALSE, "Invalid number of arguments in executeScript"); ScriptingCore::getInstance()->reset(); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; }; void registerDefaultClasses(JSContext* cx, JSObject* global) { // first, try to get the ns JS::RootedValue nsval(cx); JSObject *ns; JS_GetProperty(cx, global, "cc", &nsval); if (nsval == JSVAL_VOID) { ns = JS_NewObject(cx, NULL, NULL, NULL); nsval = OBJECT_TO_JSVAL(ns); JS_SetProperty(cx, global, "cc", nsval); } else { JS_ValueToObject(cx, nsval, &ns); } // // Javascript controller (__jsc__) // JSObject *jsc = JS_NewObject(cx, NULL, NULL, NULL); JS::RootedValue jscVal(cx); jscVal = OBJECT_TO_JSVAL(jsc); JS_SetProperty(cx, global, "__jsc__", jscVal); JS_DefineFunction(cx, jsc, "garbageCollect", ScriptingCore::forceGC, 0, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, jsc, "dumpRoot", ScriptingCore::dumpRoot, 0, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, jsc, "addGCRootObject", ScriptingCore::addRootJS, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, jsc, "removeGCRootObject", ScriptingCore::removeRootJS, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, jsc, "executeScript", ScriptingCore::executeScript, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); // register some global functions JS_DefineFunction(cx, global, "require", ScriptingCore::executeScript, 1, JSPROP_READONLY | JSPROP_PERMANENT); JS_DefineFunction(cx, global, "log", ScriptingCore::log, 0, JSPROP_READONLY | JSPROP_PERMANENT); JS_DefineFunction(cx, global, "executeScript", ScriptingCore::executeScript, 1, JSPROP_READONLY | JSPROP_PERMANENT); JS_DefineFunction(cx, global, "forceGC", ScriptingCore::forceGC, 0, JSPROP_READONLY | JSPROP_PERMANENT); JS_DefineFunction(cx, global, "__getPlatform", JSBCore_platform, 0, JSPROP_READONLY | JSPROP_PERMANENT); JS_DefineFunction(cx, global, "__getOS", JSBCore_os, 0, JSPROP_READONLY | JSPROP_PERMANENT); JS_DefineFunction(cx, global, "__getVersion", JSBCore_version, 0, JSPROP_READONLY | JSPROP_PERMANENT); JS_DefineFunction(cx, global, "__restartVM", JSB_core_restartVM, 0, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); } static void sc_finalize(JSFreeOp *freeOp, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (global class)", obj); } static JSClass global_class = { "global", JSCLASS_GLOBAL_FLAGS, JS_PropertyStub, JS_DeletePropertyStub, JS_PropertyStub, JS_StrictPropertyStub, JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, sc_finalize, JSCLASS_NO_OPTIONAL_MEMBERS }; ScriptingCore::ScriptingCore() : _rt(nullptr) , _cx(nullptr) , _global(nullptr) , _debugGlobal(nullptr) { // set utf8 strings internally (we don't need utf16) // XXX: Removed in SpiderMonkey 19.0 //JS_SetCStringsAreUTF8(); this->addRegisterCallback(registerDefaultClasses); this->_runLoop = new SimpleRunLoop(); } void ScriptingCore::string_report(jsval val) { if (JSVAL_IS_NULL(val)) { LOGD("val : (JSVAL_IS_NULL(val)"); // return 1; } else if ((JSVAL_IS_BOOLEAN(val)) && (JS_FALSE == (JSVAL_TO_BOOLEAN(val)))) { LOGD("val : (return value is JS_FALSE"); // return 1; } else if (JSVAL_IS_STRING(val)) { JSString *str = JS_ValueToString(this->getGlobalContext(), val); if (NULL == str) { LOGD("val : return string is NULL"); } else { JSStringWrapper wrapper(str); LOGD("val : return string =\n%s\n", wrapper.get()); } } else if (JSVAL_IS_NUMBER(val)) { double number; if (JS_FALSE == JS_ValueToNumber(this->getGlobalContext(), val, &number)) { LOGD("val : return number could not be converted"); } else { LOGD("val : return number =\n%f", number); } } } JSBool ScriptingCore::evalString(const char *string, jsval *outVal, const char *filename, JSContext* cx, JSObject* global) { if (cx == NULL) cx = _cx; if (global == NULL) global = _global; JSAutoCompartment ac(cx, global); JSScript* script = JS_CompileScript(cx, global, string, strlen(string), filename, 1); if (script) { JSBool evaluatedOK = JS_ExecuteScript(cx, global, script, outVal); if (JS_FALSE == evaluatedOK) { fprintf(stderr, "(evaluatedOK == JS_FALSE)\n"); } return evaluatedOK; } return JS_FALSE; } void ScriptingCore::start() { // for now just this this->createGlobalContext(); } void ScriptingCore::addRegisterCallback(sc_register_sth callback) { registrationList.push_back(callback); } void ScriptingCore::removeAllRoots(JSContext *cx) { js_proxy_t *current, *tmp; HASH_ITER(hh, _js_native_global_ht, current, tmp) { JS_RemoveObjectRoot(cx, &current->obj); HASH_DEL(_js_native_global_ht, current); free(current); } HASH_ITER(hh, _native_js_global_ht, current, tmp) { HASH_DEL(_native_js_global_ht, current); free(current); } HASH_CLEAR(hh, _js_native_global_ht); HASH_CLEAR(hh, _native_js_global_ht); } static JSPrincipals shellTrustedPrincipals = { 1 }; static JSBool CheckObjectAccess(JSContext *cx, js::HandleObject obj, js::HandleId id, JSAccessMode mode, js::MutableHandleValue vp) { return JS_TRUE; } static JSSecurityCallbacks securityCallbacks = { CheckObjectAccess, NULL }; void ScriptingCore::createGlobalContext() { if (this->_cx && this->_rt) { ScriptingCore::removeAllRoots(this->_cx); JS_DestroyContext(this->_cx); JS_DestroyRuntime(this->_rt); this->_cx = NULL; this->_rt = NULL; } // Start the engine. Added in SpiderMonkey v25 if (!JS_Init()) return; // Removed from Spidermonkey 19. //JS_SetCStringsAreUTF8(); this->_rt = JS_NewRuntime(8L * 1024L * 1024L, JS_USE_HELPER_THREADS); JS_SetGCParameter(_rt, JSGC_MAX_BYTES, 0xffffffff); JS_SetTrustedPrincipals(_rt, &shellTrustedPrincipals); JS_SetSecurityCallbacks(_rt, &securityCallbacks); JS_SetNativeStackQuota(_rt, JSB_MAX_STACK_QUOTA); this->_cx = JS_NewContext(_rt, 8192); JS_SetOptions(this->_cx, JSOPTION_TYPE_INFERENCE); // JS_SetVersion(this->_cx, JSVERSION_LATEST); // Only disable METHODJIT on iOS. #if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) // JS_SetOptions(this->_cx, JS_GetOptions(this->_cx) & ~JSOPTION_METHODJIT); // JS_SetOptions(this->_cx, JS_GetOptions(this->_cx) & ~JSOPTION_METHODJIT_ALWAYS); #endif JS_SetErrorReporter(this->_cx, ScriptingCore::reportError); #if defined(JS_GC_ZEAL) && defined(DEBUG) //JS_SetGCZeal(this->_cx, 2, JS_DEFAULT_ZEAL_FREQ); #endif this->_global = NewGlobalObject(_cx); JSAutoCompartment ac(_cx, _global); js::SetDefaultObjectForContext(_cx, _global); for (std::vector<sc_register_sth>::iterator it = registrationList.begin(); it != registrationList.end(); it++) { sc_register_sth callback = *it; callback(this->_cx, this->_global); } } static std::string RemoveFileExt(const std::string& filePath) { size_t pos = filePath.rfind('.'); if (0 < pos) { return filePath.substr(0, pos); } else { return filePath; } } JSBool ScriptingCore::runScript(const char *path, JSObject* global, JSContext* cx) { if (!path) { return false; } cocos2d::FileUtils *futil = cocos2d::FileUtils::getInstance(); if (global == NULL) { global = _global; } if (cx == NULL) { cx = _cx; } JSAutoCompartment ac(cx, global); js::RootedScript script(cx); js::RootedObject obj(cx, global); // a) check jsc file first std::string byteCodePath = RemoveFileExt(std::string(path)) + BYTE_CODE_FILE_EXT; Data data = futil->getDataFromFile(byteCodePath); if (!data.isNull()) { script = JS_DecodeScript(cx, data.getBytes(), static_cast<uint32_t>(data.getSize()), nullptr, nullptr); } // b) no jsc file, check js file if (!script) { /* Clear any pending exception from previous failed decoding. */ ReportException(cx); std::string fullPath = futil->fullPathForFilename(path); JS::CompileOptions options(cx); options.setUTF8(true).setFileAndLine(fullPath.c_str(), 1); #if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) std::string jsFileContent = futil->getStringFromFile(fullPath); if (!jsFileContent.empty()) { script = JS::Compile(cx, obj, options, jsFileContent.c_str(), jsFileContent.size()); } #else script = JS::Compile(cx, obj, options, fullPath.c_str()); #endif } JSBool evaluatedOK = false; if (script) { jsval rval; filename_script[path] = script; evaluatedOK = JS_ExecuteScript(cx, global, script, &rval); if (JS_FALSE == evaluatedOK) { cocos2d::log("(evaluatedOK == JS_FALSE)"); JS_ReportPendingException(cx); } } return evaluatedOK; } void ScriptingCore::reset() { cleanup(); start(); } ScriptingCore::~ScriptingCore() { cleanup(); } void ScriptingCore::cleanup() { localStorageFree(); removeAllRoots(_cx); if (_cx) { JS_DestroyContext(_cx); _cx = NULL; } if (_rt) { JS_DestroyRuntime(_rt); _rt = NULL; } JS_ShutDown(); if (_js_log_buf) { free(_js_log_buf); _js_log_buf = NULL; } for (auto iter = _js_global_type_map.begin(); iter != _js_global_type_map.end(); ++iter) { free(iter->second->jsclass); free(iter->second); } _js_global_type_map.clear(); } void ScriptingCore::reportError(JSContext *cx, const char *message, JSErrorReport *report) { js_log("%s:%u:%s\n", report->filename ? report->filename : "<no filename=\"filename\">", (unsigned int) report->lineno, message); }; JSBool ScriptingCore::log(JSContext* cx, uint32_t argc, jsval *vp) { if (argc > 0) { JSString *string = NULL; JS_ConvertArguments(cx, argc, JS_ARGV(cx, vp), "S", &string); if (string) { JSStringWrapper wrapper(string); js_log("%s", wrapper.get()); } } return JS_TRUE; } void ScriptingCore::removeScriptObjectByObject(Object* pObj) { js_proxy_t* nproxy; js_proxy_t* jsproxy; void *ptr = (void*)pObj; nproxy = jsb_get_native_proxy(ptr); if (nproxy) { JSContext *cx = ScriptingCore::getInstance()->getGlobalContext(); jsproxy = jsb_get_js_proxy(nproxy->obj); JS_RemoveObjectRoot(cx, &jsproxy->obj); jsb_remove_proxy(nproxy, jsproxy); } } JSBool ScriptingCore::setReservedSpot(uint32_t i, JSObject *obj, jsval value) { JS_SetReservedSlot(obj, i, value); return JS_TRUE; } JSBool ScriptingCore::executeScript(JSContext *cx, uint32_t argc, jsval *vp) { if (argc >= 1) { jsval* argv = JS_ARGV(cx, vp); JSString* str = JS_ValueToString(cx, argv[0]); JSStringWrapper path(str); JSBool res = false; if (argc == 2 && argv[1].isString()) { JSString* globalName = JSVAL_TO_STRING(argv[1]); JSStringWrapper name(globalName); // js::RootedObject* rootedGlobal = globals[name]; JSObject* debugObj = ScriptingCore::getInstance()->getDebugGlobal(); if (debugObj) { res = ScriptingCore::getInstance()->runScript(path.get(), debugObj); } else { JS_ReportError(cx, "Invalid global object: %s", name.get()); return JS_FALSE; } } else { JSObject* glob = JS::CurrentGlobalOrNull(cx); res = ScriptingCore::getInstance()->runScript(path.get(), glob); } return res; } return JS_TRUE; } JSBool ScriptingCore::forceGC(JSContext *cx, uint32_t argc, jsval *vp) { JSRuntime *rt = JS_GetRuntime(cx); JS_GC(rt); return JS_TRUE; } //static void dumpNamedRoot(const char *name, void *addr, JSGCRootType type, void *data) //{ // CCLOG("Root: '%s' at %p", name, addr); //} JSBool ScriptingCore::dumpRoot(JSContext *cx, uint32_t argc, jsval *vp) { // JS_DumpNamedRoots is only available on DEBUG versions of SpiderMonkey. // Mac and Simulator versions were compiled with DEBUG. #if COCOS2D_DEBUG // JSContext *_cx = ScriptingCore::getInstance()->getGlobalContext(); // JSRuntime *rt = JS_GetRuntime(_cx); // JS_DumpNamedRoots(rt, dumpNamedRoot, NULL); // JS_DumpHeap(rt, stdout, NULL, JSTRACE_OBJECT, NULL, 2, NULL); #endif return JS_TRUE; } JSBool ScriptingCore::addRootJS(JSContext *cx, uint32_t argc, jsval *vp) { if (argc == 1) { JSObject *o = NULL; if (JS_ConvertArguments(cx, argc, JS_ARGV(cx, vp), "o", &o) == JS_TRUE) { if (JS_AddNamedObjectRoot(cx, &o, "from-js") == JS_FALSE) { LOGD("something went wrong when setting an object to the root"); } } return JS_TRUE; } return JS_FALSE; } JSBool ScriptingCore::removeRootJS(JSContext *cx, uint32_t argc, jsval *vp) { if (argc == 1) { JSObject *o = NULL; if (JS_ConvertArguments(cx, argc, JS_ARGV(cx, vp), "o", &o) == JS_TRUE) { JS_RemoveObjectRoot(cx, &o); } return JS_TRUE; } return JS_FALSE; } void ScriptingCore::pauseSchedulesAndActions(js_proxy_t* p) { Array * arr = JSScheduleWrapper::getTargetForJSObject(p->obj); if (! arr) return; Node* node = (Node*)p->ptr; for(unsigned int i = 0; i < arr->count(); ++i) { if (arr->getObjectAtIndex(i)) { node->getScheduler()->pauseTarget(arr->getObjectAtIndex(i)); } } } void ScriptingCore::resumeSchedulesAndActions(js_proxy_t* p) { Array * arr = JSScheduleWrapper::getTargetForJSObject(p->obj); if (!arr) return; Node* node = (Node*)p->ptr; for(unsigned int i = 0; i < arr->count(); ++i) { if (!arr->getObjectAtIndex(i)) continue; node->getScheduler()->resumeTarget(arr->getObjectAtIndex(i)); } } void ScriptingCore::cleanupSchedulesAndActions(js_proxy_t* p) { Array* arr = JSScheduleWrapper::getTargetForJSObject(p->obj); if (arr) { Scheduler* pScheduler = Director::getInstance()->getScheduler(); Object* pObj = NULL; CCARRAY_FOREACH(arr, pObj) { pScheduler->unscheduleAllForTarget(pObj); } JSScheduleWrapper::removeAllTargetsForJSObject(p->obj); } } int ScriptingCore::handleNodeEvent(void* data) { if (NULL == data) return 0; BasicScriptData* basicScriptData = static_cast<BasicScriptData*>(data); if (NULL == basicScriptData->nativeObject || NULL == basicScriptData->value) return 0; Node* node = static_cast<Node*>(basicScriptData->nativeObject); int action = *((int*)(basicScriptData->value)); js_proxy_t * p = jsb_get_native_proxy(node); if (!p) return 0; jsval retval; jsval dataVal = INT_TO_JSVAL(1); if (action == kNodeOnEnter) { executeFunctionWithOwner(OBJECT_TO_JSVAL(p->obj), "onEnter", 1, &dataVal, &retval); resumeSchedulesAndActions(p); } else if (action == kNodeOnExit) { executeFunctionWithOwner(OBJECT_TO_JSVAL(p->obj), "onExit", 1, &dataVal, &retval); pauseSchedulesAndActions(p); } else if (action == kNodeOnEnterTransitionDidFinish) { executeFunctionWithOwner(OBJECT_TO_JSVAL(p->obj), "onEnterTransitionDidFinish", 1, &dataVal, &retval); } else if (action == kNodeOnExitTransitionDidStart) { executeFunctionWithOwner(OBJECT_TO_JSVAL(p->obj), "onExitTransitionDidStart", 1, &dataVal, &retval); } else if (action == kNodeOnCleanup) { cleanupSchedulesAndActions(p); } return 1; } int ScriptingCore::handleMenuClickedEvent(void* data) { if (NULL == data) return 0; BasicScriptData* basicScriptData = static_cast<BasicScriptData*>(data); if (NULL == basicScriptData->nativeObject) return 0; MenuItem* menuItem = static_cast<MenuItem*>(basicScriptData->nativeObject); js_proxy_t * p = jsb_get_native_proxy(menuItem); if (!p) return 0; jsval retval; jsval dataVal; js_proxy_t *proxy = jsb_get_native_proxy(menuItem); dataVal = (proxy ? OBJECT_TO_JSVAL(proxy->obj) : JSVAL_NULL); executeJSFunctionFromReservedSpot(this->_cx, p->obj, dataVal, retval); return 1; } int ScriptingCore::handleTouchesEvent(void* data) { if (NULL == data) return 0; TouchesScriptData* touchesScriptData = static_cast<TouchesScriptData*>(data); if (NULL == touchesScriptData->nativeObject || touchesScriptData->touches.empty()) return 0; Layer* pLayer = static_cast<Layer*>(touchesScriptData->nativeObject); EventTouch::EventCode eventType = touchesScriptData->actionType; const std::vector<Touch*>& touches = touchesScriptData->touches; std::string funcName = ""; getTouchesFuncName(eventType, funcName); JSObject *jsretArr = JS_NewArrayObject(this->_cx, 0, NULL); JS_AddNamedObjectRoot(this->_cx, &jsretArr, "touchArray"); int count = 0; for (auto& touch : touches) { jsval jsret; getJSTouchObject(this->_cx, touch, jsret); if (!JS_SetElement(this->_cx, jsretArr, count, &jsret)) { break; } ++count; } executeFunctionWithObjectData(pLayer, funcName.c_str(), jsretArr); JS_RemoveObjectRoot(this->_cx, &jsretArr); for (auto& touch : touches) { jsval jsret; removeJSTouchObject(this->_cx, touch, jsret); } return 1; } int ScriptingCore::handleTouchEvent(void* data) { if (NULL == data) return 0; TouchScriptData* touchScriptData = static_cast<TouchScriptData*>(data); if (NULL == touchScriptData->nativeObject || NULL == touchScriptData->touch) return 0; Layer* pLayer = static_cast<Layer*>(touchScriptData->nativeObject); EventTouch::EventCode eventType = touchScriptData->actionType; Touch *pTouch = touchScriptData->touch; std::string funcName = ""; getTouchFuncName(eventType, funcName); jsval jsret; getJSTouchObject(this->getGlobalContext(), pTouch, jsret); JSObject *jsObj = JSVAL_TO_OBJECT(jsret); bool retval = executeFunctionWithObjectData(pLayer, funcName.c_str(), jsObj); removeJSTouchObject(this->getGlobalContext(), pTouch, jsret); return retval; } bool ScriptingCore::executeFunctionWithObjectData(Node *self, const char *name, JSObject *obj) { js_proxy_t * p = jsb_get_native_proxy(self); if (!p) return false; jsval retval; jsval dataVal = OBJECT_TO_JSVAL(obj); executeFunctionWithOwner(OBJECT_TO_JSVAL(p->obj), name, 1, &dataVal, &retval); if (JSVAL_IS_NULL(retval)) { return false; } else if (JSVAL_IS_BOOLEAN(retval)) { return JSVAL_TO_BOOLEAN(retval); } return false; } JSBool ScriptingCore::executeFunctionWithOwner(jsval owner, const char *name, uint32_t argc /* = 0 */, jsval *vp /* = NULL */, jsval* retVal /* = NULL */) { JSBool bRet = JS_FALSE; JSBool hasAction; JSContext* cx = this->_cx; JS::RootedValue temp_retval(cx); JSObject* obj = JSVAL_TO_OBJECT(owner); do { JSAutoCompartment ac(cx, obj); if (JS_HasProperty(cx, obj, name, &hasAction) && hasAction) { if (!JS_GetProperty(cx, obj, name, &temp_retval)) { break; } if (temp_retval == JSVAL_VOID) { break; } if (retVal) { bRet = JS_CallFunctionName(cx, obj, name, argc, vp, retVal); } else { jsval jsret; bRet = JS_CallFunctionName(cx, obj, name, argc, vp, &jsret); } } }while(0); return bRet; } int ScriptingCore::handleAccelerometerEvent(void* data) { if (NULL == data) return 0; BasicScriptData* basicScriptData = static_cast<BasicScriptData*>(data); if (NULL == basicScriptData->nativeObject || NULL == basicScriptData->value) return 0; Acceleration* accelerationValue = static_cast<Acceleration*>(basicScriptData->value); Layer* layer = static_cast<Layer*>(basicScriptData->nativeObject); jsval value = ccacceleration_to_jsval(this->getGlobalContext(), *accelerationValue); JS_AddValueRoot(this->getGlobalContext(), &value); executeFunctionWithObjectData(layer, "onAccelerometer", JSVAL_TO_OBJECT(value)); JS_RemoveValueRoot(this->getGlobalContext(), &value); return 1; } int ScriptingCore::handleKeypadEvent(void* data) { if (NULL == data) return 0; KeypadScriptData* keypadScriptData = static_cast<KeypadScriptData*>(data); if (NULL == keypadScriptData->nativeObject) return 0; EventKeyboard::KeyCode action = keypadScriptData->actionType; js_proxy_t * p = jsb_get_native_proxy(keypadScriptData->nativeObject); if (p) { JSBool ret = JS_FALSE; switch(action) { case EventKeyboard::KeyCode::KEY_BACKSPACE: ret = executeFunctionWithOwner(OBJECT_TO_JSVAL(p->obj), "onBackClicked"); if (!ret) { ret = executeFunctionWithOwner(OBJECT_TO_JSVAL(p->obj), "backClicked"); if (ret) { CCLOG("backClicked will be deprecated, please use onBackClicked instead."); } } break; case EventKeyboard::KeyCode::KEY_MENU: ret = executeFunctionWithOwner(OBJECT_TO_JSVAL(p->obj), "onMenuClicked"); if (!ret) { ret = executeFunctionWithOwner(OBJECT_TO_JSVAL(p->obj), "menuClicked"); if (ret) { CCLOG("menuClicked will be deprecated, please use onMenuClicked instead."); } } break; default: break; } return 1; } return 0; } int ScriptingCore::executeCustomTouchesEvent(EventTouch::EventCode eventType, const std::vector<Touch*>& touches, JSObject *obj) { jsval retval; std::string funcName; getTouchesFuncName(eventType, funcName); JSObject *jsretArr = JS_NewArrayObject(this->_cx, 0, NULL); JS_AddNamedObjectRoot(this->_cx, &jsretArr, "touchArray"); int count = 0; for (auto& touch : touches) { jsval jsret; getJSTouchObject(this->_cx, touch, jsret); if (!JS_SetElement(this->_cx, jsretArr, count, &jsret)) { break; } ++count; } jsval jsretArrVal = OBJECT_TO_JSVAL(jsretArr); executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), funcName.c_str(), 1, &jsretArrVal, &retval); JS_RemoveObjectRoot(this->_cx, &jsretArr); for (auto& touch : touches) { jsval jsret; removeJSTouchObject(this->_cx, touch, jsret); } return 1; } int ScriptingCore::executeCustomTouchEvent(EventTouch::EventCode eventType, Touch *pTouch, JSObject *obj) { JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET jsval retval; std::string funcName; getTouchFuncName(eventType, funcName); jsval jsTouch; getJSTouchObject(this->_cx, pTouch, jsTouch); executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), funcName.c_str(), 1, &jsTouch, &retval); // Remove touch object from global hash table and unroot it. removeJSTouchObject(this->_cx, pTouch, jsTouch); return 1; } int ScriptingCore::executeCustomTouchEvent(EventTouch::EventCode eventType, Touch *pTouch, JSObject *obj, jsval &retval) { JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET std::string funcName; getTouchFuncName(eventType, funcName); jsval jsTouch; getJSTouchObject(this->_cx, pTouch, jsTouch); executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), funcName.c_str(), 1, &jsTouch, &retval); // Remove touch object from global hash table and unroot it. removeJSTouchObject(this->_cx, pTouch, jsTouch); return 1; } int ScriptingCore::sendEvent(ScriptEvent* evt) { if (NULL == evt) return 0; JSAutoCompartment ac(_cx, _global); switch (evt->type) { case kNodeEvent: { return handleNodeEvent(evt->data); } break; case kMenuClickedEvent: { return handleMenuClickedEvent(evt->data); } break; case kTouchEvent: { return handleTouchEvent(evt->data); } break; case kTouchesEvent: { return handleTouchesEvent(evt->data); } break; case kKeypadEvent: { return handleKeypadEvent(evt->data); } break; case kAccelerometerEvent: { return handleAccelerometerEvent(evt->data); } break; default: break; } return 0; } bool ScriptingCore::parseConfig(ConfigType type, const std::string &str) { jsval args[2]; args[0] = int32_to_jsval(_cx, static_cast<int>(type)); args[1] = std_string_to_jsval(_cx, str); return (JS_TRUE == executeFunctionWithOwner(OBJECT_TO_JSVAL(_global), "__onParseConfig", 2, args)); } #pragma mark - Debug void SimpleRunLoop::update(float dt) { g_qMutex.lock(); size_t size = g_queue.size(); g_qMutex.unlock(); while (size > 0) { g_qMutex.lock(); auto first = g_queue.begin(); std::string str = *first; g_queue.erase(first); size = g_queue.size(); g_qMutex.unlock(); ScriptingCore::getInstance()->debugProcessInput(str); } } void ScriptingCore::debugProcessInput(const std::string& str) { JSAutoCompartment ac(_cx, _debugGlobal); JSString* jsstr = JS_NewStringCopyZ(_cx, str.c_str()); jsval argv = STRING_TO_JSVAL(jsstr); jsval outval; JS_CallFunctionName(_cx, _debugGlobal, "processInput", 1, &argv, &outval); } static bool NS_ProcessNextEvent() { g_qMutex.lock(); size_t size = g_queue.size(); g_qMutex.unlock(); while (size > 0) { g_qMutex.lock(); auto first = g_queue.begin(); std::string str = *first; g_queue.erase(first); size = g_queue.size(); g_qMutex.unlock(); ScriptingCore::getInstance()->debugProcessInput(str); } // std::this_thread::yield(); std::this_thread::sleep_for(std::chrono::milliseconds(10)); return true; } JSBool JSBDebug_enterNestedEventLoop(JSContext* cx, unsigned argc, jsval* vp) { enum { NS_OK = 0, NS_ERROR_UNEXPECTED }; #define NS_SUCCEEDED(v) ((v) == NS_OK) int rv = NS_OK; uint32_t nestLevel = ++s_nestedLoopLevel; while (NS_SUCCEEDED(rv) && s_nestedLoopLevel >= nestLevel) { if (!NS_ProcessNextEvent()) rv = NS_ERROR_UNEXPECTED; } CCASSERT(s_nestedLoopLevel <= nestLevel, "nested event didn't unwind properly"); JS_SET_RVAL(cx, vp, UINT_TO_JSVAL(s_nestedLoopLevel)); return JS_TRUE; } JSBool JSBDebug_exitNestedEventLoop(JSContext* cx, unsigned argc, jsval* vp) { if (s_nestedLoopLevel > 0) { --s_nestedLoopLevel; } else { JS_SET_RVAL(cx, vp, UINT_TO_JSVAL(0)); return JS_TRUE; } JS_SET_RVAL(cx, vp, UINT_TO_JSVAL(s_nestedLoopLevel)); return JS_TRUE; } JSBool JSBDebug_getEventLoopNestLevel(JSContext* cx, unsigned argc, jsval* vp) { JS_SET_RVAL(cx, vp, UINT_TO_JSVAL(s_nestedLoopLevel)); return JS_TRUE; } //#pragma mark - Debugger static void _clientSocketWriteAndClearString(std::string& s) { ::send(clientSocket, s.c_str(), s.length(), 0); s.clear(); } static void processInput(const std::string& data) { std::lock_guard<std::mutex> lk(g_qMutex); g_queue.push_back(data); } static void clearBuffers() { std::lock_guard<std::mutex> lk(g_rwMutex); // only process input if there's something and we're not locked if (inData.length() > 0) { processInput(inData); inData.clear(); } if (outData.length() > 0) { _clientSocketWriteAndClearString(outData); } } static void serverEntryPoint(void) { // start a server, accept the connection and keep reading data from it struct addrinfo hints, *result = nullptr, *rp = nullptr; int s = 0; memset(&hints, 0, sizeof(struct addrinfo)); hints.ai_family = AF_INET; // IPv4 hints.ai_socktype = SOCK_STREAM; // TCP stream sockets hints.ai_flags = AI_PASSIVE; // fill in my IP for me std::stringstream portstr; portstr << JSB_DEBUGGER_PORT; int err = 0; #if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) WSADATA wsaData; err = WSAStartup(MAKEWORD(2, 2),&wsaData); #endif if ((err = getaddrinfo(NULL, portstr.str().c_str(), &hints, &result)) != 0) { LOGD("getaddrinfo error : %s\n", gai_strerror(err)); } for (rp = result; rp != NULL; rp = rp->ai_next) { if ((s = socket(rp->ai_family, rp->ai_socktype, 0)) < 0) { continue; } int optval = 1; if ((setsockopt(s, SOL_SOCKET, SO_REUSEADDR, (char*)&optval, sizeof(optval))) < 0) { close(s); TRACE_DEBUGGER_SERVER("debug server : error setting socket option SO_REUSEADDR"); return; } #if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) if ((setsockopt(s, SOL_SOCKET, SO_NOSIGPIPE, &optval, sizeof(optval))) < 0) { close(s); TRACE_DEBUGGER_SERVER("debug server : error setting socket option SO_NOSIGPIPE"); return; } #endif //(CC_TARGET_PLATFORM == CC_PLATFORM_IOS) if ((::bind(s, rp->ai_addr, rp->ai_addrlen)) == 0) { break; } close(s); s = -1; } if (s < 0 || rp == NULL) { TRACE_DEBUGGER_SERVER("debug server : error creating/binding socket"); return; } freeaddrinfo(result); listen(s, 1); while (true) { clientSocket = accept(s, NULL, NULL); if (clientSocket < 0) { TRACE_DEBUGGER_SERVER("debug server : error on accept"); return; } else { // read/write data TRACE_DEBUGGER_SERVER("debug server : client connected"); inData = "connected"; // process any input, send any output clearBuffers(); char buf[1024] = {0}; int readBytes = 0; while ((readBytes = ::recv(clientSocket, buf, sizeof(buf), 0)) > 0) { buf[readBytes] = '\0'; // TRACE_DEBUGGER_SERVER("debug server : received command >%s", buf); // no other thread is using this inData.append(buf); // process any input, send any output clearBuffers(); } // while(read) close(clientSocket); } } // while(true) } JSBool JSBDebug_BufferWrite(JSContext* cx, unsigned argc, jsval* vp) { if (argc == 1) { jsval* argv = JS_ARGV(cx, vp); JSStringWrapper strWrapper(argv[0]); // this is safe because we're already inside a lock (from clearBuffers) outData.append(strWrapper.get()); _clientSocketWriteAndClearString(outData); } return JS_TRUE; } void ScriptingCore::enableDebugger() { if (_debugGlobal == NULL) { JSAutoCompartment ac0(_cx, _global); JS_SetDebugMode(_cx, JS_TRUE); _debugGlobal = NewGlobalObject(_cx, true); // Adds the debugger object to root, otherwise it may be collected by GC. JS_AddObjectRoot(_cx, &_debugGlobal); JS_WrapObject(_cx, &_debugGlobal); JSAutoCompartment ac(_cx, _debugGlobal); // these are used in the debug program JS_DefineFunction(_cx, _debugGlobal, "log", ScriptingCore::log, 0, JSPROP_READONLY | JSPROP_PERMANENT); JS_DefineFunction(_cx, _debugGlobal, "_bufferWrite", JSBDebug_BufferWrite, 1, JSPROP_READONLY | JSPROP_PERMANENT); JS_DefineFunction(_cx, _debugGlobal, "_enterNestedEventLoop", JSBDebug_enterNestedEventLoop, 0, JSPROP_READONLY | JSPROP_PERMANENT); JS_DefineFunction(_cx, _debugGlobal, "_exitNestedEventLoop", JSBDebug_exitNestedEventLoop, 0, JSPROP_READONLY | JSPROP_PERMANENT); JS_DefineFunction(_cx, _debugGlobal, "_getEventLoopNestLevel", JSBDebug_getEventLoopNestLevel, 0, JSPROP_READONLY | JSPROP_PERMANENT); runScript("jsb_debugger.js", _debugGlobal); // prepare the debugger jsval argv = OBJECT_TO_JSVAL(_global); jsval outval; JSBool ok = JS_CallFunctionName(_cx, _debugGlobal, "_prepareDebugger", 1, &argv, &outval); if (!ok) { JS_ReportPendingException(_cx); } // start bg thread auto t = std::thread(&serverEntryPoint); t.detach(); Scheduler* scheduler = Director::getInstance()->getScheduler(); scheduler->scheduleUpdateForTarget(this->_runLoop, 0, false); } } JSObject* NewGlobalObject(JSContext* cx, bool debug) { JS::CompartmentOptions options; options.setVersion(JSVERSION_LATEST); JS::RootedObject glob(cx, JS_NewGlobalObject(cx, &global_class, NULL, JS::DontFireOnNewGlobalHook, options)); if (!glob) { return NULL; } JSAutoCompartment ac(cx, glob); JSBool ok = JS_TRUE; ok = JS_InitStandardClasses(cx, glob); if (ok) JS_InitReflect(cx, glob); if (ok && debug) ok = JS_DefineDebuggerObject(cx, glob); if (!ok) return NULL; JS_FireOnNewGlobalObject(cx, glob); return glob; } JSBool jsb_set_reserved_slot(JSObject *obj, uint32_t idx, jsval value) { JSClass *klass = JS_GetClass(obj); unsigned int slots = JSCLASS_RESERVED_SLOTS(klass); if ( idx >= slots ) return JS_FALSE; JS_SetReservedSlot(obj, idx, value); return JS_TRUE; } JSBool jsb_get_reserved_slot(JSObject *obj, uint32_t idx, jsval& ret) { JSClass *klass = JS_GetClass(obj); unsigned int slots = JSCLASS_RESERVED_SLOTS(klass); if ( idx >= slots ) return JS_FALSE; ret = JS_GetReservedSlot(obj, idx); return JS_TRUE; } js_proxy_t* jsb_new_proxy(void* nativeObj, JSObject* jsObj) { js_proxy_t* p = nullptr; JS_NEW_PROXY(p, nativeObj, jsObj); return p; } js_proxy_t* jsb_get_native_proxy(void* nativeObj) { js_proxy_t* p = nullptr; JS_GET_PROXY(p, nativeObj); return p; } js_proxy_t* jsb_get_js_proxy(JSObject* jsObj) { js_proxy_t* p = nullptr; JS_GET_NATIVE_PROXY(p, jsObj); return p; } void jsb_remove_proxy(js_proxy_t* nativeProxy, js_proxy_t* jsProxy) { JS_REMOVE_PROXY(nativeProxy, jsProxy); }
29.225296
154
0.630128
hiepns
7397f201bc888d8a436aeb6e83868b36eec85a4f
305
hpp
C++
library/ATF/$7A7EAA273238A7AEE4EBCB8D42B7FAA9.hpp
lemkova/Yorozuya
f445d800078d9aba5de28f122cedfa03f26a38e4
[ "MIT" ]
29
2017-07-01T23:08:31.000Z
2022-02-19T10:22:45.000Z
library/ATF/$7A7EAA273238A7AEE4EBCB8D42B7FAA9.hpp
kotopes/Yorozuya
605c97d3a627a8f6545cc09f2a1b0a8afdedd33a
[ "MIT" ]
90
2017-10-18T21:24:51.000Z
2019-06-06T02:30:33.000Z
library/ATF/$7A7EAA273238A7AEE4EBCB8D42B7FAA9.hpp
kotopes/Yorozuya
605c97d3a627a8f6545cc09f2a1b0a8afdedd33a
[ "MIT" ]
44
2017-12-19T08:02:59.000Z
2022-02-24T23:15:01.000Z
// This file auto generated by plugin for ida pro. Generated code only for x64. Please, dont change manually #pragma once #include <common/common.h> START_ATF_NAMESPACE enum $7A7EAA273238A7AEE4EBCB8D42B7FAA9 { combineslot_base = 0x0, combineslot_max = 0x5, }; END_ATF_NAMESPACE
21.785714
108
0.734426
lemkova
739dcd6701e5b595ac5bf68d0c537a9d7c46e90f
10,785
hpp
C++
yolox_ros_cpp/yolox_cpp/include/yolox_cpp/core.hpp
HarvestX/YOLOX-ROS
f73bf6ab8f11ac0f720d4e5b3acc9737dfa44498
[ "Apache-2.0" ]
2
2022-02-21T09:56:42.000Z
2022-02-22T00:38:41.000Z
yolox_ros_cpp/yolox_cpp/include/yolox_cpp/core.hpp
HarvestX/YOLOX-ROS
f73bf6ab8f11ac0f720d4e5b3acc9737dfa44498
[ "Apache-2.0" ]
5
2022-02-22T05:38:54.000Z
2022-03-29T09:17:32.000Z
yolox_ros_cpp/yolox_cpp/include/yolox_cpp/core.hpp
HarvestX/YOLOX-ROS
f73bf6ab8f11ac0f720d4e5b3acc9737dfa44498
[ "Apache-2.0" ]
null
null
null
#ifndef _YOLOX_CPP_CORE_HPP #define _YOLOX_CPP_CORE_HPP #include <opencv2/core/types.hpp> namespace yolox_cpp{ /** * @brief Define names based depends on Unicode path support */ #define tcout std::cout #define file_name_t std::string #define imread_t cv::imread struct Object { cv::Rect_<float> rect; int label; float prob; }; struct GridAndStride { int grid0; int grid1; int stride; }; class AbcYoloX{ public: AbcYoloX(){} AbcYoloX(float nms_th=0.45, float conf_th=0.3, std::string model_version="0.1.1rc0") :nms_thresh_(nms_th), bbox_conf_thresh_(conf_th), model_version_(model_version) {} virtual std::vector<Object> inference(cv::Mat frame) = 0; protected: int input_w_; int input_h_; float nms_thresh_; float bbox_conf_thresh_; int num_classes_ = 80; std::string model_version_; const std::vector<float> mean_ = {0.485, 0.456, 0.406}; const std::vector<float> std_ = {0.229, 0.224, 0.225}; const std::vector<int> strides_ = {8, 16, 32}; std::vector<GridAndStride> grid_strides_; cv::Mat static_resize(cv::Mat& img) { float r = std::min(input_w_ / (img.cols*1.0), input_h_ / (img.rows*1.0)); // r = std::min(r, 1.0f); int unpad_w = r * img.cols; int unpad_h = r * img.rows; cv::Mat re(unpad_h, unpad_w, CV_8UC3); cv::resize(img, re, re.size()); cv::Mat out(input_h_, input_w_, CV_8UC3, cv::Scalar(114, 114, 114)); re.copyTo(out(cv::Rect(0, 0, re.cols, re.rows))); return out; } void blobFromImage(cv::Mat& img, float *blob_data){ int channels = 3; int img_h = img.rows; int img_w = img.cols; if(this->model_version_=="0.1.0"){ for (size_t c = 0; c < channels; c++) { for (size_t h = 0; h < img_h; h++) { for (size_t w = 0; w < img_w; w++) { blob_data[c * img_w * img_h + h * img_w + w] = ((float)img.at<cv::Vec3b>(h, w)[c] / 255.0 - this->mean_[c]) / this->std_[c]; } } } }else{ for (size_t c = 0; c < channels; c++) { for (size_t h = 0; h < img_h; h++) { for (size_t w = 0; w < img_w; w++) { blob_data[c * img_w * img_h + h * img_w + w] = (float)img.at<cv::Vec3b>(h, w)[c]; // 0.1.1rc0 or later } } } } } void generate_grids_and_stride(const int target_w, const int target_h, const std::vector<int>& strides, std::vector<GridAndStride>& grid_strides) { for (auto stride : strides) { int num_grid_w = target_w / stride; int num_grid_h = target_h / stride; for (int g1 = 0; g1 < num_grid_h; g1++) { for (int g0 = 0; g0 < num_grid_w; g0++) { grid_strides.push_back((GridAndStride){g0, g1, stride}); } } } } void generate_yolox_proposals(const std::vector<GridAndStride> grid_strides, const float* feat_ptr, const float prob_threshold, std::vector<Object>& objects) { const int num_anchors = grid_strides.size(); for (int anchor_idx = 0; anchor_idx < num_anchors; anchor_idx++) { const int grid0 = grid_strides[anchor_idx].grid0; const int grid1 = grid_strides[anchor_idx].grid1; const int stride = grid_strides[anchor_idx].stride; const int basic_pos = anchor_idx * (num_classes_ + 5); float box_objectness = feat_ptr[basic_pos + 4]; int class_id = 0; float max_class_score = 0.0; for (int class_idx = 0; class_idx < num_classes_; class_idx++) { float box_cls_score = feat_ptr[basic_pos + 5 + class_idx]; float box_prob = box_objectness * box_cls_score; if (box_prob > max_class_score){ class_id = class_idx; max_class_score = box_prob; } } if (max_class_score > prob_threshold) { // yolox/models/yolo_head.py decode logic // outputs[..., :2] = (outputs[..., :2] + grids) * strides // outputs[..., 2:4] = torch.exp(outputs[..., 2:4]) * strides float x_center = (feat_ptr[basic_pos + 0] + grid0) * stride; float y_center = (feat_ptr[basic_pos + 1] + grid1) * stride; float w = exp(feat_ptr[basic_pos + 2]) * stride; float h = exp(feat_ptr[basic_pos + 3]) * stride; float x0 = x_center - w * 0.5f; float y0 = y_center - h * 0.5f; Object obj; obj.rect.x = x0; obj.rect.y = y0; obj.rect.width = w; obj.rect.height = h; obj.label = class_id; obj.prob = max_class_score; objects.push_back(obj); } } // point anchor loop } float intersection_area(const Object& a, const Object& b) { cv::Rect_<float> inter = a.rect & b.rect; return inter.area(); } void qsort_descent_inplace(std::vector<Object>& faceobjects, int left, int right) { int i = left; int j = right; float p = faceobjects[(left + right) / 2].prob; while (i <= j) { while (faceobjects[i].prob > p) i++; while (faceobjects[j].prob < p) j--; if (i <= j) { // swap std::swap(faceobjects[i], faceobjects[j]); i++; j--; } } #pragma omp parallel sections { #pragma omp section { if (left < j) qsort_descent_inplace(faceobjects, left, j); } #pragma omp section { if (i < right) qsort_descent_inplace(faceobjects, i, right); } } } void qsort_descent_inplace(std::vector<Object>& objects) { if (objects.empty()) return; qsort_descent_inplace(objects, 0, objects.size() - 1); } void nms_sorted_bboxes(const std::vector<Object>& faceobjects, std::vector<int>& picked, const float nms_threshold) { picked.clear(); const int n = faceobjects.size(); std::vector<float> areas(n); for (int i = 0; i < n; i++) { areas[i] = faceobjects[i].rect.area(); } for (int i = 0; i < n; i++) { const Object& a = faceobjects[i]; int keep = 1; for (int j = 0; j < (int)picked.size(); j++) { const Object& b = faceobjects[picked[j]]; // intersection over union float inter_area = intersection_area(a, b); float union_area = areas[i] + areas[picked[j]] - inter_area; // float IoU = inter_area / union_area if (inter_area / union_area > nms_threshold) keep = 0; } if (keep) picked.push_back(i); } } void decode_outputs(const float* prob, const std::vector<GridAndStride> grid_strides, std::vector<Object>& objects, const float bbox_conf_thresh, const float scale, const int img_w, const int img_h) { std::vector<Object> proposals; generate_yolox_proposals(grid_strides, prob, bbox_conf_thresh, proposals); qsort_descent_inplace(proposals); std::vector<int> picked; nms_sorted_bboxes(proposals, picked, nms_thresh_); int count = picked.size(); objects.resize(count); for (int i = 0; i < count; i++) { objects[i] = proposals[picked[i]]; // adjust offset to original unpadded float x0 = (objects[i].rect.x) / scale; float y0 = (objects[i].rect.y) / scale; float x1 = (objects[i].rect.x + objects[i].rect.width) / scale; float y1 = (objects[i].rect.y + objects[i].rect.height) / scale; // clip x0 = std::max(std::min(x0, (float)(img_w - 1)), 0.f); y0 = std::max(std::min(y0, (float)(img_h - 1)), 0.f); x1 = std::max(std::min(x1, (float)(img_w - 1)), 0.f); y1 = std::max(std::min(y1, (float)(img_h - 1)), 0.f); objects[i].rect.x = x0; objects[i].rect.y = y0; objects[i].rect.width = x1 - x0; objects[i].rect.height = y1 - y0; } } }; } #endif
38.935018
212
0.418544
HarvestX
739e0781817325c9c53c2d1b9c20358752c73dc8
8,713
cpp
C++
packages/utility/system/test/tstSphericalDirectionalCoordinateConversionPolicy.cpp
bam241/FRENSIE
e1760cd792928699c84f2bdce70ff54228e88094
[ "BSD-3-Clause" ]
10
2019-11-14T19:58:30.000Z
2021-04-04T17:44:09.000Z
packages/utility/system/test/tstSphericalDirectionalCoordinateConversionPolicy.cpp
bam241/FRENSIE
e1760cd792928699c84f2bdce70ff54228e88094
[ "BSD-3-Clause" ]
43
2020-03-03T19:59:20.000Z
2021-09-08T03:36:08.000Z
packages/utility/system/test/tstSphericalDirectionalCoordinateConversionPolicy.cpp
bam241/FRENSIE
e1760cd792928699c84f2bdce70ff54228e88094
[ "BSD-3-Clause" ]
6
2020-02-12T17:37:07.000Z
2020-09-08T18:59:51.000Z
//---------------------------------------------------------------------------// //! //! \file tstSphericalDirectionalCoordinateConversionPolicy.cpp //! \author Alex Robinson //! \brief Spherical directional coordinate conversion policy unit tests //! //---------------------------------------------------------------------------// // Std Lib Includes #include <iostream> // FRENSIE Includes #include "Utility_SphericalDirectionalCoordinateConversionPolicy.hpp" #include "Utility_3DCartesianVectorHelpers.hpp" #include "Utility_Vector.hpp" #include "Utility_Array.hpp" #include "Utility_QuantityTraits.hpp" #include "Utility_PhysicalConstants.hpp" #include "Utility_UnitTestHarnessWithMain.hpp" //---------------------------------------------------------------------------// // Tests. //---------------------------------------------------------------------------// // Check that the spherical directional coordinates can be converted to // Cartesian directional coordinates FRENSIE_UNIT_TEST( SphericalDirectionalCoordinateConversionPolicy, convertFromCartesianDirection ) { // Z-axis std::array<double,3> cartesian_direction = {0.0, 0.0, 1.0}; std::array<double,3> spherical_direction; std::array<double,3> ref_spherical_direction = {1.0, 0.0, 1.0}; Utility::SphericalDirectionalCoordinateConversionPolicy::convertFromCartesianDirection( cartesian_direction.data(), spherical_direction.data() ); FRENSIE_CHECK_FLOATING_EQUALITY( spherical_direction, ref_spherical_direction, 1e-15 ); // Neg. z-axis cartesian_direction = {0.0, 0.0, -1.0}; ref_spherical_direction = {1.0, 0.0, -1.0}; Utility::SphericalDirectionalCoordinateConversionPolicy::convertFromCartesianDirection( cartesian_direction.data(), spherical_direction.data() ); FRENSIE_CHECK_FLOATING_EQUALITY( spherical_direction, ref_spherical_direction, 1e-15 ); // Y-axis cartesian_direction = {0.0, 1.0, 0.0}; ref_spherical_direction = {1.0, Utility::PhysicalConstants::pi/2, 0.0}; Utility::SphericalDirectionalCoordinateConversionPolicy::convertFromCartesianDirection( cartesian_direction.data(), spherical_direction.data() ); FRENSIE_CHECK_FLOATING_EQUALITY( spherical_direction, ref_spherical_direction, 1e-15 ); // Neg. y-axis cartesian_direction = {0.0, -1.0, 0.0}; ref_spherical_direction = {1.0, 3*Utility::PhysicalConstants::pi/2, 0.0}; Utility::SphericalDirectionalCoordinateConversionPolicy::convertFromCartesianDirection( cartesian_direction.data(), spherical_direction.data() ); FRENSIE_CHECK_FLOATING_EQUALITY( spherical_direction, ref_spherical_direction, 1e-15 ); // X-axis cartesian_direction = {1.0, 0.0, 0.0}; ref_spherical_direction = {1.0, 0.0, 0.0}; Utility::SphericalDirectionalCoordinateConversionPolicy::convertFromCartesianDirection( cartesian_direction.data(), spherical_direction.data() ); FRENSIE_CHECK_FLOATING_EQUALITY( spherical_direction, ref_spherical_direction, 1e-15 ); // Neg. x-axis cartesian_direction = {-1.0, 0.0, 0.0}; ref_spherical_direction = {1.0, Utility::PhysicalConstants::pi, 0.0}; Utility::SphericalDirectionalCoordinateConversionPolicy::convertFromCartesianDirection( cartesian_direction.data(), spherical_direction.data() ); FRENSIE_CHECK_FLOATING_EQUALITY( spherical_direction, ref_spherical_direction, 1e-15 ); // Off axis cartesian_direction = {1.0/sqrt(3.0), 1.0/sqrt(3.0), 1.0/sqrt(3.0)}; ref_spherical_direction = {1.0, Utility::PhysicalConstants::pi/4, 1.0/sqrt(3.0)}; Utility::SphericalDirectionalCoordinateConversionPolicy::convertFromCartesianDirection( cartesian_direction[0], cartesian_direction[1], cartesian_direction[2], spherical_direction[0], spherical_direction[1], spherical_direction[2] ); FRENSIE_CHECK_FLOATING_EQUALITY( spherical_direction, ref_spherical_direction, 1e-15 ); } //---------------------------------------------------------------------------// // Check that the spherical directional coordinates can be converted to // Cartesian directional coordinates FRENSIE_UNIT_TEST( SphericalDirectionalCoordinateConversionPolicy, convertToCartesianDirection ) { // Z-axis std::array<double,3> spherical_direction = {1.0, 0.0, 1.0}; std::array<double,3> cartesian_direction; std::array<double,3> ref_cartesian_direction = {0.0, 0.0, 1.0}; Utility::SphericalDirectionalCoordinateConversionPolicy::convertToCartesianDirection( spherical_direction.data(), cartesian_direction.data() ); FRENSIE_CHECK_FLOATING_EQUALITY( cartesian_direction, ref_cartesian_direction, 1e-15 ); // Neg. Z-axis spherical_direction = {1.0, 0.0, -1.0}; ref_cartesian_direction = {0.0, 0.0, -1.0}; Utility::SphericalDirectionalCoordinateConversionPolicy::convertToCartesianDirection( spherical_direction.data(), cartesian_direction.data() ); FRENSIE_CHECK_FLOATING_EQUALITY( cartesian_direction, ref_cartesian_direction, 1e-15 ); // Y-axis spherical_direction = {1.0, Utility::PhysicalConstants::pi/2, 0.0}; ref_cartesian_direction = {0.0, 1.0, 0.0}; Utility::SphericalDirectionalCoordinateConversionPolicy::convertToCartesianDirection( spherical_direction.data(), cartesian_direction.data() ); Utility::clearVectorOfRoundingErrors( cartesian_direction.data(), 1e-15 ); FRENSIE_CHECK_FLOATING_EQUALITY( cartesian_direction, ref_cartesian_direction, 1e-15 ); // Neg. y-axis spherical_direction = {1.0, 3*Utility::PhysicalConstants::pi/2, 0.0}; ref_cartesian_direction = {0.0, -1.0, 0.0}; Utility::SphericalDirectionalCoordinateConversionPolicy::convertToCartesianDirection( spherical_direction.data(), cartesian_direction.data() ); Utility::clearVectorOfRoundingErrors( cartesian_direction.data(), 1e-15 ); FRENSIE_CHECK_FLOATING_EQUALITY( cartesian_direction, ref_cartesian_direction, 1e-15 ); // X-axis spherical_direction = {1.0, 0.0, 0.0}; ref_cartesian_direction = {1.0, 0.0, 0.0}; Utility::SphericalDirectionalCoordinateConversionPolicy::convertToCartesianDirection( spherical_direction.data(), cartesian_direction.data() ); FRENSIE_CHECK_FLOATING_EQUALITY( cartesian_direction, ref_cartesian_direction, 1e-15 ); // Y-axis spherical_direction = {1.0, Utility::PhysicalConstants::pi, 0.0}; ref_cartesian_direction = {-1.0, 0.0, 0.0}; Utility::SphericalDirectionalCoordinateConversionPolicy::convertToCartesianDirection( spherical_direction.data(), cartesian_direction.data() ); Utility::clearVectorOfRoundingErrors( cartesian_direction.data(), 1e-15 ); FRENSIE_CHECK_FLOATING_EQUALITY( cartesian_direction, ref_cartesian_direction, 1e-15 ); // Off axis spherical_direction = {1.0, Utility::PhysicalConstants::pi/4, 1.0/sqrt(3.0)}; ref_cartesian_direction = {1.0/sqrt(3.0), 1.0/sqrt(3.0), 1.0/sqrt(3.0)}; Utility::SphericalDirectionalCoordinateConversionPolicy::convertToCartesianDirection( spherical_direction.data(), cartesian_direction.data() ); FRENSIE_CHECK_FLOATING_EQUALITY( cartesian_direction, ref_cartesian_direction, 1e-15 ); } //---------------------------------------------------------------------------// // end tstSphericalDirectionalCoordinateConversionPolicy.cpp //---------------------------------------------------------------------------//
44.682051
89
0.596236
bam241
73a02df7bd3f19fc1efb0e588c8be63205f76042
2,119
cpp
C++
extensions_loader.cpp
kevinfrei/neutralinojs
d6433ec105d102a25a011897fa1c0a45dce8aca3
[ "WTFPL" ]
1
2018-06-23T03:45:10.000Z
2018-06-23T03:45:10.000Z
extensions_loader.cpp
kevinfrei/neutralinojs
d6433ec105d102a25a011897fa1c0a45dce8aca3
[ "WTFPL" ]
null
null
null
extensions_loader.cpp
kevinfrei/neutralinojs
d6433ec105d102a25a011897fa1c0a45dce8aca3
[ "WTFPL" ]
null
null
null
#include <string> #include <iostream> #include <fstream> #include <algorithm> #include <regex> #include <vector> #include "extensions_loader.h" #include "settings.h" #include "helpers.h" #include "auth/authbasic.h" #include "api/os/os.h" using namespace std; using json = nlohmann::json; namespace extensions { vector<string> loadedExtensions; bool initialized = false; string __buildExtensionArgs(const string &extensionId) { string options = ""; options += " --nl-port=" + to_string(settings::getOptionForCurrentMode("port").get<int>()); options += " --nl-token=" + authbasic::getTokenInternal(); options += " --nl-extension-id=" + extensionId; return options; } void init() { json jExtensions = settings::getOptionForCurrentMode("extensions"); if(jExtensions.is_null()) return; vector<json> extensions = jExtensions.get<vector<json>>(); for(const json &extension: extensions) { string commandKeyForOs = "command" + string(OS_NAME); if(!helpers::hasField(extension, "id")) { continue; } string extensionId = extension["id"].get<string>(); if(helpers::hasField(extension, "command") || helpers::hasField(extension, commandKeyForOs)) { string command = helpers::hasField(extension, commandKeyForOs) ? extension[commandKeyForOs].get<string>() : extension["command"].get<string>(); command = regex_replace(command, regex("\\$\\{NL_PATH\\}"), settings::getAppPath()); command += __buildExtensionArgs(extensionId); os::execCommand(command, "", true); // async } extensions::loadOne(extensionId); } initialized = true; } void loadOne(const string &extensionId) { loadedExtensions.push_back(extensionId); } vector<string> getLoaded() { return loadedExtensions; } bool isLoaded(const string &extensionId) { return find(loadedExtensions.begin(), loadedExtensions.end(), extensionId) != loadedExtensions.end(); } bool isInitialized() { return initialized; } } // namespace extensions
27.881579
117
0.657857
kevinfrei
73a32a7eab079e8d8054f8741b4a29111e5c527e
2,159
hpp
C++
Testbed/Tests/HalfPipe.hpp
louis-langholtz/Box2D
7c74792bf177cf36640d735de2bba0225bf7f852
[ "Zlib" ]
32
2016-10-20T05:55:04.000Z
2021-11-25T16:34:41.000Z
Testbed/Tests/HalfPipe.hpp
louis-langholtz/Box2D
7c74792bf177cf36640d735de2bba0225bf7f852
[ "Zlib" ]
50
2017-01-07T21:40:16.000Z
2018-01-31T10:04:05.000Z
Testbed/Tests/HalfPipe.hpp
louis-langholtz/Box2D
7c74792bf177cf36640d735de2bba0225bf7f852
[ "Zlib" ]
7
2017-02-09T10:02:02.000Z
2020-07-23T22:49:04.000Z
/* * Copyright (c) 2017 Louis Langholtz https://github.com/louis-langholtz/Box2D * * This software is provided 'as-is', without any express or implied * warranty. In no event will the authors be held liable for any damages * arising from the use of this software. * Permission is granted to anyone to use this software for any purpose, * including commercial applications, and to alter it and redistribute it * freely, subject to the following restrictions: * 1. The origin of this software must not be misrepresented; you must not * claim that you wrote the original software. If you use this software * in a product, an acknowledgment in the product documentation would be * appreciated but is not required. * 2. Altered source versions must be plainly marked as such, and must not be * misrepresented as being the original software. * 3. This notice may not be removed or altered from any source distribution. */ #ifndef HalfPipe_hpp #define HalfPipe_hpp #include "../Framework/Test.hpp" namespace box2d { class HalfPipe : public Test { public: HalfPipe() { const auto pipeBody = m_world->CreateBody(BodyDef{}.UseLocation(Vec2(0, 20) * Meter)); { auto conf = ChainShape::Conf{}; conf.UseFriction(1.0f); conf.vertices = GetCircleVertices(Real{20.0f} * Meter, 90, Real(180) * Degree, Real(0.5f)); pipeBody->CreateFixture(std::make_shared<ChainShape>(conf)); } const auto ballBody = m_world->CreateBody(BodyDef{} .UseType(BodyType::Dynamic) .UseLocation(Vec2(-19, 28) * Meter)); ballBody->CreateFixture(std::make_shared<DiskShape>(DiskShape::Conf{} .UseDensity(Real{0.01f} * KilogramPerSquareMeter) .UseVertexRadius(Real{1} * Meter) .UseFriction(1.0f))); } }; } #endif /* HalfPipe_hpp */
39.981481
98
0.592867
louis-langholtz
73a3cc66a9df48306cf9b544108bedb734859e28
6,876
cpp
C++
test-rpg/src/Character.cpp
sps1112/test-rpg
28b2acb4379695ad7e04401161ecca92cab9e3a6
[ "MIT" ]
2
2021-07-09T12:25:24.000Z
2021-12-22T12:38:47.000Z
test-rpg/src/Character.cpp
sps1112/test-rpg
28b2acb4379695ad7e04401161ecca92cab9e3a6
[ "MIT" ]
null
null
null
test-rpg/src/Character.cpp
sps1112/test-rpg
28b2acb4379695ad7e04401161ecca92cab9e3a6
[ "MIT" ]
null
null
null
#include "Character.h" namespace rpgText { Character::Character(std::string name_, int level, float str, float sta, float inte, float agi, float luck) { name = name_; BaseStats bs(str, sta, inte, agi, luck); stats = Stats(bs, level); cStats = stats; } void Character::change_health(float amount) { cStats.health += amount; cStats.health = clamp(cStats.health, 0, stats.health); } void Character::change_mana(float amount) { cStats.mana += amount; cStats.mana = clamp(cStats.mana, 0, stats.mana); } void Character::reset_stats() { cStats.health = stats.health; cStats.mana = stats.mana; } bool Character::get_status() { return (cStats.health > 0); } void Character::print_stats() { print_line(); log("[STATS]"); print("Name:- "); log(name); print_data("Level:- ", stats.level); print("Health:- "); print(cStats.health); print("/"); log(stats.health); print("Mana:- "); print(cStats.mana); print("/"); log(stats.mana); print_data("Attack:- ", cStats.attack); print_data("Defence:- ", cStats.defence); print_data("Mana Attack:- ", cStats.mAttack); print_data("Mana Defence:- ", cStats.mDefence); print_data("Speed:- ", cStats.speed); print_data("Accuracy:- ", cStats.accuracy); print_data("Evasion:- ", cStats.evasion); print_data("Crit Chance:- ", cStats.crit); print_line(); } Enemy::Enemy(std::string name_, bool viaData, int level, float str, float sta, float inte, float agi, float luck, float exp, float money) { name = name_; BaseStats bs(str, sta, inte, agi, luck); stats = Stats(bs, level); cStats = stats; expDrop = exp; moneyDrop = money; } Enemy::Enemy(const char *path) { std::string statsStr = get_file_data(path); const char *statsCode = statsStr.c_str(); int index = 0; // Set Name index = skip_lines(statsCode, 1, index); name = arr_to_string(get_data_point(statsCode, ":- ", index)); // Set Strength index = skip_lines(statsCode, 1, index); float str = arr_to_float(get_data_point(statsCode, ":- ", index)); // Set Stamina index = skip_lines(statsCode, 1, index); float sta = arr_to_float(get_data_point(statsCode, ":- ", index)); // Set Intelligence index = skip_lines(statsCode, 1, index); float inte = arr_to_float(get_data_point(statsCode, ":- ", index)); // Set Agility index = skip_lines(statsCode, 1, index); float agi = arr_to_float(get_data_point(statsCode, ":- ", index)); // Set Luck index = skip_lines(statsCode, 1, index); float luck = arr_to_float(get_data_point(statsCode, ":- ", index)); // Set Level index = skip_lines(statsCode, 1, index); int level = int(arr_to_float(get_data_point(statsCode, ":- ", index))); // Set Stats BaseStats bs(str, sta, inte, agi, luck); stats = Stats(bs, level); cStats = stats; // Set Exp Drop index = skip_lines(statsCode, 1, index); expDrop = arr_to_float(get_data_point(statsCode, ":- ", index)); // Set Money Drop index = skip_lines(statsCode, 1, index); moneyDrop = arr_to_float(get_data_point(statsCode, ":- ", index)); } Player::Player(std::string name_, bool viaData, int level, float str, float sta, float inte, float agi, float luck, float exp, float next) { name = name_; BaseStats bs(str, sta, inte, agi, luck); stats = Stats(bs, level); cStats = stats; currentExp = exp; expToNextlevel = next; write_to_file(); } Player::Player(const char *path) { std::string statsStr = get_file_data(path); const char *statsCode = statsStr.c_str(); int index = 0; // Set Name index = skip_lines(statsCode, 1, index); name = arr_to_string(get_data_point(statsCode, ":- ", index)); // Set Strength index = skip_lines(statsCode, 1, index); float str = arr_to_float(get_data_point(statsCode, ":- ", index)); // Set Stamina index = skip_lines(statsCode, 1, index); float sta = arr_to_float(get_data_point(statsCode, ":- ", index)); // Set Intelligence index = skip_lines(statsCode, 1, index); float inte = arr_to_float(get_data_point(statsCode, ":- ", index)); // Set Agility index = skip_lines(statsCode, 1, index); float agi = arr_to_float(get_data_point(statsCode, ":- ", index)); // Set Luck index = skip_lines(statsCode, 1, index); float luck = arr_to_float(get_data_point(statsCode, ":- ", index)); // Set Level index = skip_lines(statsCode, 1, index); int level = int(arr_to_float(get_data_point(statsCode, ":- ", index))); // Set Stats BaseStats bs(str, sta, inte, agi, luck); stats = Stats(bs, level); cStats = stats; // Set Current EXP index = skip_lines(statsCode, 1, index); currentExp = arr_to_float(get_data_point(statsCode, ":- ", index)); // Set EXP to Next Level index = skip_lines(statsCode, 1, index); expToNextlevel = arr_to_float(get_data_point(statsCode, ":- ", index)); write_to_file(); } Player::~Player() { write_to_file(); } void Player::write_to_file() { std::ofstream file; file.open(FileSystem::get_path("test-rpg/data/Player.saved.char").c_str(), std::ios::trunc); file << "[Stats]" << std::endl; file << "Name:- " << name.c_str() << std::endl; file << "Level:- " << stats.level << std::endl; file << "Health:- " << stats.health << std::endl; file << "Mana:- " << stats.mana << std::endl; file << "Attack:- " << stats.attack << std::endl; file << "Defence:- " << stats.defence << std::endl; file << "Mana Attack:- " << stats.mAttack << std::endl; file << "Mana Defence:- " << stats.mDefence << std::endl; file << "Speed:- " << stats.speed << std::endl; file << "Accuracy:- " << stats.accuracy << std::endl; file << "Evasion:- " << stats.evasion << std::endl; file << "Critical Chance:- " << stats.crit << std::endl; file << "CurrentExp:- " << currentExp << std::endl; file << "Exp to Next Level:- " << expToNextlevel << std::endl; file.close(); } } // namespace rpgText
31.113122
100
0.557446
sps1112
73a47a22080908680a30abee01a81c8c63776d50
2,243
cpp
C++
src/scripting/CameraScripting.cpp
ZaOniRinku/NeigeEngine
8dfe06e428ec1751ba0b5003ccdf5162474f002b
[ "MIT" ]
9
2020-10-06T11:17:07.000Z
2022-03-29T20:28:07.000Z
src/scripting/CameraScripting.cpp
ZaOniRinku/NeigeEngine
8dfe06e428ec1751ba0b5003ccdf5162474f002b
[ "MIT" ]
1
2020-10-06T11:55:45.000Z
2020-10-06T12:07:46.000Z
src/scripting/CameraScripting.cpp
ZaOniRinku/NeigeEngine
8dfe06e428ec1751ba0b5003ccdf5162474f002b
[ "MIT" ]
null
null
null
#include "CameraScripting.h" void CameraScripting::init() { lua_register(L, "getMainCameraIndex", getMainCameraIndex); lua_register(L, "setMainCameraIndex", setMainCameraIndex); lua_register(L, "getMainCameraEntity", getMainCameraEntity); lua_register(L, "getCameraCount", getCameraCount); } int CameraScripting::getMainCameraIndex(lua_State* L) { int n = lua_gettop(L); if (n == 0) { bool foundCamera = false; int cameraId = 0; int i = 0; for (Entity camera : *cameras) { if (mainCamera == camera) { cameraId = static_cast<int>(i); foundCamera = true; break; } i++; } if (foundCamera) { lua_pushnumber(L, cameraId); return 1; } else { NEIGE_SCRIPT_ERROR("Function \"getMainCameraIndex()\": unable to find main camera index."); return 0; } } else { NEIGE_SCRIPT_ERROR("Function \"getMainCameraIndex()\" takes no parameter."); return 0; } } int CameraScripting::setMainCameraIndex(lua_State* L) { int n = lua_gettop(L); if (n == 1) { if (lua_isnumber(L, -1)) { size_t cameraId = static_cast<size_t>(lua_tonumber(L, 1)); if (cameraId >= 0 && cameraId < cameras->size()) { mainCamera = *std::next(cameras->begin(), cameraId); return 0; } else { NEIGE_SCRIPT_ERROR("Function \"setMainCameraIndex(int cameraId)\": cameraId must be between 0 and getCameraCount() - 1."); return 0; } } else { NEIGE_SCRIPT_ERROR("Function \"setMainCameraIndex(int cameraId)\" takes 1 integer parameter."); return 0; } } else { NEIGE_SCRIPT_ERROR("Function \"setMainCameraIndex(int cameraId)\" takes 1 integer parameter."); return 0; } } int CameraScripting::getMainCameraEntity(lua_State* L) { int n = lua_gettop(L); if (n == 0) { lua_pushnumber(L, mainCamera); return 1; } else { NEIGE_SCRIPT_ERROR("Function \"getMainCameraEntity()\" takes no parameter."); return 0; } } int CameraScripting::getCameraCount(lua_State* L) { int n = lua_gettop(L); if (n == 0) { lua_pushnumber(L, static_cast<int>(cameras->size())); return 1; } else { NEIGE_SCRIPT_ERROR("Function \"getCameraCount()\" takes no parameter."); return 0; } }
24.380435
127
0.644226
ZaOniRinku
73ae11d09c48fe3a211b70bcb657f26912d2af0b
780
hpp
C++
include/lol/def/LolCollectionsCollectionsTopChampionMasteries.hpp
Maufeat/LeagueAPI
be7cb5093aab3f27d95b3c0e1d5700aa50126c47
[ "BSD-3-Clause" ]
1
2020-07-22T11:14:55.000Z
2020-07-22T11:14:55.000Z
include/lol/def/LolCollectionsCollectionsTopChampionMasteries.hpp
Maufeat/LeagueAPI
be7cb5093aab3f27d95b3c0e1d5700aa50126c47
[ "BSD-3-Clause" ]
null
null
null
include/lol/def/LolCollectionsCollectionsTopChampionMasteries.hpp
Maufeat/LeagueAPI
be7cb5093aab3f27d95b3c0e1d5700aa50126c47
[ "BSD-3-Clause" ]
4
2018-12-01T22:48:21.000Z
2020-07-22T11:14:56.000Z
#pragma once #include "../base_def.hpp" #include "LolCollectionsCollectionsChampionMastery.hpp" namespace lol { struct LolCollectionsCollectionsTopChampionMasteries { uint64_t summonerId; uint64_t score; std::vector<LolCollectionsCollectionsChampionMastery> masteries; }; inline void to_json(json& j, const LolCollectionsCollectionsTopChampionMasteries& v) { j["summonerId"] = v.summonerId; j["score"] = v.score; j["masteries"] = v.masteries; } inline void from_json(const json& j, LolCollectionsCollectionsTopChampionMasteries& v) { v.summonerId = j.at("summonerId").get<uint64_t>(); v.score = j.at("score").get<uint64_t>(); v.masteries = j.at("masteries").get<std::vector<LolCollectionsCollectionsChampionMastery>>(); } }
39
98
0.725641
Maufeat
73b20b0eb8bcfd36319ab1f750b27f5a1e3c8f30
12,275
hpp
C++
src/ropufu/format/mat4_header.hpp
ropufu/aftermath
ab9364c41672a188879d84ebebb5a23f2d6641ec
[ "MIT" ]
null
null
null
src/ropufu/format/mat4_header.hpp
ropufu/aftermath
ab9364c41672a188879d84ebebb5a23f2d6641ec
[ "MIT" ]
null
null
null
src/ropufu/format/mat4_header.hpp
ropufu/aftermath
ab9364c41672a188879d84ebebb5a23f2d6641ec
[ "MIT" ]
null
null
null
#ifndef ROPUFU_AFTERMATH_FORMAT_MAT4_HEADER_HPP_INCLUDED #define ROPUFU_AFTERMATH_FORMAT_MAT4_HEADER_HPP_INCLUDED #include "../algebra/matrix.hpp" #include <cstddef> // std::size_t #include <cstdint> // std::int32_t #include <fstream> // std::ifstream, std::ofstream #include <ios> // std::ios_base::failure #include <string> // std::string #include <system_error> // std::error_code, std::errc #include <vector> // std::vector namespace ropufu::aftermath::format { /** Indicates how the data are stored in a .mat file. */ enum struct mat4_data_format : std::int32_t { ieee_little_endian = 0000, ieee_big_endian = 1000, vax_d_float = 2000, vax_g_float = 3000, cray = 4000 }; // enum struct mat4_data_format /** Indicates what type of data is stored in a .mat file. */ template <typename t_data_type> struct mat4_data_type_id; /** Indicates that a .mat file stores \c double. */ template <> struct mat4_data_type_id<double> { static constexpr std::int32_t value = 00; }; /** Indicates that a .mat file stores \c float. */ template <> struct mat4_data_type_id<float> { static constexpr std::int32_t value = 10; }; /** Indicates that a .mat file stores \c std::int32_t. */ template <> struct mat4_data_type_id<std::int32_t> { static constexpr std::int32_t value = 20; }; /** Indicates that a .mat file stores \c std::int16_t. */ template <> struct mat4_data_type_id<std::int16_t> { static constexpr std::int32_t value = 30; }; /** Indicates that a .mat file stores \c std::uint16_t. */ template <> struct mat4_data_type_id<std::uint16_t> { static constexpr std::int32_t value = 40; }; /** Indicates that a .mat file stores \c std::uint8_t. */ template <> struct mat4_data_type_id<std::uint8_t> { static constexpr std::int32_t value = 50; }; [[maybe_unused]] static std::size_t mat4_data_type_size_by_id(std::int32_t data_type_id) noexcept { switch (data_type_id) { case mat4_data_type_id<double>::value: return sizeof(double); break; case mat4_data_type_id<float>::value: return sizeof(float); break; case mat4_data_type_id<std::int32_t>::value: return sizeof(std::int32_t); break; case mat4_data_type_id<std::int16_t>::value: return sizeof(std::int16_t); break; case mat4_data_type_id<std::uint16_t>::value: return sizeof(std::uint16_t); break; case mat4_data_type_id<std::uint8_t>::value: return sizeof(std::uint8_t); break; } // switch (...) return 0; } // mat4_data_type_size_by_id(...) /** Indicates the type of matrix stored in a .mat file. */ enum struct mat4_matrix_type_id : std::int32_t { full = 0, text = 1, sparse = 2 }; // enum struct mat4_matrix_type_id /** @brief Header format for a .mat file. */ struct mat4_header { using type = mat4_header; static constexpr std::size_t mat_level = 4; private: std::int32_t m_data_format_id = 0; std::int32_t m_data_type_id = 0; std::int32_t m_matrix_type_id = 0; std::int32_t m_height = 0; std::int32_t m_width = 0; std::int32_t m_is_complex = 0; std::string m_name = ""; /** Constructs a format type id from member fields. */ std::int32_t build_format_type_id() const noexcept { return this->m_data_format_id + this->m_data_type_id + this->m_matrix_type_id; } /** Updates member fields from a format type id. */ void decompose_format_type_id(std::int32_t format_type_id) noexcept { this->m_data_format_id = 1000 * (format_type_id / 1000); format_type_id -= this->m_data_format_id; this->m_data_type_id = 10 * (format_type_id / 10); format_type_id -= this->m_data_type_id; this->m_matrix_type_id = format_type_id; } // decompose_format_type_id(...) std::size_t on_read_error(std::error_code& ec, std::size_t int32_blocks_processed) const noexcept { ec = std::make_error_code(std::errc::io_error); return int32_blocks_processed * sizeof(std::int32_t); } // on_read_error(...) std::size_t on_write_error(std::error_code& ec, std::size_t int32_blocks_processed) const noexcept { ec = std::make_error_code(std::errc::io_error); return int32_blocks_processed * sizeof(std::int32_t); } // on_write_error(...) public: /** @brief Reads header from a .mat file. * @return Number of bytes read. * @param ec Set to \c std::errc::io_error if the header could not be read. */ std::size_t read(std::ifstream& filestream, std::error_code& ec) { std::size_t int32_blocks_processed = 0; std::int32_t format_type_id = 0; std::int32_t height = 0; std::int32_t width = 0; std::int32_t complex_flag = 0; std::int32_t name_length = 0; char terminator = '\0'; std::vector<char> text_data {}; if (!filestream.is_open()) return this->on_read_error(ec, int32_blocks_processed); if (filestream.fail()) return this->on_read_error(ec, int32_blocks_processed); // Fixed-size portion of the header: metadata. filestream.read(reinterpret_cast<char*>(&format_type_id), sizeof(decltype(format_type_id))); // type if (filestream.fail()) return this->on_read_error(ec, int32_blocks_processed); ++int32_blocks_processed; filestream.read(reinterpret_cast<char*>(&height), sizeof(decltype(height))); // mrows if (filestream.fail() || height < 0) return this->on_read_error(ec, int32_blocks_processed); ++int32_blocks_processed; filestream.read(reinterpret_cast<char*>(&width), sizeof(decltype(width))); // ncols if (filestream.fail() || width < 0) return this->on_read_error(ec, int32_blocks_processed); ++int32_blocks_processed; filestream.read(reinterpret_cast<char*>(&complex_flag), sizeof(decltype(complex_flag))); // imagf if (filestream.fail()) return this->on_read_error(ec, int32_blocks_processed); ++int32_blocks_processed; filestream.read(reinterpret_cast<char*>(&name_length), sizeof(decltype(name_length))); // namlen if (filestream.fail() || name_length < 1) return this->on_read_error(ec, int32_blocks_processed); ++int32_blocks_processed; --name_length; // The name length contains an integer with 1 plus the length of the matrix name. // Variable-sized header: variable name. text_data.resize(name_length); filestream.read(text_data.data(), name_length); if (filestream.fail() || filestream.gcount() != name_length) return this->on_read_error(ec, int32_blocks_processed); filestream.read(&terminator, 1); if (filestream.fail() || terminator != '\0') return this->on_read_error(ec, int32_blocks_processed); this->decompose_format_type_id(format_type_id); this->m_height = height; this->m_width = width; this->m_is_complex = (complex_flag == 0 ? false : true); this->m_name = std::string(text_data.begin(), text_data.end()); return this->size(); } // read(...) /** @brief Writes this header to \p filestream. * @return Number of bytes written. * @param ec Set to \c std::errc::io_error if the header could not be written. */ std::size_t write(std::ofstream& filestream, std::error_code& ec) const { std::size_t int32_blocks_processed = 0; std::int32_t format_type_id = this->build_format_type_id(); std::int32_t height = static_cast<std::int32_t>(this->m_height); std::int32_t width = static_cast<std::int32_t>(this->m_width); std::int32_t complex_flag = this->m_is_complex ? 1 : 0; std::int32_t name_length = static_cast<std::int32_t>(this->m_name.size() + 1); char terminator = '\0'; if (!filestream.is_open()) return this->on_write_error(ec, int32_blocks_processed); if (filestream.fail()) return this->on_write_error(ec, int32_blocks_processed); // Fixed-size portion of the header: metadata. filestream.write(reinterpret_cast<char*>(&format_type_id), sizeof(decltype(format_type_id))); // type if (filestream.fail()) return this->on_write_error(ec, int32_blocks_processed); ++int32_blocks_processed; filestream.write(reinterpret_cast<char*>(&height), sizeof(decltype(height))); // mrows if (filestream.fail()) return this->on_write_error(ec, int32_blocks_processed); ++int32_blocks_processed; filestream.write(reinterpret_cast<char*>(&width), sizeof(decltype(width))); // ncols if (filestream.fail()) return this->on_write_error(ec, int32_blocks_processed); ++int32_blocks_processed; filestream.write(reinterpret_cast<char*>(&complex_flag), sizeof(decltype(complex_flag))); // imagf if (filestream.fail()) return this->on_write_error(ec, int32_blocks_processed); ++int32_blocks_processed; filestream.write(reinterpret_cast<char*>(&name_length), sizeof(decltype(name_length))); // namlen if (filestream.fail()) return this->on_write_error(ec, int32_blocks_processed); ++int32_blocks_processed; // Variable-sized header: variable name. filestream.write(this->m_name.c_str(), this->m_name.size()); if (filestream.fail()) return this->on_write_error(ec, int32_blocks_processed); filestream.write(&terminator, 1); if (filestream.fail()) return this->on_write_error(ec, int32_blocks_processed); return this->size(); } // write(...) /** Initializes the header for a given matrix. */ template <typename t_value_type, typename t_allocator_type, typename t_arrangement_type> void initialize( const std::string& variable_name, const aftermath::algebra::matrix<t_value_type, t_allocator_type, t_arrangement_type>& mat, mat4_data_format data_format = mat4_data_format::ieee_little_endian, mat4_matrix_type_id matrix_type_id = mat4_matrix_type_id::full) noexcept { using data_type = t_value_type; this->m_data_format_id = static_cast<std::int32_t>(data_format); this->m_data_type_id = mat4_data_type_id<data_type>::value; this->m_matrix_type_id = static_cast<std::int32_t>(matrix_type_id); this->m_height = static_cast<std::int32_t>(mat.height()); this->m_width = static_cast<std::int32_t>(mat.width()); this->m_name = variable_name; } // initialize(...) /** Data format id. */ std::int32_t data_format_id() const noexcept { return this->m_data_format_id; } /** Data type id. */ std::int32_t data_type_id() const noexcept { return this->m_data_type_id; } /** Matrix type id. */ std::int32_t matrix_type_id() const noexcept { return this->m_matrix_type_id; } /** Matrix height. */ std::int32_t height() const noexcept { return this->m_height; } /** Matrix width. */ std::int32_t width() const noexcept { return this->m_width; } /** Indicates if a matrix contains complex numbers. */ bool is_complex() const noexcept { return this->m_is_complex; } /** Name of the matrix. */ const std::string& name() const noexcept { return this->m_name; } /** Gets the size, in bytes, of the current header. */ std::size_t size() const noexcept { return 5 * sizeof(std::int32_t) + this->m_name.size() + 1; } // size(...) }; // struct mat4_header } // namespace ropufu::aftermath::format #endif // ROPUFU_AFTERMATH_FORMAT_MAT4_HEADER_HPP_INCLUDED
47.211538
141
0.635682
ropufu
73b2de56a733c2aebe2a6c67cc40186136ea0917
1,425
hpp
C++
src/cpu/x64/brgemm/brgemm_amx.hpp
IvanNovoselov/oneDNN
aa47fcd2a03ee5caac119b6417bc66abe3154aab
[ "Apache-2.0" ]
4
2019-02-01T11:16:59.000Z
2020-04-27T17:27:06.000Z
src/cpu/x64/brgemm/brgemm_amx.hpp
IvanNovoselov/oneDNN
aa47fcd2a03ee5caac119b6417bc66abe3154aab
[ "Apache-2.0" ]
1
2020-04-17T22:23:01.000Z
2020-04-23T21:11:41.000Z
src/cpu/x64/brgemm/brgemm_amx.hpp
IvanNovoselov/oneDNN
aa47fcd2a03ee5caac119b6417bc66abe3154aab
[ "Apache-2.0" ]
5
2019-02-08T07:36:01.000Z
2021-07-14T07:58:50.000Z
/******************************************************************************* * Copyright 2020 Intel Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *******************************************************************************/ #ifndef CPU_X64_BRGEMM_BRGEMM_AMX_HPP #define CPU_X64_BRGEMM_BRGEMM_AMX_HPP namespace dnnl { namespace impl { namespace cpu { namespace x64 { namespace brgemm_amx { const static int max_m_block2 = 2; const static int max_n_block2 = 2; // Tile register decomposition inline int get_C_tensor(int m, int n) { return (m * max_m_block2 + n); } inline int get_A_tensor(int m) { return (max_m_block2 * max_n_block2 + m); } inline int get_B_tensor(int n) { return (max_m_block2 * max_n_block2 + max_m_block2 + n); } } // namespace brgemm_amx } // namespace x64 } // namespace cpu } // namespace impl } // namespace dnnl #endif //vim: et ts=4 sw=4 cindent cino+=l0,\:4,N-s
29.6875
80
0.657544
IvanNovoselov
73b3a4596cd78848524d1c62f38c0ef15d1fa680
14,544
cpp
C++
test/api/wallets.cpp
dated/cpp-client
392ad9ad87004165651aee61feca1b0320b287f8
[ "MIT" ]
11
2018-10-23T15:06:01.000Z
2021-11-17T08:02:24.000Z
test/api/wallets.cpp
dated/cpp-client
392ad9ad87004165651aee61feca1b0320b287f8
[ "MIT" ]
160
2018-10-24T17:29:11.000Z
2021-05-10T14:14:29.000Z
test/api/wallets.cpp
dated/cpp-client
392ad9ad87004165651aee61feca1b0320b287f8
[ "MIT" ]
28
2018-10-19T10:05:30.000Z
2020-11-23T23:31:40.000Z
#include "gtest/gtest.h" #include "gmock/gmock.h" #include <arkClient.h> #include "mocks/mock_api.h" using testing::_; using testing::Return; namespace { using namespace Ark::Client; using namespace Ark::Client::api; constexpr const char* tIp = "167.114.29.55"; constexpr const int tPort = 4003; } // namespace /**/ TEST(api, test_wallet) { // NOLINT Ark::Client::Connection<MockApi> connection(tIp, tPort); const std::string expected_response = R"({ "data": { "address": "DL6wmfnA2acPLpBjKS4zPGsSwxkTtGANsK", "publicKey": "02511f16ffb7b7e9afc12f04f317a11d9644e4be9eb5a5f64673946ad0f6336f34", "username": "genesis_1", "balance": "10035728150000", "isDelegate": true, "vote": "035c14e8c5f0ee049268c3e75f02f05b4246e746dc42f99271ff164b7be20cf5b8" } })"; EXPECT_CALL(connection.api.wallets, get(_)) .Times(1) .WillOnce(Return(expected_response)); const auto wallet = connection.api.wallets.get( "DL6wmfnA2acPLpBjKS4zPGsSwxkTtGANsK"); auto responseMatches = strcmp(expected_response.c_str(), wallet.c_str()) == 0; ASSERT_TRUE(responseMatches); } /**/ TEST(api, test_wallets) { // NOLINT Ark::Client::Connection<MockApi> connection(tIp, tPort); const std::string expected_response = R"({ "meta": { "count": 1, "pageCount": 196457, "totalCount": 196457, "next": "/api/wallets?limit=1&page=2", "previous": null, "self": "/api/wallets?limit=1&page=1", "first": "/api/wallets?limit=1&page=1", "last": "/api/wallets?limit=1&page=196457" }, "data": [ { "address": "D6Z26L69gdk9qYmTv5uzk3uGepigtHY4ax", "publicKey": "03d3fdad9c5b25bf8880e6b519eb3611a5c0b31adebc8455f0e096175b28321aff", "balance": "9898440219335676", "isDelegate": false } ] })"; EXPECT_CALL(connection.api.wallets, all(_)) .Times(1) .WillOnce(Return(expected_response)); const auto wallets = connection.api.wallets.all("?limit=1&page=1"); auto responseMatches = strcmp(expected_response.c_str(), wallets.c_str()) == 0; ASSERT_TRUE(responseMatches); } /**/ TEST(api, test_wallets_search) { // NOLINT Ark::Client::Connection<MockApi> connection(tIp, tPort); const std::string expected_response = R"({ "meta": { "count": 1, "pageCount": 1, "totalCount": 1, "next": null, "previous": null, "self": "/api/wallets/search?limit=1&page=1", "first": "/api/wallets/search?limit=1&page=1", "last": "/api/wallets/search?limit=1&page=1" }, "data": [ { "address": "DL6wmfnA2acPLpBjKS4zPGsSwxkTtGANsK", "publicKey": "02511f16ffb7b7e9afc12f04f317a11d9644e4be9eb5a5f64673946ad0f6336f34", "username": "genesis_1", "balance": "10035728150000", "isDelegate": true, "vote": "035c14e8c5f0ee049268c3e75f02f05b4246e746dc42f99271ff164b7be20cf5b8" } ] })"; EXPECT_CALL(connection.api.wallets, search(_, _)) .Times(1) .WillOnce(Return(expected_response)); const std::map<std::string, std::string> body = { { "username", "genesis_1" } }; const auto wallets = connection.api.wallets.search(body, "?limit=1&page=1"); auto responseMatches = strcmp(expected_response.c_str(), wallets.c_str()) == 0; ASSERT_TRUE(responseMatches); } /**/ TEST(api, test_wallets_top) { // NOLINT Ark::Client::Connection<MockApi> connection(tIp, tPort); const std::string expected_response = R"({ "meta": { "count": 1, "pageCount": 196457, "totalCount": 196457, "next": "/api/wallets/top?page=2&limit=1", "previous": null, "self": "/api/wallets/top?page=1&limit=1", "first": "/api/wallets/top?page=1&limit=1", "last": "/api/wallets/top?page=196457&limit=1" }, "data": [ { "address": "D6Z26L69gdk9qYmTv5uzk3uGepigtHY4ax", "publicKey": "03d3fdad9c5b25bf8880e6b519eb3611a5c0b31adebc8455f0e096175b28321aff", "balance": "9898440219335676", "isDelegate": false } ] })"; EXPECT_CALL(connection.api.wallets, top(_)) .Times(1) .WillOnce(Return(expected_response)); const auto wallets = connection.api.wallets.top("?limit=1&page=1"); auto responseMatches = strcmp(expected_response.c_str(), wallets.c_str()) == 0; ASSERT_TRUE(responseMatches); } /**/ TEST(api, test_wallets_locks) { // NOLINT Ark::Client::Connection<MockApi> connection(tIp, tPort); const std::string expected_response = R"({ "meta": { "count": 1, "pageCount": 1, "totalCount": 1, "next": null, "previous": null, "self": "/api/wallets/03db91f46dcd94311ab51efc9ca352e2628c27ffce63d1a609a14b8473c0db5b5d/locks?page=1&limit=100", "first": "/api/wallets/03db91f46dcd94311ab51efc9ca352e2628c27ffce63d1a609a14b8473c0db5b5d/locks?page=1&limit=100", "last": "/api/wallets/03db91f46dcd94311ab51efc9ca352e2628c27ffce63d1a609a14b8473c0db5b5d/locks?page=1&limit=100" }, "data": [ { "lockId": "d8c1d95462081fa211a8c56e717a3cdfaa53fd4985fc44473e392ab5458b336c", "amount": "1", "secretHash": "09b9a28393efd02fcd76a21b0f0f55ba2aad8f3640ff8cae86de033a9cfbd78c", "senderPublicKey": "03db91f46dcd94311ab51efc9ca352e2628c27ffce63d1a609a14b8473c0db5b5d", "recipientId": "D6eAmMh6FFynorCSjHS1Qx75rXiN89soa7", "timestamp": { "epoch": 81911280, "unix": 1572012480, "human": "2019-10-25T14:08:00.000Z" }, "expirationType": 2, "expirationValue": 6000000, "vendorField": "0.7712082776486138" } ] })"; EXPECT_CALL(connection.api.wallets, locks(_, _)) .Times(1) .WillOnce(Return(expected_response)); const auto locks = connection.api.wallets.locks( "D9SAVjqkxwWQmb82iqAedJPccFjDUnMSi9", "?limit=1&page=1"); auto responseMatches = strcmp(expected_response.c_str(), locks.c_str()) == 0; ASSERT_TRUE(responseMatches); } /**/ TEST(api, test_wallets_transactions) { // NOLINT Ark::Client::Connection<MockApi> connection(tIp, tPort); const std::string expected_response = R"({ "meta": { "totalCountIsEstimate": false, "count": 1, "pageCount": 7, "totalCount": 7, "next": "/api/wallets/DL6wmfnA2acPLpBjKS4zPGsSwxkTtGANsK/transactions?limit=1&page=2&transform=true", "previous": null, "self": "/api/wallets/DL6wmfnA2acPLpBjKS4zPGsSwxkTtGANsK/transactions?limit=1&page=1&transform=true", "first": "/api/wallets/DL6wmfnA2acPLpBjKS4zPGsSwxkTtGANsK/transactions?limit=1&page=1&transform=true", "last": "/api/wallets/DL6wmfnA2acPLpBjKS4zPGsSwxkTtGANsK/transactions?limit=1&page=7&transform=true" }, "data": [ { "id": "a8c0b8b9acabcb742e1760ce16aef5e92f0863bd035fd9bcb341b30d546abdad", "blockId": "17044958519703434496", "version": 1, "type": 0, "amount": "100000000", "fee": "10000000", "sender": "D6Z26L69gdk9qYmTv5uzk3uGepigtHY4ax", "senderPublicKey": "03d3fdad9c5b25bf8880e6b519eb3611a5c0b31adebc8455f0e096175b28321aff", "recipient": "DL6wmfnA2acPLpBjKS4zPGsSwxkTtGANsK", "signature": "3045022100cde3452fa74e8d9c2ed8187467edd631e55eb9bde5de4a62b7f52ec3d57399a602201827ead48ae19255770d10608fad103dc497f47458737edfae6abebbdd82245e", "confirmations": 2920745, "timestamp": { "epoch": 45021207, "unix": 1535122407, "human": "2018-08-24T14:53:27.000Z" } } ] })"; EXPECT_CALL(connection.api.wallets, transactions(_, _)) .Times(1) .WillOnce(Return(expected_response)); const auto transactions = connection.api.wallets.transactions( "DL6wmfnA2acPLpBjKS4zPGsSwxkTtGANsK", "?limit=1&page=1"); auto responseMatches = strcmp(expected_response.c_str(), transactions.c_str()) == 0; ASSERT_TRUE(responseMatches); } /**/ TEST(api, test_wallets_transactions_received) { // NOLINT Ark::Client::Connection<MockApi> connection(tIp, tPort); const std::string expected_response = R"({ "meta": { "totalCountIsEstimate": false, "count": 1, "pageCount": 7, "totalCount": 7, "next": "/api/wallets/DL6wmfnA2acPLpBjKS4zPGsSwxkTtGANsK/transactions/received?limit=1&page=2&transform=true", "previous": null, "self": "/api/wallets/DL6wmfnA2acPLpBjKS4zPGsSwxkTtGANsK/transactions/received?limit=1&page=1&transform=true", "first": "/api/wallets/DL6wmfnA2acPLpBjKS4zPGsSwxkTtGANsK/transactions/received?limit=1&page=1&transform=true", "last": "/api/wallets/DL6wmfnA2acPLpBjKS4zPGsSwxkTtGANsK/transactions/received?limit=1&page=7&transform=true" }, "data": [ { "id": "6b3d348a4341de3ea281d0af584d04ba78f14154955ac14af044a11bd43388cd", "blockId": "35da9ef1a5ffb396a180a1ccb7b40ee32ddfced5b6c24cb7133c926e8e66796a", "version": 1, "type": 3, "amount": "0", "fee": "10000000", "sender": "DL6wmfnA2acPLpBjKS4zPGsSwxkTtGANsK", "senderPublicKey": "02511f16ffb7b7e9afc12f04f317a11d9644e4be9eb5a5f64673946ad0f6336f34", "recipient": "DL6wmfnA2acPLpBjKS4zPGsSwxkTtGANsK", "signature": "3044022052b1d1f49c2efcbd306906449f6f46824db31110e3afbc0ed6fdca2ca5b3d59c0220039dfc70a8b48d49c5df12a7cbbb0cadc969078786d4824d25e8ff251360e763", "asset": { "votes": [ "+035c14e8c5f0ee049268c3e75f02f05b4246e746dc42f99271ff164b7be20cf5b8" ] }, "confirmations": 218052, "timestamp": { "epoch": 70926445, "unix": 1561027645, "human": "2019-06-20T10:47:25.000Z" } } ] })"; EXPECT_CALL(connection.api.wallets, transactionsReceived(_, _)) .Times(1) .WillOnce(Return(expected_response)); const auto received = connection.api.wallets.transactionsReceived( "DL6wmfnA2acPLpBjKS4zPGsSwxkTtGANsK", "?limit=1&page=1"); auto responseMatches = strcmp(expected_response.c_str(), received.c_str()) == 0; ASSERT_TRUE(responseMatches); } /**/ TEST(api, test_wallets_transactions_sent) { // NOLINT Ark::Client::Connection<MockApi> connection(tIp, tPort); const std::string expected_response = R"({ "meta": { "totalCountIsEstimate": false, "count": 1, "pageCount": 4, "totalCount": 4, "next": "/api/wallets/DL6wmfnA2acPLpBjKS4zPGsSwxkTtGANsK/transactions/sent?limit=1&page=2&transform=true", "previous": null, "self": "/api/wallets/DL6wmfnA2acPLpBjKS4zPGsSwxkTtGANsK/transactions/sent?limit=1&page=1&transform=true", "first": "/api/wallets/DL6wmfnA2acPLpBjKS4zPGsSwxkTtGANsK/transactions/sent?limit=1&page=1&transform=true", "last": "/api/wallets/DL6wmfnA2acPLpBjKS4zPGsSwxkTtGANsK/transactions/sent?limit=1&page=4&transform=true" }, "data": [ { "id": "6b3d348a4341de3ea281d0af584d04ba78f14154955ac14af044a11bd43388cd", "blockId": "35da9ef1a5ffb396a180a1ccb7b40ee32ddfced5b6c24cb7133c926e8e66796a", "version": 1, "type": 3, "amount": "0", "fee": "10000000", "sender": "DL6wmfnA2acPLpBjKS4zPGsSwxkTtGANsK", "senderPublicKey": "02511f16ffb7b7e9afc12f04f317a11d9644e4be9eb5a5f64673946ad0f6336f34", "recipient": "DL6wmfnA2acPLpBjKS4zPGsSwxkTtGANsK", "signature": "3044022052b1d1f49c2efcbd306906449f6f46824db31110e3afbc0ed6fdca2ca5b3d59c0220039dfc70a8b48d49c5df12a7cbbb0cadc969078786d4824d25e8ff251360e763", "asset": { "votes": [ "+035c14e8c5f0ee049268c3e75f02f05b4246e746dc42f99271ff164b7be20cf5b8" ] }, "confirmations": 218061, "timestamp": { "epoch": 70926445, "unix": 1561027645, "human": "2019-06-20T10:47:25.000Z" } } ] })"; EXPECT_CALL(connection.api.wallets, transactionsSent(_, _)) .Times(1) .WillOnce(Return(expected_response)); const auto sent = connection.api.wallets.transactionsSent( "DL6wmfnA2acPLpBjKS4zPGsSwxkTtGANsK", "?limit=1&page=1"); auto responseMatches = strcmp(expected_response.c_str(), sent.c_str()) == 0; ASSERT_TRUE(responseMatches); } /**/ TEST(api, test_wallets_votes) { // NOLINT Ark::Client::Connection<MockApi> connection(tIp, tPort); const std::string expected_response = R"({ "meta": { "totalCountIsEstimate": false, "count": 1, "pageCount": 3, "totalCount": 3, "next": "/api/wallets/DL6wmfnA2acPLpBjKS4zPGsSwxkTtGANsK/votes?limit=1&page=2&transform=true", "previous": null, "self": "/api/wallets/DL6wmfnA2acPLpBjKS4zPGsSwxkTtGANsK/votes?limit=1&page=1&transform=true", "first": "/api/wallets/DL6wmfnA2acPLpBjKS4zPGsSwxkTtGANsK/votes?limit=1&page=1&transform=true", "last": "/api/wallets/DL6wmfnA2acPLpBjKS4zPGsSwxkTtGANsK/votes?limit=1&page=3&transform=true" }, "data": [ { "id": "6b3d348a4341de3ea281d0af584d04ba78f14154955ac14af044a11bd43388cd", "blockId": "35da9ef1a5ffb396a180a1ccb7b40ee32ddfced5b6c24cb7133c926e8e66796a", "version": 1, "type": 3, "amount": "0", "fee": "10000000", "sender": "DL6wmfnA2acPLpBjKS4zPGsSwxkTtGANsK", "senderPublicKey": "02511f16ffb7b7e9afc12f04f317a11d9644e4be9eb5a5f64673946ad0f6336f34", "recipient": "DL6wmfnA2acPLpBjKS4zPGsSwxkTtGANsK", "signature": "3044022052b1d1f49c2efcbd306906449f6f46824db31110e3afbc0ed6fdca2ca5b3d59c0220039dfc70a8b48d49c5df12a7cbbb0cadc969078786d4824d25e8ff251360e763", "asset": { "votes": [ "+035c14e8c5f0ee049268c3e75f02f05b4246e746dc42f99271ff164b7be20cf5b8" ] }, "confirmations": 218065, "timestamp": { "epoch": 70926445, "unix": 1561027645, "human": "2019-06-20T10:47:25.000Z" } } ] })"; EXPECT_CALL(connection.api.wallets, votes(_, _)) .Times(1) .WillOnce(Return(expected_response)); const auto votes = connection.api.wallets.votes( "DL6wmfnA2acPLpBjKS4zPGsSwxkTtGANsK", "?limit=1&page=1"); auto responseMatches = strcmp(expected_response.c_str(), votes.c_str()) == 0; ASSERT_TRUE(responseMatches); }
33.981308
166
0.656216
dated
73b9eb40e4d41b656d279febf6f9387e66b4d3e2
3,735
cpp
C++
rocsolver/library/src/lapack/roclapack_potrf.cpp
leekillough/rocSOLVER
a0fa2af65be983dcec60081ed618b0642867aef0
[ "BSD-2-Clause" ]
null
null
null
rocsolver/library/src/lapack/roclapack_potrf.cpp
leekillough/rocSOLVER
a0fa2af65be983dcec60081ed618b0642867aef0
[ "BSD-2-Clause" ]
null
null
null
rocsolver/library/src/lapack/roclapack_potrf.cpp
leekillough/rocSOLVER
a0fa2af65be983dcec60081ed618b0642867aef0
[ "BSD-2-Clause" ]
null
null
null
/* ************************************************************************ * Copyright 2019-2020 Advanced Micro Devices, Inc. * ************************************************************************ */ #include "roclapack_potrf.hpp" template <typename S, typename T, typename U> rocblas_status rocsolver_potrf_impl(rocblas_handle handle, const rocblas_fill uplo, const rocblas_int n, U A, const rocblas_int lda, rocblas_int* info) { if(!handle) return rocblas_status_invalid_handle; //logging is missing ??? // argument checking if (!A || !info) return rocblas_status_invalid_pointer; if (n < 0 || lda < n) return rocblas_status_invalid_size; rocblas_stride strideA = 0; rocblas_int batch_count = 1; // memory managment size_t size_1; //size of constants size_t size_2; //size of workspace size_t size_3; size_t size_4; rocsolver_potrf_getMemorySize<T>(n,batch_count,&size_1,&size_2,&size_3,&size_4); // (TODO) MEMORY SIZE QUERIES AND ALLOCATIONS TO BE DONE WITH ROCBLAS HANDLE void *scalars, *work, *pivotGPU, *iinfo; hipMalloc(&scalars,size_1); hipMalloc(&work,size_2); hipMalloc(&pivotGPU,size_3); hipMalloc(&iinfo,size_4); if (!scalars || (size_2 && !work) || (size_3 && !pivotGPU) || (size_4 && !iinfo)) return rocblas_status_memory_error; // scalars constants for rocblas functions calls // (to standarize and enable re-use, size_1 always equals 3) std::vector<T> sca(size_1); sca[0] = -1; sca[1] = 0; sca[2] = 1; RETURN_IF_HIP_ERROR(hipMemcpy(scalars, sca.data(), sizeof(T)*size_1, hipMemcpyHostToDevice)); // execution rocblas_status status = rocsolver_potrf_template<S,T>(handle,uplo,n, A,0, //the matrix is shifted 0 entries (will work on the entire matrix) lda,strideA, info,batch_count, (T*)scalars, (T*)work, (T*)pivotGPU, (rocblas_int*)iinfo); hipFree(scalars); hipFree(work); hipFree(pivotGPU); hipFree(iinfo); return status; } /* * =========================================================================== * C wrapper * =========================================================================== */ extern "C" { ROCSOLVER_EXPORT rocblas_status rocsolver_spotrf(rocblas_handle handle, const rocblas_fill uplo, const rocblas_int n, float *A, const rocblas_int lda, rocblas_int* info) { return rocsolver_potrf_impl<float,float>(handle, uplo, n, A, lda, info); } ROCSOLVER_EXPORT rocblas_status rocsolver_dpotrf(rocblas_handle handle, const rocblas_fill uplo, const rocblas_int n, double *A, const rocblas_int lda, rocblas_int* info) { return rocsolver_potrf_impl<double,double>(handle, uplo, n, A, lda, info); } ROCSOLVER_EXPORT rocblas_status rocsolver_cpotrf(rocblas_handle handle, const rocblas_fill uplo, const rocblas_int n, rocblas_float_complex *A, const rocblas_int lda, rocblas_int* info) { return rocsolver_potrf_impl<float,rocblas_float_complex>(handle, uplo, n, A, lda, info); } ROCSOLVER_EXPORT rocblas_status rocsolver_zpotrf(rocblas_handle handle, const rocblas_fill uplo, const rocblas_int n, rocblas_double_complex *A, const rocblas_int lda, rocblas_int* info) { return rocsolver_potrf_impl<double,rocblas_double_complex>(handle, uplo, n, A, lda, info); } }
36.262136
117
0.578849
leekillough
73bf6f8d6f2592fe2a09c64173e1b709630ed9ad
18,066
cpp
C++
utils/errmsg/errmsg.cpp
kammerdienerb/flang
8cc4a02b94713750f09fe6b756d33daced0b4a74
[ "Apache-2.0" ]
1
2019-12-11T17:43:58.000Z
2019-12-11T17:43:58.000Z
utils/errmsg/errmsg.cpp
kammerdienerb/flang
8cc4a02b94713750f09fe6b756d33daced0b4a74
[ "Apache-2.0" ]
2
2019-12-29T21:15:40.000Z
2020-06-15T11:21:10.000Z
utils/errmsg/errmsg.cpp
kammerdienerb/flang
8cc4a02b94713750f09fe6b756d33daced0b4a74
[ "Apache-2.0" ]
3
2019-12-21T06:35:35.000Z
2020-06-07T23:18:58.000Z
/* * Copyright (c) 2016-2018, NVIDIA CORPORATION. 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 <cstring> #include <fstream> #include <iomanip> #include <iostream> #include <sstream> #include <stdexcept> #include <string> #include <vector> #include <cstdlib> /** * \file errmsg.cpp * \brief utility program for managing compiler error messages. * * ERRMSG - Utility program which reads file(s) in nroff format * defining error numbers and messages, and writes a file of * C code defining and initializing the data structure * containing the message text. * * INPUT: error message text definition file(s). * * OUTPUT: errmsgdf.h * output format: * static char* errtxt[] = { * ** 000 ** "text for message 0", * ** 001 ** "text for message 1", * " . . . ", * }; * * An error message definition in the errmsg*.n files looks like this: * * .MS W 109 "Type specification of field $ ignored" * Bit fields must be int, char, or short. * Bit field is given the type unsigned int. * * The arguments to the .MS macro are: * * - A letter indicating the severity. One of: * [I]nformational, [W]arning, [S]evere error, * [F]atal error, or [V]ariable severity. * * - A unique error code. * * - The error message in quotes. * * - Optionaly, a symbolic name for referring to the error in source * code. If no symbolic name is given, one is derived from the * error message like this: * * W_0109_Type_specification_of_field_OP1_ignored * * When the symbolic name is specified explicitly, it replaces the * automatically generated name. */ #if defined(_MSC_VER) #include <BaseTsd.h> typedef SSIZE_T ssize_t; #endif /** * \class Message * \brief Record for each message. */ struct Message { ssize_t number; //!< numeric error code char severity; //!< error severity code std::string symbol; //!< enum symbol for the error std::string message; //!< error message text std::vector<std::string> lines; //!< human explanation of an error /** * \brief Message default constructor * number is initialized to -1 as a flag for messages that have not * been defined yet. * other fields are default initialized to empty strings and vector. * This constructor is used when the vector of messages is created * or resized. */ Message() : number(-1), severity('\0') { } /** * \brief fill in the elements of a message. * \param n the numeric code for the error message. * \param s the severity code. * \param m the rest of the macro text specifying the error message. * \return 0 if successful or 1 otherwise. * * Parse a symbolic message identifier or generate a symbolic name * from the message text. */ int fill(int n, char s, std::string &m) { number = n; severity = s; // find the boundaries of a message text in quotes " or '. std::string::size_type begin_position = m.find_first_of("\"'"); if (begin_position != std::string::npos) { std::string::size_type end_position = m.find_last_of(m.substr(begin_position, 1)); if (end_position != std::string::npos) { // message text is the text in quotes excluding the quotes. message = m.substr(begin_position + 1, end_position - begin_position - 1); // find the symbol or generate from message if none found. begin_position = m.find_first_not_of(" \t", end_position + 1); std::ostringstream buffer; if (begin_position != std::string::npos) buffer << m.substr(begin_position); else buffer << severity << "_" << std::setfill('0') << std::setw(4) << number << "_" << message; symbol = buffer.str(); // replace $ with OPn, where n is 1, 2, ... int op = 1; bool more = true; while (more) { more = false; begin_position = symbol.find_first_of("$"); if (begin_position != std::string::npos) { more = true; buffer.str(""); buffer << "OP" << op++; symbol.replace(begin_position, 1, buffer.str()); } } // replace illegal characters with '_' avoiding multiple // sequential underscores begin_position = 0; while (begin_position != std::string::npos) { begin_position = symbol.find_first_not_of( "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", begin_position); if (begin_position != std::string::npos) { if (symbol[begin_position - 1] == '_') symbol.replace(begin_position, 1, ""); else symbol.replace(begin_position++, 1, "_"); } } // delete the trailing underscore, if any. begin_position = symbol.size() - 1; if (symbol[begin_position] == '_') symbol.replace(begin_position, 1, ""); return 0; } } return 1; } }; /** * \class Errmsg * \brief the application class encapsulates the application logic. */ class Errmsg { private: std::vector<const char *> input_filenames; //!< one or more input files const char *header_filename; //!< c header output file const char *nroff_filename; //!< aggregated doc output file const char *sphinx_filename; //!< aggregated Sphinx file //! lines before the first message definition std::vector<std::string> initial_lines; std::vector<Message> messages; //!< recorded error messages public: /** * \brief A constructor that processes the command line options. * * Multiple options of the same kind are ignored, only the last one * is used, except for input filename arguments, e.g. * $ ./errmsg -o out1.h -e err1.n in1.n in2.n -o out2.h * * ignores out1.h, reads in1.n and in2.n as input, writes C * definitions to out2.h, and writes aggregated nroff output to * err1.n. Throws an exception if the command line options are * wrong or missing. */ Errmsg(int argc, char *argv[]) : header_filename(0), nroff_filename(0), sphinx_filename(0) { for (int arg = 1; arg < argc; ++arg) { if (strcmp(argv[arg], "-e") == 0) { if (++arg < argc) nroff_filename = argv[arg]; else usage("missing error file name"); } else if (strcmp(argv[arg], "-o") == 0) { if (++arg < argc) header_filename = argv[arg]; else usage("missing output file name"); } else if (strcmp(argv[arg], "-s") == 0) { if (++arg < argc) sphinx_filename = argv[arg]; else usage("missing Sphinx file name"); } else if (argv[arg][0] == '-') usage("unknown option"); else input_filenames.push_back(argv[arg]); } if (input_filenames.size() == 0) usage("missing input file name"); if (nroff_filename == 0) usage("missing nroff doc file name"); if (header_filename == 0) usage("missing header file name"); } /** * \brief The driver of the utility program. * Read the input files and write the output files. * \return 0 if successful, 1 otherwise. */ int run() { for (std::vector<const char *>::iterator it = input_filenames.begin(); it != input_filenames.end(); ++it) if (read_input(*it)) return 1; if (sphinx_filename && write_aggregated_sphinx()) return 1; if (write_aggregated_nroff()) return 1; return write_c_declarations(); } private: /** * \brief output usage information for the program * Exit if invalid command line options are given. * \param error the error messages indicating a problem with the * command line options. */ void usage(const char *error = 0) { std::cout << "Usage: errmsg -e doc_file -o header_file [-s sphinx_file] " "input_file(s)\n\n"; std::cout << "input_file(s) -- one or more input files with error messages\n"; std::cout << "-e doc_file -- file to write the aggregated nroff output\n"; std::cout << "-o header_file -- file to write the aggregated C declarations\n"; std::cout << "-s sphinx_file -- file to write the output in Sphinx format\n\n"; if (error) { std::cerr << "Invalid command line: " << error << "\n\n"; std::exit(1); } } /** * \brief read a single input file * Fill in the information for error messages defined in the input * file. * \param filename the name of the input file. * \return 0 if successful or 1 otherwise. */ int read_input(const char *filename) { std::ifstream ifs(filename); if (!ifs) { std::cerr << "Input file could not be opened: " << filename << "\n"; return 1; } int ret = 0; int lineno = 0; std::vector<std::string> *lines = &initial_lines; for (std::string line; std::getline(ifs, line); ++lineno) { std::vector<Message>::size_type num; std::string text; char severity; if (line.compare(0, 4, ".MS ")) { lines->push_back(line); continue; } // extract the components of a macro .MS W 109 "..." std::istringstream iss(line.substr(4)); iss >> severity >> num; std::getline(iss, text); if (text.size() < 2) { std::cerr << filename << ":" << lineno << ": bad .MS macro: " << line << "\n"; ret = 1; continue; } if (num >= messages.size()) messages.resize(num + 1); // check a messages with the same number has been recorded earlier. if (messages[num].number != -1) { std::cerr << filename << ":" << lineno << ": two messages with the same number: " << num << "\n"; ret = 1; continue; } // message text is anything between <"> and <"> or <'> and <'>. if (messages[num].fill(num, severity, text)) { std::cerr << filename << ":" << lineno << "message text missing: %d" << num << "\n"; ret = 1; continue; } lines = &(messages[num].lines); lines->push_back(line); } return ret; } /** * \brief get rid of surrounding quotation mark if any. * \param input a text that may have leading or trailing whitespace * and contained in quotation marks "text". * \return a new string with quotation marks stripped or the * input text if no quotation marks found. */ std::string strip_surrounding_quotes(const std::string &input) { auto begin_pos = input.find_first_of('"'); if (begin_pos == std::string::npos) return input; auto end_pos = input.find_first_of('"', begin_pos + 1); if (end_pos == std::string::npos) return input; return input.substr(begin_pos + 1, end_pos - begin_pos - 1); } /** * \brief convert a single line of text from NROFF to RST. * Parse NROFF control sequences and transform the text to suitable * RST representation that preserves typesetting encoded in NROFF. * \param input a string of text to be transformed. * \return transformed string. */ std::string transform_nroff_to_sphinx(const std::string &input) { std::ostringstream oss; if (input[0] == '.') { std::istringstream iss(input.substr(1)); std::string macro; iss >> macro; if (macro == "NS") { int chapter; iss >> chapter; std::string header; std::getline(iss, header); // extract only the first quoted part of the line. auto begin_pos = header.find_first_of('"'); std::string::size_type end_pos; if (begin_pos == std::string::npos) { begin_pos = 0; end_pos = header.size() + 1; } else { begin_pos += 1; end_pos = header.find_first_of('"', begin_pos); } std::string underline(end_pos - begin_pos, '*'); oss << underline << "\n" << header.substr(begin_pos, end_pos - begin_pos) << "\n" << underline; } else if (macro == "US") { std::string text; std::getline(iss, text); oss << "* " << strip_surrounding_quotes(text) << " - "; } } else oss << input; return oss.str(); } /** * \brief escape the RST inline markup characters in text. * Replace special RST symbols with their escaped equivalents so * that these symbols appear in the typeset document as themselves. * \param input a text string to be transformed. * \return the input text string with all markup characters escaped. */ std::string escape_markup(std::string &input) { for (std::string::size_type pos = 0; pos != std::string::npos;) { pos = input.find_first_of("*`|", pos); if (pos != std::string::npos) { // if a markup character is already escaped don't do anything, // because it's a part of an NROFF controlling sequence. if (pos == 0 || input[pos - 1] != '\\') { input.insert(pos, 1, '\\'); pos += 2; } else { pos += 1; } } } return input; } /** * \brief trim any trailing whitespace. * \param input a string of text. * \return the input text without any trailing whitespace at the * end. */ std::string trim_trailing_whitespace(const std::string &input) { std::string::size_type pos = input.find_last_not_of(' '); return input.substr(0, pos + 1); } /** * \brief write the aggregated Sphinx file with all error messages. * * \return 0 if successful or 1 otherwise. */ int write_aggregated_sphinx() { std::ofstream out(sphinx_filename); if (!out) { std::cerr << "Output file could not be opened: " << sphinx_filename << "\n"; return 1; } // output the initial lines. for (std::vector<std::string>::iterator it = initial_lines.begin(); it != initial_lines.end(); ++it) out << transform_nroff_to_sphinx(*it) << "\n"; // output each message. out << std::setfill('0'); for (std::vector<Message>::iterator m = messages.begin(); m != messages.end(); ++m) { if (m->number != -1) { out << "**" << m->severity << std::setw(3) << m->number << "** *" << trim_trailing_whitespace(m->message) << "*\n"; for (std::vector<std::string>::iterator it = m->lines.begin() + 1; it != m->lines.end(); ++it) out << " " << transform_nroff_to_sphinx(escape_markup(*it)) << "\n"; out << "\n"; } } return 0; } /** * \brief write the aggregated nroff file with all error messages. * * \return 0 if successful or 1 otherwise. */ int write_aggregated_nroff() { std::ofstream out(nroff_filename); if (!out) { std::cerr << "Output file could not be opened: " << nroff_filename << "\n"; return 1; } // output the initial lines. for (std::vector<std::string>::iterator it = initial_lines.begin(); it != initial_lines.end(); ++it) out << *it << "\n"; // output each message. for (std::vector<Message>::iterator m = messages.begin(); m != messages.end(); ++m) for (std::vector<std::string>::iterator it = m->lines.begin(); it != m->lines.end(); ++it) out << *it << "\n"; return 0; } /** * \brief write the c header file with error message definitions. * * \return 0 if successful or 1 otherwise. */ int write_c_declarations() { std::ofstream out(header_filename); if (!out) { std::cerr << "Output file could not be opened: " << header_filename << "\n"; return 1; } out << "// This file written by utility program errmsg. Do not modify.\n" "#ifdef ERRMSG_GET_ERRTXT_TABLE\n" "#ifndef ERRMSGDFa_H_\n" "#define ERRMSGDFa_H_\n" "static char *errtxt[] = {\n"; out << std::setfill('0'); for (std::vector<Message>::size_type num = 0; num < messages.size(); ++num) { out << " /* " << std::setw(3) << num << " */"; if (messages[num].number == -1) out << " \"\",\n"; else out << " \"" << messages[num].message << "\",\n"; } out << "};\n" "#endif // ERRMSGDFa_H_\n" "#else /* ERRMSG_GET_ERRTXT_TABLE */\n" "#ifndef ERRMSGDFb_H_\n" "#define ERRMSGDFb_H_\n"; // emit an enumeration of all the symbolic error codes. out << "enum error_code {\n"; for (std::vector<Message>::iterator m = messages.begin(); m != messages.end(); ++m) { if (m->number != -1) { out << "\n " << m->symbol << " = " << m->number << ",\n"; for (std::vector<std::string>::iterator it = m->lines.begin() + 1; it != m->lines.end(); ++it) out << " // " << *it << "\n"; } } out << "};\n" "#endif // ERRMSGDFb_H_\n" "#endif /* ERRMSG_GET_ERRTXT_TABLE */\n"; return 0; } }; /** * \brief the application's main function. * * Create an application class object and invoke its run() method. * * \param argc - argument count * \param argv - array of arguments */ int main(int argc, char *argv[]) { Errmsg app(argc, argv); return app.run(); }
31.918728
80
0.579154
kammerdienerb
73c20d2ab7b184acabd3485d0ca0ca8267bb8a70
2,751
hpp
C++
breeze/debugging/dump_expression.hpp
gennaroprota/breeze
f1dfd7154222ae358f5ece936c2897a3ae110003
[ "BSD-3-Clause" ]
1
2021-04-03T22:35:52.000Z
2021-04-03T22:35:52.000Z
breeze/debugging/dump_expression.hpp
gennaroprota/breeze
f1dfd7154222ae358f5ece936c2897a3ae110003
[ "BSD-3-Clause" ]
null
null
null
breeze/debugging/dump_expression.hpp
gennaroprota/breeze
f1dfd7154222ae358f5ece936c2897a3ae110003
[ "BSD-3-Clause" ]
1
2021-10-01T04:26:48.000Z
2021-10-01T04:26:48.000Z
// =========================================================================== // Copyright 2013 Gennaro Prota // // Licensed under the 3-Clause BSD License. // (See accompanying file 3_CLAUSE_BSD_LICENSE.txt or // <https://opensource.org/licenses/BSD-3-Clause>.) // ___________________________________________________________________________ // //! \file //! \brief Displays an expression and its value to `std::cout`. // --------------------------------------------------------------------------- #ifndef BREEZE_GUARD_v4ifHvyokFutGDGkksKs5kPv6rpDcUGv #define BREEZE_GUARD_v4ifHvyokFutGDGkksKs5kPv6rpDcUGv #include "breeze/preprocessing/stringize_after_expansion.hpp" #include <cstring> #include <iostream> #include <ostream> // not necessary in C++11 // BREEZE_DUMP_EXPRESSION() // ------------------------ // //! \copybrief dump_expression.hpp //! //! \hideinitializer //! //! A simple macro for quickly dumping a variable or, generally, an //! expression to `std::cout`. //! //! It was born as "DUMP_VARIABLE" but then I immediately found a //! usage where I wanted to display something like `i + j`, so I //! renamed it to "DUMP_EXPRESSION". //! //! It's intended that you use this just for quick and dirty checks, //! and that you *remove* it after that. //! //! The expression is shown in the form `<expression> = value`. If //! `expression` contains macro invocations, the macros are //! expanded, but the unexpanded form is displayed, too. In any //! case, the output ends with `std::endl`. //! //! \note //! The `#include`'s are not part of the interface. // --------------------------------------------------------------------------- #define BREEZE_DUMP_EXPRESSION( expression ) \ do { \ char const expanded[] = \ BREEZE_STRINGIZE_AFTER_EXPANSION( expression ) ; \ char const unexpanded[] = # expression ; \ std::ostream & os = std::cout ; \ os << expanded << " = " << ( expression ) ; \ if ( std::strcmp( expanded, unexpanded ) != 0 ) { \ os << " [from: " << unexpanded << ']' ; \ } \ os << std::endl ; \ } while ( false ) /**/ #endif
45.85
78
0.455107
gennaroprota
73c2fd63df7c371a3d3378954583d8eb779433c2
10,153
cpp
C++
samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RebarTest/cpp/MainFrm.cpp
sashang/docs-1
8399f7c62a5ed6031ee7c576503cc73c268c09bb
[ "CC-BY-4.0", "MIT" ]
null
null
null
samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RebarTest/cpp/MainFrm.cpp
sashang/docs-1
8399f7c62a5ed6031ee7c576503cc73c268c09bb
[ "CC-BY-4.0", "MIT" ]
15
2022-03-23T00:40:19.000Z
2022-03-23T00:40:39.000Z
samples/snippets/cpp/VS_Snippets_Misc/NVC_MFC_RebarTest/cpp/MainFrm.cpp
sashang/docs-1
8399f7c62a5ed6031ee7c576503cc73c268c09bb
[ "CC-BY-4.0", "MIT" ]
null
null
null
// 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. #include "stdafx.h" #include "RebarTest.h" #include "MainFrm.h" #ifdef _DEBUG #define new DEBUG_NEW #endif // CMainFrame IMPLEMENT_DYNAMIC(CMainFrame, CMDIFrameWndEx) const int iMaxUserToolbars = 10; const UINT uiFirstUserToolBarId = AFX_IDW_CONTROLBAR_FIRST + 40; const UINT uiLastUserToolBarId = uiFirstUserToolBarId + iMaxUserToolbars - 1; BEGIN_MESSAGE_MAP(CMainFrame, CMDIFrameWndEx) ON_WM_CREATE() ON_WM_CLOSE() ON_COMMAND(ID_WINDOW_MANAGER, OnWindowManager) ON_COMMAND(ID_VIEW_CUSTOMIZE, OnViewCustomize) ON_REGISTERED_MESSAGE(AFX_WM_RESETTOOLBAR, OnToolbarReset) ON_COMMAND_RANGE(ID_VIEW_APPLOOK_2000, ID_VIEW_APPLOOK_2007_3, OnAppLook) ON_UPDATE_COMMAND_UI_RANGE(ID_VIEW_APPLOOK_2000, ID_VIEW_APPLOOK_2007_3, OnUpdateAppLook) END_MESSAGE_MAP() static UINT indicators[] = { ID_SEPARATOR, // status line indicator ID_INDICATOR_CAPS, ID_INDICATOR_NUM, ID_INDICATOR_SCRL, }; // CMainFrame construction/destruction CMainFrame::CMainFrame() { m_nAppLook = theApp.GetInt (_T("ApplicationLook"), ID_VIEW_APPLOOK_WIN_XP); // TODO: add member initialization code here } CMainFrame::~CMainFrame() { } int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) { if (CMDIFrameWndEx::OnCreate(lpCreateStruct) == -1) return -1; OnAppLook (m_nAppLook); // VISUAL_MANAGER if (CMFCToolBar::GetUserImages () == NULL) { // Load toolbar user images: if (!m_UserImages.Load (_T(".\\UserImages.bmp"))) { TRACE(_T("Failed to load user images\n")); } else { CMFCToolBar::SetUserImages (&m_UserImages); } } CMFCToolBar::EnableQuickCustomization (); // TODO: Define your own basic commands. Be sure, that each pulldown // menu have at least one basic command. CList<UINT, UINT> lstBasicCommands; lstBasicCommands.AddTail (ID_VIEW_TOOLBARS); lstBasicCommands.AddTail (ID_FILE_NEW); lstBasicCommands.AddTail (ID_FILE_OPEN); lstBasicCommands.AddTail (ID_FILE_SAVE); lstBasicCommands.AddTail (ID_FILE_PRINT); lstBasicCommands.AddTail (ID_APP_EXIT); lstBasicCommands.AddTail (ID_EDIT_CUT); lstBasicCommands.AddTail (ID_EDIT_PASTE); lstBasicCommands.AddTail (ID_EDIT_UNDO); lstBasicCommands.AddTail (ID_RECORD_NEXT); lstBasicCommands.AddTail (ID_RECORD_LAST); lstBasicCommands.AddTail (ID_APP_ABOUT); lstBasicCommands.AddTail (ID_VIEW_TOOLBAR); lstBasicCommands.AddTail (ID_VIEW_CUSTOMIZE); lstBasicCommands.AddTail (ID_WINDOW_TILE_HORZ); lstBasicCommands.AddTail (ID_VIEW_APPLOOK_2000); lstBasicCommands.AddTail (ID_VIEW_APPLOOK_XP); lstBasicCommands.AddTail (ID_VIEW_APPLOOK_2003); lstBasicCommands.AddTail (ID_VIEW_APPLOOK_2007); lstBasicCommands.AddTail (ID_VIEW_APPLOOK_VS2005); lstBasicCommands.AddTail (ID_VIEW_APPLOOK_WIN_XP); lstBasicCommands.AddTail (ID_VIEW_APPLOOK_2007_1); lstBasicCommands.AddTail (ID_VIEW_APPLOOK_2007_2); lstBasicCommands.AddTail (ID_VIEW_APPLOOK_2007_3); CMFCToolBar::SetBasicCommands (lstBasicCommands); if (!m_wndMenuBar.Create (this)) { TRACE0("Failed to create menubar\n"); return -1; // fail to create } m_wndMenuBar.SetPaneStyle(m_wndMenuBar.GetPaneStyle() | CBRS_SIZE_DYNAMIC); // Remove menubar gripper and borders: m_wndMenuBar.SetPaneStyle (m_wndMenuBar.GetPaneStyle() & ~(CBRS_GRIPPER | CBRS_BORDER_TOP | CBRS_BORDER_BOTTOM | CBRS_BORDER_LEFT | CBRS_BORDER_RIGHT)); // Detect color depth. 256 color toolbars can be used in the // high or true color modes only (bits per pixel is > 8): CClientDC dc (this); BOOL bIsHighColor = dc.GetDeviceCaps (BITSPIXEL) > 8; UINT uiToolbarHotID = bIsHighColor ? IDB_TOOLBAR256 : 0; if (!m_wndToolBar.CreateEx(this) || !m_wndToolBar.LoadToolBar(IDR_MAINFRAME, 0, 0, FALSE, 0, 0, uiToolbarHotID)) { TRACE0("Failed to create toolbar\n"); return -1; // fail to create } // <snippet2> // Each rebar pane will occupy its own row: DWORD dwStyle = RBBS_GRIPPERALWAYS | RBBS_FIXEDBMP | RBBS_BREAK; // CMFCMenuBar m_wndMenuBar // CMFCToolBar m_wndToolBar if (!m_wndReBar.Create(this) || !m_wndReBar.AddBar (&m_wndMenuBar) || !m_wndReBar.AddBar (&m_wndToolBar, NULL, NULL, dwStyle)) { TRACE0("Failed to create rebar\n"); return -1; // fail to create } // </snippet2> m_wndMenuBar.AdjustLayout (); m_wndToolBar.AdjustLayout (); // TODO: Remove this if you don't want chevrons: m_wndMenuBar.EnableCustomizeButton (TRUE, -1, _T("")); m_wndToolBar.EnableCustomizeButton (TRUE, ID_VIEW_CUSTOMIZE, _T("Customize...")); EnableDocking(CBRS_ALIGN_ANY); m_wndReBar.EnableDocking (CBRS_TOP); DockPane (&m_wndReBar); if (!m_wndStatusBar.Create(this) || !m_wndStatusBar.SetIndicators(indicators, sizeof(indicators)/sizeof(UINT))) { TRACE0("Failed to create status bar\n"); return -1; // fail to create } BOOL bValidString; CString strMainToolbarTitle; bValidString = strMainToolbarTitle.LoadString (IDS_MAIN_TOOLBAR); m_wndToolBar.SetWindowText (strMainToolbarTitle); // TODO: Remove this if you don't want tool tips m_wndMenuBar.SetPaneStyle(m_wndMenuBar.GetPaneStyle() | CBRS_TOOLTIPS | CBRS_FLYBY); m_wndToolBar.SetPaneStyle(m_wndToolBar.GetPaneStyle() | CBRS_TOOLTIPS | CBRS_FLYBY); // Enable windows manager: EnableWindowsDialog (ID_WINDOW_MANAGER, IDS_WINDOWS_MANAGER, TRUE); // Enable control bar context menu (list of bars + customize command): EnablePaneMenu ( TRUE, // Enable ID_VIEW_CUSTOMIZE, // Customize command ID _T("Customize..."), // Customize command text ID_VIEW_TOOLBARS); // Menu items with this ID will be replaced by // toolbars menu return 0; } BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs) { if( !CMDIFrameWndEx::PreCreateWindow(cs) ) return FALSE; // TODO: Modify the Window class or styles here by modifying // the CREATESTRUCT cs return TRUE; } // CMainFrame diagnostics #ifdef _DEBUG void CMainFrame::AssertValid() const { CMDIFrameWndEx::AssertValid(); } void CMainFrame::Dump(CDumpContext& dc) const { CMDIFrameWndEx::Dump(dc); } #endif //_DEBUG // CMainFrame message handlers void CMainFrame::OnViewCustomize() { //------------------------------------ // Create a customize toolbars dialog: //------------------------------------ CMFCToolBarsCustomizeDialog* pDlgCust = new CMFCToolBarsCustomizeDialog (this, TRUE /* Automatic menus scaning */); pDlgCust->EnableUserDefinedToolbars (); pDlgCust->Create (); } afx_msg LRESULT CMainFrame::OnToolbarReset(WPARAM /*wp*/,LPARAM) { // TODO: reset toolbar with id = (UINT) wp to its initial state: // // UINT uiToolBarId = (UINT) wp; // if (uiToolBarId == IDR_MAINFRAME) // { // do something with m_wndToolBar // } return 0; } void CMainFrame::OnWindowManager() { ShowWindowsDialog (); } void CMainFrame::OnAppLook(UINT id) { CDockingManager::SetDockingMode (DT_SMART); m_nAppLook = id; CTabbedPane::m_StyleTabWnd = CMFCTabCtrl::STYLE_3D; switch (m_nAppLook) { case ID_VIEW_APPLOOK_2000: // enable Office 2000 look: CMFCVisualManager::SetDefaultManager (RUNTIME_CLASS (CMFCVisualManager)); break; case ID_VIEW_APPLOOK_XP: // enable Office XP look: CMFCVisualManager::SetDefaultManager (RUNTIME_CLASS (CMFCVisualManagerOfficeXP)); break; case ID_VIEW_APPLOOK_WIN_XP: // enable Windows XP look (in other OS Office XP look will be used): CMFCVisualManagerWindows::m_b3DTabsXPTheme = TRUE; CMFCVisualManager::SetDefaultManager (RUNTIME_CLASS (CMFCVisualManagerWindows)); break; case ID_VIEW_APPLOOK_2003: // enable Office 2003 look: CMFCVisualManager::SetDefaultManager (RUNTIME_CLASS (CMFCVisualManagerOffice2003)); CDockingManager::SetDockingMode (DT_SMART); break; case ID_VIEW_APPLOOK_2007: case ID_VIEW_APPLOOK_2007_1: case ID_VIEW_APPLOOK_2007_2: case ID_VIEW_APPLOOK_2007_3: // enable Office 2007 look: switch (m_nAppLook) { case ID_VIEW_APPLOOK_2007: CMFCVisualManagerOffice2007::SetStyle (CMFCVisualManagerOffice2007::Office2007_LunaBlue); break; case ID_VIEW_APPLOOK_2007_1: CMFCVisualManagerOffice2007::SetStyle (CMFCVisualManagerOffice2007::Office2007_ObsidianBlack); break; case ID_VIEW_APPLOOK_2007_2: CMFCVisualManagerOffice2007::SetStyle (CMFCVisualManagerOffice2007::Office2007_Silver); break; case ID_VIEW_APPLOOK_2007_3: CMFCVisualManagerOffice2007::SetStyle (CMFCVisualManagerOffice2007::Office2007_Aqua); break; } CMFCVisualManager::SetDefaultManager (RUNTIME_CLASS (CMFCVisualManagerOffice2007)); CDockingManager::SetDockingMode (DT_SMART); break; case ID_VIEW_APPLOOK_VS2005: // enable VS 2005 look: CMFCVisualManager::SetDefaultManager (RUNTIME_CLASS (CMFCVisualManagerVS2005)); CDockingManager::SetDockingMode (DT_SMART); break; } CDockingManager* pDockManager = GetDockingManager (); if (pDockManager != NULL) { ASSERT_VALID (pDockManager); pDockManager->AdjustPaneFrames (); } CTabbedPane::ResetTabs (); RecalcLayout (); RedrawWindow (NULL, NULL, RDW_ALLCHILDREN | RDW_INVALIDATE | RDW_UPDATENOW | RDW_ERASE); theApp.WriteInt (_T("ApplicationLook"), m_nAppLook); } void CMainFrame::OnUpdateAppLook(CCmdUI* pCmdUI) { pCmdUI->SetRadio (m_nAppLook == pCmdUI->m_nID); } CMDIChildWndEx* CMainFrame::CreateDocumentWindow (LPCTSTR lpcszDocName, CObject* /*pObj*/) { if (lpcszDocName != NULL && lpcszDocName [0] != '\0') { CDocument* pDoc = AfxGetApp()->OpenDocumentFile (lpcszDocName); if (pDoc != NULL) { POSITION pos = pDoc->GetFirstViewPosition(); if (pos != NULL) { CView* pView = pDoc->GetNextView (pos); if (pView == NULL) { return NULL; } return DYNAMIC_DOWNCAST (CMDIChildWndEx, pView->GetParent ()); } } } return NULL; } void CMainFrame::OnClose() { SaveMDIState (theApp.GetRegSectionPath ()); CMDIFrameWndEx::OnClose(); } // RIBBON_APP
26.578534
97
0.751699
sashang
73c35c2ac358da87aa1b59edd3d1c2f9ce8d68f9
1,601
cpp
C++
src/trainerwrapper.cpp
roloza7/nn-test
3400e6e065be68858c6ce692d349f3ddb8596033
[ "MIT" ]
null
null
null
src/trainerwrapper.cpp
roloza7/nn-test
3400e6e065be68858c6ce692d349f3ddb8596033
[ "MIT" ]
null
null
null
src/trainerwrapper.cpp
roloza7/nn-test
3400e6e065be68858c6ce692d349f3ddb8596033
[ "MIT" ]
null
null
null
#include "trainerwrapper.h" #ifdef TrainerWrapper #undef TrainerWrapper #endif #ifndef TrainerWrapper_API #define TrainerWrapper_API TrainerWrapper #endif TrainerWrapper_API::TrainerWrapper_API(int n_subjects, int network_size) { pImpl = new TrainerWrapper_impl(n_subjects, network_size); } TrainerWrapper_API::~TrainerWrapper_API() { delete pImpl; } // double** TrainerWrapper_API::AddInputArray(int input_size) { // return pImpl->AddInputArray(input_size); // } // double** TrainerWrapper_API::AddOutputArray(int output_size) { // return pImpl->AddOutputArray(output_size); // } // bool TrainerWrapper_API::CheckStatus() { // return true; // } // void TrainerWrapper_API::Step() { // pImpl->Step(); // } // void TrainerWrapper_API::NextGeneration(int winner_id) { // pImpl->NextGeneration(winner_id); // } // TrainerWrapper* TrainerWrapper_Create(int n_subjects, int network_size) { // return new TrainerWrapper(n_subjects, network_size); // } // double** TrainerWrapper_AddInputArray(TrainerWrapper* tw, int input_size) { // return tw->AddInputArray(input_size); // } // double** TrainerWrapper_AddOutputArray(TrainerWrapper* tw, int output_size) { // return tw->AddOutputArray(output_size); // } // void TrainerWrapper_Step(TrainerWrapper* tw) { // tw->Step(); // } // void TrainerWrapper_NextGeneration(TrainerWrapper* tw, int winner_id) { // tw->NextGeneration(winner_id); // } // bool TrainerWrapper_CheckStatus(TrainerWrapper* tw) { // return tw->CheckStatus(); // }
26.245902
81
0.695815
roloza7
73c4be390e11a7acd2aec5c9e208abbb026fa126
4,687
cpp
C++
VAIC_ISU_24/src/map.cpp
wpivex/vaic-v5-20_21
ee3528ac0c2a0760ff7e15500a3160f297f889c7
[ "MIT" ]
null
null
null
VAIC_ISU_24/src/map.cpp
wpivex/vaic-v5-20_21
ee3528ac0c2a0760ff7e15500a3160f297f889c7
[ "MIT" ]
null
null
null
VAIC_ISU_24/src/map.cpp
wpivex/vaic-v5-20_21
ee3528ac0c2a0760ff7e15500a3160f297f889c7
[ "MIT" ]
null
null
null
/*----------------------------------------------------------------------------*/ /* */ /* Module: map.cpp */ /* Author: Jatin */ /* Created: 2/17/21 */ /* Description: Implementation of the map class's methods */ /* */ /*----------------------------------------------------------------------------*/ #include "vex.h" #include "map.h" using namespace vex; using namespace ai; /* * Updates the global Map obj declared in vex.h with data from the Jetson and vex link */ void updateMapObj(bool printBalls) { MAP_RECORD mapRecord; // Map from the Jetson jetson_comms.get_data(&mapRecord); jetson_comms.request_map(); // get ball data from mapRecord int numBalls = mapRecord.mapnum; BallCoord balls[numBalls]; FILE *fp = fopen("/dev/serial2", "w"); for (int i = 0; i < numBalls; i++) { float x = (mapRecord.mapobj[i].positionX / -25.4); float y = (mapRecord.mapobj[i].positionY / -25.4); balls[i] = {mapRecord.mapobj[i].age, mapRecord.mapobj[i].classID, x, y}; if(printBalls) { switch(mapRecord.mapobj[i].classID) { case 0: fprintf(fp, "* Red "); break; case 1: fprintf(fp, "* Blue "); break; default: fprintf(fp, "* Not a "); break; } fprintf(fp, "Ball: %f, %f\n\r", balls[i].x, balls[i].y ); } } fflush(fp); fclose(fp); map->setBallCoords(balls, numBalls); // get manager robot data from mapRecord and worker data from vex link coords RobotCoord robots[2]; int numRobots = 1; float managerHeading = (float) ((-mapRecord.pos.az - M_PI/2) * 360 / (2 * M_PI)); float managerX = mapRecord.pos.x / -25.4f + POS_OFFSET * cos(managerHeading * M_PI / 180); float managerY = mapRecord.pos.y / -25.4f + POS_OFFSET * sin(managerHeading * M_PI / 180); robots[0] = { 0, // manager managerX, // hopefully in to the right of (0,0), need to test on field managerY, // hopefully in above of (0,0), need to test on field managerHeading, // starts at +x and increases counterclockwise, range of (-270 : 90) 24 // 24 in }; link.set_remote_location(robots[0].x, robots[0].y, robots[0].deg); if (link.isLinked()) { float workerX, workerY, workerHeading; link.get_remote_location(workerX, workerY, workerHeading); robots[1] = { 1, // worker workerX, // hopefully in to the right of (0,0), need to test on field workerY, // hopefully in above of (0,0), need to test on field workerHeading, // hopefully starts at +x and increases counterclockwise, need to test on field 15 // 15 in }; numRobots++; } map->setRobotCoords(robots, numRobots); } // updateMapObj() BallCoord* Map::getBallCoords(void) { return balls; } int Map::getNumBalls(void) { return numBalls; } bool Map::hasBall(int id) { MAP_RECORD mapRecord; // Map from the Jetson jetson_comms.get_data(&mapRecord); jetson_comms.request_map(); for(int i = 0; i < mapRecord.boxnum; i++) { if(id == mapRecord.boxobj[i].classID) return true; } return false; } RobotCoord Map::getManagerCoords(void) { return manager; } RobotCoord Map::getWorkerCoords(void) { return worker; } RobotCoord* Map::getEnemyCoords(void) { return enemies; } int Map::getNumEnemies(void) { return numEnemies; } // void Map::addBallCoord(BallCoord coord) { // // TODO implement intelligent management of existing elements given new data // } // void Map::addRobotCoord(RobotCoord coord) { // // TODO implement intelligent management of existing elements given new data // } void Map::setBallCoords(BallCoord* coords, int numCoords) { for (int i = 0; i < MAX_BALLS; i++) { if (i < numCoords) balls[i] = coords[i]; else balls[i] = {0, -1, 0, 0}; } numBalls = numCoords; } void Map::setRobotCoords(RobotCoord* coords, int numCoords) { manager = {-1, 0, 0, 0, 0}; worker = {-1, 0, 0, 0, 0}; for (int i = 0; i < MAX_ENEMIES; i++) enemies[i] = {-1, 0, 0, 0, 0}; numEnemies = 0; for (int i = 0; i < numCoords; i++) { switch(coords[i].robotID) { case 0: manager = coords[i]; break; case 1: worker = coords[i]; break; case 2: if (numEnemies < MAX_ENEMIES) enemies[numEnemies++] = coords[i]; break; } } }
27.570588
100
0.550245
wpivex
73c803497dd0add1806b854d80e19b0e6e6afda1
216
hpp
C++
dynamic/wrappers/mesh/PottsElement3.cppwg.hpp
jmsgrogan/PyChaste
48a9863d2c941c71e47ecb72e917b477ba5c1413
[ "FTL" ]
6
2017-02-04T16:10:53.000Z
2021-07-01T08:03:16.000Z
dynamic/wrappers/mesh/PottsElement3.cppwg.hpp
jmsgrogan/PyChaste
48a9863d2c941c71e47ecb72e917b477ba5c1413
[ "FTL" ]
6
2017-06-22T08:50:41.000Z
2019-12-15T20:17:29.000Z
dynamic/wrappers/mesh/PottsElement3.cppwg.hpp
jmsgrogan/PyChaste
48a9863d2c941c71e47ecb72e917b477ba5c1413
[ "FTL" ]
3
2017-05-15T21:33:58.000Z
2019-10-27T21:43:07.000Z
#ifndef PottsElement3_hpp__pyplusplus_wrapper #define PottsElement3_hpp__pyplusplus_wrapper namespace py = pybind11; void register_PottsElement3_class(py::module &m); #endif // PottsElement3_hpp__pyplusplus_wrapper
30.857143
49
0.87037
jmsgrogan
73c8b0cdf0697dc2df99d8caf25bec80359fc3e0
2,567
cpp
C++
tree/medium/173.BinarySearchTreeIterator.cpp
XiaotaoGuo/Leetcode-Solution-In-Cpp
8e01e35c742a7afb0c8cdd228a6a5e564375434e
[ "Apache-2.0" ]
null
null
null
tree/medium/173.BinarySearchTreeIterator.cpp
XiaotaoGuo/Leetcode-Solution-In-Cpp
8e01e35c742a7afb0c8cdd228a6a5e564375434e
[ "Apache-2.0" ]
null
null
null
tree/medium/173.BinarySearchTreeIterator.cpp
XiaotaoGuo/Leetcode-Solution-In-Cpp
8e01e35c742a7afb0c8cdd228a6a5e564375434e
[ "Apache-2.0" ]
null
null
null
/* * @lc app=leetcode id=173 lang=cpp * * [173] Binary Search Tree Iterator * * https://leetcode.com/problems/binary-search-tree-iterator/description/ * * algorithms * Medium (57.87%) * Likes: 2998 * Dislikes: 285 * Total Accepted: 347.9K * Total Submissions: 599.5K * Testcase Example: '["BSTIterator","next","next","hasNext","next","hasNext","next","hasNext","next","hasNext"]\n' + '[[[7,3,15,null,null,9,20]],[null],[null],[null],[null],[null],[null],[null],[null],[null]]' * * Implement an iterator over a binary search tree (BST). Your iterator will be * initialized with the root node of a BST. * * Calling next() will return the next smallest number in the BST. * * * * * * * Example: * * * * * BSTIterator iterator = new BSTIterator(root); * iterator.next(); // return 3 * iterator.next(); // return 7 * iterator.hasNext(); // return true * iterator.next(); // return 9 * iterator.hasNext(); // return true * iterator.next(); // return 15 * iterator.hasNext(); // return true * iterator.next(); // return 20 * iterator.hasNext(); // return false * * * * * Note: * * * next() and hasNext() should run in average O(1) time and uses O(h) memory, * where h is the height of the tree. * You may assume that next() call will always be valid, that is, there will be * at least a next smallest number in the BST when next() is called. * * */ // @lc code=start /** * 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) {} * }; */ #include <queue> class BSTIterator { public: BSTIterator(TreeNode* root) { dfs(root); } /** @return the next smallest number */ int next() { int val = node_list.front(); node_list.pop(); return val; } /** @return whether we have a next smallest number */ bool hasNext() { return !node_list.empty(); } private: std::queue<int> node_list; private: void dfs(TreeNode* node) { if (node == nullptr) return; dfs(node->left); node_list.push(node->val); dfs(node->right); } }; /** * Your BSTIterator object will be instantiated and called as such: * BSTIterator* obj = new BSTIterator(root); * int param_1 = obj->next(); * bool param_2 = obj->hasNext(); */ // @lc code=end
23.990654
95
0.609661
XiaotaoGuo
73ca25d498b6dcf5c52c1a246fe269a47609b4af
3,357
cpp
C++
src/PhyloAcc-GT/profile.cpp
gwct/PhyloAcc
089162e2bce5a17b95d71add074bf51bccc8a266
[ "MIT" ]
null
null
null
src/PhyloAcc-GT/profile.cpp
gwct/PhyloAcc
089162e2bce5a17b95d71add074bf51bccc8a266
[ "MIT" ]
null
null
null
src/PhyloAcc-GT/profile.cpp
gwct/PhyloAcc
089162e2bce5a17b95d71add074bf51bccc8a266
[ "MIT" ]
null
null
null
#include "profile.h" #include <stdlib.h> #include <iostream> #include <fstream> #include <sstream> #include <string> #include <cstring> #include <vector> #include <map> #include <cassert> #include "utils.h" using namespace std; // load the phylogenetic profile PhyloProf LoadPhyloProfiles(string profile_path, string segment_path, string segment_ID) { PhyloProf prof; vector<string> seqs; prof.G=0; string linestr; ifstream in_prof(profile_path.c_str()); if (!in_prof) { cerr << "(Error. Cannot open the phylogenetic profile input file: " << profile_path << ")" << endl; exit(1); } // count the num of species, base pairs and load the profiles string wholeline=""; while(!in_prof.eof()) { std::getline(in_prof, linestr); linestr = strutils::trim(linestr); if(!strncmp(linestr.c_str(),">", 1)) { //return 0 if 1st char of linestr is >. string tmp = strutils::trim(linestr.substr(1)); prof.species_names.push_back(tmp); if(prof.G==0) prof.G = wholeline.length(); else assert(wholeline.length() == prof.G); if(prof.G>0) { wholeline =strutils::ToLowerCase(wholeline); prof.X.push_back(wholeline); } wholeline = ""; } else { wholeline += linestr; } } if(prof.G==0) prof.G = wholeline.length(); wholeline =strutils::ToLowerCase(wholeline); prof.X.push_back(wholeline); prof.S = prof.species_names.size(); //read in segment size and specific scaling factor ifstream in_segment(segment_path.c_str()); if (!in_segment) { cerr << "(Error. Cannot open the segment input file: " << segment_path << ")" << endl; exit(1); } while(!in_segment.eof()) { std::getline(in_segment, linestr); linestr = strutils::trim(linestr); vector<string> line_splits = strutils::split(linestr, '\t'); if(line_splits.size()<3) break; prof.element_names.push_back(line_splits[0]); double* tmp = new double[3]; //vector<double> tmp=vector<double>(2,0.0); tmp[0] = atoi(line_splits[1].c_str()); tmp[1] = atoi(line_splits[2].c_str()); //tmp[2] = atof(line_splits[4].c_str()); //add null scale!! prof.element_pos.push_back(tmp); if(line_splits.size() >=8) prof.element_tree.push_back(line_splits[7]); } prof.C = prof.element_names.size(); in_segment.close(); // read in ID if (segment_ID != "") { string segment_path2 = segment_ID + ".txt"; in_segment.open(segment_path2.c_str()); if (!in_segment) { cerr << "(Error. Cannot open the segment input txt file: " << segment_path2 << ")" << endl; exit(1); } while (!in_segment.eof()) { std::getline(in_segment, linestr); linestr = strutils::trim(linestr); if (linestr == "") continue; //vector<string> line_splits = strutils::split(linestr, '\t'); //if(line_splits.size()<3) break; prof.element_id.push_back(linestr); } } in_segment.close(); return prof; }
27.975
107
0.563003
gwct
73ca3792a03420a375b91425d40f8015d5fd3bb8
2,922
cpp
C++
cpp/cpp/721. Accounts Merge.cpp
longwangjhu/LeetCode
a5c33e8d67e67aedcd439953d96ac7f443e2817b
[ "MIT" ]
3
2021-08-07T07:01:34.000Z
2021-08-07T07:03:02.000Z
cpp/cpp/721. Accounts Merge.cpp
longwangjhu/LeetCode
a5c33e8d67e67aedcd439953d96ac7f443e2817b
[ "MIT" ]
null
null
null
cpp/cpp/721. Accounts Merge.cpp
longwangjhu/LeetCode
a5c33e8d67e67aedcd439953d96ac7f443e2817b
[ "MIT" ]
null
null
null
// https://leetcode.com/problems/accounts-merge/ // Given a list of accounts where each element accounts[i] is a list of strings, // where the first element accounts[i][0] is a name, and the rest of the elements // are emails representing emails of the account. // Now, we would like to merge these accounts. Two accounts definitely belong to // the same person if there is some common email to both accounts. Note that even // if two accounts have the same name, they may belong to different people as // people could have the same name. A person can have any number of accounts // initially, but all of their accounts definitely have the same name. // After merging the accounts, return the accounts in the following format: the // first element of each account is the name, and the rest of the elements are // emails in sorted order. The accounts themselves can be returned in any order. //////////////////////////////////////////////////////////////////////////////// // union find -> node: email // parents[email] = email; owner[email] = name // map parents[email] -> id to distinguish identical names // sort before return class Solution { public: vector<vector<string>> accountsMerge(vector<vector<string>>& accounts) { for (auto& account : accounts) { string name = account[0]; for (int i = 1; i < account.size(); ++i) { string email = account[i]; owners[email] = name; if (parents.find(email) == parents.end()) { parents[email] = email; ranks[email] = 1; } unionEmails(account[1], email); } } // ids[root emails] = number unordered_map<string, int> ids; for (auto& [email, _] : parents) { string parent = find(email); if (ids.find(parent) == ids.end()) { // new parent int sz = ids.size(); ids[parent] = sz; } } vector<vector<string>> ans(ids.size()); for (auto& [email, parent] : parents) { // loop over every email int id = ids[parent]; if (ans[id].empty()) ans[id].push_back(owners[parent]); ans[id].push_back(email); } // sort for (auto& account : ans) { sort(account.begin() + 1, account.end()); } return ans; } private: unordered_map<string, string> parents, owners; unordered_map<string, int> ranks; string find(string e) { if (parents[e] != e) parents[e] = find(parents[e]); return parents[e]; } void unionEmails(string e1, string e2) { string p1 = find(e1), p2 = find(e2); if (p1 == p2) return; if (ranks[p1] < ranks[p2]) parents[p1] = p2; else { if (ranks[p1] == ranks[p2]) ++ranks[p1]; parents[p2] = p1; } } };
37.948052
81
0.562628
longwangjhu
73cb633f5fa1a764c122a608cc4757ef3cd2d568
2,001
hpp
C++
hpx/runtime/components/server/preprocessed/runtime_support_create_component_capabilities.hpp
andreasbuhr/hpx
4366a90aacbd3e95428a94ab24a1646a67459cc2
[ "BSL-1.0" ]
null
null
null
hpx/runtime/components/server/preprocessed/runtime_support_create_component_capabilities.hpp
andreasbuhr/hpx
4366a90aacbd3e95428a94ab24a1646a67459cc2
[ "BSL-1.0" ]
null
null
null
hpx/runtime/components/server/preprocessed/runtime_support_create_component_capabilities.hpp
andreasbuhr/hpx
4366a90aacbd3e95428a94ab24a1646a67459cc2
[ "BSL-1.0" ]
null
null
null
// Copyright (c) 2007-2013 Hartmut Kaiser // Copyright (c) 2012-2013 Thomas Heller // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) #if !defined(HPX_PREPROCESSED_RUNTIME_COMPONENTS_SERVER_RUNTIME_SUPPORT_CREATE_COMPONENT_CAPABILITIES_HPP) #define HPX_PREPROCESSED_RUNTIME_COMPONENTS_SERVER_RUNTIME_SUPPORT_CREATE_COMPONENT_CAPABILITIES_HPP #if HPX_ACTION_ARGUMENT_LIMIT <= 5 #include <hpx/runtime/components/server/preprocessed/runtime_support_create_component_capabilities_5.hpp> #elif HPX_ACTION_ARGUMENT_LIMIT <= 10 #include <hpx/runtime/components/server/preprocessed/runtime_support_create_component_capabilities_10.hpp> #elif HPX_ACTION_ARGUMENT_LIMIT <= 15 #include <hpx/runtime/components/server/preprocessed/runtime_support_create_component_capabilities_15.hpp> #elif HPX_ACTION_ARGUMENT_LIMIT <= 20 #include <hpx/runtime/components/server/preprocessed/runtime_support_create_component_capabilities_20.hpp> /* #elif HPX_ACTION_ARGUMENT_LIMIT <= 25 #include <hpx/runtime/components/server/preprocessed/runtime_support_create_component_capabilities_25.hpp> #elif HPX_ACTION_ARGUMENT_LIMIT <= 30 #include <hpx/runtime/components/server/preprocessed/runtime_support_create_component_capabilities_30.hpp> #elif HPX_ACTION_ARGUMENT_LIMIT <= 35 #include <hpx/runtime/components/server/preprocessed/runtime_support_create_component_capabilities_35.hpp> #elif HPX_ACTION_ARGUMENT_LIMIT <= 40 #include <hpx/runtime/components/server/preprocessed/runtime_support_create_component_capabilities_40.hpp> #elif HPX_ACTION_ARGUMENT_LIMIT <= 45 #include <hpx/runtime/components/server/preprocessed/runtime_support_create_component_capabilities_45.hpp> #elif HPX_ACTION_ARGUMENT_LIMIT <= 50 #include <hpx/runtime/components/server/preprocessed/runtime_support_create_component_capabilities_50.hpp> */ #else #error "HPX_ACTION_ARGUMENT_LIMIT out of bounds for preprocessed headers" #endif #endif
54.081081
106
0.86007
andreasbuhr
73cc4087180868f033aaa43bc7724e5ad04010e0
3,341
cpp
C++
AudioSynthesis/Audio/loop.cpp
eliasrm87/AudioSynthesisQt
feb05c74d85494300d0fca868a37015042ec74c8
[ "Unlicense" ]
1
2021-09-03T11:06:45.000Z
2021-09-03T11:06:45.000Z
AudioSynthesis/Audio/loop.cpp
eliasrm87/AudioSynthesisQt
feb05c74d85494300d0fca868a37015042ec74c8
[ "Unlicense" ]
null
null
null
AudioSynthesis/Audio/loop.cpp
eliasrm87/AudioSynthesisQt
feb05c74d85494300d0fca868a37015042ec74c8
[ "Unlicense" ]
2
2021-09-03T11:06:53.000Z
2021-09-03T11:07:25.000Z
#include <QDebug> #include <QJsonArray> #include "loop.h" Loop::Loop(QJsonObject *params, QObject *parent) : Source("Loop", params, parent) { //Path path_ = params_->value("path").toString(""); //Parts QJsonArray parts = params_->value("parts").toArray(); foreach (QJsonValue part, parts) { parts_.push_back(part.toString().toULongLong()); } if (parts_.isEmpty()) { addPart(0); } else { qSort(parts_); } } Loop::Loop(const Loop &loop) : Source(loop) { path_ = loop.path_; parts_ = loop.parts_; } Loop::~Loop() { } const SamplesVector &Loop::getSamples() { return Source::getSamples(); } void Loop::getSamples(SamplesVector &dest, const qint32 &size) { QMutexLocker mtxLock(&mtx_); if (!synthesized_) { synthesized_ = true; synthesize(); } dest.clear(); int currentBeat, nextBeat; quint32 beatLength, beatPos; { QMutexLocker staticVarsMtxLoc(staticVarsMtx_); currentBeat = (samplesClock_ / beatLength_) % parts_.size(); nextBeat = (currentBeat + 1) % parts_.size(); beatPos = samplesClock_ % beatLength_; pos_ = parts_[currentBeat] + beatPos; beatLength = beatLength_; } qint32 remSize = size; qint32 mSize, remBeat; qint32 available; while (remSize > 0) { remBeat = beatLength - beatPos; if (remSize > remBeat) { mSize = remBeat; } else { mSize = remSize; } if (nextBeat == 0) { available = samplesBuffer_.size() - pos_; } else { available = parts_[nextBeat] - pos_; } if (available < 0) { available = 0; } else if (available > remBeat) { available = remBeat; } if (mSize > available) { dest.append(samplesBuffer_.mid(pos_, available)); SamplesVector filling; filling.fill(0, mSize - available); dest.append(filling); } else { dest.append(samplesBuffer_.mid(pos_, mSize)); } pos_ += mSize; remSize -= mSize; nextBeat = (currentBeat + 1) % parts_.size(); } } QString Loop::path() const { return path_; } void Loop::setPath(const QString &path) { QMutexLocker mtxLock(&mtx_); path_ = path; params_->insert("path", path); synthesize(); } void Loop::addPart(const quint64 &part) { QMutexLocker mtxLock(&mtx_); if (parts_.contains(part)) return; parts_.push_back(part); QJsonArray jsonArr; foreach (quint64 p, parts_) { jsonArr.push_back(QString::number(p)); } params_->insert("parts", jsonArr); qSort(parts_); } void Loop::delPart(const quint64 &part) { QMutexLocker mtxLock(&mtx_); parts_.removeOne(part); } void Loop::synthesize() { qDebug() << "Loop::synthesize" << path_; QFile file(path_); file.open(QFile::ReadOnly); QByteArray buffer = file.readAll(); file.close(); qint16 value16; samplesBuffer_.clear(); for (int i = 0; i < buffer.size(); i += 2) { value16 = (qint16)(((buffer[i+1] & 0xFF) << 8) | (buffer[i] & 0xFF)); samplesBuffer_.push_back((float)value16 / (float)INT16_MAX); } pos_ = 0; Source::synthesize(); }
21.280255
77
0.57408
eliasrm87