hexsha
stringlengths
40
40
size
int64
7
1.05M
ext
stringclasses
13 values
lang
stringclasses
1 value
max_stars_repo_path
stringlengths
4
269
max_stars_repo_name
stringlengths
5
108
max_stars_repo_head_hexsha
stringlengths
40
40
max_stars_repo_licenses
listlengths
1
9
max_stars_count
float64
1
191k
max_stars_repo_stars_event_min_datetime
stringlengths
24
24
max_stars_repo_stars_event_max_datetime
stringlengths
24
24
max_issues_repo_path
stringlengths
4
269
max_issues_repo_name
stringlengths
5
116
max_issues_repo_head_hexsha
stringlengths
40
40
max_issues_repo_licenses
listlengths
1
9
max_issues_count
float64
1
77k
max_issues_repo_issues_event_min_datetime
stringlengths
24
24
max_issues_repo_issues_event_max_datetime
stringlengths
24
24
max_forks_repo_path
stringlengths
4
269
max_forks_repo_name
stringlengths
5
116
max_forks_repo_head_hexsha
stringlengths
40
40
max_forks_repo_licenses
listlengths
1
9
max_forks_count
float64
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
653k
max_line_length
int64
6
990k
alphanum_fraction
float64
0.01
1
7308109a4d30d81b15a570e8c15109778ff6bf5e
767
cpp
C++
init/src/hpx_main_argc_argv.cpp
jokteur/hpx
689ce9b586322c90f966ef84aa6eba190f037dd7
[ "BSL-1.0" ]
1,822
2015-01-03T11:22:37.000Z
2022-03-31T14:49:59.000Z
init/src/hpx_main_argc_argv.cpp
Deepak-suresh14/hpx
5ecf3cad298678021c77c825a9f54d7c119d9dd1
[ "BSL-1.0" ]
3,288
2015-01-05T17:00:23.000Z
2022-03-31T18:49:41.000Z
init/src/hpx_main_argc_argv.cpp
Deepak-suresh14/hpx
5ecf3cad298678021c77c825a9f54d7c119d9dd1
[ "BSL-1.0" ]
431
2015-01-07T06:22:14.000Z
2022-03-31T14:50:04.000Z
// Copyright (c) 2007-2013 Hartmut Kaiser // // SPDX-License-Identifier: BSL-1.0 // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) #include <hpx/hpx_init.hpp> #include <hpx/hpx_finalize.hpp> /////////////////////////////////////////////////////////////////////////////// // Forwarding of hpx_main, if necessary. This has to be in a separate // translation unit to ensure the linker can pick or ignore this function, // depending on whether the main executable defines this symbol or not. int hpx_main(int argc, char** argv) { // Invoke hpx_startup::user_main int result = hpx_startup::user_main(argc, argv); hpx::finalize(); return result; }
36.52381
80
0.654498
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
730936d3234a022b9673db4e23201cfbe3c65bc1
825
cpp
C++
boboleetcode/Play-Leetcode-master/0049-Group-Anagrams/cpp-0049/main.cpp
yaominzh/CodeLrn2019
adc727d92904c5c5d445a2621813dfa99474206d
[ "Apache-2.0" ]
2
2021-03-25T05:26:55.000Z
2021-04-20T03:33:24.000Z
boboleetcode/Play-Leetcode-master/0049-Group-Anagrams/cpp-0049/main.cpp
mcuallen/CodeLrn2019
adc727d92904c5c5d445a2621813dfa99474206d
[ "Apache-2.0" ]
6
2019-12-04T06:08:32.000Z
2021-05-10T20:22:47.000Z
boboleetcode/Play-Leetcode-master/0049-Group-Anagrams/cpp-0049/main.cpp
mcuallen/CodeLrn2019
adc727d92904c5c5d445a2621813dfa99474206d
[ "Apache-2.0" ]
null
null
null
/// Source : https://leetcode.com/problems/group-anagrams/description/ /// Author : liuyubobobo /// Time : 2018-09-12 #include <iostream> #include <vector> #include <unordered_map> using namespace std; /// Using HashMap /// Using sorted string as key /// /// Time Complexity: O(n*klogk) where k is the max length of string in strs /// Space Complexity: O(n*k) class Solution { public: vector<vector<string>> groupAnagrams(vector<string>& strs) { unordered_map<string, vector<string>> map; for(const string& s: strs){ string key = s; sort(key.begin(), key.end()); map[key].push_back(s); } vector<vector<string>> res; for(const auto& p: map) res.push_back(p.second); return res; } }; int main() { return 0; }
21.153846
75
0.602424
7309ce25360b55138689d7ff062ad57fabf0a112
12,697
cc
C++
chrome/browser/supervised_user/supervised_user_allowlist_service.cc
mghgroup/Glide-Browser
6a4c1eaa6632ec55014fee87781c6bbbb92a2af5
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
null
null
null
chrome/browser/supervised_user/supervised_user_allowlist_service.cc
mghgroup/Glide-Browser
6a4c1eaa6632ec55014fee87781c6bbbb92a2af5
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
null
null
null
chrome/browser/supervised_user/supervised_user_allowlist_service.cc
mghgroup/Glide-Browser
6a4c1eaa6632ec55014fee87781c6bbbb92a2af5
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
2
2021-01-05T23:43:46.000Z
2021-01-07T23:36:34.000Z
// Copyright 2014 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "chrome/browser/supervised_user/supervised_user_allowlist_service.h" #include <stddef.h> #include <string> #include <utility> #include "base/bind.h" #include "base/command_line.h" #include "base/files/file_path.h" #include "base/metrics/histogram_macros.h" #include "base/metrics/user_metrics.h" #include "base/metrics/user_metrics_action.h" #include "base/strings/string_split.h" #include "base/values.h" #include "chrome/browser/component_updater/supervised_user_whitelist_installer.h" #include "chrome/browser/supervised_user/supervised_user_site_list.h" #include "chrome/common/chrome_switches.h" #include "chrome/common/pref_names.h" #include "components/pref_registry/pref_registry_syncable.h" #include "components/prefs/pref_service.h" #include "components/prefs/scoped_user_pref_update.h" #include "components/sync/model/sync_change.h" #include "components/sync/model/sync_change_processor.h" #include "components/sync/model/sync_data.h" #include "components/sync/model/sync_error.h" #include "components/sync/model/sync_error_factory.h" #include "components/sync/protocol/sync.pb.h" const char kName[] = "name"; SupervisedUserAllowlistService::SupervisedUserAllowlistService( PrefService* prefs, component_updater::SupervisedUserWhitelistInstaller* installer, const std::string& client_id) : prefs_(prefs), installer_(installer), client_id_(client_id) { DCHECK(prefs); } SupervisedUserAllowlistService::~SupervisedUserAllowlistService() {} // static void SupervisedUserAllowlistService::RegisterProfilePrefs( user_prefs::PrefRegistrySyncable* registry) { registry->RegisterDictionaryPref(prefs::kSupervisedUserAllowlists); } void SupervisedUserAllowlistService::Init() { const base::DictionaryValue* allowlists = prefs_->GetDictionary(prefs::kSupervisedUserAllowlists); for (base::DictionaryValue::Iterator it(*allowlists); !it.IsAtEnd(); it.Advance()) { registered_allowlists_.insert(it.key()); } UMA_HISTOGRAM_COUNTS_100("ManagedUsers.Whitelist.Count", allowlists->size()); // The installer can be null in some unit tests. if (!installer_) return; installer_->Subscribe( base::BindRepeating(&SupervisedUserAllowlistService::OnAllowlistReady, weak_ptr_factory_.GetWeakPtr())); // Register allowlists specified on the command line. for (const auto& allowlist : GetAllowlistsFromCommandLine()) RegisterAllowlist(allowlist.first, allowlist.second, FROM_COMMAND_LINE); } void SupervisedUserAllowlistService::AddSiteListsChangedCallback( const SiteListsChangedCallback& callback) { site_lists_changed_callbacks_.push_back(callback); std::vector<scoped_refptr<SupervisedUserSiteList>> allowlists; GetLoadedAllowlists(&allowlists); callback.Run(allowlists); } // static std::map<std::string, std::string> SupervisedUserAllowlistService::GetAllowlistsFromCommandLine() { std::map<std::string, std::string> allowlists; const base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); std::string command_line_allowlists = command_line->GetSwitchValueASCII( switches::kInstallSupervisedUserAllowlists); std::vector<base::StringPiece> string_pieces = base::SplitStringPiece(command_line_allowlists, ",", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); for (const base::StringPiece& allowlist : string_pieces) { std::string id; std::string name; size_t separator = allowlist.find(':'); if (separator != base::StringPiece::npos) { id = std::string(allowlist.substr(0, separator)); name = std::string(allowlist.substr(separator + 1)); } else { id = std::string(allowlist); } const bool result = allowlists.insert(std::make_pair(id, name)).second; DCHECK(result); } return allowlists; } void SupervisedUserAllowlistService::LoadAllowlistForTesting( const std::string& id, const base::string16& title, const base::FilePath& path) { bool result = registered_allowlists_.insert(id).second; DCHECK(result); OnAllowlistReady(id, title, base::FilePath(), path); } void SupervisedUserAllowlistService::UnloadAllowlist(const std::string& id) { bool result = registered_allowlists_.erase(id) > 0u; DCHECK(result); loaded_allowlists_.erase(id); NotifyAllowlistsChanged(); } // static syncer::SyncData SupervisedUserAllowlistService::CreateAllowlistSyncData( const std::string& id, const std::string& name) { sync_pb::EntitySpecifics specifics; sync_pb::ManagedUserWhitelistSpecifics* allowlist = specifics.mutable_managed_user_whitelist(); allowlist->set_id(id); allowlist->set_name(name); return syncer::SyncData::CreateLocalData(id, name, specifics); } void SupervisedUserAllowlistService::WaitUntilReadyToSync( base::OnceClosure done) { // This service handles sync events at any time. std::move(done).Run(); } base::Optional<syncer::ModelError> SupervisedUserAllowlistService::MergeDataAndStartSyncing( syncer::ModelType type, const syncer::SyncDataList& initial_sync_data, std::unique_ptr<syncer::SyncChangeProcessor> sync_processor, std::unique_ptr<syncer::SyncErrorFactory> error_handler) { DCHECK_EQ(syncer::SUPERVISED_USER_ALLOWLISTS, type); syncer::SyncChangeList change_list; DictionaryPrefUpdate update(prefs_, prefs::kSupervisedUserAllowlists); base::DictionaryValue* pref_dict = update.Get(); std::set<std::string> seen_ids; for (const syncer::SyncData& sync_data : initial_sync_data) { DCHECK_EQ(syncer::SUPERVISED_USER_ALLOWLISTS, sync_data.GetDataType()); const sync_pb::ManagedUserWhitelistSpecifics& allowlist = sync_data.GetSpecifics().managed_user_whitelist(); std::string id = allowlist.id(); std::string name = allowlist.name(); seen_ids.insert(id); base::DictionaryValue* dict = nullptr; if (pref_dict->GetDictionary(id, &dict)) { std::string old_name; bool result = dict->GetString(kName, &old_name); DCHECK(result); if (name != old_name) { SetAllowlistProperties(dict, allowlist); } } else { AddNewAllowlist(pref_dict, allowlist); } } std::set<std::string> ids_to_remove; for (base::DictionaryValue::Iterator it(*pref_dict); !it.IsAtEnd(); it.Advance()) { if (seen_ids.find(it.key()) == seen_ids.end()) ids_to_remove.insert(it.key()); } for (const std::string& id : ids_to_remove) RemoveAllowlist(pref_dict, id); // Notify if allowlists have been uninstalled. We will notify about newly // added allowlists later, when they are actually available // (in OnAllowlistLoaded). if (!ids_to_remove.empty()) NotifyAllowlistsChanged(); // The function does not generate any errors, so it can always return // base::nullopt. return base::nullopt; } void SupervisedUserAllowlistService::StopSyncing(syncer::ModelType type) { DCHECK_EQ(syncer::SUPERVISED_USER_ALLOWLISTS, type); } syncer::SyncDataList SupervisedUserAllowlistService::GetAllSyncDataForTesting( syncer::ModelType type) const { syncer::SyncDataList sync_data; const base::DictionaryValue* allowlists = prefs_->GetDictionary(prefs::kSupervisedUserAllowlists); for (base::DictionaryValue::Iterator it(*allowlists); !it.IsAtEnd(); it.Advance()) { const std::string& id = it.key(); const base::DictionaryValue* dict = nullptr; it.value().GetAsDictionary(&dict); std::string name; bool result = dict->GetString(kName, &name); DCHECK(result); sync_pb::EntitySpecifics specifics; sync_pb::ManagedUserWhitelistSpecifics* allowlist = specifics.mutable_managed_user_whitelist(); allowlist->set_id(id); allowlist->set_name(name); sync_data.push_back(syncer::SyncData::CreateLocalData(id, name, specifics)); } return sync_data; } base::Optional<syncer::ModelError> SupervisedUserAllowlistService::ProcessSyncChanges( const base::Location& from_here, const syncer::SyncChangeList& change_list) { bool allowlists_removed = false; DictionaryPrefUpdate update(prefs_, prefs::kSupervisedUserAllowlists); base::DictionaryValue* pref_dict = update.Get(); for (const syncer::SyncChange& sync_change : change_list) { syncer::SyncData data = sync_change.sync_data(); DCHECK_EQ(syncer::SUPERVISED_USER_ALLOWLISTS, data.GetDataType()); const sync_pb::ManagedUserWhitelistSpecifics& allowlist = data.GetSpecifics().managed_user_whitelist(); std::string id = allowlist.id(); switch (sync_change.change_type()) { case syncer::SyncChange::ACTION_ADD: { DCHECK(!pref_dict->HasKey(id)) << id; AddNewAllowlist(pref_dict, allowlist); break; } case syncer::SyncChange::ACTION_UPDATE: { base::DictionaryValue* dict = nullptr; pref_dict->GetDictionaryWithoutPathExpansion(id, &dict); SetAllowlistProperties(dict, allowlist); break; } case syncer::SyncChange::ACTION_DELETE: { DCHECK(pref_dict->HasKey(id)) << id; RemoveAllowlist(pref_dict, id); allowlists_removed = true; break; } case syncer::SyncChange::ACTION_INVALID: { NOTREACHED(); break; } } } if (allowlists_removed) NotifyAllowlistsChanged(); return base::nullopt; } void SupervisedUserAllowlistService::AddNewAllowlist( base::DictionaryValue* pref_dict, const sync_pb::ManagedUserWhitelistSpecifics& allowlist) { base::RecordAction(base::UserMetricsAction("ManagedUsers_Whitelist_Added")); RegisterAllowlist(allowlist.id(), allowlist.name(), FROM_SYNC); std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue); SetAllowlistProperties(dict.get(), allowlist); pref_dict->SetWithoutPathExpansion(allowlist.id(), std::move(dict)); } void SupervisedUserAllowlistService::SetAllowlistProperties( base::DictionaryValue* dict, const sync_pb::ManagedUserWhitelistSpecifics& allowlist) { dict->SetString(kName, allowlist.name()); } void SupervisedUserAllowlistService::RemoveAllowlist( base::DictionaryValue* pref_dict, const std::string& id) { base::RecordAction(base::UserMetricsAction("ManagedUsers_Whitelist_Removed")); pref_dict->RemoveKey(id); installer_->UnregisterWhitelist(client_id_, id); UnloadAllowlist(id); } void SupervisedUserAllowlistService::RegisterAllowlist(const std::string& id, const std::string& name, AllowlistSource source) { bool result = registered_allowlists_.insert(id).second; DCHECK(result); // Using an empty client ID for allowlists installed from the command line // causes the installer to not persist the installation, so the allowlist will // be removed the next time the browser is started without the command line // flag. installer_->RegisterWhitelist( source == FROM_COMMAND_LINE ? std::string() : client_id_, id, name); } void SupervisedUserAllowlistService::GetLoadedAllowlists( std::vector<scoped_refptr<SupervisedUserSiteList>>* allowlists) { for (const auto& allowlist : loaded_allowlists_) allowlists->push_back(allowlist.second); } void SupervisedUserAllowlistService::NotifyAllowlistsChanged() { std::vector<scoped_refptr<SupervisedUserSiteList>> allowlists; GetLoadedAllowlists(&allowlists); for (const auto& callback : site_lists_changed_callbacks_) callback.Run(allowlists); } void SupervisedUserAllowlistService::OnAllowlistReady( const std::string& id, const base::string16& title, const base::FilePath& large_icon_path, const base::FilePath& allowlist_path) { // If we did not register the allowlist or it has been unregistered in the // mean time, ignore it. if (registered_allowlists_.count(id) == 0u) return; SupervisedUserSiteList::Load( id, title, large_icon_path, allowlist_path, base::Bind(&SupervisedUserAllowlistService::OnAllowlistLoaded, weak_ptr_factory_.GetWeakPtr(), id)); } void SupervisedUserAllowlistService::OnAllowlistLoaded( const std::string& id, const scoped_refptr<SupervisedUserSiteList>& allowlist) { if (!allowlist) { LOG(WARNING) << "Couldn't load allowlist " << id; return; } // If the allowlist has been unregistered in the mean time, ignore it. if (registered_allowlists_.count(id) == 0u) return; loaded_allowlists_[id] = allowlist; NotifyAllowlistsChanged(); }
35.46648
81
0.731905
730b8769492185a73f22cde33327c597fc04b050
9,850
cc
C++
mysql-server/router/src/harness/src/dynamic_state.cc
silenc3502/MYSQL-Arch-Doc-Summary
fcc6bb65f72a385b9f56debc9b2c00cee5914bae
[ "MIT" ]
null
null
null
mysql-server/router/src/harness/src/dynamic_state.cc
silenc3502/MYSQL-Arch-Doc-Summary
fcc6bb65f72a385b9f56debc9b2c00cee5914bae
[ "MIT" ]
null
null
null
mysql-server/router/src/harness/src/dynamic_state.cc
silenc3502/MYSQL-Arch-Doc-Summary
fcc6bb65f72a385b9f56debc9b2c00cee5914bae
[ "MIT" ]
null
null
null
/* Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the Free Software Foundation. This program is also distributed with certain software (including but not limited to OpenSSL) that is licensed under separate terms, as designated in a particular file or component or in included license documentation. The authors of MySQL hereby grant you an additional permission to link the program and your derivative works with the separately licensed software that they have included with MySQL. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "mysql/harness/dynamic_state.h" #include "common.h" #include <fstream> #include <stdexcept> #include <rapidjson/error/en.h> #include <rapidjson/filereadstream.h> #include <rapidjson/istreamwrapper.h> #include <rapidjson/prettywriter.h> #include <rapidjson/schema.h> #include <rapidjson/stringbuffer.h> #include "dynamic_state_schema.h" namespace { using JsonValue = rapidjson::GenericValue<rapidjson::UTF8<>, rapidjson::CrtAllocator>; using JsonDocument = rapidjson::GenericDocument<rapidjson::UTF8<>, rapidjson::CrtAllocator>; using JsonStringBuffer = rapidjson::GenericStringBuffer<rapidjson::UTF8<>, rapidjson::CrtAllocator>; using JsonSchemaDocument = rapidjson::GenericSchemaDocument<JsonValue, rapidjson::CrtAllocator>; using JsonSchemaValidator = rapidjson::GenericSchemaValidator<JsonSchemaDocument>; constexpr const char *kVersionFieldName = "version"; constexpr unsigned kVersionMajor = 1; constexpr unsigned kVersionMinor = 0; constexpr unsigned kVersionPatch = 0; std::string to_string(unsigned major, unsigned minor, unsigned patch) { return std::to_string(major) + "." + std::to_string(minor) + "." + std::to_string(patch); } } // namespace namespace mysql_harness { struct DynamicState::Pimpl { JsonDocument json_state_doc_; std::mutex json_state_doc_lock_; std::mutex json_file_lock_; /*static*/ void validate_json_against_schema(const JsonSchemaDocument &schema, const JsonDocument &json) { // verify JSON against the schema JsonSchemaValidator validator(schema); if (!json.Accept(validator)) { // validation failed - throw an error with info of where the problem is rapidjson::StringBuffer sb_schema; validator.GetInvalidSchemaPointer().StringifyUriFragment(sb_schema); rapidjson::StringBuffer sb_json; validator.GetInvalidDocumentPointer().StringifyUriFragment(sb_json); throw std::runtime_error( std::string("Failed schema directive: ") + sb_schema.GetString() + "\nFailed schema keyword: " + validator.GetInvalidSchemaKeyword() + "\nFailure location in validated document: " + sb_json.GetString() + "\n"); } } }; DynamicState::DynamicState(const std::string &file_name) : file_name_(file_name) { pimpl_.reset(new Pimpl()); pimpl_->json_state_doc_.SetObject(); } DynamicState::~DynamicState() {} std::ifstream DynamicState::open_for_read() { std::ifstream input_file(file_name_); if (input_file.fail()) { throw std::runtime_error( "Could not open dynamic state file '" + file_name_ + "' for reading: " + mysql_harness::get_strerror(errno)); } return input_file; } std::ofstream DynamicState::open_for_write() { std::ofstream output_file(file_name_); if (output_file.fail()) { throw std::runtime_error( "Could not open dynamic state file '" + file_name_ + "' for writing: " + mysql_harness::get_strerror(errno)); } return output_file; } bool DynamicState::load() { std::unique_lock<std::mutex> lock(pimpl_->json_file_lock_); bool result{false}; auto input_file = open_for_read(); try { result = load_from_stream(input_file); } catch (const std::runtime_error &e) { throw std::runtime_error("Error parsing file dynamic state file '" + file_name_ + "': " + e.what()); } return result; } void DynamicState::ensure_valid_against_schema() { // construct schema JSON; throws std::runtime_error on invalid JSON, but note JsonDocument schema_json; if (schema_json .Parse<rapidjson::kParseCommentsFlag>(StateFileJsonSchema::data(), StateFileJsonSchema::size()) .HasParseError()) throw std::runtime_error( "Parsing JSON schema failed at offset " + std::to_string(schema_json.GetErrorOffset()) + ": " + rapidjson::GetParseError_En(schema_json.GetParseError())); JsonSchemaDocument schema(schema_json); // validate JSON against schema; throws std::runtime_error if validation fails try { pimpl_->validate_json_against_schema(schema, pimpl_->json_state_doc_); } catch (const std::runtime_error &e) { throw std::runtime_error( std::string("JSON file failed validation against JSON schema: ") + e.what()); } } void DynamicState::ensure_version_compatibility() { // we do it before validating against the schema so we need to // do some initial parsing manually here auto &json_doc = pimpl_->json_state_doc_; // the whole document has to be an object: if (!json_doc.IsObject()) { throw std::runtime_error( std::string("Invalid json structure: not an object")); } // it has to have version field if (!json_doc.GetObject().HasMember(kVersionFieldName)) { throw std::runtime_error( std::string("Invalid json structure: missing field: ") + kVersionFieldName); } // this field should be string auto &version_field = json_doc.GetObject()[kVersionFieldName]; if (!version_field.IsString()) { throw std::runtime_error(std::string("Invalid json structure: field ") + kVersionFieldName + " should be a string type"); } // the format od the string should be MAJOR.MINOR.PATCH std::string version = version_field.GetString(); unsigned major{0}, minor{0}, patch{0}; int res = sscanf(version.c_str(), "%u.%u.%u", &major, &minor, &patch); if (res != 3) { throw std::runtime_error( std::string("Invalid version field format, expected MAJOR.MINOR.PATCH, " "found: ") + version); } // the major and minor should match match exactly, different patch is fine if (major != kVersionMajor || minor != kVersionMinor) { throw std::runtime_error( std::string("Unsupported state file version, expected: ") + to_string(kVersionMajor, kVersionMinor, kVersionPatch) + ", found: " + to_string(major, minor, patch)); } // all good, version matches, go back to the caller with no exception } bool DynamicState::load_from_stream(std::istream &input_stream) { rapidjson::IStreamWrapper istream(input_stream); auto &json_doc = pimpl_->json_state_doc_; std::unique_lock<std::mutex> lock(pimpl_->json_state_doc_lock_); if (json_doc.ParseStream<rapidjson::kParseCommentsFlag>(istream) .HasParseError()) { throw std::runtime_error( "Parsing JSON failed at offset " + std::to_string(json_doc.GetErrorOffset()) + ": " + rapidjson::GetParseError_En(json_doc.GetParseError())); } ensure_version_compatibility(); ensure_valid_against_schema(); return true; } bool DynamicState::save(bool pretty) { std::unique_lock<std::mutex> lock(pimpl_->json_file_lock_); auto output_file = open_for_write(); return save_to_stream(output_file, pretty); } bool DynamicState::save_to_stream(std::ostream &output_stream, bool pretty) { JsonStringBuffer out_buffer; // save/update the version std::string ver_str = to_string(kVersionMajor, kVersionMinor, kVersionPatch); JsonValue version(rapidjson::kStringType); version.SetString(ver_str.c_str(), ver_str.length()); update_section(kVersionFieldName, std::move(version)); std::unique_lock<std::mutex> lock(pimpl_->json_state_doc_lock_); if (pretty) { rapidjson::PrettyWriter<JsonStringBuffer> out_writer{out_buffer}; pimpl_->json_state_doc_.Accept(out_writer); } else { rapidjson::Writer<JsonStringBuffer> out_writer{out_buffer}; pimpl_->json_state_doc_.Accept(out_writer); } output_stream << out_buffer.GetString(); return true; } std::unique_ptr<JsonValue> DynamicState::get_section( const std::string &section_name) { std::unique_lock<std::mutex> lock(pimpl_->json_state_doc_lock_); auto &json_doc = pimpl_->json_state_doc_; if (!json_doc.HasMember(section_name.c_str())) return nullptr; auto &allocator = json_doc.GetAllocator(); auto &section = json_doc[section_name.c_str()]; return std::unique_ptr<JsonValue>(new JsonValue(section, allocator)); } bool DynamicState::update_section(const std::string &section_name, JsonValue &&value) { std::unique_lock<std::mutex> lock(pimpl_->json_state_doc_lock_); auto &json_doc = pimpl_->json_state_doc_; auto &allocator = json_doc.GetAllocator(); if (!json_doc.HasMember(section_name.c_str())) { json_doc.AddMember(JsonValue(section_name.c_str(), allocator), value, allocator); } else { auto &section = json_doc[section_name.c_str()]; section = std::move(value); } return true; } } // namespace mysql_harness
34.083045
80
0.705584
730d1de7aafbb60918da55773730ef103c3a237f
6,509
cc
C++
chrome/browser/extensions/api/system_private/system_private_api.cc
metux/chromium-deb
3c08e9b89a1b6f95f103a61ff4f528dbcd57fc42
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
null
null
null
chrome/browser/extensions/api/system_private/system_private_api.cc
metux/chromium-deb
3c08e9b89a1b6f95f103a61ff4f528dbcd57fc42
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
null
null
null
chrome/browser/extensions/api/system_private/system_private_api.cc
metux/chromium-deb
3c08e9b89a1b6f95f103a61ff4f528dbcd57fc42
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
null
null
null
// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "chrome/browser/extensions/api/system_private/system_private_api.h" #include <memory> #include <utility> #include "base/macros.h" #include "base/memory/ptr_util.h" #include "base/values.h" #include "build/build_config.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/extensions/event_router_forwarder.h" #include "chrome/browser/profiles/profile.h" #include "chrome/common/extensions/api/system_private.h" #include "chrome/common/pref_names.h" #include "components/prefs/pref_service.h" #include "google_apis/google_api_keys.h" #if defined(OS_CHROMEOS) #include "chromeos/dbus/dbus_thread_manager.h" #include "chromeos/dbus/update_engine_client.h" #else #include "chrome/browser/upgrade_detector.h" #endif namespace { // Maps prefs::kIncognitoModeAvailability values (0 = enabled, ...) // to strings exposed to extensions. const char* const kIncognitoModeAvailabilityStrings[] = { "enabled", "disabled", "forced" }; // Property keys. const char kBrightnessKey[] = "brightness"; const char kDownloadProgressKey[] = "downloadProgress"; const char kIsVolumeMutedKey[] = "isVolumeMuted"; const char kStateKey[] = "state"; const char kUserInitiatedKey[] = "userInitiated"; const char kVolumeKey[] = "volume"; // System update states. const char kNotAvailableState[] = "NotAvailable"; const char kNeedRestartState[] = "NeedRestart"; #if defined(OS_CHROMEOS) const char kUpdatingState[] = "Updating"; #endif // defined(OS_CHROMEOS) // Dispatches an extension event with |argument| void DispatchEvent(extensions::events::HistogramValue histogram_value, const std::string& event_name, std::unique_ptr<base::Value> argument) { std::unique_ptr<base::ListValue> list_args(new base::ListValue()); if (argument) { list_args->Append(std::move(argument)); } g_browser_process->extension_event_router_forwarder() ->BroadcastEventToRenderers(histogram_value, event_name, std::move(list_args), GURL()); } } // namespace namespace extensions { namespace system_private = api::system_private; ExtensionFunction::ResponseAction SystemPrivateGetIncognitoModeAvailabilityFunction::Run() { PrefService* prefs = Profile::FromBrowserContext(browser_context())->GetPrefs(); int value = prefs->GetInteger(prefs::kIncognitoModeAvailability); EXTENSION_FUNCTION_VALIDATE( value >= 0 && value < static_cast<int>(arraysize(kIncognitoModeAvailabilityStrings))); return RespondNow(OneArgument( base::MakeUnique<base::Value>(kIncognitoModeAvailabilityStrings[value]))); } ExtensionFunction::ResponseAction SystemPrivateGetUpdateStatusFunction::Run() { std::string state; double download_progress = 0; #if defined(OS_CHROMEOS) // With UpdateEngineClient, we can provide more detailed information about // system updates on ChromeOS. const chromeos::UpdateEngineClient::Status status = chromeos::DBusThreadManager::Get()->GetUpdateEngineClient()-> GetLastStatus(); // |download_progress| is set to 1 after download finishes // (i.e. verify, finalize and need-reboot phase) to indicate the progress // even though |status.download_progress| is 0 in these phases. switch (status.status) { case chromeos::UpdateEngineClient::UPDATE_STATUS_ERROR: state = kNotAvailableState; break; case chromeos::UpdateEngineClient::UPDATE_STATUS_IDLE: state = kNotAvailableState; break; case chromeos::UpdateEngineClient::UPDATE_STATUS_CHECKING_FOR_UPDATE: state = kNotAvailableState; break; case chromeos::UpdateEngineClient::UPDATE_STATUS_UPDATE_AVAILABLE: state = kUpdatingState; break; case chromeos::UpdateEngineClient::UPDATE_STATUS_DOWNLOADING: state = kUpdatingState; download_progress = status.download_progress; break; case chromeos::UpdateEngineClient::UPDATE_STATUS_VERIFYING: state = kUpdatingState; download_progress = 1; break; case chromeos::UpdateEngineClient::UPDATE_STATUS_FINALIZING: state = kUpdatingState; download_progress = 1; break; case chromeos::UpdateEngineClient::UPDATE_STATUS_UPDATED_NEED_REBOOT: state = kNeedRestartState; download_progress = 1; break; case chromeos::UpdateEngineClient::UPDATE_STATUS_REPORTING_ERROR_EVENT: case chromeos::UpdateEngineClient::UPDATE_STATUS_ATTEMPTING_ROLLBACK: case chromeos::UpdateEngineClient::UPDATE_STATUS_NEED_PERMISSION_TO_UPDATE: state = kNotAvailableState; break; } #else if (UpgradeDetector::GetInstance()->notify_upgrade()) { state = kNeedRestartState; download_progress = 1; } else { state = kNotAvailableState; } #endif std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); dict->SetString(kStateKey, state); dict->SetDouble(kDownloadProgressKey, download_progress); return RespondNow(OneArgument(std::move(dict))); } ExtensionFunction::ResponseAction SystemPrivateGetApiKeyFunction::Run() { return RespondNow( OneArgument(base::MakeUnique<base::Value>(google_apis::GetAPIKey()))); } void DispatchVolumeChangedEvent(double volume, bool is_volume_muted) { std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); dict->SetDouble(kVolumeKey, volume); dict->SetBoolean(kIsVolumeMutedKey, is_volume_muted); DispatchEvent(extensions::events::SYSTEM_PRIVATE_ON_VOLUME_CHANGED, system_private::OnVolumeChanged::kEventName, std::move(dict)); } void DispatchBrightnessChangedEvent(int brightness, bool user_initiated) { std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); dict->SetInteger(kBrightnessKey, brightness); dict->SetBoolean(kUserInitiatedKey, user_initiated); DispatchEvent(extensions::events::SYSTEM_PRIVATE_ON_BRIGHTNESS_CHANGED, system_private::OnBrightnessChanged::kEventName, std::move(dict)); } void DispatchScreenUnlockedEvent() { DispatchEvent(extensions::events::SYSTEM_PRIVATE_ON_SCREEN_UNLOCKED, system_private::OnScreenUnlocked::kEventName, nullptr); } void DispatchWokeUpEvent() { DispatchEvent(extensions::events::SYSTEM_PRIVATE_ON_WOKE_UP, system_private::OnWokeUp::kEventName, nullptr); } } // namespace extensions
35.961326
80
0.746966
730d607de955483bb14616630794aef81674435d
2,583
cpp
C++
client/winapplication.cpp
flaming0/software-renderer
dfeb24eb4ac6f90552e65cc7e0cf97d7d693ad7b
[ "MIT" ]
14
2015-03-22T16:18:32.000Z
2017-08-08T14:07:44.000Z
client/winapplication.cpp
nslobodin/software-renderer
dfeb24eb4ac6f90552e65cc7e0cf97d7d693ad7b
[ "MIT" ]
null
null
null
client/winapplication.cpp
nslobodin/software-renderer
dfeb24eb4ac6f90552e65cc7e0cf97d7d693ad7b
[ "MIT" ]
2
2015-08-31T03:01:57.000Z
2016-12-20T06:09:32.000Z
/* * winapplication.cpp * * Author: flamingo * E-mail: epiforce57@gmail.com */ #include "winapplication.h" void WinApplication::update(float dt) { } WinApplication::WinApplication(int argc, const char *argv[]) : platform::BaseAppWin(argc, argv) { m_playerCamera = m_clientController->getCamera(); auto rmgr = m_clientController->getResmgr(); auto rendmgr = m_clientController->getRendmgr(); // create terrain auto heightMapTexture = rmgr->getObject<rend::Texture>("texture_water_track_height_03"); auto texture = rmgr->getObject<rend::Texture>("texture_water_track_color_03"); auto terrain = std::make_shared<rend::TerrainSceneObject>(3000.f, 3000.f, 600.f, heightMapTexture, texture); rendmgr->addSceneObject(terrain); // rendmgr->addGuiObject(std::make_shared<rend::GuiObject>(texture)); auto teapot = rmgr->getObject<rend::SceneObject>("teapot.obj"); if (teapot) { //teapot->setScale(math::vec3(50, 50, 50)); teapot->getMesh()->setShadingMode(rend::Material::SM_GOURAUD); } } WinApplication::~WinApplication() { } void WinApplication::onFrameStart() { } void WinApplication::onFrameEnd() { } void WinApplication::onMouseEvent(const platform::MouseEvent &ev) { static int yaw, pitch; static int prevx, prevy; if (ev.isLeftPressed()) { yaw -= prevx - ev.x; // inverted pitch -= prevy - ev.y; if (abs(yaw) > 360) yaw %= 360; if (abs(pitch) > 360) pitch %= 360; m_playerCamera->setEulerAnglesRotation(yaw, pitch, 0.f); } prevx = ev.x; prevy = ev.y; } void WinApplication::onKeyPressed(const platform::KeyboardEvent &ev) { static const float velocity = 100.f; static math::vec3 ds; static math::vec3 position; ds.zero(); position = m_playerCamera->getPosition(); if (ev.keycode() == platform::KEY_KEY_W) { ds = m_playerCamera->getDirection() * velocity; position += ds; } else if (ev.keycode() == platform::KEY_KEY_S) { ds = m_playerCamera->getDirection() * velocity; position -= ds; } else if (ev.keycode() == platform::KEY_KEY_D) { ds = m_playerCamera->getRightVector() * velocity; position += ds; } else if (ev.keycode() == platform::KEY_KEY_A) { ds = m_playerCamera->getRightVector() * velocity; position -= ds; } else return; m_playerCamera->setPosition(position); } void WinApplication::onKeyReleased(const platform::KeyboardEvent &/*ev*/) { }
23.481818
112
0.636856
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
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
731064edb012109930ec2ce75282ad6c5463f5fb
7,515
cc
C++
src/pass/narrow_channel_access.cc
baowenlei/tvm
6b2e18ed96fad26b4a5e5f8a6dcbedf9206c9a65
[ "Apache-2.0" ]
16
2019-11-20T03:43:19.000Z
2021-11-25T02:32:17.000Z
src/pass/narrow_channel_access.cc
baowenlei/tvm
6b2e18ed96fad26b4a5e5f8a6dcbedf9206c9a65
[ "Apache-2.0" ]
4
2019-06-27T08:05:18.000Z
2021-09-09T18:59:11.000Z
src/pass/narrow_channel_access.cc
baowenlei/tvm
6b2e18ed96fad26b4a5e5f8a6dcbedf9206c9a65
[ "Apache-2.0" ]
5
2020-03-18T10:14:30.000Z
2021-04-01T12:09:20.000Z
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ /*! * Copyright (c) 2017 by Contributors * \file narrow_channel_access.cc * \brief Narrow channel access to a smaller range * when possible by bringing it to the internal loop. */ #include <tvm/ir.h> #include <tvm/expr.h> #include <tvm/ir_pass.h> #include <tvm/ir_visitor.h> #include <tvm/ir_mutator.h> #include <tvm/arithmetic.h> #include <tvm/channel.h> #include "ir_util.h" namespace tvm { namespace ir { using namespace arith; // Bound deducer for channel access. class ChannelAccessBound : public IRVisitor { public: ChannelAccessBound(const Variable* buf_var, bool read_access) : buf_var_(buf_var), read_access_(read_access) {} void Visit_(const Store* op) final { if (!read_access_ && buf_var_ == op->buffer_var.get()) { ret_.emplace_back(EvalSet(op->index, dom_map_)); } IRVisitor::Visit_(op); } void Visit_(const For* op) final { CHECK(is_zero(op->min)); // We know that the extent of the loop won't depend on relaxed scope. // TODO(tqchen) have a verification pass. dom_map_[op->loop_var.get()] = IntSet::interval(op->min, op->extent - 1); IRVisitor::Visit_(op); } void Visit_(const Load* op) final { if (read_access_ && buf_var_ == op->buffer_var.get()) { ret_.emplace_back(EvalSet(op->index, dom_map_)); } IRVisitor::Visit_(op); } void Visit_(const Let* op) final { LOG(FATAL) << "cannot pass through let"; } void Visit_(const LetStmt* op) final { LOG(FATAL) << "cannot pass through let"; } IntSet Eval(const Stmt& stmt) { Visit(stmt); return Union(ret_); } private: // The buffer variable. const Variable* buf_var_; // read or write bool read_access_{true}; // Box std::vector<IntSet> ret_; // Domain map. std::unordered_map<const Variable*, IntSet> dom_map_; }; class ChannelAccessIndexRewriter : public IRMutator { public: ChannelAccessIndexRewriter(const Variable* buf_var, Expr min, bool read_access) : buf_var_(buf_var), min_(min), read_access_(read_access) {} Expr Mutate_(const Load* op, const Expr& e) final { Expr expr = IRMutator::Mutate_(op, e); op = expr.as<Load>(); if (read_access_ && buf_var_ == op->buffer_var.get()) { return Load::make( op->type, op->buffer_var, ir::Simplify(op->index - min_), op->predicate); } else { return expr; } } Stmt Mutate_(const Store* op, const Stmt& s) final { Stmt stmt = IRMutator::Mutate_(op, s); op = stmt.as<Store>(); if (!read_access_ && buf_var_ == op->buffer_var.get()) { return Store::make( op->buffer_var, op->value, ir::Simplify(op->index - min_), op->predicate); } else { return stmt; } } private: // The buffer variable. const Variable* buf_var_; // The min bound. Expr min_; // read or write bool read_access_{true}; }; // Rewrite channel access pattern. class ChannelAccessRewriter : public IRMutator { public: Stmt Mutate_(const AttrStmt* op, const Stmt& s) final { Stmt ret; const AttrStmt* adv = op->body.as<AttrStmt>(); if ((op->attr_key == ir::attr::channel_read_scope && adv && adv->attr_key == ir::attr::channel_read_advance) || (op->attr_key == ir::attr::channel_write_scope && adv && adv->attr_key == ir::attr::channel_write_advance)) { RewriteEntry e; e.window = op; e.advance = adv; e.read_access = op->attr_key == ir::attr::channel_read_scope; tasks_.push_back(e); ret = IRMutator::Mutate_(op, s); if (tasks_.back().rewrite_success) { ret = ret.as<AttrStmt>()->body.as<AttrStmt>()->body; } tasks_.pop_back(); return ret; } else { return IRMutator::Mutate_(op, s); } } Stmt Mutate_(const For* op, const Stmt& s) final { std::vector<RewriteEntry> tasks; std::swap(tasks_, tasks); Stmt body = op->body; std::vector<Stmt> nest; for (RewriteEntry& e : tasks) { body = RewriteAccess(op, body, &e, &nest); } if (!body.same_as(op->body)) { body = Mutate(body); body = For::make( op->loop_var, op->min, op->extent, op->for_type, op->device_api, body); body = MergeNest(nest, body); } else { CHECK_EQ(nest.size(), 0U); body = IRMutator::Mutate_(op, s); } std::swap(tasks_, tasks); return body; } private: struct RewriteEntry { bool read_access; const AttrStmt* window; const AttrStmt* advance; bool rewrite_success{false}; }; Stmt RewriteAccess(const For* for_op, Stmt body, RewriteEntry* e, std::vector<Stmt>* outer_nest) { const AttrStmt* adv_op = e->advance; const Expr& window = e->window->value; bool read_access = e->read_access; Var var(for_op->loop_var); Channel ch(adv_op->node.node_); ChannelAccessBound acc(ch->handle_var.get(), read_access); IntSet iset = acc.Eval(for_op->body); Range r = iset.cover_range(Range::make_by_min_extent(0, window)); r = Range::make_by_min_extent( ir::Simplify(r->min), ir::Simplify(r->extent)); if (ExprUseVar(r->extent, var)) return body; Array<Expr> linear_eq = DetectLinearEquation(r->min, {var}); if (linear_eq.size() == 0) return body; Expr coeff = linear_eq[0]; Expr base = linear_eq[1]; if (!is_zero(base)) return body; Expr left = ir::Simplify(adv_op->value - coeff * for_op->extent); if (!can_prove(left >= 0)) return body; // rewrite access index. ChannelAccessIndexRewriter rw( ch->handle_var.get(), var * coeff, read_access); body = rw.Mutate(body); if (read_access) { body = AttrStmt::make( ch, ir::attr::channel_read_scope, r->extent, AttrStmt::make(ch, ir::attr::channel_read_advance, coeff, body)); } else { body = AttrStmt::make( ch, ir::attr::channel_write_scope, r->extent, AttrStmt::make(ch, ir::attr::channel_write_advance, coeff, body)); } if (!is_zero(left)) { Stmt no_op = Evaluate::make(0); if (read_access) { outer_nest->emplace_back( AttrStmt::make(ch, ir::attr::channel_read_advance, left, no_op)); } else { outer_nest->emplace_back( AttrStmt::make(ch, ir::attr::channel_write_advance, left, no_op)); } } e->rewrite_success = true; return body; } std::vector<RewriteEntry> tasks_; }; Stmt NarrowChannelAccess(Stmt stmt) { return ChannelAccessRewriter().Mutate(stmt); } } // namespace ir } // namespace tvm
30.673469
78
0.628743
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
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
73138a31f2c23d1c86b51a13b80a5b64c60e5ce8
16,016
cpp
C++
smallpssmlt.cpp
shiinamiyuki/smallpssmlt
f201bdff2a3968450e8fb970cd61be46fc0aab3d
[ "MIT" ]
5
2019-06-27T05:55:52.000Z
2022-01-09T14:13:13.000Z
smallpssmlt.cpp
xt271828/smallpssmlt
f201bdff2a3968450e8fb970cd61be46fc0aab3d
[ "MIT" ]
null
null
null
smallpssmlt.cpp
xt271828/smallpssmlt
f201bdff2a3968450e8fb970cd61be46fc0aab3d
[ "MIT" ]
null
null
null
#include <random> #include <iostream> #include <stdlib.h> #include <math.h> #include <math.h> // smallpt, a Path Tracer by Kevin Beason, 2008 #include <stdlib.h> // Make : g++ -O3 -fopenmp smallpt.cpp -o smallpt #include <stdio.h> // Remove "-fopenmp" for g++ version < 4.2 #include <atomic> #include <mutex> #include <memory.h> float random(unsigned int *rng) { *rng = (1103515245 * (*rng) + 12345); return (float) *rng / (float) 0xFFFFFFFF; } struct Vec { // Usage: time ./smallpt 5000 && xv image.ppm double x, y, z; // position, also color (r,g,b) Vec(double x_ = 0, double y_ = 0, double z_ = 0) { x = x_; y = y_; z = z_; } Vec operator+(const Vec &b) const { return Vec(x + b.x, y + b.y, z + b.z); } Vec operator-(const Vec &b) const { return Vec(x - b.x, y - b.y, z - b.z); } Vec operator*(double b) const { return Vec(x * b, y * b, z * b); } Vec mult(const Vec &b) const { return Vec(x * b.x, y * b.y, z * b.z); } Vec &norm() { return *this = *this * (1 / sqrt(x * x + y * y + z * z)); } double dot(const Vec &b) const { return x * b.x + y * b.y + z * b.z; } // cross: Vec operator%(Vec &b) { return Vec(y * b.z - z * b.y, z * b.x - x * b.z, x * b.y - y * b.x); } }; struct Ray { Vec o, d; Ray(Vec o_, Vec d_) : o(o_), d(d_) {} }; enum Refl_t { DIFF, SPEC, REFR }; // material types, used in radiance() struct Sphere { double rad; // radius Vec p, e, c; // position, emission, color Refl_t refl; // reflection type (DIFFuse, SPECular, REFRactive) Sphere(double rad_, Vec p_, Vec e_, Vec c_, Refl_t refl_) : rad(rad_), p(p_), e(e_), c(c_), refl(refl_) {} double intersect(const Ray &r) const { // returns distance, 0 if nohit Vec op = p - r.o; // Solve t^2*d.d + 2*t*(o-p).d + (o-p).(o-p)-R^2 = 0 double t, eps = 1e-4, b = op.dot(r.d), det = b * b - op.dot(op) + rad * rad; if (det < 0) return 0; else det = sqrt(det); return (t = b - det) > eps ? t : ((t = b + det) > eps ? t : 0); } }; Sphere spheres[] = {//Scene: radius, position, emission, color, material Sphere(1e5, Vec(1e5 + 1, 40.8, 81.6), Vec(), Vec(.75, .25, .25), DIFF),//Left Sphere(1e5, Vec(-1e5 + 99, 40.8, 81.6), Vec(), Vec(.25, .25, .75), DIFF),//Rght Sphere(1e5, Vec(50, 40.8, 1e5), Vec(), Vec(.75, .75, .75), DIFF),//Back Sphere(1e5, Vec(50, 40.8, -1e5 + 170), Vec(), Vec(), DIFF),//Frnt Sphere(1e5, Vec(50, 1e5, 81.6), Vec(), Vec(.75, .75, .75), DIFF),//Botm Sphere(1e5, Vec(50, -1e5 + 81.6, 81.6), Vec(), Vec(.75, .75, .75), DIFF),//Top Sphere(16.5, Vec(27, 16.5, 47), Vec(), Vec(1, 1, 1) * .999, SPEC),//Mirr Sphere(14.5, Vec(60, 46.5, 78), Vec(), Vec(1, 1, 1) * .999, REFR),//Glas Sphere(600, Vec(50, 681.6 - .27, 81.6), Vec(12, 12, 12), Vec(), DIFF) //Lite }; inline double clamp(double x) { return x < 0 ? 0 : x > 1 ? 1 : x; } inline double removeNaN(double x) { return std::isnan(x) || x < 0.0 ? 0.0 : x; } inline int toInt(double x) { return int(pow(clamp(x), 1 / 2.2) * 255 + .5); } inline bool intersect(const Ray &r, double &t, int &id) { double n = sizeof(spheres) / sizeof(Sphere), d, inf = t = 1e20; for (int i = int(n); i--;) if ((d = spheres[i].intersect(r)) && d < t) { t = d; id = i; } return t < inf; } struct PrimarySample { double value; double _backup; uint64_t lastModificationIteration; uint64_t lastModifiedBackup; void backup() { _backup = value; lastModifiedBackup = lastModificationIteration; } void restore() { value = _backup; lastModificationIteration = lastModifiedBackup; } }; const double largeStepProb = 0.25; struct RadianceRecord { int x, y; Vec Li; RadianceRecord() { x = y = 0; }; }; struct Sampler { unsigned int seed; std::vector<PrimarySample> X; uint64_t currentIteration = 0; bool largeStep = true; uint64_t lastLargeStepIteration = 0; int w, h; RadianceRecord current; Sampler(int w, int h, unsigned int seed) : w(w), h(h), seed(seed) {} uint32_t sampleIndex = 0; uint64_t a = 0, r = 0; void startIteration() { sampleIndex = 0; currentIteration++; largeStep = uniform() < largeStepProb; } double uniform() { return random(&seed); } void mutate(PrimarySample &Xi, int sampleIndex) { double s1, s2; if (sampleIndex >= 2) { s1 = 1.0 / 1024.0, s2 = 1.0 / 64.0; } else if (sampleIndex == 1) { s1 = 1.0 / h, s2 = 0.1; } else { s1 = 1.0 / w, s2 = 0.1; } if (Xi.lastModificationIteration < lastLargeStepIteration) { Xi.value = uniform(); Xi.lastModificationIteration = lastLargeStepIteration; } if (largeStep) { Xi.backup(); Xi.value = uniform(); } else { int64_t nSmall = currentIteration - Xi.lastModificationIteration; auto nSmallMinus = nSmall - 1; if (nSmallMinus > 0) { auto x = Xi.value; while (nSmallMinus > 0) { nSmallMinus--; x = mutate(x, s1, s2); } Xi.value = x; Xi.lastModificationIteration = currentIteration - 1; } Xi.backup(); Xi.value = mutate(Xi.value, s1, s2); } Xi.lastModificationIteration = currentIteration; } double next() { if (sampleIndex >= X.size()) { X.resize(sampleIndex + 1u); } auto &Xi = X[sampleIndex]; mutate(Xi, sampleIndex); sampleIndex += 1; return Xi.value; } double mutate(double x, double s1, double s2) { double r = uniform(); if (r < 0.5) { r = r * 2.0; x = x + s2 * exp(-log(s2 / s1) * r); if (x > 1.0) x -= 1.0; } else { r = (r - 0.5) * 2.0; x = x - s2 * exp(-log(s2 / s1) * r); if (x < 0.0) x += 1.0; } return x; } void accept() { if (largeStep) { lastLargeStepIteration = currentIteration; } a++; } void reject() { for (PrimarySample &Xi :X) { if (Xi.lastModificationIteration == currentIteration) { Xi.restore(); } } r++; --currentIteration; } }; const float PI = 3.1415926535f; float phase(float cosTheta){ return 1.0f/(4.0f * PI); } const float volDensity = 0.005; Vec volColor(1,1,1); Vec sampleSphere(float u1, float u2){ float phi = 2 * u2 * PI; float theta = u1 * PI; float cosTheta = cos(theta); float sinTheta = sin(theta); return Vec(sin(phi)*cosTheta,sinTheta,cos(phi)*cosTheta); } Vec radiance(Ray r, Sampler &sampler) { double t; // distance to intersection int id = 0; // id of intersected object Vec cl(0, 0, 0); // accumulated color Vec cf(1, 1, 1); // accumulated reflectance int depth = 0; bool medium = true; while (true) { double u1 = sampler.next(), u2 = sampler.next(), u3 = sampler.next(); double u4 = sampler.next(), u5 = sampler.next(), u6 = sampler.next(); if (!intersect(r, t, id)) return cl; // if miss, return black if(medium){ Vec Tr(1,1,1); double dist = -std::log(1 - u6) / volDensity; bool sampled = dist < t; double pdf = volDensity; Tr = Tr.mult(volColor * exp(-volDensity * std::min(t, dist))); cf = cf.mult(Tr); if(sampled){ Vec x = r.o + r.d * dist; Vec d = sampleSphere(u4,u5); cf = cf * phase(r.d.dot(d)); cf = cf * (4 * PI); r = Ray(x, d);depth++; continue; } } const Sphere &obj = spheres[id]; // the hit object Vec x = r.o + r.d * t, n = (x - obj.p).norm(), nl = n.dot(r.d) < 0 ? n : n * -1, f = obj.c; double p = f.x > f.y && f.x > f.z ? f.x : f.y > f.z ? f.y : f.z; // max refl cl = cl + cf.mult(obj.e); if (++depth > 5) if (u3 < p) f = f * (1 / p); else { return cl; } //R.R. cf = cf.mult(f); if (obj.refl == DIFF) { // Ideal DIFFUSE reflection double r1 = 2 * M_PI * u1, r2 = u2, r2s = sqrt(r2); Vec w = nl, u = ((fabs(w.x) > .1 ? Vec(0, 1) : Vec(1)) % w).norm(), v = w % u; Vec d = (u * cos(r1) * r2s + v * sin(r1) * r2s + w * sqrt(1 - r2)).norm(); //return obj.e + f.mult(radiance(Ray(x,d),depth,Xi)); r = Ray(x, d); continue; } else if (obj.refl == SPEC) { // Ideal SPECULAR reflection //return obj.e + f.mult(radiance(Ray(x,r.d-n*2*n.dot(r.d)),depth,Xi)); r = Ray(x, r.d - n * 2 * n.dot(r.d)); continue; } Ray reflRay(x, r.d - n * 2 * n.dot(r.d)); // Ideal dielectric REFRACTION bool into = n.dot(nl) > 0; // Ray from outside going in? double nc = 1, nt = 1.5, nnt = into ? nc / nt : nt / nc, ddn = r.d.dot(nl), cos2t; medium = !into; if ((cos2t = 1 - nnt * nnt * (1 - ddn * ddn)) < 0) { // Total internal reflection //return obj.e + f.mult(radiance(reflRay,depth,Xi)); r = reflRay; continue; } Vec tdir = (r.d * nnt - n * ((into ? 1 : -1) * (ddn * nnt + sqrt(cos2t)))).norm(); double a = nt - nc, b = nt + nc, R0 = a * a / (b * b), c = 1 - (into ? -ddn : tdir.dot(n)); double Re = R0 + (1 - R0) * c * c * c * c * c, Tr = 1 - Re, P = .25 + .5 * Re, RP = Re / P, TP = Tr / (1 - P); // return obj.e + f.mult(sampler.next()<P ? // radiance(reflRay, depth,Xi)*RP: // radiance(Ray(x,tdir),depth,Xi)*TP); if (u1 < P) { cf = cf * RP; r = reflRay; } else { cf = cf * TP; r = Ray(x, tdir); } } } Vec radiance(int x, int y, int w, int h, Sampler &sampler) { Ray cam(Vec(50, 52, 295.6), Vec(0, -0.042612, -1).norm()); // cam pos, dir Vec cx = Vec(w * .5135 / h), cy = (cx % cam.d).norm() * .5135; double r1 = 2 * sampler.next(), dx = r1 < 1 ? sqrt(r1) - 1 : 1 - sqrt(2 - r1); double r2 = 2 * sampler.next(), dy = r2 < 1 ? sqrt(r2) - 1 : 1 - sqrt(2 - r2); Vec d = cx * (((1 + dx) / 2 + x) / w - .5) + cy * (((1 + dy) / 2 + y) / h - .5) + cam.d; return radiance(Ray(cam.o + d * 140, d.norm()), sampler); } RadianceRecord radiance(Sampler &sampler, bool bootstrap) { if (!bootstrap) sampler.startIteration(); double x = sampler.next(); double y = sampler.next(); RadianceRecord record; record.x = std::min<int>(sampler.w - 1, lround(x * sampler.w)); record.y = std::min<int>(sampler.h - 1, lround(y * sampler.h)); record.Li = radiance(record.x, record.y, sampler.w, sampler.h, sampler); return record; } double b; double ScalarContributionFunction(const Vec &Li) { return 0.2126 * Li.x + 0.7152 * Li.y + 0.0722 * Li.z; } void RunMarkovChain(Sampler &sampler, RadianceRecord &r1, RadianceRecord &r2) { auto r = radiance(sampler, false); double accept = std::max(0.0, std::min(1.0, ScalarContributionFunction(r.Li) / ScalarContributionFunction(sampler.current.Li))); double weight1 = (accept + (sampler.largeStep ? 1.0 : 0.0)) / (ScalarContributionFunction(r.Li) / b + largeStepProb); double weight2 = (1 - accept) / (ScalarContributionFunction(sampler.current.Li) / b + largeStepProb); r1.x = r.x; r1.y = r.y; r1.Li = r.Li * weight1; r2.x = sampler.current.x; r2.y = sampler.current.y; r2.Li = sampler.current.Li * weight2; if (accept == 1 || sampler.uniform() < accept) { sampler.accept(); sampler.current = r; } else { sampler.reject(); } } uint32_t nBootstrap = 100000; inline uint64_t floatToBits(double f) { uint64_t ui; memcpy(&ui, &f, sizeof(double)); return ui; } inline double bitsToFloat(uint64_t ui) { double f; memcpy(&f, &ui, sizeof(uint64_t)); return f; } class AtomicFloat { public: AtomicFloat(double v = 0) { bits = floatToBits(v); } AtomicFloat(const AtomicFloat &rhs) { bits.store(rhs.bits.load(std::memory_order_relaxed), std::memory_order_relaxed); } operator double() const { return bitsToFloat(bits); } double operator=(double v) { bits = floatToBits(v); return v; } AtomicFloat &operator=(const AtomicFloat &rhs) { bits.store(rhs.bits.load(std::memory_order_relaxed), std::memory_order_relaxed); return *this; } void add(double v) { uint64_t oldBits = bits, newBits; do { newBits = floatToBits(bitsToFloat(oldBits) + v); } while (!bits.compare_exchange_weak(oldBits, newBits)); } void store(double v) { bits.store(floatToBits(v), std::memory_order_relaxed); } private: std::atomic<uint64_t> bits; }; struct AtomicVec { AtomicFloat x, y, z; void splat(const Vec &c) { x.add(c.x); y.add(c.y); z.add(c.z); } }; int main(int argc, char *argv[]) { int w = 1024/2, h = 768/2, samps = argc == 2 ? atoi(argv[1]) : 4; // # samples uint32_t nChains = 2048; uint32_t nMutations = std::ceil(double(w) * h * samps / nChains); std::vector<uint32_t> seeds; for (int i = 0; i < nBootstrap; i++) { seeds.emplace_back(rand()); } std::vector<double> weights; for (int i = 0; i < nBootstrap; i++) { Sampler sampler(w, h, seeds[i]); weights.emplace_back(ScalarContributionFunction(radiance(sampler, true).Li)); } std::vector<double> cdf; cdf.emplace_back(0); for (auto &i: weights) { cdf.emplace_back(cdf.back() + i); } b = cdf.back() / nBootstrap; printf("nChains = %d, nMutations = %d\nb = %lf\n", nChains, nMutations, b); std::vector<AtomicVec> c(w * h); std::atomic<uint64_t> totalMutations(0); unsigned int mainSeed = rand(); auto write = [&](const RadianceRecord &record) { auto &r = record.Li; int i = (h - record.y - 1) * w + record.x; c[i].splat(Vec(removeNaN(r.x), removeNaN(r.y), removeNaN(r.z))); }; std::mutex mutex; int32_t count = 0; #pragma omp parallel for schedule(dynamic, 1) for (int i = 0; i < nChains; i++) { double r = random(&mainSeed) * cdf.back(); int k = 1; for (; k <= nBootstrap; k++) { if (cdf[k - 1] < r && r <= cdf[k]) { break; } } k -= 1; Sampler sampler(w, h, seeds[k]); sampler.current = radiance(sampler, true); // retrace path sampler.seed = rand(); // reseeding for (int m = 0; m < nMutations; m++) { RadianceRecord r1, r2; RunMarkovChain(sampler, r1, r2); write(r1); write(r2); totalMutations++; } { std::lock_guard<std::mutex> lockGuard(mutex); count++; printf("Done markov chain %d/%d, acceptance rate %lf\n", count, nChains, double(sampler.a) / double(sampler.a + sampler.r)); } } for (auto &i:c) { i.x = i.x * (1.0 / double(samps)); i.y = i.y * (1.0 / double(samps)); i.z = i.z * (1.0 / double(samps)); } FILE *f = fopen("image.ppm", "w"); // Write image to PPM file. fprintf(f, "P3\n%d %d\n%d\n", w, h, 255); for (int i = 0; i < w * h; i++) fprintf(f, "%d %d %d ", toInt(c[i].x), toInt(c[i].y), toInt(c[i].z)); }
32.032
118
0.512113
7313c68973add89f0ddad04b9a5810fa63df0790
3,495
cpp
C++
lib/RiGto/RiGtoSet.cpp
cmartinaf/open-gto
c673552a16c9ebe79a42c2a27ddc4cbd8e6b724d
[ "BSD-3-Clause" ]
8
2015-03-20T07:57:09.000Z
2021-02-13T22:20:04.000Z
lib/RiGto/RiGtoSet.cpp
cmartinaf/open-gto
c673552a16c9ebe79a42c2a27ddc4cbd8e6b724d
[ "BSD-3-Clause" ]
null
null
null
lib/RiGto/RiGtoSet.cpp
cmartinaf/open-gto
c673552a16c9ebe79a42c2a27ddc4cbd8e6b724d
[ "BSD-3-Clause" ]
3
2015-02-11T17:44:16.000Z
2019-11-29T12:26:07.000Z
// // Copyright (c) 2009, Tweak Software // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // // * Redistributions of source code must retain the above // copyright notice, this list of conditions and the following // disclaimer. // // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following // disclaimer in the documentation and/or other materials // provided with the distribution. // // * Neither the name of the Tweak Software nor the names of its // contributors may be used to endorse or promote products // derived from this software without specific prior written // permission. // // THIS SOFTWARE IS PROVIDED BY Tweak Software ''AS IS'' AND ANY EXPRESS // OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE // ARE DISCLAIMED. IN NO EVENT SHALL Tweak Software BE LIABLE FOR // ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT // OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR // BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE // USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH // DAMAGE. // #include <RiGto/RiGtoSet.h> namespace RiGto { //****************************************************************************** Set::Set( const std::string &ref, const std::string &open, const std::string &close ) : m_ref( ref ), m_open( open ), m_close( close ) { // Nothing } //****************************************************************************** Set::~Set() { std::vector<Object *>::iterator iter = m_objects.begin(); for ( ; iter != m_objects.end(); ++iter ) { delete (*iter); } } //****************************************************************************** void Set::doneReading( ReaderPhase rp ) { std::vector<Object *>::iterator iter = m_objects.begin(); for ( ; iter != m_objects.end(); ++iter ) { (*iter)->doneReading( rp ); } } //****************************************************************************** Object *Set::object( const std::string &name ) { std::vector<Object *>::const_iterator iter = m_objects.begin(); for ( ; iter != m_objects.end(); ++iter ) { if ( (*iter)->name() == name ) { return (*iter); } } return NULL; } //****************************************************************************** void Set::declareRi( const OnOffList &onList, const OnOffList &offList, const OnOffList &onList2, const OnOffList &offList2 ) const { std::vector<Object *>::const_iterator iter = m_objects.begin(); for ( ; iter != m_objects.end(); ++iter ) { if ( onList.has( (*iter)->name() ) && onList2.has( (*iter)->name() ) && ! offList.has( (*iter)->name() ) && ! offList2.has( (*iter)->name() ) ) { (*iter)->declareRi(); } } } } // End namespace RiGto
32.663551
80
0.546209
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
73159be7e2d0d0940067990682acd252c4792721
2,737
cpp
C++
libcxx/test/std/containers/views/span.obs/empty.pass.cpp
elizabethandrews/llvm
308498236c1c4778fdcba0bfbb556adf8aa333ea
[ "Apache-2.0" ]
305
2019-09-14T17:16:05.000Z
2022-03-31T15:05:20.000Z
libcxx/test/std/containers/views/span.obs/empty.pass.cpp
elizabethandrews/llvm
308498236c1c4778fdcba0bfbb556adf8aa333ea
[ "Apache-2.0" ]
410
2019-06-06T20:52:32.000Z
2022-01-18T14:21:48.000Z
libcxx/test/std/containers/views/span.obs/empty.pass.cpp
elizabethandrews/llvm
308498236c1c4778fdcba0bfbb556adf8aa333ea
[ "Apache-2.0" ]
50
2019-05-10T21:12:24.000Z
2022-01-21T06:39:47.000Z
// -*- C++ -*- //===------------------------------ span ---------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===---------------------------------------------------------------------===// // UNSUPPORTED: c++03, c++11, c++14, c++17 // <span> // constexpr bool empty() const noexcept; // #include <span> #include <cassert> #include <string> #include "test_macros.h" struct A{}; constexpr int iArr1[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; int iArr2[] = {10, 11, 12, 13, 14, 15, 16, 17, 18, 19}; int main(int, char**) { static_assert( noexcept(std::span<int> ().empty()), ""); static_assert( noexcept(std::span<int, 0>().empty()), ""); static_assert( std::span<int>().empty(), ""); static_assert( std::span<long>().empty(), ""); static_assert( std::span<double>().empty(), ""); static_assert( std::span<A>().empty(), ""); static_assert( std::span<std::string>().empty(), ""); static_assert( std::span<int, 0>().empty(), ""); static_assert( std::span<long, 0>().empty(), ""); static_assert( std::span<double, 0>().empty(), ""); static_assert( std::span<A, 0>().empty(), ""); static_assert( std::span<std::string, 0>().empty(), ""); static_assert(!std::span<const int>(iArr1, 1).empty(), ""); static_assert(!std::span<const int>(iArr1, 2).empty(), ""); static_assert(!std::span<const int>(iArr1, 3).empty(), ""); static_assert(!std::span<const int>(iArr1, 4).empty(), ""); static_assert(!std::span<const int>(iArr1, 5).empty(), ""); assert( (std::span<int>().empty() )); assert( (std::span<long>().empty() )); assert( (std::span<double>().empty() )); assert( (std::span<A>().empty() )); assert( (std::span<std::string>().empty() )); assert( (std::span<int, 0>().empty() )); assert( (std::span<long, 0>().empty() )); assert( (std::span<double, 0>().empty() )); assert( (std::span<A, 0>().empty() )); assert( (std::span<std::string, 0>().empty())); assert(!(std::span<int, 1>(iArr2, 1).empty())); assert(!(std::span<int, 2>(iArr2, 2).empty())); assert(!(std::span<int, 3>(iArr2, 3).empty())); assert(!(std::span<int, 4>(iArr2, 4).empty())); assert(!(std::span<int, 5>(iArr2, 5).empty())); std::string s; assert( ((std::span<std::string>(&s, (std::size_t) 0)).empty())); assert(!((std::span<std::string>(&s, 1).empty()))); return 0; }
36.493333
80
0.502009
7317ba74f6f2bad7cc0fb55df7288340d6c4720b
7,205
cpp
C++
src/reduce.cpp
q3k/cadical
b490c98b9b4a4bb66c04cbc3e535c3205f4ccc17
[ "MIT" ]
null
null
null
src/reduce.cpp
q3k/cadical
b490c98b9b4a4bb66c04cbc3e535c3205f4ccc17
[ "MIT" ]
null
null
null
src/reduce.cpp
q3k/cadical
b490c98b9b4a4bb66c04cbc3e535c3205f4ccc17
[ "MIT" ]
null
null
null
#include "internal.hpp" namespace CaDiCaL { /*------------------------------------------------------------------------*/ // Once in a while we reduce, e.g., we remove learned clauses which are // supposed to be less useful in the future. This is done in increasing // intervals, which has the effect of allowing more and more learned clause // to be kept for a longer period. The number of learned clauses kept // in memory corresponds to an upper bound on the 'space' of a resolution // proof needed to refute a formula in proof complexity sense. bool Internal::reducing () { if (!opts.reduce) return false; if (!stats.current.redundant) return false; return stats.conflicts >= lim.reduce; } /*------------------------------------------------------------------------*/ // Even less regularly we are flushing all redundant clauses. bool Internal::flushing () { if (!opts.flush) return false; return stats.conflicts >= lim.flush; } /*------------------------------------------------------------------------*/ // Reason clauses (on non-zero decision level) can not be collected. // We protect them before and unprotect them after garbage collection. void Internal::protect_reasons () { for (const auto & lit : trail) { Var & v = var (lit); if (!v.level || !v.reason) continue; LOG (v.reason, "protecting"); v.reason->reason = true; } } void Internal::unprotect_reasons () { for (const auto & lit : trail) { Var & v = var (lit); if (!v.level || !v.reason) continue; assert (v.reason->reason), v.reason->reason = false; } } /*------------------------------------------------------------------------*/ void Internal::mark_clauses_to_be_flushed () { for (const auto & c : clauses) { if (!c->redundant) continue; // keep irredundant if (c->garbage) continue; // already marked as garbage if (c->reason) continue; // need to keep reasons const bool used = c->used; c->used = false; if (used) continue; // but keep recently used clauses mark_garbage (c); // flush unused clauses if (c->hyper) stats.flush.hyper++; else stats.flush.learned++; } // No change to 'lim.kept{size,glue}'. } /*------------------------------------------------------------------------*/ // Clauses of larger glue or larger size are considered less useful. // // We also follow the observations made by the Glucose team in their // IJCAI'09 paper and keep all low glue clauses limited by // 'options.keepglue' (typically '3'). // // In earlier versions we pre-computed a 64-bit sort key per clause and // wrapped a pointer to the clause and the 64-bit sort key into a separate // data structure for sorting. This was probably faster but awkward and // so we moved back to a simpler scheme which also uses 'stable_sort' // instead of 'rsort' below. Sorting here is not a hot-spot anyhow. struct reduce_less_useful { bool operator () (const Clause * c, const Clause * d) const { if (c->glue > d->glue) return true; if (c->glue < d->glue) return false; return c->size > d->size; } }; // This function implements the important reduction policy. It determines // which redundant clauses are considered not useful and thus will be // collected in a subsequent garbage collection phase. void Internal::mark_useless_redundant_clauses_as_garbage () { // We use a separate stack for sorting candidates for removal. This uses // (slightly) more memory but has the advantage to keep the relative order // in 'clauses' intact, which actually due to using stable sorting goes // into the candidate selection (more recently learned clauses are kept if // they otherwise have the same glue and size). vector<Clause *> stack; stack.reserve (stats.current.redundant); for (const auto & c : clauses) { if (!c->redundant) continue; // Keep irredundant. if (c->garbage) continue; // Skip already marked. if (c->reason) continue; // Need to keep reasons. const bool used = c->used; c->used = false; if (c->hyper) { // Hyper binary and ternary resolvents assert (c->size <= 3); // are only kept for one reduce round if (!used) mark_garbage (c); // (even if 'c->keep' is true) unless continue; // used recently. } if (used) continue; // Do keep recently used clauses. if (c->keep) continue; // Forced to keep (see above). stack.push_back (c); } stable_sort (stack.begin (), stack.end (), reduce_less_useful ()); size_t target = 1e-2 * opts.reducetarget * stack.size (); // This is defensive code, which I usually consider a bug, but here I am // just not sure that using floating points in the line above is precise // in all situations and instead of figuring that out, I just use this. // if (target > stack.size ()) target = stack.size (); PHASE ("reduce", stats.reductions, "reducing %zd clauses %.0f%%", target, percent (target, stats.current.redundant)); auto i = stack.begin (); const auto t = i + target; while (i != t) { Clause * c = *i++; LOG (c, "marking useless to be collected"); mark_garbage (c); stats.reduced++; } lim.keptsize = lim.keptglue = 0; const auto end = stack.end (); for (i = t; i != end; i++) { Clause * c = *i; LOG (c, "keeping"); if (c->size > lim.keptsize) lim.keptsize = c->size; if (c->glue > lim.keptglue) lim.keptglue = c->glue; } erase_vector (stack); PHASE ("reduce", stats.reductions, "maximum kept size %d glue %d", lim.keptsize, lim.keptglue); } /*------------------------------------------------------------------------*/ void Internal::reduce () { START (reduce); stats.reductions++; report ('.', 1); bool flush = flushing (); if (flush) stats.flush.count++; if (level) { int ooo = 0; for (size_t i = control[1].trail; !ooo && i < trail.size (); i++) { const int lit = trail[i]; assert (val (lit) > 0); if (var (lit).level) continue; LOG ("found out-of-order assigned unit %d", ooo); ooo = lit; } if (ooo) { backtrack (0); if (!propagate ()) { learn_empty_clause (); goto DONE; } } } if (level) protect_reasons (); mark_satisfied_clauses_as_garbage (); if (flush) mark_clauses_to_be_flushed (); else mark_useless_redundant_clauses_as_garbage (); garbage_collection (); if (level) unprotect_reasons (); { long delta = opts.reduceint * (stats.reductions + 1); if (irredundant () > 1e5) { delta *= log (irredundant ()/1e4) / log (10); if (delta < 1) delta = 1; } lim.reduce = stats.conflicts + delta; PHASE ("reduce", stats.reductions, "new reduce limit %ld after %ld conflicts", lim.reduce, delta); } if (flush) { PHASE ("flush", stats.flush.count, "new flush increment %ld", inc.flush); inc.flush *= opts.flushfactor; lim.flush = stats.conflicts + inc.flush; PHASE ("flush", stats.flush.count, "new flush limit %ld", lim.flush); } last.reduce.conflicts = stats.conflicts; DONE: report (flush ? 'f' : '-'); STOP (reduce); } }
32.022222
77
0.599722
731924b015015b67c832555ad1db1862aeea142d
2,194
cpp
C++
B2G/gecko/content/html/content/src/nsTimeRanges.cpp
wilebeast/FireFox-OS
43067f28711d78c429a1d6d58c77130f6899135f
[ "Apache-2.0" ]
3
2015-08-31T15:24:31.000Z
2020-04-24T20:31:29.000Z
B2G/gecko/content/html/content/src/nsTimeRanges.cpp
wilebeast/FireFox-OS
43067f28711d78c429a1d6d58c77130f6899135f
[ "Apache-2.0" ]
null
null
null
B2G/gecko/content/html/content/src/nsTimeRanges.cpp
wilebeast/FireFox-OS
43067f28711d78c429a1d6d58c77130f6899135f
[ "Apache-2.0" ]
3
2015-07-29T07:17:15.000Z
2020-11-04T06:55:37.000Z
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim:set ts=2 sw=2 sts=2 et cindent: */ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "nsTimeRanges.h" #include "nsDOMClassInfoID.h" #include "nsError.h" NS_IMPL_ADDREF(nsTimeRanges) NS_IMPL_RELEASE(nsTimeRanges) DOMCI_DATA(TimeRanges, nsTimeRanges) NS_INTERFACE_MAP_BEGIN(nsTimeRanges) NS_INTERFACE_MAP_ENTRY(nsISupports) NS_INTERFACE_MAP_ENTRY(nsIDOMTimeRanges) NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(TimeRanges) NS_INTERFACE_MAP_END nsTimeRanges::nsTimeRanges() { MOZ_COUNT_CTOR(nsTimeRanges); } nsTimeRanges::~nsTimeRanges() { MOZ_COUNT_DTOR(nsTimeRanges); } NS_IMETHODIMP nsTimeRanges::GetLength(uint32_t* aLength) { *aLength = mRanges.Length(); return NS_OK; } NS_IMETHODIMP nsTimeRanges::Start(uint32_t aIndex, double* aTime) { if (aIndex >= mRanges.Length()) return NS_ERROR_DOM_INDEX_SIZE_ERR; *aTime = mRanges[aIndex].mStart; return NS_OK; } NS_IMETHODIMP nsTimeRanges::End(uint32_t aIndex, double* aTime) { if (aIndex >= mRanges.Length()) return NS_ERROR_DOM_INDEX_SIZE_ERR; *aTime = mRanges[aIndex].mEnd; return NS_OK; } void nsTimeRanges::Add(double aStart, double aEnd) { if (aStart > aEnd) { NS_WARNING("Can't add a range if the end is older that the start."); return; } mRanges.AppendElement(TimeRange(aStart,aEnd)); } void nsTimeRanges::Normalize() { if (mRanges.Length() >= 2) { nsAutoTArray<TimeRange,4> normalized; mRanges.Sort(CompareTimeRanges()); // This merges the intervals. TimeRange current(mRanges[0]); for (uint32_t i = 1; i < mRanges.Length(); i++) { if (current.mStart <= mRanges[i].mStart && current.mEnd >= mRanges[i].mEnd) { continue; } if (current.mEnd >= mRanges[i].mStart) { current.mEnd = mRanges[i].mEnd; } else { normalized.AppendElement(current); current = mRanges[i]; } } normalized.AppendElement(current); mRanges = normalized; } }
23.094737
79
0.69371
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
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
731c9e1161e40e1b19985ed666223cbe809a32d5
14,888
cc
C++
chrome/browser/net/stub_resolver_config_reader_unittest.cc
sarang-apps/darshan_browser
173649bb8a7c656dc60784d19e7bb73e07c20daa
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
null
null
null
chrome/browser/net/stub_resolver_config_reader_unittest.cc
sarang-apps/darshan_browser
173649bb8a7c656dc60784d19e7bb73e07c20daa
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
null
null
null
chrome/browser/net/stub_resolver_config_reader_unittest.cc
sarang-apps/darshan_browser
173649bb8a7c656dc60784d19e7bb73e07c20daa
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
null
null
null
// Copyright 2020 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "chrome/browser/net/stub_resolver_config_reader.h" #include <memory> #include <vector> #include "base/test/task_environment.h" #include "base/values.h" #include "chrome/browser/net/dns_util.h" #include "chrome/common/pref_names.h" #include "chrome/test/base/scoped_testing_local_state.h" #include "components/prefs/pref_service.h" #include "components/prefs/testing_pref_service.h" #include "content/public/test/browser_task_environment.h" #include "net/dns/dns_config.h" #include "net/dns/public/dns_over_https_server_config.h" #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h" namespace { constexpr char kDohServerTemplate[] = "https://doh1.test https://doh2.test/query{?dns}"; // Override the reader to mock out the ShouldDisableDohFor...() methods. class MockedStubResolverConfigReader : public StubResolverConfigReader { public: explicit MockedStubResolverConfigReader(PrefService* local_state) : StubResolverConfigReader(local_state, false /* set_up_pref_defaults */) {} bool ShouldDisableDohForManaged() override { return disable_for_managed_; } bool ShouldDisableDohForParentalControls() override { parental_controls_checked_ = true; return disable_for_parental_controls_; } void set_disable_for_managed() { disable_for_managed_ = true; } void set_disable_for_parental_controls() { disable_for_parental_controls_ = true; } bool parental_controls_checked() { return parental_controls_checked_; } private: bool disable_for_managed_ = false; bool disable_for_parental_controls_ = false; bool parental_controls_checked_ = false; }; class StubResolverConfigReaderTest : public testing::Test { public: StubResolverConfigReaderTest() { StubResolverConfigReader::RegisterPrefs(local_state_.registry()); } protected: content::BrowserTaskEnvironment task_environment_{ base::test::TaskEnvironment::TimeSource::MOCK_TIME}; TestingPrefServiceSimple local_state_; std::unique_ptr<MockedStubResolverConfigReader> config_reader_ = std::make_unique<MockedStubResolverConfigReader>(&local_state_); }; TEST_F(StubResolverConfigReaderTest, GetConfiguration) { bool insecure_stub_resolver_enabled; net::DnsConfig::SecureDnsMode secure_dns_mode; std::vector<net::DnsOverHttpsServerConfig> dns_over_https_servers; // |force_check_parental_controls_for_automatic_mode = true| is not the main // default case, but the specific behavior involved is tested separately. config_reader_->GetConfiguration( true /* force_check_parental_controls_for_automatic_mode */, &insecure_stub_resolver_enabled, &secure_dns_mode, &dns_over_https_servers); EXPECT_FALSE(insecure_stub_resolver_enabled); EXPECT_EQ(secure_dns_mode, net::DnsConfig::SecureDnsMode::OFF); EXPECT_TRUE(dns_over_https_servers.empty()); // Parental controls should not be checked when DoH otherwise disabled. EXPECT_FALSE(config_reader_->parental_controls_checked()); } TEST_F(StubResolverConfigReaderTest, DohEnabled) { local_state_.SetBoolean(prefs::kBuiltInDnsClientEnabled, true); local_state_.SetString(prefs::kDnsOverHttpsMode, chrome_browser_net::kDnsOverHttpsModeAutomatic); local_state_.SetString(prefs::kDnsOverHttpsTemplates, kDohServerTemplate); bool insecure_stub_resolver_enabled; net::DnsConfig::SecureDnsMode secure_dns_mode; std::vector<net::DnsOverHttpsServerConfig> dns_over_https_servers; // |force_check_parental_controls_for_automatic_mode = true| is not the main // default case, but the specific behavior involved is tested separately. config_reader_->GetConfiguration( true /* force_check_parental_controls_for_automatic_mode */, &insecure_stub_resolver_enabled, &secure_dns_mode, &dns_over_https_servers); EXPECT_TRUE(insecure_stub_resolver_enabled); EXPECT_EQ(secure_dns_mode, net::DnsConfig::SecureDnsMode::AUTOMATIC); EXPECT_THAT(dns_over_https_servers, testing::ElementsAre( net::DnsOverHttpsServerConfig("https://doh1.test", true /* use_post */), net::DnsOverHttpsServerConfig("https://doh2.test/query{?dns}", false /* use_post */))); EXPECT_TRUE(config_reader_->parental_controls_checked()); } TEST_F(StubResolverConfigReaderTest, DohEnabled_Secure) { local_state_.SetBoolean(prefs::kBuiltInDnsClientEnabled, true); local_state_.SetString(prefs::kDnsOverHttpsMode, chrome_browser_net::kDnsOverHttpsModeSecure); local_state_.SetString(prefs::kDnsOverHttpsTemplates, kDohServerTemplate); bool insecure_stub_resolver_enabled; net::DnsConfig::SecureDnsMode secure_dns_mode; std::vector<net::DnsOverHttpsServerConfig> dns_over_https_servers; // |force_check_parental_controls_for_automatic_mode| should have no effect on // SECURE mode, so set to false to ensure check is not deferred. config_reader_->GetConfiguration( false /* force_check_parental_controls_for_automatic_mode */, &insecure_stub_resolver_enabled, &secure_dns_mode, &dns_over_https_servers); EXPECT_TRUE(insecure_stub_resolver_enabled); EXPECT_EQ(secure_dns_mode, net::DnsConfig::SecureDnsMode::SECURE); EXPECT_THAT(dns_over_https_servers, testing::ElementsAre( net::DnsOverHttpsServerConfig("https://doh1.test", true /* use_post */), net::DnsOverHttpsServerConfig("https://doh2.test/query{?dns}", false /* use_post */))); EXPECT_TRUE(config_reader_->parental_controls_checked()); } TEST_F(StubResolverConfigReaderTest, DisabledForManaged) { config_reader_->set_disable_for_managed(); local_state_.SetBoolean(prefs::kBuiltInDnsClientEnabled, true); local_state_.SetString(prefs::kDnsOverHttpsMode, chrome_browser_net::kDnsOverHttpsModeAutomatic); local_state_.SetString(prefs::kDnsOverHttpsTemplates, kDohServerTemplate); bool insecure_stub_resolver_enabled; net::DnsConfig::SecureDnsMode secure_dns_mode; std::vector<net::DnsOverHttpsServerConfig> dns_over_https_servers; // |force_check_parental_controls_for_automatic_mode = true| is not the main // default case, but the specific behavior involved is tested separately. config_reader_->GetConfiguration( true /* force_check_parental_controls_for_automatic_mode */, &insecure_stub_resolver_enabled, &secure_dns_mode, &dns_over_https_servers); EXPECT_TRUE(insecure_stub_resolver_enabled); EXPECT_EQ(secure_dns_mode, net::DnsConfig::SecureDnsMode::OFF); EXPECT_TRUE(dns_over_https_servers.empty()); // Parental controls should not be checked when DoH otherwise disabled. EXPECT_FALSE(config_reader_->parental_controls_checked()); } TEST_F(StubResolverConfigReaderTest, DisabledForManaged_Secure) { config_reader_->set_disable_for_managed(); local_state_.SetBoolean(prefs::kBuiltInDnsClientEnabled, true); local_state_.SetString(prefs::kDnsOverHttpsMode, chrome_browser_net::kDnsOverHttpsModeSecure); local_state_.SetString(prefs::kDnsOverHttpsTemplates, kDohServerTemplate); bool insecure_stub_resolver_enabled; net::DnsConfig::SecureDnsMode secure_dns_mode; std::vector<net::DnsOverHttpsServerConfig> dns_over_https_servers; config_reader_->GetConfiguration( false /* force_check_parental_controls_for_automatic_mode */, &insecure_stub_resolver_enabled, &secure_dns_mode, &dns_over_https_servers); EXPECT_TRUE(insecure_stub_resolver_enabled); EXPECT_EQ(secure_dns_mode, net::DnsConfig::SecureDnsMode::OFF); EXPECT_TRUE(dns_over_https_servers.empty()); // Parental controls should not be checked when DoH otherwise disabled. EXPECT_FALSE(config_reader_->parental_controls_checked()); } TEST_F(StubResolverConfigReaderTest, DisabledForParentalControls) { config_reader_->set_disable_for_parental_controls(); local_state_.SetBoolean(prefs::kBuiltInDnsClientEnabled, true); local_state_.SetString(prefs::kDnsOverHttpsMode, chrome_browser_net::kDnsOverHttpsModeAutomatic); local_state_.SetString(prefs::kDnsOverHttpsTemplates, kDohServerTemplate); bool insecure_stub_resolver_enabled; net::DnsConfig::SecureDnsMode secure_dns_mode; std::vector<net::DnsOverHttpsServerConfig> dns_over_https_servers; // |force_check_parental_controls_for_automatic_mode = true| is not the main // default case, but the specific behavior involved is tested separately. config_reader_->GetConfiguration( true /* force_check_parental_controls_for_automatic_mode */, &insecure_stub_resolver_enabled, &secure_dns_mode, &dns_over_https_servers); EXPECT_TRUE(insecure_stub_resolver_enabled); EXPECT_EQ(secure_dns_mode, net::DnsConfig::SecureDnsMode::OFF); EXPECT_TRUE(dns_over_https_servers.empty()); EXPECT_TRUE(config_reader_->parental_controls_checked()); } TEST_F(StubResolverConfigReaderTest, DisabledForParentalControls_Secure) { config_reader_->set_disable_for_parental_controls(); local_state_.SetBoolean(prefs::kBuiltInDnsClientEnabled, true); local_state_.SetString(prefs::kDnsOverHttpsMode, chrome_browser_net::kDnsOverHttpsModeSecure); local_state_.SetString(prefs::kDnsOverHttpsTemplates, kDohServerTemplate); bool insecure_stub_resolver_enabled; net::DnsConfig::SecureDnsMode secure_dns_mode; std::vector<net::DnsOverHttpsServerConfig> dns_over_https_servers; // |force_check_parental_controls_for_automatic_mode| should have no effect on // SECURE mode, so set to false to ensure check is not deferred. config_reader_->GetConfiguration( false /* force_check_parental_controls_for_automatic_mode */, &insecure_stub_resolver_enabled, &secure_dns_mode, &dns_over_https_servers); EXPECT_TRUE(insecure_stub_resolver_enabled); EXPECT_EQ(secure_dns_mode, net::DnsConfig::SecureDnsMode::OFF); EXPECT_TRUE(dns_over_https_servers.empty()); EXPECT_TRUE(config_reader_->parental_controls_checked()); } TEST_F(StubResolverConfigReaderTest, DeferredParentalControlsCheck) { config_reader_->set_disable_for_parental_controls(); local_state_.SetBoolean(prefs::kBuiltInDnsClientEnabled, true); local_state_.SetString(prefs::kDnsOverHttpsMode, chrome_browser_net::kDnsOverHttpsModeAutomatic); local_state_.SetString(prefs::kDnsOverHttpsTemplates, kDohServerTemplate); bool insecure_stub_resolver_enabled; net::DnsConfig::SecureDnsMode secure_dns_mode; std::vector<net::DnsOverHttpsServerConfig> dns_over_https_servers; config_reader_->GetConfiguration( false /* force_check_parental_controls_for_automatic_mode */, &insecure_stub_resolver_enabled, &secure_dns_mode, &dns_over_https_servers); // Parental controls check initially skipped. EXPECT_TRUE(insecure_stub_resolver_enabled); EXPECT_EQ(secure_dns_mode, net::DnsConfig::SecureDnsMode::AUTOMATIC); EXPECT_THAT(dns_over_https_servers, testing::ElementsAre( net::DnsOverHttpsServerConfig("https://doh1.test", true /* use_post */), net::DnsOverHttpsServerConfig("https://doh2.test/query{?dns}", false /* use_post */))); EXPECT_FALSE(config_reader_->parental_controls_checked()); task_environment_.AdvanceClock( StubResolverConfigReader::kParentalControlsCheckDelay); task_environment_.RunUntilIdle(); EXPECT_TRUE(config_reader_->parental_controls_checked()); dns_over_https_servers.clear(); config_reader_->GetConfiguration( false /* force_check_parental_controls_for_automatic_mode */, &insecure_stub_resolver_enabled, &secure_dns_mode, &dns_over_https_servers); EXPECT_TRUE(insecure_stub_resolver_enabled); EXPECT_EQ(secure_dns_mode, net::DnsConfig::SecureDnsMode::OFF); EXPECT_TRUE(dns_over_https_servers.empty()); } TEST_F(StubResolverConfigReaderTest, DeferredParentalControlsCheck_Managed) { config_reader_->set_disable_for_managed(); config_reader_->set_disable_for_parental_controls(); local_state_.SetBoolean(prefs::kBuiltInDnsClientEnabled, true); local_state_.SetManagedPref( prefs::kDnsOverHttpsMode, std::make_unique<base::Value>( chrome_browser_net::kDnsOverHttpsModeAutomatic)); local_state_.SetManagedPref( prefs::kDnsOverHttpsTemplates, std::make_unique<base::Value>(kDohServerTemplate)); bool insecure_stub_resolver_enabled; net::DnsConfig::SecureDnsMode secure_dns_mode; std::vector<net::DnsOverHttpsServerConfig> dns_over_https_servers; config_reader_->GetConfiguration( false /* force_check_parental_controls_for_automatic_mode */, &insecure_stub_resolver_enabled, &secure_dns_mode, &dns_over_https_servers); // Parental controls check initially skipped, and managed prefs take // precedence over disables. EXPECT_TRUE(insecure_stub_resolver_enabled); EXPECT_EQ(secure_dns_mode, net::DnsConfig::SecureDnsMode::AUTOMATIC); EXPECT_THAT(dns_over_https_servers, testing::ElementsAre( net::DnsOverHttpsServerConfig("https://doh1.test", true /* use_post */), net::DnsOverHttpsServerConfig("https://doh2.test/query{?dns}", false /* use_post */))); EXPECT_FALSE(config_reader_->parental_controls_checked()); task_environment_.AdvanceClock( StubResolverConfigReader::kParentalControlsCheckDelay); task_environment_.RunUntilIdle(); EXPECT_TRUE(config_reader_->parental_controls_checked()); dns_over_https_servers.clear(); config_reader_->GetConfiguration( false /* force_check_parental_controls_for_automatic_mode */, &insecure_stub_resolver_enabled, &secure_dns_mode, &dns_over_https_servers); // Expect DoH still enabled after parental controls check because managed // prefs have precedence. EXPECT_TRUE(insecure_stub_resolver_enabled); EXPECT_EQ(secure_dns_mode, net::DnsConfig::SecureDnsMode::AUTOMATIC); EXPECT_THAT(dns_over_https_servers, testing::ElementsAre( net::DnsOverHttpsServerConfig("https://doh1.test", true /* use_post */), net::DnsOverHttpsServerConfig("https://doh2.test/query{?dns}", false /* use_post */))); } } // namespace
41.703081
80
0.752485
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
731e6b4c332561f4aa726e60b58e4a956da8625a
12,594
cpp
C++
game/src/ScriptObjects/ScriptObjectGame.cpp
fromasmtodisasm/BlackBox
36b4fa56e62a81d9483e76f1272b1203981b97fe
[ "MIT" ]
1
2019-12-10T00:37:05.000Z
2019-12-10T00:37:05.000Z
game/src/ScriptObjects/ScriptObjectGame.cpp
fromasmtodisasm/BlackBox
36b4fa56e62a81d9483e76f1272b1203981b97fe
[ "MIT" ]
3
2020-02-17T21:12:09.000Z
2022-01-19T10:28:02.000Z
game/src/ScriptObjects/ScriptObjectGame.cpp
fromasmtodisasm/BlackBox
36b4fa56e62a81d9483e76f1272b1203981b97fe
[ "MIT" ]
3
2019-03-14T16:28:47.000Z
2020-05-17T20:42:55.000Z
#include <Game.hpp> #include <Server/XServer.hpp> #include <ScriptObjects/ScriptObjectGame.hpp> #include <BlackBox/Core/IMarkers.hpp> #include <BlackBox/System/IConsole.hpp> ////////////////////////////////////////////////////////////////////// // Construction/Destruction ////////////////////////////////////////////////////////////////////// _DECLARE_SCRIPTABLEEX(CScriptObjectGame) CScriptObjectGame::CScriptObjectGame() { } CScriptObjectGame::~CScriptObjectGame() { } void CScriptObjectGame::InitializeTemplate(IScriptSystem* pSS) { _ScriptableEx<CScriptObjectGame>::InitializeTemplate(pSS); REG_FUNC(CScriptObjectGame, SendMessage); REG_FUNC(CScriptObjectGame, Stop); REG_FUNC(CScriptObjectGame, gotoMenu); REG_FUNC(CScriptObjectGame, gotoGame); REG_FUNC(CScriptObjectGame, gotoFly); REG_FUNC(CScriptObjectGame, gotoEdit); REG_FUNC(CScriptObjectGame, showMenu); REG_FUNC(CScriptObjectGame, GetTagPoint); REG_FUNC(CScriptObjectGame, CreateVariable); REG_FUNC(CScriptObjectGame, SetVariable); REG_FUNC(CScriptObjectGame, RemoveVariable); REG_FUNC(CScriptObjectGame, GetVariable); REG_FUNC(CScriptObjectGame, LoadLevel); REG_FUNC(CScriptObjectGame, AddCommand); REG_FUNC(CScriptObjectGame, Quit); REG_FUNC(CScriptObjectGame, SavePlayerPos); REG_FUNC(CScriptObjectGame, LoadPlayerPos); } void CScriptObjectGame::Init(IScriptSystem* pScriptSystem, CGame* pGame) { m_pGame = pGame; m_pSystem = pGame->GetSystem(); m_pConsole = m_pSystem->GetIConsole(); InitGlobal(pScriptSystem, "Game", this); } void CScriptObjectGame::OnNETServerFound(CIPAddress& ip, SXServerInfos& pServerInfo) { SmartScriptObject pServer(m_pScriptSystem); pServer->SetValue("Name", pServerInfo.strName.c_str()); pServer->SetValue("Map", pServerInfo.strMap.c_str()); pServer->SetValue("Players", (int)pServerInfo.nPlayers); pServer->SetValue("MaxPlayers", (int)pServerInfo.nMaxPlayers); pServer->SetValue("GameType", pServerInfo.strGameType.c_str()); pServer->SetValue("Mod", pServerInfo.strMod.c_str()); pServer->SetValue("Ping", (int)pServerInfo.nPing); pServer->SetValue("IP", pServerInfo.IP.GetAsString(true)); pServer->SetValue("Password", (int)((pServerInfo.nServerFlags & SXServerInfos::FLAG_PASSWORD) ? 1 : 0)); pServer->SetValue("CheatsEnabled", (int)((pServerInfo.nServerFlags & SXServerInfos::FLAG_CHEATS) ? 1 : 0)); char str[80]; pServerInfo.VersionInfo.ToString(str); pServer->SetValue("GameVersion", str); pServer->SetValue("InternetServer", (int)((pServerInfo.nServerFlags & SXServerInfos::FLAG_NET) ? 1 : 0)); pServer->SetValue("ComputerType", (int)pServerInfo.nComputerType); pServer->SetValue("PunkBuster", (int)((pServerInfo.nServerFlags & SXServerInfos::FLAG_PUNKBUSTER) ? 1 : 0)); HSCRIPTFUNCTION pfOnNETServerFound = 0; if (m_pScriptThis->GetValue("OnNETServerFound", pfOnNETServerFound)) { m_pScriptSystem->BeginCall(pfOnNETServerFound); m_pScriptSystem->PushFuncParam(GetScriptObject()); m_pScriptSystem->PushFuncParam(pServer); m_pScriptSystem->EndCall(); } m_pScriptSystem->ReleaseFunc(pfOnNETServerFound); } void CScriptObjectGame::OnNETServerTimeout(CIPAddress& ip) { SmartScriptObject pServer(m_pScriptSystem); pServer->SetValue("Name", ""); pServer->SetValue("Map", ""); pServer->SetValue("Players", 0); pServer->SetValue("MaxPlayers", 0); pServer->SetValue("GameType", ""); pServer->SetValue("Mod", ""); pServer->SetValue("Ping", 0); pServer->SetValue("IP", ip.GetAsString(true)); pServer->SetValue("Password", 0); pServer->SetValue("CheatsEnabled", 0); pServer->SetValue("GameVersion", ""); pServer->SetValue("InternetServer", 0); pServer->SetValue("ComputerType", 0); pServer->SetValue("PunkBuster", 0); HSCRIPTFUNCTION pfOnNETServerTimeout = 0; if (m_pScriptThis->GetValue("OnNETServerTimeout", pfOnNETServerTimeout)) { m_pScriptSystem->BeginCall(pfOnNETServerTimeout); m_pScriptSystem->PushFuncParam(GetScriptObject()); m_pScriptSystem->PushFuncParam(pServer); m_pScriptSystem->EndCall(); } m_pScriptSystem->ReleaseFunc(pfOnNETServerTimeout); } int CScriptObjectGame::SendMessage(IFunctionHandler* pH) { CHECK_PARAMETERS(1); const char* pszMsg; pH->GetParam(1, pszMsg); if (pszMsg) m_pGame->SendMessage(pszMsg); else m_pScriptSystem->RaiseError("SendMessage() parameter is nil"); return pH->EndFunction(); } int CScriptObjectGame::Stop(IFunctionHandler* pH) { m_pGame->Stop(); return pH->EndFunction(); } int CScriptObjectGame::gotoMenu(IFunctionHandler* pH) { m_pGame->gotoMenu(); return pH->EndFunction(); } int CScriptObjectGame::gotoFullscreen(IFunctionHandler* pH) { m_pGame->gotoFullscreen(); return pH->EndFunction(); } int CScriptObjectGame::gotoGame(IFunctionHandler* pH) { m_pGame->gotoGame(); return pH->EndFunction(); } int CScriptObjectGame::gotoFly(IFunctionHandler* pH) { m_pGame->gotoFly(); return pH->EndFunction(); } int CScriptObjectGame::gotoEdit(IFunctionHandler* pH) { m_pGame->gotoEdit(); return pH->EndFunction(); } int CScriptObjectGame::showMenu(IFunctionHandler* pH) { m_pGame->showMenu(); return pH->EndFunction(); } int CScriptObjectGame::GetVersion(IFunctionHandler* pH) { return 0; } int CScriptObjectGame::GetVersionString(IFunctionHandler* pH) { return 0; } int CScriptObjectGame::ReloadScripts(IFunctionHandler* pH) { return 0; } int CScriptObjectGame::Load(IFunctionHandler* pH) { return 0; } int CScriptObjectGame::Save(IFunctionHandler* pH) { return 0; } int CScriptObjectGame::LoadLatestCheckPoint(IFunctionHandler* pH) { return 0; } int CScriptObjectGame::ShowSaveGameMenu(IFunctionHandler* pH) { return 0; } ////////////////////////////////////////////////////////////////////// /*!quit the game */ int CScriptObjectGame::Quit(IFunctionHandler* pH) { CHECK_PARAMETERS(0); //m_pConsole->Exit(NULL); m_pSystem->Quit(); return pH->EndFunction(); } int CScriptObjectGame::IsPointInWater(IFunctionHandler* pH) { return 0; } int CScriptObjectGame::GetWaterHeight(IFunctionHandler* pH) { return 0; } int CScriptObjectGame::GetTagPoint(IFunctionHandler* pH) { CHECK_PARAMETERS(1); const char* sTPName; ITagPoint* pTP = NULL; Vec3 vec(0, 0, 0); if (pH->GetParam(1, sTPName)) { pTP = m_pGame->GetTagPoint(sTPName); if (!pTP) return pH->EndFunctionNull(); pTP->GetPos(vec); } m_pGetTagPoint.Set(vec); return pH->EndFunction(m_pGetTagPoint); } int CScriptObjectGame::IsServer(IFunctionHandler* pH) { return 0; } int CScriptObjectGame::IsClient(IFunctionHandler* pH) { return 0; } int CScriptObjectGame::IsMultiplayer(IFunctionHandler* pH) { return 0; } int CScriptObjectGame::GetMaterialIDByName(IFunctionHandler* pH) { return 0; } int CScriptObjectGame::ReloadMaterialPhysics(IFunctionHandler* pH) { return 0; } int CScriptObjectGame::StartRecord(IFunctionHandler* pH) { return 0; } int CScriptObjectGame::StopRecord(IFunctionHandler* pH) { return 0; } ////////////////////////////////////////////////////////////////////// /*!create a console variable @param sName name of the console variable @param sDefault the default value[optional] */ int CScriptObjectGame::CreateVariable(IFunctionHandler* pH) { int nPCount = pH->GetParamCount(); const char* sName; const char* sDefault; const char* sflags; int iflags = 0; pH->GetParam(1, sName); if (nPCount > 1) { pH->GetParam(2, sDefault); if (nPCount > 2) { switch (pH->GetParamType(3)) { case ScriptVarType::String: if (pH->GetParam(3, sflags)) { if (strcmp(sflags, "NetSynch") == 0) iflags = VF_NET_SYNCED; } else m_pSystem->GetILog()->LogWarning("Game:CreateVariable can't get the 3rd parameter (string)"); break; case ScriptVarType::Number: if (pH->GetParam(3, iflags)) { // do nothing, the flags must be the VF_* flags } else m_pSystem->GetILog()->LogWarning("Game:CreateVariable can't get the 3rd parameter (number)"); break; default: m_pSystem->GetILog()->LogWarning("Game:CreateVariable unexpected 3rd (flags) parameter type (%s)", ScriptVarTypeAsCStr(pH->GetParamType(3))); break; } } } else { sDefault = "0"; } m_pConsole->CreateVariable(sName, sDefault, iflags); return pH->EndFunction(); } int CScriptObjectGame::SetVariable(IFunctionHandler* pH) { CHECK_PARAMETERS(2); const char* sName; if (!pH->GetParam(1, sName)) { m_pScriptSystem->RaiseError("SetVariable invalid parameter type %s, string expected", ScriptVarTypeAsCStr(pH->GetParamType(1))); return pH->EndFunctionNull(); } ICVar* pVar = m_pSystem->GetIConsole()->GetCVar(sName); if (!pVar) { m_pScriptSystem->RaiseError("SetVariable invalid variable name \"%s\": no such variable found", sName); return pH->EndFunctionNull(); } if ((pVar->GetFlags() & VF_CHEAT) && (!m_pGame->IsDevModeEnable())) { // [martin] hid this message because we don't want to help hacking // m_pSystem->GetILog()->LogWarning ("\001 Variable %s is cheat protected.", sName); return pH->EndFunctionNull(); } switch (pH->GetParamType(2)) { case ScriptVarType::Null: pVar->Set(""); break; case ScriptVarType::String: { const char* pVal; if (!pH->GetParam(2, pVal)) { m_pScriptSystem->RaiseError("SetVariable cannot retrieve the variable %s string value", sName); return pH->EndFunctionNull(); } pVar->Set(pVal); } break; case ScriptVarType::Number: { int nVal; float fVal; if (pH->GetParam(2, fVal)) pVar->Set(fVal); else if (pH->GetParam(2, nVal)) pVar->Set(nVal); else { m_pScriptSystem->RaiseError("SetVariable cannot retrieve the variable %s numeric value", sName); return pH->EndFunctionNull(); } } break; default: m_pScriptSystem->RaiseError("SetVariable cannot set the variable %s value: unsupported type %s", sName, ScriptVarTypeAsCStr(pH->GetParamType(2))); break; } return pH->EndFunction(); } int CScriptObjectGame::RemoveVariable(IFunctionHandler* pH) { CHECK_PARAMETERS(1); const char* sName; pH->GetParam(1, sName); m_pConsole->UnregisterVariable(sName, true); return pH->EndFunction(); } int CScriptObjectGame::GetVariable(IFunctionHandler* pH) { CHECK_PARAMETERS(1); const char* sName; if (!pH->GetParam(1, sName)) { m_pScriptSystem->RaiseError("GetVariable invalid parameter type %s, string expected", ScriptVarTypeAsCStr(pH->GetParamType(1))); return pH->EndFunctionNull(); } ICVar* pVar = m_pSystem->GetIConsole()->GetCVar(sName); if (!pVar) { m_pScriptSystem->RaiseError("GetVariable invalid variable name \"%s\": no such variable found", sName); return pH->EndFunctionNull(); } switch (pVar->GetType()) { case CVAR_INT: return pH->EndFunction(pVar->GetIVal()); case CVAR_FLOAT: return pH->EndFunction(pVar->GetFVal()); case CVAR_STRING: return pH->EndFunction(pVar->GetString()); default: return pH->EndFunctionNull(); } } int CScriptObjectGame::LoadLevel(IFunctionHandler* pH) { CHECK_PARAMETERS(1); GetISystem()->Log("Loading level"); const char* szLevelName = nullptr; if (pH->GetParam(1, szLevelName)) { return pH->EndFunction(m_pGame->loadScene(szLevelName)); } return pH->EndFunctionNull(); } int CScriptObjectGame::AddCommand(IFunctionHandler* pH) { int nPCount = pH->GetParamCount(); const char* sName; const char* sCommand; const char* sHelp = NULL; int iflags = 0; pH->GetParam(1, sName); if (nPCount > 1) { pH->GetParam(2, sCommand); if (nPCount > 2) { if (!pH->GetParam(3, sHelp)) sHelp = NULL; } if (sHelp) m_pConsole->AddCommand(sName, sCommand, 0, sHelp); else m_pConsole->AddCommand(sName, sCommand, 0/*VF_NOHELP*/, ""); } return pH->EndFunction(); } int CScriptObjectGame::SavePlayerPos(IFunctionHandler* pH) { const char* sName = NULL; const char* sDesc = NULL; pH->GetParam(1, sName); pH->GetParam(2, sDesc); if (sName) m_pGame->DevMode_SavePlayerPos(0, sName, sDesc); return pH->EndFunction(); } int CScriptObjectGame::LoadPlayerPos(IFunctionHandler* pH) { CHECK_PARAMETERS(2); const char* sName; int index; if (pH->GetParam(1, index)) { if (pH->GetParam(2, sName)) { m_pGame->DevMode_LoadPlayerPos(index, sName); } } return pH->EndFunction(); }
25.137725
150
0.68612
732198936b16b5117cc7dcfd2dd2ace65dae8bc4
1,235
cpp
C++
src/expectation.cpp
xchrishawk/spookshow
139910e97330a387213a504ae77c2f3dbcb06134
[ "MIT" ]
null
null
null
src/expectation.cpp
xchrishawk/spookshow
139910e97330a387213a504ae77c2f3dbcb06134
[ "MIT" ]
null
null
null
src/expectation.cpp
xchrishawk/spookshow
139910e97330a387213a504ae77c2f3dbcb06134
[ "MIT" ]
null
null
null
/** * @file expectation.cpp * @author Chris Vig (chris@invictus.so) * @date 2016/12/30 */ /* -- Includes -- */ #include <sstream> #include <string> #include <spookshow/spookshow.hpp> /* -- Namespaces -- */ using namespace spookshow; /* -- Procedures -- */ expectation::expectation(const std::string& name, int required_count) : m_name(name), m_required_count(required_count), m_order(expectation_order::current_order()), m_count(0) { if (m_order) m_order->enqueue_expectation(this); } expectation::~expectation() { if (is_fulfilled()) return; std::ostringstream message; message << "Unfulfilled expectation! [" << name() << "] Expected " << m_required_count << " call" << (m_required_count == 1 ? "" : "s") << ", received " << m_count << " call" << (m_count == 1 ? "" : "s") << "."; internal::handle_failure(message.str()); } void expectation::fulfill() { if (m_order && m_count == 0) { if (m_order->is_expectation_next(this)) m_order->dequeue_expectation(); else { std::ostringstream message; message << "Expectation fulfilled out of order! [" << name() << "]"; internal::handle_failure(message.str()); } } ++m_count; }
21.666667
95
0.610526
7322d739c7995fac1a0a4f8867ad8953c1ae43c2
2,749
cpp
C++
Codeforces/1083C.cpp
HeRaNO/OI-ICPC-Codes
4a4639cd3e347b472520065ca6ab8caadde6906d
[ "MIT" ]
18
2019-01-01T13:16:59.000Z
2022-02-28T04:51:50.000Z
Codeforces/1083C.cpp
HeRaNO/OI-ICPC-Codes
4a4639cd3e347b472520065ca6ab8caadde6906d
[ "MIT" ]
null
null
null
Codeforces/1083C.cpp
HeRaNO/OI-ICPC-Codes
4a4639cd3e347b472520065ca6ab8caadde6906d
[ "MIT" ]
5
2019-09-13T08:48:17.000Z
2022-02-19T06:59:03.000Z
#include <cstdio> #include <vector> #include <algorithm> #define MAXN 200005 using namespace std; pair <int,int> x[1<<19],now; int n,T,R,ans,o,lg[MAXN<<1],pt[MAXN],p[MAXN],pos[MAXN],dep[MAXN<<1]; int fa[19][MAXN<<1],euler[MAXN<<1]; vector <int> g[MAXN]; inline void dfs(int x,int deep) { pt[x]=++R;euler[R]=x;dep[R]=deep; for (auto v:g[x]) { dfs(v,deep+1); euler[++R]=x;dep[R]=deep; } return ; } inline void RMQLCA() { dfs(1,0); for (int i=1;i<=R;i++) fa[0][i]=i; for (int i=2;i<=R;i++) lg[i]=lg[i>>1]+1; for (int j=1;j<=lg[R];j++) for (int i=1;i+(1<<j)-1<=R;i++) { int a=fa[j-1][i],b=fa[j-1][i+(1<<(j-1))]; fa[j][i]=dep[a]<=dep[b]?a:b; } return ; } inline int LCA(int x,int y) { x=pt[x];y=pt[y]; if (x>y) swap(x,y); int t=lg[y-x+1];int a=fa[t][x],b=fa[t][y-(1<<t)+1]; return dep[a]<=dep[b]?euler[a]:euler[b]; } inline bool On(int u,int v,int x) { return ((LCA(x,u)==x)^(LCA(x,v)==x))||(LCA(u,v)==x); } inline bool On(int x,int y,int u,int v) { if (!~x||!~y||!~u||!~v) return false; return On(x,y,u)&&On(x,y,v); } inline pair<int,int> PushUp(pair<int,int> l,pair<int,int> r) { pair <int,int> ans={-1,-1}; int ll=l.first,lr=l.second,rl=r.first,rr=r.second; if (On(ll,lr,rl,rr)) ans={ll,lr}; else if (On(ll,rl,lr,rr)) ans={ll,rl}; else if (On(ll,rr,lr,rl)) ans={ll,rr}; else if (On(lr,rl,ll,rr)) ans={lr,rl}; else if (On(lr,rr,ll,rl)) ans={lr,rr}; else if (On(rl,rr,ll,lr)) ans={rl,rr}; return ans; } void BuildTree(int u,int l,int r) { if (l+1==r){x[u]={pos[l],pos[l]};return ;} int m=l+r>>1;BuildTree(u<<1,l,m);BuildTree(u<<1|1,m,r); x[u]=PushUp(x[u<<1],x[u<<1|1]); return ; } inline void modify(int u,int p,int v,int pl,int pr) { if (pl+1==pr){x[u]={v,v};return ;} int m=pl+pr>>1;p<m?modify(u<<1,p,v,pl,m):modify(u<<1|1,p,v,m,pr); x[u]=PushUp(x[u<<1],x[u<<1|1]); return ; } inline void query(int u,int l,int r) { if (l+1==r) { pair <int,int> t=PushUp(now,x[u]); if (!~now.first||(~t.first)) { ans=max(ans,l+1); if (~now.first) now=t; else now=x[u]; } return ; } int m=l+r>>1;pair <int,int> t=PushUp(now,x[u<<1]); if (~x[u<<1].first&&(!~now.first||(~t.first))) { if (~now.first) now=t; else now=x[u<<1]; ans=max(ans,m);query(u<<1|1,m,r); } else query(u<<1,l,m); return ; } int main() { scanf("%d",&n); for (int i=1;i<=n;i++) scanf("%d",&p[i]),pos[p[i]]=i; for (int i=2,x;i<=n;i++) scanf("%d",&x),g[x].push_back(i); RMQLCA();BuildTree(1,0,n); scanf("%d",&T); while (T--) { scanf("%d",&o); if (o==1) { int x,y; scanf("%d %d",&x,&y); modify(1,p[y],pos[p[x]],0,n); modify(1,p[x],pos[p[y]],0,n); swap(pos[p[x]],pos[p[y]]);swap(p[x],p[y]); } else { ans=0;now={-1,-1};query(1,0,n); printf("%d\n",ans); } } return 0; }
20.514925
68
0.535831
73237bc7569f20482fbf5194613ab171105ba3d2
2,515
cc
C++
media/capture/video/chromeos/pixel_format_utils.cc
zealoussnow/chromium
fd8a8914ca0183f0add65ae55f04e287543c7d4a
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
14,668
2015-01-01T01:57:10.000Z
2022-03-31T23:33:32.000Z
media/capture/video/chromeos/pixel_format_utils.cc
zealoussnow/chromium
fd8a8914ca0183f0add65ae55f04e287543c7d4a
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
86
2015-10-21T13:02:42.000Z
2022-03-14T07:50:50.000Z
media/capture/video/chromeos/pixel_format_utils.cc
zealoussnow/chromium
fd8a8914ca0183f0add65ae55f04e287543c7d4a
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
5,941
2015-01-02T11:32:21.000Z
2022-03-31T16:35:46.000Z
// Copyright 2017 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "media/capture/video/chromeos/pixel_format_utils.h" #include <drm_fourcc.h> namespace media { namespace { struct SupportedFormat { cros::mojom::HalPixelFormat hal_format; ChromiumPixelFormat cr_format; } const kSupportedFormats[] = { // The Android camera HAL v3 has three types of mandatory pixel formats: // // 1. HAL_PIXEL_FORMAT_YCbCr_420_888 (YUV flexible format). // 2. HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED (platform-specific format). // 3. HAL_PIXEL_FORMAT_BLOB (for JPEG). // // We can't use HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED as it is highly // platform specific and there is no way for Chrome to query the exact // pixel layout of the implementation-defined buffer. // // On Android the framework requests the preview stream with the // implementation-defined format, and as a result some camera HALs support // only implementation-defined preview buffers. We should use the video // capture stream in Chrome VCD as it is mandatory for the camera HAL to // support YUV flexbile format video streams. {cros::mojom::HalPixelFormat::HAL_PIXEL_FORMAT_YCbCr_420_888, {PIXEL_FORMAT_NV12, gfx::BufferFormat::YUV_420_BIPLANAR}}, // FIXME(jcliang): MJPEG is not accurate; we should have BLOB or JPEG {cros::mojom::HalPixelFormat::HAL_PIXEL_FORMAT_BLOB, {PIXEL_FORMAT_MJPEG, gfx::BufferFormat::R_8}}, // Add more mappings when we have more devices. }; } // namespace std::vector<ChromiumPixelFormat> PixFormatHalToChromium( cros::mojom::HalPixelFormat from) { std::vector<ChromiumPixelFormat> ret; for (const auto& it : kSupportedFormats) { if (it.hal_format == from) { ret.push_back(it.cr_format); } } return ret; } uint32_t PixFormatVideoToDrm(VideoPixelFormat from) { switch (from) { case PIXEL_FORMAT_NV12: return DRM_FORMAT_NV12; case PIXEL_FORMAT_MJPEG: return DRM_FORMAT_R8; default: // Unsupported format. return 0; } } absl::optional<gfx::BufferFormat> PixFormatVideoToGfx( VideoPixelFormat pixel_format) { switch (pixel_format) { case PIXEL_FORMAT_MJPEG: return gfx::BufferFormat::R_8; case PIXEL_FORMAT_NV12: return gfx::BufferFormat::YUV_420_BIPLANAR; default: return absl::nullopt; } } } // namespace media
32.24359
79
0.719284
7323ab57a708ec79f17cb1ab13254ca47091ce6c
49,659
cpp
C++
opencv-2.4.11/modules/ml/src/ann_mlp.cpp
durai-chellamuthu/node-opencv
a9c18c77b2fe0f62f2f8376854bdf33de71f5dc3
[ "MIT" ]
13
2015-03-01T07:03:17.000Z
2021-11-03T06:33:31.000Z
modules/ml/src/ann_mlp.cpp
ehren/opencv
abe37659ccfc2b399e7543eee1a43900c9a7099e
[ "BSD-3-Clause" ]
null
null
null
modules/ml/src/ann_mlp.cpp
ehren/opencv
abe37659ccfc2b399e7543eee1a43900c9a7099e
[ "BSD-3-Clause" ]
32
2015-06-08T08:59:51.000Z
2021-08-05T09:54:16.000Z
/*M/////////////////////////////////////////////////////////////////////////////////////// // // IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. // // By downloading, copying, installing or using the software you agree to this license. // If you do not agree to this license, do not download, install, // copy or use the software. // // // Intel License Agreement // // Copyright (C) 2000, Intel Corporation, all rights reserved. // Third party copyrights are property of their respective owners. // // Redistribution and use in source and binary forms, with or without modification, // are permitted provided that the following conditions are met: // // * Redistribution's of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // // * Redistribution's in binary form must reproduce the above copyright notice, // this list of conditions and the following disclaimer in the documentation // and/or other materials provided with the distribution. // // * The name of Intel Corporation may not be used to endorse or promote products // derived from this software without specific prior written permission. // // This software is provided by the copyright holders and contributors "as is" and // any express or implied warranties, including, but not limited to, the implied // warranties of merchantability and fitness for a particular purpose are disclaimed. // In no event shall the Intel Corporation or contributors be liable for any direct, // indirect, incidental, special, exemplary, or consequential damages // (including, but not limited to, procurement of substitute goods or services; // loss of use, data, or profits; or business interruption) however caused // and on any theory of liability, whether in contract, strict liability, // or tort (including negligence or otherwise) arising in any way out of // the use of this software, even if advised of the possibility of such damage. // //M*/ #include "precomp.hpp" CvANN_MLP_TrainParams::CvANN_MLP_TrainParams() { term_crit = cvTermCriteria( CV_TERMCRIT_ITER + CV_TERMCRIT_EPS, 1000, 0.01 ); train_method = RPROP; bp_dw_scale = bp_moment_scale = 0.1; rp_dw0 = 0.1; rp_dw_plus = 1.2; rp_dw_minus = 0.5; rp_dw_min = FLT_EPSILON; rp_dw_max = 50.; } CvANN_MLP_TrainParams::CvANN_MLP_TrainParams( CvTermCriteria _term_crit, int _train_method, double _param1, double _param2 ) { term_crit = _term_crit; train_method = _train_method; bp_dw_scale = bp_moment_scale = 0.1; rp_dw0 = 1.; rp_dw_plus = 1.2; rp_dw_minus = 0.5; rp_dw_min = FLT_EPSILON; rp_dw_max = 50.; if( train_method == RPROP ) { rp_dw0 = _param1; if( rp_dw0 < FLT_EPSILON ) rp_dw0 = 1.; rp_dw_min = _param2; rp_dw_min = MAX( rp_dw_min, 0 ); } else if( train_method == BACKPROP ) { bp_dw_scale = _param1; if( bp_dw_scale <= 0 ) bp_dw_scale = 0.1; bp_dw_scale = MAX( bp_dw_scale, 1e-3 ); bp_dw_scale = MIN( bp_dw_scale, 1 ); bp_moment_scale = _param2; if( bp_moment_scale < 0 ) bp_moment_scale = 0.1; bp_moment_scale = MIN( bp_moment_scale, 1 ); } else train_method = RPROP; } CvANN_MLP_TrainParams::~CvANN_MLP_TrainParams() { } CvANN_MLP::CvANN_MLP() { layer_sizes = wbuf = 0; min_val = max_val = min_val1 = max_val1 = 0.; weights = 0; rng = &cv::theRNG(); default_model_name = "my_nn"; clear(); } CvANN_MLP::CvANN_MLP( const CvMat* _layer_sizes, int _activ_func, double _f_param1, double _f_param2 ) { layer_sizes = wbuf = 0; min_val = max_val = min_val1 = max_val1 = 0.; weights = 0; rng = &cv::theRNG(); default_model_name = "my_nn"; create( _layer_sizes, _activ_func, _f_param1, _f_param2 ); } CvANN_MLP::~CvANN_MLP() { clear(); } void CvANN_MLP::clear() { cvReleaseMat( &layer_sizes ); cvReleaseMat( &wbuf ); cvFree( &weights ); activ_func = SIGMOID_SYM; f_param1 = f_param2 = 1; max_buf_sz = 1 << 12; } void CvANN_MLP::set_activ_func( int _activ_func, double _f_param1, double _f_param2 ) { CV_FUNCNAME( "CvANN_MLP::set_activ_func" ); __BEGIN__; if( _activ_func < 0 || _activ_func > GAUSSIAN ) CV_ERROR( CV_StsOutOfRange, "Unknown activation function" ); activ_func = _activ_func; switch( activ_func ) { case SIGMOID_SYM: max_val = 0.95; min_val = -max_val; max_val1 = 0.98; min_val1 = -max_val1; if( fabs(_f_param1) < FLT_EPSILON ) _f_param1 = 2./3; if( fabs(_f_param2) < FLT_EPSILON ) _f_param2 = 1.7159; break; case GAUSSIAN: max_val = 1.; min_val = 0.05; max_val1 = 1.; min_val1 = 0.02; if( fabs(_f_param1) < FLT_EPSILON ) _f_param1 = 1.; if( fabs(_f_param2) < FLT_EPSILON ) _f_param2 = 1.; break; default: min_val = max_val = min_val1 = max_val1 = 0.; _f_param1 = 1.; _f_param2 = 0.; } f_param1 = _f_param1; f_param2 = _f_param2; __END__; } void CvANN_MLP::init_weights() { int i, j, k; for( i = 1; i < layer_sizes->cols; i++ ) { int n1 = layer_sizes->data.i[i-1]; int n2 = layer_sizes->data.i[i]; double val = 0, G = n2 > 2 ? 0.7*pow((double)n1,1./(n2-1)) : 1.; double* w = weights[i]; // initialize weights using Nguyen-Widrow algorithm for( j = 0; j < n2; j++ ) { double s = 0; for( k = 0; k <= n1; k++ ) { val = rng->uniform(0., 1.)*2-1.; w[k*n2 + j] = val; s += fabs(val); } if( i < layer_sizes->cols - 1 ) { s = 1./(s - fabs(val)); for( k = 0; k <= n1; k++ ) w[k*n2 + j] *= s; w[n1*n2 + j] *= G*(-1+j*2./n2); } } } } void CvANN_MLP::create( const CvMat* _layer_sizes, int _activ_func, double _f_param1, double _f_param2 ) { CV_FUNCNAME( "CvANN_MLP::create" ); __BEGIN__; int i, l_step, l_count, buf_sz = 0; int *l_src, *l_dst; clear(); if( !CV_IS_MAT(_layer_sizes) || (_layer_sizes->cols != 1 && _layer_sizes->rows != 1) || CV_MAT_TYPE(_layer_sizes->type) != CV_32SC1 ) CV_ERROR( CV_StsBadArg, "The array of layer neuron counters must be an integer vector" ); CV_CALL( set_activ_func( _activ_func, _f_param1, _f_param2 )); l_count = _layer_sizes->rows + _layer_sizes->cols - 1; l_src = _layer_sizes->data.i; l_step = CV_IS_MAT_CONT(_layer_sizes->type) ? 1 : _layer_sizes->step / sizeof(l_src[0]); CV_CALL( layer_sizes = cvCreateMat( 1, l_count, CV_32SC1 )); l_dst = layer_sizes->data.i; max_count = 0; for( i = 0; i < l_count; i++ ) { int n = l_src[i*l_step]; if( n < 1 + (0 < i && i < l_count-1)) CV_ERROR( CV_StsOutOfRange, "there should be at least one input and one output " "and every hidden layer must have more than 1 neuron" ); l_dst[i] = n; max_count = MAX( max_count, n ); if( i > 0 ) buf_sz += (l_dst[i-1]+1)*n; } buf_sz += (l_dst[0] + l_dst[l_count-1]*2)*2; CV_CALL( wbuf = cvCreateMat( 1, buf_sz, CV_64F )); CV_CALL( weights = (double**)cvAlloc( (l_count+2)*sizeof(weights[0]) )); weights[0] = wbuf->data.db; weights[1] = weights[0] + l_dst[0]*2; for( i = 1; i < l_count; i++ ) weights[i+1] = weights[i] + (l_dst[i-1] + 1)*l_dst[i]; weights[l_count+1] = weights[l_count] + l_dst[l_count-1]*2; __END__; } float CvANN_MLP::predict( const CvMat* _inputs, CvMat* _outputs ) const { int i, j, n, dn = 0, l_count, dn0, buf_sz, min_buf_sz; if( !layer_sizes ) CV_Error( CV_StsError, "The network has not been initialized" ); if( !CV_IS_MAT(_inputs) || !CV_IS_MAT(_outputs) || !CV_ARE_TYPES_EQ(_inputs,_outputs) || (CV_MAT_TYPE(_inputs->type) != CV_32FC1 && CV_MAT_TYPE(_inputs->type) != CV_64FC1) || _inputs->rows != _outputs->rows ) CV_Error( CV_StsBadArg, "Both input and output must be floating-point matrices " "of the same type and have the same number of rows" ); if( _inputs->cols != layer_sizes->data.i[0] ) CV_Error( CV_StsBadSize, "input matrix must have the same number of columns as " "the number of neurons in the input layer" ); if( _outputs->cols != layer_sizes->data.i[layer_sizes->cols - 1] ) CV_Error( CV_StsBadSize, "output matrix must have the same number of columns as " "the number of neurons in the output layer" ); n = dn0 = _inputs->rows; min_buf_sz = 2*max_count; buf_sz = n*min_buf_sz; if( buf_sz > max_buf_sz ) { dn0 = max_buf_sz/min_buf_sz; dn0 = MAX( dn0, 1 ); buf_sz = dn0*min_buf_sz; } cv::AutoBuffer<double> buf(buf_sz); l_count = layer_sizes->cols; for( i = 0; i < n; i += dn ) { CvMat hdr[2], _w, *layer_in = &hdr[0], *layer_out = &hdr[1], *temp; dn = MIN( dn0, n - i ); cvGetRows( _inputs, layer_in, i, i + dn ); cvInitMatHeader( layer_out, dn, layer_in->cols, CV_64F, &buf[0] ); scale_input( layer_in, layer_out ); CV_SWAP( layer_in, layer_out, temp ); for( j = 1; j < l_count; j++ ) { double* data = buf + (j&1 ? max_count*dn0 : 0); int cols = layer_sizes->data.i[j]; cvInitMatHeader( layer_out, dn, cols, CV_64F, data ); cvInitMatHeader( &_w, layer_in->cols, layer_out->cols, CV_64F, weights[j] ); cvGEMM( layer_in, &_w, 1, 0, 0, layer_out ); calc_activ_func( layer_out, _w.data.db + _w.rows*_w.cols ); CV_SWAP( layer_in, layer_out, temp ); } cvGetRows( _outputs, layer_out, i, i + dn ); scale_output( layer_in, layer_out ); } return 0.f; } void CvANN_MLP::scale_input( const CvMat* _src, CvMat* _dst ) const { int i, j, cols = _src->cols; double* dst = _dst->data.db; const double* w = weights[0]; int step = _src->step; if( CV_MAT_TYPE( _src->type ) == CV_32F ) { const float* src = _src->data.fl; step /= sizeof(src[0]); for( i = 0; i < _src->rows; i++, src += step, dst += cols ) for( j = 0; j < cols; j++ ) dst[j] = src[j]*w[j*2] + w[j*2+1]; } else { const double* src = _src->data.db; step /= sizeof(src[0]); for( i = 0; i < _src->rows; i++, src += step, dst += cols ) for( j = 0; j < cols; j++ ) dst[j] = src[j]*w[j*2] + w[j*2+1]; } } void CvANN_MLP::scale_output( const CvMat* _src, CvMat* _dst ) const { int i, j, cols = _src->cols; const double* src = _src->data.db; const double* w = weights[layer_sizes->cols]; int step = _dst->step; if( CV_MAT_TYPE( _dst->type ) == CV_32F ) { float* dst = _dst->data.fl; step /= sizeof(dst[0]); for( i = 0; i < _src->rows; i++, src += cols, dst += step ) for( j = 0; j < cols; j++ ) dst[j] = (float)(src[j]*w[j*2] + w[j*2+1]); } else { double* dst = _dst->data.db; step /= sizeof(dst[0]); for( i = 0; i < _src->rows; i++, src += cols, dst += step ) for( j = 0; j < cols; j++ ) dst[j] = src[j]*w[j*2] + w[j*2+1]; } } void CvANN_MLP::calc_activ_func( CvMat* sums, const double* bias ) const { int i, j, n = sums->rows, cols = sums->cols; double* data = sums->data.db; double scale = 0, scale2 = f_param2; switch( activ_func ) { case IDENTITY: scale = 1.; break; case SIGMOID_SYM: scale = -f_param1; break; case GAUSSIAN: scale = -f_param1*f_param1; break; default: ; } assert( CV_IS_MAT_CONT(sums->type) ); if( activ_func != GAUSSIAN ) { for( i = 0; i < n; i++, data += cols ) for( j = 0; j < cols; j++ ) data[j] = (data[j] + bias[j])*scale; if( activ_func == IDENTITY ) return; } else { for( i = 0; i < n; i++, data += cols ) for( j = 0; j < cols; j++ ) { double t = data[j] + bias[j]; data[j] = t*t*scale; } } cvExp( sums, sums ); n *= cols; data -= n; switch( activ_func ) { case SIGMOID_SYM: for( i = 0; i <= n - 4; i += 4 ) { double x0 = 1.+data[i], x1 = 1.+data[i+1], x2 = 1.+data[i+2], x3 = 1.+data[i+3]; double a = x0*x1, b = x2*x3, d = scale2/(a*b), t0, t1; a *= d; b *= d; t0 = (2 - x0)*b*x1; t1 = (2 - x1)*b*x0; data[i] = t0; data[i+1] = t1; t0 = (2 - x2)*a*x3; t1 = (2 - x3)*a*x2; data[i+2] = t0; data[i+3] = t1; } for( ; i < n; i++ ) { double t = scale2*(1. - data[i])/(1. + data[i]); data[i] = t; } break; case GAUSSIAN: for( i = 0; i < n; i++ ) data[i] = scale2*data[i]; break; default: ; } } void CvANN_MLP::calc_activ_func_deriv( CvMat* _xf, CvMat* _df, const double* bias ) const { int i, j, n = _xf->rows, cols = _xf->cols; double* xf = _xf->data.db; double* df = _df->data.db; double scale, scale2 = f_param2; assert( CV_IS_MAT_CONT( _xf->type & _df->type ) ); if( activ_func == IDENTITY ) { for( i = 0; i < n; i++, xf += cols, df += cols ) for( j = 0; j < cols; j++ ) { xf[j] += bias[j]; df[j] = 1; } return; } else if( activ_func == GAUSSIAN ) { scale = -f_param1*f_param1; scale2 *= scale; for( i = 0; i < n; i++, xf += cols, df += cols ) for( j = 0; j < cols; j++ ) { double t = xf[j] + bias[j]; df[j] = t*2*scale2; xf[j] = t*t*scale; } cvExp( _xf, _xf ); n *= cols; xf -= n; df -= n; for( i = 0; i < n; i++ ) df[i] *= xf[i]; } else { scale = f_param1; for( i = 0; i < n; i++, xf += cols, df += cols ) for( j = 0; j < cols; j++ ) { xf[j] = (xf[j] + bias[j])*scale; df[j] = -fabs(xf[j]); } cvExp( _df, _df ); n *= cols; xf -= n; df -= n; // ((1+exp(-ax))^-1)'=a*((1+exp(-ax))^-2)*exp(-ax); // ((1-exp(-ax))/(1+exp(-ax)))'=(a*exp(-ax)*(1+exp(-ax)) + a*exp(-ax)*(1-exp(-ax)))/(1+exp(-ax))^2= // 2*a*exp(-ax)/(1+exp(-ax))^2 scale *= 2*f_param2; for( i = 0; i < n; i++ ) { int s0 = xf[i] > 0 ? 1 : -1; double t0 = 1./(1. + df[i]); double t1 = scale*df[i]*t0*t0; t0 *= scale2*(1. - df[i])*s0; df[i] = t1; xf[i] = t0; } } } void CvANN_MLP::calc_input_scale( const CvVectors* vecs, int flags ) { bool reset_weights = (flags & UPDATE_WEIGHTS) == 0; bool no_scale = (flags & NO_INPUT_SCALE) != 0; double* scale = weights[0]; int count = vecs->count; if( reset_weights ) { int i, j, vcount = layer_sizes->data.i[0]; int type = vecs->type; double a = no_scale ? 1. : 0.; for( j = 0; j < vcount; j++ ) scale[2*j] = a, scale[j*2+1] = 0.; if( no_scale ) return; for( i = 0; i < count; i++ ) { const float* f = vecs->data.fl[i]; const double* d = vecs->data.db[i]; for( j = 0; j < vcount; j++ ) { double t = type == CV_32F ? (double)f[j] : d[j]; scale[j*2] += t; scale[j*2+1] += t*t; } } for( j = 0; j < vcount; j++ ) { double s = scale[j*2], s2 = scale[j*2+1]; double m = s/count, sigma2 = s2/count - m*m; scale[j*2] = sigma2 < DBL_EPSILON ? 1 : 1./sqrt(sigma2); scale[j*2+1] = -m*scale[j*2]; } } } void CvANN_MLP::calc_output_scale( const CvVectors* vecs, int flags ) { int i, j, vcount = layer_sizes->data.i[layer_sizes->cols-1]; int type = vecs->type; double m = min_val, M = max_val, m1 = min_val1, M1 = max_val1; bool reset_weights = (flags & UPDATE_WEIGHTS) == 0; bool no_scale = (flags & NO_OUTPUT_SCALE) != 0; int l_count = layer_sizes->cols; double* scale = weights[l_count]; double* inv_scale = weights[l_count+1]; int count = vecs->count; CV_FUNCNAME( "CvANN_MLP::calc_output_scale" ); __BEGIN__; if( reset_weights ) { double a0 = no_scale ? 1 : DBL_MAX, b0 = no_scale ? 0 : -DBL_MAX; for( j = 0; j < vcount; j++ ) { scale[2*j] = inv_scale[2*j] = a0; scale[j*2+1] = inv_scale[2*j+1] = b0; } if( no_scale ) EXIT; } for( i = 0; i < count; i++ ) { const float* f = vecs->data.fl[i]; const double* d = vecs->data.db[i]; for( j = 0; j < vcount; j++ ) { double t = type == CV_32F ? (double)f[j] : d[j]; if( reset_weights ) { double mj = scale[j*2], Mj = scale[j*2+1]; if( mj > t ) mj = t; if( Mj < t ) Mj = t; scale[j*2] = mj; scale[j*2+1] = Mj; } else { t = t*inv_scale[j*2] + inv_scale[2*j+1]; if( t < m1 || t > M1 ) CV_ERROR( CV_StsOutOfRange, "Some of new output training vector components run exceed the original range too much" ); } } } if( reset_weights ) for( j = 0; j < vcount; j++ ) { // map mj..Mj to m..M double mj = scale[j*2], Mj = scale[j*2+1]; double a, b; double delta = Mj - mj; if( delta < DBL_EPSILON ) a = 1, b = (M + m - Mj - mj)*0.5; else a = (M - m)/delta, b = m - mj*a; inv_scale[j*2] = a; inv_scale[j*2+1] = b; a = 1./a; b = -b*a; scale[j*2] = a; scale[j*2+1] = b; } __END__; } bool CvANN_MLP::prepare_to_train( const CvMat* _inputs, const CvMat* _outputs, const CvMat* _sample_weights, const CvMat* _sample_idx, CvVectors* _ivecs, CvVectors* _ovecs, double** _sw, int _flags ) { bool ok = false; CvMat* sample_idx = 0; CvVectors ivecs, ovecs; double* sw = 0; int count = 0; CV_FUNCNAME( "CvANN_MLP::prepare_to_train" ); ivecs.data.ptr = ovecs.data.ptr = 0; assert( _ivecs && _ovecs ); __BEGIN__; const int* sidx = 0; int i, sw_type = 0, sw_count = 0; int sw_step = 0; double sw_sum = 0; if( !layer_sizes ) CV_ERROR( CV_StsError, "The network has not been created. Use method create or the appropriate constructor" ); if( !CV_IS_MAT(_inputs) || (CV_MAT_TYPE(_inputs->type) != CV_32FC1 && CV_MAT_TYPE(_inputs->type) != CV_64FC1) || _inputs->cols != layer_sizes->data.i[0] ) CV_ERROR( CV_StsBadArg, "input training data should be a floating-point matrix with" "the number of rows equal to the number of training samples and " "the number of columns equal to the size of 0-th (input) layer" ); if( !CV_IS_MAT(_outputs) || (CV_MAT_TYPE(_outputs->type) != CV_32FC1 && CV_MAT_TYPE(_outputs->type) != CV_64FC1) || _outputs->cols != layer_sizes->data.i[layer_sizes->cols - 1] ) CV_ERROR( CV_StsBadArg, "output training data should be a floating-point matrix with" "the number of rows equal to the number of training samples and " "the number of columns equal to the size of last (output) layer" ); if( _inputs->rows != _outputs->rows ) CV_ERROR( CV_StsUnmatchedSizes, "The numbers of input and output samples do not match" ); if( _sample_idx ) { CV_CALL( sample_idx = cvPreprocessIndexArray( _sample_idx, _inputs->rows )); sidx = sample_idx->data.i; count = sample_idx->cols + sample_idx->rows - 1; } else count = _inputs->rows; if( _sample_weights ) { if( !CV_IS_MAT(_sample_weights) ) CV_ERROR( CV_StsBadArg, "sample_weights (if passed) must be a valid matrix" ); sw_type = CV_MAT_TYPE(_sample_weights->type); sw_count = _sample_weights->cols + _sample_weights->rows - 1; if( (sw_type != CV_32FC1 && sw_type != CV_64FC1) || (_sample_weights->cols != 1 && _sample_weights->rows != 1) || (sw_count != count && sw_count != _inputs->rows) ) CV_ERROR( CV_StsBadArg, "sample_weights must be 1d floating-point vector containing weights " "of all or selected training samples" ); sw_step = CV_IS_MAT_CONT(_sample_weights->type) ? 1 : _sample_weights->step/CV_ELEM_SIZE(sw_type); CV_CALL( sw = (double*)cvAlloc( count*sizeof(sw[0]) )); } CV_CALL( ivecs.data.ptr = (uchar**)cvAlloc( count*sizeof(ivecs.data.ptr[0]) )); CV_CALL( ovecs.data.ptr = (uchar**)cvAlloc( count*sizeof(ovecs.data.ptr[0]) )); ivecs.type = CV_MAT_TYPE(_inputs->type); ovecs.type = CV_MAT_TYPE(_outputs->type); ivecs.count = ovecs.count = count; for( i = 0; i < count; i++ ) { int idx = sidx ? sidx[i] : i; ivecs.data.ptr[i] = _inputs->data.ptr + idx*_inputs->step; ovecs.data.ptr[i] = _outputs->data.ptr + idx*_outputs->step; if( sw ) { int si = sw_count == count ? i : idx; double w = sw_type == CV_32FC1 ? (double)_sample_weights->data.fl[si*sw_step] : _sample_weights->data.db[si*sw_step]; sw[i] = w; if( w < 0 ) CV_ERROR( CV_StsOutOfRange, "some of sample weights are negative" ); sw_sum += w; } } // normalize weights if( sw ) { sw_sum = sw_sum > DBL_EPSILON ? 1./sw_sum : 0; for( i = 0; i < count; i++ ) sw[i] *= sw_sum; } calc_input_scale( &ivecs, _flags ); CV_CALL( calc_output_scale( &ovecs, _flags )); ok = true; __END__; if( !ok ) { cvFree( &ivecs.data.ptr ); cvFree( &ovecs.data.ptr ); cvFree( &sw ); } cvReleaseMat( &sample_idx ); *_ivecs = ivecs; *_ovecs = ovecs; *_sw = sw; return ok; } int CvANN_MLP::train( const CvMat* _inputs, const CvMat* _outputs, const CvMat* _sample_weights, const CvMat* _sample_idx, CvANN_MLP_TrainParams _params, int flags ) { const int MAX_ITER = 1000; const double DEFAULT_EPSILON = FLT_EPSILON; double* sw = 0; CvVectors x0, u; int iter = -1; x0.data.ptr = u.data.ptr = 0; CV_FUNCNAME( "CvANN_MLP::train" ); __BEGIN__; int max_iter; double epsilon; params = _params; // initialize training data CV_CALL( prepare_to_train( _inputs, _outputs, _sample_weights, _sample_idx, &x0, &u, &sw, flags )); // ... and link weights if( !(flags & UPDATE_WEIGHTS) ) init_weights(); max_iter = params.term_crit.type & CV_TERMCRIT_ITER ? params.term_crit.max_iter : MAX_ITER; max_iter = MAX( max_iter, 1 ); epsilon = params.term_crit.type & CV_TERMCRIT_EPS ? params.term_crit.epsilon : DEFAULT_EPSILON; epsilon = MAX(epsilon, DBL_EPSILON); params.term_crit.type = CV_TERMCRIT_ITER + CV_TERMCRIT_EPS; params.term_crit.max_iter = max_iter; params.term_crit.epsilon = epsilon; if( params.train_method == CvANN_MLP_TrainParams::BACKPROP ) { CV_CALL( iter = train_backprop( x0, u, sw )); } else { CV_CALL( iter = train_rprop( x0, u, sw )); } __END__; cvFree( &x0.data.ptr ); cvFree( &u.data.ptr ); cvFree( &sw ); return iter; } int CvANN_MLP::train_backprop( CvVectors x0, CvVectors u, const double* sw ) { CvMat* dw = 0; CvMat* buf = 0; double **x = 0, **df = 0; CvMat* _idx = 0; int iter = -1, count = x0.count; CV_FUNCNAME( "CvANN_MLP::train_backprop" ); __BEGIN__; int i, j, k, ivcount, ovcount, l_count, total = 0, max_iter; double *buf_ptr; double prev_E = DBL_MAX*0.5, E = 0, epsilon; max_iter = params.term_crit.max_iter*count; epsilon = params.term_crit.epsilon*count; l_count = layer_sizes->cols; ivcount = layer_sizes->data.i[0]; ovcount = layer_sizes->data.i[l_count-1]; // allocate buffers for( i = 0; i < l_count; i++ ) total += layer_sizes->data.i[i] + 1; CV_CALL( dw = cvCreateMat( wbuf->rows, wbuf->cols, wbuf->type )); cvZero( dw ); CV_CALL( buf = cvCreateMat( 1, (total + max_count)*2, CV_64F )); CV_CALL( _idx = cvCreateMat( 1, count, CV_32SC1 )); for( i = 0; i < count; i++ ) _idx->data.i[i] = i; CV_CALL( x = (double**)cvAlloc( total*2*sizeof(x[0]) )); df = x + total; buf_ptr = buf->data.db; for( j = 0; j < l_count; j++ ) { x[j] = buf_ptr; df[j] = x[j] + layer_sizes->data.i[j]; buf_ptr += (df[j] - x[j])*2; } // run back-propagation loop /* y_i = w_i*x_{i-1} x_i = f(y_i) E = 1/2*||u - x_N||^2 grad_N = (x_N - u)*f'(y_i) dw_i(t) = momentum*dw_i(t-1) + dw_scale*x_{i-1}*grad_i w_i(t+1) = w_i(t) + dw_i(t) grad_{i-1} = w_i^t*grad_i */ for( iter = 0; iter < max_iter; iter++ ) { int idx = iter % count; double* w = weights[0]; double sweight = sw ? count*sw[idx] : 1.; CvMat _w, _dw, hdr1, hdr2, ghdr1, ghdr2, _df; CvMat *x1 = &hdr1, *x2 = &hdr2, *grad1 = &ghdr1, *grad2 = &ghdr2, *temp; if( idx == 0 ) { //printf("%d. E = %g\n", iter/count, E); if( fabs(prev_E - E) < epsilon ) break; prev_E = E; E = 0; // shuffle indices for( i = 0; i < count; i++ ) { int tt; j = (*rng)(count); k = (*rng)(count); CV_SWAP( _idx->data.i[j], _idx->data.i[k], tt ); } } idx = _idx->data.i[idx]; if( x0.type == CV_32F ) { const float* x0data = x0.data.fl[idx]; for( j = 0; j < ivcount; j++ ) x[0][j] = x0data[j]*w[j*2] + w[j*2 + 1]; } else { const double* x0data = x0.data.db[idx]; for( j = 0; j < ivcount; j++ ) x[0][j] = x0data[j]*w[j*2] + w[j*2 + 1]; } cvInitMatHeader( x1, 1, ivcount, CV_64F, x[0] ); // forward pass, compute y[i]=w*x[i-1], x[i]=f(y[i]), df[i]=f'(y[i]) for( i = 1; i < l_count; i++ ) { cvInitMatHeader( x2, 1, layer_sizes->data.i[i], CV_64F, x[i] ); cvInitMatHeader( &_w, x1->cols, x2->cols, CV_64F, weights[i] ); cvGEMM( x1, &_w, 1, 0, 0, x2 ); _df = *x2; _df.data.db = df[i]; calc_activ_func_deriv( x2, &_df, _w.data.db + _w.rows*_w.cols ); CV_SWAP( x1, x2, temp ); } cvInitMatHeader( grad1, 1, ovcount, CV_64F, buf_ptr ); *grad2 = *grad1; grad2->data.db = buf_ptr + max_count; w = weights[l_count+1]; // calculate error if( u.type == CV_32F ) { const float* udata = u.data.fl[idx]; for( k = 0; k < ovcount; k++ ) { double t = udata[k]*w[k*2] + w[k*2+1] - x[l_count-1][k]; grad1->data.db[k] = t*sweight; E += t*t; } } else { const double* udata = u.data.db[idx]; for( k = 0; k < ovcount; k++ ) { double t = udata[k]*w[k*2] + w[k*2+1] - x[l_count-1][k]; grad1->data.db[k] = t*sweight; E += t*t; } } E *= sweight; // backward pass, update weights for( i = l_count-1; i > 0; i-- ) { int n1 = layer_sizes->data.i[i-1], n2 = layer_sizes->data.i[i]; cvInitMatHeader( &_df, 1, n2, CV_64F, df[i] ); cvMul( grad1, &_df, grad1 ); cvInitMatHeader( &_w, n1+1, n2, CV_64F, weights[i] ); cvInitMatHeader( &_dw, n1+1, n2, CV_64F, dw->data.db + (weights[i] - weights[0]) ); cvInitMatHeader( x1, n1+1, 1, CV_64F, x[i-1] ); x[i-1][n1] = 1.; cvGEMM( x1, grad1, params.bp_dw_scale, &_dw, params.bp_moment_scale, &_dw ); cvAdd( &_w, &_dw, &_w ); if( i > 1 ) { grad2->cols = n1; _w.rows = n1; cvGEMM( grad1, &_w, 1, 0, 0, grad2, CV_GEMM_B_T ); } CV_SWAP( grad1, grad2, temp ); } } iter /= count; __END__; cvReleaseMat( &dw ); cvReleaseMat( &buf ); cvReleaseMat( &_idx ); cvFree( &x ); return iter; } struct rprop_loop : cv::ParallelLoopBody { rprop_loop(const CvANN_MLP* _point, double**& _weights, int& _count, int& _ivcount, CvVectors* _x0, int& _l_count, CvMat*& _layer_sizes, int& _ovcount, int& _max_count, CvVectors* _u, const double*& _sw, double& _inv_count, CvMat*& _dEdw, int& _dcount0, double* _E, int _buf_sz) { point = _point; weights = _weights; count = _count; ivcount = _ivcount; x0 = _x0; l_count = _l_count; layer_sizes = _layer_sizes; ovcount = _ovcount; max_count = _max_count; u = _u; sw = _sw; inv_count = _inv_count; dEdw = _dEdw; dcount0 = _dcount0; E = _E; buf_sz = _buf_sz; } const CvANN_MLP* point; double** weights; int count; int ivcount; CvVectors* x0; int l_count; CvMat* layer_sizes; int ovcount; int max_count; CvVectors* u; const double* sw; double inv_count; CvMat* dEdw; int dcount0; double* E; int buf_sz; void operator()( const cv::Range& range ) const { double* buf_ptr; double** x = 0; double **df = 0; int total = 0; for(int i = 0; i < l_count; i++ ) total += layer_sizes->data.i[i]; CvMat* buf; buf = cvCreateMat( 1, buf_sz, CV_64F ); x = (double**)cvAlloc( total*2*sizeof(x[0]) ); df = x + total; buf_ptr = buf->data.db; for(int i = 0; i < l_count; i++ ) { x[i] = buf_ptr; df[i] = x[i] + layer_sizes->data.i[i]*dcount0; buf_ptr += (df[i] - x[i])*2; } for(int si = range.start; si < range.end; si++ ) { if (si % dcount0 != 0) continue; int n1, n2, k; double* w; CvMat _w, _dEdw, hdr1, hdr2, ghdr1, ghdr2, _df; CvMat *x1, *x2, *grad1, *grad2, *temp; int dcount = 0; dcount = MIN(count - si , dcount0 ); w = weights[0]; grad1 = &ghdr1; grad2 = &ghdr2; x1 = &hdr1; x2 = &hdr2; // grab and preprocess input data if( x0->type == CV_32F ) { for(int i = 0; i < dcount; i++ ) { const float* x0data = x0->data.fl[si+i]; double* xdata = x[0]+i*ivcount; for(int j = 0; j < ivcount; j++ ) xdata[j] = x0data[j]*w[j*2] + w[j*2+1]; } } else for(int i = 0; i < dcount; i++ ) { const double* x0data = x0->data.db[si+i]; double* xdata = x[0]+i*ivcount; for(int j = 0; j < ivcount; j++ ) xdata[j] = x0data[j]*w[j*2] + w[j*2+1]; } cvInitMatHeader( x1, dcount, ivcount, CV_64F, x[0] ); // forward pass, compute y[i]=w*x[i-1], x[i]=f(y[i]), df[i]=f'(y[i]) for(int i = 1; i < l_count; i++ ) { cvInitMatHeader( x2, dcount, layer_sizes->data.i[i], CV_64F, x[i] ); cvInitMatHeader( &_w, x1->cols, x2->cols, CV_64F, weights[i] ); cvGEMM( x1, &_w, 1, 0, 0, x2 ); _df = *x2; _df.data.db = df[i]; point->calc_activ_func_deriv( x2, &_df, _w.data.db + _w.rows*_w.cols ); CV_SWAP( x1, x2, temp ); } cvInitMatHeader( grad1, dcount, ovcount, CV_64F, buf_ptr ); w = weights[l_count+1]; grad2->data.db = buf_ptr + max_count*dcount; // calculate error if( u->type == CV_32F ) for(int i = 0; i < dcount; i++ ) { const float* udata = u->data.fl[si+i]; const double* xdata = x[l_count-1] + i*ovcount; double* gdata = grad1->data.db + i*ovcount; double sweight = sw ? sw[si+i] : inv_count, E1 = 0; for(int j = 0; j < ovcount; j++ ) { double t = udata[j]*w[j*2] + w[j*2+1] - xdata[j]; gdata[j] = t*sweight; E1 += t*t; } *E += sweight*E1; } else for(int i = 0; i < dcount; i++ ) { const double* udata = u->data.db[si+i]; const double* xdata = x[l_count-1] + i*ovcount; double* gdata = grad1->data.db + i*ovcount; double sweight = sw ? sw[si+i] : inv_count, E1 = 0; for(int j = 0; j < ovcount; j++ ) { double t = udata[j]*w[j*2] + w[j*2+1] - xdata[j]; gdata[j] = t*sweight; E1 += t*t; } *E += sweight*E1; } // backward pass, update dEdw static cv::Mutex mutex; for(int i = l_count-1; i > 0; i-- ) { n1 = layer_sizes->data.i[i-1]; n2 = layer_sizes->data.i[i]; cvInitMatHeader( &_df, dcount, n2, CV_64F, df[i] ); cvMul( grad1, &_df, grad1 ); { cv::AutoLock lock(mutex); cvInitMatHeader( &_dEdw, n1, n2, CV_64F, dEdw->data.db+(weights[i]-weights[0]) ); cvInitMatHeader( x1, dcount, n1, CV_64F, x[i-1] ); cvGEMM( x1, grad1, 1, &_dEdw, 1, &_dEdw, CV_GEMM_A_T ); // update bias part of dEdw for( k = 0; k < dcount; k++ ) { double* dst = _dEdw.data.db + n1*n2; const double* src = grad1->data.db + k*n2; for(int j = 0; j < n2; j++ ) dst[j] += src[j]; } if (i > 1) cvInitMatHeader( &_w, n1, n2, CV_64F, weights[i] ); } cvInitMatHeader( grad2, dcount, n1, CV_64F, grad2->data.db ); if( i > 1 ) cvGEMM( grad1, &_w, 1, 0, 0, grad2, CV_GEMM_B_T ); CV_SWAP( grad1, grad2, temp ); } } cvFree(&x); cvReleaseMat( &buf ); } }; int CvANN_MLP::train_rprop( CvVectors x0, CvVectors u, const double* sw ) { const int max_buf_size = 1 << 16; CvMat* dw = 0; CvMat* dEdw = 0; CvMat* prev_dEdw_sign = 0; CvMat* buf = 0; double **x = 0, **df = 0; int iter = -1, count = x0.count; CV_FUNCNAME( "CvANN_MLP::train" ); __BEGIN__; int i, ivcount, ovcount, l_count, total = 0, max_iter, buf_sz, dcount0; double *buf_ptr; double prev_E = DBL_MAX*0.5, epsilon; double dw_plus, dw_minus, dw_min, dw_max; double inv_count; max_iter = params.term_crit.max_iter; epsilon = params.term_crit.epsilon; dw_plus = params.rp_dw_plus; dw_minus = params.rp_dw_minus; dw_min = params.rp_dw_min; dw_max = params.rp_dw_max; l_count = layer_sizes->cols; ivcount = layer_sizes->data.i[0]; ovcount = layer_sizes->data.i[l_count-1]; // allocate buffers for( i = 0; i < l_count; i++ ) total += layer_sizes->data.i[i]; CV_CALL( dw = cvCreateMat( wbuf->rows, wbuf->cols, wbuf->type )); cvSet( dw, cvScalarAll(params.rp_dw0) ); CV_CALL( dEdw = cvCreateMat( wbuf->rows, wbuf->cols, wbuf->type )); cvZero( dEdw ); CV_CALL( prev_dEdw_sign = cvCreateMat( wbuf->rows, wbuf->cols, CV_8SC1 )); cvZero( prev_dEdw_sign ); inv_count = 1./count; dcount0 = max_buf_size/(2*total); dcount0 = MAX( dcount0, 1 ); dcount0 = MIN( dcount0, count ); buf_sz = dcount0*(total + max_count)*2; CV_CALL( buf = cvCreateMat( 1, buf_sz, CV_64F )); CV_CALL( x = (double**)cvAlloc( total*2*sizeof(x[0]) )); df = x + total; buf_ptr = buf->data.db; for( i = 0; i < l_count; i++ ) { x[i] = buf_ptr; df[i] = x[i] + layer_sizes->data.i[i]*dcount0; buf_ptr += (df[i] - x[i])*2; } // run rprop loop /* y_i(t) = w_i(t)*x_{i-1}(t) x_i(t) = f(y_i(t)) E = sum_over_all_samples(1/2*||u - x_N||^2) grad_N = (x_N - u)*f'(y_i) MIN(dw_i{jk}(t)*dw_plus, dw_max), if dE/dw_i{jk}(t)*dE/dw_i{jk}(t-1) > 0 dw_i{jk}(t) = MAX(dw_i{jk}(t)*dw_minus, dw_min), if dE/dw_i{jk}(t)*dE/dw_i{jk}(t-1) < 0 dw_i{jk}(t-1) else if (dE/dw_i{jk}(t)*dE/dw_i{jk}(t-1) < 0) dE/dw_i{jk}(t)<-0 else w_i{jk}(t+1) = w_i{jk}(t) + dw_i{jk}(t) grad_{i-1}(t) = w_i^t(t)*grad_i(t) */ for( iter = 0; iter < max_iter; iter++ ) { int n1, n2, j, k; double E = 0; // first, iterate through all the samples and compute dEdw cv::parallel_for_(cv::Range(0, count), rprop_loop(this, weights, count, ivcount, &x0, l_count, layer_sizes, ovcount, max_count, &u, sw, inv_count, dEdw, dcount0, &E, buf_sz) ); // now update weights for( i = 1; i < l_count; i++ ) { n1 = layer_sizes->data.i[i-1]; n2 = layer_sizes->data.i[i]; for( k = 0; k <= n1; k++ ) { double* wk = weights[i]+k*n2; size_t delta = wk - weights[0]; double* dwk = dw->data.db + delta; double* dEdwk = dEdw->data.db + delta; char* prevEk = (char*)(prev_dEdw_sign->data.ptr + delta); for( j = 0; j < n2; j++ ) { double Eval = dEdwk[j]; double dval = dwk[j]; double wval = wk[j]; int s = CV_SIGN(Eval); int ss = prevEk[j]*s; if( ss > 0 ) { dval *= dw_plus; dval = MIN( dval, dw_max ); dwk[j] = dval; wk[j] = wval + dval*s; } else if( ss < 0 ) { dval *= dw_minus; dval = MAX( dval, dw_min ); prevEk[j] = 0; dwk[j] = dval; wk[j] = wval + dval*s; } else { prevEk[j] = (char)s; wk[j] = wval + dval*s; } dEdwk[j] = 0.; } } } //printf("%d. E = %g\n", iter, E); if( fabs(prev_E - E) < epsilon ) break; prev_E = E; E = 0; } __END__; cvReleaseMat( &dw ); cvReleaseMat( &dEdw ); cvReleaseMat( &prev_dEdw_sign ); cvReleaseMat( &buf ); cvFree( &x ); return iter; } void CvANN_MLP::write_params( CvFileStorage* fs ) const { //CV_FUNCNAME( "CvANN_MLP::write_params" ); __BEGIN__; const char* activ_func_name = activ_func == IDENTITY ? "IDENTITY" : activ_func == SIGMOID_SYM ? "SIGMOID_SYM" : activ_func == GAUSSIAN ? "GAUSSIAN" : 0; if( activ_func_name ) cvWriteString( fs, "activation_function", activ_func_name ); else cvWriteInt( fs, "activation_function", activ_func ); if( activ_func != IDENTITY ) { cvWriteReal( fs, "f_param1", f_param1 ); cvWriteReal( fs, "f_param2", f_param2 ); } cvWriteReal( fs, "min_val", min_val ); cvWriteReal( fs, "max_val", max_val ); cvWriteReal( fs, "min_val1", min_val1 ); cvWriteReal( fs, "max_val1", max_val1 ); cvStartWriteStruct( fs, "training_params", CV_NODE_MAP ); if( params.train_method == CvANN_MLP_TrainParams::BACKPROP ) { cvWriteString( fs, "train_method", "BACKPROP" ); cvWriteReal( fs, "dw_scale", params.bp_dw_scale ); cvWriteReal( fs, "moment_scale", params.bp_moment_scale ); } else if( params.train_method == CvANN_MLP_TrainParams::RPROP ) { cvWriteString( fs, "train_method", "RPROP" ); cvWriteReal( fs, "dw0", params.rp_dw0 ); cvWriteReal( fs, "dw_plus", params.rp_dw_plus ); cvWriteReal( fs, "dw_minus", params.rp_dw_minus ); cvWriteReal( fs, "dw_min", params.rp_dw_min ); cvWriteReal( fs, "dw_max", params.rp_dw_max ); } cvStartWriteStruct( fs, "term_criteria", CV_NODE_MAP + CV_NODE_FLOW ); if( params.term_crit.type & CV_TERMCRIT_EPS ) cvWriteReal( fs, "epsilon", params.term_crit.epsilon ); if( params.term_crit.type & CV_TERMCRIT_ITER ) cvWriteInt( fs, "iterations", params.term_crit.max_iter ); cvEndWriteStruct( fs ); cvEndWriteStruct( fs ); __END__; } void CvANN_MLP::write( CvFileStorage* fs, const char* name ) const { CV_FUNCNAME( "CvANN_MLP::write" ); __BEGIN__; int i, l_count = layer_sizes->cols; if( !layer_sizes ) CV_ERROR( CV_StsError, "The network has not been initialized" ); cvStartWriteStruct( fs, name, CV_NODE_MAP, CV_TYPE_NAME_ML_ANN_MLP ); cvWrite( fs, "layer_sizes", layer_sizes ); write_params( fs ); cvStartWriteStruct( fs, "input_scale", CV_NODE_SEQ + CV_NODE_FLOW ); cvWriteRawData( fs, weights[0], layer_sizes->data.i[0]*2, "d" ); cvEndWriteStruct( fs ); cvStartWriteStruct( fs, "output_scale", CV_NODE_SEQ + CV_NODE_FLOW ); cvWriteRawData( fs, weights[l_count], layer_sizes->data.i[l_count-1]*2, "d" ); cvEndWriteStruct( fs ); cvStartWriteStruct( fs, "inv_output_scale", CV_NODE_SEQ + CV_NODE_FLOW ); cvWriteRawData( fs, weights[l_count+1], layer_sizes->data.i[l_count-1]*2, "d" ); cvEndWriteStruct( fs ); cvStartWriteStruct( fs, "weights", CV_NODE_SEQ ); for( i = 1; i < l_count; i++ ) { cvStartWriteStruct( fs, 0, CV_NODE_SEQ + CV_NODE_FLOW ); cvWriteRawData( fs, weights[i], (layer_sizes->data.i[i-1]+1)*layer_sizes->data.i[i], "d" ); cvEndWriteStruct( fs ); } cvEndWriteStruct( fs ); __END__; } void CvANN_MLP::read_params( CvFileStorage* fs, CvFileNode* node ) { //CV_FUNCNAME( "CvANN_MLP::read_params" ); __BEGIN__; const char* activ_func_name = cvReadStringByName( fs, node, "activation_function", 0 ); CvFileNode* tparams_node; if( activ_func_name ) activ_func = strcmp( activ_func_name, "SIGMOID_SYM" ) == 0 ? SIGMOID_SYM : strcmp( activ_func_name, "IDENTITY" ) == 0 ? IDENTITY : strcmp( activ_func_name, "GAUSSIAN" ) == 0 ? GAUSSIAN : 0; else activ_func = cvReadIntByName( fs, node, "activation_function" ); f_param1 = cvReadRealByName( fs, node, "f_param1", 0 ); f_param2 = cvReadRealByName( fs, node, "f_param2", 0 ); set_activ_func( activ_func, f_param1, f_param2 ); min_val = cvReadRealByName( fs, node, "min_val", 0. ); max_val = cvReadRealByName( fs, node, "max_val", 1. ); min_val1 = cvReadRealByName( fs, node, "min_val1", 0. ); max_val1 = cvReadRealByName( fs, node, "max_val1", 1. ); tparams_node = cvGetFileNodeByName( fs, node, "training_params" ); params = CvANN_MLP_TrainParams(); if( tparams_node ) { const char* tmethod_name = cvReadStringByName( fs, tparams_node, "train_method", "" ); CvFileNode* tcrit_node; if( strcmp( tmethod_name, "BACKPROP" ) == 0 ) { params.train_method = CvANN_MLP_TrainParams::BACKPROP; params.bp_dw_scale = cvReadRealByName( fs, tparams_node, "dw_scale", 0 ); params.bp_moment_scale = cvReadRealByName( fs, tparams_node, "moment_scale", 0 ); } else if( strcmp( tmethod_name, "RPROP" ) == 0 ) { params.train_method = CvANN_MLP_TrainParams::RPROP; params.rp_dw0 = cvReadRealByName( fs, tparams_node, "dw0", 0 ); params.rp_dw_plus = cvReadRealByName( fs, tparams_node, "dw_plus", 0 ); params.rp_dw_minus = cvReadRealByName( fs, tparams_node, "dw_minus", 0 ); params.rp_dw_min = cvReadRealByName( fs, tparams_node, "dw_min", 0 ); params.rp_dw_max = cvReadRealByName( fs, tparams_node, "dw_max", 0 ); } tcrit_node = cvGetFileNodeByName( fs, tparams_node, "term_criteria" ); if( tcrit_node ) { params.term_crit.epsilon = cvReadRealByName( fs, tcrit_node, "epsilon", -1 ); params.term_crit.max_iter = cvReadIntByName( fs, tcrit_node, "iterations", -1 ); params.term_crit.type = (params.term_crit.epsilon >= 0 ? CV_TERMCRIT_EPS : 0) + (params.term_crit.max_iter >= 0 ? CV_TERMCRIT_ITER : 0); } } __END__; } void CvANN_MLP::read( CvFileStorage* fs, CvFileNode* node ) { CvMat* _layer_sizes = 0; CV_FUNCNAME( "CvANN_MLP::read" ); __BEGIN__; CvFileNode* w; CvSeqReader reader; int i, l_count; _layer_sizes = (CvMat*)cvReadByName( fs, node, "layer_sizes" ); CV_CALL( create( _layer_sizes, SIGMOID_SYM, 0, 0 )); l_count = layer_sizes->cols; CV_CALL( read_params( fs, node )); w = cvGetFileNodeByName( fs, node, "input_scale" ); if( !w || CV_NODE_TYPE(w->tag) != CV_NODE_SEQ || w->data.seq->total != layer_sizes->data.i[0]*2 ) CV_ERROR( CV_StsParseError, "input_scale tag is not found or is invalid" ); CV_CALL( cvReadRawData( fs, w, weights[0], "d" )); w = cvGetFileNodeByName( fs, node, "output_scale" ); if( !w || CV_NODE_TYPE(w->tag) != CV_NODE_SEQ || w->data.seq->total != layer_sizes->data.i[l_count-1]*2 ) CV_ERROR( CV_StsParseError, "output_scale tag is not found or is invalid" ); CV_CALL( cvReadRawData( fs, w, weights[l_count], "d" )); w = cvGetFileNodeByName( fs, node, "inv_output_scale" ); if( !w || CV_NODE_TYPE(w->tag) != CV_NODE_SEQ || w->data.seq->total != layer_sizes->data.i[l_count-1]*2 ) CV_ERROR( CV_StsParseError, "inv_output_scale tag is not found or is invalid" ); CV_CALL( cvReadRawData( fs, w, weights[l_count+1], "d" )); w = cvGetFileNodeByName( fs, node, "weights" ); if( !w || CV_NODE_TYPE(w->tag) != CV_NODE_SEQ || w->data.seq->total != l_count - 1 ) CV_ERROR( CV_StsParseError, "weights tag is not found or is invalid" ); cvStartReadSeq( w->data.seq, &reader ); for( i = 1; i < l_count; i++ ) { w = (CvFileNode*)reader.ptr; CV_CALL( cvReadRawData( fs, w, weights[i], "d" )); CV_NEXT_SEQ_ELEM( reader.seq->elem_size, reader ); } __END__; } using namespace cv; CvANN_MLP::CvANN_MLP( const Mat& _layer_sizes, int _activ_func, double _f_param1, double _f_param2 ) { layer_sizes = wbuf = 0; min_val = max_val = min_val1 = max_val1 = 0.; weights = 0; rng = &cv::theRNG(); default_model_name = "my_nn"; create( _layer_sizes, _activ_func, _f_param1, _f_param2 ); } void CvANN_MLP::create( const Mat& _layer_sizes, int _activ_func, double _f_param1, double _f_param2 ) { CvMat cvlayer_sizes = _layer_sizes; create( &cvlayer_sizes, _activ_func, _f_param1, _f_param2 ); } int CvANN_MLP::train( const Mat& _inputs, const Mat& _outputs, const Mat& _sample_weights, const Mat& _sample_idx, CvANN_MLP_TrainParams _params, int flags ) { CvMat inputs = _inputs, outputs = _outputs, sweights = _sample_weights, sidx = _sample_idx; return train(&inputs, &outputs, sweights.data.ptr ? &sweights : 0, sidx.data.ptr ? &sidx : 0, _params, flags); } float CvANN_MLP::predict( const Mat& _inputs, Mat& _outputs ) const { CV_Assert(layer_sizes != 0); _outputs.create(_inputs.rows, layer_sizes->data.i[layer_sizes->cols-1], _inputs.type()); CvMat inputs = _inputs, outputs = _outputs; return predict(&inputs, &outputs); } /* End of file. */
30.672637
114
0.525282
732b7c3ed5c7a2371f52b85be91110823a9b204f
961
cpp
C++
Data_Structures/LinkedList/Merge_two_sorted_lists/mergeLists.cpp
edinapap/DSA-Library
586adf2e0bf4eb9a4ece295bb27d87f8ce7f6bce
[ "MIT" ]
30
2020-10-08T17:44:47.000Z
2022-03-23T18:05:06.000Z
Data_Structures/LinkedList/Merge_two_sorted_lists/mergeLists.cpp
edinapap/DSA-Library
586adf2e0bf4eb9a4ece295bb27d87f8ce7f6bce
[ "MIT" ]
118
2020-10-08T04:29:44.000Z
2021-12-10T06:22:26.000Z
Data_Structures/LinkedList/Merge_two_sorted_lists/mergeLists.cpp
edinapap/DSA-Library
586adf2e0bf4eb9a4ece295bb27d87f8ce7f6bce
[ "MIT" ]
125
2020-10-08T04:34:19.000Z
2022-03-30T19:16:27.000Z
//Problem Link: https://practice.geeksforgeeks.org/problems/merge-two-sorted-linked-lists/1 /* Link list Node struct Node { int data; struct Node *next; Node(int x) { data = x; next = NULL; } }; */ Node* sortedMerge(Node* h1, Node* h2) { Node* h3 = NULL; Node* last = NULL; if(h1->data < h2->data) { last = h3 = h1; h1 = h1->next; h3->next = NULL; } else{ last = h3 = h2; h2 = h2->next; h3->next = NULL; } while(h1!=NULL && h2!=NULL) { if(h1->data < h2->data) { last->next = h1; last = h1; h1 = h1->next; last->next = NULL; } else { last->next = h2; last = h2; h2 = h2->next; last->next = NULL; } } if(h1) last->next = h1; else last->next = h2; return h3; }
17.160714
91
0.416233
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
7330dd63e2b69917be0dd1c24436232566860819
4,509
cpp
C++
src/geometric/bounding_box.cpp
mapbox/nepomuk
8771482edb9b16bb0f5a152c15681c57eb3bb6b6
[ "MIT" ]
22
2017-05-12T11:52:26.000Z
2021-12-06T06:05:08.000Z
src/geometric/bounding_box.cpp
mapbox/nepomuk
8771482edb9b16bb0f5a152c15681c57eb3bb6b6
[ "MIT" ]
49
2017-05-11T16:13:58.000Z
2017-12-13T11:19:17.000Z
src/geometric/bounding_box.cpp
mapbox/nepomuk
8771482edb9b16bb0f5a152c15681c57eb3bb6b6
[ "MIT" ]
7
2017-11-19T12:04:26.000Z
2021-12-06T06:14:25.000Z
#include "geometric/bounding_box.hpp" #include <algorithm> #include <cmath> // for atan, exp #include <type_traits> // for move, swap #include <boost/math/constants/constants.hpp> namespace nepomuk { namespace geometric { WGS84BoundingBox::WGS84BoundingBox(WGS84Coordinate lower_left, WGS84Coordinate upper_right) : lower_left(std::move(lower_left)), upper_right(std::move(upper_right)) { } WGS84BoundingBox::WGS84BoundingBox(std::uint32_t const horizontal, std::uint32_t const vertical, std::uint32_t const zoom_level, double const tile_size, std::int32_t const mercator_buffer) { double min_lon = horizontal * tile_size - mercator_buffer; double max_lon = (horizontal + 1.0) * tile_size + mercator_buffer; double min_lat = (vertical + 1.0) * tile_size + mercator_buffer; double max_lat = vertical * tile_size - mercator_buffer; // 2^z * TILE_SIZE const double shift = (1u << static_cast<unsigned>(zoom_level)) * tile_size; auto const shift_lon = [shift](double const lon) { return (lon - 0.5 * shift) / shift * 360.0; }; auto const shift_lat = [shift](double const lat) { auto const tmp = boost::math::constants::pi<double>() * constants::rad_to_degree * (1 - 2 * lat / shift); auto const clamped = std::max<long double>(-180., std::min<long double>(180., tmp)); auto const normalized = constants::rad_to_degree * 2. * std::atan(std::exp(clamped * constants::degree_to_rad)); return normalized - 90.; }; min_lon = shift_lon(min_lon); max_lon = shift_lon(max_lon); min_lat = shift_lat(min_lat); max_lat = shift_lat(max_lat); lower_left = WGS84Coordinate(makeLatLonFromDouble<FixedLongitude>(min_lon), makeLatLonFromDouble<FixedLatitude>(min_lat)); upper_right = WGS84Coordinate(makeLatLonFromDouble<FixedLongitude>(max_lon), makeLatLonFromDouble<FixedLatitude>(max_lat)); } bool WGS84BoundingBox::contains(WGS84Coordinate const &coordinate) const { return lower_left.longitude <= coordinate.longitude && coordinate.longitude <= upper_right.longitude && lower_left.latitude <= coordinate.latitude && coordinate.latitude <= upper_right.latitude; } double WGS84BoundingBox::width() const { return doubleFromLatLon(upper_right.longitude) - doubleFromLatLon(lower_left.longitude); } double WGS84BoundingBox::height() const { return doubleFromLatLon(upper_right.latitude) - doubleFromLatLon(lower_left.latitude); } MercatorBoundingBox::MercatorBoundingBox(MercatorCoordinate lower_left_, MercatorCoordinate upper_right_) : lower_left(lower_left_), upper_right(upper_right_) { // mercator transformations switch invert latitude (counting from upper right). If the // coordinates don't match up (e.g. due to conversion issues) we need to swap them to the // correct order if (lower_left.latitude > upper_right.latitude) std::swap(lower_left.latitude, upper_right.latitude); } MercatorBoundingBox::MercatorBoundingBox(std::uint32_t const horizontal, std::uint32_t const vertical, std::uint32_t const zoom_level, double const tile_size, std::int32_t const mercator_buffer) { WGS84BoundingBox bbox(horizontal, vertical, zoom_level, tile_size, mercator_buffer); lower_left = MercatorCoordinate(bbox.lower_left); upper_right = MercatorCoordinate(bbox.upper_right); std::swap(lower_left.latitude, upper_right.latitude); } bool MercatorBoundingBox::contains(MercatorCoordinate const &coordinate) const { return lower_left.longitude <= coordinate.longitude && coordinate.longitude <= upper_right.longitude && lower_left.latitude <= coordinate.latitude && coordinate.latitude <= upper_right.latitude; } double MercatorBoundingBox::width() const { return doubleFromLatLon(upper_right.longitude) - doubleFromLatLon(lower_left.longitude); } double MercatorBoundingBox::height() const { return doubleFromLatLon(upper_right.latitude) - doubleFromLatLon(lower_left.latitude); } } // namespace geometric } // namespace nepomuk
37.575
100
0.667554
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
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
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
733724fd7e455677881e0464ad578dbc421f3ef6
1,523
hpp
C++
Classes/entity.hpp
mackness33/NoGravitar
ae0c4f1fc5567aa32584c8b48a2506cdea329ad1
[ "MIT" ]
null
null
null
Classes/entity.hpp
mackness33/NoGravitar
ae0c4f1fc5567aa32584c8b48a2506cdea329ad1
[ "MIT" ]
null
null
null
Classes/entity.hpp
mackness33/NoGravitar
ae0c4f1fc5567aa32584c8b48a2506cdea329ad1
[ "MIT" ]
null
null
null
#ifndef ENTITY_H #define ENTITY_H #include <SFML/Window.hpp> #include <SFML/System.hpp> #include <SFML/Graphics.hpp> #include <iostream> #include "essence.hpp" //this class handle static objects template <class T> class entity : public essence<T>{ protected: void setBoundery(); public: //----------CONSTRUCTORS---------- entity(); entity(T* b); entity(sf::Texture* image); //Sprite entity(float radius, std::size_t pointCount = 30); //CircleShape entity(const sf::Font &font, const std::string &string); //Text entity(sf::Vector2f size, sf::Vector2f position = sf::Vector2f(0, 0), sf::Texture* image = nullptr); //RectangleShape ~entity(); //----------GETS---------- float GetRotation(); sf::Vector2f GetPosition(); sf::Vector2f GetOrigin(); //----------SETS---------- void setBody(T *b); void SetPosition (float x, float y); void SetPosition (const sf::Vector2f &position); void SetRotation (float angle); void SetScale (float factorX, float factorY); void SetScale (const sf::Vector2f &factor); void SetOrigin (float x, float y); void SetOrigin (const sf::Vector2f &origin); //----------METHODS------------ virtual std::string Class(); }; #include "entity.tpp" #endif // ENTITY_H
28.735849
134
0.530532
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
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
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
733d49cacfda17ad19b7bd7918be73c1fd14a64f
5,647
cpp
C++
paddle/capi/Matrix.cpp
limeng357/Paddle
dbd25805c88c48998eb9dc0f4b2ca1fd46326482
[ "ECL-2.0", "Apache-2.0" ]
9
2017-12-04T02:58:01.000Z
2020-12-03T14:46:30.000Z
paddle/capi/Matrix.cpp
limeng357/Paddle
dbd25805c88c48998eb9dc0f4b2ca1fd46326482
[ "ECL-2.0", "Apache-2.0" ]
7
2017-12-05T20:29:08.000Z
2018-10-15T08:57:40.000Z
paddle/capi/Matrix.cpp
limeng357/Paddle
dbd25805c88c48998eb9dc0f4b2ca1fd46326482
[ "ECL-2.0", "Apache-2.0" ]
6
2018-03-19T22:38:46.000Z
2019-11-01T22:28:27.000Z
/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ #include "capi_private.h" #include "hl_cuda.h" #include "matrix.h" #define cast(v) paddle::capi::cast<paddle::capi::CMatrix>(v) extern "C" { paddle_matrix paddle_matrix_create(uint64_t height, uint64_t width, bool useGpu) { auto ptr = new paddle::capi::CMatrix(); ptr->mat = paddle::Matrix::create(height, width, false, useGpu); return ptr; } paddle_matrix paddle_matrix_create_none() { return new paddle::capi::CMatrix(); } paddle_error paddle_matrix_destroy(paddle_matrix mat) { if (mat == nullptr) return kPD_NULLPTR; auto ptr = cast(mat); delete ptr; return kPD_NO_ERROR; } paddle_error paddle_matrix_set_row(paddle_matrix mat, uint64_t rowID, paddle_real* rowArray) { if (mat == nullptr || rowArray == nullptr) return kPD_NULLPTR; auto ptr = cast(mat); if (ptr->mat == nullptr) return kPD_NULLPTR; if (rowID >= ptr->mat->getHeight()) return kPD_OUT_OF_RANGE; paddle::real* buf = ptr->mat->getRowBuf(rowID); size_t width = ptr->mat->getWidth(); #ifdef PADDLE_WITH_CUDA hl_memcpy(buf, rowArray, sizeof(paddle::real) * width); #else std::copy(rowArray, rowArray + width, buf); #endif return kPD_NO_ERROR; } PD_API paddle_error paddle_matrix_set_value(paddle_matrix mat, paddle_real* value) { if (mat == nullptr || value == nullptr) return kPD_NULLPTR; auto ptr = cast(mat); if (ptr->mat == nullptr) return kPD_NULLPTR; paddle::real* buf = ptr->mat->getRowBuf(0); size_t width = ptr->mat->getWidth(); size_t height = ptr->mat->getHeight(); if (ptr->mat->useGpu()) { #ifdef PADDLE_WITH_CUDA hl_memcpy(buf, value, sizeof(paddle::real) * width * height); #else return kPD_NOT_SUPPORTED; #endif } else { std::copy(value, value + width * height, buf); } return kPD_NO_ERROR; } PD_API paddle_error paddle_matrix_get_value(paddle_matrix mat, paddle_real* result) { if (mat == nullptr || result == nullptr) return kPD_NULLPTR; auto ptr = cast(mat); if (ptr->mat == nullptr) return kPD_NULLPTR; paddle::real* buf = ptr->mat->getRowBuf(0); size_t width = ptr->mat->getWidth(); size_t height = ptr->mat->getHeight(); if (ptr->mat->useGpu()) { #ifdef PADDLE_WITH_CUDA hl_memcpy(result, buf, width * height * sizeof(paddle::real)); #else return kPD_NOT_SUPPORTED; #endif } else { std::copy(buf, buf + width * height, result); } return kPD_NO_ERROR; } paddle_error paddle_matrix_get_row(paddle_matrix mat, uint64_t rowID, paddle_real** rawRowBuffer) { if (mat == nullptr) return kPD_NULLPTR; auto ptr = cast(mat); if (ptr->mat == nullptr) return kPD_NULLPTR; if (rowID >= ptr->mat->getHeight()) return kPD_OUT_OF_RANGE; *rawRowBuffer = ptr->mat->getRowBuf(rowID); return kPD_NO_ERROR; } paddle_error paddle_matrix_get_shape(paddle_matrix mat, uint64_t* height, uint64_t* width) { if (mat == nullptr || cast(mat)->mat == nullptr) return kPD_NULLPTR; if (height != nullptr) { *height = cast(mat)->mat->getHeight(); } if (width != nullptr) { *width = cast(mat)->mat->getWidth(); } return kPD_NO_ERROR; } } paddle_matrix paddle_matrix_create_sparse( uint64_t height, uint64_t width, uint64_t nnz, bool isBinary, bool useGpu) { #ifndef PADDLE_MOBILE_INFERENCE auto ptr = new paddle::capi::CMatrix(); ptr->mat = paddle::Matrix::createSparseMatrix( height, width, nnz, isBinary ? paddle::NO_VALUE : paddle::FLOAT_VALUE, paddle::SPARSE_CSR, false, useGpu); return ptr; #else return nullptr; #endif } paddle_error paddle_matrix_sparse_copy_from(paddle_matrix mat, int* rowArray, uint64_t rowSize, int* colArray, uint64_t colSize, float* valueArray, uint64_t valueSize) { #ifndef PADDLE_MOBILE_INFERENCE if (mat == nullptr) return kPD_NULLPTR; auto ptr = cast(mat); if (rowArray == nullptr || colArray == nullptr || (valueSize != 0 && valueArray == nullptr) || ptr->mat == nullptr) { return kPD_NULLPTR; } if (auto sparseMat = dynamic_cast<paddle::CpuSparseMatrix*>(ptr->mat.get())) { std::vector<int> row(rowSize); row.assign(rowArray, rowArray + rowSize); std::vector<int> col(colSize); col.assign(colArray, colArray + colSize); std::vector<paddle_real> val(valueSize); if (valueSize) { val.assign(valueArray, valueArray + valueSize); } sparseMat->copyFrom(row, col, val); return kPD_NO_ERROR; } else { return kPD_NOT_SUPPORTED; } #else return kPD_NOT_SUPPORTED; #endif }
32.831395
80
0.625642
733f1b2453e4e54ddde2f729f47a0bb30a32a3d2
982
cc
C++
src/calc/token.cc
madeso/bbcalc
1f5e316ce007b1d1d9b4fc49f9afb03715e5674c
[ "MIT" ]
null
null
null
src/calc/token.cc
madeso/bbcalc
1f5e316ce007b1d1d9b4fc49f9afb03715e5674c
[ "MIT" ]
null
null
null
src/calc/token.cc
madeso/bbcalc
1f5e316ce007b1d1d9b4fc49f9afb03715e5674c
[ "MIT" ]
null
null
null
#include "calc/token.h" #include <array> #include <string_view> #include <sstream> #include <cassert> [[nodiscard]] std::string Token::ToString() const { constexpr std::array NAMES{ std::string_view{"NUMBER"}, std::string_view{"AND"}, std::string_view{"OR"}, std::string_view{"EOF"}}; using A = decltype(NAMES); std::stringstream ss; ss << NAMES[static_cast<A::size_type>(type)]; if (type == NUMBER) { ss << "(" << value << ")"; } return ss.str(); } Token Token::Number(int num) { Token ret{}; ret.type = NUMBER; ret.value = num; return ret; } Token Token::And() { return FromType(OPAND); } Token Token::Or() { return FromType(OPOR); } const Token& Token::Eof() { static auto Eof = FromType(EOFTOKEN); return Eof; } Token Token::FromType(Type t) { assert(t != NUMBER); Token ret{}; ret.type = t; ret.value = 0; return ret; }
13.452055
49
0.562118
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
734116e60ec9267de8fd987959286ca00f5a5059
10,118
cpp
C++
lib/RefBackend/RefBackend.cpp
dan-garvey/mlir-npcomp
977b1b03ea7dfb68f0971f1f7313ec6856236380
[ "Apache-2.0" ]
null
null
null
lib/RefBackend/RefBackend.cpp
dan-garvey/mlir-npcomp
977b1b03ea7dfb68f0971f1f7313ec6856236380
[ "Apache-2.0" ]
null
null
null
lib/RefBackend/RefBackend.cpp
dan-garvey/mlir-npcomp
977b1b03ea7dfb68f0971f1f7313ec6856236380
[ "Apache-2.0" ]
null
null
null
//===----------------------------------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // Also available under a BSD-style license. See LICENSE. // //===----------------------------------------------------------------------===// // // The torch-mlir "reference backend" requires a few passes to glue things // together so that the final IR will work with ExecutionEngine. // // There is no actual "backend". // //===----------------------------------------------------------------------===// #include "PassDetail.h" #include "mlir/Dialect/Arithmetic/Transforms/Passes.h" #include "mlir/Dialect/Math/IR/Math.h" #include "mlir/Dialect/Math/Transforms/Approximation.h" #include "mlir/Dialect/Math/Transforms/Passes.h" #include "mlir/Dialect/StandardOps/IR/Ops.h" #include "mlir/Transforms/DialectConversion.h" #include "set" #include "torch-mlir/RefBackend/Passes.h" #include <numeric> using namespace mlir; using namespace mlir::torch; using namespace mlir::torch::RefBackend; //===----------------------------------------------------------------------===// // Pass registration //===----------------------------------------------------------------------===// namespace { #define GEN_PASS_REGISTRATION #include "torch-mlir/RefBackend/Passes.h.inc" } // end namespace void mlir::torch::RefBackend::registerRefBackendPasses() { ::registerPasses(); } //===----------------------------------------------------------------------===// // MungeCallingConventions //===----------------------------------------------------------------------===// static bool isArgMemRefTypeValid(Type type) { if (auto memRefType = type.dyn_cast<MemRefType>()) { Type elemTy = memRefType.getElementType(); if (elemTy.isa<Float32Type>()) { return true; } else if (elemTy.isa<Float64Type>()) { return true; } else if (auto integerTy = elemTy.dyn_cast<IntegerType>()) { if (integerTy.isSignlessInteger(64)) return true; if (integerTy.isSignlessInteger(32)) return true; } } return false; } static void addEmitCInterfaceAttr(FuncOp func) { func->setAttr("llvm.emit_c_interface", UnitAttr::get(func.getContext())); } static Type getAbiTypeForMemRef(Type type) { return UnrankedMemRefType::get(type.cast<MemRefType>().getElementType(), 0); } // Helper function to get the type string for one return value like i32, f64, // mri32 etc. The strings from multiple return values are concatenated to get // the consumeFuncReturnFunc name. static std::string getTypeToken(Type type) { if (type.isSignlessInteger()) return ("i" + Twine(type.getIntOrFloatBitWidth())).str(); else if (type.isa<mlir::FloatType>()) return ("f" + Twine(type.getIntOrFloatBitWidth())).str(); else if (auto memRefType = type.dyn_cast<UnrankedMemRefType>()) return "mr" + getTypeToken(memRefType.getElementType()); llvm_unreachable( "Type token should handle all types: memref, float and int type"); } // Systematically derive the consumeFuncReturnFunc name from return value types. static std::string getConsumeReturnFunctionNameForReturnTypes(TypeRange types) { SmallVector<std::string> tokens = {"refbackend_consume_func_return"}; for (auto type : types) tokens.push_back(getTypeToken(type)); return std::accumulate(tokens.begin(), tokens.end(), std::string(), [](std::string &a, std::string &b) { return a.empty() ? b : (a + "_" + b); }); } // Replace the original returnOp with a call to consumeFuncReturnFunc and add // the op to the `toErase` vector. static void replaceReturnWithCall(OpBuilder b, ReturnOp op, StringRef funcName, TypeRange retTypes, SmallVectorImpl<Value> &vals, SmallVectorImpl<Operation *> &toErase) { b.create<mlir::CallOp>(op.getLoc(), funcName, TypeRange({}), vals); b.create<mlir::ReturnOp>(op.getLoc()); toErase.push_back(op); } static LogicalResult mungeFunction( FuncOp func, std::set<std::string> &supportedConsumeFuncReturnFuncs, std::map<std::string, std::vector<Type>> &invokedConsumeFuncReturnFuncs) { // Add `llvm.emit_c_interface`. // This allows ExecutionEngine to resolve the symbol properly. addEmitCInterfaceAttr(func); // Rewrite the function as follows: // - replace all memref arguments with unranked memref // - replace all returns with a call to a function, which is going to be // supplied by the code setting up the ExecutionEngine to process the // result. Additionally, ensure that all results are passed as unranked // memrefs. // - replace the function signature accordingly (unranked inputs, no returns). OpBuilder b(func.getBody()); SmallVector<Type> newArgTypes; for (auto arg : func.getArguments()) { auto type = arg.getType(); if (!isArgMemRefTypeValid(type)) return emitError(arg.getLoc(), "argument must be a memref of f32, f64, i32, i64"); auto cast = b.create<memref::CastOp>(arg.getLoc(), arg, type); arg.replaceAllUsesExcept(cast, cast); arg.setType(getAbiTypeForMemRef(type)); newArgTypes.push_back(arg.getType()); } SmallVector<Operation *> toErase; bool isSupported = true; func.walk([&](ReturnOp op) { auto types = op.getOperandTypes(); b.setInsertionPoint(op); // Memref Types. std::vector<Type> retTypes; SmallVector<Value> retVals; for (auto en : llvm::enumerate(types)) { Type retType = en.value(); Value retVal = op.getOperand(en.index()); if (auto memrefReturnType = retType.dyn_cast<MemRefType>()) { auto elemType = memrefReturnType.getElementType(); retType = UnrankedMemRefType::get(elemType, 0); // Cast to unranked memref type before sending it as a function // argument. retVal = b.create<memref::CastOp>( op.getLoc(), retVal, getAbiTypeForMemRef(types[en.index()])); } retTypes.push_back(retType); retVals.push_back(retVal); } auto supportedFuncsEnd = supportedConsumeFuncReturnFuncs.end(); std::string funcName = getConsumeReturnFunctionNameForReturnTypes(retTypes); if (supportedConsumeFuncReturnFuncs.find(funcName) == supportedFuncsEnd) { op.emitError( "must have one return value of memref types or scalar types " "of i32, i64, f32, f64 or three return values of memref f32"); isSupported = false; } auto invokedFuncsEnd = invokedConsumeFuncReturnFuncs.end(); if (invokedConsumeFuncReturnFuncs.find(funcName) == invokedFuncsEnd) invokedConsumeFuncReturnFuncs.insert({funcName, retTypes}); replaceReturnWithCall(b, op, funcName, retTypes, retVals, toErase); }); if (!isSupported) return failure(); func.setType(FunctionType::get(func.getContext(), newArgTypes, {})); for (Operation *op : toErase) op->erase(); return success(); } static std::set<std::string> getSupportedConsumeFuncReturnFuncs(OpBuilder &b) { std::set<std::string> funcNames; Type mri32 = UnrankedMemRefType::get(b.getI32Type(), 0); Type mri64 = UnrankedMemRefType::get(b.getI64Type(), 0); Type mrf32 = UnrankedMemRefType::get(b.getF32Type(), 0); Type mrf64 = UnrankedMemRefType::get(b.getF64Type(), 0); Type i64 = b.getI64Type(); Type f32 = b.getF32Type(); Type f64 = b.getF64Type(); SmallVector<TypeRange> supportedReturnTypes = { mri32, mri64, mrf32, mrf64, i64, f32, f64, {mrf32, mrf32, mrf32}}; llvm::for_each(supportedReturnTypes, [&](TypeRange &types) { funcNames.insert(getConsumeReturnFunctionNameForReturnTypes(types)); }); return funcNames; } namespace { class MungeCallingConventions : public MungeCallingConventionsBase<MungeCallingConventions> { void runOnOperation() override { auto module = getOperation(); OpBuilder b(module.getBodyRegion()); static std::set<std::string> supported = getSupportedConsumeFuncReturnFuncs(b); std::map<std::string, std::vector<Type>> invokedConsumeFuncReturnFuncs; for (auto func : module.getOps<FuncOp>()) { if (failed(mungeFunction(func, supported, invokedConsumeFuncReturnFuncs))) return signalPassFailure(); } // Create FuncOp for consumeFuncReturnFuncs that are used. for (auto &p : invokedConsumeFuncReturnFuncs) { auto consumeFuncReturnFunc = b.create<FuncOp>(module.getLoc(), p.first, FunctionType::get(module.getContext(), p.second, {}), b.getStringAttr("private")); addEmitCInterfaceAttr(consumeFuncReturnFunc); } } }; } // namespace std::unique_ptr<OperationPass<ModuleOp>> mlir::torch::RefBackend::createMungeCallingConventionsPass() { return std::make_unique<MungeCallingConventions>(); } //===----------------------------------------------------------------------===// // ExpandOpsForLLVM //===----------------------------------------------------------------------===// namespace { class ExpandOpsForLLVM : public ExpandOpsForLLVMBase<ExpandOpsForLLVM> { void runOnOperation() override { auto func = getOperation(); auto *context = &getContext(); RewritePatternSet patterns(context); populateExpandTanhPattern(patterns); patterns.add<math::ErfPolynomialApproximation>(patterns.getContext()); ConversionTarget target(*context); target.addLegalDialect<StandardOpsDialect>(); target.addLegalDialect<math::MathDialect>(); target.addLegalDialect<arith::ArithmeticDialect>(); target.addIllegalOp<math::TanhOp>(); target.addIllegalOp<math::ErfOp>(); if (failed(applyPartialConversion(func, target, std::move(patterns)))) { return signalPassFailure(); } } }; } // namespace std::unique_ptr<OperationPass<FuncOp>> mlir::torch::RefBackend::createExpandOpsForLLVMPass() { return std::make_unique<ExpandOpsForLLVM>(); }
38.618321
80
0.646472
734227447a877a493502ce2ecbf459fa9089ebed
971
cpp
C++
algorithms/cpp/87.cpp
viing937/leetcode
e21ca52c98bddf59e43522c0aace5e8cf84350eb
[ "MIT" ]
3
2016-10-01T10:15:09.000Z
2017-07-09T02:53:36.000Z
algorithms/cpp/87.cpp
viing937/leetcode
e21ca52c98bddf59e43522c0aace5e8cf84350eb
[ "MIT" ]
null
null
null
algorithms/cpp/87.cpp
viing937/leetcode
e21ca52c98bddf59e43522c0aace5e8cf84350eb
[ "MIT" ]
null
null
null
#include <iostream> #include <vector> using namespace std; class Solution { public: bool isScramble(string s1, string s2) { if (s1 == s2) return true; int length = s1.size(); vector<int> count(26, 0); for (int i = 0; i < length; i++) { count[s1[i]-'a'] += 1; count[s2[i]-'a'] -= 1; } for (int i = 0; i < count.size(); i++) if (count[i] != 0) return false; for (int i = 1; i < length; i++) { if (isScramble(s1.substr(0, i), s2.substr(0, i)) && isScramble(s1.substr(i), s2.substr(i))) return true; if (isScramble(s1.substr(0, i), s2.substr(length-i)) && isScramble(s1.substr(i), s2.substr(0, length-i))) return true; } return false; } }; int main() { Solution solution; solution.isScramble("oatzzffqpnwcxhejzjsnpmkmzngneo", "acegneonzmkmpnsjzjhxwnpqffzzto"); return 0; }
29.424242
117
0.519053
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
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
73459419f8ec4baded376d7e3527680e11ea33c0
1,469
cc
C++
tensorflow/lite/tensorflow_profiler_logger_shim.cc
Stevanus-Christian/tensorflow
d44afcf5ca16c5d704c66f891b99eac804e7cd14
[ "Apache-2.0" ]
2
2016-09-27T05:37:33.000Z
2019-11-22T06:41:12.000Z
tensorflow/lite/tensorflow_profiler_logger_shim.cc
Stevanus-Christian/tensorflow
d44afcf5ca16c5d704c66f891b99eac804e7cd14
[ "Apache-2.0" ]
null
null
null
tensorflow/lite/tensorflow_profiler_logger_shim.cc
Stevanus-Christian/tensorflow
d44afcf5ca16c5d704c66f891b99eac804e7cd14
[ "Apache-2.0" ]
null
null
null
/* Copyright 2022 The TensorFlow Authors. All Rights Reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ==============================================================================*/ #include "tensorflow/lite/core/macros.h" #include "tensorflow/lite/tensorflow_profiler_logger.h" // Use weak symbols here (even though they are guarded by macros) to avoid // build breakage when building a benchmark requires TFLite runs. The main // benchmark library should have tensor_profiler_logger dependency. // Strong symbol definitions can be found in tensorflow_profiler_logger.cc. // No-op for the weak symbol. Overridden by a strong symbol in // tensorflow_profiler_logger.cc. TFLITE_ATTRIBUTE_WEAK void OnTfLiteTensorAlloc(size_t num_bytes, TfLiteTensor* tensor) {} // No-op for the weak symbol. Overridden by a strong symbol in // tensorflow_profiler_logger.cc. TFLITE_ATTRIBUTE_WEAK void OnTfLiteTensorDealloc(TfLiteTensor* tensor) {}
45.90625
80
0.73179
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
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
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
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
734a93a40466a1340ad176d58341a668e9376d2c
3,365
hpp
C++
libs/foe_graphics_resource/include/foe/graphics/resource/material_loader.hpp
StableCoder/foe-engine
5d49696a46c119e708dc4055b99e18194bcd4c4f
[ "Apache-2.0" ]
4
2021-04-09T13:11:22.000Z
2022-03-26T07:29:31.000Z
libs/foe_graphics_resource/include/foe/graphics/resource/material_loader.hpp
StableCoder/foe-engine
5d49696a46c119e708dc4055b99e18194bcd4c4f
[ "Apache-2.0" ]
null
null
null
libs/foe_graphics_resource/include/foe/graphics/resource/material_loader.hpp
StableCoder/foe-engine
5d49696a46c119e708dc4055b99e18194bcd4c4f
[ "Apache-2.0" ]
1
2022-02-10T14:51:00.000Z
2022-02-10T14:51:00.000Z
/* Copyright (C) 2021 George Cave. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ #ifndef FOE_GRPAHICS_RESOURCE_MATERIAL_LOADER_HPP #define FOE_GRPAHICS_RESOURCE_MATERIAL_LOADER_HPP #include <foe/graphics/vk/fragment_descriptor_pool.hpp> #include <foe/graphics/resource/export.h> #include <foe/graphics/resource/material.hpp> #include <foe/graphics/session.hpp> #include <foe/graphics/type_defs.hpp> #include <foe/simulation/core/loader.hpp> #include <vulkan/vulkan.h> #include <array> #include <vector> class foeShaderPool; class foeImagePool; struct FOE_GFX_RES_EXPORT foeMaterialCreateInfo : public foeResourceCreateInfoBase { ~foeMaterialCreateInfo(); foeId fragmentShader = FOE_INVALID_ID; foeId image = FOE_INVALID_ID; bool hasRasterizationSCI; VkPipelineRasterizationStateCreateInfo rasterizationSCI; bool hasDepthStencilSCI; VkPipelineDepthStencilStateCreateInfo depthStencilSCI; bool hasColourBlendSCI; VkPipelineColorBlendStateCreateInfo colourBlendSCI; std::vector<VkPipelineColorBlendAttachmentState> colourBlendAttachments; }; class FOE_GFX_RES_EXPORT foeMaterialLoader : public foeResourceLoaderBase { public: std::error_code initialize(foeShaderPool *pShaderPool, foeImagePool *pImagePool, foeGfxSession session); void deinitialize(); bool initialized() const noexcept; void gfxMaintenance(); virtual bool canProcessCreateInfo(foeResourceCreateInfoBase *pCreateInfo) final; virtual void load(void *pResource, std::shared_ptr<foeResourceCreateInfoBase> const &pCreateInfo, void (*pPostLoadFn)(void *, std::error_code)) final; private: std::error_code createDescriptorSet(foeMaterial::Data *pMaterialData); static void unloadResource(void *pContext, void *pResource, uint32_t resourceIteration, bool immediateUnload); foeShaderPool *mShaderPool{nullptr}; foeImagePool *mImagePool{nullptr}; foeGfxSession mGfxSession{FOE_NULL_HANDLE}; foeGfxVkFragmentDescriptorPool *mGfxFragmentDescriptorPool{nullptr}; VkDescriptorPool mDescriptorPool; struct LoadData { foeMaterial *pMaterial; void (*pPostLoadFn)(void *, std::error_code); foeMaterial::Data data; }; std::mutex mLoadSync; std::vector<LoadData> mLoadRequests; struct UnloadData { foeMaterial *pMaterial; uint32_t iteration; }; std::mutex mUnloadSync; std::vector<UnloadData> mUnloadRequests; size_t mDataDestroyIndex{0}; std::array<std::vector<foeMaterial::Data>, FOE_GRAPHICS_MAX_BUFFERED_FRAMES + 1> mDataDestroyLists{}; }; #endif // FOE_GRPAHICS_RESOURCE_MATERIAL_LOADER_HPP
32.990196
84
0.719465
734bf82529614ce4230de06837fae7e75d94dad3
5,460
cpp
C++
src/extralibs/sdl_draw/src/draw_line.cpp
SamuraiCrow/protrekkr
4bf6f52635ac722e7a9370dacfbc8807a4043c4a
[ "BSD-3-Clause" ]
22
2018-02-13T12:29:23.000Z
2022-02-21T16:18:15.000Z
src/extralibs/sdl_draw/src/draw_line.cpp
PaulBatchelor/protrekkr
0f93032913bf111b0721901691dd351a165c3d61
[ "BSD-2-Clause" ]
5
2018-02-13T13:43:55.000Z
2021-12-14T07:55:07.000Z
src/extralibs/sdl_draw/src/draw_line.cpp
hitchhikr/protrekkr
d14b83f1a2570ea31deced97972839b621710c9e
[ "BSD-3-Clause" ]
5
2019-05-02T13:07:28.000Z
2022-01-07T17:51:37.000Z
/*! \file Draw_Line.c \author Mario Palomo <mpalomo@ihman.com> \author Jose M. de la Huerga Fern�ndez \author Pepe Gonz�lez Mora \date 05-2002 Based in Kenny Hoff sourcer. */ /* This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #if defined(__GCC__) #include "../include/sdl_draw.h" #else #include "../../include/sdl_draw.h" #endif #define SDL_DRAW_PUTPIXEL_BPP(A, B, C, D) *(A(B(Uint8*)D))=C; #if SDL_DRAW_BPP == 1 #define SDL_DRAW_PUTPIXEL(D) SDL_DRAW_PUTPIXEL_BPP(0+,0+,color,D) #elif SDL_DRAW_BPP == 4 #define SDL_DRAW_PUTPIXEL(D) SDL_DRAW_PUTPIXEL_BPP((Uint32*),0+,color,D) #endif /*SDL_DRAW_BPP*/ void STDCALL Draw_Line(SDL_Surface *super, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Uint32 color) { register Sint16 dx; register Sint16 dy; Sint16 fbXincr, fbYincr, fbXYincr; Sint16 dPr, dPru, P; Sint16 pixx = super->format->BytesPerPixel; Sint16 pixy = super->pitch; Uint8 *AfbAddr, *BfbAddr; /* Clip line and test if we have to draw only if we need to do it */ /* It is in next version. #ifdef SDL_DRAW_CLIP if (!(clipLine(super, &x1, &y1, &x2, &y2))) { return; } #endif */ /* Store the fremebuffer Endpoint-Addresses (A and B) */ AfbAddr = ((Uint8*)super->pixels) + pixx * (int)x1 + pixy * (int)y1; BfbAddr = ((Uint8*)super->pixels) + pixx * (int)x2 + pixy * (int)y2; /* Lock surface */ if (SDL_MUSTLOCK(super)) { if (SDL_LockSurface(super) < 0) { return; } } fbXincr=pixx; if ( (dx=x2-x1) >= 0 ) goto AFTERNEGX; dx = -dx; fbXincr = -pixx; AFTERNEGX: fbYincr=pixy; //debug if ( (dy=y2-y1) >= 0) goto AFTERNEGY; fbYincr = -pixy; dy = -dy; AFTERNEGY: fbXYincr = fbXincr+fbYincr; if (dy > dx) goto YisIndependent; /*Check if X or Y is independent vaiable */ /*XisIndependent;*/ dPr = dy+dy; P = -dx; dPru = P+P; dy = dx>>1; XLOOP: SDL_DRAW_PUTPIXEL(AfbAddr); /*Plot the pixel from end of pointer one*/ SDL_DRAW_PUTPIXEL(BfbAddr); /*Plot the pixel from end of pointer two*/ if ((P+=dPr) > 0) goto RightAndUp; /*Up:*/ AfbAddr+=fbXincr; BfbAddr-=fbXincr; if ((dy=dy-1) > 0) goto XLOOP; SDL_DRAW_PUTPIXEL(AfbAddr) /*(Fix midpoint problem) Plot last PT from end pointer one*/ if (( dx & 1) == 0) goto END_P; SDL_DRAW_PUTPIXEL(BfbAddr); /*Plot last PT from end of pointer two if independent is odd*/ goto END_P; RightAndUp: AfbAddr+=fbXYincr; /*Advance to next point from end of pointer one*/ BfbAddr-=fbXYincr; /*Advance to next point from end of pointer two*/ P+=dPru; if ((dy=dy-1) > 0) goto XLOOP; SDL_DRAW_PUTPIXEL(AfbAddr); /*(Fix midpoint problem) Plot last PT from end of pointer one*/ if ((dx & 1) == 0) goto END_P; SDL_DRAW_PUTPIXEL(BfbAddr); /*Plot last PT from end of pointer two if indepent is odd*/ goto END_P; YisIndependent: dPr = dx+dx; P = -dy; dPru = P+P; dx = dy >>1; YLOOP: /* PROCESS EACH POINT IN THE LINE ONE AT A TIME (use dX as loop counter) */ SDL_DRAW_PUTPIXEL(AfbAddr); /* PLOT THE PIXEL FROM END A */ SDL_DRAW_PUTPIXEL(BfbAddr); /* PLOT THE PIXEL FROM END B */ if ((P+=dPr) > 0) goto RightAndUp2; /* INCREMENT DECISION, CHECK IF THE PIXEL IS GOING RIGHT AND UP */ /*Up:*/ AfbAddr+=fbYincr; /* ADVANCE TO NEXT POINT FROM END A */ BfbAddr-=fbYincr; /* ADVANCE TO NEXT POINT FROM END B */ if ((dx=dx-1) > 0) goto YLOOP; /* DECREMENT LOOP VARIABLE AND LOOP */ SDL_DRAW_PUTPIXEL(AfbAddr); /* (FIX MIDPOINT PROBLEM) PLOT THE LAST POINT FROM END A */ if ((dy & 1) == 0) goto END_P; /* FINISHED IF INDEPENDENT IS EVEN (ODD # STEPS) */ SDL_DRAW_PUTPIXEL(BfbAddr); /* PLOT LAST PT FROM END B IF INDEPENDENT IS ODD (EVEN # STEPS) */ goto END_P; RightAndUp2: AfbAddr+=fbXYincr; /* ADVANCE TO NEXT POINT FROM END A */ BfbAddr-=fbXYincr; /* ADVANCE TO NEXT POINT FROM END B */ P+=dPru; /* INCREMENT DECISION (for up) */ if ((dx=dx-1) > 0) goto YLOOP; /* DECREMENT LOOP VARIABLE AND LOOP */ SDL_DRAW_PUTPIXEL(AfbAddr); /* (FIX MIDPOINT PROBLEM) PLOT THE LAST POINT FROM END A */ if ((dy & 1) == 0) goto END_P; /* FINISHED IF INDEPENDENT IS EVEN (ODD # STEPS) */ SDL_DRAW_PUTPIXEL(BfbAddr); /* PLOT LAST PT FROM END B IF INDEPENDENT IS ODD (EVEN # STEPS) */ END_P: /* Unlock surface */ if (SDL_MUSTLOCK(super)) { SDL_UnlockSurface(super); } }/*Draw_Line*/ #undef SDL_DRAW_PUTPIXEL #undef SDL_DRAW_PUTPIXEL_BPP
35.225806
119
0.621062
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
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
7356ec7988fe8e9febc6102713b570ffe9912f4f
5,975
cpp
C++
3rdparty/GPSTk/ext/lib/Procframe/GravitationalDelay.cpp
mfkiwl/ICE
e660d031bb1bcea664db1de4946fd8781be5b627
[ "MIT" ]
50
2019-10-12T01:22:20.000Z
2022-02-15T23:28:26.000Z
3rdparty/GPSTk/ext/lib/Procframe/GravitationalDelay.cpp
wuyou33/Enabling-Robust-State-Estimation-through-Measurement-Error-Covariance-Adaptation
2f1ff054b7c5059da80bb3b2f80c05861a02cc36
[ "MIT" ]
null
null
null
3rdparty/GPSTk/ext/lib/Procframe/GravitationalDelay.cpp
wuyou33/Enabling-Robust-State-Estimation-through-Measurement-Error-Covariance-Adaptation
2f1ff054b7c5059da80bb3b2f80c05861a02cc36
[ "MIT" ]
14
2019-11-05T01:50:29.000Z
2021-08-06T06:23:44.000Z
//============================================================================ // // This file is part of GPSTk, the GPS Toolkit. // // The GPSTk is free software; you can redistribute it and/or modify // it under the terms of the GNU Lesser General Public License as published // by the Free Software Foundation; either version 3.0 of the License, or // any later version. // // The GPSTk is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public // License along with GPSTk; if not, write to the Free Software Foundation, // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA // // Copyright 2004, The University of Texas at Austin // Dagoberto Salazar - gAGE ( http://www.gage.es ). 2008, 2011 // //============================================================================ //============================================================================ // //This software developed by Applied Research Laboratories at the University of //Texas at Austin, under contract to an agency or agencies within the U.S. //Department of Defense. The U.S. Government retains all rights to use, //duplicate, distribute, disclose, or release this software. // //Pursuant to DoD Directive 523024 // // DISTRIBUTION STATEMENT A: This software has been approved for public // release, distribution is unlimited. // //============================================================================= /** * @file GravitationalDelay.cpp * This class computes the delay in the signal due to changes in gravity field. */ #include "GravitationalDelay.hpp" namespace gpstk { // Returns a string identifying this object. std::string GravitationalDelay::getClassName() const { return "GravitationalDelay"; } // Constant value needed for computation. This value comes from: // K = (1+gamma) muE / (c*c) // where: // - gamma = 1.0 (general relativity) // - muE = 3.986004418e14 m^3/s^2 (std gravitational parameter, Earth) // - c = 2.99792458e8 m/s (speed of light) const double K = 0.887005608e-2; /* Returns a satTypeValueMap object, adding the new data generated * when calling this object. * * @param epoch Time of observations. * @param gData Data object holding the data. */ satTypeValueMap& GravitationalDelay::Process( const CommonTime& epoch, satTypeValueMap& gData ) throw(ProcessingException) { try { SatIDSet satRejectedSet; // Define a Triple that will hold satellite position, in ECEF Triple svPos(0.0, 0.0, 0.0); // Loop through all the satellites satTypeValueMap::iterator it; for (it = gData.begin(); it != gData.end(); ++it) { // Check if satellite position is not already computed if( ( (*it).second.find(TypeID::satX) == (*it).second.end() ) || ( (*it).second.find(TypeID::satY) == (*it).second.end() ) || ( (*it).second.find(TypeID::satZ) == (*it).second.end() ) ) { // If satellite position is missing, then schedule this // satellite for removal satRejectedSet.insert( (*it).first ); continue; } else { // Get satellite position out of GDS svPos[0] = (*it).second[TypeID::satX]; svPos[1] = (*it).second[TypeID::satY]; svPos[2] = (*it).second[TypeID::satZ]; } // End of 'if( ( (*it).second.find(TypeID::satX) == ...' // Get magnitude of satellite position vector double r2(svPos.mag()); // Get vector from Earth mass center to receiver Triple rxPos(nominalPos.X(), nominalPos.Y(), nominalPos.Z()); // Compute magnitude of receiver position vector double r1(rxPos.mag()); // Compute the difference vector between satellite and // receiver positions Position difPos(svPos - rxPos); // Compute magnitude of the diference between rxPos and svPos double r12( difPos.mag() ); // Compute gravitational delay correction double gravDel( K*std::log( (r1+r2+r12)/(r1+r2-r12) ) ); // Get the correction into the GDS (*it).second[TypeID::gravDelay] = gravDel; } // End of 'for (it = gData.begin(); it != gData.end(); ++it)' // Remove satellites with missing data gData.removeSatID(satRejectedSet); return gData; } catch(Exception& u) { // Throw an exception if something unexpected happens ProcessingException e( getClassName() + ":" + u.what() ); GPSTK_THROW(e); } } // End of method 'GravitationalDelay::Process()' /* Returns a gnnsRinex object, adding the new data generated when * calling this object. * * @param gData Data object holding the data. */ gnssRinex& GravitationalDelay::Process(gnssRinex& gData) throw(ProcessingException) { try { Process(gData.header.epoch, gData.body); return gData; } catch(Exception& u) { // Throw an exception if something unexpected happens ProcessingException e( getClassName() + ":" + u.what() ); GPSTK_THROW(e); } } // End of method 'GravitationalDelay::Process()' } // End of namespace gpstk
31.951872
79
0.553138
7357263d07252d38c3915db364f5e0fd1297d4d1
8,364
cpp
C++
CGameFree.cpp
SAFETY1956/-
a49fd06061e45d3a95c9c6f2af0f6febeac619ec
[ "Apache-2.0" ]
null
null
null
CGameFree.cpp
SAFETY1956/-
a49fd06061e45d3a95c9c6f2af0f6febeac619ec
[ "Apache-2.0" ]
null
null
null
CGameFree.cpp
SAFETY1956/-
a49fd06061e45d3a95c9c6f2af0f6febeac619ec
[ "Apache-2.0" ]
null
null
null
// CGameFree.cpp: 实现文件 // #include "stdafx.h" #include "LLK.h" #include "CGameFree.h" #include "afxdialogex.h" #include <Windows.h> #include <MMSystem.h> #pragma comment( lib,"winmm.lib" ) // CGameFree 对话框 IMPLEMENT_DYNAMIC(CGameFree, CDialogEx) CGameFree::CGameFree(CWnd* pParent /*=nullptr*/) : CDialogEx(IDD_DIALOG1, pParent) { m_ptGame_Top.x = 50; m_ptGame_Top.y = 50; m_sizeElem.cx = 40; m_sizeElem.cy = 40; //初始化游戏更新区域 m_rtGameRect.top = m_ptGame_Top.y; m_rtGameRect.left = m_ptGame_Top.x; m_rtGameRect.right = m_rtGameRect.left + 16 * m_sizeElem.cx; m_rtGameRect.bottom = m_rtGameRect.top + 10 * m_sizeElem.cy; m_bFirstPoint = true; } CGameFree::~CGameFree() { } void CGameFree::DoDataExchange(CDataExchange* pDX) { CDialogEx::DoDataExchange(pDX); DDX_Control(pDX, IDC_TOOL, m_GIFctrl); } BEGIN_MESSAGE_MAP(CGameFree, CDialogEx) ON_WM_PAINT() ON_BN_CLICKED(IDC_XIU_HELP, &CGameFree::OnClickedXiuHelp) ON_BN_CLICKED(IDC_XIU_PAUSE, &CGameFree::OnClickedXiuPause) ON_BN_CLICKED(IDC_XIU_RESET, &CGameFree::OnClickedXiuReset) ON_BN_CLICKED(IDC_XIU_SET, &CGameFree::OnClickedXiuSet) ON_BN_CLICKED(IDC_XIU_START, &CGameFree::OnClickedXiuStart) ON_BN_CLICKED(IDC_XIU_TOOL, &CGameFree::OnClickedXiuTool) ON_WM_LBUTTONUP() ON_STN_CLICKED(IDC_TOOL, &CGameFree::OnStnClickedTool) END_MESSAGE_MAP() void CGameFree::InitBackgroubd() { HBITMAP bmp = LoadBitmap(AfxGetInstanceHandle(), (LPCWSTR)IDB_BITMAP7); CClientDC dc(this); m_dcBG.CreateCompatibleDC(&dc); m_dcBG.SelectObject(bmp); //初始化内存DC m_dcMen.CreateCompatibleDC(&dc); CBitmap bmpMen; bmpMen.CreateCompatibleBitmap(&dc, 1000, 600); m_dcMen.SelectObject(&bmpMen); //绘制背景到内存DC m_dcMen.BitBlt(0, 0, 1000, 600, &m_dcBG, 0, 0, SRCCOPY); UpdateWindow(); } BOOL CGameFree::OnInitDialog() { CDialogEx::OnInitDialog(); // TODO: 在此添加额外的初始化 InitBackgroubd(); InitElement(); Initpause(); InitResult(); InitGIF(); return TRUE; } void CGameFree::OnPaint() { CPaintDC dc(this); // device context for painting // TODO: 在此处添加消息处理程序代码 // 不为绘图消息调用 CDialogEx::OnPaint() dc.BitBlt(0, 0, 1000, 600, &m_dcMen, 0, 0, SRCCOPY); } void CGameFree::InitElement() { HBITMAP bmp = LoadBitmap(AfxGetInstanceHandle(), (LPCWSTR)IDB_BITMAP4); CClientDC dc(this); m_dcElement.CreateCompatibleDC(&dc); m_dcElement.SelectObject(bmp); HBITMAP bmp1 = LoadBitmap(AfxGetInstanceHandle(), (LPCWSTR)IDB_BITMAP5); m_dcMark.CreateCompatibleDC(&dc); m_dcMark.SelectObject(bmp1); } // CGameFree 消息处理程序 void CGameFree::OnClickedXiuHelp() { // TODO: 在此添加控件通知处理程序代码 } void CGameFree::OnClickedXiuPause() { //获得当前对话框的视频内容 CClientDC dc(this); //游戏没在进行时,直接返回 if (m_bPlaying == false) return; //如果游戏没有暂停 if (m_bPause == false) { //绘制背景到内存DC中 m_dcMen.BitBlt(MAP_LETF, MAP_TOP, 640, 400, &m_dcCache, 0, 0, SRCCOPY); // GetDlgItem(IDC_BUTTON_TIPS)->EnableWindow(0); GetDlgItem(IDC_XIU_RESET)->EnableWindow(0); InvalidateRect(m_rtGameRect, FALSE); //局部矩形更新 this->GetDlgItem(IDC_XIU_PAUSE)->SetWindowTextW(_T("继续游戏")); } //如果游戏暂停 if (m_bPause == true) { UpdateMap(); //GetDlgItem(IDC_BUTTON_TIPS)->EnableWindow(1); GetDlgItem(IDC_XIU_RESET)->EnableWindow(1); InvalidateRect(m_rtGameRect, FALSE); //局部矩形更新 this->GetDlgItem(IDC_XIU_PAUSE)->SetWindowTextW(_T("暂停游戏")); } m_bPause = !m_bPause; } void CGameFree::UpdateWindow() { CRect rtWin; CRect rtClient; this->GetWindowRect(rtWin); this->GetClientRect(rtClient); //标题栏和外边框的大小 int nSpanWidth = rtWin.Width() - rtClient.Width(); int nSpanHeight = rtWin.Height() - rtClient.Height(); //设置窗口大小 MoveWindow(0, 0, 1000 + nSpanWidth, 600 + nSpanHeight); CenterWindow(); } void CGameFree::UpdateMap() { int nLeft = m_ptGame_Top.x; int nTop = m_ptGame_Top.y; int nElemW = m_sizeElem.cx; int nElemH = m_sizeElem.cy; m_dcMen.BitBlt(m_rtGameRect.left, m_rtGameRect.top, m_rtGameRect.Width(), m_rtGameRect.Height(), &m_dcBG, m_rtGameRect.left, m_rtGameRect.top, SRCCOPY); for (int i = 0;i < 10;i++) { for (int j = 0;j < 16;j++) { int nInfo = m_gameControl.GetElement(i, j); //m_dcMen.BitBlt(nLeft + j * nElemW, nTop + i * nElemH, nElemW,nElemH, &m_dcElement, 0, m_anMap[i][j] * nElemH, SRCCOPY); m_dcMen.BitBlt(nLeft + j * nElemW, nTop + i * nElemH, nElemW, nElemH, &m_dcMark, 0, nInfo * nElemH, SRCPAINT); m_dcMen.BitBlt(nLeft + j * nElemW, nTop + i * nElemH, nElemW, nElemH, &m_dcElement, 0, nInfo * nElemH, SRCAND); } Invalidate(FALSE); } } void CGameFree::OnClickedXiuReset() { m_gameControl.Reset(); UpdateMap(); InvalidateRect(m_rtGameRect, FALSE); } void CGameFree::OnClickedXiuSet() { // TODO: 在此添加控件通知处理程序代码 } void CGameFree::OnClickedXiuStart() { m_bPlaying = true; m_bPause = false; if (m_bPause == true) return; //暂停时不响应 m_gameControl.StartGame(); UpdateMap(); } void CGameFree::Initpause() { CClientDC dc(this); HBITMAP bmp2 = LoadBitmap(AfxGetInstanceHandle(), (LPCWSTR)IDB_BITMAP3); m_dcCache.CreateCompatibleDC(&dc); m_dcCache.SelectObject(bmp2); } void CGameFree::InitResult() { CClientDC dc(this); HBITMAP bmp3 = LoadBitmap(AfxGetInstanceHandle(), (LPCWSTR)IDB_BITMAP6); m_dcWin.SelectObject(bmp3); HBITMAP bmp4 = LoadBitmap(AfxGetInstanceHandle(), (LPCWSTR)IDB_BITMAP2); m_dcLose.CreateCompatibleDC(&dc); m_dcLose.SelectObject(bmp4); } void CGameFree::OnClickedXiuTool() { //如果能够连通,绘制提示框和连接线并更新游戏地图 Vertex avPath[MAXVEXNUM]; //获得路径 int nVexnum = 0; //顶点个数 if (m_gameControl.select(avPath, nVexnum)) { //画第一个点的提示框 DrawTipFrame(avPath[0].row, avPath[0].col); //画第一个点的提示框 DrawTipFrame(avPath[nVexnum - 1].row, avPath[nVexnum - 1].col); m_GIFctrl.ShowWindow(SW_SHOW); //显示控件 UpdateMap(); //更新地图 InvalidateRect(m_rtGameRect, FALSE); //局部矩形更新 } } void CGameFree::OnLButtonUp(UINT nFlags, CPoint point) { if (point.x < m_ptGame_Top.x || point.y < m_ptGame_Top.y) { return CDialogEx::OnLButtonUp(nFlags, point); } int nRow = (point.y - m_ptGame_Top.y) / m_sizeElem.cy; int nCol = (point.x - m_ptGame_Top.x) / m_sizeElem.cx; if (nRow > 9 || nCol > 15) { return CDialogEx::OnLButtonUp(nFlags, point); } if (m_bFirstPoint) { DrawTipFrame(nRow, nCol); m_gameControl.SetFirstPoint(nRow, nCol); } else { DrawTipFrame(nRow, nCol); m_gameControl.SetSecPoint(nRow, nCol); //判断是否是相同图片 Vertex avPath[MAXVEXNUM]; int nVernum = 0; if (m_gameControl.Link(avPath, nVernum)) { DrawTipLine(avPath, nVernum); UpdateMap(); } Sleep(200); InvalidateRect(m_rtGameRect, FALSE); } m_bFirstPoint = !m_bFirstPoint; } void CGameFree::DrawTipFrame(int nRow, int nCol) { CClientDC dc(this); CBrush brush(RGB(223, 43, 43)); CRect rtTipFrame; rtTipFrame.left = m_ptGame_Top.x + nCol * m_sizeElem.cx; rtTipFrame.top = m_ptGame_Top.y + nRow * m_sizeElem.cy; rtTipFrame.right = rtTipFrame.left + m_sizeElem.cx; rtTipFrame.bottom = rtTipFrame.top + m_sizeElem.cy; dc.FrameRect(rtTipFrame, &brush); } void CGameFree::DrawTipLine(Vertex *asvPath, int nVexnum) { CClientDC dc(this); //设置画笔 CPen penLine(PS_SOLID, 2, RGB(0, 255, 0)); //将画笔选入DC CPen *pOldPen = dc.SelectObject(&penLine); //绘制连接线 dc.MoveTo(m_ptGame_Top.x + asvPath[0].col *m_sizeElem.cx + m_sizeElem.cx / 2, m_ptGame_Top.y + asvPath[0].row *m_sizeElem.cy + m_sizeElem.cy / 2); for (int i = 0;i < nVexnum - 1;i++) { dc.LineTo(m_ptGame_Top.x + asvPath[i + 1].col *m_sizeElem.cx + m_sizeElem.cx / 2, m_ptGame_Top.y + asvPath[i + 1].row *m_sizeElem.cy + m_sizeElem.cy / 2); } dc.SelectObject(pOldPen); } // 获取执行文件所有的路径 CString GetAbsolutePath() { CString strTemp; TCHAR *pBuf = strTemp.GetBuffer(MAX_PATH); ::GetModuleFileName(NULL, pBuf, MAX_PATH); strTemp.ReleaseBuffer(); strTemp = strTemp.Left(strTemp.ReverseFind(_T('\\'))) + _T('\\'); return strTemp; } void CGameFree::InitGIF() { CString strFile = GetAbsolutePath() + _T("tool.gif"); if (m_GIFctrl.Load(strFile)) { m_GIFctrl.Draw(); } m_GIFctrl.ShowWindow(SW_HIDE); //再隐藏控件 UpdateWindow(); } void CGameFree::OnStnClickedTool() { }
24.45614
157
0.684481
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
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
73587308ae31a021d44997a9a43e4ed92ec3cc01
16,573
cc
C++
chrome/browser/android/vr_shell/vr_shell_renderer.cc
xzhan96/chromium.src
1bd0cf3997f947746c0fc5406a2466e7b5f6159e
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
1
2021-01-07T18:51:03.000Z
2021-01-07T18:51:03.000Z
chrome/browser/android/vr_shell/vr_shell_renderer.cc
emilio/chromium.src
1bd0cf3997f947746c0fc5406a2466e7b5f6159e
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
null
null
null
chrome/browser/android/vr_shell/vr_shell_renderer.cc
emilio/chromium.src
1bd0cf3997f947746c0fc5406a2466e7b5f6159e
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
null
null
null
// Copyright 2016 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "chrome/browser/android/vr_shell/vr_shell_renderer.h" #include "chrome/browser/android/vr_shell/vr_gl_util.h" namespace { #define RECTANGULAR_TEXTURE_BUFFER(left, right, bottom, top) \ { left, bottom, left, top, right, bottom, left, top, right, top, right, \ bottom } static constexpr float kHalfHeight = 0.5f; static constexpr float kHalfWidth = 0.5f; static constexpr float kTextureQuadPosition[18] = { -kHalfWidth, kHalfHeight, 0.0f, -kHalfWidth, -kHalfHeight, 0.0f, kHalfWidth, kHalfHeight, 0.0f, -kHalfWidth, -kHalfHeight, 0.0f, kHalfWidth, -kHalfHeight, 0.0f, kHalfWidth, kHalfHeight, 0.0f}; static constexpr int kPositionDataSize = 3; // Number of vertices passed to glDrawArrays(). static constexpr int kVerticesNumber = 6; static constexpr float kTexturedQuadTextureCoordinates[12] = RECTANGULAR_TEXTURE_BUFFER(0.0f, 1.0f, 0.0f, 1.0f); static constexpr int kTextureCoordinateDataSize = 2; static constexpr float kWebVrVertices[16] = { // x y u, v -1.f, 1.f, 0.f, 0.f, -1.f, -1.f, 0.f, 1.f, 1.f, -1.f, 1.f, 1.f, 1.f, 1.f, 1.f, 0.f }; static constexpr int kWebVrVerticesSize = sizeof(float) * 16; // Reticle constants static constexpr float kRingDiameter = 1.0f; static constexpr float kInnerHole = 0.0f; static constexpr float kInnerRingEnd = 0.177f; static constexpr float kInnerRingThickness = 0.14f; static constexpr float kMidRingEnd = 0.177f; static constexpr float kMidRingOpacity = 0.22f; static constexpr float kReticleColor[] = {1.0f, 1.0f, 1.0f, 1.0f}; // Laser constants static constexpr float kFadeEnd = 0.535; static constexpr float kFadePoint = 0.5335; static constexpr float kLaserColor[] = {1.0f, 1.0f, 1.0f, 0.5f}; static constexpr int kLaserDataWidth = 48; static constexpr int kLaserDataHeight = 1; // Laser texture data, 48x1 RGBA. // TODO(mthiesse): As we add more resources for VR Shell, we should put them // in Chrome's resource files. static const unsigned char kLaserData[] = "\xff\xff\xff\x01\xff\xff\xff\x02\xbf\xbf\xbf\x04\xcc\xcc\xcc\x05\xdb\xdb" "\xdb\x07\xcc\xcc\xcc\x0a\xd8\xd8\xd8\x0d\xd2\xd2\xd2\x11\xce\xce\xce\x15" "\xce\xce\xce\x1a\xce\xce\xce\x1f\xcd\xcd\xcd\x24\xc8\xc8\xc8\x2a\xc9\xc9" "\xc9\x2f\xc9\xc9\xc9\x34\xc9\xc9\xc9\x39\xc9\xc9\xc9\x3d\xc8\xc8\xc8\x41" "\xcb\xcb\xcb\x44\xee\xee\xee\x87\xfa\xfa\xfa\xc8\xf9\xf9\xf9\xc9\xf9\xf9" "\xf9\xc9\xfa\xfa\xfa\xc9\xfa\xfa\xfa\xc9\xf9\xf9\xf9\xc9\xf9\xf9\xf9\xc9" "\xfa\xfa\xfa\xc8\xee\xee\xee\x87\xcb\xcb\xcb\x44\xc8\xc8\xc8\x41\xc9\xc9" "\xc9\x3d\xc9\xc9\xc9\x39\xc9\xc9\xc9\x34\xc9\xc9\xc9\x2f\xc8\xc8\xc8\x2a" "\xcd\xcd\xcd\x24\xce\xce\xce\x1f\xce\xce\xce\x1a\xce\xce\xce\x15\xd2\xd2" "\xd2\x11\xd8\xd8\xd8\x0d\xcc\xcc\xcc\x0a\xdb\xdb\xdb\x07\xcc\xcc\xcc\x05" "\xbf\xbf\xbf\x04\xff\xff\xff\x02\xff\xff\xff\x01"; #define SHADER(Src) #Src #define OEIE_SHADER(Src) "#extension GL_OES_EGL_image_external : require\n" #Src #define VOID_OFFSET(x) reinterpret_cast<void*>(x) const char* GetShaderSource(vr_shell::ShaderID shader) { switch (shader) { case vr_shell::ShaderID::TEXTURE_QUAD_VERTEX_SHADER: case vr_shell::ShaderID::RETICLE_VERTEX_SHADER: case vr_shell::ShaderID::LASER_VERTEX_SHADER: return SHADER(uniform mat4 u_CombinedMatrix; attribute vec4 a_Position; attribute vec2 a_TexCoordinate; varying vec2 v_TexCoordinate; void main() { v_TexCoordinate = a_TexCoordinate; gl_Position = u_CombinedMatrix * a_Position; }); case vr_shell::ShaderID::TEXTURE_QUAD_FRAGMENT_SHADER: return OEIE_SHADER( precision highp float; uniform samplerExternalOES u_Texture; uniform vec4 u_CopyRect; // rectangle varying vec2 v_TexCoordinate; void main() { vec2 scaledTex = vec2(u_CopyRect[0] + v_TexCoordinate.x * u_CopyRect[2], u_CopyRect[1] + v_TexCoordinate.y * u_CopyRect[3]); gl_FragColor = texture2D(u_Texture, scaledTex); }); case vr_shell::ShaderID::WEBVR_VERTEX_SHADER: return SHADER( attribute vec4 a_Position; varying vec2 v_TexCoordinate; void main() { // Pack the texcoord into the position to avoid state changes. v_TexCoordinate = a_Position.zw; gl_Position = vec4(a_Position.xy, 0.0, 1.0); }); case vr_shell::ShaderID::WEBVR_FRAGMENT_SHADER: return OEIE_SHADER( precision highp float; uniform samplerExternalOES u_Texture; varying vec2 v_TexCoordinate; void main() { gl_FragColor = texture2D(u_Texture, v_TexCoordinate); }); case vr_shell::ShaderID::RETICLE_FRAGMENT_SHADER: return SHADER( varying mediump vec2 v_TexCoordinate; uniform lowp vec4 color; uniform mediump float ring_diameter; uniform mediump float inner_hole; uniform mediump float inner_ring_end; uniform mediump float inner_ring_thickness; uniform mediump float mid_ring_end; uniform mediump float mid_ring_opacity; void main() { mediump float r = length(v_TexCoordinate - vec2(0.5, 0.5)); mediump float color_radius = inner_ring_end * ring_diameter; mediump float color_feather_radius = inner_ring_thickness * ring_diameter; mediump float hole_radius = inner_hole * ring_diameter - color_feather_radius; mediump float color1 = clamp( 1.0 - (r - color_radius) / color_feather_radius, 0.0, 1.0); mediump float hole_alpha = clamp((r - hole_radius) / color_feather_radius, 0.0, 1.0); mediump float black_radius = mid_ring_end * ring_diameter; mediump float black_feather = 1.0 / (ring_diameter * 0.5 - black_radius); mediump float black_alpha_factor = mid_ring_opacity * (1.0 - (r - black_radius) * black_feather); mediump float alpha = clamp( min(hole_alpha, max(color1, black_alpha_factor)), 0.0, 1.0); lowp vec3 color_rgb = color1 * color.xyz; gl_FragColor = vec4(color_rgb, color.w * alpha); }); case vr_shell::ShaderID::LASER_FRAGMENT_SHADER: return SHADER( varying mediump vec2 v_TexCoordinate; uniform sampler2D texture_unit; uniform lowp vec4 color; uniform mediump float fade_point; uniform mediump float fade_end; void main() { mediump vec2 uv = v_TexCoordinate; mediump float front_fade_factor = 1.0 - clamp(1.0 - (uv.y - fade_point) / (1.0 - fade_point), 0.0, 1.0); mediump float back_fade_factor = clamp((uv.y - fade_point) / (fade_end - fade_point), 0.0, 1.0); mediump float total_fade = front_fade_factor * back_fade_factor; lowp vec4 texture_color = texture2D(texture_unit, uv); lowp vec4 final_color = color * texture_color; gl_FragColor = vec4(final_color.xyz, final_color.w * total_fade); }); default: LOG(ERROR) << "Shader source requested for unknown shader"; return ""; } } #undef RECTANGULAR_TEXTURE_BUFFER } // namespace namespace vr_shell { BaseRenderer::BaseRenderer(ShaderID vertex_id, ShaderID fragment_id) { std::string error; GLuint vertex_shader_handle = CompileShader( GL_VERTEX_SHADER, GetShaderSource(vertex_id), error); CHECK(vertex_shader_handle) << error; GLuint fragment_shader_handle = CompileShader( GL_FRAGMENT_SHADER, GetShaderSource(fragment_id), error); CHECK(fragment_shader_handle) << error; program_handle_ = CreateAndLinkProgram(vertex_shader_handle, fragment_shader_handle, error); CHECK(program_handle_) << error; // Once the program is linked the shader objects are no longer needed glDeleteShader(vertex_shader_handle); glDeleteShader(fragment_shader_handle); position_handle_ = glGetAttribLocation(program_handle_, "a_Position"); tex_coord_handle_ = glGetAttribLocation(program_handle_, "a_TexCoordinate"); } BaseRenderer::~BaseRenderer() = default; void BaseRenderer::PrepareToDraw(GLuint combined_matrix_handle, const gvr::Mat4f& combined_matrix) { glUseProgram(program_handle_); // Pass in model view project matrix. glUniformMatrix4fv(combined_matrix_handle, 1, false, MatrixToGLArray(combined_matrix).data()); // Pass in texture coordinate. glVertexAttribPointer(tex_coord_handle_, kTextureCoordinateDataSize, GL_FLOAT, false, 0, kTexturedQuadTextureCoordinates); glEnableVertexAttribArray(tex_coord_handle_); glVertexAttribPointer(position_handle_, kPositionDataSize, GL_FLOAT, false, 0, kTextureQuadPosition); glEnableVertexAttribArray(position_handle_); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); } TexturedQuadRenderer::TexturedQuadRenderer() : BaseRenderer(TEXTURE_QUAD_VERTEX_SHADER, TEXTURE_QUAD_FRAGMENT_SHADER) { combined_matrix_handle_ = glGetUniformLocation(program_handle_, "u_CombinedMatrix"); tex_uniform_handle_ = glGetUniformLocation(program_handle_, "u_Texture"); copy_rect_uniform_handle_ = glGetUniformLocation(program_handle_, "u_CopyRect"); } void TexturedQuadRenderer::Draw(int texture_data_handle, const gvr::Mat4f& combined_matrix, const Rectf& copy_rect) { PrepareToDraw(combined_matrix_handle_, combined_matrix); // Link texture data with texture unit. glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_EXTERNAL_OES, texture_data_handle); glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glUniform1i(tex_uniform_handle_, 0); glUniform4fv(copy_rect_uniform_handle_, 1, (float*)(&copy_rect)); glDrawArrays(GL_TRIANGLES, 0, kVerticesNumber); glDisableVertexAttribArray(position_handle_); glDisableVertexAttribArray(tex_coord_handle_); } TexturedQuadRenderer::~TexturedQuadRenderer() = default; WebVrRenderer::WebVrRenderer() : BaseRenderer(WEBVR_VERTEX_SHADER, WEBVR_FRAGMENT_SHADER) { tex_uniform_handle_ = glGetUniformLocation(program_handle_, "u_Texture"); // TODO(bajones): Figure out why this need to be restored. GLint old_buffer; glGetIntegerv(GL_ARRAY_BUFFER_BINDING, &old_buffer); glGenBuffersARB(1, &vertex_buffer_); glBindBuffer(GL_ARRAY_BUFFER, vertex_buffer_); glBufferData(GL_ARRAY_BUFFER, kWebVrVerticesSize, kWebVrVertices, GL_STATIC_DRAW); glBindBuffer(GL_ARRAY_BUFFER, old_buffer); } // Draw the stereo WebVR frame void WebVrRenderer::Draw(int texture_handle) { // TODO(bajones): Figure out why this need to be restored. GLint old_buffer; glGetIntegerv(GL_ARRAY_BUFFER_BINDING, &old_buffer); glUseProgram(program_handle_); // Bind vertex attributes glBindBuffer(GL_ARRAY_BUFFER, vertex_buffer_); glEnableVertexAttribArray(position_handle_); glVertexAttribPointer(position_handle_, VERTEX_ELEMENTS, GL_FLOAT, false, VERTEX_STRIDE, VOID_OFFSET(VERTEX_OFFSET)); // Bind texture. Ideally this should be a 1:1 pixel copy. (Or even more // ideally, a zero copy reuse of the texture.) For now, we're using an // undersized render target for WebVR, so GL_LINEAR makes it look slightly // less chunky. TODO(klausw): change this to GL_NEAREST once we're doing // a 1:1 copy since that should be more efficient. glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_EXTERNAL_OES, texture_handle); glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glUniform1i(tex_uniform_handle_, 0); // Blit texture to buffer glDrawArrays(GL_TRIANGLE_FAN, 0, 4); glDisableVertexAttribArray(position_handle_); glBindBuffer(GL_ARRAY_BUFFER, old_buffer); } // Note that we don't explicitly delete gl objects here, they're deleted // automatically when we call ClearGLBindings, and deleting them here leads to // segfaults. WebVrRenderer::~WebVrRenderer() = default; ReticleRenderer::ReticleRenderer() : BaseRenderer(RETICLE_VERTEX_SHADER, RETICLE_FRAGMENT_SHADER) { combined_matrix_handle_ = glGetUniformLocation(program_handle_, "u_CombinedMatrix"); color_handle_ = glGetUniformLocation(program_handle_, "color"); ring_diameter_handle_ = glGetUniformLocation(program_handle_, "ring_diameter"); inner_hole_handle_ = glGetUniformLocation(program_handle_, "inner_hole"); inner_ring_end_handle_ = glGetUniformLocation(program_handle_, "inner_ring_end"); inner_ring_thickness_handle_ = glGetUniformLocation(program_handle_, "inner_ring_thickness"); mid_ring_end_handle_ = glGetUniformLocation(program_handle_, "mid_ring_end"); mid_ring_opacity_handle_ = glGetUniformLocation(program_handle_, "mid_ring_opacity"); } void ReticleRenderer::Draw(const gvr::Mat4f& combined_matrix) { PrepareToDraw(combined_matrix_handle_, combined_matrix); glUniform4f(color_handle_, kReticleColor[0], kReticleColor[1], kReticleColor[2], kReticleColor[3]); glUniform1f(ring_diameter_handle_, kRingDiameter); glUniform1f(inner_hole_handle_, kInnerHole); glUniform1f(inner_ring_end_handle_, kInnerRingEnd); glUniform1f(inner_ring_thickness_handle_, kInnerRingThickness); glUniform1f(mid_ring_end_handle_, kMidRingEnd); glUniform1f(mid_ring_opacity_handle_, kMidRingOpacity); glDrawArrays(GL_TRIANGLES, 0, kVerticesNumber); glDisableVertexAttribArray(position_handle_); glDisableVertexAttribArray(tex_coord_handle_); } ReticleRenderer::~ReticleRenderer() = default; LaserRenderer::LaserRenderer() : BaseRenderer(LASER_VERTEX_SHADER, LASER_FRAGMENT_SHADER) { combined_matrix_handle_ = glGetUniformLocation(program_handle_, "u_CombinedMatrix"); texture_unit_handle_ = glGetUniformLocation(program_handle_, "texture_unit"); color_handle_ = glGetUniformLocation(program_handle_, "color"); fade_point_handle_ = glGetUniformLocation(program_handle_, "fade_point"); fade_end_handle_ = glGetUniformLocation(program_handle_, "fade_end"); glGenTextures(1, &texture_data_handle_); glBindTexture(GL_TEXTURE_2D, texture_data_handle_); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, kLaserDataWidth, kLaserDataHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, kLaserData); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); } void LaserRenderer::Draw(const gvr::Mat4f& combined_matrix) { PrepareToDraw(combined_matrix_handle_, combined_matrix); // Link texture data with texture unit. glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, texture_data_handle_); glUniform1i(texture_unit_handle_, 0); glUniform4f(color_handle_, kLaserColor[0], kLaserColor[1], kLaserColor[2], kLaserColor[3]); glUniform1f(fade_point_handle_, kFadePoint); glUniform1f(fade_end_handle_, kFadeEnd); glDrawArrays(GL_TRIANGLES, 0, kVerticesNumber); glDisableVertexAttribArray(position_handle_); glDisableVertexAttribArray(tex_coord_handle_); } LaserRenderer::~LaserRenderer() = default; VrShellRenderer::VrShellRenderer() : textured_quad_renderer_(new TexturedQuadRenderer), webvr_renderer_(new WebVrRenderer), reticle_renderer_(new ReticleRenderer), laser_renderer_(new LaserRenderer) {} VrShellRenderer::~VrShellRenderer() = default; } // namespace vr_shell
40.719902
80
0.722923
7359b69116be43f028344c95fbb9b7d94ecd86d1
1,099
cpp
C++
Source/Framework/Core/Manager/TeAudioManager.cpp
fabsgc/TweedeFramework
dfd48f53a6c64b1c8b11ae2ed204dbfcb3ae6fda
[ "MIT" ]
2
2019-04-18T18:13:51.000Z
2020-06-02T10:58:21.000Z
Source/Framework/Core/Manager/TeAudioManager.cpp
fabsgc/TweedeFramework
dfd48f53a6c64b1c8b11ae2ed204dbfcb3ae6fda
[ "MIT" ]
null
null
null
Source/Framework/Core/Manager/TeAudioManager.cpp
fabsgc/TweedeFramework
dfd48f53a6c64b1c8b11ae2ed204dbfcb3ae6fda
[ "MIT" ]
1
2020-02-11T15:38:27.000Z
2020-02-11T15:38:27.000Z
#include "Manager/TeAudioManager.h" #include "Utility/TeDynLibManager.h" #include "Utility/TeDynLib.h" namespace te { AudioManager::AudioManager(const String& pluginName) : _plugin(nullptr) , _factory(nullptr) { _plugin = DynLibManager::Instance().Load(pluginName); if (_plugin != nullptr) { typedef AudioFactory* (*LoadPluginFunc)(); LoadPluginFunc loadPluginFunc = (LoadPluginFunc)_plugin->GetSymbol("LoadPlugin"); _factory = loadPluginFunc(); if (_factory != nullptr) _factory->StartUp(); } } AudioManager::~AudioManager() { if (_plugin != nullptr) { if (_factory != nullptr) { typedef void(*UnloadPluginFunc)(AudioFactory*); UnloadPluginFunc unloadPluginFunc = (UnloadPluginFunc)_plugin->GetSymbol("UnloadPlugin"); _factory->ShutDown(); unloadPluginFunc(_factory); } DynLibManager::Instance().Unload(_plugin); } } }
26.166667
105
0.569609
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
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
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
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
735fbff85eef398dbc2ddfe02ff8675ac9937cc4
6,254
cpp
C++
src/commands/CmdSummary.cpp
chrko/timewarrior
532d1b4e910d8431ffeabd5bb7a8e405a57e586e
[ "MIT" ]
null
null
null
src/commands/CmdSummary.cpp
chrko/timewarrior
532d1b4e910d8431ffeabd5bb7a8e405a57e586e
[ "MIT" ]
null
null
null
src/commands/CmdSummary.cpp
chrko/timewarrior
532d1b4e910d8431ffeabd5bb7a8e405a57e586e
[ "MIT" ]
null
null
null
//////////////////////////////////////////////////////////////////////////////// // // Copyright 2016 - 2020, Thomas Lauf, Paul Beckingham, Federico Hernandez. // // 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. // // https://www.opensource.org/licenses/mit-license.php // //////////////////////////////////////////////////////////////////////////////// #include <Table.h> #include <Duration.h> #include <shared.h> #include <format.h> #include <commands.h> #include <timew.h> #include <iostream> // Implemented in CmdChart.cpp. std::map <Datetime, std::string> createHolidayMap (Rules&, Interval&); std::string renderHolidays (const std::map <Datetime, std::string>&); //////////////////////////////////////////////////////////////////////////////// int CmdSummary ( const CLI& cli, Rules& rules, Database& database) { const bool verbose = rules.getBoolean ("verbose"); // Create a filter, and if empty, choose 'today'. auto filter = cli.getFilter (Range { Datetime ("today"), Datetime ("tomorrow") }); // Load the data. auto tracked = getTracked (database, rules, filter); if (tracked.empty ()) { if (verbose) { std::cout << "No filtered data found"; if (filter.is_started ()) { std::cout << " in the range " << filter.start.toISOLocalExtended (); if (filter.is_ended ()) std::cout << " - " << filter.end.toISOLocalExtended (); } if (! filter.tags ().empty ()) { std::cout << " tagged with " << joinQuotedIfNeeded (", ", filter.tags ()); } std::cout << ".\n"; } return 0; } // Map tags to colors. auto palette = createPalette (rules); auto tag_colors = createTagColorMap (rules, palette, tracked); Color colorID (rules.getBoolean ("color") ? rules.get ("theme.colors.ids") : ""); auto ids = findHint (cli, ":ids"); auto show_annotation = findHint (cli, ":annotations"); Table table; table.width (1024); table.colorHeader (Color ("underline")); table.add ("Wk"); table.add ("Date"); table.add ("Day"); if (ids) { table.add ("ID"); } table.add ("Tags"); auto offset = 0; if (show_annotation) { table.add ("Annotation"); offset = 1; } table.add ("Start", false); table.add ("End", false); table.add ("Time", false); table.add ("Total", false); // Each day is rendered separately. time_t grand_total = 0; Datetime previous; auto days_start = filter.is_started() ? filter.start : tracked.front ().start; auto days_end = filter.is_ended() ? filter.end : tracked.back ().end; if (days_end == 0) { days_end = Datetime (); } for (Datetime day = days_start.startOfDay (); day < days_end; ++day) { auto day_range = getFullDay (day); time_t daily_total = 0; int row = -1; for (auto& track : subset (day_range, tracked)) { // Make sure the track only represents one day. if ((track.is_open () && day > Datetime ())) continue; row = table.addRow (); if (day != previous) { table.set (row, 0, format ("W{1}", day.week ())); table.set (row, 1, day.toString ("Y-M-D")); table.set (row, 2, day.dayNameShort (day.dayOfWeek ())); previous = day; } // Intersect track with day. auto today = day_range.intersect (track); if (track.is_open () && day <= Datetime () && today.end > Datetime ()) today.end = Datetime (); std::string tags = join(", ", track.tags()); if (ids) { table.set (row, 3, format ("@{1}", track.id), colorID); } table.set (row, (ids ? 4 : 3), tags); if (show_annotation) { auto annotation = track.getAnnotation (); if (annotation.length () > 15) annotation = annotation.substr (0, 12) + "..."; table.set (row, (ids ? 5 : 4), annotation); } table.set (row, (ids ? 5 : 4) + offset, today.start.toString ("h:N:S")); table.set (row, (ids ? 6 : 5) + offset, (track.is_open () ? "-" : today.end.toString ("h:N:S"))); table.set (row, (ids ? 7 : 6) + offset, Duration (today.total ()).formatHours ()); daily_total += today.total (); } if (row != -1) table.set (row, (ids ? 8 : 7) + offset, Duration (daily_total).formatHours ()); grand_total += daily_total; } // Add the total. table.set (table.addRow (), (ids ? 8 : 7) + offset, " ", Color ("underline")); table.set (table.addRow (), (ids ? 8 : 7) + offset, Duration (grand_total).formatHours ()); const auto with_holidays = rules.getBoolean ("reports.summary.holidays"); std::cout << '\n' << table.render () << (with_holidays ? renderHolidays (createHolidayMap (rules, filter)) : "") << '\n'; return 0; } //////////////////////////////////////////////////////////////////////////////// std::string renderHolidays (const std::map<Datetime, std::string> &holidays) { std::stringstream out; for (auto &entry : holidays) { out << entry.first.toString ("Y-M-D") << " " << entry.second << '\n'; } return out.str (); } ////////////////////////////////////////////////////////////////////////////////
29.224299
103
0.569555
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
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
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
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
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
736d4f8ad7401c2184db476974f1f418f1285784
908
hpp
C++
ExternalLibraries/NvGameworksFramework/externals/include/Cg/determinant.hpp
centauroWaRRIor/VulkanSamples
5a7c58de820207cc0931a9db8c90f00453e31631
[ "MIT" ]
null
null
null
ExternalLibraries/NvGameworksFramework/externals/include/Cg/determinant.hpp
centauroWaRRIor/VulkanSamples
5a7c58de820207cc0931a9db8c90f00453e31631
[ "MIT" ]
null
null
null
ExternalLibraries/NvGameworksFramework/externals/include/Cg/determinant.hpp
centauroWaRRIor/VulkanSamples
5a7c58de820207cc0931a9db8c90f00453e31631
[ "MIT" ]
null
null
null
/* * Copyright 2005 by NVIDIA Corporation. All rights reserved. All * information contained herein is proprietary and confidential to NVIDIA * Corporation. Any use, reproduction, or disclosure without the written * permission of NVIDIA Corporation is prohibited. */ #ifndef __Cg_determinant_hpp__ #define __Cg_determinant_hpp__ #ifdef __Cg_stdlib_hpp__ #pragma message("error: include this header file (" __FILE__ ") before <Cg/stdlib.hpp>") #endif #include <Cg/matrix.hpp> namespace Cg { extern float1 determinant(float1x1 A); extern float1 determinant(float2x2 A); extern float1 determinant(float3x3 A); extern float1 determinant(float4x4 A); #ifdef __Cg_double_hpp__ extern double1 determinant(double1x1 A); extern double1 determinant(double2x2 A); extern double1 determinant(double3x3 A); extern double1 determinant(double4x4 A); #endif } // namespace Cg #endif // __Cg_determinant_hpp__
27.515152
88
0.790749
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
7371c310a8c120485d865d36fbc6a0f87475027e
9,589
cc
C++
common/unit_test/CryptoCNGMultithreadTest.cc
liuxiang88/core-alljoyn
549c966482d9b89da84aa528117584e7049916cb
[ "Apache-2.0" ]
33
2018-01-12T00:37:43.000Z
2022-03-24T02:31:36.000Z
common/unit_test/CryptoCNGMultithreadTest.cc
liuxiang88/core-alljoyn
549c966482d9b89da84aa528117584e7049916cb
[ "Apache-2.0" ]
1
2020-01-05T05:51:27.000Z
2020-01-05T05:51:27.000Z
common/unit_test/CryptoCNGMultithreadTest.cc
liuxiang88/core-alljoyn
549c966482d9b89da84aa528117584e7049916cb
[ "Apache-2.0" ]
30
2017-12-13T23:24:00.000Z
2022-01-25T02:11:19.000Z
/****************************************************************************** * Copyright (c) Open Connectivity Foundation (OCF), AllJoyn Open Source * Project (AJOSP) Contributors and others. * * SPDX-License-Identifier: Apache-2.0 * * All rights reserved. This program and the accompanying materials are * made available under the terms of the Apache License, Version 2.0 * which accompanies this distribution, and is available at * http://www.apache.org/licenses/LICENSE-2.0 * * Copyright (c) Open Connectivity Foundation and Contributors to AllSeen * Alliance. All rights reserved. * * Permission to use, copy, modify, and/or distribute this software for * any purpose with or without fee is hereby granted, provided that the * above copyright notice and this permission notice appear in all * copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR * PERFORMANCE OF THIS SOFTWARE. ******************************************************************************/ /* These tests apply only to CNG on Windows. */ #ifdef CRYPTO_CNG #include <gtest/gtest.h> #include <qcc/Crypto.h> #include "../crypto/Crypto.h" #include <qcc/CngCache.h> #include <qcc/Thread.h> #include <qcc/Util.h> #include <memory> #include <vector> using namespace qcc; /* * These tests have multiple threads that all attempt to initialize provider handles at the same * time. No matter what, when everything is done, all the threads should come away with the * same provider handles as all the other threads. */ static const int trials = 20; static const int numThreads = 100; typedef struct { BCRYPT_ALG_HANDLE handles[CngCache::ALGORITHM_COUNT][2]; } MultipleOpenHashHandleTestResult; static ThreadReturn STDCALL MultipleOpenHashHandleThreadRun(void* arg) { QStatus status; MultipleOpenHashHandleTestResult* result = reinterpret_cast<MultipleOpenHashHandleTestResult*>(arg); for (int algorithm = 0; algorithm < CngCache::ALGORITHM_COUNT; algorithm++) { status = cngCache.OpenHashHandle(static_cast<Crypto_Hash::Algorithm>(algorithm), false); if (ER_OK != status) { return reinterpret_cast<ThreadReturn>(status); } result->handles[algorithm][0] = cngCache.algHandles[algorithm][0]; status = cngCache.OpenHashHandle(static_cast<Crypto_Hash::Algorithm>(algorithm), true); if (ER_OK != status) { return reinterpret_cast<ThreadReturn>(status); } result->handles[algorithm][1] = cngCache.algHandles[algorithm][1]; } return reinterpret_cast<ThreadReturn>(ER_OK); } TEST(CryptoCNGMultithreadTest, MultipleOpenHashHandle) { MultipleOpenHashHandleTestResult results[numThreads]; std::vector<std::unique_ptr<Thread> > threads(numThreads); for (uint8_t trial = 0; trial < trials; trial++) { memset(results, 0, sizeof(results)); Crypto::Shutdown(); ASSERT_EQ(ER_OK, Crypto::Init()); for (size_t i = 0; i < threads.size(); i++) { threads[i].reset(new Thread("", MultipleOpenHashHandleThreadRun, false)); } for (size_t i = 0; i < threads.size(); i++) { ASSERT_EQ(ER_OK, threads[i]->Start(&results[i])); } for (size_t i = 0; i < threads.size(); i++) { ASSERT_EQ(ER_OK, threads[i]->Join()); ASSERT_FALSE(threads[i]->IsRunning()); ASSERT_EQ(reinterpret_cast<ThreadReturn>(ER_OK), threads[i]->GetExitValue()); } for (size_t i = 1; i < ArraySize(results); i++) { for (int alg = 0; alg < CngCache::ALGORITHM_COUNT; alg++) { EXPECT_NE(results[i].handles[alg][0], results[i].handles[alg][1]); EXPECT_EQ(results[0].handles[alg][0], results[i].handles[alg][0]); EXPECT_EQ(results[0].handles[alg][1], results[i].handles[alg][1]); } } } Crypto::Shutdown(); } static ThreadReturn STDCALL MultipleOpenAesHandleThreadRun(void* arg) { QStatus status; BCRYPT_ALG_HANDLE* handles = reinterpret_cast<BCRYPT_ALG_HANDLE*>(arg); status = cngCache.OpenCcmHandle(); if (ER_OK != status) { return reinterpret_cast<ThreadReturn>(status); } handles[0] = cngCache.ccmHandle; status = cngCache.OpenEcbHandle(); if (ER_OK != status) { return reinterpret_cast<ThreadReturn>(status); } handles[1] = cngCache.ecbHandle; return reinterpret_cast<ThreadReturn>(ER_OK); } TEST(CryptoCNGMultithreadTest, MultipleOpenAesHandle) { BCRYPT_ALG_HANDLE handles[numThreads][2]; std::vector<std::unique_ptr<Thread> > threads(numThreads); for (uint8_t trial = 0; trial < trials; trial++) { memset(handles, 0, sizeof(handles)); Crypto::Shutdown(); ASSERT_EQ(ER_OK, Crypto::Init()); for (size_t i = 0; i < threads.size(); i++) { threads[i].reset(new Thread("", MultipleOpenAesHandleThreadRun, false)); } for (size_t i = 0; i < threads.size(); i++) { ASSERT_EQ(ER_OK, threads[i]->Start(&handles[i])); } for (size_t i = 0; i < threads.size(); i++) { ASSERT_EQ(ER_OK, threads[i]->Join()); ASSERT_FALSE(threads[i]->IsRunning()); ASSERT_EQ(reinterpret_cast<ThreadReturn>(ER_OK), threads[i]->GetExitValue()); } for (size_t i = 1; i < ArraySize(handles); i++) { for (int alg = 0; alg < CngCache::ALGORITHM_COUNT; alg++) { EXPECT_NE(handles[i][0], handles[i][1]); EXPECT_EQ(handles[0][0], handles[i][0]); EXPECT_EQ(handles[0][1], handles[i][1]); } } } Crypto::Shutdown(); } static ThreadReturn STDCALL MultipleOpenEcdsaHandleThreadRun(void* arg) { QStatus status; BCRYPT_ALG_HANDLE* handles = reinterpret_cast<BCRYPT_ALG_HANDLE*>(arg); for (int algorithm = 0; algorithm < CngCache::ECDSA_ALGORITHM_COUNT; algorithm++) { status = cngCache.OpenEcdsaHandle(algorithm); if (ER_OK != status) { return reinterpret_cast<ThreadReturn>(status); } handles[algorithm] = cngCache.ecdsaHandles[algorithm]; } return reinterpret_cast<ThreadReturn>(ER_OK); } TEST(CryptoCNGMultithreadTest, MultipleOpenEcdsaHandle) { BCRYPT_ALG_HANDLE handles[numThreads][CngCache::ECDSA_ALGORITHM_COUNT]; std::vector<std::unique_ptr<Thread> > threads(numThreads); for (uint8_t trial = 0; trial < trials; trial++) { memset(handles, 0, sizeof(handles)); Crypto::Shutdown(); ASSERT_EQ(ER_OK, Crypto::Init()); for (size_t i = 0; i < threads.size(); i++) { threads[i].reset(new Thread("", MultipleOpenEcdsaHandleThreadRun, false)); } for (size_t i = 0; i < threads.size(); i++) { ASSERT_EQ(ER_OK, threads[i]->Start(&handles[i])); } for (size_t i = 0; i < threads.size(); i++) { ASSERT_EQ(ER_OK, threads[i]->Join()); ASSERT_FALSE(threads[i]->IsRunning()); ASSERT_EQ(reinterpret_cast<ThreadReturn>(ER_OK), threads[i]->GetExitValue()); } for (size_t i = 1; i < ArraySize(handles); i++) { for (int alg = 0; alg < CngCache::ECDSA_ALGORITHM_COUNT; alg++) { EXPECT_EQ(handles[0][alg], handles[i][alg]); } } } Crypto::Shutdown(); } static ThreadReturn STDCALL MultipleOpenEcdhHandleThreadRun(void* arg) { QStatus status; BCRYPT_ALG_HANDLE* handles = reinterpret_cast<BCRYPT_ALG_HANDLE*>(arg); for (int algorithm = 0; algorithm < CngCache::ECDH_ALGORITHM_COUNT; algorithm++) { status = cngCache.OpenEcdhHandle(algorithm); if (ER_OK != status) { return reinterpret_cast<ThreadReturn>(status); } handles[algorithm] = cngCache.ecdhHandles[algorithm]; } return reinterpret_cast<ThreadReturn>(ER_OK); } TEST(CryptoCNGMultithreadTest, MultipleOpenEcdhHandle) { BCRYPT_ALG_HANDLE handles[numThreads][CngCache::ECDH_ALGORITHM_COUNT]; std::vector<std::unique_ptr<Thread> > threads(numThreads); for (uint8_t trial = 0; trial < trials; trial++) { memset(handles, 0, sizeof(handles)); Crypto::Shutdown(); ASSERT_EQ(ER_OK, Crypto::Init()); for (size_t i = 0; i < threads.size(); i++) { threads[i].reset(new Thread("", MultipleOpenEcdhHandleThreadRun, false)); } for (size_t i = 0; i < threads.size(); i++) { ASSERT_EQ(ER_OK, threads[i]->Start(&handles[i])); } for (size_t i = 0; i < threads.size(); i++) { ASSERT_EQ(ER_OK, threads[i]->Join()); ASSERT_FALSE(threads[i]->IsRunning()); ASSERT_EQ(reinterpret_cast<ThreadReturn>(ER_OK), threads[i]->GetExitValue()); } for (size_t i = 1; i < ArraySize(handles); i++) { for (int alg = 0; alg < CngCache::ECDH_ALGORITHM_COUNT; alg++) { EXPECT_EQ(handles[0][alg], handles[i][alg]); } } } Crypto::Shutdown(); } #endif /* CRYPTO_CNG */
34.369176
104
0.623318
73724843459fec643b31b7e6fa8ef0158b6dc3b5
39,549
hpp
C++
src/simulators/matrix_product_state/matrix_product_state.hpp
RafeyIqbalRahman/qiskit-aer
4484040a0a210542c63c94d02394dd28711827b8
[ "Apache-2.0" ]
3
2021-11-08T11:46:42.000Z
2021-12-27T10:13:38.000Z
src/simulators/matrix_product_state/matrix_product_state.hpp
RafeyIqbalRahman/qiskit-aer
4484040a0a210542c63c94d02394dd28711827b8
[ "Apache-2.0" ]
2
2021-11-09T14:57:09.000Z
2022-01-12T12:35:58.000Z
artifacts/old_dataset_versions/original_commits_v02/qiskit-aer/qiskit-aer#1132/after/matrix_product_state.hpp
MattePalte/Bugs-Quantum-Computing-Platforms
0c1c805fd5dfce465a8955ee3faf81037023a23e
[ "MIT" ]
null
null
null
/** * This code is part of Qiskit. * * (C) Copyright IBM 2018, 2019. * * This code is licensed under the Apache License, Version 2.0. You may * obtain a copy of this license in the LICENSE.txt file in the root directory * of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. * * Any modifications or derivative works of this code must retain this * copyright notice, and modified files need to carry a notice indicating * that they have been altered from the originals. */ //========================================================================= // Tensor Network State - simulation method //========================================================================= // For this simulation method, we represent the state of the circuit using a tensor // network structure, the specifically matrix product state. The idea is based on // the following paper (there exist other sources as well): // The density-matrix renormalization group in the age of matrix product states by // Ulrich Schollwock. // //-------------------------------------------------------------------------- #ifndef _matrix_product_state_hpp #define _matrix_product_state_hpp #include <algorithm> #define _USE_MATH_DEFINES #include <math.h> #include "framework/json.hpp" #include "framework/utils.hpp" #include "simulators/state.hpp" #include "matrix_product_state_internal.hpp" #include "matrix_product_state_internal.cpp" #include "framework/linalg/almost_equal.hpp" namespace AER { namespace MatrixProductState { using OpType = Operations::OpType; // OpSet of supported instructions const Operations::OpSet StateOpSet( {OpType::gate, OpType::measure, OpType::reset, OpType::initialize, OpType::snapshot, OpType::barrier, OpType::bfunc, OpType::roerror, OpType::matrix, OpType::diagonal_matrix, OpType::kraus, OpType::save_expval, OpType::save_expval_var, OpType::save_densmat, OpType::save_statevec, OpType::save_probs, OpType::save_probs_ket, OpType::save_amps, OpType::save_amps_sq}, // Gates {"id", "x", "y", "z", "s", "sdg", "h", "t", "tdg", "p", "u1", "u2", "u3", "u", "U", "CX", "cx", "cy", "cz", "cp", "cu1", "swap", "ccx", "sx", "r", "rx", "ry", "rz", "rxx", "ryy", "rzz", "rzx", "csx", "delay", "cswap"}, // Snapshots {"statevector", "amplitudes", "memory", "register", "probabilities", "expectation_value_pauli", "expectation_value_pauli_with_variance", "expectation_value_pauli_single_shot", "expectation_value_matrix", "expectation_value_matrix_with_variance", "expectation_value_matrix_single_shot", "density_matrix", "density_matrix_with_variance"} ); // Allowed snapshots enum class enum class Snapshots { statevector, amplitudes, cmemory, cregister, probs, probs_var, densmat, densmat_var, expval_pauli, expval_pauli_var, expval_pauli_shot, expval_matrix, expval_matrix_var, expval_matrix_shot }; // Enum class for different types of expectation values enum class SnapshotDataType {average, average_var, pershot}; //========================================================================= // Matrix Product State subclass //========================================================================= using matrixproductstate_t = MPS; class State : public Base::State<matrixproductstate_t> { public: using BaseState = Base::State<matrixproductstate_t>; State() : BaseState(StateOpSet) {} State(uint_t num_qubits) : State() {qreg_.initialize((uint_t)num_qubits);} virtual ~State() = default; //----------------------------------------------------------------------- // Base class overrides //----------------------------------------------------------------------- // Return the string name of the State class virtual std::string name() const override { return "matrix_product_state"; } bool empty() const { return qreg_.empty(); } // Apply a sequence of operations by looping over list // If the input is not in allowed_ops an exception will be raised. virtual void apply_ops(const std::vector<Operations::Op> &ops, ExperimentResult &result, RngEngine &rng, bool final_ops = false) override; // Initializes an n-qubit state to the all |0> state virtual void initialize_qreg(uint_t num_qubits) override; // Initializes to a specific n-qubit state given as a complex std::vector void initialize_qreg(uint_t num_qubits, const cvector_t &statevector); virtual void initialize_qreg(uint_t num_qubits, const matrixproductstate_t &state) override; // Returns the required memory for storing an n-qubit state in megabytes. // For this state the memory is indepdentent of the number of ops // and is approximately 16 * 1 << num_qubits bytes virtual size_t required_memory_mb(uint_t num_qubits, const std::vector<Operations::Op> &ops) const override; // Load the threshold for applying OpenMP parallelization // if the controller/engine allows threads for it // We currently set the threshold to 1 in qasm_controller.hpp, i.e., no parallelization virtual void set_config(const json_t &config) override; virtual void add_metadata(ExperimentResult &result) const override; // Sample n-measurement outcomes without applying the measure operation // to the system state virtual std::vector<reg_t> sample_measure(const reg_t& qubits, uint_t shots, RngEngine &rng) override; // Computes sample_measure by first computing the probabilities and then // randomly chooses measurement outcomes based on the probability weights std::vector<reg_t> sample_measure_using_probabilities(const reg_t &qubits, uint_t shots, RngEngine &rng); // Computes sample_measure by copying the MPS to a temporary structure, and // applying a measurement on the temporary MPS. This is done for every shot, // so is not efficient for a large number of shots std::vector<reg_t> sample_measure_using_apply_measure(const reg_t &qubits, uint_t shots, RngEngine &rng) const; //----------------------------------------------------------------------- // Additional methods //----------------------------------------------------------------------- void initialize_omp(); protected: //----------------------------------------------------------------------- // Apply instructions //----------------------------------------------------------------------- // Applies a sypported Gate operation to the state class. // If the input is not in allowed_gates an exeption will be raised. void apply_gate(const Operations::Op &op); // Initialize the specified qubits to a given state |psi> // by creating the MPS state with the new state |psi>. // |psi> is given in params // Currently only supports intialization of all qubits void apply_initialize(const reg_t &qubits, const cvector_t &params, RngEngine &rng); // Measure qubits and return a list of outcomes [q0, q1, ...] // If a state subclass supports this function, then "measure" // should be contained in the set defined by 'allowed_ops' virtual void apply_measure(const reg_t &qubits, const reg_t &cmemory, const reg_t &cregister, RngEngine &rng); // Reset the specified qubits to the |0> state by simulating // a measurement, applying a conditional x-gate if the outcome is 1, and // then discarding the outcome. void apply_reset(const reg_t &qubits, RngEngine &rng); // Apply a supported snapshot instruction // If the input is not in allowed_snapshots an exception will be raised. virtual void apply_snapshot(const Operations::Op &op, ExperimentResult &result); // Apply a matrix to given qubits (identity on all other qubits) // We assume matrix to be 2x2 void apply_matrix(const reg_t &qubits, const cmatrix_t & mat); // Apply a vectorized matrix to given qubits (identity on all other qubits) void apply_matrix(const reg_t &qubits, const cvector_t & vmat); // Apply a Kraus error operation void apply_kraus(const reg_t &qubits, const std::vector<cmatrix_t> &kmats, RngEngine &rng); //----------------------------------------------------------------------- // Save data instructions //----------------------------------------------------------------------- // Compute and save the statevector for the current simulator state void apply_save_statevector(const Operations::Op &op, ExperimentResult &result); // Save the current density matrix or reduced density matrix void apply_save_density_matrix(const Operations::Op &op, ExperimentResult &result); // Helper function for computing expectation value void apply_save_probs(const Operations::Op &op, ExperimentResult &result); // Helper function for saving amplitudes and amplitudes squared void apply_save_amplitudes(const Operations::Op &op, ExperimentResult &result); // Helper function for computing expectation value virtual double expval_pauli(const reg_t &qubits, const std::string& pauli) override; //----------------------------------------------------------------------- // Measurement Helpers //----------------------------------------------------------------------- // Return vector of measure probabilities for specified qubits // If a state subclass supports this function, then "measure" // must be contained in the set defined by 'allowed_ops' rvector_t measure_probs(const reg_t &qubits) const; // Sample the measurement outcome for qubits // return a pair (m, p) of the outcome m, and its corresponding // probability p. // Outcome is given as an int: Eg for two-qubits {q0, q1} we have // 0 -> |q1 = 0, q0 = 0> state // 1 -> |q1 = 0, q0 = 1> state // 2 -> |q1 = 1, q0 = 0> state // 3 -> |q1 = 1, q0 = 1> state std::pair<uint_t, double> sample_measure_with_prob(const reg_t &qubits, RngEngine &rng); //----------------------------------------------------------------------- // Special snapshot types // // IMPORTANT: These methods are not marked const to allow modifying state // during snapshot, but after the snapshot is applied the simulator // should be left in the pre-snapshot state. //----------------------------------------------------------------------- // Snapshot current qubit probabilities for a measurement (average) void snapshot_probabilities(const Operations::Op &op, ExperimentResult &result, SnapshotDataType type); void snapshot_density_matrix(const Operations::Op &op, ExperimentResult &result, SnapshotDataType type); // Snapshot the expectation value of a Pauli operator void snapshot_pauli_expval(const Operations::Op &op, ExperimentResult &result, SnapshotDataType type); // Snapshot the expectation value of a matrix operator void snapshot_matrix_expval(const Operations::Op &op, ExperimentResult &result, SnapshotDataType type); // Snapshot the state vector void snapshot_state(const Operations::Op &op, ExperimentResult &result, std::string name = ""); //----------------------------------------------------------------------- // Single-qubit gate helpers //----------------------------------------------------------------------- // Apply a waltz gate specified by parameters u3(theta, phi, lambda) void apply_gate_u3(const uint_t qubit, const double theta, const double phi, const double lambda); // Optimize phase gate with diagonal [1, phase] void apply_gate_phase(const uint_t qubit, const complex_t phase); //----------------------------------------------------------------------- // Config Settings //----------------------------------------------------------------------- // Table of allowed gate names to gate enum class members const static stringmap_t<Gates> gateset_; // Table of allowed snapshot types to enum class members const static stringmap_t<Snapshots> snapshotset_; }; //========================================================================= // Implementation: Allowed ops and gateset //========================================================================= const stringmap_t<Gates> State::gateset_({ // Single qubit gates {"id", Gates::id}, // Pauli-Identity gate {"delay", Gates::id}, {"x", Gates::x}, // Pauli-X gate {"y", Gates::y}, // Pauli-Y gate {"z", Gates::z}, // Pauli-Z gate {"s", Gates::s}, // Phase gate (aka sqrt(Z) gate) {"sdg", Gates::sdg}, // Conjugate-transpose of Phase gate {"h", Gates::h}, // Hadamard gate (X + Z / sqrt(2)) {"sx", Gates::sx}, // Sqrt(X) gate {"t", Gates::t}, // T-gate (sqrt(S)) {"tdg", Gates::tdg}, // Conjguate-transpose of T gate {"r", Gates::r}, // R rotation gate {"rx", Gates::rx}, // Pauli-X rotation gate {"ry", Gates::ry}, // Pauli-Y rotation gate {"rz", Gates::rz}, // Pauli-Z rotation gate // Waltz Gates {"p", Gates::u1}, // zero-X90 pulse waltz gate {"u1", Gates::u1}, // zero-X90 pulse waltz gate {"u2", Gates::u2}, // single-X90 pulse waltz gate {"u3", Gates::u3}, // two X90 pulse waltz gate {"u", Gates::u3}, // two X90 pulse waltz gate {"U", Gates::u3}, // two X90 pulse waltz gate // Two-qubit gates {"CX", Gates::cx}, // Controlled-X gate (CNOT) {"cx", Gates::cx}, // Controlled-X gate (CNOT) {"cy", Gates::cy}, // Controlled-Y gate {"cz", Gates::cz}, // Controlled-Z gate {"cu1", Gates::cu1}, // Controlled-U1 gate {"cp", Gates::cu1}, // Controlled-U1 gate {"csx", Gates::csx}, {"swap", Gates::swap}, // SWAP gate {"rxx", Gates::rxx}, // Pauli-XX rotation gate {"ryy", Gates::ryy}, // Pauli-YY rotation gate {"rzz", Gates::rzz}, // Pauli-ZZ rotation gate {"rzx", Gates::rzx}, // Pauli-ZX rotation gate // Three-qubit gates {"ccx", Gates::ccx}, // Controlled-CX gate (Toffoli) {"cswap", Gates::cswap} }); const stringmap_t<Snapshots> State::snapshotset_({ {"statevector", Snapshots::statevector}, {"amplitudes", Snapshots::amplitudes}, {"probabilities", Snapshots::probs}, {"expectation_value_pauli", Snapshots::expval_pauli}, {"expectation_value_matrix", Snapshots::expval_matrix}, {"probabilities_with_variance", Snapshots::probs_var}, {"density_matrix", Snapshots::densmat}, {"density_matrix_with_variance", Snapshots::densmat_var}, {"expectation_value_pauli_with_variance", Snapshots::expval_pauli_var}, {"expectation_value_matrix_with_variance", Snapshots::expval_matrix_var}, {"expectation_value_pauli_single_shot", Snapshots::expval_pauli_shot}, {"expectation_value_matrix_single_shot", Snapshots::expval_matrix_shot}, {"memory", Snapshots::cmemory}, {"register", Snapshots::cregister} }); //========================================================================= // Implementation: Base class method overrides //========================================================================= //------------------------------------------------------------------------- // Initialization //------------------------------------------------------------------------- void State::initialize_qreg(uint_t num_qubits=0) { qreg_.initialize(num_qubits); } void State::initialize_qreg(uint_t num_qubits, const cvector_t &statevector) { if (qreg_.num_qubits() != num_qubits) throw std::invalid_argument("MatrixProductState::State::initialize_qreg: initial state does not match qubit number"); reg_t qubits(num_qubits); std::iota(qubits.begin(), qubits.end(), 0); qreg_.initialize_from_statevector_internal(qubits, statevector); } void State::initialize_qreg(uint_t num_qubits, const matrixproductstate_t &state) { // Check dimension of state if (qreg_.num_qubits() != num_qubits) { throw std::invalid_argument("MatrixProductState::State::initialize_qreg: initial state does not match qubit number"); } #ifdef DEBUG std::cout << "initialize with state not supported yet"; #endif } void State::initialize_omp() { if (BaseState::threads_ > 0) qreg_.set_omp_threads(BaseState::threads_); // set allowed OMP threads in MPS } size_t State::required_memory_mb(uint_t num_qubits, const std::vector<Operations::Op> &ops) const { // for each qubit we have a tensor structure. // Initially, each tensor contains 2 matrices with a single complex double // Depending on the number of 2-qubit gates, // these matrices may double their size // for now - compute only initial size // later - FIXME size_t mem_mb = 16 * 2 * num_qubits; return mem_mb; } void State::set_config(const json_t &config) { // Set threshold for truncating Schmidt coefficients double threshold; if (JSON::get_value(threshold, "matrix_product_state_truncation_threshold", config)) MPS_Tensor::set_truncation_threshold(threshold); else MPS_Tensor::set_truncation_threshold(1e-16); uint_t max_bond_dimension; if (JSON::get_value(max_bond_dimension, "matrix_product_state_max_bond_dimension", config)) MPS_Tensor::set_max_bond_dimension(max_bond_dimension); else MPS_Tensor::set_max_bond_dimension(UINT64_MAX); // Set threshold for truncating snapshots uint_t json_chop_threshold; if (JSON::get_value(json_chop_threshold, "chop_threshold", config)) MPS::set_json_chop_threshold(json_chop_threshold); else MPS::set_json_chop_threshold(1E-8); // Set OMP num threshold uint_t omp_qubit_threshold; if (JSON::get_value(omp_qubit_threshold, "mps_parallel_threshold", config)) MPS::set_omp_threshold(omp_qubit_threshold); else MPS::set_omp_threshold(14); // Set OMP threads uint_t omp_threads; if (JSON::get_value(omp_threads, "mps_omp_threads", config)) MPS::set_omp_threads(omp_threads); else MPS::set_omp_threads(1); // Set the algorithm for sample measure std::string alg; if (JSON::get_value(alg, "mps_sample_measure_algorithm", config)) { if (alg.compare("mps_probabilities") == 0) { MPS::set_sample_measure_alg(Sample_measure_alg::PROB); } else if (alg.compare("mps_apply_measure") == 0) { MPS::set_sample_measure_alg(Sample_measure_alg::APPLY_MEASURE); } } else { MPS::set_sample_measure_alg(Sample_measure_alg::HEURISTIC); } } void State::add_metadata(ExperimentResult &result) const { result.metadata.add( MPS_Tensor::get_truncation_threshold(), "matrix_product_state_truncation_threshold"); result.metadata.add( MPS_Tensor::get_max_bond_dimension(), "matrix_product_state_max_bond_dimension"); result.metadata.add( MPS::get_sample_measure_alg(), "matrix_product_state_sample_measure_algorithm"); } //========================================================================= // Implementation: apply operations //========================================================================= void State::apply_ops(const std::vector<Operations::Op> &ops, ExperimentResult &result, RngEngine &rng, bool final_ops) { // Simple loop over vector of input operations for (const auto &op: ops) { if(BaseState::creg_.check_conditional(op)) { switch (op.type) { case OpType::barrier: break; case OpType::reset: apply_reset(op.qubits, rng); break; case OpType::initialize: apply_initialize(op.qubits, op.params, rng); break; case OpType::measure: apply_measure(op.qubits, op.memory, op.registers, rng); break; case OpType::bfunc: BaseState::creg_.apply_bfunc(op); break; case OpType::roerror: BaseState::creg_.apply_roerror(op, rng); break; case OpType::gate: apply_gate(op); break; case OpType::snapshot: apply_snapshot(op, result); break; case OpType::matrix: apply_matrix(op.qubits, op.mats[0]); break; case OpType::diagonal_matrix: BaseState::qreg_.apply_diagonal_matrix(op.qubits, op.params); break; case OpType::kraus: apply_kraus(op.qubits, op.mats, rng); break; case OpType::save_expval: case OpType::save_expval_var: BaseState::apply_save_expval(op, result); break; case OpType::save_densmat: apply_save_density_matrix(op, result); break; case OpType::save_statevec: apply_save_statevector(op, result); break; case OpType::save_probs: case OpType::save_probs_ket: apply_save_probs(op, result); break; case OpType::save_amps: case OpType::save_amps_sq: apply_save_amplitudes(op, result); break; default: throw std::invalid_argument("MatrixProductState::State::invalid instruction \'" + op.name + "\'."); } } } } //========================================================================= // Implementation: Save data //========================================================================= void State::apply_save_probs(const Operations::Op &op, ExperimentResult &result) { rvector_t probs; qreg_.get_probabilities_vector(probs, op.qubits); if (op.type == OpType::save_probs_ket) { BaseState::save_data_average(result, op.string_params[0], Utils::vec2ket(probs, MPS::get_json_chop_threshold(), 16), op.save_type); } else { BaseState::save_data_average(result, op.string_params[0], std::move(probs), op.save_type); } } void State::apply_save_amplitudes(const Operations::Op &op, ExperimentResult &result) { if (op.int_params.empty()) { throw std::invalid_argument("Invalid save amplitudes instructions (empty params)."); } Vector<complex_t> amps = qreg_.get_amplitude_vector(op.int_params); if (op.type == OpType::save_amps_sq) { // Square amplitudes std::vector<double> amps_sq(op.int_params.size()); std::transform(amps.data(), amps.data() + amps.size(), amps_sq.begin(), [](complex_t val) -> double { return pow(abs(val), 2); }); BaseState::save_data_average(result, op.string_params[0], std::move(amps_sq), op.save_type); } else { BaseState::save_data_pershot(result, op.string_params[0], std::move(amps), op.save_type); } } double State::expval_pauli(const reg_t &qubits, const std::string& pauli) { return BaseState::qreg_.expectation_value_pauli(qubits, pauli).real(); } void State::apply_save_statevector(const Operations::Op &op, ExperimentResult &result) { if (op.qubits.size() != BaseState::qreg_.num_qubits()) { throw std::invalid_argument( "Save statevector was not applied to all qubits." " Only the full statevector can be saved."); } BaseState::save_data_pershot(result, op.string_params[0], qreg_.full_statevector(), op.save_type); } void State::apply_save_density_matrix(const Operations::Op &op, ExperimentResult &result) { cmatrix_t reduced_state; if (op.qubits.empty()) { reduced_state = cmatrix_t(1, 1); reduced_state[0] = qreg_.norm(); } else { reduced_state = qreg_.density_matrix(op.qubits); } BaseState::save_data_average(result, op.string_params[0], std::move(reduced_state), op.save_type); } //========================================================================= // Implementation: Snapshots //========================================================================= void State::snapshot_pauli_expval(const Operations::Op &op, ExperimentResult &result, SnapshotDataType type){ if (op.params_expval_pauli.empty()) { throw std::invalid_argument("Invalid expval snapshot (Pauli components are empty)."); } //Compute expval components complex_t expval(0., 0.); for (const auto &param : op.params_expval_pauli) { complex_t coeff = param.first; std::string pauli_matrices = param.second; expval += coeff * expval_pauli(op.qubits, pauli_matrices); } // add to snapshot Utils::chop_inplace(expval, MPS::get_json_chop_threshold()); switch (type) { case SnapshotDataType::average: result.legacy_data.add_average_snapshot("expectation_value", op.string_params[0], BaseState::creg_.memory_hex(), expval, false); break; case SnapshotDataType::average_var: result.legacy_data.add_average_snapshot("expectation_value", op.string_params[0], BaseState::creg_.memory_hex(), expval, true); break; case SnapshotDataType::pershot: result.legacy_data.add_pershot_snapshot("expectation_values", op.string_params[0], expval); break; } } void State::snapshot_matrix_expval(const Operations::Op &op, ExperimentResult &result, SnapshotDataType type){ if (op.params_expval_matrix.empty()) { throw std::invalid_argument("Invalid matrix snapshot (components are empty)."); } complex_t expval(0., 0.); double one_expval = 0; for (const auto &param : op.params_expval_matrix) { complex_t coeff = param.first; for (const auto &pair: param.second) { reg_t sub_qubits; for (const auto pos : pair.first) { sub_qubits.push_back(op.qubits[pos]); } const cmatrix_t &mat = pair.second; one_expval = qreg_.expectation_value(sub_qubits, mat); expval += coeff * one_expval; } } // add to snapshot Utils::chop_inplace(expval, MPS::get_json_chop_threshold()); switch (type) { case SnapshotDataType::average: result.legacy_data.add_average_snapshot("expectation_value", op.string_params[0], BaseState::creg_.memory_hex(), expval, false); break; case SnapshotDataType::average_var: result.legacy_data.add_average_snapshot("expectation_value", op.string_params[0], BaseState::creg_.memory_hex(), expval, true); break; case SnapshotDataType::pershot: result.legacy_data.add_pershot_snapshot("expectation_values", op.string_params[0], expval); break; } } void State::snapshot_state(const Operations::Op &op, ExperimentResult &result, std::string name) { result.legacy_data.add_pershot_snapshot( "statevector", op.string_params[0], qreg_.full_statevector()); } void State::snapshot_probabilities(const Operations::Op &op, ExperimentResult &result, SnapshotDataType type) { rvector_t prob_vector; qreg_.get_probabilities_vector(prob_vector, op.qubits); auto probs = Utils::vec2ket(prob_vector, MPS::get_json_chop_threshold(), 16); bool variance = type == SnapshotDataType::average_var; result.legacy_data.add_average_snapshot("probabilities", op.string_params[0], BaseState::creg_.memory_hex(), probs, variance); } void State::snapshot_density_matrix(const Operations::Op &op, ExperimentResult &result, SnapshotDataType type) { cmatrix_t reduced_state; if (op.qubits.empty()) { reduced_state = cmatrix_t(1, 1); reduced_state[0] = qreg_.norm(); } else { reduced_state = qreg_.density_matrix(op.qubits); } // Add density matrix to result data switch (type) { case SnapshotDataType::average: result.legacy_data.add_average_snapshot("density_matrix", op.string_params[0], BaseState::creg_.memory_hex(), std::move(reduced_state), false); break; case SnapshotDataType::average_var: result.legacy_data.add_average_snapshot("density_matrix", op.string_params[0], BaseState::creg_.memory_hex(), std::move(reduced_state), true); break; case SnapshotDataType::pershot: result.legacy_data.add_pershot_snapshot("density_matrix", op.string_params[0], std::move(reduced_state)); break; } } void State::apply_gate(const Operations::Op &op) { // Look for gate name in gateset auto it = gateset_.find(op.name); if (it == gateset_.end()) throw std::invalid_argument( "MatrixProductState::State::invalid gate instruction \'" + op.name + "\'."); switch (it -> second) { case Gates::ccx: qreg_.apply_ccx(op.qubits); break; case Gates::cswap: qreg_.apply_cswap(op.qubits); break; case Gates::u3: qreg_.apply_u3(op.qubits[0], std::real(op.params[0]), std::real(op.params[1]), std::real(op.params[2])); break; case Gates::u2: qreg_.apply_u2(op.qubits[0], std::real(op.params[0]), std::real(op.params[1])); break; case Gates::u1: qreg_.apply_u1(op.qubits[0], std::real(op.params[0])); break; case Gates::cx: qreg_.apply_cnot(op.qubits[0], op.qubits[1]); break; case Gates::id: { break; } case Gates::x: qreg_.apply_x(op.qubits[0]); break; case Gates::y: qreg_.apply_y(op.qubits[0]); break; case Gates::z: qreg_.apply_z(op.qubits[0]); break; case Gates::h: qreg_.apply_h(op.qubits[0]); break; case Gates::s: qreg_.apply_s(op.qubits[0]); break; case Gates::sdg: qreg_.apply_sdg(op.qubits[0]); break; case Gates::sx: qreg_.apply_sx(op.qubits[0]); break; case Gates::t: qreg_.apply_t(op.qubits[0]); break; case Gates::tdg: qreg_.apply_tdg(op.qubits[0]); break; case Gates::r: qreg_.apply_r(op.qubits[0], std::real(op.params[0]), std::real(op.params[1])); break; case Gates::rx: qreg_.apply_rx(op.qubits[0], std::real(op.params[0])); break; case Gates::ry: qreg_.apply_ry(op.qubits[0], std::real(op.params[0])); break; case Gates::rz: qreg_.apply_rz(op.qubits[0], std::real(op.params[0])); break; case Gates::swap: qreg_.apply_swap(op.qubits[0], op.qubits[1], true); break; case Gates::cy: qreg_.apply_cy(op.qubits[0], op.qubits[1]); break; case Gates::cz: qreg_.apply_cz(op.qubits[0], op.qubits[1]); break; case Gates::csx: qreg_.apply_csx(op.qubits[0], op.qubits[1]); break; case Gates::cu1: qreg_.apply_cu1(op.qubits[0], op.qubits[1], std::real(op.params[0])); break; case Gates::rxx: qreg_.apply_rxx(op.qubits[0], op.qubits[1], std::real(op.params[0])); break; case Gates::ryy: qreg_.apply_ryy(op.qubits[0], op.qubits[1], std::real(op.params[0])); break; case Gates::rzz: qreg_.apply_rzz(op.qubits[0], op.qubits[1], std::real(op.params[0])); break; case Gates::rzx: qreg_.apply_rzx(op.qubits[0], op.qubits[1], std::real(op.params[0])); break; default: // We shouldn't reach here unless there is a bug in gateset throw std::invalid_argument( "MatrixProductState::State::invalid gate instruction \'" + op.name + "\'."); } } void State::apply_matrix(const reg_t &qubits, const cmatrix_t &mat) { if (!qubits.empty() && mat.size() > 0) qreg_.apply_matrix(qubits, mat); } void State::apply_matrix(const reg_t &qubits, const cvector_t &vmat) { // Check if diagonal matrix if (vmat.size() == 1ULL << qubits.size()) { qreg_.apply_diagonal_matrix(qubits, vmat); } else { qreg_.apply_matrix(qubits, vmat); } } void State::apply_kraus(const reg_t &qubits, const std::vector<cmatrix_t> &kmats, RngEngine &rng) { qreg_.apply_kraus(qubits, kmats, rng); } //========================================================================= // Implementation: Reset and Measurement Sampling //========================================================================= void State::apply_initialize(const reg_t &qubits, const cvector_t &params, RngEngine &rng) { qreg_.apply_initialize(qubits, params, rng); } void State::apply_measure(const reg_t &qubits, const reg_t &cmemory, const reg_t &cregister, RngEngine &rng) { reg_t outcome = qreg_.apply_measure(qubits, rng); creg_.store_measure(outcome, cmemory, cregister); } rvector_t State::measure_probs(const reg_t &qubits) const { rvector_t probvector; qreg_.get_probabilities_vector(probvector, qubits); return probvector; } std::vector<reg_t> State::sample_measure(const reg_t &qubits, uint_t shots, RngEngine &rng) { // There are two alternative algorithms for sample measure // We choose the one that is optimal relative to the total number // of qubits,and the number of shots. // The parameters used below are based on experimentation. // The user can override this by setting the parameter "mps_sample_measure_algorithm" uint_t num_qubits = qubits.size(); if (MPS::get_sample_measure_alg() == Sample_measure_alg::PROB){ return sample_measure_using_probabilities(qubits, shots, rng); } if (MPS::get_sample_measure_alg() == Sample_measure_alg::APPLY_MEASURE || num_qubits >26 ) return sample_measure_using_apply_measure(qubits, shots, rng); double num_qubits_dbl = static_cast<double>(num_qubits); double shots_dbl = static_cast<double>(shots); // Sample_measure_alg::HEURISTIC uint_t max_bond_dim = qreg_.get_max_bond_dimensions(); if (num_qubits <10) return sample_measure_using_probabilities(qubits, shots, rng); if (max_bond_dim <= 2) { if (shots_dbl < 12.0 * pow(1.85, (num_qubits_dbl-10.0))) return sample_measure_using_apply_measure(qubits, shots, rng); else return sample_measure_using_probabilities(qubits, shots, rng); } else if (max_bond_dim <= 4) { if (shots_dbl < 3.0 * pow(1.75, (num_qubits_dbl-10.0))) return sample_measure_using_apply_measure(qubits, shots, rng); else return sample_measure_using_probabilities(qubits, shots, rng); } else if (max_bond_dim <= 8) { if (shots_dbl < 2.5 * pow(1.65, (num_qubits_dbl-10.0))) return sample_measure_using_apply_measure(qubits, shots, rng); else return sample_measure_using_probabilities(qubits, shots, rng); } else if (max_bond_dim <= 16) { if (shots_dbl < 0.5 * pow(1.75, (num_qubits_dbl-10.0))) return sample_measure_using_apply_measure(qubits, shots, rng); else return sample_measure_using_probabilities(qubits, shots, rng); } return sample_measure_using_probabilities(qubits, shots, rng); } std::vector<reg_t> State:: sample_measure_using_probabilities(const reg_t &qubits, uint_t shots, RngEngine &rng) { // Generate flat register for storing rvector_t rnds; rnds.reserve(shots); for (uint_t i = 0; i < shots; ++i) rnds.push_back(rng.rand(0, 1)); auto allbit_samples = qreg_.sample_measure_using_probabilities(rnds, qubits); // Convert to reg_t format std::vector<reg_t> all_samples; all_samples.reserve(shots); for (int_t val : allbit_samples) { reg_t allbit_sample = Utils::int2reg(val, 2, qubits.size()); reg_t sample; sample.reserve(qubits.size()); for (uint_t j=0; j<qubits.size(); j++){ sample.push_back(allbit_sample[j]); } all_samples.push_back(sample); } return all_samples; } std::vector<reg_t> State:: sample_measure_using_apply_measure(const reg_t &qubits, uint_t shots, RngEngine &rng) const { MPS temp; std::vector<reg_t> all_samples; all_samples.resize(shots); reg_t single_result; for (int_t i=0; i<static_cast<int_t>(shots); i++) { temp.initialize(qreg_); single_result = temp.apply_measure(qubits, rng); all_samples[i] = single_result; } return all_samples; } void State::apply_snapshot(const Operations::Op &op, ExperimentResult &result) { // Look for snapshot type in snapshotset auto it = snapshotset_.find(op.name); if (it == snapshotset_.end()) throw std::invalid_argument("MatrixProductState::invalid snapshot instruction \'" + op.name + "\'."); switch (it -> second) { case Snapshots::statevector: { snapshot_state(op, result, "statevector"); break; } case Snapshots::cmemory: BaseState::snapshot_creg_memory(op, result); break; case Snapshots::cregister: BaseState::snapshot_creg_register(op, result); break; case Snapshots::probs: { // get probs as hexadecimal snapshot_probabilities(op, result, SnapshotDataType::average); break; } case Snapshots::densmat: { snapshot_density_matrix(op, result, SnapshotDataType::average); } break; case Snapshots::expval_pauli: { snapshot_pauli_expval(op, result, SnapshotDataType::average); } break; case Snapshots::expval_matrix: { snapshot_matrix_expval(op, result, SnapshotDataType::average); } break; case Snapshots::probs_var: { // get probs as hexadecimal snapshot_probabilities(op, result, SnapshotDataType::average_var); } break; case Snapshots::densmat_var: { snapshot_density_matrix(op, result, SnapshotDataType::average_var); } break; case Snapshots::expval_pauli_var: { snapshot_pauli_expval(op, result, SnapshotDataType::average_var); } break; case Snapshots::expval_matrix_var: { snapshot_matrix_expval(op, result, SnapshotDataType::average_var); } break; case Snapshots::expval_pauli_shot: { snapshot_pauli_expval(op, result, SnapshotDataType::pershot); } break; case Snapshots::expval_matrix_shot: { snapshot_matrix_expval(op, result, SnapshotDataType::pershot); } break; default: // We shouldn't get here unless there is a bug in the snapshotset throw std::invalid_argument("MatrixProductState::State::invalid snapshot instruction \'" + op.name + "\'."); } } void State::apply_reset(const reg_t &qubits, RngEngine &rng) { qreg_.reset(qubits, rng); } std::pair<uint_t, double> State::sample_measure_with_prob(const reg_t &qubits, RngEngine &rng) { rvector_t probs = measure_probs(qubits); // Randomly pick outcome and return pair uint_t outcome = rng.rand_int(probs); return std::make_pair(outcome, probs[outcome]); } //------------------------------------------------------------------------- } // end namespace MatrixProductState //------------------------------------------------------------------------- } // end namespace AER //------------------------------------------------------------------------- #endif
36.551756
121
0.614175
73727144668884127305509b827327cd8d9a14b5
8,636
cpp
C++
third_party/WebKit/Source/bindings/core/v8/ExceptionState.cpp
metux/chromium-deb
3c08e9b89a1b6f95f103a61ff4f528dbcd57fc42
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
null
null
null
third_party/WebKit/Source/bindings/core/v8/ExceptionState.cpp
metux/chromium-deb
3c08e9b89a1b6f95f103a61ff4f528dbcd57fc42
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
null
null
null
third_party/WebKit/Source/bindings/core/v8/ExceptionState.cpp
metux/chromium-deb
3c08e9b89a1b6f95f103a61ff4f528dbcd57fc42
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
null
null
null
/* * Copyright (C) 2013 Google Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above * copyright notice, this list of conditions and the following disclaimer * in the documentation and/or other materials provided with the * distribution. * * Neither the name of Google Inc. nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "bindings/core/v8/ExceptionState.h" #include "bindings/core/v8/ExceptionMessages.h" #include "bindings/core/v8/ScriptPromiseResolver.h" #include "bindings/core/v8/V8ThrowDOMException.h" namespace blink { void ExceptionState::ThrowDOMException(ExceptionCode ec, const char* message) { ThrowDOMException(ec, String(message)); } void ExceptionState::ThrowRangeError(const char* message) { ThrowRangeError(String(message)); } void ExceptionState::ThrowSecurityError(const char* sanitized_message, const char* unsanitized_message) { ThrowSecurityError(String(sanitized_message), String(unsanitized_message)); } void ExceptionState::ThrowTypeError(const char* message) { ThrowTypeError(String(message)); } void ExceptionState::ThrowDOMException(ExceptionCode ec, const String& message) { // SecurityError is thrown via ::throwSecurityError, and _careful_ // consideration must be given to the data exposed to JavaScript via the // 'sanitizedMessage'. DCHECK(ec != kSecurityError); const String& processed_message = AddExceptionContext(message); SetException( ec, processed_message, V8ThrowDOMException::CreateDOMException(isolate_, ec, processed_message)); } void ExceptionState::ThrowRangeError(const String& message) { SetException(kV8RangeError, message, V8ThrowException::CreateRangeError( isolate_, AddExceptionContext(message))); } void ExceptionState::ThrowSecurityError(const String& sanitized_message, const String& unsanitized_message) { const String& final_sanitized = AddExceptionContext(sanitized_message); const String& final_unsanitized = AddExceptionContext(unsanitized_message); SetException( kSecurityError, final_sanitized, V8ThrowDOMException::CreateDOMException( isolate_, kSecurityError, final_sanitized, final_unsanitized)); } void ExceptionState::ThrowTypeError(const String& message) { SetException(kV8TypeError, message, V8ThrowException::CreateTypeError(isolate_, AddExceptionContext(message))); } void ExceptionState::RethrowV8Exception(v8::Local<v8::Value> value) { SetException(kRethrownException, String(), value); } void ExceptionState::ClearException() { code_ = 0; message_ = String(); exception_.Clear(); } ScriptPromise ExceptionState::Reject(ScriptState* script_state) { ScriptPromise promise = ScriptPromise::Reject(script_state, GetException()); ClearException(); return promise; } void ExceptionState::Reject(ScriptPromiseResolver* resolver) { resolver->Reject(GetException()); ClearException(); } void ExceptionState::SetException(ExceptionCode ec, const String& message, v8::Local<v8::Value> exception) { CHECK(ec); code_ = ec; message_ = message; if (exception.IsEmpty()) { exception_.Clear(); } else { DCHECK(isolate_); exception_.Set(isolate_, exception); } } String ExceptionState::AddExceptionContext(const String& message) const { if (message.IsEmpty()) return message; String processed_message = message; if (PropertyName() && InterfaceName() && context_ != kUnknownContext) { if (context_ == kDeletionContext) processed_message = ExceptionMessages::FailedToDelete( PropertyName(), InterfaceName(), message); else if (context_ == kExecutionContext) processed_message = ExceptionMessages::FailedToExecute( PropertyName(), InterfaceName(), message); else if (context_ == kGetterContext) processed_message = ExceptionMessages::FailedToGet( PropertyName(), InterfaceName(), message); else if (context_ == kSetterContext) processed_message = ExceptionMessages::FailedToSet( PropertyName(), InterfaceName(), message); } else if (!PropertyName() && InterfaceName()) { if (context_ == kConstructionContext) processed_message = ExceptionMessages::FailedToConstruct(InterfaceName(), message); else if (context_ == kEnumerationContext) processed_message = ExceptionMessages::FailedToEnumerate(InterfaceName(), message); else if (context_ == kIndexedDeletionContext) processed_message = ExceptionMessages::FailedToDeleteIndexed(InterfaceName(), message); else if (context_ == kIndexedGetterContext) processed_message = ExceptionMessages::FailedToGetIndexed(InterfaceName(), message); else if (context_ == kIndexedSetterContext) processed_message = ExceptionMessages::FailedToSetIndexed(InterfaceName(), message); } return processed_message; } NonThrowableExceptionState::NonThrowableExceptionState() : ExceptionState(nullptr, ExceptionState::kUnknownContext, nullptr, nullptr), file_(""), line_(0) {} NonThrowableExceptionState::NonThrowableExceptionState(const char* file, int line) : ExceptionState(nullptr, ExceptionState::kUnknownContext, nullptr, nullptr), file_(file), line_(line) {} void NonThrowableExceptionState::ThrowDOMException(ExceptionCode ec, const String& message) { DCHECK_AT(false, file_, line_) << "DOMExeption should not be thrown."; } void NonThrowableExceptionState::ThrowRangeError(const String& message) { DCHECK_AT(false, file_, line_) << "RangeError should not be thrown."; } void NonThrowableExceptionState::ThrowSecurityError( const String& sanitized_message, const String&) { DCHECK_AT(false, file_, line_) << "SecurityError should not be thrown."; } void NonThrowableExceptionState::ThrowTypeError(const String& message) { DCHECK_AT(false, file_, line_) << "TypeError should not be thrown."; } void NonThrowableExceptionState::RethrowV8Exception(v8::Local<v8::Value>) { DCHECK_AT(false, file_, line_) << "An exception should not be rethrown."; } void DummyExceptionStateForTesting::ThrowDOMException(ExceptionCode ec, const String& message) { SetException(ec, message, v8::Local<v8::Value>()); } void DummyExceptionStateForTesting::ThrowRangeError(const String& message) { SetException(kV8RangeError, message, v8::Local<v8::Value>()); } void DummyExceptionStateForTesting::ThrowSecurityError( const String& sanitized_message, const String&) { SetException(kSecurityError, sanitized_message, v8::Local<v8::Value>()); } void DummyExceptionStateForTesting::ThrowTypeError(const String& message) { SetException(kV8TypeError, message, v8::Local<v8::Value>()); } void DummyExceptionStateForTesting::RethrowV8Exception(v8::Local<v8::Value>) { SetException(kRethrownException, String(), v8::Local<v8::Value>()); } } // namespace blink
37.71179
80
0.704724
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
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
73751a821a3b85f14535d9c5723cb31f2a0d422a
9,260
cpp
C++
src/foundation/third_party/agg/examples/gouraud.cpp
airgiser/gona
4b81cbf8daacfca46a6bdec56935318a06f7e804
[ "MIT" ]
31
2017-06-28T09:50:03.000Z
2021-08-11T14:09:35.000Z
src/foundation/third_party/agg/examples/gouraud.cpp
airgiser/gona
4b81cbf8daacfca46a6bdec56935318a06f7e804
[ "MIT" ]
null
null
null
src/foundation/third_party/agg/examples/gouraud.cpp
airgiser/gona
4b81cbf8daacfca46a6bdec56935318a06f7e804
[ "MIT" ]
5
2017-06-29T13:43:23.000Z
2020-09-01T02:47:11.000Z
#include <stdio.h> #include "agg_basics.h" #include "agg_rendering_buffer.h" #include "agg_rasterizer_scanline_aa.h" #include "agg_scanline_u.h" #include "agg_scanline_p.h" #include "agg_renderer_scanline.h" #include "agg_span_allocator.h" #include "agg_span_gouraud_rgba.h" #include "agg_span_gouraud_gray.h" #include "agg_span_solid.h" #include "platform/agg_platform_support.h" #include "ctrl/agg_slider_ctrl.h" //#define AGG_GRAY8 #define AGG_BGR24 //#define AGG_RGB24 //#define AGG_BGRA32 //#define AGG_RGBA32 //#define AGG_ARGB32 //#define AGG_ABGR32 //#define AGG_RGB565 //#define AGG_RGB555 #include "pixel_formats.h" enum flip_y_e { flip_y = true }; #include "agg_math.h" #include "agg_dda_line.h" class the_application : public agg::platform_support { double m_x[3]; double m_y[3]; double m_dx; double m_dy; int m_idx; agg::slider_ctrl<agg::rgba> m_dilation; agg::slider_ctrl<agg::rgba> m_gamma; agg::slider_ctrl<agg::rgba> m_alpha; public: the_application(agg::pix_format_e format, bool flip_y) : agg::platform_support(format, flip_y), m_idx(-1), m_dilation(5, 5, 400-5, 11, !flip_y), m_gamma (5, 5+15, 400-5, 11+15, !flip_y), m_alpha (5, 5+30, 400-5, 11+30, !flip_y) { m_x[0] = 57; m_y[0] = 60; m_x[1] = 369; m_y[1] = 170; m_x[2] = 143; m_y[2] = 310; add_ctrl(m_dilation); add_ctrl(m_gamma); add_ctrl(m_alpha); m_dilation.label("Dilation=%3.2f"); m_gamma.label("Linear gamma=%3.2f"); m_alpha.label("Opacity=%3.2f"); m_dilation.value(0.175); m_gamma.value(0.809); m_alpha.value(1.0); } template<class Scanline, class Ras> void render_gouraud(Scanline& sl, Ras& ras) { double alpha = m_alpha.value(); double brc = 1; typedef agg::renderer_base<pixfmt> base_ren_type; #ifdef AGG_GRAY8 typedef agg::span_gouraud_gray<color_type> span_gen_type; #else typedef agg::span_gouraud_rgba<color_type> span_gen_type; #endif typedef agg::span_allocator<color_type> span_alloc_type; pixfmt pf(rbuf_window()); base_ren_type ren_base(pf); span_alloc_type span_alloc; span_gen_type span_gen; ras.gamma(agg::gamma_linear(0.0, m_gamma.value())); double d = m_dilation.value(); // Single triangle //span_gen.colors(agg::rgba(1, 0, 0, alpha), // agg::rgba(0, 1, 0, alpha), // agg::rgba(0, 0, 1, alpha)); //span_gen.triangle(m_x[0], m_y[0], m_x[1], m_y[1], m_x[2], m_y[2], d); //ras.add_path(span_gen); //agg::render_scanlines_aa(ras, sl, ren_base, span_alloc, span_gen); // Six triangles double xc = (m_x[0] + m_x[1] + m_x[2]) / 3.0; double yc = (m_y[0] + m_y[1] + m_y[2]) / 3.0; double x1 = (m_x[1] + m_x[0]) / 2 - (xc - (m_x[1] + m_x[0]) / 2); double y1 = (m_y[1] + m_y[0]) / 2 - (yc - (m_y[1] + m_y[0]) / 2); double x2 = (m_x[2] + m_x[1]) / 2 - (xc - (m_x[2] + m_x[1]) / 2); double y2 = (m_y[2] + m_y[1]) / 2 - (yc - (m_y[2] + m_y[1]) / 2); double x3 = (m_x[0] + m_x[2]) / 2 - (xc - (m_x[0] + m_x[2]) / 2); double y3 = (m_y[0] + m_y[2]) / 2 - (yc - (m_y[0] + m_y[2]) / 2); span_gen.colors(agg::rgba(1, 0, 0, alpha), agg::rgba(0, 1, 0, alpha), agg::rgba(brc, brc, brc, alpha)); span_gen.triangle(m_x[0], m_y[0], m_x[1], m_y[1], xc, yc, d); ras.add_path(span_gen); agg::render_scanlines_aa(ras, sl, ren_base, span_alloc, span_gen); span_gen.colors(agg::rgba(0, 1, 0, alpha), agg::rgba(0, 0, 1, alpha), agg::rgba(brc, brc, brc, alpha)); span_gen.triangle(m_x[1], m_y[1], m_x[2], m_y[2], xc, yc, d); ras.add_path(span_gen); agg::render_scanlines_aa(ras, sl, ren_base, span_alloc, span_gen); span_gen.colors(agg::rgba(0, 0, 1, alpha), agg::rgba(1, 0, 0, alpha), agg::rgba(brc, brc, brc, alpha)); span_gen.triangle(m_x[2], m_y[2], m_x[0], m_y[0], xc, yc, d); ras.add_path(span_gen); agg::render_scanlines_aa(ras, sl, ren_base, span_alloc, span_gen); brc = 1-brc; span_gen.colors(agg::rgba(1, 0, 0, alpha), agg::rgba(0, 1, 0, alpha), agg::rgba(brc, brc, brc, alpha)); span_gen.triangle(m_x[0], m_y[0], m_x[1], m_y[1], x1, y1, d); ras.add_path(span_gen); agg::render_scanlines_aa(ras, sl, ren_base, span_alloc, span_gen); span_gen.colors(agg::rgba(0, 1, 0, alpha), agg::rgba(0, 0, 1, alpha), agg::rgba(brc, brc, brc, alpha)); span_gen.triangle(m_x[1], m_y[1], m_x[2], m_y[2], x2, y2, d); ras.add_path(span_gen); agg::render_scanlines_aa(ras, sl, ren_base, span_alloc, span_gen); span_gen.colors(agg::rgba(0, 0, 1, alpha), agg::rgba(1, 0, 0, alpha), agg::rgba(brc, brc, brc, alpha)); span_gen.triangle(m_x[2], m_y[2], m_x[0], m_y[0], x3, y3, d); ras.add_path(span_gen); agg::render_scanlines_aa(ras, sl, ren_base, span_alloc, span_gen); } virtual void on_draw() { typedef agg::renderer_base<pixfmt> base_ren_type; pixfmt pf(rbuf_window()); base_ren_type ren_base(pf); ren_base.clear(agg::rgba(1,1,1)); agg::scanline_u8 sl; agg::rasterizer_scanline_aa<> ras; render_gouraud(sl, ras); ras.gamma(agg::gamma_none()); agg::render_ctrl(ras, sl, ren_base, m_dilation); agg::render_ctrl(ras, sl, ren_base, m_gamma); agg::render_ctrl(ras, sl, ren_base, m_alpha); } virtual void on_mouse_button_down(int x, int y, unsigned flags) { unsigned i; if(flags & agg::mouse_right) { agg::scanline_u8 sl; agg::rasterizer_scanline_aa<> ras; start_timer(); for(i = 0; i < 100; i++) { render_gouraud(sl, ras); } char buf[100]; sprintf(buf, "Time=%2.2f ms", elapsed_time()); message(buf); } if(flags & agg::mouse_left) { for (i = 0; i < 3; i++) { if(sqrt( (x-m_x[i]) * (x-m_x[i]) + (y-m_y[i]) * (y-m_y[i]) ) < 10.0) { m_dx = x - m_x[i]; m_dy = y - m_y[i]; m_idx = i; break; } } if(i == 3) { if(agg::point_in_triangle(m_x[0], m_y[0], m_x[1], m_y[1], m_x[2], m_y[2], x, y)) { m_dx = x - m_x[0]; m_dy = y - m_y[0]; m_idx = 3; } } } } virtual void on_mouse_move(int x, int y, unsigned flags) { if(flags & agg::mouse_left) { if(m_idx == 3) { double dx = x - m_dx; double dy = y - m_dy; m_x[1] -= m_x[0] - dx; m_y[1] -= m_y[0] - dy; m_x[2] -= m_x[0] - dx; m_y[2] -= m_y[0] - dy; m_x[0] = dx; m_y[0] = dy; force_redraw(); return; } if(m_idx >= 0) { m_x[m_idx] = x - m_dx; m_y[m_idx] = y - m_dy; force_redraw(); } } else { on_mouse_button_up(x, y, flags); } } virtual void on_mouse_button_up(int x, int y, unsigned flags) { m_idx = -1; } virtual void on_key(int x, int y, unsigned key, unsigned flags) { double dx = 0; double dy = 0; switch(key) { case agg::key_left: dx = -0.1; break; case agg::key_right: dx = 0.1; break; case agg::key_up: dy = 0.1; break; case agg::key_down: dy = -0.1; break; } m_x[0] += dx; m_y[0] += dy; m_x[1] += dx; m_y[1] += dy; force_redraw(); } }; int agg_main(int argc, char* argv[]) { the_application app(pix_format, flip_y); app.caption("AGG Example. Gouraud Shading"); if(app.init(400, 320, agg::window_resize)) { return app.run(); } return 1; }
29.396825
85
0.47203
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
737bc5fdb150874db26ef66845c907de6bca77f2
14,426
cpp
C++
inference-engine/src/mkldnn_plugin/nodes/priorbox.cpp
fujunwei/dldt
09497b7724de4be92629f7799b8538b483d809a2
[ "Apache-2.0" ]
1
2021-07-30T17:03:50.000Z
2021-07-30T17:03:50.000Z
inference-engine/src/mkldnn_plugin/nodes/priorbox.cpp
fujunwei/dldt
09497b7724de4be92629f7799b8538b483d809a2
[ "Apache-2.0" ]
null
null
null
inference-engine/src/mkldnn_plugin/nodes/priorbox.cpp
fujunwei/dldt
09497b7724de4be92629f7799b8538b483d809a2
[ "Apache-2.0" ]
null
null
null
// Copyright (C) 2018-2020 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // #include "list.hpp" #include "base.hpp" #include <vector> #include <string> #include <cmath> #include <limits> #include "ie_parallel.hpp" namespace InferenceEngine { namespace Extensions { namespace Cpu { class PriorBoxImpl: public ExtLayerBase { static inline float clip_great(float x, float threshold) { return x < threshold ? x : threshold; } static inline float clip_less(float x, float threshold) { return x > threshold ? x : threshold; } public: explicit PriorBoxImpl(const CNNLayer *layer) { try { if (layer->insData.size() != 2 || layer->outData.empty()) THROW_IE_EXCEPTION << "Incorrect number of input/output edges!"; if (layer->insData[0].lock()->getTensorDesc().getDims().size() != 4 || layer->insData[1].lock()->getTensorDesc().getDims().size() != 4) THROW_IE_EXCEPTION << "PriorBox supports only 4D blobs!"; _offset = layer->GetParamAsFloat("offset"); _step = layer->GetParamAsFloat("step", 0); _min_sizes = layer->GetParamAsFloats("min_size", {}); _max_sizes = layer->GetParamAsFloats("max_size", {}); _flip = layer->GetParamAsBool("flip", false); _clip = layer->GetParamAsBool("clip", false); _scale_all_sizes = layer->GetParamAsBool("scale_all_sizes", true); _fixed_sizes = layer->GetParamAsFloats("fixed_size", {}); _fixed_ratios = layer->GetParamAsFloats("fixed_ratio", {}); _densitys = layer->GetParamAsFloats("density", {}); bool exist; _aspect_ratios.push_back(1.0f); const std::vector<float> aspect_ratios = layer->GetParamAsFloats("aspect_ratio", {}); for (float aspect_ratio : aspect_ratios) { exist = false; if (std::fabs(aspect_ratio) < std::numeric_limits<float>::epsilon()) { THROW_IE_EXCEPTION << "aspect_ratio param can't be equal to zero"; } for (float _aspect_ratio : _aspect_ratios) { if (fabs(aspect_ratio - _aspect_ratio) < 1e-6) { exist = true; break; } } if (exist) { continue; } _aspect_ratios.push_back(aspect_ratio); if (_flip) { _aspect_ratios.push_back(1.0f / aspect_ratio); } } if (_scale_all_sizes) { _num_priors = static_cast<int>(_aspect_ratios.size() * _min_sizes.size()); } else { _num_priors = static_cast<int>(_aspect_ratios.size() + _min_sizes.size() - 1); } if (_fixed_sizes.size() > 0) { _num_priors = static_cast<int>(_aspect_ratios.size() * _fixed_sizes.size()); } if (_densitys.size() > 0) { for (size_t i = 0; i < _densitys.size(); ++i) { if (_fixed_ratios.size() > 0) { _num_priors += (_fixed_ratios.size()) * (static_cast<size_t>(pow(_densitys[i], 2)) - 1); } else { _num_priors += (_aspect_ratios.size()) * (static_cast<size_t>(pow(_densitys[i], 2)) - 1); } } } for (auto it = _max_sizes.begin(); it != _max_sizes.end(); it++) { _num_priors += 1; } const std::vector<float> variance = layer->GetParamAsFloats("variance", {}); if (variance.size() == 1 || variance.size() == 4) { for (float i : variance) { if (i < 0) { THROW_IE_EXCEPTION << "Variance must be > 0."; } _variance.push_back(i); } } else if (variance.empty()) { _variance.push_back(0.1f); } else { THROW_IE_EXCEPTION << "Wrong number of variance values. Not less than 1 and more than 4 variance values."; } addConfig(layer, {{ConfLayout::ANY, true}, {ConfLayout::ANY, true}}, {{ConfLayout::PLN, true}}); } catch (InferenceEngine::details::InferenceEngineException &ex) { errorMsg = ex.what(); } } StatusCode init(LayerConfig& config, ResponseDesc *resp) noexcept override { return OK; } StatusCode execute(std::vector<Blob::Ptr>& inputs, std::vector<Blob::Ptr>& outputs, ResponseDesc *resp) noexcept override { if (inputs.size() != 2 || outputs.empty()) { if (resp) { std::string errorMsg = "Incorrect number of input or output edges!"; errorMsg.copy(resp->msg, sizeof(resp->msg) - 1); } return GENERAL_ERROR; } auto& dataMemPtr = inputs[0]; auto& imageMemPtr = inputs[1]; auto& dstMemPtr = outputs[0]; SizeVector _data_dims = dataMemPtr->getTensorDesc().getDims(); SizeVector _image_dims = imageMemPtr->getTensorDesc().getDims(); const int W = _data_dims[3]; const int H = _data_dims[2]; const int IW = _image_dims[3]; const int IH = _image_dims[2]; const int OH = dstMemPtr->getTensorDesc().getDims()[2]; const int OW = (dstMemPtr->getTensorDesc().getDims().size() == 3) ? 1 : dstMemPtr->getTensorDesc().getDims()[3]; float step_x = 0.0f; float step_y = 0.0f; if (_step == 0) { step_x = static_cast<float>(IW) / W; step_y = static_cast<float>(IH) / H; } else { step_x = _step; step_y = _step; } float IWI = 1.0f / static_cast<float>(IW); float IHI = 1.0f / static_cast<float>(IH); float* dst_data = dstMemPtr->buffer(); int idx = 0; float center_x = 0.0f; float center_y = 0.0f; float box_width; float box_height; for (int h = 0; h < H; ++h) { for (int w = 0; w < W; ++w) { if (_step == 0) { center_x = (w + 0.5f) * step_x; center_y = (h + 0.5f) * step_y; } else { center_x = (_offset + w) * _step; center_y = (_offset + h) * _step; } for (size_t s = 0; s < _fixed_sizes.size(); ++s) { size_t fixed_size_ = static_cast<size_t>(_fixed_sizes[s]); box_width = box_height = fixed_size_ * 0.5f; if (_fixed_ratios.size() > 0) { for (float ar : _fixed_ratios) { size_t density_ = static_cast<size_t>(_densitys[s]); int shift = static_cast<int>(_fixed_sizes[s] / density_); ar = sqrt(ar); float box_width_ratio = _fixed_sizes[s] * 0.5f * ar; float box_height_ratio = _fixed_sizes[s] * 0.5f / ar; for (size_t r = 0; r < density_; ++r) { for (size_t c = 0; c < density_; ++c) { float center_x_temp = center_x - fixed_size_ / 2 + shift / 2.f + c * shift; float center_y_temp = center_y - fixed_size_ / 2 + shift / 2.f + r * shift; // xmin dst_data[idx++] = clip_less((center_x_temp - box_width_ratio) * IWI, 0); // ymin dst_data[idx++] = clip_less((center_y_temp - box_height_ratio) * IHI, 0); // xmax dst_data[idx++] = clip_great((center_x_temp + box_width_ratio) * IWI, 1); // ymax dst_data[idx++] = clip_great((center_y_temp + box_height_ratio) * IHI, 1); } } } } else { if (_densitys.size() > 0) { int density_ = static_cast<int>(_densitys[s]); int shift = static_cast<int>(_fixed_sizes[s] / density_); for (int r = 0; r < density_; ++r) { for (int c = 0; c < density_; ++c) { float center_x_temp = center_x - fixed_size_ / 2 + shift / 2.f + c * shift; float center_y_temp = center_y - fixed_size_ / 2 + shift / 2.f + r * shift; // xmin dst_data[idx++] = clip_less((center_x_temp - box_width) * IWI, 0); // ymin dst_data[idx++] = clip_less((center_y_temp - box_height) * IHI, 0); // xmax dst_data[idx++] = clip_great((center_x_temp + box_width) * IWI, 1); // ymax dst_data[idx++] = clip_great((center_y_temp + box_height) * IHI, 1); } } } // Rest of priors for (float ar : _aspect_ratios) { if (fabs(ar - 1.) < 1e-6) { continue; } int density_ = static_cast<int>(_densitys[s]); int shift = static_cast<int>(_fixed_sizes[s] / density_); ar = sqrt(ar); float box_width_ratio = _fixed_sizes[s] * 0.5f * ar; float box_height_ratio = _fixed_sizes[s] * 0.5f / ar; for (int r = 0; r < density_; ++r) { for (int c = 0; c < density_; ++c) { float center_x_temp = center_x - fixed_size_ / 2 + shift / 2.f + c * shift; float center_y_temp = center_y - fixed_size_ / 2 + shift / 2.f + r * shift; // xmin dst_data[idx++] = clip_less((center_x_temp - box_width_ratio) * IWI, 0); // ymin dst_data[idx++] = clip_less((center_y_temp - box_height_ratio) * IHI, 0); // xmax dst_data[idx++] = clip_great((center_x_temp + box_width_ratio) * IWI, 1); // ymax dst_data[idx++] = clip_great((center_y_temp + box_height_ratio) * IHI, 1); } } } } } for (size_t msIdx = 0; msIdx < _min_sizes.size(); msIdx++) { box_width = _min_sizes[msIdx] * 0.5f; box_height = _min_sizes[msIdx] * 0.5f; dst_data[idx++] = (center_x - box_width) * IWI; dst_data[idx++] = (center_y - box_height) * IHI; dst_data[idx++] = (center_x + box_width) * IWI; dst_data[idx++] = (center_y + box_height) * IHI; if (_max_sizes.size() > msIdx) { box_width = box_height = sqrt(_min_sizes[msIdx] * _max_sizes[msIdx]) * 0.5f; dst_data[idx++] = (center_x - box_width) * IWI; dst_data[idx++] = (center_y - box_height) * IHI; dst_data[idx++] = (center_x + box_width) * IWI; dst_data[idx++] = (center_y + box_height) * IHI; } if (_scale_all_sizes || (!_scale_all_sizes && (msIdx == _min_sizes.size() - 1))) { size_t sIdx = _scale_all_sizes ? msIdx : 0; for (float ar : _aspect_ratios) { if (fabs(ar - 1.0f) < 1e-6) { continue; } ar = sqrt(ar); box_width = _min_sizes[sIdx] * 0.5f * ar; box_height = _min_sizes[sIdx] * 0.5f / ar; dst_data[idx++] = (center_x - box_width) * IWI; dst_data[idx++] = (center_y - box_height) * IHI; dst_data[idx++] = (center_x + box_width) * IWI; dst_data[idx++] = (center_y + box_height) * IHI; } } } } } if (_clip) { parallel_for((H * W * _num_priors * 4), [&](size_t i) { dst_data[i] = (std::min)((std::max)(dst_data[i], 0.0f), 1.0f); }); } size_t channel_size = OH * OW; dst_data += channel_size; if (_variance.size() == 1) { parallel_for(channel_size, [&](size_t i) { dst_data[i] = _variance[0]; }); } else { parallel_for((H * W * _num_priors), [&](size_t i) { for (size_t j = 0; j < 4; ++j) { dst_data[i * 4 + j] = _variance[j]; } }); } return OK; } private: float _offset = 0; float _step = 0; std::vector<float> _min_sizes; std::vector<float> _max_sizes; bool _flip = false; bool _clip = false; bool _scale_all_sizes = true; std::vector<float> _fixed_sizes; std::vector<float> _fixed_ratios; std::vector<float> _densitys; std::vector<float> _aspect_ratios; std::vector<float> _variance; int _num_priors = 0; }; REG_FACTORY_FOR(ImplFactory<PriorBoxImpl>, PriorBox); } // namespace Cpu } // namespace Extensions } // namespace InferenceEngine
41.693642
122
0.449674
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
737cfdd1ddccd000dd2e64b2fcc69ac86b35ba54
3,417
cpp
C++
tests/test.cpp
agoose77/cpp11-range
ad62070845f24a9f509f0625e204654612bb5924
[ "Apache-2.0" ]
null
null
null
tests/test.cpp
agoose77/cpp11-range
ad62070845f24a9f509f0625e204654612bb5924
[ "Apache-2.0" ]
null
null
null
tests/test.cpp
agoose77/cpp11-range
ad62070845f24a9f509f0625e204654612bb5924
[ "Apache-2.0" ]
null
null
null
#include <cpp11-range/range.hpp> #include <algorithm> #include <iostream> #include <iterator> #include <vector> template <typename R> void print_range(R const& range); template <typename R> void test_range_size(R const& range); int main() { using std::cout; using util::lang::range; using util::lang::indices; cout << "Basic usage: iterating over a range of numbers.\n"; for (auto i : range(1, 5)) { cout << i << " "; } cout << "\n"; cout << "Ranges can be “infinite”.\n"; for (auto u : range(0u)) { if (u == 3u) { cout << "\n"; break; } cout << u << " "; } cout << "Ranges can be non-numeric, as long as the type is incrementable and equality comparable.\n"; print_range(range('a', 'd')); cout << "Ranges can be non-contiguous.\n"; print_range(range(20u, 29u).step(2u)); cout << "… and we can even step backwards.\n"; for (auto i : range(100).step(-3)) { if (i < 90) { cout << "\n"; break; } cout << i << " "; } cout << "\n"; cout << "Container indices are a special case of ranges.\n"; std::vector<int> x{1, 2, 3}; print_range(indices(x)); print_range(indices({"foo", "bar"})); cout << "Strings are containers, too.\n"; print_range(indices("foobar").step(2)); cout << "\n"; // TODO: Test cases; do something smarter with them. print_range(range(6, 10)); print_range(range(1, 8).step(2)); print_range(range(8, 1).step(-2)); print_range(range(8.0, 1.0).step(-2.0)); cout << "\n"; cout << "Mixed type inference:\n"; print_range(range(0, sizeof "Hello")); cout << "Inferred as mangled type name " << typeid(typename std::iterator_traits<decltype(range(0, sizeof "Hello").begin())>::value_type).name() << " (expected: " << typeid(decltype(sizeof "Hello")).name() << ")\n"; cout << "\n"; test_range_size(range(1, 8).step(2)); test_range_size(range(8.0, 1.0).step(-2.0)); test_range_size(range(8, 1).step(-2)); test_range_size(range(0.1, 0.11).step(2)); test_range_size(range(-7, 1).step(7)); } namespace util { namespace lang { template <typename T> std::ostream& operator <<(std::ostream& out, step_range_proxy<T> const& r) { return out << "range(" << *r.begin() << ", " << *r.end() << ")" << ".step(" << r.begin().step_ << ")"; } template <typename T> std::ostream& operator <<(std::ostream& out, range_proxy<T> const& r) { return out << "range(" << *r.begin() << ", " << *r.end() << ")"; } }} template <typename R> void print_range(R const& range) { using T = typename std::iterator_traits<decltype(range.begin())>::value_type; std::cout << range << " = "; std::copy(range.begin(), range.end(), std::ostream_iterator<T>(std::cout, " ")); std::cout << "\n"; } template <typename R> std::size_t manual_range_size(R const& range) { std::size_t size = 0; for (auto const& _ : range) ++size, (void) _; return size; } template <typename R> void test_range_size(R const& range) { auto const real_size = manual_range_size(R{range}); if (real_size == range.size()) { std::cout << range << ".size() = " << real_size << "\n"; } else { std::cout << "ERROR: " << range << ".size() ≠ " << real_size << " (was " << range.size() << ")!\n"; } }
28.239669
111
0.559848
737dfe0c0182de10ed7688dffdc44ba3035911cf
595
cc
C++
src/broker/broker_main.cc
iot-dsa-v2/sdk-dslink-cpp
d7734fba02237bd11bc887058f4d9573aac598d8
[ "Apache-2.0" ]
1
2018-02-09T21:20:31.000Z
2018-02-09T21:20:31.000Z
src/broker/broker_main.cc
iot-dsa-v2/sdk-dslink-cpp
d7734fba02237bd11bc887058f4d9573aac598d8
[ "Apache-2.0" ]
7
2017-11-20T22:22:12.000Z
2018-03-21T13:00:06.000Z
src/broker/broker_main.cc
iot-dsa-v2/sdk-dslink-cpp
d7734fba02237bd11bc887058f4d9573aac598d8
[ "Apache-2.0" ]
null
null
null
#include "dsa_common.h" #include "broker.h" #include "module/default/simple_security.h" #include "module/default/simple_session_manager.h" #include "config/broker_config.h" #include "module/default/console_logger.h" #include "module/client/broker_client_manager.h" #include "module/authorizer/broker_authorizer.h" #include "module/module_broker_default.h" using namespace dsa; int main(int argc, const char* argv[]) { ref_<BrokerConfig> broker_config = make_ref_<BrokerConfig>(argc, argv); auto broker = make_ref_<DsBroker>(std::move(broker_config)); broker->run(); return 0; }
22.884615
73
0.764706
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
73827b17a72e04d33f721ea7b3992759cbb79cfe
1,850
cpp
C++
ios/versioned-react-native/ABI44_0_0/ReactNative/ReactCommon/react/renderer/components/text/tests/ABI44_0_0ParagraphLocalDataTest.cpp
zakharchenkoAndrii/expo
f6b009d204b9124d43df59b75eb6affc2f0ba5bd
[ "Apache-2.0", "MIT" ]
1
2022-01-18T23:59:15.000Z
2022-01-18T23:59:15.000Z
ios/versioned-react-native/ABI44_0_0/ReactNative/ReactCommon/react/renderer/components/text/tests/ABI44_0_0ParagraphLocalDataTest.cpp
zakharchenkoAndrii/expo
f6b009d204b9124d43df59b75eb6affc2f0ba5bd
[ "Apache-2.0", "MIT" ]
6
2020-08-06T12:31:23.000Z
2021-02-05T12:47:10.000Z
ios/versioned-react-native/ABI44_0_0/ReactNative/ReactCommon/react/renderer/components/text/tests/ABI44_0_0ParagraphLocalDataTest.cpp
zakharchenkoAndrii/expo
f6b009d204b9124d43df59b75eb6affc2f0ba5bd
[ "Apache-2.0", "MIT" ]
1
2020-05-27T08:06:46.000Z
2020-05-27T08:06:46.000Z
/* * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ #include <memory> #include <assert.h> #include <gtest/gtest.h> #include <ABI44_0_0React/ABI44_0_0renderer/attributedstring/AttributedString.h> #include <ABI44_0_0React/ABI44_0_0renderer/attributedstring/TextAttributes.h> #include <ABI44_0_0React/ABI44_0_0renderer/attributedstring/primitives.h> #include <ABI44_0_0React/ABI44_0_0renderer/components/text/ParagraphState.h> #include <ABI44_0_0React/ABI44_0_0renderer/components/text/conversions.h> namespace ABI44_0_0facebook { namespace ABI44_0_0React { #ifdef ANDROID TEST(ParagraphLocalDataTest, testSomething) { auto attributedString = AttributedString(); auto fragment = AttributedString::Fragment(); fragment.string = "test"; auto text = TextAttributes(); text.foregroundColor = { colorFromComponents({100 / 255.0, 153 / 255.0, 253 / 255.0, 1.0})}; text.opacity = 0.5; text.fontStyle = FontStyle::Italic; text.fontWeight = FontWeight::Thin; text.fontVariant = FontVariant::TabularNums; fragment.textAttributes = text; attString.prependFragment(fragment); auto paragraphState = ParagraphState{}; paragraphLocalData.attributedString = attributedString; auto result = toDynamic(paragraphState)["attributedString"]; assert(result["string"] == fragment.string); auto textAttribute = result["fragments"][0]["textAttributes"]; assert(textAttribute["foregroundColor"] == toDynamic(text.foregroundColor)); assert(textAttribute["opacity"] == text.opacity); assert(textAttribute["fontStyle"] == toString(*text.fontStyle)); assert(textAttribute["fontWeight"] == toString(*text.fontWeight)); } #endif } // namespace ABI44_0_0React } // namespace ABI44_0_0facebook
33.636364
79
0.764865
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
738444c763d99b815c36c54f5de9a0a9c327c89c
12,802
cc
C++
src/yb/master/sys_catalog_initialization.cc
eliahburns/yugabyte-db
570d28dde28d6a0e6a689274b5e319de9a81b707
[ "Apache-2.0", "CC0-1.0" ]
null
null
null
src/yb/master/sys_catalog_initialization.cc
eliahburns/yugabyte-db
570d28dde28d6a0e6a689274b5e319de9a81b707
[ "Apache-2.0", "CC0-1.0" ]
null
null
null
src/yb/master/sys_catalog_initialization.cc
eliahburns/yugabyte-db
570d28dde28d6a0e6a689274b5e319de9a81b707
[ "Apache-2.0", "CC0-1.0" ]
null
null
null
// Copyright (c) YugaByte, Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except // in compliance with the License. You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software distributed under the License // is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express // or implied. See the License for the specific language governing permissions and limitations // under the License. // #include "yb/master/sys_catalog_initialization.h" #include "yb/util/countdown_latch.h" #include "yb/util/pb_util.h" #include "yb/util/env_util.h" #include "yb/util/path_util.h" #include "yb/util/flag_tags.h" #include "yb/master/sys_catalog_constants.h" #include "yb/master/catalog_entity_info.h" #include "yb/master/sys_catalog.h" #include "yb/tablet/tablet.h" #include "yb/tablet/tablet_peer.h" #include "yb/tablet/operations/operation.h" #include "yb/tablet/operations/snapshot_operation.h" #include "yb/tablet/operations/change_metadata_operation.h" DEFINE_string(initial_sys_catalog_snapshot_path, "", "If this is specified, system catalog RocksDB is checkpointed at this location after initdb " "is done."); DEFINE_bool(use_initial_sys_catalog_snapshot, false, "DEPRECATED: use --enable_ysql instead. " "Initialize sys catalog tablet from a pre-existing snapshot instead of running initdb. " "Only takes effect if --initial_sys_catalog_snapshot_path is specified or can be " "auto-detected."); DEFINE_bool(enable_ysql, true, "Enable YSQL on cluster. This will initialize sys catalog tablet from a pre-existing snapshot " "and start YSQL proxy. " "Only takes effect if --initial_sys_catalog_snapshot_path is specified or can be auto-detected." ); DEFINE_bool(create_initial_sys_catalog_snapshot, false, "Run initdb and create an initial sys catalog data snapshot"); DEFINE_bool( // TODO: switch the default to true after updating all external callers (yb-ctl, YugaWare) // and unit tests. master_auto_run_initdb, false, "Automatically run initdb on master leader initialization"); TAG_FLAG(create_initial_sys_catalog_snapshot, advanced); TAG_FLAG(create_initial_sys_catalog_snapshot, hidden); using yb::CountDownLatch; using yb::tserver::TabletSnapshotOpRequestPB; using yb::tserver::TabletSnapshotOpResponsePB; using yb::tablet::SnapshotOperationState; using yb::pb_util::ReadPBContainerFromPath; namespace yb { namespace master { namespace { const char* kDefaultInitialSysCatalogSnapshotDir = "initial_sys_catalog_snapshot"; const char* kSysCatalogSnapshotRocksDbSubDir = "rocksdb"; const char* kSysCatalogSnapshotTabletMetadataChangesFile = "exported_tablet_metadata_changes"; const char* kUseInitialSysCatalogSnapshotEnvVar = "YB_USE_INITIAL_SYS_CATALOG_SNAPSHOT"; } // anonymous namespace // ------------------------------------------------------------------------------------------------ // InitialSysCatalogSnapshotWriter // ------------------------------------------------------------------------------------------------ void InitialSysCatalogSnapshotWriter::AddMetadataChange( tserver::ChangeMetadataRequestPB metadata_change) { initdb_metadata_changes_.push_back(std::move(metadata_change)); } Status InitialSysCatalogSnapshotWriter::WriteSnapshot( tablet::Tablet* sys_catalog_tablet, const std::string& dest_path) { RETURN_NOT_OK(sys_catalog_tablet->Flush(yb::tablet::FlushMode::kSync)); RETURN_NOT_OK(Env::Default()->CreateDir(dest_path)); RETURN_NOT_OK(sys_catalog_tablet->CreateCheckpoint( JoinPathSegments(dest_path, kSysCatalogSnapshotRocksDbSubDir))); tserver::ExportedTabletMetadataChanges exported_tablet_metadata_changes; for (int i = 0; i < initdb_metadata_changes_.size(); ++i) { *exported_tablet_metadata_changes.add_metadata_changes() = std::move( initdb_metadata_changes_[i]); } const string metadata_changes_file = JoinPathSegments( dest_path, kSysCatalogSnapshotTabletMetadataChangesFile); RETURN_NOT_OK(WritePBContainerToPath( Env::Default(), metadata_changes_file, exported_tablet_metadata_changes, pb_util::CreateMode::NO_OVERWRITE, pb_util::SyncMode::NO_SYNC)); LOG(INFO) << "Wrote " << initdb_metadata_changes_.size() << " tablet metadata changes to file " << metadata_changes_file; LOG(INFO) << "Created initial sys catalog snapshot at " << dest_path; return Status::OK(); } // ------------------------------------------------------------------------------------------------ // End of InitialSysCatalogSnapshotWriter // ------------------------------------------------------------------------------------------------ Status RestoreInitialSysCatalogSnapshot( const std::string& initial_snapshot_path, tablet::TabletPeer* sys_catalog_tablet_peer, int64_t term) { TabletSnapshotOpRequestPB tablet_snapshot_req; tablet_snapshot_req.set_operation(yb::tserver::TabletSnapshotOpRequestPB::RESTORE); tablet_snapshot_req.set_tablet_id(kSysCatalogTabletId); tablet_snapshot_req.set_snapshot_dir_override( JoinPathSegments(initial_snapshot_path, kSysCatalogSnapshotRocksDbSubDir)); TabletSnapshotOpResponsePB tablet_snapshot_resp; auto tx_state = std::make_unique<SnapshotOperationState>( sys_catalog_tablet_peer->tablet(), &tablet_snapshot_req); CountDownLatch latch(1); tx_state->set_completion_callback( tablet::MakeLatchOperationCompletionCallback(&latch, &tablet_snapshot_resp)); sys_catalog_tablet_peer->Submit( std::make_unique<tablet::SnapshotOperation>(std::move(tx_state)), term); // Now restore tablet metadata. tserver::ExportedTabletMetadataChanges tablet_metadata_changes; RETURN_NOT_OK(ReadPBContainerFromPath( Env::Default(), JoinPathSegments(initial_snapshot_path, kSysCatalogSnapshotTabletMetadataChangesFile), &tablet_metadata_changes)); for (const tserver::ChangeMetadataRequestPB& change_metadata_req : tablet_metadata_changes.metadata_changes()) { RETURN_NOT_OK(tablet::SyncReplicateChangeMetadataOperation( &change_metadata_req, sys_catalog_tablet_peer, term)); } LOG(INFO) << "Imported " << tablet_metadata_changes.metadata_changes_size() << " tablet metadata changes"; latch.Wait(); return Status::OK(); } void SetDefaultInitialSysCatalogSnapshotFlags() { // Allowing to turn off the use of initial catalog snapshot with an env variable -- useful in // tests. const char* env_var_value = getenv(kUseInitialSysCatalogSnapshotEnvVar); if (env_var_value && strcmp(env_var_value, "0") == 0) { LOG(INFO) << "Disabling the use of initial sys catalog snapshot: env var " << kUseInitialSysCatalogSnapshotEnvVar << " is set to 0"; FLAGS_use_initial_sys_catalog_snapshot = 0; FLAGS_enable_ysql = 0; } if (FLAGS_initial_sys_catalog_snapshot_path.empty() && !FLAGS_create_initial_sys_catalog_snapshot && (FLAGS_use_initial_sys_catalog_snapshot || FLAGS_enable_ysql)) { const char* kStaticDataParentDir = "share"; const std::string search_for_dir = JoinPathSegments( kStaticDataParentDir, kDefaultInitialSysCatalogSnapshotDir, kSysCatalogSnapshotRocksDbSubDir); VLOG(1) << "Searching for directory containing subdirectory " << search_for_dir; const string candidate_dir = JoinPathSegments( env_util::GetRootDir(search_for_dir), kStaticDataParentDir, kDefaultInitialSysCatalogSnapshotDir); VLOG(1) << "candidate_dir=" << candidate_dir; // The metadata changes file is written last, so its presence indicates that the snapshot // was successful. const string candidate_metadata_changes_path = JoinPathSegments(candidate_dir, kSysCatalogSnapshotTabletMetadataChangesFile); VLOG(1) << "candidate_metadata_changes_path=" << candidate_metadata_changes_path; if (Env::Default()->FileExists(candidate_metadata_changes_path)) { VLOG(1) << "Found initial sys catalog snapshot directory: " << candidate_dir; FLAGS_initial_sys_catalog_snapshot_path = candidate_dir; return; } else { VLOG(1) << "File " << candidate_metadata_changes_path << " does not exist"; } } else { VLOG(1) << "Not attempting initial sys catalog snapshot auto-detection: " << "FLAGS_initial_sys_catalog_snapshot_path=" << FLAGS_initial_sys_catalog_snapshot_path << ", " << "FLAGS_create_initial_sys_catalog_snapshot=" << FLAGS_create_initial_sys_catalog_snapshot << ", " << "FLAGS_use_initial_sys_catalog_snapshot=" << FLAGS_use_initial_sys_catalog_snapshot << ", " << "FLAGS_enable_ysql=" << FLAGS_enable_ysql; } } bool ShouldAutoRunInitDb(SysConfigInfo* ysql_catalog_config, bool pg_proc_exists) { if (pg_proc_exists) { LOG(INFO) << "Table pg_proc exists, assuming initdb has already been run"; return false; } if (!FLAGS_master_auto_run_initdb) { LOG(INFO) << "--master_auto_run_initdb is set to false, not running initdb"; return false; } { auto l = ysql_catalog_config->LockForRead(); if (l->data().pb.ysql_catalog_config().initdb_done()) { LOG(INFO) << "Cluster configuration indicates that initdb has already completed"; return false; } } LOG(INFO) << "initdb has never been run on this cluster, running it"; return true; } Status MakeYsqlSysCatalogTablesTransactional( TableInfoMap* table_ids_map, SysCatalogTable* sys_catalog, SysConfigInfo* ysql_catalog_config, int64_t term) { { auto ysql_catalog_config_lock = ysql_catalog_config->LockForRead(); const auto& ysql_catalog_config_pb = ysql_catalog_config_lock->data().pb.ysql_catalog_config(); if (ysql_catalog_config_pb.transactional_sys_catalog_enabled()) { LOG(INFO) << "YSQL catalog tables are already transactional"; return Status::OK(); } } int num_updated_tables = 0; for (const auto& iter : *table_ids_map) { const auto& table_id = iter.first; auto& table_info = *iter.second; if (!IsPgsqlId(table_id)) { continue; } { TabletInfos tablet_infos; table_info.GetAllTablets(&tablet_infos); if (tablet_infos.size() != 1 || tablet_infos.front()->tablet_id() != kSysCatalogTabletId) { continue; } } auto table_lock = table_info.LockForWrite(); auto& schema = *table_lock->mutable_data()->mutable_schema(); auto& table_properties = *schema.mutable_table_properties(); bool should_modify = false; if (!table_properties.is_ysql_catalog_table()) { table_properties.set_is_ysql_catalog_table(true); should_modify = true; } if (!table_properties.is_transactional()) { table_properties.set_is_transactional(true); should_modify = true; } if (!should_modify) { continue; } num_updated_tables++; LOG(INFO) << "Making YSQL system catalog table transactional: " << table_info.ToString(); // Change table properties in tablet metadata. tserver::ChangeMetadataRequestPB change_req; change_req.set_tablet_id(kSysCatalogTabletId); auto& add_table = *change_req.mutable_add_table(); VERIFY_RESULT(sys_catalog->tablet_peer()->tablet_metadata()->GetTableInfo(table_id))->ToPB( &add_table); auto& metadata_table_properties = *add_table.mutable_schema()->mutable_table_properties(); metadata_table_properties.set_is_ysql_catalog_table(true); metadata_table_properties.set_is_transactional(true); RETURN_NOT_OK(tablet::SyncReplicateChangeMetadataOperation( &change_req, sys_catalog->tablet_peer().get(), term)); // Change table properties in the sys catalog. We do this after updating tablet metadata, so // that if a restart happens before this step succeeds, we'll retry updating both next time. RETURN_NOT_OK(sys_catalog->UpdateItem(&table_info, term)); table_lock->Commit(); } if (num_updated_tables > 0) { LOG(INFO) << "Made " << num_updated_tables << " YSQL sys catalog tables transactional"; } LOG(INFO) << "Marking YSQL system catalog as transactional in YSQL catalog config"; { auto ysql_catalog_lock = ysql_catalog_config->LockForWrite(); auto* ysql_catalog_config_pb = ysql_catalog_lock->mutable_data()->pb.mutable_ysql_catalog_config(); ysql_catalog_config_pb->set_transactional_sys_catalog_enabled(true); RETURN_NOT_OK(sys_catalog->UpdateItem(ysql_catalog_config, term)); ysql_catalog_lock->Commit(); } return Status::OK(); } } // namespace master } // namespace yb
39.030488
100
0.718403
738662c27810c1ae8fd41b3675a52e067e5bb8b6
1,575
cpp
C++
src/sched/entry/ze/ze_event_wait_entry.cpp
otcshare/oneccl
44dbef938cb7730eb4f3484389bacaadbfbb99ea
[ "Apache-2.0" ]
null
null
null
src/sched/entry/ze/ze_event_wait_entry.cpp
otcshare/oneccl
44dbef938cb7730eb4f3484389bacaadbfbb99ea
[ "Apache-2.0" ]
null
null
null
src/sched/entry/ze/ze_event_wait_entry.cpp
otcshare/oneccl
44dbef938cb7730eb4f3484389bacaadbfbb99ea
[ "Apache-2.0" ]
1
2021-07-15T08:30:06.000Z
2021-07-15T08:30:06.000Z
/* Copyright 2016-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. */ #include "sched/entry/ze/ze_event_wait_entry.hpp" #include <ze_api.h> ze_event_wait_entry::ze_event_wait_entry(ccl_sched* sched, ze_event_handle_t event) : sched_entry(sched), event(event) { CCL_THROW_IF_NOT(sched, "no sched"); CCL_THROW_IF_NOT(event, "no event"); } void ze_event_wait_entry::check_event_status() { auto query_status = zeEventQueryStatus(event); if (query_status == ZE_RESULT_SUCCESS) { LOG_DEBUG("event complete"); status = ccl_sched_entry_status_complete; } else if (query_status == ZE_RESULT_NOT_READY) { // just return in case if the kernel is not ready yet, will check again on the next iteration return; } else { CCL_THROW("error at zeEventQueryStatus"); } } void ze_event_wait_entry::start() { LOG_DEBUG("start event waiting"); status = ccl_sched_entry_status_started; check_event_status(); } void ze_event_wait_entry::update() { check_event_status(); }
30.882353
101
0.72254
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
7387fb075c05ba940f346b6681a8dda890bd1dc1
3,362
cpp
C++
external/win32cpp/WCE samples/Scribble/MainFrm.cpp
probonopd/Update-Installer
0e46db8acb7bb85174d9e63aca0fce9fbb9a57c2
[ "BSD-2-Clause" ]
236
2015-01-06T15:47:08.000Z
2022-03-31T05:45:50.000Z
external/win32cpp/WCE samples/Scribble/MainFrm.cpp
probonopd/Update-Installer
0e46db8acb7bb85174d9e63aca0fce9fbb9a57c2
[ "BSD-2-Clause" ]
8
2015-09-30T19:00:44.000Z
2021-09-14T12:42:15.000Z
external/win32cpp/WCE samples/Scribble/MainFrm.cpp
probonopd/Update-Installer
0e46db8acb7bb85174d9e63aca0fce9fbb9a57c2
[ "BSD-2-Clause" ]
60
2015-01-02T17:27:27.000Z
2022-02-16T07:36:38.000Z
#include "MainFrm.h" #include "resource.h" CMainFrame::CMainFrame() : m_PenColor(RGB(0,0,0)) { // Set the Resource IDs for the toolbar buttons AddToolBarButton( 0 ); // Separator AddToolBarButton( IDM_RED ); AddToolBarButton( IDM_BLUE ); AddToolBarButton( IDM_GREEN ); AddToolBarButton( IDM_BLACK ); } void CMainFrame::DrawLine(short x, short y) { CDC* pDC = GetDC(); pDC->CreatePen(PS_SOLID, 1, m_points.back().color); pDC->MoveTo(m_points.back().x, m_points.back().y); pDC->LineTo(x, y); } BOOL CMainFrame::OnCommand(WPARAM wParam, LPARAM /*lParam*/) { // Respond to menu and toolbar selections switch (LOWORD(wParam)) { // Respond to menu items case IDM_NEW: m_points.clear(); Invalidate(); return TRUE; case IDM_HELP_ABOUT: { CDialog HelpDialog(IDW_ABOUT, this); HelpDialog.DoModal(); } return TRUE; // Respond to ToolBar buttons case IDM_RED: m_PenColor = RGB(255, 0, 0); TRACE(_T("Red Pen Selected \n")); return TRUE; case IDM_BLUE: m_PenColor = RGB(0, 0, 255); TRACE(_T("Blue Pen Selected \n")); return TRUE; case IDM_GREEN: m_PenColor = RGB(0, 191, 0); TRACE(_T("Green Pen Selected \n")); return TRUE; case IDM_BLACK: m_PenColor = RGB(0, 0, 0); TRACE(_T("Black Pen Selected \n")); return TRUE; // Respond to the accelerator key case IDW_QUIT: SendMessage(WM_CLOSE, 0L, 0L); return TRUE; } return FALSE; } void CMainFrame::OnDraw(CDC* pDC) { // Redraw our client area if (m_points.size() > 0) { bool bDraw = false; //Start with the pen up for (unsigned int i = 0 ; i < m_points.size(); i++) { pDC->CreatePen(PS_SOLID, 1, m_points[i].color); if (bDraw) pDC->LineTo(m_points[i].x, m_points[i].y); else pDC->MoveTo(m_points[i].x, m_points[i].y); bDraw = m_points[i].PenDown; } } } void CMainFrame::OnInitialUpdate() { // Startup code goes here } void CMainFrame::OnLButtonDown(WPARAM /*wParam*/, LPARAM lParam) { // Capture mouse input. SetCapture(); StorePoint(LOWORD(lParam), HIWORD(lParam), true); } void CMainFrame::OnLButtonUp(WPARAM /*wParam*/, LPARAM lParam) { //Release the capture on the mouse ReleaseCapture(); StorePoint(LOWORD(lParam), HIWORD(lParam), false); } void CMainFrame::OnMouseMove(WPARAM wParam, LPARAM lParam) { // hold down the left mouse button and move mouse to draw lines. if (wParam & MK_LBUTTON) { TCHAR str[80]; ::wsprintf(str, TEXT("Draw Point: %hd, %hd\n"), LOWORD(lParam), HIWORD(lParam)); TRACE(str); DrawLine(LOWORD(lParam), HIWORD(lParam)); StorePoint(LOWORD(lParam), HIWORD(lParam), true); } } void CMainFrame::SetPen(COLORREF color) { m_PenColor = color; } void CMainFrame::StorePoint(int x, int y, bool PenDown) { PlotPoint P1; P1.x = x; P1.y = y; P1.PenDown = PenDown; P1.color = m_PenColor; m_points.push_back(P1); //Add the point to the vector } LRESULT CMainFrame::WndProc(UINT uMsg, WPARAM wParam, LPARAM lParam) { // handle left mouse button up/down and mouse move messages // a seperate function for each case keeps the code tidy. switch (uMsg) { case WM_LBUTTONDOWN: OnLButtonDown(wParam, lParam); break; case WM_MOUSEMOVE: OnMouseMove(wParam, lParam); break; case WM_LBUTTONUP: OnLButtonUp(wParam, lParam); break; } // Pass unhandled messages on to WndProcDefault return WndProcDefault(uMsg, wParam, lParam); }
20.753086
83
0.682927
7388c69d220200c084c0ca5685f72bcf630a3204
1,421
cpp
C++
src/rpcserver/iothreadpool.cpp
SymbioticLab/Salus
b2a194e7e4654b51dbd8d8fc1577fb1e9915ca6f
[ "Apache-2.0" ]
104
2019-02-12T20:41:07.000Z
2022-03-07T16:58:47.000Z
src/rpcserver/iothreadpool.cpp
SymbioticLab/Salus
b2a194e7e4654b51dbd8d8fc1577fb1e9915ca6f
[ "Apache-2.0" ]
9
2019-08-24T03:23:21.000Z
2021-06-06T17:59:07.000Z
src/rpcserver/iothreadpool.cpp
SymbioticLab/Salus
b2a194e7e4654b51dbd8d8fc1577fb1e9915ca6f
[ "Apache-2.0" ]
18
2019-03-04T07:45:41.000Z
2021-09-15T22:13:07.000Z
/* * Copyright 2019 Peifeng Yu <peifeng@umich.edu> * * This file is part of Salus * (see https://github.com/SymbioticLab/Salus). * * 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 "iothreadpool.h" #include "platform/thread_annotations.h" #include <thread> namespace salus { IOThreadPoolImpl::IOThreadPoolImpl() : m_numThreads(std::max(std::thread::hardware_concurrency() / 2, 1u)) , m_context(static_cast<int>(m_numThreads)) , m_workguard(boost::asio::make_work_guard(m_context)) { while (m_threads.size() < m_numThreads) { m_threads.create_thread(std::bind(&IOThreadPoolImpl::workerLoop, this)); } } IOThreadPoolImpl::~IOThreadPoolImpl() { m_context.stop(); m_workguard.reset(); m_threads.join_all(); } void IOThreadPoolImpl::workerLoop() { threading::set_thread_name("salus::IOThreadPoolWorker"); m_context.run(); } } // namespace salus
27.862745
80
0.717804
738a89dff4b2053c53125ee0b2421384ab36fd0b
15,812
cpp
C++
tests/src/gui/testqgssqlcomposerdialog.cpp
dyna-mis/Hilabeling
cb7d5d4be29624a20c8a367162dbc6fd779b2b52
[ "MIT" ]
null
null
null
tests/src/gui/testqgssqlcomposerdialog.cpp
dyna-mis/Hilabeling
cb7d5d4be29624a20c8a367162dbc6fd779b2b52
[ "MIT" ]
null
null
null
tests/src/gui/testqgssqlcomposerdialog.cpp
dyna-mis/Hilabeling
cb7d5d4be29624a20c8a367162dbc6fd779b2b52
[ "MIT" ]
1
2021-12-25T08:40:30.000Z
2021-12-25T08:40:30.000Z
/*************************************************************************** testqgssqlcomposerdialog.cpp -------------------------------------- Date : April 2016 Copyright : (C) 2016 Even Rouault Email : even.rouault at spatialys.com *************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ #include "qgstest.h" #include <qgslogger.h> #include <qgssqlcomposerdialog.h> class TestQgsSQLComposerDialog: public QObject { Q_OBJECT private slots: void testReciprocalEditorsUpdate(); void testSelectTable(); void testSelectColumn(); void testSelectFunction(); void testSelectSpatialPredicate(); void testSelectOperator(); void testJoins(); private: bool runTest(); }; bool TestQgsSQLComposerDialog::runTest() { // Those tests are fragile because may depend on focus works without // widget being displayed. Or shortcuts to go to end of line //const char* travis = getenv( "TRAVIS_OS_NAME" ); //if ( travis && strcmp( travis, "osx" ) == 0 ) //{ // QgsDebugMsg( QStringLiteral( "Test disabled" ) ); // return false; //} return true; } static QWidget *getQueryEdit( QgsSQLComposerDialog &d ) { QWidget *widget = d.findChild<QWidget *>( QStringLiteral( "mQueryEdit" ) ); Q_ASSERT( widget ); return widget; } static QWidget *getColumnsEditor( QgsSQLComposerDialog &d ) { QWidget *widget = d.findChild<QWidget *>( QStringLiteral( "mColumnsEditor" ) ); Q_ASSERT( widget ); return widget; } static QWidget *getTablesEditor( QgsSQLComposerDialog &d ) { QWidget *widget = d.findChild<QWidget *>( QStringLiteral( "mTablesEditor" ) ); Q_ASSERT( widget ); return widget; } static QWidget *getWhereEditor( QgsSQLComposerDialog &d ) { QWidget *widget = d.findChild<QWidget *>( QStringLiteral( "mWhereEditor" ) ); Q_ASSERT( widget ); return widget; } static QWidget *getOrderEditor( QgsSQLComposerDialog &d ) { QWidget *widget = d.findChild<QWidget *>( QStringLiteral( "mOrderEditor" ) ); Q_ASSERT( widget ); return widget; } static QComboBox *getTablesCombo( QgsSQLComposerDialog &d ) { QComboBox *widget = d.findChild<QComboBox *>( QStringLiteral( "mTablesCombo" ) ); Q_ASSERT( widget ); return widget; } static QComboBox *getColumnsCombo( QgsSQLComposerDialog &d ) { QComboBox *widget = d.findChild<QComboBox *>( QStringLiteral( "mColumnsCombo" ) ); Q_ASSERT( widget ); return widget; } static QComboBox *getFunctionsCombo( QgsSQLComposerDialog &d ) { QComboBox *widget = d.findChild<QComboBox *>( QStringLiteral( "mFunctionsCombo" ) ); Q_ASSERT( widget ); return widget; } static QComboBox *getSpatialPredicatesCombo( QgsSQLComposerDialog &d ) { QComboBox *widget = d.findChild<QComboBox *>( QStringLiteral( "mSpatialPredicatesCombo" ) ); Q_ASSERT( widget ); return widget; } static QComboBox *getOperatorsCombo( QgsSQLComposerDialog &d ) { QComboBox *widget = d.findChild<QComboBox *>( QStringLiteral( "mOperatorsCombo" ) ); Q_ASSERT( widget ); return widget; } static QWidget *getResetButton( QgsSQLComposerDialog &d ) { QDialogButtonBox *mButtonBox = d.findChild<QDialogButtonBox *>( QStringLiteral( "mButtonBox" ) ); Q_ASSERT( mButtonBox ); QPushButton *button = mButtonBox->button( QDialogButtonBox::Reset ); Q_ASSERT( button ); return button; } static QTableWidget *getTableJoins( QgsSQLComposerDialog &d ) { QTableWidget *widget = d.findChild<QTableWidget *>( QStringLiteral( "mTableJoins" ) ); Q_ASSERT( widget ); return widget; } static QWidget *getAddJoinButton( QgsSQLComposerDialog &d ) { QWidget *widget = d.findChild<QWidget *>( QStringLiteral( "mAddJoinButton" ) ); Q_ASSERT( widget ); return widget; } static QWidget *getRemoveJoinButton( QgsSQLComposerDialog &d ) { QWidget *widget = d.findChild<QWidget *>( QStringLiteral( "mRemoveJoinButton" ) ); Q_ASSERT( widget ); return widget; } static void gotoEndOfLine( QWidget *w ) { #ifdef Q_OS_MAC QTest::keyPress( w, Qt::Key_Right, Qt::ControlModifier ); #else QTest::keyPress( w, Qt::Key_End ); #endif } void TestQgsSQLComposerDialog::testReciprocalEditorsUpdate() { if ( !runTest() ) return; QgsSQLComposerDialog d; QString oriSql( QStringLiteral( "SELECT a_column FROM my_table JOIN join_table ON cond WHERE where_expr ORDER BY column DESC" ) ); d.setSql( oriSql ); QCOMPARE( d.sql(), oriSql ); gotoEndOfLine( getColumnsEditor( d ) ); QTest::keyClicks( getColumnsEditor( d ), QStringLiteral( ", another_column" ) ); gotoEndOfLine( getTablesEditor( d ) ); QTest::keyClicks( getTablesEditor( d ), QStringLiteral( ", another_from_table" ) ); gotoEndOfLine( getWhereEditor( d ) ); QTest::keyClicks( getWhereEditor( d ), QStringLiteral( " AND another_cond" ) ); gotoEndOfLine( getOrderEditor( d ) ); QTest::keyClicks( getOrderEditor( d ), QStringLiteral( ", another_column_asc" ) ); QCOMPARE( d.sql(), QString( "SELECT a_column, another_column FROM my_table, another_from_table JOIN join_table ON cond WHERE where_expr AND another_cond ORDER BY column DESC, another_column_asc" ) ); QTest::mouseClick( getResetButton( d ), Qt::LeftButton ); QCOMPARE( d.sql(), oriSql ); } static void setFocusIn( QWidget *widget ) { QFocusEvent focusInEvent( QEvent::FocusIn ); QApplication::sendEvent( widget, &focusInEvent ); } void TestQgsSQLComposerDialog::testSelectTable() { if ( !runTest() ) return; QgsSQLComposerDialog d; d.addTableNames( QStringList() << QStringLiteral( "my_table" ) ); d.addTableNames( QList<QgsSQLComposerDialog::PairNameTitle>() << QgsSQLComposerDialog::PairNameTitle( QStringLiteral( "another_table" ), QStringLiteral( "title" ) ) ); QCOMPARE( getTablesCombo( d )->itemText( 1 ), QString( "my_table" ) ); QCOMPARE( getTablesCombo( d )->itemText( 2 ), QString( "another_table (title)" ) ); d.setSql( QStringLiteral( "SELECT * FROM " ) ); gotoEndOfLine( getQueryEdit( d ) ); // Set focus in SQL zone setFocusIn( getQueryEdit( d ) ); // Select dummy entry in combo getTablesCombo( d )->setCurrentIndex( 0 ); // Select first entry in combo getTablesCombo( d )->setCurrentIndex( 1 ); QCOMPARE( d.sql(), QString( "SELECT * FROM my_table" ) ); // Set focus in table editor setFocusIn( getTablesEditor( d ) ); // Select second entry in combo getTablesCombo( d )->setCurrentIndex( 2 ); QCOMPARE( d.sql(), QString( "SELECT * FROM my_table, another_table" ) ); } void TestQgsSQLComposerDialog::testSelectColumn() { if ( !runTest() ) return; QgsSQLComposerDialog d; d.addColumnNames( QList<QgsSQLComposerDialog::PairNameType>() << QgsSQLComposerDialog::PairNameType( QStringLiteral( "a" ), QString() ) << QgsSQLComposerDialog::PairNameType( QStringLiteral( "b" ), QStringLiteral( "type" ) ), QStringLiteral( "my_table" ) ); QCOMPARE( getColumnsCombo( d )->itemText( 1 ), QString( "a" ) ); QCOMPARE( getColumnsCombo( d )->itemText( 2 ), QString( "b (type)" ) ); d.setSql( QStringLiteral( "SELECT " ) ); gotoEndOfLine( getQueryEdit( d ) ); // Set focus in SQL zone setFocusIn( getQueryEdit( d ) ); // Select dummy entry in combo getColumnsCombo( d )->setCurrentIndex( 0 ); // Select first entry in combo getColumnsCombo( d )->setCurrentIndex( 1 ); QCOMPARE( d.sql(), QString( "SELECT a" ) ); gotoEndOfLine( getQueryEdit( d ) ); QTest::keyClicks( getQueryEdit( d ), QStringLiteral( " FROM my_table" ) ); QCOMPARE( d.sql(), QString( "SELECT a FROM my_table" ) ); // Set focus in column editor setFocusIn( getColumnsEditor( d ) ); QTest::keyPress( getColumnsEditor( d ), Qt::Key_End ); // Select second entry in combo getColumnsCombo( d )->setCurrentIndex( 2 ); QCOMPARE( d.sql(), QString( "SELECT a,\nb FROM my_table" ) ); // Set focus in where editor setFocusIn( getWhereEditor( d ) ); getColumnsCombo( d )->setCurrentIndex( 1 ); QCOMPARE( d.sql(), QString( "SELECT a,\nb FROM my_table WHERE a" ) ); // Set focus in order editor setFocusIn( getOrderEditor( d ) ); getColumnsCombo( d )->setCurrentIndex( 2 ); QCOMPARE( d.sql(), QString( "SELECT a,\nb FROM my_table WHERE a ORDER BY b" ) ); } void TestQgsSQLComposerDialog::testSelectFunction() { if ( !runTest() ) return; QgsSQLComposerDialog d; QList<QgsSQLComposerDialog::Function> functions; { QgsSQLComposerDialog::Function f; f.name = QStringLiteral( "first_func" ); functions << f; } { QgsSQLComposerDialog::Function f; f.name = QStringLiteral( "second_func" ); f.returnType = QStringLiteral( "xs:int" ); functions << f; } { QgsSQLComposerDialog::Function f; f.name = QStringLiteral( "third_func" ); f.minArgs = 1; f.maxArgs = 1; functions << f; } { QgsSQLComposerDialog::Function f; f.name = QStringLiteral( "fourth_func" ); f.minArgs = 1; f.maxArgs = 2; functions << f; } { QgsSQLComposerDialog::Function f; f.name = QStringLiteral( "fifth_func" ); f.minArgs = 1; functions << f; } { QgsSQLComposerDialog::Function f; f.name = QStringLiteral( "sixth_func" ); f.argumentList << QgsSQLComposerDialog::Argument( QStringLiteral( "arg1" ), QString() ); f.argumentList << QgsSQLComposerDialog::Argument( QStringLiteral( "arg2" ), QStringLiteral( "xs:double" ) ); f.argumentList << QgsSQLComposerDialog::Argument( QStringLiteral( "arg3" ), QStringLiteral( "gml:AbstractGeometryType" ) ); f.argumentList << QgsSQLComposerDialog::Argument( QStringLiteral( "number" ), QStringLiteral( "xs:int" ) ); functions << f; } { QgsSQLComposerDialog::Function f; f.name = QStringLiteral( "seventh_func" ); f.argumentList << QgsSQLComposerDialog::Argument( QStringLiteral( "arg1" ), QString() ); f.argumentList << QgsSQLComposerDialog::Argument( QStringLiteral( "arg2" ), QStringLiteral( "xs:double" ) ); f.minArgs = 1; functions << f; } d.addFunctions( functions ); QCOMPARE( getFunctionsCombo( d )->itemText( 1 ), QString( "first_func()" ) ); QCOMPARE( getFunctionsCombo( d )->itemText( 2 ), QString( "second_func(): int" ) ); QCOMPARE( getFunctionsCombo( d )->itemText( 3 ), QString( "third_func(1 argument)" ) ); QCOMPARE( getFunctionsCombo( d )->itemText( 4 ), QString( "fourth_func(1 to 2 arguments)" ) ); QCOMPARE( getFunctionsCombo( d )->itemText( 5 ), QString( "fifth_func(1 argument or more)" ) ); QCOMPARE( getFunctionsCombo( d )->itemText( 6 ), QString( "sixth_func(arg1, arg2: double, arg3: geometry, int)" ) ); QCOMPARE( getFunctionsCombo( d )->itemText( 7 ), QString( "seventh_func(arg1[, arg2: double])" ) ); d.setSql( QStringLiteral( "SELECT * FROM my_table" ) ); // Set focus in where editor setFocusIn( getWhereEditor( d ) ); getFunctionsCombo( d )->setCurrentIndex( 0 ); getFunctionsCombo( d )->setCurrentIndex( 1 ); QCOMPARE( d.sql(), QString( "SELECT * FROM my_table WHERE first_func(" ) ); // Set focus in SQL zone d.setSql( QStringLiteral( "SELECT * FROM my_table WHERE " ) ); setFocusIn( getQueryEdit( d ) ); gotoEndOfLine( getQueryEdit( d ) ); getFunctionsCombo( d )->setCurrentIndex( 0 ); getFunctionsCombo( d )->setCurrentIndex( 1 ); QCOMPARE( d.sql(), QString( "SELECT * FROM my_table WHERE first_func(" ) ); } void TestQgsSQLComposerDialog::testSelectSpatialPredicate() { if ( !runTest() ) return; QgsSQLComposerDialog d; d.addSpatialPredicates( QList<QgsSQLComposerDialog::Function>() << QgsSQLComposerDialog::Function( QStringLiteral( "predicate" ), 2 ) ); d.setSql( QStringLiteral( "SELECT * FROM my_table" ) ); // Set focus in where editor setFocusIn( getWhereEditor( d ) ); getSpatialPredicatesCombo( d )->setCurrentIndex( 0 ); getSpatialPredicatesCombo( d )->setCurrentIndex( 1 ); QCOMPARE( d.sql(), QString( "SELECT * FROM my_table WHERE predicate(" ) ); // Set focus in SQL zone d.setSql( QStringLiteral( "SELECT * FROM my_table WHERE " ) ); setFocusIn( getQueryEdit( d ) ); gotoEndOfLine( getQueryEdit( d ) ); getSpatialPredicatesCombo( d )->setCurrentIndex( 0 ); getSpatialPredicatesCombo( d )->setCurrentIndex( 1 ); QCOMPARE( d.sql(), QString( "SELECT * FROM my_table WHERE predicate(" ) ); } void TestQgsSQLComposerDialog::testSelectOperator() { if ( !runTest() ) return; QgsSQLComposerDialog d; d.setSql( QStringLiteral( "SELECT * FROM my_table" ) ); // Set focus in where editor setFocusIn( getWhereEditor( d ) ); getOperatorsCombo( d )->setCurrentIndex( 0 ); getOperatorsCombo( d )->setCurrentIndex( 1 ); QCOMPARE( d.sql(), QString( "SELECT * FROM my_table WHERE AND" ) ); // Set focus in SQL zone d.setSql( QStringLiteral( "SELECT * FROM my_table WHERE " ) ); setFocusIn( getQueryEdit( d ) ); gotoEndOfLine( getQueryEdit( d ) ); getOperatorsCombo( d )->setCurrentIndex( 0 ); getOperatorsCombo( d )->setCurrentIndex( 1 ); QCOMPARE( d.sql(), QString( "SELECT * FROM my_table WHERE AND" ) ); } void TestQgsSQLComposerDialog::testJoins() { if ( !runTest() ) return; QgsSQLComposerDialog d; d.setSql( QStringLiteral( "SELECT * FROM my_table" ) ); d.setSupportMultipleTables( true ); QTableWidget *table = getTableJoins( d ); QCOMPARE( table->rowCount(), 1 ); QVERIFY( table->item( 0, 0 ) ); table->item( 0, 0 )->setText( QStringLiteral( "join_table" ) ); table->item( 0, 1 )->setText( QStringLiteral( "join_expr" ) ); QCOMPARE( d.sql(), QString( "SELECT * FROM my_table JOIN join_table ON join_expr" ) ); QTest::mouseClick( getAddJoinButton( d ), Qt::LeftButton ); QCOMPARE( table->rowCount(), 2 ); table->item( 1, 0 )->setText( QStringLiteral( "join2_table" ) ); table->item( 1, 1 )->setText( QStringLiteral( "join2_expr" ) ); QCOMPARE( d.sql(), QString( "SELECT * FROM my_table JOIN join_table ON join_expr JOIN join2_table ON join2_expr" ) ); table->setCurrentCell( 0, 0 ); QTest::mouseClick( getAddJoinButton( d ), Qt::LeftButton ); QCOMPARE( table->rowCount(), 3 ); table->item( 1, 0 )->setText( QStringLiteral( "join15_table" ) ); table->item( 1, 1 )->setText( QStringLiteral( "join15_expr" ) ); QCOMPARE( d.sql(), QString( "SELECT * FROM my_table JOIN join_table ON join_expr JOIN join15_table ON join15_expr JOIN join2_table ON join2_expr" ) ); table->setCurrentCell( 1, 0 ); QTest::mouseClick( getRemoveJoinButton( d ), Qt::LeftButton ); QCOMPARE( table->rowCount(), 2 ); QCOMPARE( d.sql(), QString( "SELECT * FROM my_table JOIN join_table ON join_expr JOIN join2_table ON join2_expr" ) ); QTest::mouseClick( getRemoveJoinButton( d ), Qt::LeftButton ); QCOMPARE( table->rowCount(), 1 ); QCOMPARE( d.sql(), QString( "SELECT * FROM my_table JOIN join_table ON join_expr" ) ); QTest::mouseClick( getRemoveJoinButton( d ), Qt::LeftButton ); QCOMPARE( table->rowCount(), 1 ); table->setCurrentCell( 0, 0 ); QTest::mouseClick( getRemoveJoinButton( d ), Qt::LeftButton ); QCOMPARE( table->rowCount(), 0 ); QCOMPARE( d.sql(), QString( "SELECT * FROM my_table" ) ); QTest::mouseClick( getAddJoinButton( d ), Qt::LeftButton ); QCOMPARE( table->rowCount(), 1 ); QVERIFY( table->item( 0, 0 ) ); } QGSTEST_MAIN( TestQgsSQLComposerDialog ) #include "testqgssqlcomposerdialog.moc"
33.714286
201
0.667405
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
738cc6d0ea241df86f35c3aa97456b5fdbe148dc
991
cpp
C++
workspace/projects/lab13/sources/unpack.cpp
GolubkovArtem/lab13
785d2beab547fc6d6e0d8760293fe65d754f641e
[ "MIT" ]
null
null
null
workspace/projects/lab13/sources/unpack.cpp
GolubkovArtem/lab13
785d2beab547fc6d6e0d8760293fe65d754f641e
[ "MIT" ]
null
null
null
workspace/projects/lab13/sources/unpack.cpp
GolubkovArtem/lab13
785d2beab547fc6d6e0d8760293fe65d754f641e
[ "MIT" ]
null
null
null
#include <iostream> #include <fstream> using json = nlohmann::json; struct Email { std::string nickname; std::string server; }; struct Person { std::string first_name; std::string last_name; Email email; size_t age; std::string phone; }; std::ostream & print (std::ostream & out, json & j_son) { out << "person:" << "\n firstname: " << j_son.at("First name").get<std::string>() << "\n lastname: " << j_son.at("Last name").get<std::string>() << "\n email: " << j_son.at("Email").get<std::string>(); if (j_son.find("Age") != j_son.end()) { out << "\n age: " << j_son.at("Age").get<size_t>(); } if (j_son.find("Phone") != j_son.end()) { out << "\n phone: " << j_son.at("Phone").get<std::string>(); } return out; } int main(int argc, char * argv[]) { std::ifstream file(argv[1]); json j_son; file >> j_son; print(std::cout, j_son); return 0; }
22.522727
74
0.52775
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 <beat-kueng@gmx.net> */ #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
738fbe615d90e30181d897804a5538d5ab970e6d
2,034
cpp
C++
lit/SymbolFile/NativePDB/typedefs.cpp
nathawes/swift-lldb
3cbf7470e0f9191ec1fc1c69ce8048c1dc64ec77
[ "Apache-2.0" ]
2
2019-05-24T14:10:24.000Z
2019-05-24T14:27:38.000Z
lit/SymbolFile/NativePDB/typedefs.cpp
DalavanCloud/lldb
e913eaf2468290fb94c767d474d611b41a84dd69
[ "Apache-2.0" ]
null
null
null
lit/SymbolFile/NativePDB/typedefs.cpp
DalavanCloud/lldb
e913eaf2468290fb94c767d474d611b41a84dd69
[ "Apache-2.0" ]
null
null
null
// clang-format off // REQUIRES: system-windows // RUN: %build --compiler=clang-cl --nodefaultlib -o %t.exe -- %s // RUN: env LLDB_USE_NATIVE_PDB_READER=1 lldb-test symbols -dump-ast %t.exe | FileCheck %s namespace A { namespace B { using NamespaceTypedef = double; } template<typename T> class C { public: using ClassTypedef = T; }; using ClassTypedef = C<char>::ClassTypedef; using ClassTypedef2 = C<wchar_t>::ClassTypedef; template<typename T> using AliasTemplate = typename C<T>::ClassTypedef; } namespace { using AnonNamespaceTypedef = bool; } using IntTypedef = int; using ULongArrayTypedef = unsigned long[10]; using RefTypedef = long double*&; using FuncPtrTypedef = long long(*)(int&, unsigned char**, short[], const double, volatile bool); using VarArgsFuncTypedef = char(*)(void*, long, unsigned short, unsigned int, ...); using VarArgsFuncTypedefA = float(*)(...); int main(int argc, char **argv) { long double *Ptr; A::B::NamespaceTypedef *X0; A::C<char>::ClassTypedef *X1; A::C<wchar_t>::ClassTypedef *X2; AnonNamespaceTypedef *X3; IntTypedef *X4; ULongArrayTypedef *X5; RefTypedef X6 = Ptr; FuncPtrTypedef X7; VarArgsFuncTypedef X8; VarArgsFuncTypedefA X9; A::AliasTemplate<float> X10; return 0; } // CHECK: namespace `anonymous namespace' { // CHECK-NEXT: typedef bool AnonNamespaceTypedef; // CHECK-NEXT: } // CHECK-NEXT: typedef unsigned long ULongArrayTypedef[10]; // CHECK-NEXT: typedef double *&RefTypedef; // CHECK-NEXT: namespace A { // CHECK-NEXT: namespace B { // CHECK-NEXT: typedef double NamespaceTypedef; // CHECK-NEXT: } // CHECK-NEXT: typedef float AliasTemplate<float>; // CHECK-NEXT: } // CHECK-NEXT: typedef long long (*FuncPtrTypedef)(int &, unsigned char **, short *, const double, volatile bool); // CHECK-NEXT: typedef char (*VarArgsFuncTypedef)(void *, long, unsigned short, unsigned int, ...); // CHECK-NEXT: typedef float (*VarArgsFuncTypedefA)(...); // CHECK-NEXT: typedef int IntTypedef;
28.25
114
0.692232
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
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
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
73997f23aa41c72edfe6e899e16f9d36e9bd1c4d
17,757
cpp
C++
AnalyzerExamples/CanAnalyzer/CanSimulationDataGenerator.cpp
blargony/RFFEAnalyzer
24684cee1494f5ac4bd7d9c9f020f42248a06f89
[ "MIT" ]
15
2015-06-23T23:28:24.000Z
2022-03-12T03:23:31.000Z
AnalyzerExamples/CanAnalyzer/CanSimulationDataGenerator.cpp
blargony/RFFEAnalyzer
24684cee1494f5ac4bd7d9c9f020f42248a06f89
[ "MIT" ]
3
2015-06-23T23:41:48.000Z
2022-03-16T22:20:50.000Z
AnalyzerExamples/CanAnalyzer/CanSimulationDataGenerator.cpp
blargony/RFFEAnalyzer
24684cee1494f5ac4bd7d9c9f020f42248a06f89
[ "MIT" ]
3
2015-06-23T23:28:30.000Z
2020-07-30T15:46:04.000Z
#include "CanSimulationDataGenerator.h" #include "CanAnalyzerSettings.h" CanSimulationDataGenerator::CanSimulationDataGenerator() { } CanSimulationDataGenerator::~CanSimulationDataGenerator() { } void CanSimulationDataGenerator::Initialize( U32 simulation_sample_rate, CanAnalyzerSettings* settings ) { mSimulationSampleRateHz = simulation_sample_rate; mSettings = settings; mClockGenerator.Init( mSettings->mBitRate, simulation_sample_rate ); mCanSimulationData.SetChannel( mSettings->mCanChannel ); mCanSimulationData.SetSampleRate( simulation_sample_rate ); mCanSimulationData.SetInitialBitState( mSettings->Recessive() ); mCanSimulationData.Advance( mClockGenerator.AdvanceByHalfPeriod( 10.0 ) ); //insert 10 bit-periods of idle mValue = 0; } U32 CanSimulationDataGenerator::GenerateSimulationData( U64 largest_sample_requested, U32 sample_rate, SimulationChannelDescriptor** simulation_channels ) { U64 adjusted_largest_sample_requested = AnalyzerHelpers::AdjustSimulationTargetSample( largest_sample_requested, sample_rate, mSimulationSampleRateHz ); std::vector<U8> data; std::vector<U8> empty_data; while( mCanSimulationData.GetCurrentSampleNumber() < adjusted_largest_sample_requested ) { data.clear(); data.push_back( mValue + 0 ); data.push_back( mValue + 1 ); data.push_back( mValue + 2 ); data.push_back( mValue + 3 ); data.push_back( mValue + 4 ); data.push_back( mValue + 5 ); data.push_back( mValue + 6 ); data.push_back( mValue + 7 ); mValue++; CreateDataOrRemoteFrame( 123, false, false, data, true ); WriteFrame(); CreateDataOrRemoteFrame( 321, true, false, data, true ); WriteFrame(); CreateDataOrRemoteFrame( 456, true, false, data, true ); WriteFrame(true); mCanSimulationData.Advance( mClockGenerator.AdvanceByHalfPeriod( 40 ) ); CreateDataOrRemoteFrame( 123, false, true, empty_data, true ); WriteFrame(); CreateDataOrRemoteFrame( 321, true, true, empty_data, true ); WriteFrame(); mCanSimulationData.Advance( mClockGenerator.AdvanceByHalfPeriod( 100 ) ); } *simulation_channels = &mCanSimulationData; return 1; // we are retuning the size of the SimulationChannelDescriptor array. In our case, the "array" is length 1. } void CanSimulationDataGenerator::CreateDataOrRemoteFrame( U32 identifier, bool use_extended_frame_format, bool remote_frame, std::vector<U8>& data, bool get_ack_in_response ) { //A DATA FRAME is composed of seven different bit fields: //START OF FRAME, ARBITRATION FIELD, CONTROL FIELD, DATA FIELD, CRC //FIELD, ACK FIELD, END OF FRAME. The DATA FIELD can be of length zero. mFakeStuffedBits.clear(); mFakeFixedFormBits.clear(); mFakeStartOfFrameField.clear(); mFakeArbitrationField.clear(); mFakeControlField.clear(); mFakeDataField.clear(); mFakeCrcFieldWithoutDelimiter.clear(); mFakeAckField.clear(); mFakeEndOfFrame.clear(); //START OF FRAME (Standard Format as well as Extended Format) //The START OF FRAME (SOF) marks the beginning of DATA FRAMES and REMOTE //FRAMEs. It consists of a single dominant bit. //A station is only allowed to start transmission when the bus is idle (see INTERFRAME //Spacing). All stations have to synchronize to the leading edge caused by START OF //FRAME (see HARD SYNCHRONIZATION) of the station starting transmission first. mFakeStartOfFrameField.push_back( mSettings->Dominant() ); //ARBITRATION FIELD //The format of the ARBITRATION FIELD is different for Standard Format and //Extended Format Frames. //In Standard Format the ARBITRATION FIELD consists of the 11 bit IDENTIFIER //and the RTR-BIT. The IDENTIFIER bits are denoted ID-28 ... ID-18. //In Extended Format the ARBITRATION FIELD consists of the 29 bit IDENTIFIER, //the SRR-Bit, the IDE-Bit, and the RTR-BIT. The IDENTIFIER bits are denoted ID-28 //... ID-0. if( use_extended_frame_format == true ) { U32 mask = 1 << 28; //28 bits in exdended format's identifier. //IDENTIFIER - Extended Format //In contrast to the Standard Format the Extended Format consists of 29 bits. The //format comprises two sections: //Base ID //The Base ID consists of 11 bits. It is transmitted in the order from ID-28 to ID-18. It //is equivalent to format of the Standard Identifier. The Base ID defines the Extended //Frames base priority. //Extended ID //The Extended ID consists of 18 bits. It is transmitted in the order of ID-17 to ID-0. //11 bits of identifier: for( U32 i=0; i<11; i++ ) { if( ( mask & identifier ) == 0 ) mFakeArbitrationField.push_back( mSettings->Dominant() ); else mFakeArbitrationField.push_back( mSettings->Recessive() ); mask >>= 1; } //the next bit is SRR //SRR BIT (Extended Format) //Substitute Remote Request BIT //The SRR is a recessive bit. It is transmitted in Extended Frames at the position of the //RTR bit in Standard Frames and so substitutes the RTR-Bit in the Standard Frame. //Therefore, collisions of a Standard Frame and an Extended Frame, the Base ID (see //Extended IDENTIFIER below) of which is the same as the Standard Frames Identifier, //are resolved in such a way that the Standard Frame prevails the Extended Frame. mFakeArbitrationField.push_back( mSettings->Recessive() ); //SSR bit //the next bit is IDE //IDE BIT (Extended Format) //Identifier Extension Bit //The IDE Bit belongs to //- the ARBITRATION FIELD for the Extended Format //- the Control Field for the Standard Format //The IDE bit in the Standard Format is transmitted dominant, whereas in the Extended //Format the IDE bit is recessive. mFakeArbitrationField.push_back( mSettings->Recessive() ); //IDE bit //18 bits of identifier: for( U32 i=0; i<18; i++ ) { if( ( mask & identifier ) == 0 ) mFakeArbitrationField.push_back( mSettings->Dominant() ); else mFakeArbitrationField.push_back( mSettings->Recessive() ); mask >>= 1; } //the next bit is RTR //RTR BIT (Standard Format as well as Extended Format) //Remote Transmission Request BIT //In DATA FRAMEs the RTR BIT has to be dominant. Within a REMOTE FRAME the //RTR BIT has to be recessive. if( remote_frame == true ) mFakeArbitrationField.push_back( mSettings->Recessive() ); //RTR bit else mFakeArbitrationField.push_back( mSettings->Dominant() ); //RTR bit //next is the control field. r1, r0, DLC3, DLC2, DLC1, DLC0 //CONTROL FIELD (Standard Format as well as Extended Format) //The CONTROL FIELD consists of six bits. The format of the CONTROL FIELD is //different for Standard Format and Extended Format. Frames in Standard Format //include the DATA LENGTH CODE, the IDE bit, which is transmitted dominant (see //above), and the reserved bit r0. Frames in the Extended Format include the DATA //LENGTH CODE and two reserved bits r1 and r0. The reserved bits have to be sent //dominant, but receivers accept dominant and recessive bits in all combinations. mFakeControlField.push_back( mSettings->Recessive() ); //r1 bit mFakeControlField.push_back( mSettings->Recessive() ); //r0 bit }else { //IDENTIFIER //IDENTIFIER - Standard Format //The IDENTIFIERs length is 11 bits and corresponds to the Base ID in Extended //Format. These bits are transmitted in the order from ID-28 to ID-18. The least //significant bit is ID-18. The 7 most significant bits (ID-28 - ID-22) must not be all //recessive. //In a Standard Frame the IDENTIFIER is followed by the RTR bit. //RTR BIT (Standard Format as well as Extended Format) //Remote Transmission Request BIT //In DATA FRAMEs the RTR BIT has to be dominant. Within a REMOTE FRAME the //RTR BIT has to be recessive. U32 mask = 1 << 10; for( U32 i=0; i<11; i++ ) { if( ( mask & identifier ) == 0 ) mFakeArbitrationField.push_back( mSettings->Dominant() ); else mFakeArbitrationField.push_back( mSettings->Recessive() ); mask >>= 1; } //the next bit is RTR //RTR BIT (Standard Format as well as Extended Format) //Remote Transmission Request BIT //In DATA FRAMEs the RTR BIT has to be dominant. Within a REMOTE FRAME the //RTR BIT has to be recessive. if( remote_frame == true ) mFakeArbitrationField.push_back( mSettings->Recessive() ); //RTR bit else mFakeArbitrationField.push_back( mSettings->Dominant() ); //RTR bit //next is the control field. r1, r0, DLC3, DLC2, DLC1, DLC0 //CONTROL FIELD (Standard Format as well as Extended Format) //The CONTROL FIELD consists of six bits. The format of the CONTROL FIELD is //different for Standard Format and Extended Format. Frames in Standard Format //include the DATA LENGTH CODE, the IDE bit, which is transmitted dominant (see //above), and the reserved bit r0. Frames in the Extended Format include the DATA //LENGTH CODE and two reserved bits r1 and r0. The reserved bits have to be sent //dominant, but receivers accept dominant and recessive bits in all combinations. mFakeControlField.push_back( mSettings->Dominant() ); //IDE bit mFakeControlField.push_back( mSettings->Dominant() ); //r0 bit } //send 4 bits for the length of the attached data. U32 data_size = data.size(); if( data_size > 9 ) AnalyzerHelpers::Assert( "can't sent more than 8 bytes" ); if( remote_frame == true ) if( data_size != 0 ) AnalyzerHelpers::Assert( "remote frames can't send data" ); U32 mask = 1 << 3; for( U32 i=0; i<4; i++ ) { if( ( mask & data_size ) == 0 ) mFakeControlField.push_back( mSettings->Dominant() ); else mFakeControlField.push_back( mSettings->Recessive() ); mask >>= 1; } //next is the DATA FIELD //DATA FIELD (Standard Format as well as Extended Format) //The DATA FIELD consists of the data to be transferred within a DATA FRAME. It can //contain from 0 to 8 bytes, which each contain 8 bits which are transferred MSB first. if( remote_frame == false ) { for( U32 i=0; i<data_size; i++ ) { U32 dat = data[i]; U32 mask = 0x80; for( U32 j=0; j<8; j++ ) { if( ( mask & dat ) == 0 ) mFakeDataField.push_back( mSettings->Dominant() ); else mFakeDataField.push_back( mSettings->Recessive() ); mask >>= 1; } } } //CRC FIELD (Standard Format as well as Extended Format) //contains the CRC SEQUENCE followed by a CRC DELIMITER. AddCrc(); //ACK FIELD (Standard Format as well as Extended Format) //The ACK FIELD is two bits long and contains the ACK SLOT and the ACK DELIMITER. //In the ACK FIELD the transmitting station sends two recessive bits. //A RECEIVER which has received a valid message correctly, reports this to the //TRANSMITTER by sending a dominant bit during the ACK SLOT (it sends ACK). //ACK SLOT //All stations having received the matching CRC SEQUENCE report this within the ACK //SLOT by superscribing the recessive bit of the TRANSMITTER by a dominant bit. if( get_ack_in_response == true ) mFakeAckField.push_back( mSettings->Dominant() ); else mFakeAckField.push_back( mSettings->Recessive() ); //ACK DELIMITER //The ACK DELIMITER is the second bit of the ACK FIELD and has to be a recessive //bit. As a consequence, the ACK SLOT is surrounded by two recessive bits (CRC //DELIMITER, ACK DELIMITER). mFakeAckField.push_back( mSettings->Recessive() ); //END OF FRAME (Standard Format as well as Extended Format) //Each DATA FRAME and REMOTE FRAME is delimited by a flag sequence consisting //of seven recessive bits. for( U32 i=0; i<7; i++ ) mFakeEndOfFrame.push_back( mSettings->Recessive() ); mFakeFixedFormBits.insert( mFakeFixedFormBits.end(), mFakeAckField.begin(), mFakeAckField.end() ); mFakeFixedFormBits.insert( mFakeFixedFormBits.end(), mFakeEndOfFrame.begin(), mFakeEndOfFrame.end() ); } void CanSimulationDataGenerator::AddCrc() { mFakeStuffedBits.insert( mFakeStuffedBits.end(), mFakeStartOfFrameField.begin(), mFakeStartOfFrameField.end() ); mFakeStuffedBits.insert( mFakeStuffedBits.end(), mFakeArbitrationField.begin(), mFakeArbitrationField.end() ); mFakeStuffedBits.insert( mFakeStuffedBits.end(), mFakeControlField.begin(), mFakeControlField.end() ); mFakeStuffedBits.insert( mFakeStuffedBits.end(), mFakeDataField.begin(), mFakeDataField.end() ); U32 bits_for_crc = mFakeStuffedBits.size(); U16 crc = ComputeCrc( mFakeStuffedBits, bits_for_crc ); U32 mask = 0x4000; for( U32 i=0; i<15; i++ ) { if( ( mask & crc ) == 0 ) mFakeCrcFieldWithoutDelimiter.push_back( mSettings->Dominant() ); else mFakeCrcFieldWithoutDelimiter.push_back( mSettings->Recessive() ); mask >>= 1; } mFakeStuffedBits.insert( mFakeStuffedBits.end(), mFakeCrcFieldWithoutDelimiter.begin(), mFakeCrcFieldWithoutDelimiter.end() ); //CRC DELIMITER (Standard Format as well as Extended Format) //The CRC SEQUENCE is followed by the CRC DELIMITER which consists of a single //recessive bit. mFakeFixedFormBits.push_back( mSettings->Recessive() ); } U16 CanSimulationDataGenerator::ComputeCrc( std::vector<BitState>& bits, U32 num_bits ) { //note that this is a 15 bit CRC (not 16-bit) //CRC FIELD (Standard Format as well as Extended Format) //contains the CRC SEQUENCE followed by a CRC DELIMITER. //CRC SEQUENCE (Standard Format as well as Extended Format) //The frame check sequence is derived from a cyclic redundancy code best suited for ///frames with bit counts less than 127 bits (BCH Code). //In order to carry out the CRC calculation the polynomial to be divided is defined as the //polynomial, the coefficients of which are given by the destuffed bit stream consisting of //START OF FRAME, ARBITRATION FIELD, CONTROL FIELD, DATA FIELD (if ///present) and, for the 15 lowest coefficients, by 0. This polynomial is divided (the //coefficients are calculated modulo-2) by the generator-polynomial: //X15 + X14 + X10 + X8 + X7 + X4 + X3 + 1. //The remainder of this polynomial division is the CRC SEQUENCE transmitted over the //bus. In order to implement this function, a 15 bit shift register CRC_RG(14:0) can be //used. If NXTBIT denotes the next bit of the bit stream, given by the destuffed bit //sequence from START OF FRAME until the end of the DATA FIELD, the CRC //SEQUENCE is calculated as follows: //CRC_RG = 0; // initialize shift register //REPEAT //CRCNXT = NXTBIT EXOR CRC_RG(14); //CRC_RG(14:1) = CRC_RG(13:0); // shift left by //CRC_RG(0) = 0; // 1 position //IF CRCNXT THEN //CRC_RG(14:0) = CRC_RG(14:0) EXOR (4599hex); //ENDIF //UNTIL (CRC SEQUENCE starts or there is an ERROR condition) //After the transmission / reception of the last bit of the DATA FIELD, CRC_RG contains //the CRC sequence. U16 crc_result = 0; for( U32 i=0; i<num_bits; i++ ) { BitState next_bit = bits[i]; //Exclusive or if( ( crc_result & 0x4000 ) != 0 ) { next_bit = Invert( next_bit ); //if the msb of crc_result is zero, then next_bit is not inverted; otherwise, it is. } crc_result <<= 1; if( next_bit == mSettings->Recessive() ) //normally bit high. crc_result ^= 0x4599; } return crc_result & 0x7FFF; } void CanSimulationDataGenerator::WriteFrame( bool error ) { U32 recessive_count = 0; U32 dominant_count = 0; //The frame segments START OF FRAME, ARBITRATION FIELD, CONTROL FIELD, //DATA FIELD and CRC SEQUENCE are coded by the method of bit stuffing. Whenever //a transmitter detects five consecutive bits of identical value in the bit stream to be //transmitted it automatically inserts a complementary bit in the actual transmitted bit //stream. //The remaining bit fields of the DATA FRAME or REMOTE FRAME (CRC DELIMITER, //ACK FIELD, and END OF FRAME) are of fixed form and not stuffed. The ERROR //FRAME and the OVERLOAD FRAME are of fixed form as well and not coded by the //method of bit stuffing. U32 count = mFakeStuffedBits.size(); if( error == true ) count -= 9; for( U32 i=0; i<count; i++ ) { if( recessive_count == 5 ) { mCanSimulationData.Advance( mClockGenerator.AdvanceByHalfPeriod( 1.0 ) ); recessive_count = 0; dominant_count = 1; // this stuffed bit counts mCanSimulationData.Transition(); //to DOMINANT } if( dominant_count == 5 ) { mCanSimulationData.Advance( mClockGenerator.AdvanceByHalfPeriod( 1.0 ) ); dominant_count = 0; recessive_count = 1; // this stuffed bit counts mCanSimulationData.Transition(); //to RECESSIVE } BitState bit = mFakeStuffedBits[i]; if( bit == mSettings->Recessive() ) { recessive_count++; dominant_count = 0; }else { dominant_count++; recessive_count = 0; } mCanSimulationData.Advance( mClockGenerator.AdvanceByHalfPeriod( 1.0 ) ); mCanSimulationData.TransitionIfNeeded( bit ); } if( error == true ) { if( mCanSimulationData.GetCurrentBitState() != mSettings->Dominant() ) { mCanSimulationData.Advance( mClockGenerator.AdvanceByHalfPeriod( 1.0 ) ); mCanSimulationData.Transition(); //to DOMINANT } mCanSimulationData.Advance( mClockGenerator.AdvanceByHalfPeriod( 8.0 ) ); mCanSimulationData.Transition(); //to DOMINANT return; } count = mFakeFixedFormBits.size(); for( U32 i=0; i<count; i++ ) { mCanSimulationData.Advance( mClockGenerator.AdvanceByHalfPeriod( 1.0 ) ); mCanSimulationData.TransitionIfNeeded( mFakeFixedFormBits[i] ); } }
35.72837
175
0.707327
739ab177355eb1cb10a4e1ed9547d2da179af27c
2,853
cpp
C++
src/Editor/WorldEditor/WCreateTab.cpp
henriquegemignani/PrimeWorldEditor
741185e8d695c5bc86b7efbfadaf4e5dcd67d4d9
[ "MIT" ]
null
null
null
src/Editor/WorldEditor/WCreateTab.cpp
henriquegemignani/PrimeWorldEditor
741185e8d695c5bc86b7efbfadaf4e5dcd67d4d9
[ "MIT" ]
null
null
null
src/Editor/WorldEditor/WCreateTab.cpp
henriquegemignani/PrimeWorldEditor
741185e8d695c5bc86b7efbfadaf4e5dcd67d4d9
[ "MIT" ]
1
2020-02-21T15:22:56.000Z
2020-02-21T15:22:56.000Z
#include "WCreateTab.h" #include "ui_WCreateTab.h" #include "CTemplateMimeData.h" #include "CWorldEditor.h" #include "Editor/Undo/UndoCommands.h" #include <Core/Resource/Script/NGameList.h> WCreateTab::WCreateTab(CWorldEditor *pEditor, QWidget *pParent /*= 0*/) : QWidget(pParent) , ui(new Ui::WCreateTab) , mpSpawnLayer(nullptr) { ui->setupUi(this); mpEditor = pEditor; mpEditor->Viewport()->installEventFilter(this); connect(mpEditor, SIGNAL(LayersModified()), this, SLOT(OnLayersChanged())); connect(gpEdApp, SIGNAL(ActiveProjectChanged(CGameProject*)), this, SLOT(OnActiveProjectChanged(CGameProject*))); connect(ui->SpawnLayerComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(OnSpawnLayerChanged(int))); } WCreateTab::~WCreateTab() { delete ui; } bool WCreateTab::eventFilter(QObject *pObj, QEvent *pEvent) { if (pObj == mpEditor->Viewport()) { if (pEvent->type() == QEvent::DragEnter) { if (mpEditor->ActiveArea() != nullptr) { QDragEnterEvent *pDragEvent = static_cast<QDragEnterEvent*>(pEvent); if (qobject_cast<const CTemplateMimeData*>(pDragEvent->mimeData())) { pDragEvent->acceptProposedAction(); return true; } } } else if (pEvent->type() == QEvent::Drop) { QDropEvent *pDropEvent = static_cast<QDropEvent*>(pEvent); const CTemplateMimeData *pMimeData = qobject_cast<const CTemplateMimeData*>(pDropEvent->mimeData()); if (pMimeData) { CVector3f SpawnPoint = mpEditor->Viewport()->HoverPoint(); CCreateInstanceCommand *pCmd = new CCreateInstanceCommand(mpEditor, pMimeData->Template(), mpSpawnLayer, SpawnPoint); mpEditor->UndoStack().push(pCmd); return true; } } } return false; } // ************ PUBLIC SLOTS ************ void WCreateTab::OnActiveProjectChanged(CGameProject *pProj) { EGame Game = (pProj ? pProj->Game() : EGame::Invalid); CGameTemplate *pGame = NGameList::GetGameTemplate(Game); ui->TemplateView->SetGame(pGame); } void WCreateTab::OnLayersChanged() { CGameArea *pArea = mpEditor->ActiveArea(); ui->SpawnLayerComboBox->blockSignals(true); ui->SpawnLayerComboBox->clear(); for (uint32 iLyr = 0; iLyr < pArea->NumScriptLayers(); iLyr++) ui->SpawnLayerComboBox->addItem(TO_QSTRING(pArea->ScriptLayer(iLyr)->Name())); ui->SpawnLayerComboBox->setCurrentIndex(0); ui->SpawnLayerComboBox->blockSignals(false); OnSpawnLayerChanged(0); } void WCreateTab::OnSpawnLayerChanged(int LayerIndex) { CGameArea *pArea = mpEditor->ActiveArea(); mpSpawnLayer = pArea->ScriptLayer(LayerIndex); }
30.677419
133
0.637925