hexsha
stringlengths 40
40
| size
int64 7
1.05M
| ext
stringclasses 13
values | lang
stringclasses 1
value | max_stars_repo_path
stringlengths 4
269
| max_stars_repo_name
stringlengths 5
109
| max_stars_repo_head_hexsha
stringlengths 40
40
| max_stars_repo_licenses
sequencelengths 1
9
| max_stars_count
int64 1
191k
⌀ | max_stars_repo_stars_event_min_datetime
stringlengths 24
24
⌀ | max_stars_repo_stars_event_max_datetime
stringlengths 24
24
⌀ | max_issues_repo_path
stringlengths 4
269
| max_issues_repo_name
stringlengths 5
116
| max_issues_repo_head_hexsha
stringlengths 40
40
| max_issues_repo_licenses
sequencelengths 1
9
| max_issues_count
int64 1
48.5k
⌀ | max_issues_repo_issues_event_min_datetime
stringlengths 24
24
⌀ | max_issues_repo_issues_event_max_datetime
stringlengths 24
24
⌀ | max_forks_repo_path
stringlengths 4
269
| max_forks_repo_name
stringlengths 5
116
| max_forks_repo_head_hexsha
stringlengths 40
40
| max_forks_repo_licenses
sequencelengths 1
9
| max_forks_count
int64 1
105k
⌀ | max_forks_repo_forks_event_min_datetime
stringlengths 24
24
⌀ | max_forks_repo_forks_event_max_datetime
stringlengths 24
24
⌀ | content
stringlengths 7
1.05M
| avg_line_length
float64 1.21
330k
| max_line_length
int64 6
990k
| alphanum_fraction
float64 0.01
0.99
| author_id
stringlengths 2
40
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
73ccfd3cb0f80bde181a6d4f4ec41b917af71cc8 | 27,244 | cc | C++ | src/common/chemistry/tests_regression/batch_chem.cc | fmyuan/amanzi | edb7b815ae6c22956c8519acb9d87b92a9915ed4 | [
"RSA-MD"
] | 37 | 2017-04-26T16:27:07.000Z | 2022-03-01T07:38:57.000Z | src/common/chemistry/tests_regression/batch_chem.cc | fmyuan/amanzi | edb7b815ae6c22956c8519acb9d87b92a9915ed4 | [
"RSA-MD"
] | 494 | 2016-09-14T02:31:13.000Z | 2022-03-13T18:57:05.000Z | src/common/chemistry/tests_regression/batch_chem.cc | fmyuan/amanzi | edb7b815ae6c22956c8519acb9d87b92a9915ed4 | [
"RSA-MD"
] | 43 | 2016-09-26T17:58:40.000Z | 2022-03-25T02:29:59.000Z | #include <unistd.h>
//#define ABORT_ON_FLOATING_POINT_EXCEPTIONS
#ifdef __APPLE__
#include <xmmintrin.h>
#endif
#include <cstdlib>
#include <cctype>
#include <iostream>
#include <iomanip>
#include <fstream>
#include <vector>
#include <string>
#include <stdexcept>
// TPLs
#include "VerboseObject_objs.hh"
#include "VerboseObject.hh"
// Chemistry
#include "simple_thermo_database.hh"
#include "beaker.hh"
#include "activity_model_factory.hh"
#include "chemistry_utilities.hh"
#include "chemistry_exception.hh"
#include "string_tokenizer.hh"
#include "batch_chem.hh"
namespace ac = Amanzi::AmanziChemistry;
const std::string kCrunch("crunch");
const std::string kPflotran("pflotran");
/* TODO: might be worth switching over to reading the component values
into a map rather than a vector, then order of components in the
cfg file wouldn't matter, but we need to request an name-id map
from the beaker. */
int main(int argc, char** argv) {
#ifdef ABORT_ON_FLOATING_POINT_EXCEPTIONS
#ifdef __APPLE__
// Make floating point exceptions abort the program. runtime error
// message isn't helpful, but running in gdb will stop at the
// correct line. This may code may not be apple specific....
_MM_SET_EXCEPTION_MASK(_MM_GET_EXCEPTION_MASK() & ~_MM_MASK_INVALID);
_MM_SET_EXCEPTION_MASK(_MM_GET_EXCEPTION_MASK() & ~_MM_MASK_DENORM);
_MM_SET_EXCEPTION_MASK(_MM_GET_EXCEPTION_MASK() & ~_MM_MASK_DIV_ZERO);
_MM_SET_EXCEPTION_MASK(_MM_GET_EXCEPTION_MASK() & ~_MM_MASK_OVERFLOW);
_MM_SET_EXCEPTION_MASK(_MM_GET_EXCEPTION_MASK() & ~_MM_MASK_UNDERFLOW);
#endif
#endif
std::stringstream message;
bool debug_batch_driver(false);
std::string verbosity_name("");
std::string input_file_name("");
std::string template_file_name("");
int error = EXIT_SUCCESS;
// if verbosity was specified on the command line, add the level
Amanzi::VerboseObject::global_hide_line_prefix = false; // two default value
Amanzi::VerboseObject::global_default_level = Teuchos::VERB_MEDIUM;
Teuchos::ParameterList plist;
auto vo = Teuchos::rcp(new Amanzi::VerboseObject("Chemistry PK", plist));
error = CommandLineOptions(argc, argv,
&verbosity_name,
&input_file_name,
&template_file_name,
&debug_batch_driver,
vo);
if (!template_file_name.empty()) {
WriteTemplateFile(template_file_name, vo);
exit(EXIT_SUCCESS);
}
ac::Beaker::BeakerComponents components;
SimulationParameters simulation_params;
if (!input_file_name.empty()) {
ReadInputFile(input_file_name, &simulation_params, &components, vo);
}
if (components.total.size() == 0) {
message << "Must have a non-zero number of total component values.\n";
vo->WriteWarning(Teuchos::VERB_LOW, message);
abort();
}
if (debug_batch_driver) {
PrintInput(simulation_params, components, vo);
}
double time_units_conversion = 1.0;
char time_units = 's';
std::fstream text_output;
if (simulation_params.text_output.size() > 0) {
SetupTextOutput(simulation_params, input_file_name,
&text_output, &time_units, &time_units_conversion);
}
ac::Beaker* chem = NULL;
try {
if (simulation_params.database_file.size() != 0) {
chem = new ac::SimpleThermoDatabase(vo);
ac::Beaker::BeakerParameters parameters = chem->GetDefaultParameters();
parameters.thermo_database_file = simulation_params.database_file;
parameters.activity_model_name = simulation_params.activity_model;
parameters.max_iterations = simulation_params.max_iterations;
parameters.tolerance = simulation_params.tolerance;
parameters.porosity = simulation_params.porosity; // -
parameters.saturation = simulation_params.saturation; // -
parameters.volume = simulation_params.volume; // m^3
ModelSpecificParameters(simulation_params.comparison_model, ¶meters);
if (components.free_ion.size() != components.total.size()) {
components.free_ion.resize(components.total.size(), 1.0e-9);
}
chem->Setup(components, parameters);
if (vo->getVerbLevel() >= Teuchos::VERB_HIGH) {
chem->Display();
chem->DisplayComponents(components);
}
// solve for free-ion concentrations
chem->Speciate(&components, parameters);
chem->CopyBeakerToComponents(&components);
if (vo->getVerbLevel() >= Teuchos::VERB_EXTREME) {
chem->DisplayResults();
}
bool using_sorption = false;
if (components.total_sorbed.size() > 0) {
using_sorption = true;
}
if (simulation_params.num_time_steps != 0) {
message.str("");
message << "-- Test Beaker Reaction Stepping -------------------------------------" << std::endl;
vo->Write(Teuchos::VERB_HIGH, message.str());
// write out the headers info and initial conditions
chem->DisplayTotalColumnHeaders(simulation_params.display_free_columns);
chem->DisplayTotalColumns(0.0, components,
simulation_params.display_free_columns);
std::vector<std::string> names;
chem->GetPrimaryNames(&names);
WriteTextOutputHeader(&text_output, time_units, names, using_sorption);
WriteTextOutput(&text_output, 0.0, components);
// parameters.max_iterations = 2;
for (int time_step = 0; time_step < simulation_params.num_time_steps;
time_step++) {
chem->ReactionStep(&components, parameters, simulation_params.delta_time);
if ((time_step + 1) % simulation_params.output_interval == 0) {
double time = (time_step + 1) * simulation_params.delta_time;
chem->DisplayTotalColumns(time, components,
simulation_params.display_free_columns);
WriteTextOutput(&text_output, time * time_units_conversion, components);
}
if (vo->getVerbLevel() >= Teuchos::VERB_HIGH) {
message.str("");
ac::Beaker::SolverStatus status = chem->status();
message << "Timestep: " << time_step << std::endl;
message << " number of rhs evaluations: " << status.num_rhs_evaluations << std::endl;
message << " number of jacobian evaluations: " << status.num_jacobian_evaluations << std::endl;
message << " number of newton iterations: " << status.num_newton_iterations << std::endl;
message << " solution converged: " << status.converged << std::endl;
vo->Write(Teuchos::VERB_HIGH, message.str());
}
}
vo->Write(Teuchos::VERB_HIGH, "---- Final Speciation\n");
chem->Speciate(&components, parameters);
if (vo->getVerbLevel() >= Teuchos::VERB_EXTREME) {
chem->DisplayResults();
}
}
} else {
vo->Write(Teuchos::VERB_HIGH, "No database file specified in input file.\n");
}
} catch (const ac::ChemistryException& geochem_error) {
vo->WriteWarning(Teuchos::VERB_LOW, geochem_error.what());
error = EXIT_FAILURE;
} catch (const std::runtime_error& rt_error) {
vo->WriteWarning(Teuchos::VERB_LOW, rt_error.what());
error = EXIT_FAILURE;
} catch (const std::logic_error& lg_error) {
vo->WriteWarning(Teuchos::VERB_LOW, lg_error.what());
error = EXIT_FAILURE;
}
if (!error) {
vo->Write(Teuchos::VERB_HIGH, "Success!\n");
} else {
vo->Write(Teuchos::VERB_HIGH, "Failed!\n");
}
text_output.close();
// cleanup memory
delete chem;
return error;
} // end main()
void ModelSpecificParameters(const std::string model,
ac::Beaker::BeakerParameters* parameters) {
if (model == kCrunch) {
parameters->water_density = 997.075; // kg / m^3
} else if (model == kPflotran) {
parameters->water_density = 997.16; // kg / m^3
// where did this number come from?
// default parameters->water_density = 997.205133945901; // kg / m^3
} else {
// bad model name, how did we get here....
}
} // end ModelSpecificParameters()
/*******************************************************************************
**
** Commandline
**
*******************************************************************************/
int CommandLineOptions(int argc, char** argv,
std::string* verbosity_name,
std::string* input_file_name,
std::string* template_file_name,
bool* debug_batch_driver,
const Teuchos::RCP<Amanzi::VerboseObject>& vo)
{
int error = -2;
int option;
extern char* optarg;
while ((option = getopt(argc, argv, "di:ht:v:?")) != -1) {
switch (option) {
case 'd': {
*debug_batch_driver = true;
break;
}
case 'i': {
/* input file name */
input_file_name->assign(optarg);
error = EXIT_SUCCESS;
break;
}
case 't': {
/* template file name */
template_file_name->assign(optarg);
error = EXIT_SUCCESS;
break;
}
case 'v': {
verbosity_name->assign(optarg);
break;
}
case '?':
case 'h': { /* help mode */
/* print some help stuff and exit without doing anything */
std::cout << argv[0] << " command line options:" << std::endl;
std::cout << " -d" << std::endl;
std::cout << " debugging flag for batch driver" << std::endl;
std::cout << " -i string " << std::endl;
std::cout << " input file name" << std::endl;
std::cout << std::endl;
std::cout << " -t string" << std::endl;
std::cout << " write a template input file" << std::endl;
std::cout << std::endl;
std::cout << " -v string" << std::endl;
std::cout << " additional verbosity level:" << std::endl;
std::cout << " silent" << std::endl;
std::cout << " terse" << std::endl;
std::cout << " verbose" << std::endl;
std::cout << " debug" << std::endl;
std::cout << " debug_beaker" << std::endl;
std::cout << " debug_database" << std::endl;
std::cout << " debug_mineral_kinetics" << std::endl;
std::cout << " debug_ion_exchange" << std::endl;
std::cout << " debug_newton_solver" << std::endl;
error = -1;
break;
}
default: {
/* no options */
break;
}
}
}
if (!input_file_name->c_str() && !template_file_name->c_str()) {
std::cout << "An input or template file name must be specified." << std::endl;
std::cout << "Run \"" << argv[0] << " -h \" for help." << std::endl;
}
if (*debug_batch_driver) {
std::stringstream message;
message << "- Command Line Options -----------------------------------------------" << std::endl;
message << "\tdebug batch driver: " << *debug_batch_driver << std::endl;
message << "\tinput file name: " << *input_file_name << std::endl;
message << "\ttemplate file name: " << *template_file_name << std::endl;
message << "\tverbosity name: " << *verbosity_name << std::endl;
message << "----------------------------------------------- Command Line Options -" << std::endl;
message << std::endl << std::endl;
vo->Write(Teuchos::VERB_EXTREME, message.str());
}
return error;
} // end commandLineOptions()
/*******************************************************************************
**
** Input file parser
**
*******************************************************************************/
void ReadInputFile(const std::string& file_name,
SimulationParameters* simulation_params,
ac::Beaker::BeakerComponents* components,
const Teuchos::RCP<Amanzi::VerboseObject>& vo)
{
std::stringstream message;
std::ifstream input_file(file_name.c_str());
if (!input_file) {
message.str("");
message << "batch_chem: \n";
message << "input file \'" << file_name
<< "\' could not be opened." << std::endl;
vo->WriteWarning(Teuchos::VERB_LOW, message);
abort();
}
enum LineType {
kCommentLine,
kSection,
kParameter
} line_type;
enum SectionType {
kSectionSimulation,
kSectionTotal,
kSectionMineral,
kSectionSorbed,
kSectionFreeIon,
kSectionIonExchange,
kSectionSiteDensity,
kSectionSpecificSurfaceArea,
kSectionIsotherms
} current_section;
int count = 0;
const int max_lines = 500;
while (!input_file.eof() && count < max_lines) {
count++;
std::string raw_line;
getline(input_file, raw_line);
//std::cout << raw_line << std::endl;
if ((raw_line.size() > 0) && (raw_line.at(raw_line.size() - 1) == '\r')) {
// getline only searches for \n line ends. windows files use \r\n
// check for a hanging \r and remove it if it is there
raw_line.resize(raw_line.size() - 1);
}
char sym_first = '\0';
if (raw_line.length() > 0) sym_first = raw_line[0];
if (sym_first == '#' || sym_first == '\0') {
line_type = kCommentLine;
} else if (sym_first == '[') {
line_type = kSection;
} else {
line_type = kParameter;
}
if (line_type == kSection) {
size_t first = raw_line.find_first_not_of('[');
size_t last = raw_line.find_last_of(']');
last--;
std::string section_name = raw_line.substr(first, last);
if (section_name.compare(kSimulationSection) == 0) {
current_section = kSectionSimulation;
} else if (section_name.compare(kTotalSection) == 0) {
current_section = kSectionTotal;
} else if (section_name.compare(kMineralSection) == 0) {
current_section = kSectionMineral;
} else if (section_name.compare(kIonExchangeSection) == 0) {
current_section = kSectionIonExchange;
} else if (section_name.compare(kSorbedSection) == 0) {
current_section = kSectionSorbed;
} else if (section_name.compare(kFreeIonSection) == 0) {
current_section = kSectionFreeIon;
} else if (section_name.compare(kSiteDensitySection) == 0) {
current_section = kSectionSiteDensity;
} else if (section_name.compare(kSpecificSurfaceAreaSection) == 0) {
current_section = kSectionSpecificSurfaceArea;
} else if (section_name.compare(kIsothermSection) == 0) {
current_section = kSectionIsotherms;
} else {
message.str("");
message << "batch_chem::ReadInputFile(): ";
message << "unknown section found on line " << count << ":";
message << "\'" << raw_line << "\'"<< std::endl;
vo->Write(Teuchos::VERB_LOW, message.str());
}
} else if (line_type == kParameter) {
// assume parameter line, but it may be empty (just spaces or missing an = )...
if (current_section == kSectionSimulation) {
ParseSimulationParameter(raw_line, simulation_params);
} else if (current_section == kSectionTotal) {
ParseComponentValue(raw_line, &(components->total));
} else if (current_section == kSectionSorbed) {
ParseComponentValue(raw_line, &(components->total_sorbed));
} else if (current_section == kSectionFreeIon) {
ParseComponentValue(raw_line, &(components->free_ion));
} else if (current_section == kSectionMineral) {
ParseComponentValue(raw_line, &(components->mineral_volume_fraction));
} else if (current_section == kSectionSpecificSurfaceArea) {
ParseComponentValue(raw_line, &(components->mineral_specific_surface_area));
} else if (current_section == kSectionIonExchange) {
ParseComponentValue(raw_line, &(components->ion_exchange_sites));
} else if (current_section == kSectionSiteDensity) {
ParseComponentValue(raw_line, &(components->surface_site_density));
} else if (current_section == kSectionIsotherms) {
// TODO: need to figure out the format of this data...
}
}
}
input_file.close();
} // end ReadInputFile()
void ParseSimulationParameter(const std::string& raw_line,
SimulationParameters* params)
{
std::string equal("=:");
std::string spaces(" \t");
ac::StringTokenizer param(raw_line, equal);
//std::cout << "\'" << raw_line << "\'" << std::endl;
// if param.size() == 0 then we have a blank line
if (param.size() != 0) {
ac::StringTokenizer values(param.at(1), ",");
std::string value("");
if (values.size() == 1) {
value.assign(values.at(0));
ac::utilities::RemoveLeadingAndTrailingWhitespace(&value);
}
//std::cout << "Parsing -----> '" << param.at(0) << "'" << std::endl;
if (param.at(0).find(kDescriptionParam) != std::string::npos) {
// the description probably has spaces in it, so we want to use
// the raw parameter value from param.at(1) rather than the
// version in value, which has been tokenized by spaces!
params->description.assign(param.at(1));
} else if (param.at(0).find(kTextOutputParam) != std::string::npos) {
params->text_output.assign(value) ;
} else if (param.at(0).find(kTextTimeUnitsParam) != std::string::npos) {
params->text_time_units.assign(value) ;
} else if (param.at(0).find(kComparisonModelParam) != std::string::npos) {
params->comparison_model.assign(value);
} else if (param.at(0).find(kDatabaseTypeParam) != std::string::npos) {
params->database_type.assign(value);
} else if (param.at(0).find(kDatabaseFileParam) != std::string::npos) {
params->database_file.assign(value);
} else if (param.at(0).find(kActivityModelParam) != std::string::npos) {
params->activity_model.assign(value);
} else if (param.at(0).find(kPorosityParam) != std::string::npos) {
params->porosity = std::atof(value.c_str());
} else if (param.at(0).find(kSaturationParam) != std::string::npos) {
params->saturation = std::atof(value.c_str());
} else if (param.at(0).find(kVolumeParam) != std::string::npos) {
params->volume = std::atof(value.c_str());
} else if (param.at(0).find(kDeltaTimeParam) != std::string::npos) {
params->delta_time = std::atof(value.c_str());
} else if (param.at(0).find(kNumTimeStepsParam) != std::string::npos) {
params->num_time_steps = std::atoi(value.c_str());
} else if (param.at(0).find(kOutputIntervalParam) != std::string::npos) {
params->output_interval = std::atoi(value.c_str());
} else if (param.at(0).find(kToleranceParam) != std::string::npos) {
params->tolerance = std::atof(value.c_str());
} else if (param.at(0).find(kMaxIterationsParam) != std::string::npos) {
params->max_iterations = std::atoi(value.c_str());
}
}
} // end ParseSimulationParameter()
void ParseComponentValue(const std::string& raw_line,
std::vector<double>* component)
{
// for now we assume that the order of the component is the
// same as the order in the database file
std::string equal("=:");
std::string spaces(" \t");
ac::StringTokenizer param(raw_line, equal);
//std::cout << "\'" << raw_line << "\'" << std::endl;
// if param.size() == 0 then we have a blank line
if (param.size() != 0) {
ac::StringTokenizer param_value(param.at(1), spaces);
double value;
if (param_value.size() > 0) {
value = std::atof(param_value.at(0).c_str());
}
component->push_back(value);
}
} // end ParseComponentValue();
void ParseComponentValue(const std::string& raw_line,
double* component)
{
// this is intended for a single value, not a c-style array!
std::string equal("=:");
std::string spaces(" \t");
ac::StringTokenizer param(raw_line, equal);
//std::cout << "\'" << raw_line << "\'" << std::endl;
// if param.size() == 0 then we have a blank line
if (param.size() != 0) {
ac::StringTokenizer param_value(param.at(1), spaces);
double value = 0.;
if (param_value.size() > 0) {
value = std::atof(param_value.at(0).c_str());
}
*component = value;
}
} // end ParseComponentValue();
/*******************************************************************************
**
** Output related functions
**
*******************************************************************************/
void WriteTemplateFile(const std::string& file_name,
const Teuchos::RCP<Amanzi::VerboseObject>& vo)
{
std::ofstream template_file(file_name.c_str());
if (!template_file) {
std::stringstream message;
message << "batch_chem: \n";
message << "template file \'" << file_name
<< "\' could not be opened." << std::endl;
vo->WriteWarning(Teuchos::VERB_LOW, message);
abort();
}
template_file << "[" << kSimulationSection << "]" << std::endl;
template_file << kDescriptionParam << " = " << std::endl;
template_file << "# verbosity can be a comma seperated list." << std::endl;
template_file << kComparisonModelParam << " = pflotran" << std::endl;
template_file << kTextOutputParam << " = true" << std::endl;
template_file << kTextTimeUnitsParam << " = days" << std::endl;
template_file << std::endl;
template_file << kDatabaseTypeParam << " = simple" << std::endl;
template_file << kDatabaseFileParam << " = " << std::endl;
template_file << kActivityModelParam << " = debye-huckel" << std::endl;
template_file << kPorosityParam << " = " << std::endl;
template_file << kSaturationParam << " = " << std::endl;
template_file << kVolumeParam << " = " << std::endl;
template_file << kDeltaTimeParam << " = " << std::endl;
template_file << kNumTimeStepsParam << " = " << std::endl;
template_file << kOutputIntervalParam << " = " << std::endl;
template_file << std::endl;
template_file << "# all component values must be in the same order as the database file" << std::endl;
template_file << "[" << kTotalSection << "]" << std::endl;
template_file << std::endl;
template_file << "[" << kMineralSection << "]" << std::endl;
template_file << std::endl;
template_file << "[" << kSorbedSection << "]" << std::endl;
template_file << std::endl;
template_file << "[" << kFreeIonSection << "]" << std::endl;
template_file << std::endl;
template_file << "[" << kIonExchangeSection << "] # CEC" << std::endl;
template_file << std::endl;
template_file << "[" << kIsothermSection << "]" << std::endl;
template_file << std::endl;
template_file.close();
} // end WriteTemplateFile()
void SetupTextOutput(const SimulationParameters& simulation_params,
const std::string& input_file_name,
std::fstream* text_output, char* time_units,
double* time_units_conversion) {
// are we writting to observations to a text file?
if (simulation_params.text_output == "true" ||
simulation_params.text_output == "yes" ||
simulation_params.text_output == "on") {
// generate the output file name:
size_t position = input_file_name.find_last_of('.');
std::string text_output_name = input_file_name.substr(0, position) + ".txt";
text_output->open(text_output_name.c_str(), std::fstream::out);
// do we want to change the time units for the output?
if (simulation_params.text_time_units.size() > 0) {
*time_units = std::tolower(simulation_params.text_time_units.at(0));
switch (*time_units) {
case 's':
break;
case 'm':
*time_units_conversion = 60.0;
break;
case 'h':
*time_units_conversion = 60.0 * 60.0;
break;
case 'd':
*time_units_conversion = 60.0 * 60.0 * 24.0;
break;
case 'y':
*time_units_conversion = 60.0 * 60.0 * 24.0 * 365.25;
break;
default:
break;
}
}
*time_units_conversion = 1.0 / (*time_units_conversion);
}
}
void WriteTextOutputHeader(std::fstream* text_output, const char time_units,
const std::vector<std::string>& names,
const bool using_sorption) {
if (text_output->is_open()) {
*text_output << "# Time(" << time_units << ")";
for (std::vector<std::string>::const_iterator name = names.begin();
name != names.end(); ++name) {
*text_output << " , " << *name;
}
if (using_sorption) {
for (std::vector<std::string>::const_iterator name = names.begin();
name != names.end(); ++name) {
*text_output << " , " << *name << "_sorbed";
}
}
*text_output << std::endl;
}
}
void WriteTextOutput(std::fstream* text_output, const double time,
const Amanzi::AmanziChemistry::Beaker::BeakerComponents& components) {
if (text_output->is_open()) {
std::string seperator(" , ");
*text_output << std::scientific << std::setprecision(6) << std::setw(15) << time;
for (int i = 0; i < components.total.size(); ++i) {
*text_output << seperator << components.total.at(i);
}
for (int i = 0; i < components.total_sorbed.size(); ++i) {
*text_output << seperator << components.total_sorbed.at(i);
}
*text_output << std::endl;
}
}
void PrintInput(const SimulationParameters& params,
const Amanzi::AmanziChemistry::Beaker::BeakerComponents& components,
const Teuchos::RCP<Amanzi::VerboseObject>& vo)
{
vo->Write(Teuchos::VERB_HIGH, "- Input File ---------------------------------------------------------\n");
PrintSimulationParameters(params, vo);
components.Display("-- Input components: \n", vo);
vo->Write(Teuchos::VERB_HIGH, "--------------------------------------------------------- Input File -\n");
} // end PrintInput()
void PrintSimulationParameters(const SimulationParameters& params,
const Teuchos::RCP<Amanzi::VerboseObject>& vo)
{
std::stringstream message;
message << "-- Simulation parameters:" << std::endl;
message << "\tdescription: " << params.description << std::endl;
vo->Write(Teuchos::VERB_HIGH, message.str());
message.str("");
message << "\tcomparison model: " << params.comparison_model << std::endl;
message << "\tdatabase type: " << params.database_type << std::endl;
message << "\tdatabase file: " << params.database_file << std::endl;
message << "\tactivity model: " << params.activity_model << std::endl;
message << "\tporosity: " << params.porosity << std::endl;
message << "\tsaturation: " << params.saturation << std::endl;
message << "\tvolume: " << params.volume << std::endl;
message << "\tdelta time: " << params.delta_time << std::endl;
message << "\tnum time steps: " << params.num_time_steps << std::endl;
message << "\toutput interval: " << params.output_interval << std::endl;
message << "\tmax iterations: " << params.max_iterations << std::endl;
message << "\ttolerance: " << params.tolerance << std::endl;
vo->Write(Teuchos::VERB_HIGH, message.str());
}
| 39.143678 | 110 | 0.602812 | fmyuan |
73d091a7595a87265d1acfa7b9081aac2fc8a915 | 406 | hpp | C++ | src/point.hpp | harry830622/fixed-outline-floorplanning | 8fc1fc91f0e3329c6369c8b1f863bcce31465430 | [
"MIT"
] | 4 | 2019-07-02T18:15:01.000Z | 2021-12-22T06:09:35.000Z | src/point.hpp | harry830622/fixed-outline-floorplanning | 8fc1fc91f0e3329c6369c8b1f863bcce31465430 | [
"MIT"
] | null | null | null | src/point.hpp | harry830622/fixed-outline-floorplanning | 8fc1fc91f0e3329c6369c8b1f863bcce31465430 | [
"MIT"
] | 1 | 2016-12-07T15:13:07.000Z | 2016-12-07T15:13:07.000Z | #ifndef POINT_HPP
#define POINT_HPP
#include <iostream>
class Point {
public:
static double HPWL(const Point& point_a, const Point& point_b);
static Point Center(const Point& point_a, const Point& point_b);
Point(double x, double y);
void Print(std::ostream& os = std::cout, int indent_level = 0) const;
double x() const;
double y() const;
private:
double x_;
double y_;
};
#endif
| 16.916667 | 71 | 0.694581 | harry830622 |
73d158187bc010e9aec65b6a81de99539d4e7b90 | 16,317 | cc | C++ | generator/integration_tests/golden/tests/golden_thing_admin_auth_decorator_test.cc | bryanlaura736/google-cloud-cpp | c0179a2209a4b11f8db1b1b474c1c8bdb2f1df86 | [
"Apache-2.0"
] | null | null | null | generator/integration_tests/golden/tests/golden_thing_admin_auth_decorator_test.cc | bryanlaura736/google-cloud-cpp | c0179a2209a4b11f8db1b1b474c1c8bdb2f1df86 | [
"Apache-2.0"
] | null | null | null | generator/integration_tests/golden/tests/golden_thing_admin_auth_decorator_test.cc | bryanlaura736/google-cloud-cpp | c0179a2209a4b11f8db1b1b474c1c8bdb2f1df86 | [
"Apache-2.0"
] | null | null | null | // Copyright 2021 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include "generator/integration_tests/golden/internal/golden_thing_admin_auth_decorator.h"
#include "google/cloud/testing_util/mock_grpc_authentication_strategy.h"
#include "google/cloud/testing_util/status_matchers.h"
#include "generator/integration_tests/golden/mocks/mock_golden_thing_admin_stub.h"
#include <gmock/gmock.h>
#include <memory>
namespace google {
namespace cloud {
namespace golden_internal {
GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN
namespace {
using ::google::cloud::testing_util::MakeTypicalAsyncMockAuth;
using ::google::cloud::testing_util::MakeTypicalMockAuth;
using ::google::cloud::testing_util::StatusIs;
using ::testing::ByMove;
using ::testing::IsNull;
using ::testing::Return;
using ::testing::Unused;
future<StatusOr<google::longrunning::Operation>> LongrunningError(Unused,
Unused,
Unused) {
return make_ready_future(StatusOr<google::longrunning::Operation>(
Status(StatusCode::kPermissionDenied, "uh-oh")));
}
// The general pattern of these test is to make two requests, both of which
// return an error. The first one because the auth strategy fails, the second
// because the operation in the mock stub fails.
TEST(GoldenThingAdminAuthDecoratorTest, ListDatabases) {
auto mock = std::make_shared<MockGoldenThingAdminStub>();
EXPECT_CALL(*mock, ListDatabases)
.WillOnce(Return(Status(StatusCode::kPermissionDenied, "uh-oh")));
auto under_test = GoldenThingAdminAuth(MakeTypicalMockAuth(), mock);
google::test::admin::database::v1::ListDatabasesRequest request;
grpc::ClientContext ctx;
auto auth_failure = under_test.ListDatabases(ctx, request);
EXPECT_THAT(ctx.credentials(), IsNull());
EXPECT_THAT(auth_failure, StatusIs(StatusCode::kInvalidArgument));
auto auth_success = under_test.ListDatabases(ctx, request);
EXPECT_THAT(ctx.credentials(), Not(IsNull()));
EXPECT_THAT(auth_success, StatusIs(StatusCode::kPermissionDenied));
}
TEST(GoldenThingAdminAuthDecoratorTest, AsyncCreateDatabase) {
auto mock = std::make_shared<MockGoldenThingAdminStub>();
EXPECT_CALL(*mock, AsyncCreateDatabase).WillOnce(LongrunningError);
auto under_test = GoldenThingAdminAuth(MakeTypicalAsyncMockAuth(), mock);
google::test::admin::database::v1::CreateDatabaseRequest request;
CompletionQueue cq;
auto auth_failure = under_test.AsyncCreateDatabase(
cq, absl::make_unique<grpc::ClientContext>(), request);
EXPECT_THAT(auth_failure.get(), StatusIs(StatusCode::kInvalidArgument));
auto auth_success = under_test.AsyncCreateDatabase(
cq, absl::make_unique<grpc::ClientContext>(), request);
EXPECT_THAT(auth_success.get(), StatusIs(StatusCode::kPermissionDenied));
}
TEST(GoldenThingAdminAuthDecoratorTest, GetDatabase) {
auto mock = std::make_shared<MockGoldenThingAdminStub>();
EXPECT_CALL(*mock, GetDatabase)
.WillOnce(Return(Status(StatusCode::kPermissionDenied, "uh-oh")));
auto under_test = GoldenThingAdminAuth(MakeTypicalMockAuth(), mock);
google::test::admin::database::v1::GetDatabaseRequest request;
grpc::ClientContext ctx;
auto auth_failure = under_test.GetDatabase(ctx, request);
EXPECT_THAT(ctx.credentials(), IsNull());
EXPECT_THAT(auth_failure, StatusIs(StatusCode::kInvalidArgument));
auto auth_success = under_test.GetDatabase(ctx, request);
EXPECT_THAT(ctx.credentials(), Not(IsNull()));
EXPECT_THAT(auth_success, StatusIs(StatusCode::kPermissionDenied));
}
TEST(GoldenThingAdminAuthDecoratorTest, AsyncUpdateDatabaseDdl) {
auto mock = std::make_shared<MockGoldenThingAdminStub>();
EXPECT_CALL(*mock, AsyncUpdateDatabaseDdl).WillOnce(LongrunningError);
auto under_test = GoldenThingAdminAuth(MakeTypicalAsyncMockAuth(), mock);
google::test::admin::database::v1::UpdateDatabaseDdlRequest request;
CompletionQueue cq;
auto auth_failure = under_test.AsyncUpdateDatabaseDdl(
cq, absl::make_unique<grpc::ClientContext>(), request);
EXPECT_THAT(auth_failure.get(), StatusIs(StatusCode::kInvalidArgument));
auto auth_success = under_test.AsyncUpdateDatabaseDdl(
cq, absl::make_unique<grpc::ClientContext>(), request);
EXPECT_THAT(auth_success.get(), StatusIs(StatusCode::kPermissionDenied));
}
TEST(GoldenThingAdminAuthDecoratorTest, DropDatabase) {
auto mock = std::make_shared<MockGoldenThingAdminStub>();
EXPECT_CALL(*mock, DropDatabase)
.WillOnce(Return(Status(StatusCode::kPermissionDenied, "uh-oh")));
auto under_test = GoldenThingAdminAuth(MakeTypicalMockAuth(), mock);
google::test::admin::database::v1::DropDatabaseRequest request;
grpc::ClientContext ctx;
auto auth_failure = under_test.DropDatabase(ctx, request);
EXPECT_THAT(ctx.credentials(), IsNull());
EXPECT_THAT(auth_failure, StatusIs(StatusCode::kInvalidArgument));
auto auth_success = under_test.DropDatabase(ctx, request);
EXPECT_THAT(ctx.credentials(), Not(IsNull()));
EXPECT_THAT(auth_success, StatusIs(StatusCode::kPermissionDenied));
}
TEST(GoldenThingAdminAuthDecoratorTest, GetDatabaseDdl) {
auto mock = std::make_shared<MockGoldenThingAdminStub>();
EXPECT_CALL(*mock, GetDatabaseDdl)
.WillOnce(Return(Status(StatusCode::kPermissionDenied, "uh-oh")));
auto under_test = GoldenThingAdminAuth(MakeTypicalMockAuth(), mock);
google::test::admin::database::v1::GetDatabaseDdlRequest request;
grpc::ClientContext ctx;
auto auth_failure = under_test.GetDatabaseDdl(ctx, request);
EXPECT_THAT(ctx.credentials(), IsNull());
EXPECT_THAT(auth_failure, StatusIs(StatusCode::kInvalidArgument));
auto auth_success = under_test.GetDatabaseDdl(ctx, request);
EXPECT_THAT(ctx.credentials(), Not(IsNull()));
EXPECT_THAT(auth_success, StatusIs(StatusCode::kPermissionDenied));
}
TEST(GoldenThingAdminAuthDecoratorTest, SetIamPolicy) {
auto mock = std::make_shared<MockGoldenThingAdminStub>();
EXPECT_CALL(*mock, SetIamPolicy)
.WillOnce(Return(Status(StatusCode::kPermissionDenied, "uh-oh")));
auto under_test = GoldenThingAdminAuth(MakeTypicalMockAuth(), mock);
google::iam::v1::SetIamPolicyRequest request;
grpc::ClientContext ctx;
auto auth_failure = under_test.SetIamPolicy(ctx, request);
EXPECT_THAT(ctx.credentials(), IsNull());
EXPECT_THAT(auth_failure, StatusIs(StatusCode::kInvalidArgument));
auto auth_success = under_test.SetIamPolicy(ctx, request);
EXPECT_THAT(ctx.credentials(), Not(IsNull()));
EXPECT_THAT(auth_success, StatusIs(StatusCode::kPermissionDenied));
}
TEST(GoldenThingAdminAuthDecoratorTest, GetIamPolicy) {
auto mock = std::make_shared<MockGoldenThingAdminStub>();
EXPECT_CALL(*mock, GetIamPolicy)
.WillOnce(Return(Status(StatusCode::kPermissionDenied, "uh-oh")));
auto under_test = GoldenThingAdminAuth(MakeTypicalMockAuth(), mock);
google::iam::v1::GetIamPolicyRequest request;
grpc::ClientContext ctx;
auto auth_failure = under_test.GetIamPolicy(ctx, request);
EXPECT_THAT(ctx.credentials(), IsNull());
EXPECT_THAT(auth_failure, StatusIs(StatusCode::kInvalidArgument));
auto auth_success = under_test.GetIamPolicy(ctx, request);
EXPECT_THAT(ctx.credentials(), Not(IsNull()));
EXPECT_THAT(auth_success, StatusIs(StatusCode::kPermissionDenied));
}
TEST(GoldenThingAdminAuthDecoratorTest, TestIamPermissions) {
auto mock = std::make_shared<MockGoldenThingAdminStub>();
EXPECT_CALL(*mock, TestIamPermissions)
.WillOnce(Return(Status(StatusCode::kPermissionDenied, "uh-oh")));
auto under_test = GoldenThingAdminAuth(MakeTypicalMockAuth(), mock);
google::iam::v1::TestIamPermissionsRequest request;
grpc::ClientContext ctx;
auto auth_failure = under_test.TestIamPermissions(ctx, request);
EXPECT_THAT(ctx.credentials(), IsNull());
EXPECT_THAT(auth_failure, StatusIs(StatusCode::kInvalidArgument));
auto auth_success = under_test.TestIamPermissions(ctx, request);
EXPECT_THAT(ctx.credentials(), Not(IsNull()));
EXPECT_THAT(auth_success, StatusIs(StatusCode::kPermissionDenied));
}
TEST(GoldenThingAdminAuthDecoratorTest, AsyncCreateBackup) {
auto mock = std::make_shared<MockGoldenThingAdminStub>();
EXPECT_CALL(*mock, AsyncCreateBackup).WillOnce(LongrunningError);
auto under_test = GoldenThingAdminAuth(MakeTypicalAsyncMockAuth(), mock);
google::test::admin::database::v1::CreateBackupRequest request;
CompletionQueue cq;
auto auth_failure = under_test.AsyncCreateBackup(
cq, absl::make_unique<grpc::ClientContext>(), request);
EXPECT_THAT(auth_failure.get(), StatusIs(StatusCode::kInvalidArgument));
auto auth_success = under_test.AsyncCreateBackup(
cq, absl::make_unique<grpc::ClientContext>(), request);
EXPECT_THAT(auth_success.get(), StatusIs(StatusCode::kPermissionDenied));
}
TEST(GoldenThingAdminAuthDecoratorTest, GetBackup) {
auto mock = std::make_shared<MockGoldenThingAdminStub>();
EXPECT_CALL(*mock, GetBackup)
.WillOnce(Return(Status(StatusCode::kPermissionDenied, "uh-oh")));
auto under_test = GoldenThingAdminAuth(MakeTypicalMockAuth(), mock);
google::test::admin::database::v1::GetBackupRequest request;
grpc::ClientContext ctx;
auto auth_failure = under_test.GetBackup(ctx, request);
EXPECT_THAT(ctx.credentials(), IsNull());
EXPECT_THAT(auth_failure, StatusIs(StatusCode::kInvalidArgument));
auto auth_success = under_test.GetBackup(ctx, request);
EXPECT_THAT(ctx.credentials(), Not(IsNull()));
EXPECT_THAT(auth_success, StatusIs(StatusCode::kPermissionDenied));
}
TEST(GoldenThingAdminAuthDecoratorTest, UpdateBackup) {
auto mock = std::make_shared<MockGoldenThingAdminStub>();
EXPECT_CALL(*mock, UpdateBackup)
.WillOnce(Return(Status(StatusCode::kPermissionDenied, "uh-oh")));
auto under_test = GoldenThingAdminAuth(MakeTypicalMockAuth(), mock);
google::test::admin::database::v1::UpdateBackupRequest request;
grpc::ClientContext ctx;
auto auth_failure = under_test.UpdateBackup(ctx, request);
EXPECT_THAT(ctx.credentials(), IsNull());
EXPECT_THAT(auth_failure, StatusIs(StatusCode::kInvalidArgument));
auto auth_success = under_test.UpdateBackup(ctx, request);
EXPECT_THAT(ctx.credentials(), Not(IsNull()));
EXPECT_THAT(auth_success, StatusIs(StatusCode::kPermissionDenied));
}
TEST(GoldenThingAdminAuthDecoratorTest, DeleteBackup) {
auto mock = std::make_shared<MockGoldenThingAdminStub>();
EXPECT_CALL(*mock, DeleteBackup)
.WillOnce(Return(Status(StatusCode::kPermissionDenied, "uh-oh")));
auto under_test = GoldenThingAdminAuth(MakeTypicalMockAuth(), mock);
google::test::admin::database::v1::DeleteBackupRequest request;
grpc::ClientContext ctx;
auto auth_failure = under_test.DeleteBackup(ctx, request);
EXPECT_THAT(ctx.credentials(), IsNull());
EXPECT_THAT(auth_failure, StatusIs(StatusCode::kInvalidArgument));
auto auth_success = under_test.DeleteBackup(ctx, request);
EXPECT_THAT(ctx.credentials(), Not(IsNull()));
EXPECT_THAT(auth_success, StatusIs(StatusCode::kPermissionDenied));
}
TEST(GoldenThingAdminAuthDecoratorTest, ListBackups) {
auto mock = std::make_shared<MockGoldenThingAdminStub>();
EXPECT_CALL(*mock, ListBackups)
.WillOnce(Return(Status(StatusCode::kPermissionDenied, "uh-oh")));
auto under_test = GoldenThingAdminAuth(MakeTypicalMockAuth(), mock);
google::test::admin::database::v1::ListBackupsRequest request;
grpc::ClientContext ctx;
auto auth_failure = under_test.ListBackups(ctx, request);
EXPECT_THAT(ctx.credentials(), IsNull());
EXPECT_THAT(auth_failure, StatusIs(StatusCode::kInvalidArgument));
auto auth_success = under_test.ListBackups(ctx, request);
EXPECT_THAT(ctx.credentials(), Not(IsNull()));
EXPECT_THAT(auth_success, StatusIs(StatusCode::kPermissionDenied));
}
TEST(GoldenThingAdminAuthDecoratorTest, AsyncRestoreDatabase) {
auto mock = std::make_shared<MockGoldenThingAdminStub>();
EXPECT_CALL(*mock, AsyncRestoreDatabase).WillOnce(LongrunningError);
auto under_test = GoldenThingAdminAuth(MakeTypicalAsyncMockAuth(), mock);
google::test::admin::database::v1::RestoreDatabaseRequest request;
CompletionQueue cq;
auto auth_failure = under_test.AsyncRestoreDatabase(
cq, absl::make_unique<grpc::ClientContext>(), request);
EXPECT_THAT(auth_failure.get(), StatusIs(StatusCode::kInvalidArgument));
auto auth_success = under_test.AsyncRestoreDatabase(
cq, absl::make_unique<grpc::ClientContext>(), request);
EXPECT_THAT(auth_success.get(), StatusIs(StatusCode::kPermissionDenied));
}
TEST(GoldenThingAdminAuthDecoratorTest, ListDatabaseOperations) {
auto mock = std::make_shared<MockGoldenThingAdminStub>();
EXPECT_CALL(*mock, ListDatabaseOperations)
.WillOnce(Return(Status(StatusCode::kPermissionDenied, "uh-oh")));
auto under_test = GoldenThingAdminAuth(MakeTypicalMockAuth(), mock);
google::test::admin::database::v1::ListDatabaseOperationsRequest request;
grpc::ClientContext ctx;
auto auth_failure = under_test.ListDatabaseOperations(ctx, request);
EXPECT_THAT(ctx.credentials(), IsNull());
EXPECT_THAT(auth_failure, StatusIs(StatusCode::kInvalidArgument));
auto auth_success = under_test.ListDatabaseOperations(ctx, request);
EXPECT_THAT(ctx.credentials(), Not(IsNull()));
EXPECT_THAT(auth_success, StatusIs(StatusCode::kPermissionDenied));
}
TEST(GoldenThingAdminAuthDecoratorTest, ListBackupOperations) {
auto mock = std::make_shared<MockGoldenThingAdminStub>();
EXPECT_CALL(*mock, ListBackupOperations)
.WillOnce(Return(Status(StatusCode::kPermissionDenied, "uh-oh")));
auto under_test = GoldenThingAdminAuth(MakeTypicalMockAuth(), mock);
google::test::admin::database::v1::ListBackupOperationsRequest request;
grpc::ClientContext ctx;
auto auth_failure = under_test.ListBackupOperations(ctx, request);
EXPECT_THAT(ctx.credentials(), IsNull());
EXPECT_THAT(auth_failure, StatusIs(StatusCode::kInvalidArgument));
auto auth_success = under_test.ListBackupOperations(ctx, request);
EXPECT_THAT(ctx.credentials(), Not(IsNull()));
EXPECT_THAT(auth_success, StatusIs(StatusCode::kPermissionDenied));
}
TEST(GoldenThingAdminAuthDecoratorTest, AsyncGetOperation) {
auto mock = std::make_shared<MockGoldenThingAdminStub>();
EXPECT_CALL(*mock, AsyncGetOperation).WillOnce(LongrunningError);
auto under_test = GoldenThingAdminAuth(MakeTypicalAsyncMockAuth(), mock);
google::longrunning::GetOperationRequest request;
CompletionQueue cq;
auto auth_failure = under_test.AsyncGetOperation(
cq, absl::make_unique<grpc::ClientContext>(), request);
EXPECT_THAT(auth_failure.get(), StatusIs(StatusCode::kInvalidArgument));
auto auth_success = under_test.AsyncGetOperation(
cq, absl::make_unique<grpc::ClientContext>(), request);
EXPECT_THAT(auth_success.get(), StatusIs(StatusCode::kPermissionDenied));
}
TEST(GoldenThingAdminAuthDecoratorTest, AsyncCancelOperation) {
auto mock = std::make_shared<MockGoldenThingAdminStub>();
EXPECT_CALL(*mock, AsyncCancelOperation)
.WillOnce(Return(ByMove(
make_ready_future(Status{StatusCode::kPermissionDenied, "uh-oh"}))));
auto under_test = GoldenThingAdminAuth(MakeTypicalAsyncMockAuth(), mock);
google::longrunning::CancelOperationRequest request;
CompletionQueue cq;
auto auth_failure = under_test.AsyncCancelOperation(
cq, absl::make_unique<grpc::ClientContext>(), request);
EXPECT_THAT(auth_failure.get(), StatusIs(StatusCode::kInvalidArgument));
auto auth_success = under_test.AsyncCancelOperation(
cq, absl::make_unique<grpc::ClientContext>(), request);
EXPECT_THAT(auth_success.get(), StatusIs(StatusCode::kPermissionDenied));
}
} // namespace
GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END
} // namespace golden_internal
} // namespace cloud
} // namespace google
| 43.981132 | 90 | 0.771036 | bryanlaura736 |
73d2718c9ae9549a1baabb2f2bd5d5452ea611d0 | 5,384 | cpp | C++ | common/fileview2/fvquerysource.cpp | miguelvazq/HPCC-Platform | 22ad8e5fcb59626abfd8febecbdfccb1e9fb0aa5 | [
"Apache-2.0"
] | null | null | null | common/fileview2/fvquerysource.cpp | miguelvazq/HPCC-Platform | 22ad8e5fcb59626abfd8febecbdfccb1e9fb0aa5 | [
"Apache-2.0"
] | 1 | 2018-03-01T18:15:12.000Z | 2018-03-01T18:15:12.000Z | common/fileview2/fvquerysource.cpp | miguelvazq/HPCC-Platform | 22ad8e5fcb59626abfd8febecbdfccb1e9fb0aa5 | [
"Apache-2.0"
] | 3 | 2021-05-02T17:01:57.000Z | 2021-05-02T17:02:28.000Z | /*##############################################################################
HPCC SYSTEMS software Copyright (C) 2012 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 "jliball.hpp"
#include "eclrtl.hpp"
#include "hqlexpr.hpp"
#include "hqlthql.hpp"
#include "fvresultset.ipp"
#include "fileview.hpp"
#include "fvquerysource.ipp"
#include "fvwugen.hpp"
QueryDataSource::QueryDataSource(IConstWUResult * _wuResult, const char * _wuid, const char * _username, const char * _password)
{
wuResult.set(_wuResult);
wuid.set(_wuid);
username.set(_username);
password.set(_password);
}
QueryDataSource::~QueryDataSource()
{
if (browseWuid)
{
Owned<IWorkUnitFactory> factory = getWorkUnitFactory();
factory->deleteWorkUnit(browseWuid);
}
}
bool QueryDataSource::createBrowseWU()
{
StringAttr dataset, datasetDefs;
StringAttrAdaptor a1(dataset), a2(datasetDefs);
wuResult->getResultDataset(a1, a2);
if (!dataset || !datasetDefs)
return false;
StringBuffer fullText;
fullText.append(datasetDefs).append(dataset);
OwnedHqlExpr parsed = parseQuery(fullText.str());
if (!parsed)
return false;
HqlExprAttr selectFields = parsed.getLink();
if (selectFields->getOperator() == no_output)
selectFields.set(selectFields->queryChild(0));
OwnedHqlExpr browseWUcode = buildQueryViewerEcl(selectFields);
if (!browseWUcode)
return false;
returnedRecord.set(browseWUcode->queryChild(0)->queryRecord());
Owned<IWorkUnitFactory> factory = getWorkUnitFactory();
Owned<IConstWorkUnit> parent = factory->openWorkUnit(wuid);
const char *user = parent->queryUser();
Owned<IWorkUnit> workunit = factory->createWorkUnit("fileViewer", user);
workunit->setUser(user);
workunit->setClusterName(parent->queryClusterName());
browseWuid.set(workunit->queryWuid());
workunit->setDebugValueInt("importImplicitModules", false, true);
workunit->setDebugValueInt("importAllModules", false, true);
workunit->setDebugValueInt("forceFakeThor", 1, true);
StringBuffer jobName;
jobName.append("FileView for ").append(wuid).append(":").append("x");
workunit->setJobName(jobName.str());
StringBuffer eclText;
toECL(browseWUcode, eclText, true);
Owned<IWUQuery> query = workunit->updateQuery();
query->setQueryText(eclText.str());
query->setQueryName(jobName.str());
return true;
}
bool QueryDataSource::init()
{
return createBrowseWU();
}
void QueryDataSource::improveLocation(__int64 row, RowLocation & location)
{
#if 0
if (!diskMeta->isFixedSize())
return;
if (location.bestRow <= row && location.bestRow + DISKREAD_PAGE_SIZE > row)
return;
assertex(row >= 0);
//Align the row so the chunks don't overlap....
location.bestRow = (row / DISKREAD_PAGE_SIZE) * DISKREAD_PAGE_SIZE;
location.bestOffset = location.bestRow * diskMeta->fixedSize();
#endif
}
bool QueryDataSource::loadBlock(__int64 startRow, offset_t startOffset)
{
MemoryBuffer temp;
//enter scope....>
{
Owned<IWorkUnitFactory> factory = getWorkUnitFactory();
Owned<IWorkUnit> wu = factory->updateWorkUnit(browseWuid);
Owned<IWUResult> lower = wu->updateVariableByName(LOWER_LIMIT_ID);
lower->setResultInt(startOffset);
lower->setResultStatus(ResultStatusSupplied);
Owned<IWUResult> dataResult = wu->updateResultBySequence(0);
dataResult->setResultRaw(0, NULL, ResultFormatRaw);
dataResult->setResultStatus(ResultStatusUndefined);
wu->clearExceptions();
if (wu->getState() != WUStateUnknown)
wu->setState(WUStateCompiled);
//Owned<IWUResult> count = wu->updateVariableByName(RECORD_LIMIT_ID);
//count->setResultInt64(fetchSize);
}
//Resubmit the query...
submitWorkUnit(browseWuid, username, password);
WUState finalState = waitForWorkUnitToComplete(browseWuid, -1, true);
if(!((finalState == WUStateCompleted) || (finalState == WUStateWait)))
return false;
//Now extract the results...
Owned<IWorkUnitFactory> factory = getWorkUnitFactory();
Owned<IConstWorkUnit> wu = factory->openWorkUnit(browseWuid);
Owned<IConstWUResult> dataResult = wu->getResultBySequence(0);
MemoryBuffer2IDataVal xxx(temp); dataResult->getResultRaw(xxx, NULL, NULL);
if (temp.length() == 0)
return false;
RowBlock * rows;
if (returnedMeta->isFixedSize())
rows = new FilePosFixedRowBlock(temp, startRow, startOffset, returnedMeta->fixedSize());
else
rows = new FilePosVariableRowBlock(temp, startRow, startOffset, returnedMeta, true);
cache.addRowsOwn(rows);
return true;
}
| 31.670588 | 128 | 0.678492 | miguelvazq |
73d80f96d5421a87f7fe89992e14e228f26355b3 | 15,621 | cpp | C++ | _studio/shared/umc/codec/vc1_dec/src/umc_vc1_video_decoder_hw.cpp | chuanli1/oneVPL-intel-gpu | 9d337b4add45f861f0307dc75fa1e50786b73462 | [
"MIT"
] | null | null | null | _studio/shared/umc/codec/vc1_dec/src/umc_vc1_video_decoder_hw.cpp | chuanli1/oneVPL-intel-gpu | 9d337b4add45f861f0307dc75fa1e50786b73462 | [
"MIT"
] | null | null | null | _studio/shared/umc/codec/vc1_dec/src/umc_vc1_video_decoder_hw.cpp | chuanli1/oneVPL-intel-gpu | 9d337b4add45f861f0307dc75fa1e50786b73462 | [
"MIT"
] | null | null | null | // Copyright (c) 2004-2019 Intel Corporation
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
#include "umc_defs.h"
#if defined (MFX_ENABLE_VC1_VIDEO_DECODE)
#include "umc_vc1_video_decoder_hw.h"
#include "umc_video_data.h"
#include "umc_media_data_ex.h"
#include "umc_vc1_dec_debug.h"
#include "umc_vc1_dec_seq.h"
#include "vm_sys_info.h"
#include "umc_vc1_dec_task_store.h"
#include "umc_memory_allocator.h"
#include "umc_vc1_common.h"
#include "umc_vc1_common_defs.h"
#include "umc_vc1_dec_exception.h"
#include "umc_va_base.h"
#include "umc_vc1_dec_frame_descr_va.h"
using namespace UMC;
using namespace UMC::VC1Common;
using namespace UMC::VC1Exceptions;
VC1VideoDecoderHW::VC1VideoDecoderHW():
m_stCodes_VA(NULL)
{
}
VC1VideoDecoderHW::~VC1VideoDecoderHW()
{
Close();
}
Status VC1VideoDecoderHW::Init(BaseCodecParams *pInit)
{
VideoDecoderParams *init = DynamicCast<VideoDecoderParams, BaseCodecParams>(pInit);
if (!init)
return UMC_ERR_INIT;
if (init->pVideoAccelerator)
{
if ((init->pVideoAccelerator->m_Profile & VA_CODEC) == VA_VC1)
m_va = init->pVideoAccelerator;
else
return UMC_ERR_UNSUPPORTED;
}
Status umcRes = UMC_OK;
umcRes = VC1VideoDecoder::Init(pInit);
if (umcRes != UMC_OK)
return umcRes;
try
// memory allocation and Init all env for frames/tasks store - VC1TaskStore object
{
m_pStore = new(m_pHeap->s_alloc<VC1TaskStore>()) VC1TaskStore(m_pMemoryAllocator);
if (!m_pStore->Init(m_iThreadDecoderNum,
m_iMaxFramesInProcessing,
this) )
return UMC_ERR_ALLOC;
m_pStore->CreateDSQueue(m_pContext,m_va);
}
catch(...)
{
// only allocation errors here
Close();
return UMC_ERR_ALLOC;
}
return umcRes;
}
Status VC1VideoDecoderHW::Reset(void)
{
Status umcRes = VC1VideoDecoder::Reset();
if (umcRes != UMC_OK)
return umcRes;
if (m_pStore)
{
if (!m_pStore->Reset())
return UMC_ERR_NOT_INITIALIZED;
m_pStore->CreateDSQueue(&m_pInitContext, m_va);
}
return UMC_OK;
}
bool VC1VideoDecoderHW::InitVAEnvironment()
{
m_pContext->m_frmBuff.m_pFrames.Reset(m_FrameStorage);
SetVideoHardwareAccelerator(m_va);
return true;
}
uint32_t VC1VideoDecoderHW::CalculateHeapSize()
{
uint32_t Size = 0;
Size += mfx::align2_value<uint32_t>(sizeof(VC1TaskStore));
if (!m_va)
Size += mfx::align2_value<uint32_t>(sizeof(Frame)*(2*m_iMaxFramesInProcessing + 2*VC1NUMREFFRAMES));
else
Size += mfx::align2_value<uint32_t>(sizeof(Frame)*(m_SurfaceNum));
Size += mfx::align2_value<uint32_t>(sizeof(MediaDataEx));
return Size;
}
Status VC1VideoDecoderHW::Close(void)
{
Status umcRes = UMC_OK;
m_AllocBuffer = 0;
// reset all values
umcRes = Reset();
if (m_pStore)
{
m_pStore->~VC1TaskStore();
m_pStore = nullptr;
}
FreeAlloc(m_pContext);
if(m_pMemoryAllocator)
{
if (static_cast<int>(m_iMemContextID) != -1)
{
m_pMemoryAllocator->Unlock(m_iMemContextID);
m_pMemoryAllocator->Free(m_iMemContextID);
m_iMemContextID = (MemID)-1;
}
if (static_cast<int>(m_iHeapID) != -1)
{
m_pMemoryAllocator->Unlock(m_iHeapID);
m_pMemoryAllocator->Free(m_iHeapID);
m_iHeapID = (MemID)-1;
}
if (static_cast<int>(m_iFrameBufferID) != -1)
{
m_pMemoryAllocator->Unlock(m_iFrameBufferID);
m_pMemoryAllocator->Free(m_iFrameBufferID);
m_iFrameBufferID = (MemID)-1;
}
}
m_pContext = NULL;
m_dataBuffer = NULL;
m_stCodes = NULL;
m_frameData = NULL;
m_pHeap = NULL;
memset(&m_pInitContext,0,sizeof(VC1Context));
m_pMemoryAllocator = 0;
if (m_stCodes_VA)
{
free(m_stCodes_VA);
m_stCodes_VA = NULL;
}
m_pStore = NULL;
m_pContext = NULL;
m_iThreadDecoderNum = 0;
m_decoderInitFlag = 0;
m_decoderFlags = 0;
return umcRes;
}
void VC1VideoDecoderHW::SetVideoHardwareAccelerator (VideoAccelerator* va)
{
if (va)
m_va = (VideoAccelerator*)va;
}
bool VC1VideoDecoderHW::InitAlloc(VC1Context* pContext, uint32_t )
{
if (!InitTables(pContext))
return false;
pContext->m_frmBuff.m_iDisplayIndex = -1;
pContext->m_frmBuff.m_iCurrIndex = -1;
pContext->m_frmBuff.m_iPrevIndex = -1;
pContext->m_frmBuff.m_iNextIndex = -1;
pContext->m_frmBuff.m_iBFrameIndex = -1;
pContext->m_frmBuff.m_iRangeMapIndex = -1;
pContext->m_frmBuff.m_iRangeMapIndexPrev = -1;
m_bLastFrameNeedDisplay = true;
//for slice, field start code
if (m_stCodes_VA == NULL)
{
m_stCodes_VA = (MediaDataEx::_MediaDataEx *)malloc(START_CODE_NUMBER * 2 * sizeof(int32_t) + sizeof(MediaDataEx::_MediaDataEx));
if (m_stCodes_VA == NULL)
return false;
memset(reinterpret_cast<void*>(m_stCodes_VA), 0, (START_CODE_NUMBER * 2 * sizeof(int32_t) + sizeof(MediaDataEx::_MediaDataEx)));
m_stCodes_VA->count = 0;
m_stCodes_VA->index = 0;
m_stCodes_VA->bstrm_pos = 0;
m_stCodes_VA->offsets = (uint32_t*)((uint8_t*)m_stCodes_VA +
sizeof(MediaDataEx::_MediaDataEx));
m_stCodes_VA->values = (uint32_t*)((uint8_t*)m_stCodes_VA->offsets +
START_CODE_NUMBER * sizeof(uint32_t));
}
return true;
}
void VC1VideoDecoderHW::GetStartCodes_HW(MediaData* in, uint32_t &sShift)
{
uint8_t* readPos = (uint8_t*)in->GetBufferPointer();
uint32_t readBufSize = (uint32_t)in->GetDataSize();
uint8_t* readBuf = (uint8_t*)in->GetBufferPointer();
uint32_t frameSize = 0;
MediaDataEx::_MediaDataEx *stCodes = m_stCodes_VA;
stCodes->count = 0;
sShift = 0;
uint32_t size = 0;
uint8_t* ptr = NULL;
uint32_t readDataSize = 0;
uint32_t a = 0x0000FF00 | (*readPos);
uint32_t b = 0xFFFFFFFF;
uint32_t FrameNum = 0;
memset(stCodes->offsets, 0, START_CODE_NUMBER * sizeof(int32_t));
memset(stCodes->values, 0, START_CODE_NUMBER * sizeof(int32_t));
while (readPos < (readBuf + readBufSize))
{
if (stCodes->count > 512)
return;
//find sequence of 0x000001 or 0x000003
while (!(b == 0x00000001 || b == 0x00000003)
&& (++readPos < (readBuf + readBufSize)))
{
a = (a << 8) | (int32_t)(*readPos);
b = a & 0x00FFFFFF;
}
//check end of read buffer
if (readPos < (readBuf + readBufSize - 1))
{
if (*readPos == 0x01)
{
if ((*(readPos + 1) == VC1_Slice) ||
(*(readPos + 1) == VC1_Field) ||
(*(readPos + 1) == VC1_FrameHeader) ||
(*(readPos + 1) == VC1_SliceLevelUserData) ||
(*(readPos + 1) == VC1_FieldLevelUserData) ||
(*(readPos + 1) == VC1_FrameLevelUserData)
)
{
readPos += 2;
ptr = readPos - 5;
size = (uint32_t)(ptr - readBuf - readDataSize + 1);
frameSize = frameSize + size;
stCodes->offsets[stCodes->count] = frameSize;
if (FrameNum)
sShift = 1;
stCodes->values[stCodes->count] = ((*(readPos - 1)) << 24) + ((*(readPos - 2)) << 16) + ((*(readPos - 3)) << 8) + (*(readPos - 4));
readDataSize = (uint32_t)(readPos - readBuf - 4);
a = 0x00010b00 | (int32_t)(*readPos);
b = a & 0x00FFFFFF;
stCodes->count++;
}
else
{
{
readPos += 2;
ptr = readPos - 5;
//trim zero bytes
if (stCodes->count)
{
while ((*ptr == 0) && (ptr > readBuf))
ptr--;
}
//slice or field size
size = (uint32_t)(readPos - readBuf - readDataSize - 4);
frameSize = frameSize + size;
readDataSize = readDataSize + size;
FrameNum++;
}
}
}
else //if(*readPos == 0x03)
{
readPos++;
a = (a << 8) | (int32_t)(*readPos);
b = a & 0x00FFFFFF;
}
}
else
{
//end of stream
size = (uint32_t)(readPos - readBuf - readDataSize);
readDataSize = readDataSize + size;
return;
}
}
}
Status VC1VideoDecoderHW::FillAndExecute(MediaData* in)
{
uint32_t stShift = 0;
int32_t SCoffset = 0;
if ((VC1_PROFILE_ADVANCED != m_pContext->m_seqLayerHeader.PROFILE))
// special header (with frame size) in case of .rcv format
SCoffset = -VC1FHSIZE;
VC1FrameDescriptor* pPackDescriptorChild = m_pStore->GetLastDS();
pPackDescriptorChild->m_bIsFieldAbsent = false;
if ((!VC1_IS_SKIPPED(pPackDescriptorChild->m_pContext->m_picLayerHeader->PTYPE)) &&
(VC1_PROFILE_ADVANCED == m_pContext->m_seqLayerHeader.PROFILE))
{
GetStartCodes_HW(in, stShift);
if (stShift) // we begin since start code frame in case of external MS splitter
{
SCoffset -= *m_stCodes_VA->offsets;
pPackDescriptorChild->m_pContext->m_FrameSize -= *m_stCodes_VA->offsets;
}
}
try
{
pPackDescriptorChild->PrepareVLDVABuffers(m_pContext->m_Offsets,
m_pContext->m_values,
(uint8_t*)in->GetDataPointer() - SCoffset,
m_stCodes_VA + stShift);
}
catch (vc1_exception ex)
{
exception_type e_type = ex.get_exception_type();
if (mem_allocation_er == e_type)
return UMC_ERR_NOT_ENOUGH_BUFFER;
}
if (!VC1_IS_SKIPPED(pPackDescriptorChild->m_pContext->m_picLayerHeader->PTYPE))
{
if (UMC_OK != m_va->EndFrame())
throw VC1Exceptions::vc1_exception(VC1Exceptions::internal_pipeline_error);
}
in->MoveDataPointer(pPackDescriptorChild->m_pContext->m_FrameSize);
if (pPackDescriptorChild->m_pContext->m_picLayerHeader->FCM == VC1_FieldInterlace && m_stCodes_VA->count < 2)
pPackDescriptorChild->m_bIsFieldAbsent = true;
if ((VC1_PROFILE_ADVANCED != m_pContext->m_seqLayerHeader.PROFILE))
{
m_pContext->m_seqLayerHeader.RNDCTRL = pPackDescriptorChild->m_pContext->m_seqLayerHeader.RNDCTRL;
}
return UMC_OK;
}
Status VC1VideoDecoderHW::VC1DecodeFrame(MediaData* in, VideoData* out_data)
{
(void)in;
(void)out_data;
if (m_va->m_Profile == VC1_VLD)
{
return VC1DecodeFrame_VLD<VC1FrameDescriptorVA_Linux<VC1PackerLVA> >(in, out_data);
}
return UMC_ERR_FAILED;
}
FrameMemID VC1VideoDecoderHW::ProcessQueuesForNextFrame(bool& isSkip, mfxU16& Corrupted)
{
FrameMemID currIndx = -1;
UMC::VC1FrameDescriptor *pCurrDescriptor = 0;
UMC::VC1FrameDescriptor *pTempDescriptor = 0;
m_RMIndexToFree = -1;
m_CurrIndexToFree = -1;
pCurrDescriptor = m_pStore->GetFirstDS();
// free first descriptor
m_pStore->SetFirstBusyDescriptorAsReady();
if (!m_pStore->GetPerformedDS(&pTempDescriptor))
m_pStore->GetReadySkippedDS(&pTempDescriptor);
if (pCurrDescriptor)
{
SetCorrupted(pCurrDescriptor, Corrupted);
if (VC1_IS_SKIPPED(pCurrDescriptor->m_pContext->m_picLayerHeader->PTYPE))
{
isSkip = true;
if (!pCurrDescriptor->isDescriptorValid())
{
return currIndx;
}
else
{
currIndx = m_pStore->GetIdx(pCurrDescriptor->m_pContext->m_frmBuff.m_iCurrIndex);
}
// Range Map
if ((pCurrDescriptor->m_pContext->m_seqLayerHeader.RANGE_MAPY_FLAG) ||
(pCurrDescriptor->m_pContext->m_seqLayerHeader.RANGE_MAPUV_FLAG))
{
currIndx = m_pStore->GetIdx(pCurrDescriptor->m_pContext->m_frmBuff.m_iRangeMapIndex);
}
m_pStore->UnLockSurface(pCurrDescriptor->m_pContext->m_frmBuff.m_iToSkipCoping);
return currIndx;
}
else
{
currIndx = m_pStore->GetIdx(pCurrDescriptor->m_pContext->m_frmBuff.m_iCurrIndex);
// We should unlock after LockRect in PrepareOutPut function
if ((pCurrDescriptor->m_pContext->m_seqLayerHeader.RANGE_MAPY_FLAG) ||
(pCurrDescriptor->m_pContext->m_seqLayerHeader.RANGE_MAPUV_FLAG) ||
(pCurrDescriptor->m_pContext->m_seqLayerHeader.RANGERED))
{
if (!VC1_IS_REFERENCE(pCurrDescriptor->m_pContext->m_picLayerHeader->PTYPE))
{
currIndx = m_pStore->GetIdx(pCurrDescriptor->m_pContext->m_frmBuff.m_iRangeMapIndex);
m_RMIndexToFree = pCurrDescriptor->m_pContext->m_frmBuff.m_iRangeMapIndex;
}
else
{
currIndx = m_pStore->GetIdx(pCurrDescriptor->m_pContext->m_frmBuff.m_iRangeMapIndex);
m_RMIndexToFree = pCurrDescriptor->m_pContext->m_frmBuff.m_iRangeMapIndexPrev;
}
}
// Asynchrony Unlock
if (!VC1_IS_REFERENCE(pCurrDescriptor->m_pContext->m_picLayerHeader->PTYPE))
m_CurrIndexToFree = pCurrDescriptor->m_pContext->m_frmBuff.m_iDisplayIndex;
else
{
if (pCurrDescriptor->m_pContext->m_frmBuff.m_iToFreeIndex > -1)
m_CurrIndexToFree = pCurrDescriptor->m_pContext->m_frmBuff.m_iToFreeIndex;
}
}
}
return currIndx;
}
Status VC1VideoDecoderHW::SetRMSurface()
{
Status sts;
sts = VC1VideoDecoder::SetRMSurface();
UMC_CHECK_STATUS(sts);
FillAndExecute(m_pCurrentIn);
return UMC_OK;
}
UMC::FrameMemID VC1VideoDecoderHW::GetSkippedIndex(bool isIn)
{
return VC1VideoDecoder::GetSkippedIndex(m_pStore->GetLastDS(), isIn);
}
#endif //MFX_ENABLE_VC1_VIDEO_DECODE
| 30.629412 | 151 | 0.605147 | chuanli1 |
73d9c024579bede1257529c1ffc856074b6b47c2 | 2,679 | cpp | C++ | modules/task_4/iamshchikov_i_sparse_matrix_mult/main.cpp | 381706-1-DenisovVladislavL/pp_2020_spring | 52d640bd274920b1664414a5f9b0f27da6707f7d | [
"BSD-3-Clause"
] | 1 | 2020-04-21T04:02:06.000Z | 2020-04-21T04:02:06.000Z | modules/task_4/iamshchikov_i_sparse_matrix_mult/main.cpp | 381706-1-DenisovVladislavL/pp_2020_spring | 52d640bd274920b1664414a5f9b0f27da6707f7d | [
"BSD-3-Clause"
] | 1 | 2020-05-16T09:02:12.000Z | 2020-05-16T09:02:12.000Z | modules/task_4/iamshchikov_i_sparse_matrix_mult/main.cpp | 381706-1-DenisovVladislavL/pp_2020_spring | 52d640bd274920b1664414a5f9b0f27da6707f7d | [
"BSD-3-Clause"
] | 3 | 2020-07-28T13:12:29.000Z | 2021-03-24T20:22:40.000Z | // Copyright 2020 Iamshchikov Ivan
#include <gtest/gtest.h>
#include <thread>
#include <random>
#include <ctime>
#include <cmath>
#include "../../modules/task_4/iamshchikov_i_sparse_matrix_mult/sparse_matrix_mult.h"
TEST(sparse_matrix_mult_std, can_create_matrix) {
ASSERT_NO_THROW(CcsMatrix m(1, 1, 1));
}
TEST(sparse_matrix_mult_std, throw_when_number_of_rows_are_not_positive) {
ASSERT_ANY_THROW(CcsMatrix m(-3, 1, 1));
}
TEST(sparse_matrix_mult_std, throw_when_number_of_columns_are_not_positive) {
ASSERT_ANY_THROW(CcsMatrix m(1, 0, 1));
}
TEST(sparse_matrix_mult_std, throw_when_number_of_elements_are_not_positive) {
ASSERT_ANY_THROW(CcsMatrix m(1, 0, -3));
}
TEST(sparse_matrix_mult_std, multiply_vector_by_vector) {
CcsMatrix m1(5, 1, 2);
m1.value = { 2, 1 };
m1.row = { 1, 2 };
m1.colIndex = { 0, 2 };
CcsMatrix m2(1, 4, 1);
m2.value = { 3 };
m2.row = { 0 };
m2.colIndex = { 0, 0, 0, 1, 1 };
CcsMatrix m3(5, 4, 2);
m3.value = { 6, 3 };
m3.row = { 1, 2 };
m3.colIndex = { 0, 0, 0, 2, 2 };
EXPECT_EQ(m3, matrixMultiplicate(&m1, &m2));
}
TEST(sparse_matrix_mult_std, multiply_matrix_by_vector) {
CcsMatrix m1(4, 5, 6);
m1.value = { 1, 3, 2, 5, 4, 8 };
m1.row = { 0, 3, 1, 2, 3, 0 };
m1.colIndex = { 0, 1, 2, 3, 5, 6 };
CcsMatrix m2(5, 1, 2);
m2.value = { 2, 1 };
m2.row = { 1, 2 };
m2.colIndex = { 0, 2 };
CcsMatrix m3(4, 1, 2);
m3.value = { 2, 6 };
m3.row = { 1, 3 };
m3.colIndex = { 0, 2 };
EXPECT_EQ(m3, matrixMultiplicate(&m1, &m2));
}
TEST(sparse_matrix_mult_std, multiply_vector_by_matrix) {
CcsMatrix m1(1, 4, 2);
m1.value = { 2, 1 };
m1.row = { 0, 0 };
m1.colIndex = { 0, 0, 1, 2, 2 };
CcsMatrix m2(4, 5, 6);
m2.value = { 1, 3, 2, 5, 4, 8 };
m2.row = { 0, 3, 1, 2, 3, 0 };
m2.colIndex = { 0, 1, 2, 3, 5, 6 };
CcsMatrix m3(1, 5, 2);
m3.value = { 4, 5 };
m3.row = { 0 , 0 };
m3.colIndex = { 0, 0, 0, 1, 2, 2 };
EXPECT_EQ(m3, matrixMultiplicate(&m1, &m2));
}
TEST(sparse_matrix_mult_std, multiply_matrix_by_matrix) {
CcsMatrix m1(4, 5, 6);
m1.value = { 1, 3, 2, 5, 4, 8 };
m1.row = { 0, 3, 1, 2, 3, 0 };
m1.colIndex = { 0, 1, 2, 3, 5, 6 };
CcsMatrix m2(5, 3, 5);
m2.value = { 1, 6, 3, 7, 2 };
m2.row = { 0, 4, 3, 1, 4 };
m2.colIndex = { 0, 2, 3, 5 };
CcsMatrix m3(4, 3, 5);
m3.value = { 49, 15, 12, 16, 21 };
m3.row = { 0, 2, 3, 0, 3 };
m3.colIndex = { 0, 1, 3, 5 };
EXPECT_EQ(m3, matrixMultiplicate(&m1, &m2));
}
int main(int argc, char** argv) {
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}
| 25.514286 | 85 | 0.565136 | 381706-1-DenisovVladislavL |
73da3b2c1344576195b3a8cba5bc888b9b56d40b | 4,681 | cpp | C++ | src/location.cpp | smu-sc-gj/aicore | b313065e25851a974a3b061ca12595a1fa88d7be | [
"MIT"
] | 412 | 2015-01-05T01:06:31.000Z | 2022-03-08T08:13:36.000Z | src/location.cpp | smu-sc-gj/aicore | b313065e25851a974a3b061ca12595a1fa88d7be | [
"MIT"
] | 6 | 2015-04-18T17:53:13.000Z | 2021-03-29T17:01:23.000Z | src/location.cpp | smu-sc-gj/aicore | b313065e25851a974a3b061ca12595a1fa88d7be | [
"MIT"
] | 141 | 2015-01-11T11:39:48.000Z | 2022-03-24T16:53:15.000Z | /*
* Defines the state classes used for steering.
*
* Part of the Artificial Intelligence for Games system.
*
* Copyright (c) Ian Millington 2003-2006. All Rights Reserved.
*
* This software is distributed under licence. Use of this software
* implies agreement with all terms and conditions of the accompanying
* software licence.
*/
#include <aicore/aicore.h>
namespace aicore
{
/*
* This is messy, but it saves a function call or code duplication.
*/
#define SIMPLE_INTEGRATION(duration, velocity, rotation) \
position.x += (velocity).x*duration; \
position.y += (velocity).y*duration; \
position.z += (velocity).z*duration; \
orientation += (rotation)*duration; \
orientation = real_mod_real(orientation, M_2PI);
/*
* Uses SIMPLE_INTEGRATION(duration), defined above.
*/
void Location::integrate(const SteeringOutput& steer, real duration)
{
SIMPLE_INTEGRATION(duration, steer.linear, steer.angular);
}
void Location::setOrientationFromVelocity(const Vector3& velocity)
{
// If we haven't got any velocity, then we can do nothing.
if (velocity.squareMagnitude() > 0) {
orientation = real_atan2(velocity.x, velocity.z);
}
}
Vector3 Location::getOrientationAsVector() const
{
return Vector3(real_sin(orientation),
0,
real_cos(orientation));
}
/*
* Uses SIMPLE_INTEGRATION(duration), defined above.
*/
void Kinematic::integrate(real duration)
{
SIMPLE_INTEGRATION(duration, velocity, rotation);
}
/*
* Uses SIMPLE_INTEGRATION(duration), defined above.
*/
void Kinematic::integrate(const SteeringOutput& steer,
real duration)
{
SIMPLE_INTEGRATION(duration, velocity, rotation);
velocity.x += steer.linear.x*duration;
velocity.y += steer.linear.y*duration;
velocity.z += steer.linear.z*duration;
rotation += steer.angular*duration;
}
/*
* Uses SIMPLE_INTEGRATION(duration), defined above.
*/
void Kinematic::integrate(const SteeringOutput& steer,
real drag,
real duration)
{
SIMPLE_INTEGRATION(duration, velocity, rotation);
// Slowing velocity and rotational velocity
drag = real_pow(drag, duration);
velocity *= drag;
rotation *= drag*drag;
velocity.x += steer.linear.x*duration;
velocity.y += steer.linear.y*duration;
velocity.z += steer.linear.z*duration;
rotation += steer.angular*duration;
}
/*
* Uses SIMPLE_INTEGRATION(duration), defined above.
*/
void Kinematic::integrate(const SteeringOutput& steer,
const SteeringOutput& drag,
real duration)
{
SIMPLE_INTEGRATION(duration, velocity, rotation);
velocity.x *= real_pow(drag.linear.x, duration);
velocity.y *= real_pow(drag.linear.y, duration);
velocity.z *= real_pow(drag.linear.z, duration);
rotation *= real_pow(drag.angular, duration);
velocity.x += steer.linear.x*duration;
velocity.y += steer.linear.y*duration;
velocity.z += steer.linear.z*duration;
rotation += steer.angular*duration;
}
/* Add and divide used in finding Kinematic means. */
void Kinematic::operator += (const Kinematic& other)
{
position+=other.position;
velocity+=other.velocity;
rotation+=other.rotation;
orientation+=other.orientation;
}
void Kinematic::operator -= (const Kinematic& other)
{
position-=other.position;
velocity-=other.velocity;
rotation-=other.rotation;
orientation-=other.orientation;
}
void Kinematic::operator *= (real f)
{
position*=f;
velocity*=f;
rotation*=f;
orientation*=f;
}
void Kinematic::trimMaxSpeed(real maxSpeed)
{
if (velocity.squareMagnitude() > maxSpeed*maxSpeed) {
velocity.normalise();
velocity *= maxSpeed;
}
}
void Kinematic::setOrientationFromVelocity()
{
// If we haven't got any velocity, then we can do nothing.
if (velocity.squareMagnitude() > 0) {
orientation = real_atan2(velocity.x, velocity.z);
}
}
}; // end of namespace
| 30.00641 | 73 | 0.582995 | smu-sc-gj |
73dbaf1b035f1ca7b44e95b76ce80967e64c967f | 26,198 | cpp | C++ | olp-cpp-sdk-dataservice-write/tests/VersionedLayerClientImplTest.cpp | fermeise/here-data-sdk-cpp | e0ebd7bd74463fa3958eb0447b90227a4f322643 | [
"Apache-2.0"
] | 21 | 2019-07-03T07:26:52.000Z | 2019-09-04T08:35:07.000Z | olp-cpp-sdk-dataservice-write/tests/VersionedLayerClientImplTest.cpp | fermeise/here-data-sdk-cpp | e0ebd7bd74463fa3958eb0447b90227a4f322643 | [
"Apache-2.0"
] | 639 | 2019-09-13T17:14:24.000Z | 2020-05-13T11:49:14.000Z | olp-cpp-sdk-dataservice-write/tests/VersionedLayerClientImplTest.cpp | fermeise/here-data-sdk-cpp | e0ebd7bd74463fa3958eb0447b90227a4f322643 | [
"Apache-2.0"
] | 21 | 2020-05-14T15:32:28.000Z | 2022-03-15T13:52:33.000Z | /*
* Copyright (C) 2020-2021 HERE Europe B.V.
*
* 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.
*
* SPDX-License-Identifier: Apache-2.0
* License-Filename: LICENSE
*/
#include <gmock/gmock.h>
#include <matchers/NetworkUrlMatchers.h>
#include <mocks/CacheMock.h>
#include <mocks/NetworkMock.h>
#include <olp/authentication/Settings.h>
#include <olp/authentication/TokenProvider.h>
#include <olp/core/client/OlpClientSettingsFactory.h>
// clang-format off
#include "generated/serializer/ApiSerializer.h"
#include "generated/serializer/PublicationSerializer.h"
#include <olp/core/generated/serializer/SerializerWrapper.h>
#include "generated/serializer/JsonSerializer.h"
// clang-format on
#include "VersionedLayerClientImpl.h"
#include "WriteDefaultResponses.h"
namespace {
using testing::_;
using testing::Mock;
using testing::Return;
namespace client = olp::client;
namespace write = olp::dataservice::write;
namespace model = olp::dataservice::write::model;
constexpr auto kAppId = "id";
constexpr auto kAppSecret = "secret";
constexpr auto kLayer = "layer";
const std::string kPublishApiName = "publish";
const auto kHrn = olp::client::HRN{"hrn:here:data:::catalog"};
const auto kLookupPublishApiUrl =
"https://api-lookup.data.api.platform.here.com/lookup/v1/resources/" +
kHrn.ToString() + "/apis/publish/v2";
const std::string kPublishUrl =
"https://tmp.publish.data.api.platform.here.com/publish/v2/catalogs/" +
kHrn.ToString() + "/publications";
const std::string kUserSigninResponse = R"JSON(
{"accessToken":"password_grant_token","tokenType":"bearer","expiresIn":3599,"refreshToken":"5j687leur4njgb4osomifn55p0","userId":"HERE-5fa10eda-39ff-4cbc-9b0c-5acba4685649"}
)JSON";
class VersionedLayerClientImplTest : public ::testing::Test {
protected:
void SetUp() override {
cache_ = std::make_shared<CacheMock>();
network_ = std::make_shared<NetworkMock>();
olp::authentication::Settings auth_settings({kAppId, kAppSecret});
auth_settings.network_request_handler = network_;
olp::authentication::TokenProviderDefault provider(auth_settings);
olp::client::AuthenticationSettings auth_client_settings;
auth_client_settings.token_provider = provider;
settings_.network_request_handler = network_;
settings_.cache = cache_;
settings_.task_scheduler =
olp::client::OlpClientSettingsFactory::CreateDefaultTaskScheduler(1);
settings_.authentication_settings = auth_client_settings;
}
void TearDown() override {
settings_.network_request_handler.reset();
settings_.cache.reset();
network_.reset();
cache_.reset();
}
write::model::Apis CreateApiResponse(const std::string& service) {
const auto apis =
mockserver::DefaultResponses::GenerateResourceApisResponse(
kHrn.ToCatalogHRNString());
auto it = std::find_if(
apis.begin(), apis.end(),
[&](const model::Api& obj) -> bool { return obj.GetApi() == service; });
write::model::Apis result;
if (it != apis.end()) {
result.push_back(*it);
}
return result;
}
std::shared_ptr<CacheMock> cache_;
std::shared_ptr<NetworkMock> network_;
olp::client::OlpClientSettings settings_;
};
TEST_F(VersionedLayerClientImplTest, StartBatch) {
const auto catalog = kHrn.ToCatalogHRNString();
const auto api = CreateApiResponse(kPublishApiName);
const auto publication =
mockserver::DefaultResponses::GeneratePublicationResponse({kLayer}, {});
ASSERT_FALSE(api.empty());
// auth token should be valid till the end of all tests
EXPECT_CALL(
*network_,
Send(IsPostRequest(olp::authentication::kHereAccountProductionTokenUrl),
_, _, _, _))
.WillOnce(ReturnHttpResponse(olp::http::NetworkResponse().WithStatus(
olp::http::HttpStatusCode::OK),
kUserSigninResponse));
{
SCOPED_TRACE("Successful request, future");
EXPECT_CALL(*network_, Send(IsGetRequest(kLookupPublishApiUrl), _, _, _, _))
.WillOnce(ReturnHttpResponse(olp::http::NetworkResponse().WithStatus(
olp::http::HttpStatusCode::OK),
olp::serializer::serialize(api)));
EXPECT_CALL(*network_, Send(IsPostRequest(kPublishUrl), _, _, _, _))
.WillOnce(ReturnHttpResponse(olp::http::NetworkResponse().WithStatus(
olp::http::HttpStatusCode::OK),
olp::serializer::serialize(publication)));
// mock apis caching
EXPECT_CALL(*cache_, Get(_, _)).Times(1);
EXPECT_CALL(*cache_, Put(_, _, _, _))
.WillOnce([](const std::string& /*key*/, const boost::any& /*value*/,
const olp::cache::Encoder& /*encoder*/,
time_t /*expiry*/) { return true; });
write::VersionedLayerClientImpl write_client(kHrn, settings_);
const auto batch_request = model::StartBatchRequest().WithLayers({kLayer});
auto future = write_client.StartBatch(batch_request).GetFuture();
const auto response = future.get();
const auto& result = response.GetResult();
EXPECT_TRUE(response.IsSuccessful());
ASSERT_TRUE(result.GetId());
ASSERT_TRUE(result.GetDetails());
ASSERT_TRUE(result.GetLayerIds());
ASSERT_EQ(result.GetLayerIds().get().size(), 1);
ASSERT_EQ(result.GetLayerIds().get().front(), kLayer);
ASSERT_NE("", response.GetResult().GetId().value());
Mock::VerifyAndClearExpectations(network_.get());
Mock::VerifyAndClearExpectations(cache_.get());
}
{
SCOPED_TRACE("Successful request, callback");
EXPECT_CALL(*network_, Send(IsGetRequest(kLookupPublishApiUrl), _, _, _, _))
.WillOnce(ReturnHttpResponse(olp::http::NetworkResponse().WithStatus(
olp::http::HttpStatusCode::OK),
olp::serializer::serialize(api)));
EXPECT_CALL(*network_, Send(IsPostRequest(kPublishUrl), _, _, _, _))
.WillOnce(ReturnHttpResponse(olp::http::NetworkResponse().WithStatus(
olp::http::HttpStatusCode::OK),
olp::serializer::serialize(publication)));
// mock apis caching
EXPECT_CALL(*cache_, Get(_, _)).Times(1);
EXPECT_CALL(*cache_, Put(_, _, _, _))
.WillOnce([](const std::string& /*key*/, const boost::any& /*value*/,
const olp::cache::Encoder& /*encoder*/,
time_t /*expiry*/) { return true; });
std::promise<write::StartBatchResponse> promise;
write::VersionedLayerClientImpl write_client(kHrn, settings_);
const auto batch_request = model::StartBatchRequest().WithLayers({kLayer});
const auto token = write_client.StartBatch(
batch_request, [&promise](write::StartBatchResponse response) {
promise.set_value(std::move(response));
});
auto future = promise.get_future();
const auto response = future.get();
const auto& result = response.GetResult();
EXPECT_TRUE(response.IsSuccessful());
ASSERT_TRUE(result.GetId());
ASSERT_TRUE(result.GetDetails());
ASSERT_TRUE(result.GetLayerIds());
ASSERT_EQ(result.GetLayerIds().get().size(), 1);
ASSERT_EQ(result.GetLayerIds().get().front(), kLayer);
ASSERT_NE("", response.GetResult().GetId().value());
Mock::VerifyAndClearExpectations(network_.get());
Mock::VerifyAndClearExpectations(cache_.get());
}
{
SCOPED_TRACE("Apis load from cache");
EXPECT_CALL(*network_, Send(IsPostRequest(kPublishUrl), _, _, _, _))
.WillOnce(ReturnHttpResponse(olp::http::NetworkResponse().WithStatus(
olp::http::HttpStatusCode::OK),
olp::serializer::serialize(publication)));
// mock apis caching
EXPECT_CALL(*cache_, Get(_, _))
.WillOnce([&api](const std::string&, const olp::cache::Decoder&) {
return api[0].GetBaseUrl();
});
write::VersionedLayerClientImpl write_client(kHrn, settings_);
const auto batch_request = model::StartBatchRequest().WithLayers({kLayer});
auto future = write_client.StartBatch(batch_request).GetFuture();
const auto response = future.get();
const auto& result = response.GetResult();
EXPECT_TRUE(response.IsSuccessful());
ASSERT_TRUE(result.GetId());
ASSERT_TRUE(result.GetDetails());
ASSERT_TRUE(result.GetLayerIds());
ASSERT_EQ(result.GetLayerIds().get().size(), 1);
ASSERT_EQ(result.GetLayerIds().get().front(), kLayer);
ASSERT_NE("", response.GetResult().GetId().value());
Mock::VerifyAndClearExpectations(network_.get());
Mock::VerifyAndClearExpectations(cache_.get());
}
{
SCOPED_TRACE("No layer");
write::VersionedLayerClientImpl write_client(kHrn, settings_);
const auto batch_request = model::StartBatchRequest();
auto future = write_client.StartBatch(batch_request).GetFuture();
const auto response = future.get();
EXPECT_FALSE(response.IsSuccessful());
EXPECT_EQ(response.GetError().GetErrorCode(),
client::ErrorCode::InvalidArgument);
Mock::VerifyAndClearExpectations(network_.get());
Mock::VerifyAndClearExpectations(cache_.get());
}
{
SCOPED_TRACE("Empty layers array");
write::VersionedLayerClientImpl write_client(kHrn, settings_);
const auto batch_request = model::StartBatchRequest().WithLayers({});
auto future = write_client.StartBatch(batch_request).GetFuture();
const auto response = future.get();
EXPECT_FALSE(response.IsSuccessful());
EXPECT_EQ(response.GetError().GetErrorCode(),
client::ErrorCode::InvalidArgument);
Mock::VerifyAndClearExpectations(network_.get());
Mock::VerifyAndClearExpectations(cache_.get());
}
}
TEST_F(VersionedLayerClientImplTest, StartBatchCancel) {
const auto catalog = kHrn.ToCatalogHRNString();
// auth token should be valid till the end of all test cases
EXPECT_CALL(
*network_,
Send(IsPostRequest(olp::authentication::kHereAccountProductionTokenUrl),
_, _, _, _))
.WillOnce(ReturnHttpResponse(olp::http::NetworkResponse().WithStatus(
olp::http::HttpStatusCode::OK),
kUserSigninResponse));
{
SCOPED_TRACE("Cancel");
const auto apis =
mockserver::DefaultResponses::GenerateResourceApisResponse(catalog);
olp::http::RequestId request_id;
NetworkCallback send_mock;
CancelCallback cancel_mock;
auto wait_for_cancel = std::make_shared<std::promise<void>>();
auto pause_for_cancel = std::make_shared<std::promise<void>>();
std::tie(request_id, send_mock, cancel_mock) =
GenerateNetworkMockActions(wait_for_cancel, pause_for_cancel,
{olp::http::HttpStatusCode::OK,
olp::serializer::serialize(apis).c_str()});
EXPECT_CALL(*network_, Send(IsGetRequest(kLookupPublishApiUrl), _, _, _, _))
.WillOnce(testing::Invoke(std::move(send_mock)));
EXPECT_CALL(*network_, Cancel(_))
.WillOnce(testing::Invoke(std::move(cancel_mock)));
// mock apis caching
EXPECT_CALL(*cache_, Get(_, _)).Times(1);
std::promise<write::StartBatchResponse> promise;
write::VersionedLayerClientImpl write_client(kHrn, settings_);
const auto batch_request = model::StartBatchRequest().WithLayers({kLayer});
const auto token = write_client.StartBatch(
batch_request, [&promise](write::StartBatchResponse response) {
promise.set_value(std::move(response));
});
wait_for_cancel->get_future().get();
token.Cancel();
pause_for_cancel->set_value();
auto future = promise.get_future();
const auto response = future.get();
ASSERT_FALSE(response.IsSuccessful());
ASSERT_EQ(response.GetError().GetErrorCode(), client::ErrorCode::Cancelled);
Mock::VerifyAndClearExpectations(network_.get());
Mock::VerifyAndClearExpectations(cache_.get());
}
{
SCOPED_TRACE("On client deletion");
const auto apis =
mockserver::DefaultResponses::GenerateResourceApisResponse(catalog);
olp::http::RequestId request_id;
NetworkCallback send_mock;
CancelCallback cancel_mock;
auto wait_for_cancel = std::make_shared<std::promise<void>>();
auto pause_for_cancel = std::make_shared<std::promise<void>>();
std::tie(request_id, send_mock, cancel_mock) =
GenerateNetworkMockActions(wait_for_cancel, pause_for_cancel,
{olp::http::HttpStatusCode::OK,
olp::serializer::serialize(apis).c_str()});
EXPECT_CALL(*network_, Send(IsGetRequest(kLookupPublishApiUrl), _, _, _, _))
.WillOnce(testing::Invoke(std::move(send_mock)));
EXPECT_CALL(*network_, Cancel(_))
.WillOnce(testing::Invoke(std::move(cancel_mock)));
// mock apis caching
EXPECT_CALL(*cache_, Get(_, _)).Times(1);
auto write_client =
std::make_shared<write::VersionedLayerClientImpl>(kHrn, settings_);
const auto batch_request = model::StartBatchRequest().WithLayers({kLayer});
auto future = write_client->StartBatch(batch_request).GetFuture();
wait_for_cancel->get_future().get();
write_client.reset();
pause_for_cancel->set_value();
const auto response = future.get();
ASSERT_FALSE(response.IsSuccessful());
ASSERT_EQ(response.GetError().GetErrorCode(), client::ErrorCode::Cancelled);
Mock::VerifyAndClearExpectations(network_.get());
Mock::VerifyAndClearExpectations(cache_.get());
}
{
SCOPED_TRACE("Cancellable future");
const auto apis =
mockserver::DefaultResponses::GenerateResourceApisResponse(catalog);
olp::http::RequestId request_id;
NetworkCallback send_mock;
CancelCallback cancel_mock;
auto wait_for_cancel = std::make_shared<std::promise<void>>();
auto pause_for_cancel = std::make_shared<std::promise<void>>();
std::tie(request_id, send_mock, cancel_mock) =
GenerateNetworkMockActions(wait_for_cancel, pause_for_cancel,
{olp::http::HttpStatusCode::OK,
olp::serializer::serialize(apis).c_str()});
EXPECT_CALL(*network_, Send(_, _, _, _, _))
.WillOnce(testing::Invoke(std::move(send_mock)));
EXPECT_CALL(*network_, Cancel(_))
.WillOnce(testing::Invoke(std::move(cancel_mock)));
// mock apis caching
EXPECT_CALL(*cache_, Get(_, _)).Times(1);
write::VersionedLayerClientImpl write_client(kHrn, settings_);
const auto batch_request = model::StartBatchRequest().WithLayers({kLayer});
const auto cancellable = write_client.StartBatch(batch_request);
auto token = cancellable.GetCancellationToken();
wait_for_cancel->get_future().get();
token.Cancel();
pause_for_cancel->set_value();
const auto response = cancellable.GetFuture().get();
ASSERT_FALSE(response.IsSuccessful());
ASSERT_EQ(response.GetError().GetErrorCode(), client::ErrorCode::Cancelled);
Mock::VerifyAndClearExpectations(network_.get());
Mock::VerifyAndClearExpectations(cache_.get());
}
}
TEST_F(VersionedLayerClientImplTest, CompleteBatch) {
const auto catalog = kHrn.ToCatalogHRNString();
const auto api = CreateApiResponse(kPublishApiName);
const auto publication =
mockserver::DefaultResponses::GeneratePublicationResponse({kLayer}, {});
ASSERT_FALSE(api.empty());
ASSERT_TRUE(publication.GetId());
const auto publication_publish_url =
kPublishUrl + "/" + publication.GetId().get();
// auth token should be valid till the end of all tests
EXPECT_CALL(
*network_,
Send(IsPostRequest(olp::authentication::kHereAccountProductionTokenUrl),
_, _, _, _))
.WillOnce(ReturnHttpResponse(olp::http::NetworkResponse().WithStatus(
olp::http::HttpStatusCode::OK),
kUserSigninResponse));
{
SCOPED_TRACE("Successful request, future");
EXPECT_CALL(*network_, Send(IsGetRequest(kLookupPublishApiUrl), _, _, _, _))
.WillOnce(ReturnHttpResponse(olp::http::NetworkResponse().WithStatus(
olp::http::HttpStatusCode::OK),
olp::serializer::serialize(api)));
EXPECT_CALL(*network_,
Send(IsPutRequest(publication_publish_url), _, _, _, _))
.WillOnce(ReturnHttpResponse(olp::http::NetworkResponse().WithStatus(
olp::http::HttpStatusCode::NO_CONTENT),
{}));
// mock apis caching
EXPECT_CALL(*cache_, Get(_, _)).Times(1);
EXPECT_CALL(*cache_, Put(_, _, _, _))
.WillOnce([](const std::string& /*key*/, const boost::any& /*value*/,
const olp::cache::Encoder& /*encoder*/,
time_t /*expiry*/) { return true; });
write::VersionedLayerClientImpl write_client(kHrn, settings_);
const auto batch_request = model::StartBatchRequest().WithLayers({kLayer});
auto future = write_client.CompleteBatch(publication).GetFuture();
const auto response = future.get();
EXPECT_TRUE(response.IsSuccessful());
Mock::VerifyAndClearExpectations(network_.get());
Mock::VerifyAndClearExpectations(cache_.get());
}
{
SCOPED_TRACE("Successful request, callback");
EXPECT_CALL(*network_, Send(IsGetRequest(kLookupPublishApiUrl), _, _, _, _))
.WillOnce(ReturnHttpResponse(olp::http::NetworkResponse().WithStatus(
olp::http::HttpStatusCode::OK),
olp::serializer::serialize(api)));
EXPECT_CALL(*network_,
Send(IsPutRequest(publication_publish_url), _, _, _, _))
.WillOnce(ReturnHttpResponse(olp::http::NetworkResponse().WithStatus(
olp::http::HttpStatusCode::NO_CONTENT),
{}));
// mock apis caching
EXPECT_CALL(*cache_, Get(_, _)).Times(1);
EXPECT_CALL(*cache_, Put(_, _, _, _))
.WillOnce([](const std::string& /*key*/, const boost::any& /*value*/,
const olp::cache::Encoder& /*encoder*/,
time_t /*expiry*/) { return true; });
std::promise<write::CompleteBatchResponse> promise;
write::VersionedLayerClientImpl write_client(kHrn, settings_);
const auto batch_request = model::StartBatchRequest().WithLayers({kLayer});
const auto token = write_client.CompleteBatch(
publication, [&promise](write::CompleteBatchResponse response) {
promise.set_value(std::move(response));
});
auto future = promise.get_future();
const auto response = future.get();
EXPECT_TRUE(response.IsSuccessful());
Mock::VerifyAndClearExpectations(network_.get());
Mock::VerifyAndClearExpectations(cache_.get());
}
{
SCOPED_TRACE("Apis load from cache");
EXPECT_CALL(*network_,
Send(IsPutRequest(publication_publish_url), _, _, _, _))
.WillOnce(ReturnHttpResponse(olp::http::NetworkResponse().WithStatus(
olp::http::HttpStatusCode::NO_CONTENT),
{}));
// mock apis caching
EXPECT_CALL(*cache_, Get(_, _))
.WillOnce([&api](const std::string&, const olp::cache::Decoder&) {
return api[0].GetBaseUrl();
});
write::VersionedLayerClientImpl write_client(kHrn, settings_);
const auto batch_request = model::StartBatchRequest().WithLayers({kLayer});
auto future = write_client.CompleteBatch(publication).GetFuture();
const auto response = future.get();
EXPECT_TRUE(response.IsSuccessful());
Mock::VerifyAndClearExpectations(network_.get());
Mock::VerifyAndClearExpectations(cache_.get());
}
{
SCOPED_TRACE("No publication id");
model::Publication invalid_publication;
write::VersionedLayerClientImpl write_client(kHrn, settings_);
const auto batch_request = model::StartBatchRequest().WithLayers({kLayer});
auto future = write_client.CompleteBatch(invalid_publication).GetFuture();
const auto response = future.get();
const auto& error = response.GetError();
EXPECT_FALSE(response.IsSuccessful());
EXPECT_EQ(error.GetErrorCode(), client::ErrorCode::InvalidArgument);
Mock::VerifyAndClearExpectations(network_.get());
Mock::VerifyAndClearExpectations(cache_.get());
}
}
TEST_F(VersionedLayerClientImplTest, CompleteBatchCancel) {
const auto catalog = kHrn.ToCatalogHRNString();
const auto apis =
mockserver::DefaultResponses::GenerateResourceApisResponse(catalog);
const auto apis_response = olp::serializer::serialize(apis).c_str();
const auto publication =
mockserver::DefaultResponses::GeneratePublicationResponse({kLayer}, {});
ASSERT_TRUE(publication.GetId());
// auth token should be valid till the end of all test cases
EXPECT_CALL(
*network_,
Send(IsPostRequest(olp::authentication::kHereAccountProductionTokenUrl),
_, _, _, _))
.WillOnce(ReturnHttpResponse(olp::http::NetworkResponse().WithStatus(
olp::http::HttpStatusCode::OK),
kUserSigninResponse));
{
SCOPED_TRACE("Cancel");
olp::http::RequestId request_id;
NetworkCallback send_mock;
CancelCallback cancel_mock;
auto wait_for_cancel = std::make_shared<std::promise<void>>();
auto pause_for_cancel = std::make_shared<std::promise<void>>();
std::tie(request_id, send_mock, cancel_mock) = GenerateNetworkMockActions(
wait_for_cancel, pause_for_cancel,
{olp::http::HttpStatusCode::OK, apis_response});
EXPECT_CALL(*network_, Send(IsGetRequest(kLookupPublishApiUrl), _, _, _, _))
.WillOnce(testing::Invoke(std::move(send_mock)));
EXPECT_CALL(*network_, Cancel(_))
.WillOnce(testing::Invoke(std::move(cancel_mock)));
// mock apis caching
EXPECT_CALL(*cache_, Get(_, _)).Times(1);
std::promise<write::CompleteBatchResponse> promise;
write::VersionedLayerClientImpl write_client(kHrn, settings_);
const auto token = write_client.CompleteBatch(
publication, [&promise](write::CompleteBatchResponse response) {
promise.set_value(std::move(response));
});
wait_for_cancel->get_future().get();
token.Cancel();
pause_for_cancel->set_value();
auto future = promise.get_future();
const auto response = future.get();
ASSERT_FALSE(response.IsSuccessful());
ASSERT_EQ(response.GetError().GetErrorCode(), client::ErrorCode::Cancelled);
Mock::VerifyAndClearExpectations(network_.get());
Mock::VerifyAndClearExpectations(cache_.get());
}
{
SCOPED_TRACE("On client deletion");
olp::http::RequestId request_id;
NetworkCallback send_mock;
CancelCallback cancel_mock;
auto wait_for_cancel = std::make_shared<std::promise<void>>();
auto pause_for_cancel = std::make_shared<std::promise<void>>();
std::tie(request_id, send_mock, cancel_mock) = GenerateNetworkMockActions(
wait_for_cancel, pause_for_cancel,
{olp::http::HttpStatusCode::OK, apis_response});
EXPECT_CALL(*network_, Send(IsGetRequest(kLookupPublishApiUrl), _, _, _, _))
.WillOnce(testing::Invoke(std::move(send_mock)));
EXPECT_CALL(*network_, Cancel(_))
.WillOnce(testing::Invoke(std::move(cancel_mock)));
// mock apis caching
EXPECT_CALL(*cache_, Get(_, _)).Times(1);
auto write_client =
std::make_shared<write::VersionedLayerClientImpl>(kHrn, settings_);
auto future = write_client->CompleteBatch(publication).GetFuture();
wait_for_cancel->get_future().get();
write_client.reset();
pause_for_cancel->set_value();
const auto response = future.get();
ASSERT_FALSE(response.IsSuccessful());
ASSERT_EQ(response.GetError().GetErrorCode(), client::ErrorCode::Cancelled);
Mock::VerifyAndClearExpectations(network_.get());
Mock::VerifyAndClearExpectations(cache_.get());
}
{
SCOPED_TRACE("Cancellable future");
olp::http::RequestId request_id;
NetworkCallback send_mock;
CancelCallback cancel_mock;
auto wait_for_cancel = std::make_shared<std::promise<void>>();
auto pause_for_cancel = std::make_shared<std::promise<void>>();
std::tie(request_id, send_mock, cancel_mock) = GenerateNetworkMockActions(
wait_for_cancel, pause_for_cancel,
{olp::http::HttpStatusCode::OK, apis_response});
EXPECT_CALL(*network_, Send(_, _, _, _, _))
.WillOnce(testing::Invoke(std::move(send_mock)));
EXPECT_CALL(*network_, Cancel(_))
.WillOnce(testing::Invoke(std::move(cancel_mock)));
// mock apis caching
EXPECT_CALL(*cache_, Get(_, _)).Times(1);
write::VersionedLayerClientImpl write_client(kHrn, settings_);
const auto cancellable = write_client.CompleteBatch(publication);
auto token = cancellable.GetCancellationToken();
wait_for_cancel->get_future().get();
token.Cancel();
pause_for_cancel->set_value();
const auto response = cancellable.GetFuture().get();
ASSERT_FALSE(response.IsSuccessful());
ASSERT_EQ(response.GetError().GetErrorCode(), client::ErrorCode::Cancelled);
Mock::VerifyAndClearExpectations(network_.get());
Mock::VerifyAndClearExpectations(cache_.get());
}
}
} // namespace
| 38.469897 | 177 | 0.666921 | fermeise |
73dd78bb27495e5502f72f159af60d0ef4c69170 | 8,545 | cpp | C++ | LocalManUtils/IXmlSerializeable.cpp | xuepingiw/open_source_startalk | 44d962b04039f5660ec47a10313876a0754d3e72 | [
"MIT"
] | 34 | 2019-03-18T08:09:24.000Z | 2022-03-15T02:03:25.000Z | LocalManUtils/IXmlSerializeable.cpp | venliong/open_source_startalk | 51fda091a932a8adea626c312692836555753a9a | [
"MIT"
] | 5 | 2019-05-29T09:32:05.000Z | 2019-08-29T03:01:33.000Z | LocalManUtils/IXmlSerializeable.cpp | venliong/open_source_startalk | 51fda091a932a8adea626c312692836555753a9a | [
"MIT"
] | 32 | 2019-03-15T09:43:22.000Z | 2021-08-10T08:26:02.000Z | #include "IXmlSerializeable.h"
const QString mainNode = "item";
const QString argsNode = "args";
const QString classNode = "className";
const QString argNode = "arg";
const QString argNode_Attribute = "attribute";
const QString argNode_Type = "type";
const QString argNode_Value = "value";
#define CompType(x, y) x.typeName() == QString::fromStdString(y)
IXmlSerializeable::IXmlSerializeable(QObject *parent)
: ISerializeable(parent)
{
}
IXmlSerializeable::~IXmlSerializeable()
{
}
void IXmlSerializeable::initNotifycation()
{
auto count = metaObject()->propertyCount();
for(int i=0; i<count; ++i)
{
auto pro = metaObject()->property(i);
const char *name = pro.name();
auto signalIndex = pro.notifySignalIndex();
auto slotIndex = metaObject()->indexOfMethod("onNotifycation()");
auto ret = this->metaObject()->connect(this, pro.notifySignalIndex(), this, metaObject()->indexOfMethod("NotifyConnection()"));
}
}
void IXmlSerializeable::onNotifycation()
{
auto count = metaObject()->propertyCount();
for(int i=0; i<count; ++i)
{
auto pro = metaObject()->property(i);
if( !pro.hasNotifySignal() || pro.notifySignalIndex() != senderSignalIndex() )
continue;
//auto a = pro.typeName();
//auto proName = pro.name();
//auto proValue = pro.read(this);
mChangeList.push_back(pro.name());
break;
}
}
bool IXmlSerializeable::compare( IXmlSerializeable& other )
{
auto tmp1 = seralizeToString();
auto tmp2 = other.seralizeToString();
return tmp1.compare(tmp2) == 0;
}
QDomDocument IXmlSerializeable::seralizeToDocument()
{
QDomDocument doc;
innerSerialize(doc);
return doc;
}
QString IXmlSerializeable::seralizeToString()
{
return seralizeToDocument().toString();
}
QString IXmlSerializeable::seralizeChangedList()
{
QDomDocument doc;
innerSerializeChangedLst(doc);
return doc.toString();
}
void IXmlSerializeable::unserializeFromString( const QString& content )
{
QDomDocument doc;
doc.setContent(content);
auto elemRoot = doc.firstChildElement(mainNode);
innerUnserialize(elemRoot);
}
void IXmlSerializeable::unserialize( QDomElement& elem )
{
//auto elemRoot = elem.firstChildElement(mainNode);
innerUnserialize(elem);
}
void IXmlSerializeable::innerSerializeChangedLst( QDomDocument& doc )
{
auto elemClassName = doc.createElement(mainNode);
elemClassName.setAttribute(classNode, metaObject()->className());
auto elemArgs = doc.createElement(argsNode);
foreach(auto itor, mChangeList){
auto count = metaObject()->propertyCount();
for(int i=0; i<count; ++i)
{
auto pro = metaObject()->property(i);
auto a = pro.typeName();
auto b = pro.read(this);
auto c = pro.name();
if(strcmp(pro.name(), "objectName")==0)
continue;
if(QString::compare(pro.name(), itor) != 0)
continue;
auto elemArg = doc.createElement( argNode );
elemArg.setAttribute( argNode_Attribute, pro.name() );
elemArg.setAttribute( argNode_Type, pro.typeName());
if( CompType(pro, "QString") )
elemArg.setAttribute( argNode_Value, pro.read(this).toString() );
else if( CompType(pro, "int") )
elemArg.setAttribute( argNode_Value, pro.read(this).toInt() );
else if( CompType(pro, "bool") )
elemArg.setAttribute( argNode_Value, pro.read(this).toBool() );
else if( CompType(pro, "QUrl") )
continue;
else
{
Q_ASSERT(false);
continue;
}
elemArgs.appendChild(elemArg);
}
elemClassName.appendChild(elemArgs);
doc.appendChild(elemClassName);
}
}
void IXmlSerializeable::innerSerialize( QDomDocument& doc )
{
auto elemClassName = doc.createElement(mainNode);
elemClassName.setAttribute(classNode, metaObject()->className());
auto elemArgs = doc.createElement(argsNode);
auto count = metaObject()->propertyCount();
for(int i=0; i<count; ++i)
{
auto pro = metaObject()->property(i);
auto a = pro.typeName();
//auto b = pro.read(this);
auto c = pro.name();
if(strcmp(pro.name(), "objectName")==0)
continue;
auto elemArg = doc.createElement( argNode );
elemArg.setAttribute( argNode_Attribute, pro.name() );
elemArg.setAttribute( argNode_Type, pro.typeName());
if( CompType(pro, "QString") )
elemArg.setAttribute( argNode_Value, pro.read(this).toString() );
else if( CompType(pro, "int") )
elemArg.setAttribute( argNode_Value, pro.read(this).toInt() );
else if( CompType(pro, "bool") )
elemArg.setAttribute( argNode_Value, pro.read(this).toBool() );
else if( CompType(pro, "QUrl") )
continue;
else if( CompType(pro, "qreal") || CompType(pro, "double") )
elemArg.setAttribute( argNode_Value, pro.read(this).toDouble() );
else if( CompType(pro, "qint64") || CompType(pro, "qlonglong") )
elemArg.setAttribute( argNode_Value, pro.read(this).toLongLong() );
else if( CompType(pro, "quint64") || CompType(pro, "qulonglong") )
elemArg.setAttribute( argNode_Value, pro.read(this).toULongLong() );
else if( CompType(pro, "QStringList"))
{
auto datas = pro.read(this).toStringList();
foreach(auto item, datas){
auto elemListItem = doc.createElement("item");
elemListItem.appendChild(doc.createTextNode(item));
elemArg.appendChild(elemListItem);
}
}
else if( CompType(pro, "QList<IXmlSerializeable*>")){
auto datas = pro.read(this).value<QList<IXmlSerializeable*>>();
//auto datas = pro.read(this).toList();
foreach(auto item, datas){
elemArg.appendChild(item->seralizeToDocument());
}
}
else
{
// Q_ASSERT(false);
continue;
}
elemArgs.appendChild(elemArg);
}
elemClassName.appendChild(elemArgs);
doc.appendChild(elemClassName);
childSerialize(doc, elemClassName);
}
void IXmlSerializeable::innerUnserialize( QDomElement& elemRoot )
{
do
{
auto className = metaObject()->className();
auto xmlClassName = elemRoot.attribute(classNode);
if(xmlClassName.isEmpty()){
return;
}
if(elemRoot.attribute(classNode) != metaObject()->className())
break;
auto elemArgs = elemRoot.firstChildElement(argsNode);
if(!elemArgs.isElement())
break;
auto elemArg = elemArgs.firstChildElement(argNode);
while(elemArg.isElement())
{
auto elemType = elemArg.attribute(argNode_Attribute);
auto count = metaObject()->propertyCount();
for(int i=0; i<count; ++i)
{
auto pro = metaObject()->property(i);
auto tn = pro.name();
if(elemType != pro.name())
continue;
auto pn = pro.typeName();
if(CompType(pro, "QList<IXmlSerializeable*>"))
{
auto itemArg = elemArg.firstChildElement(mainNode);
while(itemArg.isElement())
{
unserializeItem(pro.name(), itemArg);
itemArg = itemArg.nextSiblingElement(mainNode);
}
}
else if( CompType(pro, "QStringList"))
{
}
else
{
auto attr = elemArg.attribute(argNode_Value);
pro.write(this, elemArg.attribute(argNode_Value));
}
emit pro.notifySignalIndex();
break;
}
elemArg = elemArg.nextSiblingElement();
}
childUnserialize(elemRoot);
return;
} while (false);
Q_ASSERT(false);
}
void IXmlSerializeable::childSerialize( QDomDocument& doc, QDomElement& elem ) const
{
}
void IXmlSerializeable::childUnserialize( QDomElement& elemRoot )
{
}
void IXmlSerializeable::unserializeItem( const QString&name, QDomElement& elem )
{
}
| 29.263699 | 135 | 0.590053 | xuepingiw |
73de8ff45894187821fa3fd7844a623e398d9b1b | 1,422 | cc | C++ | tests/runtime/kernel_exec_context_test.cc | weisk/ppl.nn | 7dd75a1077867fc9a762449953417088446ae2f8 | [
"Apache-2.0"
] | 1 | 2021-10-06T14:39:58.000Z | 2021-10-06T14:39:58.000Z | tests/runtime/kernel_exec_context_test.cc | wolf15/ppl.nn | ac23e5eb518039536f1ef39b43c63d6bda900e77 | [
"Apache-2.0"
] | null | null | null | tests/runtime/kernel_exec_context_test.cc | wolf15/ppl.nn | ac23e5eb518039536f1ef39b43c63d6bda900e77 | [
"Apache-2.0"
] | null | null | null | #include "ppl/nn/runtime/kernel_exec_context.h"
#include "tests/ir/graph_builder.h"
#include "tests/runtime/test_barrier.h"
#include "gtest/gtest.h"
#include <vector>
using namespace std;
using namespace ppl::nn;
using namespace ppl::nn::test;
using namespace ppl::common;
class KernelExecContextTest : public testing::Test {
protected:
void SetUp() override {
builder_.AddNode("a", ir::Node::Type("test", "op1"), {"input_of_a"}, {"output_of_a"});
builder_.AddNode("b", ir::Node::Type("test", "op2"), {"output_of_a"}, {"output_of_b"});
builder_.AddNode("c", ir::Node::Type("test", "op3"), {"output_of_b"}, {"output_of_c"});
builder_.Finalize();
barriers_.resize(builder_.GetGraph()->topo->GetMaxEdgeId());
}
protected:
GraphBuilder builder_;
vector<TestBarrier> barriers_;
};
TEST_F(KernelExecContextTest, misc) {
auto topo = builder_.GetGraph()->topo.get();
auto node = topo->GetNodeById(0);
EXPECT_EQ("a", node->GetName());
KernelExecContext ctx;
ctx.SetNode(node);
ctx.SetGetBarrierFunc([this](edgeid_t eid) -> Barrier* {
return &barriers_[eid];
});
auto edge = topo->GetEdgeByName("input_of_a");
EXPECT_NE(nullptr, edge);
EXPECT_EQ(&barriers_[0], ctx.GetInputBarrier(0));
edge = topo->GetEdgeByName("output_of_a");
EXPECT_NE(nullptr, edge);
EXPECT_EQ(&barriers_[1], ctx.GetOutputBarrier(0));
}
| 30.255319 | 95 | 0.666667 | weisk |
73deb90e17605e524b783b1be083b0bf6f659a3d | 29,826 | cc | C++ | gazebo/gui/MainWindow_TEST.cc | yinnglu/gazebo | 3a5618a2a18873141e3cac734a692b778cec4fc0 | [
"ECL-2.0",
"Apache-2.0"
] | 3 | 2018-07-17T00:17:13.000Z | 2020-05-26T08:39:25.000Z | gazebo/gui/MainWindow_TEST.cc | yinnglu/gazebo | 3a5618a2a18873141e3cac734a692b778cec4fc0 | [
"ECL-2.0",
"Apache-2.0"
] | 1 | 2022-02-03T18:32:35.000Z | 2022-02-03T18:32:35.000Z | gazebo/gui/MainWindow_TEST.cc | mingfeisun/gazebo | f3eae789c738f040b8fb27c2dc16dc4c06f2495c | [
"ECL-2.0",
"Apache-2.0"
] | 2 | 2016-04-25T22:05:09.000Z | 2020-03-08T08:45:12.000Z | /*
* Copyright (C) 2012 Open Source Robotics Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
#include <boost/filesystem.hpp>
#include <ignition/math/Helpers.hh>
#include <ignition/math/Pose3.hh>
#include <ignition/math/Vector2.hh>
#include "gazebo/msgs/msgs.hh"
#include "gazebo/transport/transport.hh"
#include "gazebo/gui/Actions.hh"
#include "gazebo/gui/GuiEvents.hh"
#include "gazebo/gui/GuiIface.hh"
#include "gazebo/gui/MainWindow.hh"
#include "gazebo/gui/GLWidget.hh"
#include "gazebo/gui/MainWindow_TEST.hh"
#include "test_config.h"
bool g_gotSetWireframe = false;
void OnRequest(ConstRequestPtr &_msg)
{
if (_msg->request() == "set_wireframe")
g_gotSetWireframe = true;
}
/////////////////////////////////////////////////
void MainWindow_TEST::MinimizeMaximize()
{
this->resMaxPercentChange = 5.0;
this->shareMaxPercentChange = 2.0;
this->Load("worlds/empty.world", false, false, false);
gazebo::gui::MainWindow *mainWindow = new gazebo::gui::MainWindow();
QVERIFY(mainWindow != NULL);
// Create the main window.
mainWindow->Load();
mainWindow->Init();
mainWindow->show();
// repeat minimize and maximize a couple of times
this->ProcessEventsAndDraw(mainWindow);
mainWindow->showMinimized();
this->ProcessEventsAndDraw(mainWindow);
mainWindow->showMaximized();
this->ProcessEventsAndDraw(mainWindow);
mainWindow->showMinimized();
this->ProcessEventsAndDraw(mainWindow);
mainWindow->showMaximized();
this->ProcessEventsAndDraw(mainWindow);
mainWindow->close();
delete mainWindow;
}
/////////////////////////////////////////////////
void MainWindow_TEST::StepState()
{
this->resMaxPercentChange = 5.0;
this->shareMaxPercentChange = 2.0;
this->Load("worlds/shapes.world", false, false, false);
gazebo::gui::MainWindow *mainWindow = new gazebo::gui::MainWindow();
QVERIFY(mainWindow != NULL);
// Create the main window.
mainWindow->Load();
mainWindow->Init();
mainWindow->show();
this->ProcessEventsAndDraw(mainWindow);
QVERIFY(gazebo::gui::g_stepAct != NULL);
QVERIFY(!gazebo::gui::g_stepAct->isEnabled());
QVERIFY(!mainWindow->IsPaused());
// toggle pause and play step and check if the step action is properly
// enabled / disabled.
mainWindow->Pause();
this->ProcessEventsAndDraw(mainWindow);
QVERIFY(mainWindow->IsPaused());
QVERIFY(gazebo::gui::g_stepAct->isEnabled());
mainWindow->Play();
this->ProcessEventsAndDraw(mainWindow);
QVERIFY(!mainWindow->IsPaused());
QVERIFY(!gazebo::gui::g_stepAct->isEnabled());
mainWindow->Pause();
this->ProcessEventsAndDraw(mainWindow);
QVERIFY(mainWindow->IsPaused());
QVERIFY(gazebo::gui::g_stepAct->isEnabled());
mainWindow->close();
delete mainWindow;
}
/////////////////////////////////////////////////
void MainWindow_TEST::Selection()
{
this->resMaxPercentChange = 5.0;
this->shareMaxPercentChange = 2.0;
this->Load("worlds/shapes.world", false, false, false);
gazebo::gui::MainWindow *mainWindow = new gazebo::gui::MainWindow();
QVERIFY(mainWindow != NULL);
// Create the main window.
mainWindow->Load();
mainWindow->Init();
mainWindow->show();
this->ProcessEventsAndDraw(mainWindow);
// Get the user camera and scene
gazebo::rendering::UserCameraPtr cam = gazebo::gui::get_active_camera();
QVERIFY(cam != NULL);
gazebo::gui::GLWidget *glWidget =
mainWindow->findChild<gazebo::gui::GLWidget *>("GLWidget");
QVERIFY(glWidget != NULL);
ignition::math::Vector2i glWidgetCenter(
glWidget->width()*0.5, glWidget->height()*0.5);
// get model at center of window - should get the box
gazebo::rendering::VisualPtr vis =
cam->Visual(glWidgetCenter);
QVERIFY(vis != NULL);
QVERIFY(vis->GetRootVisual()->Name() == "box");
// move camera to look at the box
ignition::math::Pose3d cameraPose(ignition::math::Vector3d(-1, 0, 0.5),
ignition::math::Quaterniond(0, 0, 0));
cam->SetWorldPose(cameraPose);
QVERIFY(cam->WorldPose() == cameraPose);
// verify we get a box
gazebo::rendering::VisualPtr vis2 =
cam->Visual(ignition::math::Vector2i(0, 0));
QVERIFY(vis2 != NULL);
QVERIFY(vis2->GetRootVisual()->Name() == "box");
// look upwards
ignition::math::Quaterniond pitch90(ignition::math::Vector3d(0, -1.57, 0));
cam->SetWorldRotation(pitch90);
QVERIFY(cam->WorldRotation() == pitch90);
// verify there is nothing in the middle of the window
gazebo::rendering::VisualPtr vis3 = cam->Visual(glWidgetCenter);
QVERIFY(vis3 == NULL);
// reset orientation
ignition::math::Quaterniond identityRot(ignition::math::Vector3d(0, 0, 0));
cam->SetWorldRotation(identityRot);
QVERIFY(cam->WorldRotation() == identityRot);
// verify we can still get the box
gazebo::rendering::VisualPtr vis4 =
cam->Visual(ignition::math::Vector2i(0, 0));
QVERIFY(vis4 != NULL);
QVERIFY(vis4->GetRootVisual()->Name() == "box");
// hide the box
vis4->SetVisible(false);
gazebo::rendering::VisualPtr vis5 = cam->Visual(glWidgetCenter);
// verify we don't get anything now
QVERIFY(vis5 == NULL);
cam->Fini();
mainWindow->close();
delete mainWindow;
}
/////////////////////////////////////////////////
void MainWindow_TEST::SceneDestruction()
{
this->resMaxPercentChange = 5.0;
this->shareMaxPercentChange = 2.0;
this->Load("worlds/shapes.world", false, false, false);
gazebo::gui::MainWindow *mainWindow = new gazebo::gui::MainWindow();
QVERIFY(mainWindow != NULL);
// Create the main window.
mainWindow->Load();
mainWindow->Init();
mainWindow->show();
this->ProcessEventsAndDraw(mainWindow);
// Get the user camera and scene
gazebo::rendering::UserCameraPtr cam = gazebo::gui::get_active_camera();
QVERIFY(cam != NULL);
gazebo::rendering::ScenePtr scene = cam->GetScene();
QVERIFY(scene != NULL);
cam->Fini();
mainWindow->close();
delete mainWindow;
// verify that this test case has the only scene shared pointer remaining.
QVERIFY(scene.use_count() == 1u);
}
/////////////////////////////////////////////////
void MainWindow_TEST::UserCameraFPS()
{
this->resMaxPercentChange = 5.0;
this->shareMaxPercentChange = 2.0;
this->Load("worlds/shapes.world", false, false, false);
gazebo::gui::MainWindow *mainWindow = new gazebo::gui::MainWindow();
QVERIFY(mainWindow != NULL);
// Create the main window.
mainWindow->Load();
mainWindow->Init();
mainWindow->show();
this->ProcessEventsAndDraw(mainWindow);
// Get the user camera and scene
gazebo::rendering::UserCameraPtr cam = gazebo::gui::get_active_camera();
QVERIFY(cam != NULL);
// some machines are unable to hit the target FPS
// sample update time and determine whether to skip FPS lower bound check
bool skipFPSTest = false;
gazebo::common::Time t = gazebo::common::Time::GetWallTime();
QCoreApplication::processEvents();
double dt = (gazebo::common::Time::GetWallTime()-t).Double();
if (dt >= 0.01)
{
std::cerr << "Skipping lower bound FPS check" << std::endl;
skipFPSTest = true;
}
unsigned int iterations = skipFPSTest ? 500 : 5000;
double lowerFPSBound = skipFPSTest ? 0 : 45;
// Wait a little bit for the average FPS to even out.
this->ProcessEventsAndDraw(NULL, iterations, 1);
std::cerr << "\nFPS[" << cam->AvgFPS() << "]\n" << std::endl;
QVERIFY(cam->AvgFPS() > lowerFPSBound);
QVERIFY(cam->AvgFPS() < 75.0);
cam->Fini();
mainWindow->close();
delete mainWindow;
}
/////////////////////////////////////////////////
void MainWindow_TEST::CopyPaste()
{
this->resMaxPercentChange = 5.0;
this->shareMaxPercentChange = 2.0;
this->Load("worlds/shapes.world", false, false, false);
gazebo::gui::MainWindow *mainWindow = new gazebo::gui::MainWindow();
QVERIFY(mainWindow != NULL);
// Create the main window.
mainWindow->Load();
mainWindow->Init();
mainWindow->show();
// Get the user camera and scene
gazebo::rendering::UserCameraPtr cam = gazebo::gui::get_active_camera();
QVERIFY(cam != NULL);
gazebo::rendering::ScenePtr scene = cam->GetScene();
QVERIFY(scene != NULL);
// Get GLWidget
gazebo::gui::GLWidget *glWidget =
mainWindow->findChild<gazebo::gui::GLWidget *>("GLWidget");
QVERIFY(glWidget != NULL);
// Test model copy
{
std::string modelName = "cylinder";
// trigger selection to initialize wirebox's vertex buffer creation first.
// Otherwise test segfaults later when selecting a model due to making
// this call outside the rendering thread.
gazebo::event::Events::setSelectedEntity(modelName, "normal");
this->ProcessEventsAndDraw(mainWindow);
gazebo::rendering::VisualPtr modelVis = scene->GetVisual(modelName);
QVERIFY(modelVis != NULL);
// Select the model
gazebo::event::Events::setSelectedEntity(modelName, "normal");
// Wait until the model is selected
int sleep = 0;
int maxSleep = 100;
while (!modelVis->GetHighlighted() && sleep < maxSleep)
{
gazebo::common::Time::MSleep(30);
sleep++;
}
QVERIFY(modelVis->GetHighlighted());
this->ProcessEventsAndDraw(mainWindow);
QVERIFY(gazebo::gui::g_copyAct != NULL);
QVERIFY(gazebo::gui::g_pasteAct != NULL);
// Copy the model
QTest::keyClick(glWidget, Qt::Key_C, Qt::ControlModifier, 100);
// Move to center of the screen
QPoint moveTo(glWidget->width()/2, glWidget->height()/2);
QTest::mouseMove(glWidget, moveTo, 100);
// Paste the model
QTest::keyClick(glWidget, Qt::Key_V, Qt::ControlModifier, 100);
// Release and spawn the model
QTest::mouseClick(glWidget, Qt::LeftButton, Qt::NoModifier, moveTo, 100);
QCoreApplication::processEvents();
// Verify there is a clone of the model
gazebo::rendering::VisualPtr modelVisClone;
sleep = 0;
maxSleep = 100;
while (!modelVisClone && sleep < maxSleep)
{
modelVisClone = scene->GetVisual(modelName + "_clone");
QTest::qWait(100);
sleep++;
}
QVERIFY(modelVisClone != NULL);
}
// Test light copy
{
std::string lightName = "sun";
// Select the light
gazebo::event::Events::setSelectedEntity(lightName, "normal");
gazebo::rendering::VisualPtr lightVis = scene->GetVisual(lightName);
QVERIFY(lightVis != NULL);
// Wait until the light is selected
int sleep = 0;
int maxSleep = 100;
while (!lightVis->GetHighlighted() && sleep < maxSleep)
{
gazebo::common::Time::MSleep(30);
sleep++;
}
QVERIFY(lightVis->GetHighlighted());
// Copy the light
QTest::keyClick(glWidget, Qt::Key_C, Qt::ControlModifier, 500);
QCoreApplication::processEvents();
// Move to center of the screen
QPoint moveTo(glWidget->width()/2, glWidget->height()/2);
QTest::mouseMove(glWidget, moveTo, 500);
QCoreApplication::processEvents();
// Paste the light
QTest::keyClick(glWidget, Qt::Key_V, Qt::ControlModifier, 500);
QCoreApplication::processEvents();
// Release and spawn the model
QTest::mouseClick(glWidget, Qt::LeftButton, Qt::NoModifier, moveTo, 500);
QCoreApplication::processEvents();
// Verify there is a clone of the light
gazebo::rendering::LightPtr lightClone;
sleep = 0;
maxSleep = 100;
while (!lightClone && sleep < maxSleep)
{
lightClone = scene->GetLight(lightName + "_clone");
QTest::qWait(30);
sleep++;
}
QVERIFY(lightClone != NULL);
lightClone.reset();
}
cam->Fini();
mainWindow->close();
delete mainWindow;
}
/////////////////////////////////////////////////
void MainWindow_TEST::Wireframe()
{
this->resMaxPercentChange = 5.0;
this->shareMaxPercentChange = 2.0;
boost::filesystem::path path = TEST_PATH;
path = path / "worlds" / "empty_dark_plane.world";
this->Load(path.string(), false, false, false);
gazebo::transport::NodePtr node;
gazebo::transport::SubscriberPtr sub;
node = gazebo::transport::NodePtr(new gazebo::transport::Node());
node->Init();
sub = node->Subscribe("~/request", &OnRequest, true);
// Create the main window.
gazebo::gui::MainWindow *mainWindow = new gazebo::gui::MainWindow();
QVERIFY(mainWindow != NULL);
mainWindow->Load();
mainWindow->Init();
mainWindow->show();
this->ProcessEventsAndDraw(mainWindow);
// Get the user camera, and tell it to save frames
gazebo::rendering::UserCameraPtr cam = gazebo::gui::get_active_camera();
if (!cam)
return;
cam->SetCaptureData(true);
this->ProcessEventsAndDraw(mainWindow);
// Get the image data
const unsigned char *image = cam->ImageData();
unsigned int height = cam->ImageHeight();
unsigned int width = cam->ImageWidth();
unsigned int depth = 3;
// Calculate the average color.
unsigned int sum = 0;
for (unsigned int y = 0; y < height; ++y)
{
for (unsigned int x = 0; x < width*depth; ++x)
{
unsigned int a = image[(y*width*depth)+x];
sum += a;
}
}
double avgPreWireframe = static_cast<double>(sum) / (height*width*depth);
// Trigger the wireframe request.
gazebo::gui::g_viewWireframeAct->trigger();
double avgPostWireframe = avgPreWireframe;
// Redraw the screen
for (unsigned int i = 0; i < 100 &&
ignition::math::equal(avgPostWireframe, avgPreWireframe, 1e-3); ++i)
{
gazebo::common::Time::MSleep(30);
QCoreApplication::processEvents();
mainWindow->repaint();
// Get the new image data, and calculate the new average color
image = cam->ImageData();
sum = 0;
for (unsigned int y = 0; y < height; ++y)
{
for (unsigned int x = 0; x < width*depth; ++x)
{
unsigned int a = image[(y*width*depth)+x];
sum += a;
}
}
avgPostWireframe = static_cast<double>(sum) / (height*width*depth);
}
// Make sure the request was set.
QVERIFY(g_gotSetWireframe);
gzdbg << "AvgPrewireframe [" << avgPreWireframe
<< "] AvgPostWireframe[" << avgPostWireframe << "]\n";
// Removing the grey ground plane should change the image.
QVERIFY(!ignition::math::equal(avgPreWireframe, avgPostWireframe));
cam->Fini();
mainWindow->close();
delete mainWindow;
}
/////////////////////////////////////////////////
void MainWindow_TEST::NonDefaultWorld()
{
this->resMaxPercentChange = 5.0;
this->shareMaxPercentChange = 2.0;
boost::filesystem::path path = TEST_PATH;
path = path / "worlds" / "empty_different_name.world";
this->Load(path.string(), false, false, false);
// Create the main window.
gazebo::gui::MainWindow *mainWindow = new gazebo::gui::MainWindow();
QVERIFY(mainWindow != NULL);
mainWindow->Load();
mainWindow->Init();
mainWindow->show();
this->ProcessEventsAndDraw(mainWindow);
// Get the user camera, and tell it to save frames
gazebo::rendering::UserCameraPtr cam = gazebo::gui::get_active_camera();
QVERIFY(cam != nullptr);
cam->SetCaptureData(true);
this->ProcessEventsAndDraw(mainWindow);
// Get the image data
const unsigned char *image = cam->ImageData();
unsigned int height = cam->ImageHeight();
unsigned int width = cam->ImageWidth();
unsigned int depth = 3;
unsigned int sum = 0;
for (unsigned int y = 0; y < height; ++y)
{
for (unsigned int x = 0; x < width*depth; ++x)
{
unsigned int a = image[(y*width*depth)+x];
sum += a;
}
}
QVERIFY(sum > 0);
cam->Fini();
mainWindow->close();
delete mainWindow;
}
/////////////////////////////////////////////////
void MainWindow_TEST::UserCameraJoystick()
{
this->resMaxPercentChange = 5.0;
this->shareMaxPercentChange = 2.0;
this->Load("worlds/shapes.world", false, false, false);
gazebo::gui::MainWindow *mainWindow = new gazebo::gui::MainWindow();
QVERIFY(mainWindow != NULL);
// Create the main window.
mainWindow->Load();
mainWindow->Init();
mainWindow->show();
this->ProcessEventsAndDraw(mainWindow);
// Get the user camera and scene
gazebo::rendering::UserCameraPtr cam = gazebo::gui::get_active_camera();
QVERIFY(cam != NULL);
ignition::math::Pose3d startPose = cam->WorldPose();
QVERIFY(startPose == ignition::math::Pose3d(5, -5, 2, 0, 0.275643, 2.35619));
gazebo::transport::NodePtr node = gazebo::transport::NodePtr(
new gazebo::transport::Node());
node->Init();
gazebo::transport::PublisherPtr joyPub =
node->Advertise<gazebo::msgs::Joystick>("~/user_camera/joy_twist");
// Test with just translation
{
gazebo::msgs::Joystick joystickMsg;
joystickMsg.mutable_translation()->set_x(0.1);
joystickMsg.mutable_translation()->set_y(0.2);
joystickMsg.mutable_translation()->set_z(0.3);
joyPub->Publish(joystickMsg);
this->ProcessEventsAndDraw(mainWindow);
ignition::math::Pose3d endPose = cam->WorldPose();
QVERIFY(endPose == ignition::math::Pose3d(4.98664, -5.00091, 2.01306,
0, 0.275643, 2.35619));
}
// Test with just rotation
{
gazebo::msgs::Joystick joystickMsg;
joystickMsg.mutable_rotation()->set_x(0.0);
joystickMsg.mutable_rotation()->set_y(0.1);
joystickMsg.mutable_rotation()->set_z(0.2);
joyPub->Publish(joystickMsg);
this->ProcessEventsAndDraw(mainWindow);
ignition::math::Pose3d endPose = cam->WorldPose();
QVERIFY(endPose == ignition::math::Pose3d(4.98664, -5.00091, 2.01306,
0, 0.276643, 2.36619));
}
// Test with both translation and rotation
{
gazebo::msgs::Joystick joystickMsg;
joystickMsg.mutable_translation()->set_x(1.0);
joystickMsg.mutable_translation()->set_y(2.1);
joystickMsg.mutable_translation()->set_z(3.2);
joystickMsg.mutable_rotation()->set_x(1.0);
joystickMsg.mutable_rotation()->set_y(2.1);
joystickMsg.mutable_rotation()->set_z(3.2);
joyPub->Publish(joystickMsg);
this->ProcessEventsAndDraw(mainWindow);
ignition::math::Pose3d endPose = cam->WorldPose();
QVERIFY(endPose == ignition::math::Pose3d(4.84758, -5.01151, 2.15333,
0, 0.297643, 2.52619));
}
cam->Fini();
mainWindow->close();
delete mainWindow;
}
/////////////////////////////////////////////////
void MainWindow_TEST::ActionCreationDestruction()
{
this->resMaxPercentChange = 5.0;
this->shareMaxPercentChange = 2.0;
this->Load("worlds/empty.world", false, false, false);
gazebo::gui::MainWindow *mainWindow = new gazebo::gui::MainWindow();
QVERIFY(mainWindow != NULL);
// Create the main window.
mainWindow->Load();
mainWindow->Init();
QVERIFY(gazebo::gui::g_topicVisAct);
QVERIFY(gazebo::gui::g_openAct);
QVERIFY(gazebo::gui::g_saveAct);
QVERIFY(gazebo::gui::g_saveAsAct);
QVERIFY(gazebo::gui::g_saveCfgAct);
QVERIFY(gazebo::gui::g_cloneAct);
QVERIFY(gazebo::gui::g_aboutAct);
QVERIFY(gazebo::gui::g_hotkeyChartAct);
QVERIFY(gazebo::gui::g_quitAct);
QVERIFY(gazebo::gui::g_resetModelsAct);
QVERIFY(gazebo::gui::g_resetWorldAct);
QVERIFY(gazebo::gui::g_editBuildingAct);
QVERIFY(gazebo::gui::g_editTerrainAct);
QVERIFY(gazebo::gui::g_editModelAct);
QVERIFY(gazebo::gui::g_stepAct);
QVERIFY(gazebo::gui::g_playAct);
QVERIFY(gazebo::gui::g_pauseAct);
QVERIFY(gazebo::gui::g_arrowAct);
QVERIFY(gazebo::gui::g_translateAct);
QVERIFY(gazebo::gui::g_rotateAct);
QVERIFY(gazebo::gui::g_scaleAct);
QVERIFY(gazebo::gui::g_boxCreateAct);
QVERIFY(gazebo::gui::g_sphereCreateAct);
QVERIFY(gazebo::gui::g_cylinderCreateAct);
QVERIFY(gazebo::gui::g_pointLghtCreateAct);
QVERIFY(gazebo::gui::g_spotLghtCreateAct);
QVERIFY(gazebo::gui::g_dirLghtCreateAct);
QVERIFY(gazebo::gui::g_resetAct);
QVERIFY(gazebo::gui::g_showCollisionsAct);
QVERIFY(gazebo::gui::g_showGridAct);
QVERIFY(gazebo::gui::g_showOriginAct);
QVERIFY(gazebo::gui::g_showLinkFrameAct);
QVERIFY(gazebo::gui::g_showSkeletonAct);
QVERIFY(gazebo::gui::g_transparentAct);
QVERIFY(gazebo::gui::g_viewWireframeAct);
QVERIFY(gazebo::gui::g_showCOMAct);
QVERIFY(gazebo::gui::g_showInertiaAct);
QVERIFY(gazebo::gui::g_showContactsAct);
QVERIFY(gazebo::gui::g_showJointsAct);
QVERIFY(gazebo::gui::g_showToolbarsAct);
QVERIFY(gazebo::gui::g_fullScreenAct);
QVERIFY(gazebo::gui::g_fpsAct);
QVERIFY(gazebo::gui::g_orbitAct);
QVERIFY(gazebo::gui::g_overlayAct);
QVERIFY(gazebo::gui::g_viewOculusAct);
QVERIFY(gazebo::gui::g_dataLoggerAct);
QVERIFY(gazebo::gui::g_screenshotAct);
QVERIFY(gazebo::gui::g_copyAct);
QVERIFY(gazebo::gui::g_pasteAct);
QVERIFY(gazebo::gui::g_snapAct);
QVERIFY(gazebo::gui::g_alignAct);
QVERIFY(gazebo::gui::g_viewAngleAct);
QVERIFY(gazebo::gui::g_cameraOrthoAct);
QVERIFY(gazebo::gui::g_cameraPerspectiveAct);
QVERIFY(gazebo::gui::g_undoAct);
QVERIFY(gazebo::gui::g_undoHistoryAct);
QVERIFY(gazebo::gui::g_redoAct);
QVERIFY(gazebo::gui::g_plotAct);
QVERIFY(gazebo::gui::g_redoHistoryAct);
this->ProcessEventsAndDraw(mainWindow);
mainWindow->close();
delete mainWindow;
QVERIFY(!gazebo::gui::g_topicVisAct);
QVERIFY(!gazebo::gui::g_openAct);
QVERIFY(!gazebo::gui::g_saveAct);
QVERIFY(!gazebo::gui::g_saveAsAct);
QVERIFY(!gazebo::gui::g_saveCfgAct);
QVERIFY(!gazebo::gui::g_cloneAct);
QVERIFY(!gazebo::gui::g_aboutAct);
QVERIFY(!gazebo::gui::g_hotkeyChartAct);
QVERIFY(!gazebo::gui::g_quitAct);
QVERIFY(!gazebo::gui::g_resetModelsAct);
QVERIFY(!gazebo::gui::g_resetWorldAct);
QVERIFY(!gazebo::gui::g_editBuildingAct);
QVERIFY(!gazebo::gui::g_editTerrainAct);
QVERIFY(!gazebo::gui::g_editModelAct);
QVERIFY(!gazebo::gui::g_stepAct);
QVERIFY(!gazebo::gui::g_playAct);
QVERIFY(!gazebo::gui::g_pauseAct);
QVERIFY(!gazebo::gui::g_arrowAct);
QVERIFY(!gazebo::gui::g_translateAct);
QVERIFY(!gazebo::gui::g_rotateAct);
QVERIFY(!gazebo::gui::g_scaleAct);
QVERIFY(!gazebo::gui::g_boxCreateAct);
QVERIFY(!gazebo::gui::g_sphereCreateAct);
QVERIFY(!gazebo::gui::g_cylinderCreateAct);
QVERIFY(!gazebo::gui::g_pointLghtCreateAct);
QVERIFY(!gazebo::gui::g_spotLghtCreateAct);
QVERIFY(!gazebo::gui::g_dirLghtCreateAct);
QVERIFY(!gazebo::gui::g_resetAct);
QVERIFY(!gazebo::gui::g_showCollisionsAct);
QVERIFY(!gazebo::gui::g_showGridAct);
QVERIFY(!gazebo::gui::g_showOriginAct);
QVERIFY(!gazebo::gui::g_showLinkFrameAct);
QVERIFY(!gazebo::gui::g_showSkeletonAct);
QVERIFY(!gazebo::gui::g_transparentAct);
QVERIFY(!gazebo::gui::g_viewWireframeAct);
QVERIFY(!gazebo::gui::g_showCOMAct);
QVERIFY(!gazebo::gui::g_showInertiaAct);
QVERIFY(!gazebo::gui::g_showContactsAct);
QVERIFY(!gazebo::gui::g_showJointsAct);
QVERIFY(!gazebo::gui::g_showToolbarsAct);
QVERIFY(!gazebo::gui::g_fullScreenAct);
QVERIFY(!gazebo::gui::g_fpsAct);
QVERIFY(!gazebo::gui::g_orbitAct);
QVERIFY(!gazebo::gui::g_overlayAct);
QVERIFY(!gazebo::gui::g_viewOculusAct);
QVERIFY(!gazebo::gui::g_dataLoggerAct);
QVERIFY(!gazebo::gui::g_screenshotAct);
QVERIFY(!gazebo::gui::g_copyAct);
QVERIFY(!gazebo::gui::g_pasteAct);
QVERIFY(!gazebo::gui::g_snapAct);
QVERIFY(!gazebo::gui::g_alignAct);
QVERIFY(!gazebo::gui::g_viewAngleAct);
QVERIFY(!gazebo::gui::g_cameraOrthoAct);
QVERIFY(!gazebo::gui::g_cameraPerspectiveAct);
QVERIFY(!gazebo::gui::g_undoAct);
QVERIFY(!gazebo::gui::g_undoHistoryAct);
QVERIFY(!gazebo::gui::g_redoAct);
QVERIFY(!gazebo::gui::g_redoHistoryAct);
QVERIFY(!gazebo::gui::g_plotAct);
}
/////////////////////////////////////////////////
void MainWindow_TEST::SetUserCameraPoseSDF()
{
this->resMaxPercentChange = 5.0;
this->shareMaxPercentChange = 2.0;
this->Load("worlds/usercamera_test.world", false, false, false);
gazebo::gui::MainWindow *mainWindow = new gazebo::gui::MainWindow();
QVERIFY(mainWindow != NULL);
// Create the main window.
mainWindow->Load();
mainWindow->Init();
mainWindow->show();
// Get the user camera and scene
gazebo::rendering::UserCameraPtr cam = gazebo::gui::get_active_camera();
QVERIFY(cam != NULL);
cam->SetCaptureData(true);
this->ProcessEventsAndDraw(mainWindow);
const unsigned char *data = cam->ImageData();
unsigned int width = cam->ImageWidth();
unsigned int height = cam->ImageHeight();
unsigned int depth = cam->ImageDepth();
// Part 1 : The user camera should be positioned so that it sees only
// a white box
{
int blackCount = 0;
// Get the number of black pixels
for (unsigned int y = 0; y < height; ++y)
{
for (unsigned int x = 0; x < width*depth; ++x)
{
if (data[y*(width*depth) + x] <= 10)
blackCount++;
}
}
// Make sure the black count is zero. This means the camera is
// positioned correctly
QVERIFY(blackCount == 0);
}
cam->Fini();
mainWindow->close();
delete mainWindow;
}
/////////////////////////////////////////////////
void MainWindow_TEST::MenuBar()
{
this->resMaxPercentChange = 5.0;
this->shareMaxPercentChange = 2.0;
this->Load("worlds/empty.world", false, false, false);
gazebo::gui::MainWindow *mainWindow = new gazebo::gui::MainWindow();
QVERIFY(mainWindow != NULL);
// Create the main window.
mainWindow->Load();
mainWindow->Init();
mainWindow->show();
// Get the user camera
gazebo::rendering::UserCameraPtr cam = gazebo::gui::get_active_camera();
QVERIFY(cam != NULL);
QList<QMenuBar *> menuBars = mainWindow->findChildren<QMenuBar *>();
QVERIFY(!menuBars.empty());
std::set<std::string> mainMenus;
mainMenus.insert("&File");
mainMenus.insert("&Edit");
mainMenus.insert("&Camera");
mainMenus.insert("&View");
mainMenus.insert("&Window");
mainMenus.insert("&Help");
// verify all menus are created in the menu bar.
std::set<std::string> mainMenusCopy = mainMenus;
QMenuBar *menuBar = menuBars[0];
QList<QMenu *> menus = menuBar->findChildren<QMenu *>();
for (auto &m : menus)
{
auto it = mainMenusCopy.find(m->title().toStdString());
QVERIFY(it != mainMenus.end());
mainMenusCopy.erase(it);
}
// test adding a new menu to the menu bar
QMenu newMenu(tr("&TEST"));
mainWindow->AddMenu(&newMenu);
QList<QMenu *> newMenus = menuBar->findChildren<QMenu *>();
mainMenusCopy = mainMenus;
mainMenusCopy.insert("&TEST");
for (auto &m : menus)
{
std::string title = m->title().toStdString();
auto it = mainMenusCopy.find(title);
QVERIFY(it != mainMenus.end());
mainMenusCopy.erase(it);
}
// test calling ShowMenuBar and verify all menus remain the same
mainWindow->ShowMenuBar();
menus = menuBar->findChildren<QMenu *>();
mainMenusCopy = mainMenus;
mainMenusCopy.insert("TEST");
for (auto &m : menus)
{
std::string title = m->title().toStdString();
auto it = mainMenusCopy.find(title);
QVERIFY(it != mainMenus.end());
mainMenusCopy.erase(title);
}
cam->Fini();
mainWindow->close();
delete mainWindow;
}
/////////////////////////////////////////////////
void MainWindow_TEST::WindowModes()
{
this->resMaxPercentChange = 5.0;
this->shareMaxPercentChange = 2.0;
this->Load("worlds/empty.world", false, false, false);
// Create the main window.
gazebo::gui::MainWindow *mainWindow = new gazebo::gui::MainWindow();
QVERIFY(mainWindow != NULL);
mainWindow->Load();
mainWindow->Init();
mainWindow->show();
this->ProcessEventsAndDraw(mainWindow);
// Check edit actions are visible
QVERIFY(gazebo::gui::g_resetModelsAct->isVisible());
QVERIFY(gazebo::gui::g_resetWorldAct->isVisible());
QVERIFY(gazebo::gui::g_editBuildingAct->isVisible());
QVERIFY(gazebo::gui::g_editModelAct->isVisible());
// Change to Model Editor mode
gazebo::gui::Events::windowMode("ModelEditor");
// Check edit actions are not visible
QVERIFY(!gazebo::gui::g_resetModelsAct->isVisible());
QVERIFY(!gazebo::gui::g_resetWorldAct->isVisible());
QVERIFY(!gazebo::gui::g_editBuildingAct->isVisible());
QVERIFY(!gazebo::gui::g_editModelAct->isVisible());
// Terminate
mainWindow->close();
delete mainWindow;
}
/////////////////////////////////////////////////
void MainWindow_TEST::MinimumSize()
{
this->resMaxPercentChange = 5.0;
this->shareMaxPercentChange = 2.0;
this->Load("worlds/empty.world", false, false, false);
gazebo::gui::MainWindow *mainWindow = new gazebo::gui::MainWindow();
QVERIFY(mainWindow != NULL);
// Create the main window.
mainWindow->Load();
mainWindow->Init();
// Check that minimum size is smaller then a predefined size
// This desired values are arbitrary, but increasing the minimum
// size could create problems on small screens (such as laptop's).
// See https://bitbucket.org/osrf/gazebo/issues/1706 for more info.
int desiredMinimumWidth = 700;
int desiredMinimumHeight = 710;
QVERIFY(mainWindow->minimumSize().width() <= desiredMinimumWidth);
QVERIFY(mainWindow->minimumSize().height() <= desiredMinimumHeight);
// Check that resizing to a small window (10x10) actually result
// in a size that is smaller then desiredMinimum*
mainWindow->resize(10, 10);
QVERIFY(mainWindow->width() <= desiredMinimumWidth);
QVERIFY(mainWindow->height() <= desiredMinimumHeight);
mainWindow->close();
delete mainWindow;
}
// Generate a main function for the test
QTEST_MAIN(MainWindow_TEST)
| 26.70188 | 79 | 0.667974 | yinnglu |
73e19b361341c44b0f1055ac366ff7077cfa0be4 | 1,803 | hpp | C++ | include/codegen/include/GlobalNamespace/Signal.hpp | Futuremappermydud/Naluluna-Modifier-Quest | bfda34370764b275d90324b3879f1a429a10a873 | [
"MIT"
] | 1 | 2021-11-12T09:29:31.000Z | 2021-11-12T09:29:31.000Z | include/codegen/include/GlobalNamespace/Signal.hpp | Futuremappermydud/Naluluna-Modifier-Quest | bfda34370764b275d90324b3879f1a429a10a873 | [
"MIT"
] | null | null | null | include/codegen/include/GlobalNamespace/Signal.hpp | Futuremappermydud/Naluluna-Modifier-Quest | bfda34370764b275d90324b3879f1a429a10a873 | [
"MIT"
] | 2 | 2021-10-03T02:14:20.000Z | 2021-11-12T09:29:36.000Z | // Autogenerated from CppHeaderCreator
// Created by Sc2ad
// =========================================================================
#pragma once
#pragma pack(push, 8)
// Begin includes
#include "extern/beatsaber-hook/shared/utils/typedefs.h"
// Including type: UnityEngine.ScriptableObject
#include "UnityEngine/ScriptableObject.hpp"
// Completed includes
// Begin forward declares
// Forward declaring namespace: System
namespace System {
// Forward declaring type: Action
class Action;
}
// Completed forward declares
// Type namespace:
namespace GlobalNamespace {
// Autogenerated type: Signal
class Signal : public UnityEngine::ScriptableObject {
public:
// private System.Action _event
// Offset: 0x18
System::Action* event;
// private System.Void add__event(System.Action value)
// Offset: 0xCBCAC0
void add__event(System::Action* value);
// private System.Void remove__event(System.Action value)
// Offset: 0xCBCB64
void remove__event(System::Action* value);
// public System.Void Raise()
// Offset: 0xCBCC08
void Raise();
// public System.Void Subscribe(System.Action foo)
// Offset: 0xCBCC1C
void Subscribe(System::Action* foo);
// public System.Void Unsubscribe(System.Action foo)
// Offset: 0xCBCC48
void Unsubscribe(System::Action* foo);
// public System.Void .ctor()
// Offset: 0xCBCC4C
// Implemented from: UnityEngine.ScriptableObject
// Base method: System.Void ScriptableObject::.ctor()
// Base method: System.Void Object::.ctor()
// Base method: System.Void Object::.ctor()
static Signal* New_ctor();
}; // Signal
}
#include "extern/beatsaber-hook/shared/utils/il2cpp-type-check.hpp"
DEFINE_IL2CPP_ARG_TYPE(GlobalNamespace::Signal*, "", "Signal");
#pragma pack(pop)
| 34.018868 | 76 | 0.681642 | Futuremappermydud |
73e1cf080b36f9cefe704a37fb5c7e8772e8978e | 28,726 | cc | C++ | DQMServices/FwkIO/plugins/DQMRootSource.cc | CeliaFernandez/cmssw | bec73cc7eebb30608c73685df0ff07025d838dd2 | [
"Apache-2.0"
] | 13 | 2015-11-30T15:49:45.000Z | 2022-02-08T16:11:30.000Z | DQMServices/FwkIO/plugins/DQMRootSource.cc | CeliaFernandez/cmssw | bec73cc7eebb30608c73685df0ff07025d838dd2 | [
"Apache-2.0"
] | 640 | 2015-02-11T18:55:47.000Z | 2022-03-31T14:12:23.000Z | DQMServices/FwkIO/plugins/DQMRootSource.cc | CeliaFernandez/cmssw | bec73cc7eebb30608c73685df0ff07025d838dd2 | [
"Apache-2.0"
] | 51 | 2015-08-11T21:01:40.000Z | 2022-03-30T07:31:34.000Z | // -*- C++ -*-
//
// Package: FwkIO
// Class : DQMRootSource
//
// Implementation:
// [Notes on implementation]
//
// Original Author: Chris Jones
// Created: Tue May 3 11:13:47 CDT 2011
//
// system include files
#include <memory>
#include "TFile.h"
#include "TString.h"
#include "TTree.h"
#include <map>
#include <string>
#include <vector>
#include "DQMServices/Core/interface/DQMStore.h"
#include "DataFormats/Histograms/interface/DQMToken.h"
#include "FWCore/ServiceRegistry/interface/Service.h"
#include "FWCore/Framework/interface/InputSource.h"
#include "FWCore/Sources/interface/PuttableSourceBase.h"
#include "FWCore/Catalog/interface/InputFileCatalog.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/Utilities/interface/ExceptionPropagate.h"
#include "FWCore/Framework/interface/RunPrincipal.h"
#include "FWCore/Framework/interface/LuminosityBlockPrincipal.h"
#include "FWCore/Framework/interface/Run.h"
#include "FWCore/Framework/interface/LuminosityBlock.h"
#include "DataFormats/Provenance/interface/LuminosityBlockID.h"
#include "DataFormats/Provenance/interface/LuminosityBlockRange.h"
#include "DataFormats/Provenance/interface/ProcessHistoryRegistry.h"
#include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
#include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
#include "FWCore/Framework/interface/InputSourceMacros.h"
#include "FWCore/Framework/interface/FileBlock.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"
#include "FWCore/MessageLogger/interface/JobReport.h"
#include "FWCore/Utilities/interface/TimeOfDay.h"
#include "format.h"
// class rather than namespace so we can make this a friend of the
// MonitorElement to get access to constructors etc.
struct DQMTTreeIO {
typedef dqm::harvesting::MonitorElement MonitorElement;
typedef dqm::harvesting::DQMStore DQMStore;
// TODO: this should probably be moved somewhere else
class DQMMergeHelper {
public:
// Utility function to check the consistency of the axis labels
// Taken from TH1::CheckBinLabels which is not public
static bool CheckBinLabels(const TAxis* a1, const TAxis* a2) {
// Check that axis have same labels
THashList* l1 = (const_cast<TAxis*>(a1))->GetLabels();
THashList* l2 = (const_cast<TAxis*>(a2))->GetLabels();
if (!l1 && !l2)
return true;
if (!l1 || !l2) {
return false;
}
// Check now labels sizes are the same
if (l1->GetSize() != l2->GetSize()) {
return false;
}
for (int i = 1; i <= a1->GetNbins(); ++i) {
std::string_view label1 = a1->GetBinLabel(i);
std::string_view label2 = a2->GetBinLabel(i);
if (label1 != label2) {
return false;
}
}
return true;
}
// NOTE: the merge logic comes from DataFormats/Histograms/interface/MEtoEDMFormat.h
static void mergeTogether(TH1* original, TH1* toAdd) {
if (original->CanExtendAllAxes() && toAdd->CanExtendAllAxes()) {
TList list;
list.Add(toAdd);
if (original->Merge(&list) == -1) {
edm::LogError("MergeFailure") << "Failed to merge DQM element " << original->GetName();
}
} else {
// TODO: Redo. This is both more strict than what ROOT checks for yet
// allows cases where ROOT fails with merging.
if (original->GetNbinsX() == toAdd->GetNbinsX() &&
original->GetXaxis()->GetXmin() == toAdd->GetXaxis()->GetXmin() &&
original->GetXaxis()->GetXmax() == toAdd->GetXaxis()->GetXmax() &&
original->GetNbinsY() == toAdd->GetNbinsY() &&
original->GetYaxis()->GetXmin() == toAdd->GetYaxis()->GetXmin() &&
original->GetYaxis()->GetXmax() == toAdd->GetYaxis()->GetXmax() &&
original->GetNbinsZ() == toAdd->GetNbinsZ() &&
original->GetZaxis()->GetXmin() == toAdd->GetZaxis()->GetXmin() &&
original->GetZaxis()->GetXmax() == toAdd->GetZaxis()->GetXmax() &&
CheckBinLabels(original->GetXaxis(), toAdd->GetXaxis()) &&
CheckBinLabels(original->GetYaxis(), toAdd->GetYaxis()) &&
CheckBinLabels(original->GetZaxis(), toAdd->GetZaxis())) {
original->Add(toAdd);
} else {
edm::LogError("MergeFailure") << "Found histograms with different axis limits or different labels '"
<< original->GetName() << "' not merged.";
}
}
}
};
// This struct allows to find all MEs belonging to a run-lumi pair
// All files will be open at once so m_file property indicates the file where data is saved.
struct FileMetadata {
unsigned int m_run;
unsigned int m_lumi;
ULong64_t m_beginTime;
ULong64_t m_endTime;
ULong64_t m_firstIndex;
ULong64_t m_lastIndex; // Last is inclusive
unsigned int m_type;
TFile* m_file;
// This will be used when sorting a vector
bool operator<(const FileMetadata& obj) const {
if (m_run == obj.m_run)
return m_lumi < obj.m_lumi;
else
return m_run < obj.m_run;
}
void describe() {
std::cout << "read r:" << m_run << " l:" << m_lumi << " bt:" << m_beginTime << " et:" << m_endTime
<< " fi:" << m_firstIndex << " li:" << m_lastIndex << " type:" << m_type << " file: " << m_file
<< std::endl;
}
};
class TreeReaderBase {
public:
TreeReaderBase(MonitorElementData::Kind kind, MonitorElementData::Scope rescope)
: m_kind(kind), m_rescope(rescope) {}
virtual ~TreeReaderBase() {}
MonitorElementData::Key makeKey(std::string const& fullname, int run, int lumi) {
MonitorElementData::Key key;
key.kind_ = m_kind;
key.path_.set(fullname, MonitorElementData::Path::Type::DIR_AND_NAME);
if (m_rescope == MonitorElementData::Scope::LUMI) {
// no rescoping
key.scope_ = lumi == 0 ? MonitorElementData::Scope::RUN : MonitorElementData::Scope::LUMI;
key.id_ = edm::LuminosityBlockID(run, lumi);
} else if (m_rescope == MonitorElementData::Scope::RUN) {
// everything becomes run, we'll never see Scope::JOB inside DQMIO files.
key.scope_ = MonitorElementData::Scope::RUN;
key.id_ = edm::LuminosityBlockID(run, 0);
} else if (m_rescope == MonitorElementData::Scope::JOB) {
// Everything is aggregated over the entire job.
key.scope_ = MonitorElementData::Scope::JOB;
key.id_ = edm::LuminosityBlockID(0, 0);
} else {
assert(!"Invalid Scope in rescope option.");
}
return key;
}
virtual void read(ULong64_t iIndex, DQMStore* dqmstore, int run, int lumi) = 0;
virtual void setTree(TTree* iTree) = 0;
protected:
MonitorElementData::Kind m_kind;
MonitorElementData::Scope m_rescope;
};
template <class T>
class TreeObjectReader : public TreeReaderBase {
public:
TreeObjectReader(MonitorElementData::Kind kind, MonitorElementData::Scope rescope) : TreeReaderBase(kind, rescope) {
assert(m_kind != MonitorElementData::Kind::INT);
assert(m_kind != MonitorElementData::Kind::REAL);
assert(m_kind != MonitorElementData::Kind::STRING);
}
void read(ULong64_t iIndex, DQMStore* dqmstore, int run, int lumi) override {
// This will populate the fields as defined in setTree method
m_tree->GetEntry(iIndex);
auto key = makeKey(*m_fullName, run, lumi);
auto existing = dqmstore->findOrRecycle(key);
if (existing) {
// TODO: make sure there is sufficient locking here.
DQMMergeHelper::mergeTogether(existing->getTH1(), m_buffer);
} else {
// We make our own MEs here, to avoid a round-trip through the booking API.
MonitorElementData meData;
meData.key_ = key;
meData.value_.object_ = std::unique_ptr<T>((T*)(m_buffer->Clone()));
auto me = new MonitorElement(std::move(meData));
dqmstore->putME(me);
}
}
void setTree(TTree* iTree) override {
m_tree = iTree;
m_tree->SetBranchAddress(kFullNameBranch, &m_fullName);
m_tree->SetBranchAddress(kFlagBranch, &m_tag);
m_tree->SetBranchAddress(kValueBranch, &m_buffer);
}
private:
TTree* m_tree = nullptr;
std::string* m_fullName = nullptr;
T* m_buffer = nullptr;
uint32_t m_tag = 0;
};
class TreeStringReader : public TreeReaderBase {
public:
TreeStringReader(MonitorElementData::Kind kind, MonitorElementData::Scope rescope) : TreeReaderBase(kind, rescope) {
assert(m_kind == MonitorElementData::Kind::STRING);
}
void read(ULong64_t iIndex, DQMStore* dqmstore, int run, int lumi) override {
// This will populate the fields as defined in setTree method
m_tree->GetEntry(iIndex);
auto key = makeKey(*m_fullName, run, lumi);
auto existing = dqmstore->findOrRecycle(key);
if (existing) {
existing->Fill(*m_value);
} else {
// We make our own MEs here, to avoid a round-trip through the booking API.
MonitorElementData meData;
meData.key_ = key;
meData.value_.scalar_.str = *m_value;
auto me = new MonitorElement(std::move(meData));
dqmstore->putME(me);
}
}
void setTree(TTree* iTree) override {
m_tree = iTree;
m_tree->SetBranchAddress(kFullNameBranch, &m_fullName);
m_tree->SetBranchAddress(kFlagBranch, &m_tag);
m_tree->SetBranchAddress(kValueBranch, &m_value);
}
private:
TTree* m_tree = nullptr;
std::string* m_fullName = nullptr;
std::string* m_value = nullptr;
uint32_t m_tag = 0;
};
template <class T>
class TreeSimpleReader : public TreeReaderBase {
public:
TreeSimpleReader(MonitorElementData::Kind kind, MonitorElementData::Scope rescope) : TreeReaderBase(kind, rescope) {
assert(m_kind == MonitorElementData::Kind::INT || m_kind == MonitorElementData::Kind::REAL);
}
void read(ULong64_t iIndex, DQMStore* dqmstore, int run, int lumi) override {
// This will populate the fields as defined in setTree method
m_tree->GetEntry(iIndex);
auto key = makeKey(*m_fullName, run, lumi);
auto existing = dqmstore->findOrRecycle(key);
if (existing) {
existing->Fill(m_buffer);
} else {
// We make our own MEs here, to avoid a round-trip through the booking API.
MonitorElementData meData;
meData.key_ = key;
if (m_kind == MonitorElementData::Kind::INT)
meData.value_.scalar_.num = m_buffer;
else if (m_kind == MonitorElementData::Kind::REAL)
meData.value_.scalar_.real = m_buffer;
auto me = new MonitorElement(std::move(meData));
dqmstore->putME(me);
}
}
void setTree(TTree* iTree) override {
m_tree = iTree;
m_tree->SetBranchAddress(kFullNameBranch, &m_fullName);
m_tree->SetBranchAddress(kFlagBranch, &m_tag);
m_tree->SetBranchAddress(kValueBranch, &m_buffer);
}
private:
TTree* m_tree = nullptr;
std::string* m_fullName = nullptr;
T m_buffer = 0;
uint32_t m_tag = 0;
};
};
class DQMRootSource : public edm::PuttableSourceBase, DQMTTreeIO {
public:
DQMRootSource(edm::ParameterSet const&, const edm::InputSourceDescription&);
~DQMRootSource() override;
// ---------- const member functions ---------------------
// ---------- static member functions --------------------
// ---------- member functions ---------------------------
static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
private:
DQMRootSource(const DQMRootSource&) = delete;
edm::InputSource::ItemType getNextItemType() override;
std::shared_ptr<edm::FileBlock> readFile_() override;
std::shared_ptr<edm::RunAuxiliary> readRunAuxiliary_() override;
std::shared_ptr<edm::LuminosityBlockAuxiliary> readLuminosityBlockAuxiliary_() override;
void readRun_(edm::RunPrincipal& rpCache) override;
void readLuminosityBlock_(edm::LuminosityBlockPrincipal& lbCache) override;
void readEvent_(edm::EventPrincipal&) override;
// Read MEs from m_fileMetadatas to DQMStore till run or lumi transition
void readElements();
// True if m_currentIndex points to an element that has a different
// run or lumi than the previous element (a transition needs to happen).
// False otherwise.
bool isRunOrLumiTransition() const;
void readNextItemType();
// These methods will be called by the framework.
// MEs in DQMStore will be put to products.
void beginRun(edm::Run& run) override;
void beginLuminosityBlock(edm::LuminosityBlock& lumi) override;
// If the run matches the filterOnRun configuration parameter, the run
// (and all its lumis) will be kept.
// Otherwise, check if a run and a lumi are in the range that needs to be processed.
// Range is retrieved from lumisToProcess configuration parameter.
// If at least one lumi of a run needs to be kept, per run MEs of that run will also be kept.
bool keepIt(edm::RunNumber_t, edm::LuminosityBlockNumber_t) const;
void logFileAction(char const* msg, char const* fileName) const;
const DQMRootSource& operator=(const DQMRootSource&) = delete; // stop default
// ---------- member data --------------------------------
// Properties from python config
bool m_skipBadFiles;
unsigned int m_filterOnRun;
edm::InputFileCatalog m_catalog;
std::vector<edm::LuminosityBlockRange> m_lumisToProcess;
MonitorElementData::Scope m_rescope;
edm::InputSource::ItemType m_nextItemType;
// Each ME type gets its own reader
std::vector<std::shared_ptr<TreeReaderBase>> m_treeReaders;
// Index of currenlty processed row in m_fileMetadatas
unsigned int m_currentIndex;
// All open DQMIO files
std::vector<TFile*> m_openFiles;
// An item here is a row read from DQMIO indices (metadata) table
std::vector<FileMetadata> m_fileMetadatas;
};
//
// constants, enums and typedefs
//
//
// static data member definitions
//
void DQMRootSource::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
edm::ParameterSetDescription desc;
desc.addUntracked<std::vector<std::string>>("fileNames")->setComment("Names of files to be processed.");
desc.addUntracked<unsigned int>("filterOnRun", 0)->setComment("Just limit the process to the selected run.");
desc.addUntracked<std::string>("reScope", "JOB")
->setComment(
"Accumulate histograms more coarsely."
" Options: \"\": keep unchanged, \"RUN\": turn LUMI histograms into RUN histograms, \"JOB\": turn everything "
"into JOB histograms.");
desc.addUntracked<bool>("skipBadFiles", false)->setComment("Skip the file if it is not valid");
desc.addUntracked<std::string>("overrideCatalog", std::string())
->setComment("An alternate file catalog to use instead of the standard site one.");
std::vector<edm::LuminosityBlockRange> defaultLumis;
desc.addUntracked<std::vector<edm::LuminosityBlockRange>>("lumisToProcess", defaultLumis)
->setComment("Skip any lumi inside the specified run:lumi range.");
descriptions.addDefault(desc);
}
//
// constructors and destructor
//
DQMRootSource::DQMRootSource(edm::ParameterSet const& iPSet, const edm::InputSourceDescription& iDesc)
: edm::PuttableSourceBase(iPSet, iDesc),
m_skipBadFiles(iPSet.getUntrackedParameter<bool>("skipBadFiles", false)),
m_filterOnRun(iPSet.getUntrackedParameter<unsigned int>("filterOnRun", 0)),
m_catalog(iPSet.getUntrackedParameter<std::vector<std::string>>("fileNames"),
iPSet.getUntrackedParameter<std::string>("overrideCatalog")),
m_lumisToProcess(iPSet.getUntrackedParameter<std::vector<edm::LuminosityBlockRange>>(
"lumisToProcess", std::vector<edm::LuminosityBlockRange>())),
m_rescope(std::map<std::string, MonitorElementData::Scope>{
{"", MonitorElementData::Scope::LUMI},
{"LUMI", MonitorElementData::Scope::LUMI},
{"RUN", MonitorElementData::Scope::RUN},
{"JOB", MonitorElementData::Scope::JOB}}[iPSet.getUntrackedParameter<std::string>("reScope", "JOB")]),
m_nextItemType(edm::InputSource::IsFile),
m_treeReaders(kNIndicies, std::shared_ptr<TreeReaderBase>()),
m_currentIndex(0),
m_openFiles(std::vector<TFile*>()),
m_fileMetadatas(std::vector<FileMetadata>()) {
edm::sortAndRemoveOverlaps(m_lumisToProcess);
if (m_catalog.fileNames(0).empty()) {
m_nextItemType = edm::InputSource::IsStop;
} else {
m_treeReaders[kIntIndex].reset(new TreeSimpleReader<Long64_t>(MonitorElementData::Kind::INT, m_rescope));
m_treeReaders[kFloatIndex].reset(new TreeSimpleReader<double>(MonitorElementData::Kind::REAL, m_rescope));
m_treeReaders[kStringIndex].reset(new TreeStringReader(MonitorElementData::Kind::STRING, m_rescope));
m_treeReaders[kTH1FIndex].reset(new TreeObjectReader<TH1F>(MonitorElementData::Kind::TH1F, m_rescope));
m_treeReaders[kTH1SIndex].reset(new TreeObjectReader<TH1S>(MonitorElementData::Kind::TH1S, m_rescope));
m_treeReaders[kTH1DIndex].reset(new TreeObjectReader<TH1D>(MonitorElementData::Kind::TH1D, m_rescope));
m_treeReaders[kTH2FIndex].reset(new TreeObjectReader<TH2F>(MonitorElementData::Kind::TH2F, m_rescope));
m_treeReaders[kTH2SIndex].reset(new TreeObjectReader<TH2S>(MonitorElementData::Kind::TH2S, m_rescope));
m_treeReaders[kTH2DIndex].reset(new TreeObjectReader<TH2D>(MonitorElementData::Kind::TH2D, m_rescope));
m_treeReaders[kTH3FIndex].reset(new TreeObjectReader<TH3F>(MonitorElementData::Kind::TH3F, m_rescope));
m_treeReaders[kTProfileIndex].reset(new TreeObjectReader<TProfile>(MonitorElementData::Kind::TPROFILE, m_rescope));
m_treeReaders[kTProfile2DIndex].reset(
new TreeObjectReader<TProfile2D>(MonitorElementData::Kind::TPROFILE2D, m_rescope));
}
produces<DQMToken, edm::Transition::BeginRun>("DQMGenerationRecoRun");
produces<DQMToken, edm::Transition::BeginLuminosityBlock>("DQMGenerationRecoLumi");
}
DQMRootSource::~DQMRootSource() {
for (auto& file : m_openFiles) {
if (file != nullptr && file->IsOpen()) {
file->Close();
logFileAction("Closed file", "");
}
}
}
//
// member functions
//
edm::InputSource::ItemType DQMRootSource::getNextItemType() { return m_nextItemType; }
// We will read the metadata of all files and fill m_fileMetadatas vector
std::shared_ptr<edm::FileBlock> DQMRootSource::readFile_() {
const int numFiles = m_catalog.fileNames(0).size();
m_openFiles.reserve(numFiles);
for (auto& fileitem : m_catalog.fileCatalogItems()) {
TFile* file;
std::list<std::string> exInfo;
//loop over names of a file, each of them corresponds to a data catalog
bool isGoodFile(true);
//get all names of a file, each of them corresponds to a data catalog
const std::vector<std::string>& fNames = fileitem.fileNames();
for (std::vector<std::string>::const_iterator it = fNames.begin(); it != fNames.end(); ++it) {
// Try to open a file
try {
file = TFile::Open(it->c_str());
// Exception will be trapped so we pull it out ourselves
std::exception_ptr e = edm::threadLocalException::getException();
if (e != std::exception_ptr()) {
edm::threadLocalException::setException(std::exception_ptr());
std::rethrow_exception(e);
}
} catch (cms::Exception const& e) {
file = nullptr; // is there anything we need to free?
if (std::next(it) == fNames.end()) { //last name corresponding to the last data catalog to try
if (!m_skipBadFiles) {
edm::Exception ex(edm::errors::FileOpenError, "", e);
ex.addContext("Opening DQM Root file");
ex << "\nInput file " << it->c_str() << " was not found, could not be opened, or is corrupted.\n";
//report previous exceptions when use other names to open file
for (auto const& s : exInfo)
ex.addAdditionalInfo(s);
throw ex;
}
isGoodFile = false;
}
// save in case of error when trying next name
for (auto const& s : e.additionalInfo())
exInfo.push_back(s);
}
// Check if a file is usable
if (file && !file->IsZombie()) {
logFileAction("Successfully opened file ", it->c_str());
break;
} else {
if (std::next(it) == fNames.end()) {
if (!m_skipBadFiles) {
edm::Exception ex(edm::errors::FileOpenError);
ex << "Input file " << it->c_str() << " could not be opened.\n";
ex.addContext("Opening DQM Root file");
//report previous exceptions when use other names to open file
for (auto const& s : exInfo)
ex.addAdditionalInfo(s);
throw ex;
}
isGoodFile = false;
}
if (file) {
delete file;
file = nullptr;
}
}
} //end loop over names of the file
if (!isGoodFile && m_skipBadFiles)
continue;
m_openFiles.insert(m_openFiles.begin(), file);
// Check file format version, which is encoded in the Title of the TFile
if (strcmp(file->GetTitle(), "1") != 0) {
edm::Exception ex(edm::errors::FileReadError);
ex << "Input file " << fNames[0].c_str() << " does not appear to be a DQM Root file.\n";
}
// Read metadata from the file
TTree* indicesTree = dynamic_cast<TTree*>(file->Get(kIndicesTree));
assert(indicesTree != nullptr);
FileMetadata temp;
// Each line of metadata will be read into the coresponding fields of temp.
indicesTree->SetBranchAddress(kRunBranch, &temp.m_run);
indicesTree->SetBranchAddress(kLumiBranch, &temp.m_lumi);
indicesTree->SetBranchAddress(kBeginTimeBranch, &temp.m_beginTime);
indicesTree->SetBranchAddress(kEndTimeBranch, &temp.m_endTime);
indicesTree->SetBranchAddress(kTypeBranch, &temp.m_type);
indicesTree->SetBranchAddress(kFirstIndex, &temp.m_firstIndex);
indicesTree->SetBranchAddress(kLastIndex, &temp.m_lastIndex);
for (Long64_t index = 0; index != indicesTree->GetEntries(); ++index) {
indicesTree->GetEntry(index);
temp.m_file = file;
if (keepIt(temp.m_run, temp.m_lumi)) {
m_fileMetadatas.push_back(temp);
}
}
} //end loop over files
// Sort to make sure runs and lumis appear in sequential order
std::stable_sort(m_fileMetadatas.begin(), m_fileMetadatas.end());
// If we have lumisections without matching runs, insert dummy runs here.
unsigned int run = 0;
auto toadd = std::vector<FileMetadata>();
for (auto& metadata : m_fileMetadatas) {
if (run < metadata.m_run && metadata.m_lumi != 0) {
// run transition and lumi transition at the same time!
FileMetadata dummy{}; // zero initialize
dummy.m_run = metadata.m_run;
dummy.m_lumi = 0;
dummy.m_type = kNoTypesStored;
toadd.push_back(dummy);
}
run = metadata.m_run;
}
if (!toadd.empty()) {
// rather than trying to insert at the right places, just append and sort again.
m_fileMetadatas.insert(m_fileMetadatas.end(), toadd.begin(), toadd.end());
std::stable_sort(m_fileMetadatas.begin(), m_fileMetadatas.end());
}
//for (auto& metadata : m_fileMetadatas)
// metadata.describe();
// Stop if there's nothing to process. Otherwise start the run.
if (m_fileMetadatas.empty())
m_nextItemType = edm::InputSource::IsStop;
else
m_nextItemType = edm::InputSource::IsRun;
// We have to return something but not sure why
return std::make_shared<edm::FileBlock>();
}
std::shared_ptr<edm::RunAuxiliary> DQMRootSource::readRunAuxiliary_() {
FileMetadata metadata = m_fileMetadatas[m_currentIndex];
auto runAux =
edm::RunAuxiliary(metadata.m_run, edm::Timestamp(metadata.m_beginTime), edm::Timestamp(metadata.m_endTime));
return std::make_shared<edm::RunAuxiliary>(runAux);
}
std::shared_ptr<edm::LuminosityBlockAuxiliary> DQMRootSource::readLuminosityBlockAuxiliary_() {
FileMetadata metadata = m_fileMetadatas[m_currentIndex];
auto lumiAux = edm::LuminosityBlockAuxiliary(edm::LuminosityBlockID(metadata.m_run, metadata.m_lumi),
edm::Timestamp(metadata.m_beginTime),
edm::Timestamp(metadata.m_endTime));
return std::make_shared<edm::LuminosityBlockAuxiliary>(lumiAux);
}
void DQMRootSource::readRun_(edm::RunPrincipal& rpCache) {
// Read elements of a current run.
do {
FileMetadata metadata = m_fileMetadatas[m_currentIndex];
if (metadata.m_lumi == 0) {
readElements();
}
m_currentIndex++;
} while (!isRunOrLumiTransition());
readNextItemType();
edm::Service<edm::JobReport> jr;
jr->reportInputRunNumber(rpCache.id().run());
rpCache.fillRunPrincipal(processHistoryRegistryForUpdate());
}
void DQMRootSource::readLuminosityBlock_(edm::LuminosityBlockPrincipal& lbCache) {
// Read elements of a current lumi.
do {
readElements();
m_currentIndex++;
} while (!isRunOrLumiTransition());
readNextItemType();
edm::Service<edm::JobReport> jr;
jr->reportInputLumiSection(lbCache.id().run(), lbCache.id().luminosityBlock());
lbCache.fillLuminosityBlockPrincipal(processHistoryRegistry().getMapped(lbCache.aux().processHistoryID()));
}
void DQMRootSource::readEvent_(edm::EventPrincipal&) {}
void DQMRootSource::readElements() {
FileMetadata metadata = m_fileMetadatas[m_currentIndex];
if (metadata.m_type != kNoTypesStored) {
std::shared_ptr<TreeReaderBase> reader = m_treeReaders[metadata.m_type];
TTree* tree = dynamic_cast<TTree*>(metadata.m_file->Get(kTypeNames[metadata.m_type]));
// The Reset() below screws up the tree, so we need to re-read it from file
// before use here.
tree->Refresh();
reader->setTree(tree);
ULong64_t index = metadata.m_firstIndex;
ULong64_t endIndex = metadata.m_lastIndex + 1;
for (; index != endIndex; ++index) {
reader->read(index, edm::Service<DQMStore>().operator->(), metadata.m_run, metadata.m_lumi);
}
// Drop buffers in the TTree. This reduces memory consuption while the tree
// just sits there and waits for the next block to be read.
tree->Reset();
}
}
bool DQMRootSource::isRunOrLumiTransition() const {
if (m_currentIndex == 0) {
return false;
}
if (m_currentIndex > m_fileMetadatas.size() - 1) {
// We reached the end
return true;
}
FileMetadata previousMetadata = m_fileMetadatas[m_currentIndex - 1];
FileMetadata metadata = m_fileMetadatas[m_currentIndex];
return previousMetadata.m_run != metadata.m_run || previousMetadata.m_lumi != metadata.m_lumi;
}
void DQMRootSource::readNextItemType() {
if (m_currentIndex == 0) {
m_nextItemType = edm::InputSource::IsRun;
} else if (m_currentIndex > m_fileMetadatas.size() - 1) {
// We reached the end
m_nextItemType = edm::InputSource::IsStop;
} else {
FileMetadata previousMetadata = m_fileMetadatas[m_currentIndex - 1];
FileMetadata metadata = m_fileMetadatas[m_currentIndex];
if (previousMetadata.m_run != metadata.m_run) {
m_nextItemType = edm::InputSource::IsRun;
} else if (previousMetadata.m_lumi != metadata.m_lumi) {
m_nextItemType = edm::InputSource::IsLumi;
}
}
}
void DQMRootSource::beginRun(edm::Run& run) {
std::unique_ptr<DQMToken> product = std::make_unique<DQMToken>();
run.put(std::move(product), "DQMGenerationRecoRun");
}
void DQMRootSource::beginLuminosityBlock(edm::LuminosityBlock& lumi) {
std::unique_ptr<DQMToken> product = std::make_unique<DQMToken>();
lumi.put(std::move(product), "DQMGenerationRecoLumi");
}
bool DQMRootSource::keepIt(edm::RunNumber_t run, edm::LuminosityBlockNumber_t lumi) const {
if (m_filterOnRun != 0 && run != m_filterOnRun) {
return false;
}
if (m_lumisToProcess.empty()) {
return true;
}
for (edm::LuminosityBlockRange const& lumiToProcess : m_lumisToProcess) {
if (run >= lumiToProcess.startRun() && run <= lumiToProcess.endRun()) {
if (lumi >= lumiToProcess.startLumi() && lumi <= lumiToProcess.endLumi()) {
return true;
} else if (lumi == 0) {
return true;
}
}
}
return false;
}
void DQMRootSource::logFileAction(char const* msg, char const* fileName) const {
edm::LogAbsolute("fileAction") << std::setprecision(0) << edm::TimeOfDay() << msg << fileName;
edm::FlushMessageLog();
}
//
// const member functions
//
//
// static member functions
//
DEFINE_FWK_INPUT_SOURCE(DQMRootSource);
| 37.94716 | 120 | 0.673641 | CeliaFernandez |
73e9a0fbdf15fa564c69ca95f58af05dfe50ec65 | 4,764 | cpp | C++ | FarLight/src/FarLight/ConfigurationSystem/LocalConfigurations/Serializers/Entity/EntitySerializerConfiguration.cpp | NewBediver/FarLight | 1ffaf127f51bb88ea3f5eb8d05c04458532d5389 | [
"Apache-2.0"
] | null | null | null | FarLight/src/FarLight/ConfigurationSystem/LocalConfigurations/Serializers/Entity/EntitySerializerConfiguration.cpp | NewBediver/FarLight | 1ffaf127f51bb88ea3f5eb8d05c04458532d5389 | [
"Apache-2.0"
] | null | null | null | FarLight/src/FarLight/ConfigurationSystem/LocalConfigurations/Serializers/Entity/EntitySerializerConfiguration.cpp | NewBediver/FarLight | 1ffaf127f51bb88ea3f5eb8d05c04458532d5389 | [
"Apache-2.0"
] | null | null | null | #include "flpch.h"
#include "FarLight/ConfigurationSystem/LocalConfigurations/Serializers/Entity/EntitySerializerConfiguration.h"
#include "FarLight/ConfigurationSystem/ConfigurationManager.h"
#include "FarLight/EntityComponentSystem/Components/Tag/TagComponent.h"
#include "FarLight/EntityComponentSystem/Components/Transform/TransformComponent.h"
#include "FarLight/EntityComponentSystem/Components/Render/RenderComponent.h"
#include "FarLight/EntityComponentSystem/Components/Camera/CameraComponent.h"
namespace FarLight
{
bool EntitySerializerConfiguration::IsEntityExists(const EngineID& id) const noexcept
{
for (auto& node = m_PropertyTree.begin(); node != m_PropertyTree.end(); ++node)
{
if (node->first == m_EntityNodeName && node->second.get<std::string>("<xmlattr>.id") == id.ToString())
{
return true;
}
}
return false;
}
void EntitySerializerConfiguration::EraseEntity(const EngineID& id) noexcept
{
if (!IsEntityExists(id)) return;
for (auto& node = m_PropertyTree.begin(); node != m_PropertyTree.end(); ++node)
{
if (node->first == m_EntityNodeName && node->second.get<std::string>("<xmlattr>.id") == id.ToString())
{
node = m_PropertyTree.erase(node);
break;
}
}
}
Ref<Entity> EntitySerializerConfiguration::LoadEntity(const EngineID& id, Ref<Scene> scene) const noexcept
{
if (!IsEntityExists(id))
{
FL_CORE_ERROR("Entity with id = \"{0}\" doesn't exists!", id.ToString());
return nullptr;
}
Ref<Entity> entity = scene->CreateEntity(id);
for (auto& node = m_PropertyTree.begin(); node != m_PropertyTree.end(); ++node)
{
if (node->first == m_EntityNodeName && node->second.get<std::string>("<xmlattr>.id") == id.ToString())
{
LoadComponentIfExist<TagComponent>(node->second, "TagComponent", entity);
LoadComponentIfExist<TransformComponent>(node->second, "TransformComponent", entity);
LoadComponentIfExist<RenderComponent>(node->second, "RenderComponent", entity);
LoadComponentIfExist<CameraComponent>(node->second, "CameraComponent", entity);
break;
}
}
return entity;
}
void EntitySerializerConfiguration::SaveEntity(Ref<Entity> entity) noexcept
{
if (IsEntityExists(entity->GetId()))
{
FL_CORE_WARN("Try to save entity with the existent id = \"{0}\"!", entity->GetId().ToString());
EraseEntity(entity->GetId());
}
std::string id = entity->GetId().ToString();
boost::property_tree::ptree tmpTree;
tmpTree.put<std::string>(m_EntityNodeName + ".<xmlattr>.id", id);
SaveComponentIfExist<TagComponent>(tmpTree, "TagComponent", entity);
SaveComponentIfExist<TransformComponent>(tmpTree, "TransformComponent", entity);
SaveComponentIfExist<RenderComponent>(tmpTree, "RenderComponent", entity);
SaveComponentIfExist<CameraComponent>(tmpTree, "CameraComponent", entity);
ConfigurationManager::GetInstance().GetComponentSerializerConfiguration()->Save();
m_PropertyTree.add_child(m_EntityNodeName, tmpTree.get_child(m_EntityNodeName));
}
template<typename T>
inline void EntitySerializerConfiguration::LoadComponentIfExist(const boost::property_tree::ptree& tree, const std::string& name, Ref<Entity> entity) const noexcept
{
if (tree.find(name) != tree.not_found() && ConfigurationManager::GetInstance().GetComponentSerializerConfiguration()->IsComponentExists(EngineID(tree.get<std::string>(name))))
{
Ref<T> component = ConfigurationManager::GetInstance().GetComponentSerializerConfiguration()->LoadComponent<T>(EngineID(tree.get<std::string>(name)));
if (entity->HasAllComponents<T>())
{
entity->ReplaceComponent<T>(*(component.get()));
}
else
{
entity->AddComponent<T>(*(component.get()));
}
}
}
template<typename T>
inline void EntitySerializerConfiguration::SaveComponentIfExist(boost::property_tree::ptree& tree, const std::string& name, Ref<Entity> entity) noexcept
{
if (entity->HasAllComponents<T>())
{
tree.put<std::string>(m_EntityNodeName + "." + name, entity->GetComponent<T>().GetId().ToString());
ConfigurationManager::GetInstance().GetComponentSerializerConfiguration()->SaveComponent<T>(CreateRef<T>(entity->GetComponent<T>()));
}
}
}
| 42.535714 | 183 | 0.642317 | NewBediver |
73efb305f2fc9d060f8e139e9db8fcaa7a1e34e5 | 2,356 | hpp | C++ | src/interfaces/vectorInterfaces.hpp | lhb8125/HSF | f0cea44691a0e41bdeb5613a2d5a6cd7cda0a999 | [
"Apache-2.0"
] | null | null | null | src/interfaces/vectorInterfaces.hpp | lhb8125/HSF | f0cea44691a0e41bdeb5613a2d5a6cd7cda0a999 | [
"Apache-2.0"
] | null | null | null | src/interfaces/vectorInterfaces.hpp | lhb8125/HSF | f0cea44691a0e41bdeb5613a2d5a6cd7cda0a999 | [
"Apache-2.0"
] | null | null | null | /*
* @author: liu hongbin
* @brief: vector interfaces
* @email: [email protected]
* @date: 2020-02-22 12:09:40
* @last Modified by: lhb8125
* @last Modified time: 2020-02-22 14:48:06
*/
#ifndef VECTORINTERFACES_HPP
#define VECTORINTERFACES_HPP
#include "mpi.h"
// #include "voidtor.hpp"
// using namespace HSF;
// #define void Vector<double>
#define HSF_COMM MPI_COMM_WORLD
/**
* @brief 给串行向量v开辟空间
* @param[in] v 待开辟空间向量
* @param[in] n 向量大小
*/
void VecConstrSeq (void* v, int n);
/**
* @brief 给并行向量v开辟空间
* @param[in] v 待开辟空间向量
* @param[in] n 向量大小
* @param[in] nbghosts ghost元素个数
* @param[in] ghosts ghost元素的全局位置
*/
void VecConstrPar (void* v, int n, int nbghosts, int* ghosts);
/**
* @brief 释放向量空间
*/
void VecDestr (void* v);
/**
* @brief 给向量指定位置赋值
*/
void VecSetCmp (void* v, int ind, double value);
/**
* @brief 给向量所有位置赋相同的值
*/
void VecSetAllCmp (void* v, double value);
/**
* @brief 获得向量指定位置的值,当前进程上
* @param[in] v 取值向量
* @param[in] ind 取值位置
* @return 返回向量指定位置的值
*/
double VecGetCmp (void* v, int ind);
/**
* @brief Obtains the local ghosted representation of a parallel vector
* @param[in] vg the global vector
* @param[out] vl the local (ghosted) representation, NULL if g is not ghosted
*/
void VecGhostGetLocalForm(void* vg, void* vl);
/**
* @brief Restores the local ghosted representation of a parallel vector obtained with V_GhostGetLocalForm()
* @param[in] vg the global vector
* @param[out] vl the local (ghosted) representation
*/
void VecGhostRestoreLocalForm(void* vg, void* vl);
/**
* @brief 启动向量ghost部分更新
* @param[in] v 被更新向量
*/
void VecGhostUpdate(void* v);
/**
* @brief 复制向量
* @param[in] vfrom 被复制向量
* @param[out] vto 结果向量
*/
void VecCopy(void* vfrom, void* vto);
/**
* @brief 计算向量第二范数
* @param[in] v 被求向量
* @param[out] norm2 v的第二范数
*/
void VecNorm2(void* v, double *norm2);
/**
* @brief w = alpha * x + y
* @param[out] w 结果向量
*/
void VecWAXPY(void* w, double alpha, void* x, void* y);
/**
* @brief y = alpha * x + y
* @param[out] y 结果向量
*/
void VecAXPY(void* y, double alpha, void* x);
/**
* @brief 点乘 w = x*y
* @param[out] w 点乘后返回的结果向量
*/
void VecPointwiseMult(void* w, void* x, void* y);
/**
* @brief 获取向量的最大值及其位置
* @param[in] x 目标向量
* @param[out] loc 最大值位置
* @param[out] val 最大值
*/
void VecMax(void* v, int *loc, double *val);
/**
* @brief 向量写入到文件
*/
void VecWrite(void* x);
#endif | 18.698413 | 107 | 0.663837 | lhb8125 |
73f1486954537fdcef284a0819d92cbdb4b35bd6 | 950 | hpp | C++ | include/Animador.hpp | rickylh/Medieval-Game | 2e818ab09cdd6158b59133c56cfca8e31d1f8f3a | [
"MIT"
] | null | null | null | include/Animador.hpp | rickylh/Medieval-Game | 2e818ab09cdd6158b59133c56cfca8e31d1f8f3a | [
"MIT"
] | null | null | null | include/Animador.hpp | rickylh/Medieval-Game | 2e818ab09cdd6158b59133c56cfca8e31d1f8f3a | [
"MIT"
] | null | null | null | #pragma once
#include "Std.hpp"
class Fase;
class Animador {
private:
sf::Texture textura;
sf::IntRect sprite;
int colunas;
int coluna_atual;
float tempo_contabilizado;
float tempo_por_quadro;
bool ja_terminou;
bool ativa;
void carregarTextura(std::string caminho);
public:
Animador();
Animador(const Animador& copia);
~Animador();
//configura valores iniciais para a anima�ao
bool setConfig(std::string caminho, int colunas, float tempo_por_quadro);
void atualiza(bool para_direita, sf::RectangleShape& corpo, float tempo = -1);
//retorna booleano caso a anima�ao tenha atinjido o quadro de execu�ao
bool executou(int coluna_especifica) const;
//retorna booleano case a anima�ao tenha terminado (chegou ao ultimo sprite)
bool terminou() const;
//volta a anima�ao para o primeiro quadro
void zerar();
int getLargura() const;
void reiniciar();
bool estaAtiva() const;
};
| 23.170732 | 80 | 0.712632 | rickylh |
73f18f7b6c9ff41a9d2300929d39dbe7e218c56b | 21,468 | cc | C++ | model/std_cells/MUX2.cc | gyb1325/Desent_modification | ff0a146bddfb97269b7874092dd203be3633f97c | [
"MIT"
] | 94 | 2015-02-21T09:44:03.000Z | 2022-03-13T03:06:19.000Z | model/std_cells/MUX2.cc | gyb1325/Desent_modification | ff0a146bddfb97269b7874092dd203be3633f97c | [
"MIT"
] | null | null | null | model/std_cells/MUX2.cc | gyb1325/Desent_modification | ff0a146bddfb97269b7874092dd203be3633f97c | [
"MIT"
] | 36 | 2015-01-09T16:48:18.000Z | 2022-03-13T03:06:21.000Z | #include "model/std_cells/MUX2.h"
#include <cmath>
#include "model/PortInfo.h"
#include "model/TransitionInfo.h"
#include "model/EventInfo.h"
#include "model/std_cells/StdCellLib.h"
#include "model/std_cells/CellMacros.h"
#include "model/timing_graph/ElectricalNet.h"
#include "model/timing_graph/ElectricalDriver.h"
#include "model/timing_graph/ElectricalLoad.h"
#include "model/timing_graph/ElectricalDelay.h"
namespace DSENT
{
using std::ceil;
using std::max;
MUX2::MUX2(const String& instance_name_, const TechModel* tech_model_)
: StdCell(instance_name_, tech_model_)
{
initProperties();
}
MUX2::~MUX2()
{}
void MUX2::initProperties()
{
return;
}
void MUX2::constructModel()
{
// All constructModel should do is create Area/NDDPower/Energy Results as
// well as instantiate any sub-instances using only the hard parameters
createInputPort("A");
createInputPort("B");
createInputPort("S0");
createOutputPort("Y");
createLoad("A_Cap");
createLoad("B_Cap");
createLoad("S0_Cap");
createDelay("A_to_Y_delay");
createDelay("B_to_Y_delay");
createDelay("S0_to_Y_delay");
createDriver("Y_Ron", true);
ElectricalLoad* a_cap = getLoad("A_Cap");
ElectricalLoad* b_cap = getLoad("B_Cap");
ElectricalLoad* s0_cap = getLoad("S0_Cap");
ElectricalDelay* a_to_y_delay = getDelay("A_to_Y_delay");
ElectricalDelay* b_to_y_delay = getDelay("B_to_Y_delay");
ElectricalDelay* s0_to_y_delay = getDelay("S0_to_Y_delay");
ElectricalDriver* y_ron = getDriver("Y_Ron");
getNet("A")->addDownstreamNode(a_cap);
getNet("B")->addDownstreamNode(b_cap);
getNet("S0")->addDownstreamNode(s0_cap);
a_cap->addDownstreamNode(a_to_y_delay);
b_cap->addDownstreamNode(b_to_y_delay);
s0_cap->addDownstreamNode(s0_to_y_delay);
a_to_y_delay->addDownstreamNode(y_ron);
b_to_y_delay->addDownstreamNode(y_ron);
s0_to_y_delay->addDownstreamNode(y_ron);
y_ron->addDownstreamNode(getNet("Y"));
// Create Area result
createElectricalAtomicResults();
getEventInfo("Idle")->setStaticTransitionInfos();
// Create MUX2 Event Energy Result
createElectricalEventAtomicResult("MUX2");
return;
}
void MUX2::updateModel()
{
// Get parameters
double drive_strength = getDrivingStrength();
Map<double>* cache = getTechModel()->getStdCellLib()->getStdCellCache();
// Standard cell cache string
String cell_name = "MUX2_X" + (String) drive_strength;
// Get timing parameters
getLoad("A_Cap")->setLoadCap(cache->get(cell_name + "->Cap->A"));
getLoad("B_Cap")->setLoadCap(cache->get(cell_name + "->Cap->B"));
getLoad("S0_Cap")->setLoadCap(cache->get(cell_name + "->Cap->S0"));
getDelay("A_to_Y_delay")->setDelay(cache->get(cell_name + "->Delay->A_to_Y"));
getDelay("B_to_Y_delay")->setDelay(cache->get(cell_name + "->Delay->B_to_Y"));
getDelay("S0_to_Y_delay")->setDelay(cache->get(cell_name + "->Delay->S0_to_Y"));
getDriver("Y_Ron")->setOutputRes(cache->get(cell_name + "->DriveRes->Y"));
// Set the cell area
getAreaResult("Active")->setValue(cache->get(cell_name + "->ActiveArea"));
getAreaResult("Metal1Wire")->setValue(cache->get(cell_name + "->ActiveArea"));
return;
}
void MUX2::evaluateModel()
{
return;
}
void MUX2::useModel()
{
// Get parameters
double drive_strength = getDrivingStrength();
Map<double>* cache = getTechModel()->getStdCellLib()->getStdCellCache();
// Standard cell cache string
String cell_name = "MUX2_X" + (String) drive_strength;
// Propagate the transition and get the 0->1 transition count
propagateTransitionInfo();
double P_A = getInputPort("A")->getTransitionInfo().getProbability1();
double P_B = getInputPort("B")->getTransitionInfo().getProbability1();
double P_S0 = getInputPort("S0")->getTransitionInfo().getProbability1();
double S0_num_trans_01 = getInputPort("S0")->getTransitionInfo().getNumberTransitions01();
double Y_num_trans_01 = getOutputPort("Y")->getTransitionInfo().getNumberTransitions01();
// Calculate leakage
double leakage = 0;
leakage += cache->get(cell_name + "->Leakage->!A!B!S0") * (1 - P_A) * (1 - P_B) * (1 - P_S0);
leakage += cache->get(cell_name + "->Leakage->!A!BS0") * (1 - P_A) * (1 - P_B) * P_S0;
leakage += cache->get(cell_name + "->Leakage->!AB!S0") * (1 - P_A) * P_B * (1 - P_S0);
leakage += cache->get(cell_name + "->Leakage->!ABS0") * (1 - P_A) * P_B * P_S0;
leakage += cache->get(cell_name + "->Leakage->A!B!S0") * P_A * (1 - P_B) * (1 - P_S0);
leakage += cache->get(cell_name + "->Leakage->A!BS0") * P_A * (1 - P_B) * P_S0;
leakage += cache->get(cell_name + "->Leakage->AB!S0") * P_A * P_B * (1 - P_S0);
leakage += cache->get(cell_name + "->Leakage->ABS0") * P_A * P_B * P_S0;
getNddPowerResult("Leakage")->setValue(leakage);
// Get VDD
double vdd = getTechModel()->get("Vdd");
// Get capacitances
double s0_b_cap = cache->get(cell_name + "->Cap->S0_b");
double y_bar_cap = cache->get(cell_name + "->Cap->Y_b");
double y_cap = cache->get(cell_name + "->Cap->Y");
double y_load_cap = getNet("Y")->getTotalDownstreamCap();
// Create mux2 event energy
double mux2_event_energy = 0.0;
mux2_event_energy += (s0_b_cap) * S0_num_trans_01;
mux2_event_energy += (y_bar_cap + y_cap + y_load_cap) * Y_num_trans_01;
mux2_event_energy *= vdd * vdd;
getEventResult("MUX2")->setValue(mux2_event_energy);
return;
}
void MUX2::propagateTransitionInfo()
{
// Get input signal transition info
const TransitionInfo& trans_A = getInputPort("A")->getTransitionInfo();
const TransitionInfo& trans_B = getInputPort("B")->getTransitionInfo();
const TransitionInfo& trans_S0 = getInputPort("S0")->getTransitionInfo();
// Scale all transition information to the highest freq multiplier
double max_freq_mult = max(max(trans_A.getFrequencyMultiplier(), trans_B.getFrequencyMultiplier()), trans_S0.getFrequencyMultiplier());
const TransitionInfo& scaled_trans_A = trans_A.scaleFrequencyMultiplier(max_freq_mult);
const TransitionInfo& scaled_trans_B = trans_B.scaleFrequencyMultiplier(max_freq_mult);
const TransitionInfo& scaled_trans_S0 = trans_S0.scaleFrequencyMultiplier(max_freq_mult);
// Compute the probability of each transition on a given cycle
double A_prob_00 = scaled_trans_A.getNumberTransitions00() / max_freq_mult;
double A_prob_01 = scaled_trans_A.getNumberTransitions01() / max_freq_mult;
double A_prob_10 = A_prob_01;
double A_prob_11 = scaled_trans_A.getNumberTransitions11() / max_freq_mult;
double B_prob_00 = scaled_trans_B.getNumberTransitions00() / max_freq_mult;
double B_prob_01 = scaled_trans_B.getNumberTransitions01() / max_freq_mult;
double B_prob_10 = B_prob_01;
double B_prob_11 = scaled_trans_B.getNumberTransitions11() / max_freq_mult;
double S0_prob_00 = scaled_trans_S0.getNumberTransitions00() / max_freq_mult;
double S0_prob_01 = scaled_trans_S0.getNumberTransitions01() / max_freq_mult;
double S0_prob_10 = S0_prob_01;
double S0_prob_11 = scaled_trans_S0.getNumberTransitions11() / max_freq_mult;
// Compute output probabilities
double Y_prob_00 = S0_prob_00 * A_prob_00 +
S0_prob_01 * (A_prob_00 + A_prob_01) * (B_prob_00 + B_prob_10) +
S0_prob_10 * (A_prob_00 + A_prob_10) * (B_prob_00 + B_prob_01) +
S0_prob_11 * B_prob_00;
double Y_prob_01 = S0_prob_00 * A_prob_01 +
S0_prob_01 * (A_prob_00 + A_prob_01) * (B_prob_01 + B_prob_11) +
S0_prob_10 * (A_prob_01 + A_prob_11) * (B_prob_00 + B_prob_01) +
S0_prob_11 * B_prob_01;
double Y_prob_11 = S0_prob_00 * A_prob_11 +
S0_prob_01 * (A_prob_10 + A_prob_11) * (B_prob_01 + B_prob_11) +
S0_prob_10 * (A_prob_01 + A_prob_11) * (B_prob_10 + B_prob_11) +
S0_prob_11 * B_prob_11;
// Check that probabilities add up to 1.0 with some finite tolerance
ASSERT(LibUtil::Math::isEqual((Y_prob_00 + Y_prob_01 + Y_prob_01 + Y_prob_11), 1.0),
"[Error] " + getInstanceName() + "Output transition probabilities must add up to 1 (" +
(String) Y_prob_00 + ", " + (String) Y_prob_01 + ", " + (String) Y_prob_11 + ")!");
// Turn probability of transitions per cycle into number of transitions per time unit
TransitionInfo trans_Y(Y_prob_00 * max_freq_mult, Y_prob_01 * max_freq_mult, Y_prob_11 * max_freq_mult);
getOutputPort("Y")->setTransitionInfo(trans_Y);
return;
}
// Creates the standard cell, characterizes and abstracts away the details
void MUX2::cacheStdCell(StdCellLib* cell_lib_, double drive_strength_)
{
// Get parameters
double gate_pitch = cell_lib_->getTechModel()->get("Gate->PitchContacted");
Map<double>* cache = cell_lib_->getStdCellCache();
// Standard cell cache string
String cell_name = "MUX2_X" + (String) drive_strength_;
Log::printLine("=== " + cell_name + " ===");
// Now actually build the full standard cell model
createInputPort("A");
createInputPort("B");
createInputPort("S0");
createOutputPort("Y");
createNet("S0_b");
createNet("Y_b");
// Adds macros
CellMacros::addInverter(this, "INV1", false, true, "S0", "S0_b");
CellMacros::addInverter(this, "INV2", false, true, "Y_b", "Y");
CellMacros::addTristate(this, "INVZ1", true, true, true, true, "A", "S0_b", "S0", "Y_b");
CellMacros::addTristate(this, "INVZ2", true, true, true, true, "B", "S0", "S0_b", "Y_b");
// I have no idea how to size each of the parts haha
CellMacros::updateInverter(this, "INV1", drive_strength_ * 0.250);
CellMacros::updateInverter(this, "INV2", drive_strength_ * 1.000);
CellMacros::updateTristate(this, "INVZ1", drive_strength_ * 0.500);
CellMacros::updateTristate(this, "INVZ2", drive_strength_ * 0.500);
// Cache area result
double area = 0.0;
area += gate_pitch * getTotalHeight() * 1;
area += gate_pitch * getTotalHeight() * getGenProperties()->get("INV1_GatePitches").toDouble();
area += gate_pitch * getTotalHeight() * getGenProperties()->get("INV2_GatePitches").toDouble();
area += gate_pitch * getTotalHeight() * getGenProperties()->get("INVZ1_GatePitches").toDouble();
area += gate_pitch * getTotalHeight() * getGenProperties()->get("INVZ2_GatePitches").toDouble();
cache->set(cell_name + "->ActiveArea", area);
Log::printLine(cell_name + "->ActiveArea=" + (String) area);
// --------------------------------------------------------------------
// Cache Leakage Power (for every single signal combination)
// --------------------------------------------------------------------
double leakage_000 = 0; //!A, !B, !S0
double leakage_001 = 0; //!A, !B, S0
double leakage_010 = 0; //!A, B, !S0
double leakage_011 = 0; //!A, B, S0
double leakage_100 = 0; //A, !B, !S0
double leakage_101 = 0; //A, !B, S0
double leakage_110 = 0; //A, B, !S0
double leakage_111 = 0; //A, B, S0
//This is so painful...
leakage_000 += getGenProperties()->get("INV1_LeakagePower_0").toDouble();
leakage_000 += getGenProperties()->get("INV2_LeakagePower_1").toDouble();
leakage_000 += getGenProperties()->get("INVZ1_LeakagePower_100_1").toDouble();
leakage_000 += getGenProperties()->get("INVZ2_LeakagePower_010_1").toDouble();
leakage_001 += getGenProperties()->get("INV1_LeakagePower_1").toDouble();
leakage_001 += getGenProperties()->get("INV2_LeakagePower_1").toDouble();
leakage_001 += getGenProperties()->get("INVZ1_LeakagePower_010_1").toDouble();
leakage_001 += getGenProperties()->get("INVZ2_LeakagePower_100_1").toDouble();
leakage_010 += getGenProperties()->get("INV1_LeakagePower_0").toDouble();
leakage_010 += getGenProperties()->get("INV2_LeakagePower_1").toDouble();
leakage_010 += getGenProperties()->get("INVZ1_LeakagePower_100_1").toDouble();
leakage_010 += getGenProperties()->get("INVZ2_LeakagePower_011_1").toDouble();
leakage_011 += getGenProperties()->get("INV1_LeakagePower_1").toDouble();
leakage_011 += getGenProperties()->get("INV2_LeakagePower_0").toDouble();
leakage_011 += getGenProperties()->get("INVZ1_LeakagePower_010_0").toDouble();
leakage_011 += getGenProperties()->get("INVZ2_LeakagePower_101_0").toDouble();
leakage_100 += getGenProperties()->get("INV1_LeakagePower_0").toDouble();
leakage_100 += getGenProperties()->get("INV2_LeakagePower_0").toDouble();
leakage_100 += getGenProperties()->get("INVZ1_LeakagePower_101_0").toDouble();
leakage_100 += getGenProperties()->get("INVZ2_LeakagePower_010_0").toDouble();
leakage_101 += getGenProperties()->get("INV1_LeakagePower_1").toDouble();
leakage_101 += getGenProperties()->get("INV2_LeakagePower_0").toDouble();
leakage_101 += getGenProperties()->get("INVZ1_LeakagePower_011_1").toDouble();
leakage_101 += getGenProperties()->get("INVZ2_LeakagePower_100_1").toDouble();
leakage_110 += getGenProperties()->get("INV1_LeakagePower_1").toDouble();
leakage_110 += getGenProperties()->get("INV2_LeakagePower_1").toDouble();
leakage_110 += getGenProperties()->get("INVZ1_LeakagePower_101_0").toDouble();
leakage_110 += getGenProperties()->get("INVZ2_LeakagePower_011_0").toDouble();
leakage_111 += getGenProperties()->get("INV1_LeakagePower_1").toDouble();
leakage_111 += getGenProperties()->get("INV2_LeakagePower_1").toDouble();
leakage_111 += getGenProperties()->get("INVZ1_LeakagePower_011_0").toDouble();
leakage_111 += getGenProperties()->get("INVZ2_LeakagePower_101_0").toDouble();
cache->set(cell_name + "->Leakage->!A!B!S0", leakage_000);
cache->set(cell_name + "->Leakage->!A!BS0", leakage_001);
cache->set(cell_name + "->Leakage->!AB!S0", leakage_010);
cache->set(cell_name + "->Leakage->!ABS0", leakage_011);
cache->set(cell_name + "->Leakage->A!B!S0", leakage_100);
cache->set(cell_name + "->Leakage->A!BS0", leakage_101);
cache->set(cell_name + "->Leakage->AB!S0", leakage_110);
cache->set(cell_name + "->Leakage->ABS0", leakage_111);
Log::printLine(cell_name + "->Leakage->!A!B!S0=" + (String) leakage_000);
Log::printLine(cell_name + "->Leakage->!A!BS0=" + (String) leakage_001);
Log::printLine(cell_name + "->Leakage->!AB!S0=" + (String) leakage_010);
Log::printLine(cell_name + "->Leakage->!ABS0=" + (String) leakage_011);
Log::printLine(cell_name + "->Leakage->A!B!S0=" + (String) leakage_100);
Log::printLine(cell_name + "->Leakage->A!BS0=" + (String) leakage_101);
Log::printLine(cell_name + "->Leakage->AB!S0=" + (String) leakage_110);
Log::printLine(cell_name + "->Leakage->ABS0=" + (String) leakage_111);
// Cache event energy results
/*
double event_a_flip = 0.0;
event_a_flip += getGenProperties()->get("INVZ1_A_Flip").toDouble();
cache->set(cell_name + "->Event_A_Flip", event_a_flip);
Log::printLine(cell_name + "->Event_A_Flip=" + (String) event_a_flip);
double event_b_flip = 0.0;
event_b_flip += getGenProperties()->get("INVZ1_A_Flip").toDouble();
cache->set(cell_name + "->Event_B_Flip", event_b_flip);
Log::printLine(cell_name + "->Event_B_Flip=" + (String) event_b_flip);
double event_s0_flip = 0.0;
event_s0_flip += getGenProperties()->get("INV1_A_Flip").toDouble();
event_s0_flip += getGenProperties()->get("INV1_ZN_Flip").toDouble();
event_s0_flip += getGenProperties()->get("INVZ1_OE_Flip").toDouble() + getGenProperties()->get("INVZ1_OEN_Flip").toDouble();
event_s0_flip += getGenProperties()->get("INVZ2_OE_Flip").toDouble() + getGenProperties()->get("INVZ2_OEN_Flip").toDouble();
cache->set(cell_name + "->Event_S0_Flip", event_s0_flip);
Log::printLine(cell_name + "->Event_S0_Flip=" + (String) event_s0_flip);
double event_y_flip = 0.0;
event_y_flip += getGenProperties()->get("INVZ1_ZN_Flip").toDouble();
event_y_flip += getGenProperties()->get("INVZ2_ZN_Flip").toDouble();
event_y_flip += getGenProperties()->get("INV2_A_Flip").toDouble();
event_y_flip += getGenProperties()->get("INV2_ZN_Flip").toDouble();
cache->set(cell_name + "->Event_Y_Flip", event_y_flip);
Log::printLine(cell_name + "->Event_Y_Flip=" + (String) event_y_flip);
double a_cap = getLoad("INVZ1_CgA")->getLoadCap();
double b_cap = getLoad("INVZ2_CgA")->getLoadCap();
double s0_cap = getLoad("INV1_CgA")->getLoadCap() + getLoad("INVZ1_CgOEN")->getLoadCap() + getLoad("INVZ2_CgOE")->getLoadCap();
double y_ron = getDriver("INV2_RonZN")->getOutputRes();
*/
// --------------------------------------------------------------------
// --------------------------------------------------------------------
// Get Node capacitances
// --------------------------------------------------------------------
double a_cap = getNet("A")->getTotalDownstreamCap();
double b_cap = getNet("B")->getTotalDownstreamCap();
double s0_cap = getNet("S0")->getTotalDownstreamCap();
double s0_b_cap = getNet("S0_b")->getTotalDownstreamCap();
double y_b_cap = getNet("Y_b")->getTotalDownstreamCap();
double y_cap = getNet("Y")->getTotalDownstreamCap();
cache->set(cell_name + "->Cap->A", a_cap);
cache->set(cell_name + "->Cap->B", b_cap);
cache->set(cell_name + "->Cap->S0", s0_cap);
cache->set(cell_name + "->Cap->S0_b", s0_b_cap);
cache->set(cell_name + "->Cap->Y_b", y_b_cap);
cache->set(cell_name + "->Cap->Y", y_cap);
Log::printLine(cell_name + "->Cap->A=" + (String) a_cap);
Log::printLine(cell_name + "->Cap->B=" + (String) b_cap);
Log::printLine(cell_name + "->Cap->S0=" + (String) s0_cap);
Log::printLine(cell_name + "->Cap->S0_b=" + (String) s0_b_cap);
Log::printLine(cell_name + "->Cap->Y_b=" + (String) y_b_cap);
Log::printLine(cell_name + "->Cap->Y=" + (String) y_cap);
// --------------------------------------------------------------------
// --------------------------------------------------------------------
// Build Internal Delay Model
// --------------------------------------------------------------------
// Build abstracted timing model
double y_ron = getDriver("INV2_RonZN")->getOutputRes();
double a_to_y_delay = 0.0;
a_to_y_delay += getDriver("INVZ1_RonZN")->calculateDelay();
a_to_y_delay += getDriver("INV2_RonZN")->calculateDelay();
double b_to_y_delay = 0.0;
b_to_y_delay += getDriver("INVZ1_RonZN")->calculateDelay();
b_to_y_delay += getDriver("INV2_RonZN")->calculateDelay();
double s0_to_y_delay = 0.0;
s0_to_y_delay += getDriver("INV1_RonZN")->calculateDelay();
s0_to_y_delay += max(getDriver("INVZ1_RonZN")->calculateDelay(), getDriver("INVZ1_RonZN")->calculateDelay());
s0_to_y_delay += getDriver("INV2_RonZN")->calculateDelay();
cache->set(cell_name + "->DriveRes->Y", y_ron);
cache->set(cell_name + "->Delay->A_to_Y", a_to_y_delay);
cache->set(cell_name + "->Delay->B_to_Y", b_to_y_delay);
cache->set(cell_name + "->Delay->S0_to_Y", s0_to_y_delay);
Log::printLine(cell_name + "->DriveRes->Y=" + (String) y_ron);
Log::printLine(cell_name + "->Delay->A_to_Y=" + (String) a_to_y_delay);
Log::printLine(cell_name + "->Delay->B_to_Y=" + (String) b_to_y_delay);
Log::printLine(cell_name + "->Delay->S0_to_Y=" + (String) s0_to_y_delay);
// --------------------------------------------------------------------
return;
}
} // namespace DSENT
| 50.992874 | 143 | 0.602851 | gyb1325 |
73f36b14922041ca588a53c2303aabd62200aeb4 | 3,349 | cpp | C++ | src/globals.cpp | mad-mix/my-little-investigations | 8d40d117a4de44c337dd4d015cfcfa44c9de29e7 | [
"MIT"
] | null | null | null | src/globals.cpp | mad-mix/my-little-investigations | 8d40d117a4de44c337dd4d015cfcfa44c9de29e7 | [
"MIT"
] | null | null | null | src/globals.cpp | mad-mix/my-little-investigations | 8d40d117a4de44c337dd4d015cfcfa44c9de29e7 | [
"MIT"
] | null | null | null | /**
* Provides global variables for use in the game's source code.
*
* @author GabuEx, dawnmew
* @since 1.0
*
* Licensed under the MIT License.
*
* Copyright (c) 2014 Equestrian Dreamers
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#include "globals.h"
#ifdef GAME_EXECUTABLE
#include "MLIException.h"
#include <SDL2/SDL.h>
#endif
SDL_Window *gpWindow = NULL;
SDL_Renderer *gpRenderer = NULL;
Uint16 gScreenWidth = 0;
Uint16 gScreenHeight = 0;
int gMaxTextureWidth = 0;
int gMaxTextureHeight = 0;
#ifdef GAME_EXECUTABLE
bool gIsFullscreen = false;
double gScreenScale = 0.0;
Uint16 gHorizontalOffset = 0;
Uint16 gVerticalOffset = 0;
int gTexturesRecreatedCount = 0;
bool gIsSavingScreenshot = false;
Uint16 gScreenshotWidth = 0;
Uint16 gScreenshotHeight = 0;
#endif
double gFramerate = 0.0;
string gTitle = "";
#ifdef GAME_EXECUTABLE
SDL_threadID gUiThreadId = 0;
string gCaseFilePath = "";
string gSaveFilePath = "";
bool gEnableTutorials = true;
bool gEnableHints = true;
bool gEnableFullscreen = false;
bool gEnableSkippingUnseenDialog = false;
#ifdef ENABLE_DEBUG_MODE
bool gEnableDebugMode = false;
#endif
double gBackgroundMusicVolume = 0.2;
double gSoundEffectsVolume = 0.67;
double gVoiceVolume = 0.5;
bool gEnableTutorialsDefault = gEnableTutorials;
bool gEnableHintsDefault = gEnableHints;
bool gEnableFullscreenDefault = gEnableFullscreen;
bool gEnableSkippingUnseenDialogDefault = gEnableSkippingUnseenDialog;
#ifdef ENABLE_DEBUG_MODE
bool gEnableDebugModeDefault = gEnableDebugMode;
#endif
double gBackgroundMusicVolumeDefault = gBackgroundMusicVolume;
double gSoundEffectsVolumeDefault = gSoundEffectsVolume;
double gVoiceVolumeDefault = gVoiceVolume;
vector<string> gCompletedCaseGuidList;
map<string, bool> gCaseIsSignedByFilePathMap;
vector<string> gDialogsSeenList;
bool gToggleFullscreen = false;
#else
CURL *gpCurlHandle = NULL;
#endif
bool gIsQuitting = false;
Version gVersion(1, 0, 0);
#ifdef UPDATER
string gVersionsXmlFilePath = "";
#endif
#ifdef GAME_EXECUTABLE
LocalizableContent *pgLocalizableContent = NULL;
#endif
void EnsureUIThread()
{
#ifdef GAME_EXECUTABLE
SDL_threadID currentThreadId = SDL_ThreadID();
if (currentThreadId != gUiThreadId)
{
throw new MLIException("This method can only be called on the UI thread.");
}
#endif
}
| 27.677686 | 83 | 0.776351 | mad-mix |
73f5d37c848c88088ac7fd1c24e98c0bc7ea3dc6 | 1,540 | cpp | C++ | src/lib/OpenEXR/ImfRational.cpp | msercheli/openexr | 9912f6b3886f6c695547747d70e19b98c0e38d59 | [
"BSD-3-Clause"
] | 517 | 2018-08-11T02:18:47.000Z | 2022-03-27T05:31:40.000Z | src/lib/OpenEXR/ImfRational.cpp | msercheli/openexr | 9912f6b3886f6c695547747d70e19b98c0e38d59 | [
"BSD-3-Clause"
] | 391 | 2018-07-31T21:28:52.000Z | 2022-03-28T16:51:18.000Z | src/lib/OpenEXR/ImfRational.cpp | msercheli/openexr | 9912f6b3886f6c695547747d70e19b98c0e38d59 | [
"BSD-3-Clause"
] | 189 | 2018-12-22T15:39:26.000Z | 2022-03-16T17:03:20.000Z | //
// SPDX-License-Identifier: BSD-3-Clause
// Copyright (c) Contributors to the OpenEXR Project.
//
//-----------------------------------------------------------------------------
//
// Rational numbers
//
// The double-to-Rational conversion code below
// was contributed to OpenEXR by Greg Ward.
//
//-----------------------------------------------------------------------------
#include <ImfRational.h>
#include <cmath>
using namespace std;
#include "ImfNamespace.h"
OPENEXR_IMF_INTERNAL_NAMESPACE_SOURCE_ENTER
namespace {
double
frac (double x, double e)
{
return x - floor (x + e);
}
double
square (double x)
{
return x * x;
}
double
denom (double x, double e)
{
if (e > frac (x, e))
{
return 1;
}
else
{
double r = frac (1 / x, e);
if (e > r)
{
return floor (1 / x + e);
}
else
{
return denom (frac (1 / r, e), e / square (x * r)) +
floor (1 / x + e) * denom (frac (1 / x, e), e / square (x));
}
}
}
} // namespace
Rational::Rational (double x)
{
int sign;
if (x >= 0)
{
sign = 1; // positive
}
else if (x < 0)
{
sign = -1; // negative
x = -x;
}
else
{
n = 0; // NaN
d = 0;
return;
}
if (x >= (1U << 31) - 0.5)
{
n = sign; // infinity
d = 0;
return;
}
double e = (x < 1? 1: x) / (1U << 30);
d = (unsigned int) denom (x, e);
n = sign * (int) floor (x * d + 0.5);
}
OPENEXR_IMF_INTERNAL_NAMESPACE_SOURCE_EXIT
| 15.555556 | 79 | 0.453247 | msercheli |
73f8dc4c074982a878f59716c078a9ac87a3b08f | 5,525 | cpp | C++ | src/plugins/follow_me/follow_me.cpp | rworrall/MAVSDK | 634f171bb5b492e2d5bd6453f54e7e88c603899e | [
"BSD-3-Clause"
] | 275 | 2019-06-13T17:50:40.000Z | 2022-03-28T01:03:01.000Z | src/plugins/follow_me/follow_me.cpp | rworrall/MAVSDK | 634f171bb5b492e2d5bd6453f54e7e88c603899e | [
"BSD-3-Clause"
] | 655 | 2019-06-07T13:08:12.000Z | 2022-03-23T04:51:21.000Z | src/plugins/follow_me/follow_me.cpp | SEESAI/MAVSDK | 5a9289eb09eb6b13f24e9d8d69f5644d2210d6b2 | [
"BSD-3-Clause"
] | 299 | 2019-06-10T06:58:58.000Z | 2022-03-25T04:14:34.000Z | // WARNING: THIS FILE IS AUTOGENERATED! As such, it should not be edited.
// Edits need to be made to the proto files
// (see https://github.com/mavlink/MAVSDK-Proto/blob/master/protos/follow_me/follow_me.proto)
#include <iomanip>
#include "follow_me_impl.h"
#include "plugins/follow_me/follow_me.h"
namespace mavsdk {
using Config = FollowMe::Config;
using TargetLocation = FollowMe::TargetLocation;
FollowMe::FollowMe(System& system) : PluginBase(), _impl{std::make_unique<FollowMeImpl>(system)} {}
FollowMe::FollowMe(std::shared_ptr<System> system) :
PluginBase(),
_impl{std::make_unique<FollowMeImpl>(system)}
{}
FollowMe::~FollowMe() {}
FollowMe::Config FollowMe::get_config() const
{
return _impl->get_config();
}
FollowMe::Result FollowMe::set_config(Config config) const
{
return _impl->set_config(config);
}
bool FollowMe::is_active() const
{
return _impl->is_active();
}
FollowMe::Result FollowMe::set_target_location(TargetLocation location) const
{
return _impl->set_target_location(location);
}
FollowMe::TargetLocation FollowMe::get_last_location() const
{
return _impl->get_last_location();
}
FollowMe::Result FollowMe::start() const
{
return _impl->start();
}
FollowMe::Result FollowMe::stop() const
{
return _impl->stop();
}
std::ostream&
operator<<(std::ostream& str, FollowMe::Config::FollowDirection const& follow_direction)
{
switch (follow_direction) {
case FollowMe::Config::FollowDirection::None:
return str << "None";
case FollowMe::Config::FollowDirection::Behind:
return str << "Behind";
case FollowMe::Config::FollowDirection::Front:
return str << "Front";
case FollowMe::Config::FollowDirection::FrontRight:
return str << "Front Right";
case FollowMe::Config::FollowDirection::FrontLeft:
return str << "Front Left";
default:
return str << "Unknown";
}
}
bool operator==(const FollowMe::Config& lhs, const FollowMe::Config& rhs)
{
return ((std::isnan(rhs.min_height_m) && std::isnan(lhs.min_height_m)) ||
rhs.min_height_m == lhs.min_height_m) &&
((std::isnan(rhs.follow_distance_m) && std::isnan(lhs.follow_distance_m)) ||
rhs.follow_distance_m == lhs.follow_distance_m) &&
(rhs.follow_direction == lhs.follow_direction) &&
((std::isnan(rhs.responsiveness) && std::isnan(lhs.responsiveness)) ||
rhs.responsiveness == lhs.responsiveness);
}
std::ostream& operator<<(std::ostream& str, FollowMe::Config const& config)
{
str << std::setprecision(15);
str << "config:" << '\n' << "{\n";
str << " min_height_m: " << config.min_height_m << '\n';
str << " follow_distance_m: " << config.follow_distance_m << '\n';
str << " follow_direction: " << config.follow_direction << '\n';
str << " responsiveness: " << config.responsiveness << '\n';
str << '}';
return str;
}
bool operator==(const FollowMe::TargetLocation& lhs, const FollowMe::TargetLocation& rhs)
{
return ((std::isnan(rhs.latitude_deg) && std::isnan(lhs.latitude_deg)) ||
rhs.latitude_deg == lhs.latitude_deg) &&
((std::isnan(rhs.longitude_deg) && std::isnan(lhs.longitude_deg)) ||
rhs.longitude_deg == lhs.longitude_deg) &&
((std::isnan(rhs.absolute_altitude_m) && std::isnan(lhs.absolute_altitude_m)) ||
rhs.absolute_altitude_m == lhs.absolute_altitude_m) &&
((std::isnan(rhs.velocity_x_m_s) && std::isnan(lhs.velocity_x_m_s)) ||
rhs.velocity_x_m_s == lhs.velocity_x_m_s) &&
((std::isnan(rhs.velocity_y_m_s) && std::isnan(lhs.velocity_y_m_s)) ||
rhs.velocity_y_m_s == lhs.velocity_y_m_s) &&
((std::isnan(rhs.velocity_z_m_s) && std::isnan(lhs.velocity_z_m_s)) ||
rhs.velocity_z_m_s == lhs.velocity_z_m_s);
}
std::ostream& operator<<(std::ostream& str, FollowMe::TargetLocation const& target_location)
{
str << std::setprecision(15);
str << "target_location:" << '\n' << "{\n";
str << " latitude_deg: " << target_location.latitude_deg << '\n';
str << " longitude_deg: " << target_location.longitude_deg << '\n';
str << " absolute_altitude_m: " << target_location.absolute_altitude_m << '\n';
str << " velocity_x_m_s: " << target_location.velocity_x_m_s << '\n';
str << " velocity_y_m_s: " << target_location.velocity_y_m_s << '\n';
str << " velocity_z_m_s: " << target_location.velocity_z_m_s << '\n';
str << '}';
return str;
}
std::ostream& operator<<(std::ostream& str, FollowMe::Result const& result)
{
switch (result) {
case FollowMe::Result::Unknown:
return str << "Unknown";
case FollowMe::Result::Success:
return str << "Success";
case FollowMe::Result::NoSystem:
return str << "No System";
case FollowMe::Result::ConnectionError:
return str << "Connection Error";
case FollowMe::Result::Busy:
return str << "Busy";
case FollowMe::Result::CommandDenied:
return str << "Command Denied";
case FollowMe::Result::Timeout:
return str << "Timeout";
case FollowMe::Result::NotActive:
return str << "Not Active";
case FollowMe::Result::SetConfigFailed:
return str << "Set Config Failed";
default:
return str << "Unknown";
}
}
} // namespace mavsdk | 35.416667 | 99 | 0.631131 | rworrall |
73fbab9e4e3fd2e51524449a52051cf952fc847a | 11,265 | hpp | C++ | include/System/Security/Cryptography/AesTransform.hpp | marksteward/BeatSaber-Quest-Codegen | a76f063f71cef207a9f048ad7613835f554911a7 | [
"Unlicense"
] | null | null | null | include/System/Security/Cryptography/AesTransform.hpp | marksteward/BeatSaber-Quest-Codegen | a76f063f71cef207a9f048ad7613835f554911a7 | [
"Unlicense"
] | null | null | null | include/System/Security/Cryptography/AesTransform.hpp | marksteward/BeatSaber-Quest-Codegen | a76f063f71cef207a9f048ad7613835f554911a7 | [
"Unlicense"
] | null | null | null | // Autogenerated from CppHeaderCreator
// Created by Sc2ad
// =========================================================================
#pragma once
// Begin includes
#include "extern/beatsaber-hook/shared/utils/typedefs.h"
#include "extern/beatsaber-hook/shared/utils/byref.hpp"
// Including type: Mono.Security.Cryptography.SymmetricTransform
#include "Mono/Security/Cryptography/SymmetricTransform.hpp"
#include "extern/beatsaber-hook/shared/utils/il2cpp-utils-methods.hpp"
#include "extern/beatsaber-hook/shared/utils/il2cpp-utils-properties.hpp"
#include "extern/beatsaber-hook/shared/utils/il2cpp-utils-fields.hpp"
#include "extern/beatsaber-hook/shared/utils/utils.h"
// Completed includes
// Begin forward declares
// Forward declaring namespace: System::Security::Cryptography
namespace System::Security::Cryptography {
// Forward declaring type: Aes
class Aes;
}
// Completed forward declares
// Type namespace: System.Security.Cryptography
namespace System::Security::Cryptography {
// Size: 0x68
#pragma pack(push, 1)
// Autogenerated type: System.Security.Cryptography.AesTransform
// [TokenAttribute] Offset: FFFFFFFF
class AesTransform : public Mono::Security::Cryptography::SymmetricTransform {
public:
// private System.UInt32[] expandedKey
// Size: 0x8
// Offset: 0x58
::Array<uint>* expandedKey;
// Field size check
static_assert(sizeof(::Array<uint>*) == 0x8);
// private System.Int32 Nk
// Size: 0x4
// Offset: 0x60
int Nk;
// Field size check
static_assert(sizeof(int) == 0x4);
// private System.Int32 Nr
// Size: 0x4
// Offset: 0x64
int Nr;
// Field size check
static_assert(sizeof(int) == 0x4);
// Creating value type constructor for type: AesTransform
AesTransform(::Array<uint>* expandedKey_ = {}, int Nk_ = {}, int Nr_ = {}) noexcept : expandedKey{expandedKey_}, Nk{Nk_}, Nr{Nr_} {}
// Get static field: static private readonly System.UInt32[] Rcon
static ::Array<uint>* _get_Rcon();
// Set static field: static private readonly System.UInt32[] Rcon
static void _set_Rcon(::Array<uint>* value);
// Get static field: static private readonly System.Byte[] SBox
static ::Array<uint8_t>* _get_SBox();
// Set static field: static private readonly System.Byte[] SBox
static void _set_SBox(::Array<uint8_t>* value);
// Get static field: static private readonly System.Byte[] iSBox
static ::Array<uint8_t>* _get_iSBox();
// Set static field: static private readonly System.Byte[] iSBox
static void _set_iSBox(::Array<uint8_t>* value);
// Get static field: static private readonly System.UInt32[] T0
static ::Array<uint>* _get_T0();
// Set static field: static private readonly System.UInt32[] T0
static void _set_T0(::Array<uint>* value);
// Get static field: static private readonly System.UInt32[] T1
static ::Array<uint>* _get_T1();
// Set static field: static private readonly System.UInt32[] T1
static void _set_T1(::Array<uint>* value);
// Get static field: static private readonly System.UInt32[] T2
static ::Array<uint>* _get_T2();
// Set static field: static private readonly System.UInt32[] T2
static void _set_T2(::Array<uint>* value);
// Get static field: static private readonly System.UInt32[] T3
static ::Array<uint>* _get_T3();
// Set static field: static private readonly System.UInt32[] T3
static void _set_T3(::Array<uint>* value);
// Get static field: static private readonly System.UInt32[] iT0
static ::Array<uint>* _get_iT0();
// Set static field: static private readonly System.UInt32[] iT0
static void _set_iT0(::Array<uint>* value);
// Get static field: static private readonly System.UInt32[] iT1
static ::Array<uint>* _get_iT1();
// Set static field: static private readonly System.UInt32[] iT1
static void _set_iT1(::Array<uint>* value);
// Get static field: static private readonly System.UInt32[] iT2
static ::Array<uint>* _get_iT2();
// Set static field: static private readonly System.UInt32[] iT2
static void _set_iT2(::Array<uint>* value);
// Get static field: static private readonly System.UInt32[] iT3
static ::Array<uint>* _get_iT3();
// Set static field: static private readonly System.UInt32[] iT3
static void _set_iT3(::Array<uint>* value);
// Get instance field: private System.UInt32[] expandedKey
::Array<uint>* _get_expandedKey();
// Set instance field: private System.UInt32[] expandedKey
void _set_expandedKey(::Array<uint>* value);
// Get instance field: private System.Int32 Nk
int _get_Nk();
// Set instance field: private System.Int32 Nk
void _set_Nk(int value);
// Get instance field: private System.Int32 Nr
int _get_Nr();
// Set instance field: private System.Int32 Nr
void _set_Nr(int value);
// public System.Void .ctor(System.Security.Cryptography.Aes algo, System.Boolean encryption, System.Byte[] key, System.Byte[] iv)
// Offset: 0x1DE7F60
template<::il2cpp_utils::CreationType creationType = ::il2cpp_utils::CreationType::Temporary>
static AesTransform* New_ctor(System::Security::Cryptography::Aes* algo, bool encryption, ::Array<uint8_t>* key, ::Array<uint8_t>* iv) {
static auto ___internal__logger = ::Logger::get().WithContext("System::Security::Cryptography::AesTransform::.ctor");
return THROW_UNLESS((::il2cpp_utils::New<AesTransform*, creationType>(algo, encryption, key, iv)));
}
// static private System.Void .cctor()
// Offset: 0x1DECD74
static void _cctor();
// private System.UInt32 SubByte(System.UInt32 a)
// Offset: 0x1DE905C
uint SubByte(uint a);
// private System.Void Encrypt128(System.Byte[] indata, System.Byte[] outdata, System.UInt32[] ekey)
// Offset: 0x1DE914C
void Encrypt128(::Array<uint8_t>* indata, ::Array<uint8_t>* outdata, ::Array<uint>* ekey);
// private System.Void Decrypt128(System.Byte[] indata, System.Byte[] outdata, System.UInt32[] ekey)
// Offset: 0x1DEAF64
void Decrypt128(::Array<uint8_t>* indata, ::Array<uint8_t>* outdata, ::Array<uint>* ekey);
// protected override System.Void ECB(System.Byte[] input, System.Byte[] output)
// Offset: 0x1DE9138
// Implemented from: Mono.Security.Cryptography.SymmetricTransform
// Base method: System.Void SymmetricTransform::ECB(System.Byte[] input, System.Byte[] output)
void ECB(::Array<uint8_t>* input, ::Array<uint8_t>* output);
}; // System.Security.Cryptography.AesTransform
#pragma pack(pop)
static check_size<sizeof(AesTransform), 100 + sizeof(int)> __System_Security_Cryptography_AesTransformSizeCheck;
static_assert(sizeof(AesTransform) == 0x68);
}
DEFINE_IL2CPP_ARG_TYPE(System::Security::Cryptography::AesTransform*, "System.Security.Cryptography", "AesTransform");
#include "extern/beatsaber-hook/shared/utils/il2cpp-utils-methods.hpp"
// Writing MetadataGetter for method: System::Security::Cryptography::AesTransform::New_ctor
// Il2CppName: .ctor
// Cannot get method pointer of value based method overload from template for constructor!
// Try using FindMethod instead!
// Writing MetadataGetter for method: System::Security::Cryptography::AesTransform::_cctor
// Il2CppName: .cctor
template<>
struct ::il2cpp_utils::il2cpp_type_check::MetadataGetter<static_cast<void (*)()>(&System::Security::Cryptography::AesTransform::_cctor)> {
static const MethodInfo* get() {
return ::il2cpp_utils::FindMethod(classof(System::Security::Cryptography::AesTransform*), ".cctor", std::vector<Il2CppClass*>(), ::std::vector<const Il2CppType*>{});
}
};
// Writing MetadataGetter for method: System::Security::Cryptography::AesTransform::SubByte
// Il2CppName: SubByte
template<>
struct ::il2cpp_utils::il2cpp_type_check::MetadataGetter<static_cast<uint (System::Security::Cryptography::AesTransform::*)(uint)>(&System::Security::Cryptography::AesTransform::SubByte)> {
static const MethodInfo* get() {
static auto* a = &::il2cpp_utils::GetClassFromName("System", "UInt32")->byval_arg;
return ::il2cpp_utils::FindMethod(classof(System::Security::Cryptography::AesTransform*), "SubByte", std::vector<Il2CppClass*>(), ::std::vector<const Il2CppType*>{a});
}
};
// Writing MetadataGetter for method: System::Security::Cryptography::AesTransform::Encrypt128
// Il2CppName: Encrypt128
template<>
struct ::il2cpp_utils::il2cpp_type_check::MetadataGetter<static_cast<void (System::Security::Cryptography::AesTransform::*)(::Array<uint8_t>*, ::Array<uint8_t>*, ::Array<uint>*)>(&System::Security::Cryptography::AesTransform::Encrypt128)> {
static const MethodInfo* get() {
static auto* indata = &il2cpp_functions::array_class_get(::il2cpp_utils::GetClassFromName("System", "Byte"), 1)->byval_arg;
static auto* outdata = &il2cpp_functions::array_class_get(::il2cpp_utils::GetClassFromName("System", "Byte"), 1)->byval_arg;
static auto* ekey = &il2cpp_functions::array_class_get(::il2cpp_utils::GetClassFromName("System", "UInt32"), 1)->byval_arg;
return ::il2cpp_utils::FindMethod(classof(System::Security::Cryptography::AesTransform*), "Encrypt128", std::vector<Il2CppClass*>(), ::std::vector<const Il2CppType*>{indata, outdata, ekey});
}
};
// Writing MetadataGetter for method: System::Security::Cryptography::AesTransform::Decrypt128
// Il2CppName: Decrypt128
template<>
struct ::il2cpp_utils::il2cpp_type_check::MetadataGetter<static_cast<void (System::Security::Cryptography::AesTransform::*)(::Array<uint8_t>*, ::Array<uint8_t>*, ::Array<uint>*)>(&System::Security::Cryptography::AesTransform::Decrypt128)> {
static const MethodInfo* get() {
static auto* indata = &il2cpp_functions::array_class_get(::il2cpp_utils::GetClassFromName("System", "Byte"), 1)->byval_arg;
static auto* outdata = &il2cpp_functions::array_class_get(::il2cpp_utils::GetClassFromName("System", "Byte"), 1)->byval_arg;
static auto* ekey = &il2cpp_functions::array_class_get(::il2cpp_utils::GetClassFromName("System", "UInt32"), 1)->byval_arg;
return ::il2cpp_utils::FindMethod(classof(System::Security::Cryptography::AesTransform*), "Decrypt128", std::vector<Il2CppClass*>(), ::std::vector<const Il2CppType*>{indata, outdata, ekey});
}
};
// Writing MetadataGetter for method: System::Security::Cryptography::AesTransform::ECB
// Il2CppName: ECB
template<>
struct ::il2cpp_utils::il2cpp_type_check::MetadataGetter<static_cast<void (System::Security::Cryptography::AesTransform::*)(::Array<uint8_t>*, ::Array<uint8_t>*)>(&System::Security::Cryptography::AesTransform::ECB)> {
static const MethodInfo* get() {
static auto* input = &il2cpp_functions::array_class_get(::il2cpp_utils::GetClassFromName("System", "Byte"), 1)->byval_arg;
static auto* output = &il2cpp_functions::array_class_get(::il2cpp_utils::GetClassFromName("System", "Byte"), 1)->byval_arg;
return ::il2cpp_utils::FindMethod(classof(System::Security::Cryptography::AesTransform*), "ECB", std::vector<Il2CppClass*>(), ::std::vector<const Il2CppType*>{input, output});
}
};
| 59.289474 | 241 | 0.706791 | marksteward |
73ff736684f88a5c01544e52ad77ef76a7ac6a9f | 1,276 | cpp | C++ | Chapter 10. Generic Algorithms/Codes/10.25 Solution.cpp | Yunxiang-Li/Cpp_Primer | b5c857e3f6be993b2ff8fc03f634141ae24925fc | [
"MIT"
] | null | null | null | Chapter 10. Generic Algorithms/Codes/10.25 Solution.cpp | Yunxiang-Li/Cpp_Primer | b5c857e3f6be993b2ff8fc03f634141ae24925fc | [
"MIT"
] | null | null | null | Chapter 10. Generic Algorithms/Codes/10.25 Solution.cpp | Yunxiang-Li/Cpp_Primer | b5c857e3f6be993b2ff8fc03f634141ae24925fc | [
"MIT"
] | 1 | 2021-09-30T14:08:03.000Z | 2021-09-30T14:08:03.000Z | #include <functional>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
void elimdups(std::vector<std::string>& vs)
{
std::sort(vs.begin(), vs.end());
auto new_end = std::unique(vs.begin(), vs.end());
vs.erase(new_end, vs.end());
}
bool check_size(const std::string& s, const std::string::size_type& sz)
{
return s.size() >= sz;
}
void biggies(std::vector<std::string>& vs, std::size_t sz)
{
elimdups(vs);
//! sort by size, but maintain alphabetical order for same size.
std::stable_sort(vs.begin(), vs.end(),
[](std::string const& lhs, std::string const& rhs) {
return lhs.size() < rhs.size();
});
//! get an iterator to the first one whose size() is >= sz
auto wc = std::partition(vs.begin(), vs.end(), std::bind(check_size, std::placeholders::_1, sz));
//! print the biggies
std::for_each(wc, vs.end(), [](const std::string& s) { std::cout << s << " "; });
}
int main()
{
std::vector<std::string> v{"a", "a", "in", "dog", "dog", "drivers", "deliver",
"fridge", "forever", "provide"};
std::cout << "The string which has no duplicates and less than 3 letters are: ";
biggies(v, 3);
std::cout << std::endl;
return 0;
}
| 26.583333 | 99 | 0.582288 | Yunxiang-Li |
bab69c1c253d0c7dcf56aa04f811fd66d57a5f66 | 245 | hpp | C++ | uart/Uart.hpp | PhischDotOrg/phisch-lib | 26df59d78533d3220a46e077ead5a5180a84d57a | [
"MIT"
] | null | null | null | uart/Uart.hpp | PhischDotOrg/phisch-lib | 26df59d78533d3220a46e077ead5a5180a84d57a | [
"MIT"
] | null | null | null | uart/Uart.hpp | PhischDotOrg/phisch-lib | 26df59d78533d3220a46e077ead5a5180a84d57a | [
"MIT"
] | null | null | null | /*-
* $Copyright$
-*/
#ifndef __UART_HPP_ba3914c2_b82e_482b_ad80_f21cfb95d989
#define __UART_HPP_ba3914c2_b82e_482b_ad80_f21cfb95d989
namespace uart {
}; /* namespace uart */
#endif /* __UART_HPP_ba3914c2_b82e_482b_ad80_f21cfb95d989 */
| 18.846154 | 60 | 0.787755 | PhischDotOrg |
bab82fb7a332e5c5b9ffc499aa0971e477ba5a05 | 4,130 | hpp | C++ | northstar/include/driver/Optics.hpp | BryanChrisBrown/project_northstar_openvr_driver | cf16e98e24804aee699805dca766b8153f4e52e5 | [
"Unlicense"
] | null | null | null | northstar/include/driver/Optics.hpp | BryanChrisBrown/project_northstar_openvr_driver | cf16e98e24804aee699805dca766b8153f4e52e5 | [
"Unlicense"
] | null | null | null | northstar/include/driver/Optics.hpp | BryanChrisBrown/project_northstar_openvr_driver | cf16e98e24804aee699805dca766b8153f4e52e5 | [
"Unlicense"
] | null | null | null | #pragma once
#include "driver/IOptics.hpp"
#include "math/Types.hpp"
#include "math/IVectorFactory.hpp"
#include "math/IMatrixFactory.hpp"
#include "math/IGeometry.hpp"
#include "math/ISpaceAdapter.hpp"
#include "math/IWorldAdapter.hpp"
#include "openvr_driver.h"
#include "driver/Settings.hpp"
#include "utility/ILogger.hpp"
#include <memory>
namespace northstar {
namespace driver {
class COptics : public IOptics {
public:
COptics(
vr::IVRSettings* pVRSettings,
std::shared_ptr<northstar::math::IWorldAdapter> pWorldAdapter,
std::shared_ptr<northstar::math::ISpaceAdapter> pSpaceAdapter,
std::shared_ptr<northstar::math::IGeometry> pGeometry,
std::shared_ptr<northstar::math::IMatrixFactory> pMatrixFactory,
std::shared_ptr<northstar::math::IVectorFactory> pVectorFactory,
std::shared_ptr<northstar::utility::ILogger> pLogger);
virtual northstar::math::types::Vector2d EyeUVToScreenUV(const vr::EVREye& eEye, const northstar::math::types::Vector2d& v2dEyeUV) override final;
virtual northstar::math::types::Vector4d GetEyeProjectionLRTB(const vr::EVREye& eEye) override final;
private:
static constexpr size_t x_nNumberOfSolverIterations = 7;
static constexpr std::array<double, 2> x_daInitialWarpGuess = { 0.5, 0.5 };
static constexpr std::array<double, 2> x_daIterativeSolverErrorResult = { 0.0, 0.0 };
static constexpr std::array<double, 3> x_daLensProxySphereOrigin = { 0.0, 0.0, 0.0 };
static constexpr double x_dLensProxySphereRadius = 0.5;
static constexpr double x_dIterativeSolverGradiantEpsilon = 0.0001;
static constexpr double x_dIterativeSolverStepWeight = 1.0 / 7.0;
struct SEllipsisAxis {
double dMinor;
double dMajor;
};
struct SEyeConfiguration {
SEllipsisAxis sEllipsisAxis = { 0 };
northstar::math::types::Vector3d v3dScreenForward;
northstar::math::types::Vector3d v3dScreenPosition;
northstar::math::types::Vector3d v3dEyePosition;
northstar::math::types::Quaterniond qdEyeRotation;
northstar::math::types::Vector4d v4dCameraProjectionFrustumExtentsLRTB;
northstar::math::types::AffineMatrix4d m4dSphereToWorldSpace;
northstar::math::types::AffineMatrix4d m4dWorldToScreenSpace;
northstar::math::types::AffineMatrix4d m4dWorldToSphereSpace;
northstar::math::types::ProjMatrix4d m4dCameraProjection;
northstar::math::types::ProjMatrix4d m4dClipToWorld;
};
typedef std::unordered_map<
northstar::math::types::Vector2d,
northstar::math::types::Vector2d,
northstar::math::types::SHasher<northstar::math::types::Vector2d>> UVWarpMap;
SEyeConfiguration LoadConfigFromEye(const vr::EVREye& eEye);
northstar::math::types::Vector2d ReverseProjectEyeUVToDisplayUV(const vr::EVREye& eEye, const northstar::math::types::Vector2d& v2dTargetEyeUV);
northstar::math::types::Vector2d IterativeGradientUVWarpSolve(const vr::EVREye& eEye, const northstar::math::types::Vector2d& v2dEyeUV, const northstar::math::types::Vector2d& v2dWarpUVGuess);
vr::IVRSettings* m_pVRSettings;
std::shared_ptr<northstar::math::IVectorFactory> m_pVectorFactory;
std::shared_ptr<northstar::math::IMatrixFactory> m_pMatrixFactory;
std::shared_ptr<northstar::math::IGeometry> m_pGeometry;
std::shared_ptr<northstar::math::IWorldAdapter> m_pWorldAdapter;
std::shared_ptr<northstar::math::ISpaceAdapter> m_pSpaceAdapter;
std::shared_ptr<northstar::utility::ILogger> m_pLogger;
std::unordered_map<vr::EVREye, SEyeConfiguration> m_umEyeConfigs;
std::unordered_map<vr::EVREye, UVWarpMap> m_umUVWarps;
};
}
}
| 51.625 | 204 | 0.659806 | BryanChrisBrown |
babcc15f3399c374704c2c2861c1e0010c6fee50 | 30,051 | cpp | C++ | layer/dispatch.cpp | jpark37/Fossilize | 4af65358c66a032ddb500df3341788277e32d56a | [
"MIT"
] | null | null | null | layer/dispatch.cpp | jpark37/Fossilize | 4af65358c66a032ddb500df3341788277e32d56a | [
"MIT"
] | null | null | null | layer/dispatch.cpp | jpark37/Fossilize | 4af65358c66a032ddb500df3341788277e32d56a | [
"MIT"
] | null | null | null | /* Copyright (c) 2018 Hans-Kristian Arntzen
*
* 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.
*/
#define VK_NO_PROTOTYPES // VALVE: So that vulkan_core.h definitions lacking dllexport don't conflict with our exported functions
#include "dispatch_helper.hpp"
#include "utils.hpp"
#include "device.hpp"
#include "instance.hpp"
#include "fossilize_errors.hpp"
#include <mutex>
// VALVE: do exports without .def file, see vk_layer.h for definition on non-Windows platforms
#ifdef _MSC_VER
#if defined(_WIN32) && !defined(_WIN64)
// Josh: We need to match the export names up to the functions to avoid stdcall aliasing
#pragma comment(linker, "/EXPORT:VK_LAYER_fossilize_GetInstanceProcAddr=_VK_LAYER_fossilize_GetInstanceProcAddr@8")
#pragma comment(linker, "/EXPORT:VK_LAYER_fossilize_GetDeviceProcAddr=_VK_LAYER_fossilize_GetDeviceProcAddr@8")
#endif
#undef VK_LAYER_EXPORT
#define VK_LAYER_EXPORT extern "C" __declspec(dllexport)
#endif
extern "C"
{
#ifdef ANDROID
#define VK_LAYER_fossilize_GetInstanceProcAddr vkGetInstanceProcAddr
#define VK_LAYER_fossilize_GetDeviceProcAddr vkGetDeviceProcAddr
#endif
VK_LAYER_EXPORT VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL VK_LAYER_fossilize_GetInstanceProcAddr(VkInstance instance, const char *pName);
VK_LAYER_EXPORT VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL VK_LAYER_fossilize_GetDeviceProcAddr(VkDevice device, const char *pName);
}
using namespace std;
namespace Fossilize
{
// Global data structures to remap VkInstance and VkDevice to internal data structures.
static mutex globalLock;
static InstanceTable instanceDispatch;
static DeviceTable deviceDispatch;
static unordered_map<void *, unique_ptr<Instance>> instanceData;
static unordered_map<void *, unique_ptr<Device>> deviceData;
static Device *get_device_layer(VkDevice device)
{
// Need to hold a lock while querying the global hashmap, but not after it.
Device *layer = nullptr;
void *key = getDispatchKey(device);
lock_guard<mutex> holder{ globalLock };
layer = getLayerData(key, deviceData);
return layer;
}
static Instance *get_instance_layer(VkPhysicalDevice gpu)
{
lock_guard<mutex> holder{ globalLock };
return getLayerData(getDispatchKey(gpu), instanceData);
}
static VKAPI_ATTR VkResult VKAPI_CALL CreateDevice(VkPhysicalDevice gpu, const VkDeviceCreateInfo *pCreateInfo,
const VkAllocationCallbacks *pAllocator, VkDevice *pDevice)
{
auto *layer = get_instance_layer(gpu);
auto *chainInfo = getChainInfo(pCreateInfo, VK_LAYER_LINK_INFO);
auto fpGetInstanceProcAddr = chainInfo->u.pLayerInfo->pfnNextGetInstanceProcAddr;
auto fpGetDeviceProcAddr = chainInfo->u.pLayerInfo->pfnNextGetDeviceProcAddr;
auto fpCreateDevice =
reinterpret_cast<PFN_vkCreateDevice>(fpGetInstanceProcAddr(layer->getInstance(), "vkCreateDevice"));
if (!fpCreateDevice)
return VK_ERROR_INITIALIZATION_FAILED;
// Advance the link info for the next element on the chain
chainInfo->u.pLayerInfo = chainInfo->u.pLayerInfo->pNext;
auto res = fpCreateDevice(gpu, pCreateInfo, pAllocator, pDevice);
if (res != VK_SUCCESS)
return res;
// Build a physical device features 2 struct if we cannot find it in pCreateInfo.
auto *pdf2 = static_cast<const VkPhysicalDeviceFeatures2 *>(findpNext(pCreateInfo, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2));
VkPhysicalDeviceFeatures2 physicalDeviceFeatures2 = { VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2 };
if (!pdf2)
{
pdf2 = &physicalDeviceFeatures2;
if (pCreateInfo->pEnabledFeatures)
physicalDeviceFeatures2.features = *pCreateInfo->pEnabledFeatures;
}
{
lock_guard<mutex> holder{globalLock};
auto *device = createLayerData(getDispatchKey(*pDevice), deviceData);
device->init(gpu, *pDevice, layer, *pdf2, initDeviceTable(*pDevice, fpGetDeviceProcAddr, deviceDispatch));
}
return VK_SUCCESS;
}
static VKAPI_ATTR VkResult VKAPI_CALL CreateInstance(const VkInstanceCreateInfo *pCreateInfo,
const VkAllocationCallbacks *pAllocator, VkInstance *pInstance)
{
auto *chainInfo = getChainInfo(pCreateInfo, VK_LAYER_LINK_INFO);
auto fpGetInstanceProcAddr = chainInfo->u.pLayerInfo->pfnNextGetInstanceProcAddr;
auto fpCreateInstance = reinterpret_cast<PFN_vkCreateInstance>(fpGetInstanceProcAddr(nullptr, "vkCreateInstance"));
if (!fpCreateInstance)
return VK_ERROR_INITIALIZATION_FAILED;
chainInfo->u.pLayerInfo = chainInfo->u.pLayerInfo->pNext;
auto res = fpCreateInstance(pCreateInfo, pAllocator, pInstance);
if (res != VK_SUCCESS)
return res;
{
lock_guard<mutex> holder{globalLock};
auto *layer = createLayerData(getDispatchKey(*pInstance), instanceData);
layer->init(*pInstance, pCreateInfo->pApplicationInfo,
initInstanceTable(*pInstance, fpGetInstanceProcAddr, instanceDispatch), fpGetInstanceProcAddr);
}
return VK_SUCCESS;
}
static VKAPI_ATTR void VKAPI_CALL DestroyInstance(VkInstance instance, const VkAllocationCallbacks *pAllocator)
{
lock_guard<mutex> holder{ globalLock };
void *key = getDispatchKey(instance);
auto *layer = getLayerData(key, instanceData);
layer->getTable()->DestroyInstance(instance, pAllocator);
destroyLayerData(key, instanceData);
}
static VKAPI_ATTR VkResult VKAPI_CALL CreateGraphicsPipelinesNormal(Device *layer,
VkDevice device, VkPipelineCache pipelineCache,
uint32_t createInfoCount,
const VkGraphicsPipelineCreateInfo *pCreateInfos,
const VkAllocationCallbacks *pAllocator,
VkPipeline *pPipelines)
{
// Have to create all pipelines here, in case the application makes use of basePipelineIndex.
auto res = layer->getTable()->CreateGraphicsPipelines(device, pipelineCache, createInfoCount, pCreateInfos, pAllocator, pPipelines);
if (res < 0)
return res;
for (uint32_t i = 0; i < createInfoCount; i++)
{
if (!layer->getRecorder().record_graphics_pipeline(pPipelines[i], pCreateInfos[i], pPipelines, createInfoCount))
LOGW_LEVEL("Recording graphics pipeline failed, usually caused by unsupported pNext.\n");
}
return res;
}
static VKAPI_ATTR VkResult VKAPI_CALL CreateGraphicsPipelinesParanoid(Device *layer,
VkDevice device, VkPipelineCache pipelineCache,
uint32_t createInfoCount,
const VkGraphicsPipelineCreateInfo *pCreateInfos,
const VkAllocationCallbacks *pAllocator,
VkPipeline *pPipelines)
{
for (uint32_t i = 0; i < createInfoCount; i++)
{
// Fixup base pipeline index since we unroll the Create call.
auto info = pCreateInfos[i];
if ((info.flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) != 0 &&
info.basePipelineHandle == VK_NULL_HANDLE &&
info.basePipelineIndex >= 0)
{
info.basePipelineHandle = pPipelines[info.basePipelineIndex];
info.basePipelineIndex = -1;
}
bool eager = layer->getInstance()->capturesEagerly();
if (eager && !layer->getRecorder().record_graphics_pipeline(VK_NULL_HANDLE, info, nullptr, 0))
LOGW_LEVEL("Failed to capture eagerly.\n");
// Have to create all pipelines here, in case the application makes use of basePipelineIndex.
// Write arguments in TLS in-case we crash here.
Instance::braceForGraphicsPipelineCrash(&layer->getRecorder(), &info);
auto res = layer->getTable()->CreateGraphicsPipelines(device, pipelineCache, 1, &info,
pAllocator, &pPipelines[i]);
Instance::completedPipelineCompilation();
// Record failing pipelines for repro.
if (!layer->getRecorder().record_graphics_pipeline(res == VK_SUCCESS ? pPipelines[i] : VK_NULL_HANDLE, info, nullptr, 0))
LOGW_LEVEL("Failed to record graphics pipeline, usually caused by unsupported pNext.\n");
// FIXME: Unsure how to deal with divergent success codes.
if (res < 0)
{
for (uint32_t j = 0; j < i; j++)
layer->getTable()->DestroyPipeline(device, pPipelines[j], pAllocator);
return res;
}
}
return VK_SUCCESS;
}
static VKAPI_ATTR VkResult VKAPI_CALL CreateGraphicsPipelines(VkDevice device, VkPipelineCache pipelineCache,
uint32_t createInfoCount,
const VkGraphicsPipelineCreateInfo *pCreateInfos,
const VkAllocationCallbacks *pAllocator,
VkPipeline *pPipelines)
{
auto *layer = get_device_layer(device);
if (layer->getInstance()->capturesParanoid())
return CreateGraphicsPipelinesParanoid(layer, device, pipelineCache, createInfoCount, pCreateInfos, pAllocator, pPipelines);
else
return CreateGraphicsPipelinesNormal(layer, device, pipelineCache, createInfoCount, pCreateInfos, pAllocator, pPipelines);
}
static VKAPI_ATTR VkResult VKAPI_CALL CreateComputePipelinesNormal(Device *layer,
VkDevice device, VkPipelineCache pipelineCache,
uint32_t createInfoCount,
const VkComputePipelineCreateInfo *pCreateInfos,
const VkAllocationCallbacks *pAllocator,
VkPipeline *pPipelines)
{
// Have to create all pipelines here, in case the application makes use of basePipelineIndex.
auto res = layer->getTable()->CreateComputePipelines(device, pipelineCache, createInfoCount, pCreateInfos, pAllocator, pPipelines);
if (res < 0)
return res;
for (uint32_t i = 0; i < createInfoCount; i++)
{
if (!layer->getRecorder().record_compute_pipeline(pPipelines[i], pCreateInfos[i], pPipelines, createInfoCount))
LOGW_LEVEL("Failed to record compute pipeline, usually caused by unsupported pNext.\n");
}
return res;
}
static VKAPI_ATTR VkResult VKAPI_CALL CreateComputePipelinesParanoid(Device *layer,
VkDevice device, VkPipelineCache pipelineCache,
uint32_t createInfoCount,
const VkComputePipelineCreateInfo *pCreateInfos,
const VkAllocationCallbacks *pAllocator,
VkPipeline *pPipelines)
{
for (uint32_t i = 0; i < createInfoCount; i++)
{
// Fixup base pipeline index since we unroll the Create call.
auto info = pCreateInfos[i];
if ((info.flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) != 0 &&
info.basePipelineHandle == VK_NULL_HANDLE &&
info.basePipelineIndex >= 0)
{
info.basePipelineHandle = pPipelines[info.basePipelineIndex];
info.basePipelineIndex = -1;
}
bool eager = layer->getInstance()->capturesEagerly();
if (eager && !layer->getRecorder().record_compute_pipeline(VK_NULL_HANDLE, info, nullptr, 0))
LOGW_LEVEL("Failed to capture eagerly.\n");
// Have to create all pipelines here, in case the application makes use of basePipelineIndex.
// Write arguments in TLS in-case we crash here.
Instance::braceForComputePipelineCrash(&layer->getRecorder(), &info);
auto res = layer->getTable()->CreateComputePipelines(device, pipelineCache, 1, &info,
pAllocator, &pPipelines[i]);
Instance::completedPipelineCompilation();
// Record failing pipelines for repro.
if (!layer->getRecorder().record_compute_pipeline(res == VK_SUCCESS ? pPipelines[i] : VK_NULL_HANDLE, info, nullptr, 0))
LOGW_LEVEL("Failed to record compute pipeline, usually caused by unsupported pNext.\n");
// FIXME: Unsure how to deal with divergent success codes.
if (res < 0)
{
for (uint32_t j = 0; j < i; j++)
layer->getTable()->DestroyPipeline(device, pPipelines[j], pAllocator);
return res;
}
}
return VK_SUCCESS;
}
static VKAPI_ATTR VkResult VKAPI_CALL CreateComputePipelines(VkDevice device, VkPipelineCache pipelineCache,
uint32_t createInfoCount,
const VkComputePipelineCreateInfo *pCreateInfos,
const VkAllocationCallbacks *pAllocator,
VkPipeline *pPipelines)
{
auto *layer = get_device_layer(device);
if (layer->getInstance()->capturesParanoid())
return CreateComputePipelinesParanoid(layer, device, pipelineCache, createInfoCount, pCreateInfos, pAllocator, pPipelines);
else
return CreateComputePipelinesNormal(layer, device, pipelineCache, createInfoCount, pCreateInfos, pAllocator, pPipelines);
}
static VKAPI_ATTR VkResult VKAPI_CALL CreateRayTracingPipelinesNormal(Device *layer,
VkDevice device, VkDeferredOperationKHR deferredOperation,
VkPipelineCache pipelineCache,
uint32_t createInfoCount,
const VkRayTracingPipelineCreateInfoKHR *pCreateInfos,
const VkAllocationCallbacks *pAllocator,
VkPipeline *pPipelines)
{
// Have to create all pipelines here, in case the application makes use of basePipelineIndex.
auto res = layer->getTable()->CreateRayTracingPipelinesKHR(
device, deferredOperation, pipelineCache,
createInfoCount, pCreateInfos, pAllocator, pPipelines);
if (res < 0)
return res;
for (uint32_t i = 0; i < createInfoCount; i++)
{
if (!layer->getRecorder().record_raytracing_pipeline(pPipelines[i], pCreateInfos[i], pPipelines, createInfoCount))
LOGW_LEVEL("Failed to record compute pipeline, usually caused by unsupported pNext.\n");
}
return res;
}
static VKAPI_ATTR VkResult VKAPI_CALL CreateRayTracingPipelinesParanoid(Device *layer,
VkDevice device, VkDeferredOperationKHR deferredOperation,
VkPipelineCache pipelineCache,
uint32_t createInfoCount,
const VkRayTracingPipelineCreateInfoKHR *pCreateInfos,
const VkAllocationCallbacks *pAllocator,
VkPipeline *pPipelines)
{
for (uint32_t i = 0; i < createInfoCount; i++)
{
// Fixup base pipeline index since we unroll the Create call.
auto info = pCreateInfos[i];
if ((info.flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) != 0 &&
info.basePipelineHandle == VK_NULL_HANDLE &&
info.basePipelineIndex >= 0)
{
info.basePipelineHandle = pPipelines[info.basePipelineIndex];
info.basePipelineIndex = -1;
}
bool eager = layer->getInstance()->capturesEagerly();
if (eager && !layer->getRecorder().record_raytracing_pipeline(VK_NULL_HANDLE, info, nullptr, 0))
LOGW_LEVEL("Failed to capture eagerly.\n");
// Have to create all pipelines here, in case the application makes use of basePipelineIndex.
// Write arguments in TLS in-case we crash here.
Instance::braceForRayTracingPipelineCrash(&layer->getRecorder(), &info);
// FIXME: Can we meaningfully deal with deferredOperation here?
auto res = layer->getTable()->CreateRayTracingPipelinesKHR(device, deferredOperation, pipelineCache, 1, &info,
pAllocator, &pPipelines[i]);
Instance::completedPipelineCompilation();
// Record failing pipelines for repro.
if (!layer->getRecorder().record_raytracing_pipeline(res == VK_SUCCESS ? pPipelines[i] : VK_NULL_HANDLE, info, nullptr, 0))
LOGW_LEVEL("Failed to record compute pipeline, usually caused by unsupported pNext.\n");
// FIXME: Unsure how to deal with divergent success codes.
if (res < 0)
{
for (uint32_t j = 0; j < i; j++)
layer->getTable()->DestroyPipeline(device, pPipelines[j], pAllocator);
return res;
}
}
return VK_SUCCESS;
}
static VKAPI_ATTR VkResult VKAPI_CALL CreateRayTracingPipelinesKHR(
VkDevice device, VkDeferredOperationKHR deferredOperation,
VkPipelineCache pipelineCache, uint32_t createInfoCount,
const VkRayTracingPipelineCreateInfoKHR *pCreateInfos,
const VkAllocationCallbacks *pAllocator,
VkPipeline *pPipelines)
{
auto *layer = get_device_layer(device);
if (layer->getInstance()->capturesParanoid())
{
return CreateRayTracingPipelinesParanoid(layer, device, deferredOperation, pipelineCache,
createInfoCount, pCreateInfos, pAllocator, pPipelines);
}
else
{
return CreateRayTracingPipelinesNormal(layer, device, deferredOperation, pipelineCache,
createInfoCount, pCreateInfos, pAllocator, pPipelines);
}
}
static VKAPI_ATTR VkResult VKAPI_CALL CreatePipelineLayout(VkDevice device,
const VkPipelineLayoutCreateInfo *pCreateInfo,
const VkAllocationCallbacks *pAllocator,
VkPipelineLayout *pLayout)
{
auto *layer = get_device_layer(device);
VkResult result = layer->getTable()->CreatePipelineLayout(device, pCreateInfo, pAllocator, pLayout);
if (result == VK_SUCCESS)
{
if (!layer->getRecorder().record_pipeline_layout(*pLayout, *pCreateInfo))
LOGW_LEVEL("Failed to record pipeline layout, usually caused by unsupported pNext.\n");
}
return result;
}
static VKAPI_ATTR VkResult VKAPI_CALL CreateDescriptorSetLayout(VkDevice device,
const VkDescriptorSetLayoutCreateInfo *pCreateInfo,
const VkAllocationCallbacks *pAllocator,
VkDescriptorSetLayout *pSetLayout)
{
auto *layer = get_device_layer(device);
VkResult result = layer->getTable()->CreateDescriptorSetLayout(device, pCreateInfo, pAllocator, pSetLayout);
// No point in recording a host only layout since we will never be able to use it in a pipeline layout.
if (result == VK_SUCCESS && (pCreateInfo->flags & VK_DESCRIPTOR_SET_LAYOUT_CREATE_HOST_ONLY_POOL_BIT_VALVE) == 0)
{
if (!layer->getRecorder().record_descriptor_set_layout(*pSetLayout, *pCreateInfo))
LOGW_LEVEL("Failed to record descriptor set layout, usually caused by unsupported pNext.\n");
}
return result;
}
static PFN_vkVoidFunction interceptCoreInstanceCommand(const char *pName)
{
static const struct
{
const char *name;
PFN_vkVoidFunction proc;
} coreInstanceCommands[] = {
{ "vkCreateInstance", reinterpret_cast<PFN_vkVoidFunction>(CreateInstance) },
{ "vkDestroyInstance", reinterpret_cast<PFN_vkVoidFunction>(DestroyInstance) },
{ "vkGetInstanceProcAddr", reinterpret_cast<PFN_vkVoidFunction>(VK_LAYER_fossilize_GetInstanceProcAddr) },
{ "vkCreateDevice", reinterpret_cast<PFN_vkVoidFunction>(CreateDevice) },
};
for (auto &cmd : coreInstanceCommands)
if (strcmp(cmd.name, pName) == 0)
return cmd.proc;
return nullptr;
}
static VKAPI_ATTR void VKAPI_CALL DestroyDevice(VkDevice device, const VkAllocationCallbacks *pAllocator)
{
lock_guard<mutex> holder{ globalLock };
void *key = getDispatchKey(device);
auto *layer = getLayerData(key, deviceData);
layer->getTable()->DestroyDevice(device, pAllocator);
destroyLayerData(key, deviceData);
}
static VKAPI_ATTR VkResult VKAPI_CALL CreateSampler(VkDevice device, const VkSamplerCreateInfo *pCreateInfo,
const VkAllocationCallbacks *pCallbacks, VkSampler *pSampler)
{
auto *layer = get_device_layer(device);
auto res = layer->getTable()->CreateSampler(device, pCreateInfo, pCallbacks, pSampler);
if (res == VK_SUCCESS)
{
if (!layer->getRecorder().record_sampler(*pSampler, *pCreateInfo))
LOGW_LEVEL("Failed to record sampler, usually caused by unsupported pNext.\n");
}
return res;
}
static VKAPI_ATTR VkResult VKAPI_CALL CreateShaderModule(VkDevice device, const VkShaderModuleCreateInfo *pCreateInfo,
const VkAllocationCallbacks *pCallbacks,
VkShaderModule *pShaderModule)
{
auto *layer = get_device_layer(device);
*pShaderModule = VK_NULL_HANDLE;
auto res = layer->getTable()->CreateShaderModule(device, pCreateInfo, pCallbacks, pShaderModule);
if (res == VK_SUCCESS)
{
if (!layer->getRecorder().record_shader_module(*pShaderModule, *pCreateInfo))
LOGW_LEVEL("Failed to record shader module, usually caused by unsupported pNext.\n");
}
return res;
}
static VKAPI_ATTR VkResult VKAPI_CALL CreateRenderPass(VkDevice device, const VkRenderPassCreateInfo *pCreateInfo,
const VkAllocationCallbacks *pCallbacks, VkRenderPass *pRenderPass)
{
auto *layer = get_device_layer(device);
auto res = layer->getTable()->CreateRenderPass(device, pCreateInfo, pCallbacks, pRenderPass);
if (res == VK_SUCCESS)
{
if (!layer->getRecorder().record_render_pass(*pRenderPass, *pCreateInfo))
LOGW_LEVEL("Failed to record render pass, usually caused by unsupported pNext.\n");
}
return res;
}
static VKAPI_ATTR VkResult VKAPI_CALL CreateRenderPass2(VkDevice device, const VkRenderPassCreateInfo2 *pCreateInfo,
const VkAllocationCallbacks *pCallbacks, VkRenderPass *pRenderPass)
{
auto *layer = get_device_layer(device);
// Split calls since 2 and KHR variants might not be present even if the other one is.
auto res = layer->getTable()->CreateRenderPass2(device, pCreateInfo, pCallbacks, pRenderPass);
if (res == VK_SUCCESS)
{
if (!layer->getRecorder().record_render_pass2(*pRenderPass, *pCreateInfo))
LOGW_LEVEL("Failed to record render pass, usually caused by unsupported pNext.\n");
}
return res;
}
static VKAPI_ATTR VkResult VKAPI_CALL CreateRenderPass2KHR(VkDevice device, const VkRenderPassCreateInfo2 *pCreateInfo,
const VkAllocationCallbacks *pCallbacks, VkRenderPass *pRenderPass)
{
auto *layer = get_device_layer(device);
// Split calls since 2 and KHR variants might not be present even if the other one is.
auto res = layer->getTable()->CreateRenderPass2KHR(device, pCreateInfo, pCallbacks, pRenderPass);
if (res == VK_SUCCESS)
{
if (!layer->getRecorder().record_render_pass2(*pRenderPass, *pCreateInfo))
LOGW_LEVEL("Failed to record render pass, usually caused by unsupported pNext.\n");
}
return res;
}
static PFN_vkVoidFunction interceptCoreDeviceCommand(const char *pName)
{
static const struct
{
const char *name;
PFN_vkVoidFunction proc;
} coreDeviceCommands[] = {
{ "vkGetDeviceProcAddr", reinterpret_cast<PFN_vkVoidFunction>(VK_LAYER_fossilize_GetDeviceProcAddr) },
{ "vkDestroyDevice", reinterpret_cast<PFN_vkVoidFunction>(DestroyDevice) },
{ "vkCreateDescriptorSetLayout", reinterpret_cast<PFN_vkVoidFunction>(CreateDescriptorSetLayout) },
{ "vkCreatePipelineLayout", reinterpret_cast<PFN_vkVoidFunction>(CreatePipelineLayout) },
{ "vkCreateGraphicsPipelines", reinterpret_cast<PFN_vkVoidFunction>(CreateGraphicsPipelines) },
{ "vkCreateComputePipelines", reinterpret_cast<PFN_vkVoidFunction>(CreateComputePipelines) },
{ "vkCreateSampler", reinterpret_cast<PFN_vkVoidFunction>(CreateSampler) },
{ "vkCreateShaderModule", reinterpret_cast<PFN_vkVoidFunction>(CreateShaderModule) },
{ "vkCreateRenderPass", reinterpret_cast<PFN_vkVoidFunction>(CreateRenderPass) },
{ "vkCreateRenderPass2", reinterpret_cast<PFN_vkVoidFunction>(CreateRenderPass2) },
{ "vkCreateRenderPass2KHR", reinterpret_cast<PFN_vkVoidFunction>(CreateRenderPass2KHR) },
{ "vkCreateRayTracingPipelinesKHR", reinterpret_cast<PFN_vkVoidFunction>(CreateRayTracingPipelinesKHR) },
};
for (auto &cmd : coreDeviceCommands)
if (strcmp(cmd.name, pName) == 0)
return cmd.proc;
return nullptr;
}
}
using namespace Fossilize;
extern "C"
{
VK_LAYER_EXPORT VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL VK_LAYER_fossilize_GetDeviceProcAddr(VkDevice device, const char *pName)
{
Device *layer;
{
lock_guard<mutex> holder{globalLock};
layer = getLayerData(getDispatchKey(device), deviceData);
}
auto proc = layer->getTable()->GetDeviceProcAddr(device, pName);
// If the underlying implementation returns nullptr, we also need to return nullptr.
// This means we never expose wrappers which will end up dispatching into nullptr.
if (proc)
{
auto wrapped_proc = interceptCoreDeviceCommand(pName);
if (wrapped_proc)
proc = wrapped_proc;
}
return proc;
}
VK_LAYER_EXPORT VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL VK_LAYER_fossilize_GetInstanceProcAddr(VkInstance instance, const char *pName)
{
// We only wrap core Vulkan 1.0 instance commands, no need to check for availability of underlying implementation.
auto proc = interceptCoreInstanceCommand(pName);
if (proc)
return proc;
Instance *layer;
{
lock_guard<mutex> holder{globalLock};
layer = getLayerData(getDispatchKey(instance), instanceData);
}
proc = layer->getProcAddr(pName);
// If the underlying implementation returns nullptr, we also need to return nullptr.
// This means we never expose wrappers which will end up dispatching into nullptr.
if (proc)
{
auto wrapped_proc = interceptCoreDeviceCommand(pName);
if (wrapped_proc)
proc = wrapped_proc;
}
return proc;
}
#ifdef ANDROID
static const VkLayerProperties layerProps[] = {
{ VK_LAYER_fossilize, VK_MAKE_VERSION(1, 2, 136), 1, "Fossilize capture layer" },
};
VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL
vkEnumerateInstanceExtensionProperties(const char *pLayerName, uint32_t *pPropertyCount,
VkExtensionProperties *pProperties)
{
if (!pLayerName || strcmp(pLayerName, layerProps[0].layerName))
return VK_ERROR_LAYER_NOT_PRESENT;
if (pProperties && *pPropertyCount != 0)
{
*pPropertyCount = 0;
return VK_INCOMPLETE;
}
*pPropertyCount = 0;
return VK_SUCCESS;
}
VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL
vkEnumerateDeviceExtensionProperties(VkPhysicalDevice, const char *pLayerName,
uint32_t *pPropertyCount,
VkExtensionProperties *pProperties)
{
if (pLayerName && !strcmp(pLayerName, layerProps[0].layerName))
{
if (pProperties && *pPropertyCount > 0)
return VK_INCOMPLETE;
*pPropertyCount = 0;
return VK_SUCCESS;
}
else
return VK_ERROR_LAYER_NOT_PRESENT;
}
VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkEnumerateInstanceLayerProperties(uint32_t *pPropertyCount,
VkLayerProperties *pProperties)
{
if (pProperties)
{
uint32_t count = std::min(1u, *pPropertyCount);
memcpy(pProperties, layerProps, count * sizeof(VkLayerProperties));
VkResult res = count < *pPropertyCount ? VK_INCOMPLETE : VK_SUCCESS;
*pPropertyCount = count;
return res;
}
else
{
*pPropertyCount = sizeof(layerProps) / sizeof(VkLayerProperties);
return VK_SUCCESS;
}
}
VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL
vkEnumerateDeviceLayerProperties(VkPhysicalDevice, uint32_t *pPropertyCount,
VkLayerProperties *pProperties)
{
if (pProperties)
{
uint32_t count = std::min(1u, *pPropertyCount);
memcpy(pProperties, layerProps, count * sizeof(VkLayerProperties));
VkResult res = count < *pPropertyCount ? VK_INCOMPLETE : VK_SUCCESS;
*pPropertyCount = count;
return res;
}
else
{
*pPropertyCount = sizeof(layerProps) / sizeof(VkLayerProperties);
return VK_SUCCESS;
}
}
#endif
}
| 42.147265 | 136 | 0.677349 | jpark37 |
bac1170359dcbd3a2d9f8b93934541c73c1adff0 | 1,623 | cc | C++ | src/parse.cc | realzhangm/dpdk_port_test | b5546a57df243ba86c8c3330cce3905e61d15ff2 | [
"MIT"
] | null | null | null | src/parse.cc | realzhangm/dpdk_port_test | b5546a57df243ba86c8c3330cce3905e61d15ff2 | [
"MIT"
] | null | null | null | src/parse.cc | realzhangm/dpdk_port_test | b5546a57df243ba86c8c3330cce3905e61d15ff2 | [
"MIT"
] | null | null | null | #include <rte_mbuf.h>
#include <rte_ether.h>
#include <rte_ip.h>
#include <rte_tcp.h>
#include <rte_udp.h>
bool PreparePacket(rte_mbuf* m, int port_id, int ring_id) {
char* pkt_data = rte_ctrlmbuf_data(m);
uint16_t* eth_type = (uint16_t*)(pkt_data + 2 * ETHER_ADDR_LEN);
m->l2_len = 2 * ETHER_ADDR_LEN;
ipv4_hdr* ipv4 = NULL;
tcp_hdr* tcp = NULL;
while (*eth_type == rte_cpu_to_be_16(ETHER_TYPE_VLAN) ||
*eth_type == rte_cpu_to_be_16(ETHER_TYPE_QINQ)) {
eth_type += 2;
m->l2_len += 4;
}
m->l2_len += 2;
uint8_t ip_proto = 0;
switch (rte_cpu_to_be_16(*eth_type)) {
case ETHER_TYPE_IPv4: {
ipv4 = (ipv4_hdr*)(eth_type + 1);
m->l3_len = 4 * (ipv4->version_ihl & 0x0F);
ip_proto = ipv4->next_proto_id;
break;
}
case ETHER_TYPE_IPv6: {
m->l3_len = sizeof(ipv6_hdr); //
ip_proto = ((ipv6_hdr*)(eth_type + 1))->proto;
break;
}
default: {
printf("%s\n", "Packet is not IP - not supported");
return false;
}
}
// If it's not TCP or UDP packet - skip it
switch (ip_proto) {
case IPPROTO_TCP: {
tcp = rte_pktmbuf_mtod_offset(m, tcp_hdr*, m->l2_len + m->l3_len);
m->l4_len = 4 * ((tcp->data_off & 0xF0) >> 4);
printf(
"port_id=%02d, ring_num=%02d, hash=%x, sip=%u, dip=%u, sport=%d, "
"dport=%d\n",
port_id, ring_id, m->hash.rss, ipv4->src_addr, ipv4->dst_addr,
tcp->src_port, tcp->dst_port);
break;
}
case IPPROTO_UDP: {
m->l4_len = sizeof(udp_hdr); //
break;
}
default: { return false; }
}
return true;
} | 26.606557 | 76 | 0.586568 | realzhangm |
bac18c89cb712144e3f8cb81cb67002a2f7e7279 | 1,311 | hh | C++ | Cayley.hh | steelbrain/Cayley-HHVM | a774f83a4a84f7d37592bc16e8f6336a31f34ce3 | [
"MIT"
] | 1 | 2015-04-25T06:09:20.000Z | 2015-04-25T06:09:20.000Z | Cayley.hh | steelbrain/Cayley-HHVM | a774f83a4a84f7d37592bc16e8f6336a31f34ce3 | [
"MIT"
] | null | null | null | Cayley.hh | steelbrain/Cayley-HHVM | a774f83a4a84f7d37592bc16e8f6336a31f34ce3 | [
"MIT"
] | null | null | null | <?hh //strict
require(__DIR__.'/CayleyQuery.hh');
type TypeCayleyEntry = shape(
'subject' => string,
'predicate' => string,
'object' => string,
'label' => string
);
enum CayleyOp:string as string{
WRITE = 'write';
DELETE = 'delete';
}
class Cayley{
public function __construct(public string $URL){
}
public function g():CayleyQuery{
return new CayleyQuery($this);
}
public function write(string $subject, string $predicate, string $object, string $label = ''):void{
$this->ProcessMulti(CayleyOp::WRITE, [shape(
'subject' => $subject,
'predicate' => $predicate,
'object' => $object,
'label' => $label
)]);
}
public function delete(string $subject, string $predicate, string $object, string $label = ''):void{
$this->ProcessMulti(CayleyOp::DELETE, [shape(
'subject' => $subject,
'predicate' => $predicate,
'object' => $object,
'label' => $label
)]);
}
public function ProcessMulti(CayleyOp $Op, Traversable<TypeCayleyEntry> $Items):void{
$Items = json_encode($Items);
$CH = curl_init('http://'.$this->URL.'/api/v1/'.$Op);
curl_setopt_array($CH,[
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => $Items
]);
curl_exec($CH);
curl_close($CH);
}
}
| 27.3125 | 102 | 0.620137 | steelbrain |
bac3247d079e96a32b58c32aa87c2f2665545707 | 164 | cc | C++ | src/DetectorHit.cc | skscurious/Geant4_JPET | a5846af20b8b4b886f33c54552631623e1749fac | [
"Apache-2.0"
] | null | null | null | src/DetectorHit.cc | skscurious/Geant4_JPET | a5846af20b8b4b886f33c54552631623e1749fac | [
"Apache-2.0"
] | null | null | null | src/DetectorHit.cc | skscurious/Geant4_JPET | a5846af20b8b4b886f33c54552631623e1749fac | [
"Apache-2.0"
] | null | null | null | #include "DetectorHit.hh"
DetectorHit::DetectorHit()
: G4VHit(), fScinID(0), fTrackID(-1), fEdep(0.0), fTime(0), fPos(0)
{}
DetectorHit::~DetectorHit()
{}
| 14.909091 | 72 | 0.640244 | skscurious |
bac50e1c285675028a116f04c0065e3dcea125c5 | 5,596 | cpp | C++ | ch17/ex17_4_5_6_7_8.cpp | 0iui0/Cpp-Primer | ff8530a202ac0340a3e8de6bb9726cf0516c50fc | [
"CC0-1.0"
] | null | null | null | ch17/ex17_4_5_6_7_8.cpp | 0iui0/Cpp-Primer | ff8530a202ac0340a3e8de6bb9726cf0516c50fc | [
"CC0-1.0"
] | null | null | null | ch17/ex17_4_5_6_7_8.cpp | 0iui0/Cpp-Primer | ff8530a202ac0340a3e8de6bb9726cf0516c50fc | [
"CC0-1.0"
] | null | null | null | /***************************************************************************
* @file main.cpp
* @author Alan.W
* @date 3 Mar 2014
* @remark This code is for the exercises from C++ Primer 5th Edition
* @note
***************************************************************************/
//
// Exercise 17.4:
// Write and test your own version of the findBook function.
//
// Exercise 17.5:
// Rewrite findBook to return a pair that holds an index and a pair of iterators.
//
// Exercise 17.6:
// Rewrite findBook so that it does not use tuple or pair.
//
// Exercise 17.7:
// Explain which version of findBook you prefer and why.
//
// The version using tuple is prefered.It's more flexible, campared to other versions.
//
// Exercise 17.8:
// What would happen if we passed Sales_data() as the third parameter to accumulate
// in the last code example in this section?
//
// If so, the output should be 0, as the Sales_data is default constructed.
//
#include <iostream>
#include <tuple>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <numeric>
#include "ex17_4_5_6_7_8_SalesData.h"
// for ex17.4
// maches has 3 members:
// an index of a store and iterators into that store's vector
typedef std::tuple<std::vector<Sales_data>::size_type,
std::vector<Sales_data>::const_iterator,
std::vector<Sales_data>::const_iterator>
matches;
// for ex17.5
// return a pair that holds an index and a pair of iterators.
typedef std::pair<std::vector<Sales_data>::size_type,
std::pair<std::vector<Sales_data>::const_iterator,
std::vector<Sales_data>::const_iterator>>
matches_pair;
// for ex17.6
// return a struct that holds an index of a store and iterators into that store's vector
struct matches_struct {
std::vector<Sales_data>::size_type st;
std::vector<Sales_data>::const_iterator first;
std::vector<Sales_data>::const_iterator last;
matches_struct(std::vector<Sales_data>::size_type s,
std::vector<Sales_data>::const_iterator f,
std::vector<Sales_data>::const_iterator l) : st(s), first(f), last(l) {}
};
// for ex17.4
// return a vector with an entry for each store that sold the given book.
std::vector<matches>
findBook(const std::vector<std::vector<Sales_data>> &files,
const std::string &book);
// print the result using the given iostream
void reportResults(std::istream &in, std::ostream os,
const std::vector<std::vector<Sales_data>> &files);
// for ex17.5
// return a vector with an entry for each store that sold the given book.
std::vector<matches_pair>
findBook_pair(const std::vector<std::vector<Sales_data> > &files,
const std::string &book);
// for ex17.6
// return a vector with an entry for each store that sold the given book.
std::vector<matches_struct>
findBook_struct(const std::vector<std::vector<Sales_data> > &files,
const std::string &book);
int main() {
return 0;
}
// for ex17.4
// return a vector with an entry for each store that sold the given book.
std::vector<matches>
findBook(const std::vector<std::vector<Sales_data>> &files,
const std::string &book) {
std::vector<matches> ret;
// for each strore find the range of matching books, if any
for (auto it = files.cbegin(); it != files.cend(); ++it) {
// find the range of Sales_data tat have the same ISBN
auto found = std::equal_range(it->cbegin(), it->cend(), book, compareIsbn);
if (found.first != found.second)
ret.push_back(std::make_tuple(it - files.cbegin(),
found.first, found.second));
}
return ret;
}
// for ex17.4
// print the result using the given iostream
void reportResults(std::istream &in, std::ostream os,
const std::vector<std::vector<Sales_data>> &files) {
std::string s;
while (in >> s) {
auto trans = findBook(files, s);
if (trans.empty()) {
std::cout << s << "not found in any stores" << std::endl;
continue;
}
for (const auto &store :trans)
os << "store " << std::get<0>(store) << " sales: "
<< std::accumulate(std::get<1>(store), std::get<2>(store),
Sales_data(s))
<< std::endl;
}
}
// for ex17.5
// return a vector with an entry for each store that sold the given book
std::vector<matches_pair>
findBook_pair(const std::vector<std::vector<Sales_data> > &files,
const std::string &book) {
std::vector<matches_pair> ret;
for (auto it = files.cbegin(); it != files.cend(); ++it) {
auto found = std::equal_range(it->cbegin(), it->cend(), book, compareIsbn);
if (found.first != found.second)
ret.push_back(std::make_pair(it - files.cbegin(),
std::make_pair(found.first, found.second)));
}
return ret;
}
// for ex17.6
// return a vector with an entry for each store that sold the given book.
std::vector<matches_struct>
findBook_struct(const std::vector<std::vector<Sales_data> > &files,
const std::string &book) {
std::vector<matches_struct> ret;
for (auto it = files.cbegin(); it != files.cend(); ++it) {
auto found = std::equal_range(it->cbegin(), it->cend(), book, compareIsbn);
if (found.first != found.second)
ret.push_back(matches_struct(it - files.cbegin(), found.first, found.second));
}
return ret;
}
| 34.757764 | 91 | 0.615797 | 0iui0 |
bace3891a327416cd367e230de6bf75a85aca29a | 3,832 | cpp | C++ | wpb_mani_description/src/wpb_mani_test.cpp | 6-robot/wpb_mani | 6aa6e2d8713c8d018a422e4665ff8fcd7e299ad0 | [
"BSD-3-Clause"
] | 4 | 2021-02-08T03:55:26.000Z | 2021-12-13T12:06:34.000Z | wpb_mani_description/src/wpb_mani_test.cpp | 6-robot/wpb_mani | 6aa6e2d8713c8d018a422e4665ff8fcd7e299ad0 | [
"BSD-3-Clause"
] | null | null | null | wpb_mani_description/src/wpb_mani_test.cpp | 6-robot/wpb_mani | 6aa6e2d8713c8d018a422e4665ff8fcd7e299ad0 | [
"BSD-3-Clause"
] | 1 | 2021-06-08T01:17:54.000Z | 2021-06-08T01:17:54.000Z | /*********************************************************************
* Software License Agreement (BSD License)
*
* Copyright (c) 2017-2020, Waterplus http://www.6-robot.com
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of the WaterPlus nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* FOOTPRINTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*********************************************************************/
/*!******************************************************************
@author ZhangWanjie
********************************************************************/
#include <ros/ros.h>
#include <sensor_msgs/JointState.h>
#include <math.h>
#include <vector>
#include <string>
static double fDegToAng = 3.1415926/180;
static double fAngToDeg = 180/3.1415926;
static double fJointAngle[6];
static int nJointSpeed[6];
int main(int argc, char** argv)
{
ros::init(argc,argv,"wpb_mani_test");
ROS_INFO("[wpb_mani_test]");
ros::NodeHandle n;
for(int i=0;i<5;i++)
{
fJointAngle[i] = 0;
nJointSpeed[i] = 1500;
}
ros::Publisher joint_state_pub = n.advertise<sensor_msgs::JointState>("/joint_states",10);
sensor_msgs::JointState msg;
std::vector<std::string> joint_name(11);
std::vector<double> joint_pos(11);
joint_name[0] = "front_left_wheel_joint";
joint_name[1] = "front_right_wheel_joint";
joint_name[2] = "back_right_wheel_joint";
joint_name[3] = "back_left_wheel_joint";
joint_name[4] = "kinect_height";
joint_name[5] = "kinect_pitch";
joint_name[6] = "joint1";
joint_name[7] = "joint2";
joint_name[8] = "joint3";
joint_name[9] = "joint4";
joint_name[10] = "gripper";
joint_pos[0] = 0.0f;
joint_pos[1] = 0.0f;
joint_pos[2] = 0.0f;
joint_pos[3] = 0.0f;
joint_pos[4] = 0.0f;
joint_pos[5] = 0.0f;
joint_pos[6] = 0.0f;
joint_pos[7] = 0.0f;
joint_pos[8] = 0.0f;
joint_pos[9] = 0.0f;
joint_pos[10] = 0.0f;
int nCount = 0;
ros::Rate r(30);
while(n.ok())
{
nCount += 5;
joint_pos[0] = (float)nCount*0.01;
joint_pos[1] = (float)nCount*-0.01;
joint_pos[2] = (float)nCount*-0.01;
joint_pos[3] = (float)nCount*0.01;
msg.header.stamp = ros::Time::now();
msg.header.seq ++;
msg.name = joint_name;
msg.position = joint_pos;
joint_state_pub.publish(msg);
ros::spinOnce();
r.sleep();
}
} | 35.813084 | 94 | 0.625 | 6-robot |
bacecdee6338b7f7be7809e6720c6657bd8ef62d | 3,855 | cpp | C++ | src/Pyros3D/Rendering/PostEffects/Effects/MotionBlurEffect.cpp | Peixinho/Pyros3D | d6857ce99f3731a851ca5e7d67afbb13aafd18e0 | [
"MIT"
] | 20 | 2016-02-15T23:22:06.000Z | 2021-12-07T00:13:49.000Z | src/Pyros3D/Rendering/PostEffects/Effects/MotionBlurEffect.cpp | Peixinho/Pyros3D | d6857ce99f3731a851ca5e7d67afbb13aafd18e0 | [
"MIT"
] | 1 | 2017-09-04T00:28:19.000Z | 2017-09-05T11:00:12.000Z | src/Pyros3D/Rendering/PostEffects/Effects/MotionBlurEffect.cpp | Peixinho/Pyros3D | d6857ce99f3731a851ca5e7d67afbb13aafd18e0 | [
"MIT"
] | 3 | 2016-08-10T02:44:08.000Z | 2021-05-28T23:03:10.000Z | //============================================================================
// Name : MotionBlur.h
// Author : Duarte Peixinho
// Version :
// Copyright : ;)
// Description : MotionBlur Effect
//============================================================================
#include <Pyros3D/Rendering/PostEffects/Effects/MotionBlurEffect.h>
namespace p3d {
MotionBlurEffect::MotionBlurEffect(const uint32 Tex1, Texture* VelocityMap, const uint32 Width, const uint32 Height) : IEffect(Width, Height)
{
// Set RTT
UseRTT(Tex1);
UseCustomTexture(VelocityMap);
//Vec2 res = Vec2(Width, Height);
f32 vel = 3.25f;
//texResHandle = AddUniform(Uniform("uTexResolution", Uniforms::DataType::Vec2, &res));
velHandle = AddUniform(Uniform("uVelocityScale", Uniforms::DataType::Float, &vel));
VertexShaderString =
#if defined(GLES2)
"#define varying_in varying\n"
"#define varying_out varying\n"
"#define attribute_in attribute\n"
"#define texture_2D texture2D\n"
"#define texture_cube textureCube\n"
"precision mediump float;"
#else
"#define varying_in in\n"
"#define varying_out out\n"
"#define attribute_in in\n"
"#define texture_2D texture\n"
"#define texture_cube texture\n"
#if defined(GLES3)
"precision mediump float;\n"
#endif
#endif
"varying_out vec2 vTexcoord;\n"
"void main() {\n"
"gl_Position = vec4(-1.0 + vec2((gl_VertexID & 1) << 2, (gl_VertexID & 2) << 1), 0.0, 1.0);\n"
"vTexcoord = (gl_Position.xy+1.0)*0.5;\n"
"}";
// Create Fragment Shader
FragmentShaderString =
"#define MAX_SAMPLES 32\n"
#if defined(GLES2)
"#define varying_in varying\n"
"#define varying_out varying\n"
"#define attribute_in attribute\n"
"#define texture_2D texture2D\n"
"#define texture_cube textureCube\n"
"precision mediump float;"
#else
"#define varying_in in\n"
"#define varying_out out\n"
"#define attribute_in in\n"
"#define texture_2D texture\n"
"#define texture_cube texture\n"
#if defined(GLES3)
"precision mediump float;\n"
#endif
#endif
#if defined(GLES2)
"vec4 FragColor;\n"
#else
"out vec4 FragColor;\n"
#endif
"varying_in vec2 vTexcoord;\n"
"uniform sampler2D uTex0;\n"
"uniform sampler2D uTex1;\n"
"uniform vec2 uTexResolution;\n"
"uniform float uVelocityScale;\n"
"void main() {\n"
"vec2 texelSize = 1.0 / vec2(textureSize(uTex0, 0));\n"
"vec2 screenTexCoords = gl_FragCoord.xy * texelSize;\n"
"vec2 velocity = texture(uTex1, screenTexCoords).rg;\n"
"velocity *= uVelocityScale;\n"
"float speed = length(velocity / texelSize);\n"
"float nSamples = clamp(int(speed), 1, MAX_SAMPLES);\n"
"vec4 oResult = texture(uTex0, screenTexCoords);\n"
"for (int i = 1; i < nSamples; ++i) {\n"
" vec2 offset = velocity * (float(i) / float(nSamples - 1) - 0.5);\n"
" oResult += texture(uTex0, screenTexCoords + offset);\n"
"}\n"
"FragColor = oResult / float(nSamples);\n"
#if defined(GLES2)
"gl_FragColor = FragColor;\n"
#endif
"}";
CompileShaders();
}
MotionBlurEffect::~MotionBlurEffect() {
}
void MotionBlurEffect::SetCurrentFPS(const f32 ¤tfps) {
this->cfps = currentfps;
f32 v = cfps/tfps;
velHandle->SetValue(&v);
}
void MotionBlurEffect::SetTargetFPS(const f32 &targetfps) {
this->tfps = targetfps;
f32 v = cfps/tfps;
velHandle->SetValue(&v);
}
};
| 33.232759 | 146 | 0.563684 | Peixinho |
bad44eb45c38c0009b04cd2f484bcf1b438c9396 | 3,670 | hpp | C++ | 3rd-party/apache/xsec/src/xsec/enc/XSECCryptoX509.hpp | okean/cpputils | 812cf41f04d66c28a5eb46dedab6e782c49e0f7a | [
"Naumen",
"Condor-1.1",
"MS-PL"
] | 1 | 2019-08-30T02:34:29.000Z | 2019-08-30T02:34:29.000Z | 3rd-party/apache/xsec/src/xsec/enc/XSECCryptoX509.hpp | okean/cpputils | 812cf41f04d66c28a5eb46dedab6e782c49e0f7a | [
"Naumen",
"Condor-1.1",
"MS-PL"
] | null | null | null | 3rd-party/apache/xsec/src/xsec/enc/XSECCryptoX509.hpp | okean/cpputils | 812cf41f04d66c28a5eb46dedab6e782c49e0f7a | [
"Naumen",
"Condor-1.1",
"MS-PL"
] | null | null | null | /**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
/*
* XSEC
*
* XSECCryptoX509:= A base class for handling X509 (V3) certificates
*
* Author(s): Berin Lautenbach
*
* $Id: XSECCryptoX509.hpp 1125514 2011-05-20 19:08:33Z scantor $
*
*/
#ifndef XSECCRYPTOX509_INCLUDE
#define XSECCRYPTOX509_INCLUDE
#include <xsec/framework/XSECDefs.hpp>
#include <xsec/enc/XSECCryptoKey.hpp>
#include <xsec/utils/XSECSafeBuffer.hpp>
/**
* \brief Interface class for X509 certificates.
* @ingroup crypto
*
* The library uses classes derived from this to process X509 Certificates.
*
* Strictly speaking, this class is not required (and is completely
* <em>Optional</em>. However it is used by
* XSECKeyInfoResolverDefault to extract a key from a certificate in cases
* where the caller is not worried about the trust level of the certificate.
*
*/
class DSIG_EXPORT XSECCryptoX509 {
public :
/** @name Constructors and Destructors */
//@{
XSECCryptoX509() {};
virtual ~XSECCryptoX509() {};
//@}
/** @name Key Interface methods */
//@{
/**
* \brief Return the type of the key stored in the certificate.
*
* The implementation is expected to extract the key from the
* certificate and determine the type.
*
*/
virtual XSECCryptoKey::KeyType getPublicKeyType() const = 0;
/**
* \brief Get a copy of the public key.
*
* The implementation should extract the key from the certificate,
* create an instance of the appropriate key type, and return it.
*
*/
virtual XSECCryptoKey * clonePublicKey() const = 0;
/**
* \brief Returns a string that identifies the crypto owner of this library.
*/
virtual const XMLCh * getProviderName() const = 0;
//@}
/** @name Load and Get the certificate */
//@{
/**
* \brief Load a certificate into the object.
*
* Take a base64 DER encoded certificate and load.
*
* @param buf A buffer containing the Base64 encoded certificate
* @param len The number of bytes of data in the certificate.
*/
virtual void loadX509Base64Bin(const char * buf, unsigned int len) = 0;
/**
* \brief Load a PEM encoded certificate into the object.
*
* Take a PEM encoded certificate and load.
*
* @param buf A buffer containing the PEM encoded certificate
* @param len The number of bytes of data in the certificate.
* (0 if the string is null terminated.)
*/
void loadX509PEM(const char * buf, unsigned int len = 0);
/**
* \brief Get a Base64 DER encoded copy of the certificate
*
* @returns A safeBuffer containing the DER encoded certificate
*/
virtual safeBuffer &getDEREncodingSB(void) = 0; // Get the DER string
/**
* \brief Get a Base64 DER encoded copy of the certificate
*
* @returns A safeBuffer containing the DER encoded certificate
*/
virtual const safeBuffer &getDEREncodingSB(void) const = 0; // Get the DER string
//@}
};
#endif /* XSECCRYPTOX509_INCLUDE */
| 25.486111 | 83 | 0.708992 | okean |
bad5c2147b8f8a6ea7de87d310289fb411af4bf1 | 9,926 | cpp | C++ | Moco/Moco/Components/PositionMotion.cpp | zhengsizehrb/opensim-moco | 9844abc640a34d818a4bb21ef4fea3c3cb0f34ed | [
"Apache-2.0"
] | 41 | 2019-11-13T10:29:20.000Z | 2022-03-10T17:42:30.000Z | Moco/Moco/Components/PositionMotion.cpp | zhengsizehrb/opensim-moco | 9844abc640a34d818a4bb21ef4fea3c3cb0f34ed | [
"Apache-2.0"
] | 165 | 2019-11-13T00:55:57.000Z | 2022-03-04T19:02:26.000Z | Moco/Moco/Components/PositionMotion.cpp | zhengsizehrb/opensim-moco | 9844abc640a34d818a4bb21ef4fea3c3cb0f34ed | [
"Apache-2.0"
] | 15 | 2020-01-24T23:57:57.000Z | 2021-12-10T21:59:46.000Z | /* -------------------------------------------------------------------------- *
* OpenSim Moco: PositionMotion.cpp *
* -------------------------------------------------------------------------- *
* Copyright (c) 2019 Stanford University and the Authors *
* *
* Author(s): Christopher Dembia *
* *
* Licensed under the Apache License, Version 2.0 (the "License"); you may *
* not use this file except in compliance with the License. You may obtain a *
* copy of the License at http://www.apache.org/licenses/LICENSE-2.0 *
* *
* Unless required by applicable law or agreed to in writing, software *
* distributed under the License is distributed on an "AS IS" BASIS, *
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
* See the License for the specific language governing permissions and *
* limitations under the License. *
* -------------------------------------------------------------------------- */
#include "PositionMotion.h"
#include "../MocoUtilities.h"
#include <OpenSim/Common/Function.h>
#include <OpenSim/Common/GCVSplineSet.h>
#include <OpenSim/Simulation/Model/Model.h>
#include <OpenSim/Simulation/SimbodyEngine/Coordinate.h>
#include <OpenSim/Simulation/StatesTrajectory.h>
using namespace OpenSim;
class SimTKPositionMotionImplementation
: public SimTK::Motion::Custom::Implementation {
public:
void setFunctions(std::vector<Function*> functions) {
m_functions = std::move(functions);
}
SimTK::Motion::Level getLevel(const SimTK::State&) const override {
return SimTK::Motion::Level::Position;
}
/// nq: The number of generalized coordinates for this MobilizedBody.
/// q: The values of the generalized coordinates to set, with length nq.
void calcPrescribedPosition(
const SimTK::State& s, int nq, SimTK::Real* q) const override {
if (m_functions.size()) {
for (int i = 0; i < nq; ++i) {
m_funcArgs[0] = s.getTime();
q[i] = m_functions[i]->calcValue(m_funcArgs);
}
}
}
void calcPrescribedPositionDot(
const SimTK::State& s, int nq, SimTK::Real* qdot) const override {
if (m_functions.size()) {
for (int i = 0; i < nq; ++i) {
m_funcArgs[0] = s.getTime();
qdot[i] = m_functions[i]->calcDerivative(
m_qdotDerivComponents, m_funcArgs);
}
}
}
void calcPrescribedPositionDotDot(const SimTK::State& s, int nq,
SimTK::Real* qdotdot) const override {
if (m_functions.size()) {
for (int i = 0; i < nq; ++i) {
m_funcArgs[0] = s.getTime();
qdotdot[i] = m_functions[i]->calcDerivative(
m_qdotdotDerivComponents, m_funcArgs);
}
}
}
private:
std::vector<Function*> m_functions;
mutable SimTK::Vector m_funcArgs = SimTK::Vector(1);
static const std::vector<int> m_qdotDerivComponents;
static const std::vector<int> m_qdotdotDerivComponents;
};
const std::vector<int>
SimTKPositionMotionImplementation::m_qdotDerivComponents = {0};
const std::vector<int>
SimTKPositionMotionImplementation::m_qdotdotDerivComponents = {0, 0};
class SimTKPositionMotion : public SimTK::Motion::Custom {
public:
SimTKPositionMotion(SimTK::MobilizedBody& mobod)
: Motion::Custom(mobod, new SimTKPositionMotionImplementation()) {}
void setFunctions(std::vector<Function*> functions) {
static_cast<SimTKPositionMotionImplementation&>(updImplementation())
.setFunctions(std::move(functions));
}
};
void PositionMotion::setPositionForCoordinate(
const Coordinate& coord, const Function& position) {
const auto path = coord.getAbsolutePathString();
auto pos = std::unique_ptr<Function>(position.clone());
pos->setName(path);
if (get_functions().contains(path)) {
upd_functions().set(get_functions().getIndex(path), *pos);
} else {
upd_functions().adoptAndAppend(pos.release());
}
}
void PositionMotion::setEnabled(SimTK::State& state, bool enabled) const {
for (auto& motion : m_motions) {
if (enabled) {
motion.enable(state);
} else {
motion.disable(state);
}
}
}
bool PositionMotion::getEnabled(const SimTK::State& state) const {
if (m_motions.size() && !m_motions[0].isDisabled(state)) return true;
return false;
}
std::unique_ptr<PositionMotion> PositionMotion::createFromTable(
const Model& model, const TimeSeriesTable& table,
bool allowExtraColumns) {
auto posmot = std::unique_ptr<PositionMotion>(new PositionMotion());
const auto& labels = table.getColumnLabels();
// TODO: Avoid splining extra columns.
GCVSplineSet splines(table);
for (auto label : labels) {
std::string coordPath = label;
if (endsWith(label, "/value")) {
// This assumes that the coordinate is not named "value".
coordPath = label.substr(0, label.find("/value"));
const auto& coord = model.getComponent<Coordinate>(coordPath);
const auto path = coord.getAbsolutePathString();
posmot->setPositionForCoordinate(coord, splines.get(label));
} else {
OPENSIM_THROW_IF(!model.findComponent<Component>(coordPath) &&
!allowExtraColumns,
Exception, "Column '{}' is not a coordinate.", label);
}
}
return posmot;
}
std::unique_ptr<PositionMotion> PositionMotion::createFromStatesTrajectory(
const Model& model, const StatesTrajectory& statesTraj) {
const auto coords = model.getCoordinatesInMultibodyTreeOrder();
std::vector<std::string> coordSVNames;
for (const auto& coord : coords) {
coordSVNames.push_back(coord->getStateVariableNames()[0]);
}
return createFromTable(
model, statesTraj.exportToTable(model, coordSVNames));
}
TimeSeriesTable PositionMotion::exportToTable(
const std::vector<double>& time) const {
TimeSeriesTable table(time);
std::vector<std::string> labels;
SimTK::Vector value((int)time.size());
SimTK::Vector speed((int)time.size());
SimTK::Vector thisTime(1);
for (int ifunc = 0; ifunc < get_functions().getSize(); ++ifunc) {
for (int itime = 0; itime < (int)time.size(); ++itime) {
thisTime[0] = time[itime];
value[itime] = get_functions().get(ifunc).calcValue(thisTime);
speed[itime] = get_functions().get(ifunc).calcDerivative(
std::vector<int>{0}, thisTime);
}
const std::string& name = get_functions().get(ifunc).getName();
table.appendColumn(name + "/value", value);
table.appendColumn(name + "/speed", speed);
}
return table;
}
void PositionMotion::extendAddToSystem(SimTK::MultibodySystem& system) const {
Super::extendAddToSystem(system);
auto& matter = system.updMatterSubsystem();
m_motions.clear();
for (int imb = 0; imb < matter.getNumBodies(); ++imb) {
auto& mobod = matter.updMobilizedBody(SimTK::MobilizedBodyIndex(imb));
m_motions.push_back(SimTKPositionMotion(mobod));
m_motions.back().setDisabledByDefault(!get_default_enabled());
}
}
void PositionMotion::extendRealizeTopology(SimTK::State& state) const {
Super::extendRealizeTopology(state);
// Ensure all coordinates are prescribed.
const auto coords = getModel().getComponentList<Coordinate>();
for (const auto& coord : coords) {
const auto& path = coord.getAbsolutePathString();
OPENSIM_THROW_IF(!get_functions().contains(path), Exception,
"No function provided for coordinate '{}'.", path);
}
// Create a mapping from SimTK position DOFs to OpenSim Coordinates.
// We identify a SimTK DOF as a MobilizedBodyIndex and a Q index.
std::map<std::pair<SimTK::MobilizedBodyIndex, int>, std::string>
indicesToCoordName;
for (int i = 0; i < get_functions().getSize(); ++i) {
const auto& path = get_functions().get(i).getName();
const auto& coord = getModel().getComponent<Coordinate>(path);
const auto mbi = coord.getBodyIndex();
const auto qIndex = coord.getMobilizerQIndex();
indicesToCoordName[std::make_pair(mbi, qIndex)] = path;
}
auto& matter = getSystem().getMatterSubsystem();
for (SimTK::MobilizedBodyIndex mbi(0); mbi < matter.getNumBodies(); ++mbi) {
auto& mobod = matter.getMobilizedBody(mbi);
// Create the vector of functions to provide to the SimTK::Motion for
// this MobilizedBody.
std::vector<Function*> mobodFunctions;
for (int iq = 0; iq < mobod.getNumQ(state); ++iq) {
const auto key = std::make_pair(mbi, iq);
// This skips over unused quaternion slots, as indicesToCoordName
// doesn't have entries for such slots.
if (indicesToCoordName.count(key)) {
const auto& coordName = indicesToCoordName.at(key);
mobodFunctions.push_back(
const_cast<Function*>(&get_functions().get(coordName)));
}
}
auto& motion = const_cast<SimTK::Motion&>(m_motions[mbi]);
auto& customMotion = static_cast<SimTKPositionMotion&>(motion);
customMotion.setFunctions(std::move(mobodFunctions));
}
}
| 42.969697 | 80 | 0.600544 | zhengsizehrb |
bad818c0912e9953676db2a077bd411ec714a159 | 2,560 | cpp | C++ | src/engine/scene/camera/OrthoCamera.cpp | zapolnov/TankHero | a907417dc171cb0d4ea04539ae09ba37ee7782ab | [
"MIT"
] | null | null | null | src/engine/scene/camera/OrthoCamera.cpp | zapolnov/TankHero | a907417dc171cb0d4ea04539ae09ba37ee7782ab | [
"MIT"
] | null | null | null | src/engine/scene/camera/OrthoCamera.cpp | zapolnov/TankHero | a907417dc171cb0d4ea04539ae09ba37ee7782ab | [
"MIT"
] | null | null | null | #include "OrthoCamera.h"
#include <glm/gtc/matrix_transform.hpp>
OrthoCamera::OrthoCamera()
: mLeft(-1.0f)
, mTop(1.0f)
, mRight(1.0f)
, mBottom(-1.0f)
, mNearZ(-10.0f)
, mFarZ(10.0f)
{
}
void OrthoCamera::setLeft(float left)
{
if (mLeft != left) {
mLeft = left;
invalidateProjectionMatrix();
}
}
void OrthoCamera::setTop(float top)
{
if (mTop != top) {
mTop = top;
invalidateProjectionMatrix();
}
}
void OrthoCamera::setRight(float right)
{
if (mRight != right) {
mRight = right;
invalidateProjectionMatrix();
}
}
void OrthoCamera::setBottom(float bottom)
{
if (mBottom != bottom) {
mBottom = bottom;
invalidateProjectionMatrix();
}
}
void OrthoCamera::setDimensions(float left, float right, float bottom, float top)
{
if (mLeft != left || mRight != right || mBottom != bottom || mTop != top) {
mLeft = left;
mRight = right;
mTop = top;
mBottom = bottom;
invalidateProjectionMatrix();
}
}
void OrthoCamera::setSize(float width, float height)
{
float oldSizeX = (mRight - mLeft);
float oldSizeY = (mBottom - mTop);
if (oldSizeX == width && oldSizeY == height)
return;
float centerX = mLeft + oldSizeX * 0.5f;
float centerY = mTop + oldSizeY * 0.5f;
float halfWidth = width * 0.5f;
float halfHeight = height * 0.5f;
if (mLeft > mRight)
halfWidth = -halfWidth;
if (mTop > mBottom)
halfHeight = -halfHeight;
mLeft = centerX - halfWidth;
mRight = centerX + halfWidth;
mTop = centerY - halfHeight;
mBottom = centerY + halfHeight;
invalidateProjectionMatrix();
}
void OrthoCamera::setNearZ(float nearZ)
{
if (mNearZ != nearZ) {
mNearZ = nearZ;
invalidateProjectionMatrix();
}
}
void OrthoCamera::setFarZ(float farZ)
{
if (mFarZ != farZ) {
mFarZ = farZ;
invalidateProjectionMatrix();
}
}
void OrthoCamera::setZRange(float nearZ, float farZ)
{
if (mNearZ != nearZ || mFarZ != farZ) {
mNearZ = nearZ;
mFarZ = farZ;
invalidateProjectionMatrix();
}
}
bool OrthoCamera::unproject2D(glm::vec2& point)
{
point = glm::vec2(inverseProjectionViewMatrix() * glm::vec4(point, 0.0f, 1.0f));
return true;
}
void OrthoCamera::calcProjectionMatrix(glm::mat4& m) const
{
m = glm::ortho(mLeft, mRight, mBottom, mTop, mNearZ, mFarZ);
}
void OrthoCamera::calcViewMatrix(glm::mat4& m) const
{
m = glm::mat4(1.0f);
}
| 20.645161 | 84 | 0.603125 | zapolnov |
bada555810c2c66cf5c07f4c5f30bcfab431ad44 | 9,358 | cpp | C++ | src/gpu/GrTextureRenderTargetProxy.cpp | aam/skia | e7bc0844989faff96aa22ae052cc8603d6f8c6b9 | [
"BSD-3-Clause"
] | 1 | 2021-04-09T23:24:57.000Z | 2021-04-09T23:24:57.000Z | src/gpu/GrTextureRenderTargetProxy.cpp | aam/skia | e7bc0844989faff96aa22ae052cc8603d6f8c6b9 | [
"BSD-3-Clause"
] | null | null | null | src/gpu/GrTextureRenderTargetProxy.cpp | aam/skia | e7bc0844989faff96aa22ae052cc8603d6f8c6b9 | [
"BSD-3-Clause"
] | null | null | null | /*
* Copyright 2016 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#include "src/gpu/GrTextureRenderTargetProxy.h"
#include "include/gpu/GrTexture.h"
#include "src/gpu/GrCaps.h"
#include "src/gpu/GrContextPriv.h"
#include "src/gpu/GrRenderTarget.h"
#include "src/gpu/GrRenderTargetProxyPriv.h"
#include "src/gpu/GrSurfacePriv.h"
#include "src/gpu/GrSurfaceProxyPriv.h"
#include "src/gpu/GrTexturePriv.h"
#include "src/gpu/GrTextureProxyPriv.h"
// Deferred version
// This class is virtually derived from GrSurfaceProxy (via both GrTextureProxy and
// GrRenderTargetProxy) so its constructor must be explicitly called.
GrTextureRenderTargetProxy::GrTextureRenderTargetProxy(const GrCaps& caps,
const GrBackendFormat& format,
const GrSurfaceDesc& desc,
int sampleCnt,
GrSurfaceOrigin origin,
GrMipMapped mipMapped,
GrMipMapsStatus mipMapsStatus,
const GrSwizzle& texSwizzle,
const GrSwizzle& outSwizzle,
SkBackingFit fit,
SkBudgeted budgeted,
GrProtected isProtected,
GrInternalSurfaceFlags surfaceFlags,
UseAllocator useAllocator)
: GrSurfaceProxy(format, desc, GrRenderable::kYes, origin, texSwizzle, fit, budgeted,
isProtected, surfaceFlags, useAllocator)
// for now textures w/ data are always wrapped
, GrRenderTargetProxy(caps, format, desc, sampleCnt, origin, texSwizzle, outSwizzle, fit,
budgeted, isProtected, surfaceFlags, useAllocator)
, GrTextureProxy(format, desc, origin, mipMapped, mipMapsStatus, texSwizzle, fit, budgeted,
isProtected, surfaceFlags, useAllocator) {
this->initSurfaceFlags(caps);
}
// Lazy-callback version
GrTextureRenderTargetProxy::GrTextureRenderTargetProxy(const GrCaps& caps,
LazyInstantiateCallback&& callback,
const GrBackendFormat& format,
const GrSurfaceDesc& desc,
int sampleCnt,
GrSurfaceOrigin origin,
GrMipMapped mipMapped,
GrMipMapsStatus mipMapsStatus,
const GrSwizzle& texSwizzle,
const GrSwizzle& outSwizzle,
SkBackingFit fit,
SkBudgeted budgeted,
GrProtected isProtected,
GrInternalSurfaceFlags surfaceFlags,
UseAllocator useAllocator)
: GrSurfaceProxy(std::move(callback), format, desc, GrRenderable::kYes, origin, texSwizzle,
fit, budgeted, isProtected, surfaceFlags, useAllocator)
// Since we have virtual inheritance, we initialize GrSurfaceProxy directly. Send null
// callbacks to the texture and RT proxies simply to route to the appropriate constructors.
, GrRenderTargetProxy(LazyInstantiateCallback(), format, desc, sampleCnt, origin,
texSwizzle, outSwizzle, fit, budgeted, isProtected, surfaceFlags,
useAllocator, WrapsVkSecondaryCB::kNo)
, GrTextureProxy(LazyInstantiateCallback(), format, desc, origin, mipMapped, mipMapsStatus,
texSwizzle, fit, budgeted, isProtected, surfaceFlags, useAllocator) {
this->initSurfaceFlags(caps);
}
// Wrapped version
// This class is virtually derived from GrSurfaceProxy (via both GrTextureProxy and
// GrRenderTargetProxy) so its constructor must be explicitly called.
GrTextureRenderTargetProxy::GrTextureRenderTargetProxy(sk_sp<GrSurface> surf,
GrSurfaceOrigin origin,
const GrSwizzle& texSwizzle,
const GrSwizzle& outSwizzle,
UseAllocator useAllocator)
: GrSurfaceProxy(surf, origin, texSwizzle, SkBackingFit::kExact, useAllocator)
, GrRenderTargetProxy(surf, origin, texSwizzle, outSwizzle, useAllocator)
, GrTextureProxy(surf, origin, texSwizzle, useAllocator) {
SkASSERT(surf->asTexture());
SkASSERT(surf->asRenderTarget());
SkASSERT(fSurfaceFlags == fTarget->surfacePriv().flags());
SkASSERT((this->numSamples() <= 1 ||
fTarget->getContext()->priv().caps()->msaaResolvesAutomatically()) !=
this->requiresManualMSAAResolve());
}
void GrTextureRenderTargetProxy::initSurfaceFlags(const GrCaps& caps) {
// FBO 0 should never be wrapped as a texture render target.
SkASSERT(!this->rtPriv().glRTFBOIDIs0());
if (this->numSamples() > 1 && !caps.msaaResolvesAutomatically()) {
// MSAA texture-render-targets always require manual resolve if we are not using a
// multisampled-render-to-texture extension.
//
// NOTE: This is the only instance where we need to set the manual resolve flag on a proxy.
// Any other proxies that require manual resolve (e.g., wrapBackendTextureAsRenderTarget())
// will be wrapped, and the wrapped version of the GrSurface constructor will automatically
// get the manual resolve flag when copying the target GrSurface's flags.
fSurfaceFlags |= GrInternalSurfaceFlags::kRequiresManualMSAAResolve;
}
}
size_t GrTextureRenderTargetProxy::onUninstantiatedGpuMemorySize() const {
int colorSamplesPerPixel = this->numSamples();
if (colorSamplesPerPixel > 1) {
// Add one to account for the resolve buffer.
++colorSamplesPerPixel;
}
// TODO: do we have enough information to improve this worst case estimate?
return GrSurface::ComputeSize(this->config(), this->width(), this->height(),
colorSamplesPerPixel, this->proxyMipMapped(),
!this->priv().isExact());
}
bool GrTextureRenderTargetProxy::instantiate(GrResourceProvider* resourceProvider) {
if (this->isLazy()) {
return false;
}
const GrUniqueKey& key = this->getUniqueKey();
if (!this->instantiateImpl(resourceProvider, this->numSamples(), this->numStencilSamples(),
GrRenderable::kYes, this->mipMapped(),
key.isValid() ? &key : nullptr)) {
return false;
}
if (key.isValid()) {
SkASSERT(key == this->getUniqueKey());
}
SkASSERT(this->peekRenderTarget());
SkASSERT(this->peekTexture());
return true;
}
sk_sp<GrSurface> GrTextureRenderTargetProxy::createSurface(
GrResourceProvider* resourceProvider) const {
sk_sp<GrSurface> surface =
this->createSurfaceImpl(resourceProvider, this->numSamples(), this->numStencilSamples(),
GrRenderable::kYes, this->mipMapped());
if (!surface) {
return nullptr;
}
SkASSERT(surface->asRenderTarget());
SkASSERT(surface->asTexture());
return surface;
}
#ifdef SK_DEBUG
void GrTextureRenderTargetProxy::onValidateSurface(const GrSurface* surface) {
// Anything checked here should also be checking the GrTextureProxy version
SkASSERT(surface->asTexture());
SkASSERT(GrMipMapped::kNo == this->proxyMipMapped() ||
GrMipMapped::kYes == surface->asTexture()->texturePriv().mipMapped());
// Anything checked here should also be checking the GrRenderTargetProxy version
SkASSERT(surface->asRenderTarget());
SkASSERT(surface->asRenderTarget()->numSamples() == this->numSamples());
SkASSERT(surface->asTexture()->texturePriv().textureType() == this->textureType());
GrInternalSurfaceFlags proxyFlags = fSurfaceFlags;
GrInternalSurfaceFlags surfaceFlags = surface->surfacePriv().flags();
// Only non-RT textures can be read only.
SkASSERT(!(proxyFlags & GrInternalSurfaceFlags::kReadOnly));
SkASSERT(!(surfaceFlags & GrInternalSurfaceFlags::kReadOnly));
SkASSERT(((int)proxyFlags & kGrInternalTextureRenderTargetFlagsMask) ==
((int)surfaceFlags & kGrInternalTextureRenderTargetFlagsMask));
}
#endif
| 51.136612 | 100 | 0.574695 | aam |
badc4f7b8eb4d5da2a7292a419aa2f4aeeeae723 | 6,041 | cpp | C++ | CSC201/assignments/Test/Chukwudi_Peter_OFOMA_-_CSC201_CA1_Update_1.cpp | ochudi/ochudi-CSC201 | 3a792beef4780960c725ef9bf6c4af96110c373d | [
"MIT"
] | null | null | null | CSC201/assignments/Test/Chukwudi_Peter_OFOMA_-_CSC201_CA1_Update_1.cpp | ochudi/ochudi-CSC201 | 3a792beef4780960c725ef9bf6c4af96110c373d | [
"MIT"
] | null | null | null | CSC201/assignments/Test/Chukwudi_Peter_OFOMA_-_CSC201_CA1_Update_1.cpp | ochudi/ochudi-CSC201 | 3a792beef4780960c725ef9bf6c4af96110c373d | [
"MIT"
] | null | null | null | #include<iostream>
#include<string>
using namespace std;
string Question[]= {"Which of the following is the correct identifier?", "Which of the following is the address operator?","Which of the following features must be supported by any programming language to become a pure object-oriented programming language?","Which of the following refers to characteristics of an array?","If we stored five elements or data items in an array, what will be the index address or the index number of the array's last data item?","Which of the following is the correct syntax for declaring the array?","Which of the following is the correct syntax for accessing the first element?","Which of the following gives the 4th element of the array?","Which type of memory is used by an Array in C++ programming language?","Which one of the following is the correct definition of the is_array(); function in C++?"};
string OptionA[]= {" $var_name","@","Encapsulation","An array is a set of similar data items","2","int array{};","array[2];","array[2];","Contiguous","It checks that the specified variable is of the array or not"};
string OptionB[]= {"VAR_123","#","Inheritance","An array is a set of distinct data items","3","int array [5];","array[0]","array[3]","None-contiguous","It checks that the specified array of single dimension or not"};
string OptionC[]= {"varname@","&","Polymorphism","An array can hold different types of datatypes","4","Array[5];","Array[5];","Array[5];","Both A and B","It checks that the array specified of multi-dimension or not"};
string OptionD[]= {"None of the above","%","All of the above","None of the above","5","None of the above","array[1]","array[1]","Not mentioned","Both B and C"};
string Answer[]= {"B","C","D","A","C","B","B","B","A","A" };
string YourOption[]= {"","","","","","","","","",""};
int score=0;
char start;
void begin() {
cout<<"\t\tWelcome to C++ quiz game"<<endl;
cout<<"\t\t-------------------------"<<endl;
}
void rules() {
cout<<"\t\tRules of the game"<<endl;
cout<<"\t\t------------------"<<endl;
cout<<"You are expected to answer 10 questions"<<endl;
cout<<"You can skip a question and return to it later"<<endl;
cout<<"To answer a question enter the right option on the keyboard and Press Enter"<<endl;
cout<<"To skip a question Press N"<<endl;
cout<<"To go back to previous questions Press P"<<endl;
cout<<"To submit Press F\n\n"<<endl;
}
void play (string *Question, string *OptionA, string *OptionB, string *OptionC, string *OptionD, string *YourOption) {
int counter=0;
string answer;
bool submit=false;
do {
if(counter==10) {
terminal:
cout<<"This is the last question\nPress F to Submit\nPress P to go back to Previous Question\n\n "<<endl;
} else {
cout<<"Question "<<counter+1<<endl;
cout<<*(Question+counter)<<endl;
cout<<"A. "<<*(OptionA+counter)<<" B. "<<*(OptionB+counter)<<endl;
cout<<"C. "<<*(OptionC+counter)<<" D. "<<*(OptionD+counter)<<endl;
if(*(YourOption+counter)=="") {
} else {
cout<<"You selected "<<*(YourOption+counter)<<endl;
}
}
repeat:
cout<<"Enter your Answer ";
cin>>answer;
if((counter==10)&&((answer=="A")||(answer=="a")||(answer=="B")||(answer=="b")||
(answer=="C")||(answer=="c")||(answer=="D")||(answer=="d")||(answer=="N")||(answer=="n")
) ) {
goto terminal;
} else {
if((answer=="A")||(answer=="a")) {
*(YourOption+counter)="A";
counter=counter+1;
cout<<endl;
} else if((answer=="B")||(answer=="b")) {
*(YourOption+counter)="B";
counter=counter+1;
cout<<endl;
} else if((answer=="C")||(answer=="c")) {
*(YourOption+counter)="C";
counter=counter+1;
cout<<endl;
} else if((answer=="D")||(answer=="d")) {
*(YourOption+counter)="D";
counter=counter+1;
cout<<endl;
} else if((answer=="N")||(answer=="n")) {
if(counter==9) {
cout<<"This is the last question"<<endl;
cout<<endl;
} else {
counter=counter+1;
cout<<"Next question"<<endl;
cout<<endl;
}
} else if((answer=="P")||(answer=="p")) {
if(counter==0) {
cout<<"This is the first question"<<endl;
cout<<endl;
} else {
counter=counter-1;
cout<<"Previous question"<<endl;
cout<<endl;
}
} else if((answer=="F")||(answer=="f")) {
submit=true;
cout<<"Processing"<<endl;
cout<<endl;
}
else {
cout<<"Wrong Option"<<endl;
goto repeat;
}
}
} while(submit==false);
}
int result (string *YourOption, string *Answer) {
int score=0;
for(int i=0; i<10; i++) {
if(*(YourOption+i)==*(Answer+i) ) {
score=score+1;
}
}
return score;
}
void viewscript (string *Question, string *OptionA, string *OptionB, string *OptionC, string *OptionD, string *Answer, string *YourOption) {
viewing:
cout<<"To view your script Press V "<<endl;
string view;
cin>>view;
if((view=="V")||(view=="v")) {
for(int counter=0; counter<10; counter++) {
cout<<"Question "<<counter+1<<endl;
cout<<*(Question+counter)<<endl;
cout<<"A. "<<*(OptionA+counter)<<" B. "<<*(OptionB+counter)<<endl;
cout<<"C. "<<*(OptionC+counter)<<" D. "<<*(OptionD+counter)<<endl;
cout<<"Correct Option :"<<Answer[counter]<<" Your Choice: "<<*(YourOption+counter)<<" ";
if(*(YourOption+counter)==Answer[counter]) {
cout<<" Correct!\n\n"<<endl;
} else {
cout<<" Wrong!\n\n"<<endl;
}
}
} else {
cout<<"You entered the wrong Option "<<endl;
goto viewing;
}
}
int main() {
begin();
loop:
cout<<"Press 1 to Start"<<endl;
cout<<"Press 2 to Exit"<<endl;
cin>>start;
if(start=='1') {
rules();
play(&Question[0], &OptionA[0], &OptionB[0], &OptionC[0], &OptionD[0], &YourOption[0]);
score= result (&YourOption[0], &Answer[0]);
cout<<"You scored " <<score<<" out of 10"<<endl;
viewscript(&Question[0], &OptionA[0], &OptionB[0], &OptionC[0], &OptionD[0], &Answer[0], &YourOption[0]);
} else if(start=='2') {
return 0;
} else {
cout<<"You entered a wrong value\n"<<endl;
goto loop;
}
return 0;
}
| 36.173653 | 837 | 0.610992 | ochudi |
bade9ad191f29e084b0bcd3161f6db83a7c296a2 | 1,213 | hpp | C++ | source/quantum-script-extension-task-version.hpp | g-stefan/quantum-script-extension-task | d7d4f5a2d276fec951ca3bced371306d9307da45 | [
"MIT",
"Unlicense"
] | null | null | null | source/quantum-script-extension-task-version.hpp | g-stefan/quantum-script-extension-task | d7d4f5a2d276fec951ca3bced371306d9307da45 | [
"MIT",
"Unlicense"
] | null | null | null | source/quantum-script-extension-task-version.hpp | g-stefan/quantum-script-extension-task | d7d4f5a2d276fec951ca3bced371306d9307da45 | [
"MIT",
"Unlicense"
] | null | null | null | //
// Quantum Script Extension Task
//
// Copyright (c) 2020-2021 Grigore Stefan <[email protected]>
// Created by Grigore Stefan <[email protected]>
//
// MIT License (MIT) <http://opensource.org/licenses/MIT>
//
#ifndef QUANTUM_SCRIPT_EXTENSION_TASK_VERSION_HPP
#define QUANTUM_SCRIPT_EXTENSION_TASK_VERSION_HPP
#define QUANTUM_SCRIPT_EXTENSION_TASK_VERSION_ABCD 2,1,0,19
#define QUANTUM_SCRIPT_EXTENSION_TASK_VERSION_STR "2.1.0"
#define QUANTUM_SCRIPT_EXTENSION_TASK_VERSION_STR_BUILD "19"
#define QUANTUM_SCRIPT_EXTENSION_TASK_VERSION_STR_DATETIME "2021-08-09 17:38:06"
#ifndef XYO_RC
#ifndef QUANTUM_SCRIPT_EXTENSION_TASK__EXPORT_HPP
#include "quantum-script-extension-task--export.hpp"
#endif
namespace Quantum {
namespace Script {
namespace Extension {
namespace Task {
namespace Version {
QUANTUM_SCRIPT_EXTENSION_TASK_EXPORT const char *version();
QUANTUM_SCRIPT_EXTENSION_TASK_EXPORT const char *build();
QUANTUM_SCRIPT_EXTENSION_TASK_EXPORT const char *versionWithBuild();
QUANTUM_SCRIPT_EXTENSION_TASK_EXPORT const char *datetime();
};
};
};
};
};
#endif
#endif
| 28.880952 | 88 | 0.728772 | g-stefan |
badf75ce5a0b810c40cb0437c640a3888ac551d4 | 6,797 | cpp | C++ | Base/PLCore/src/Xml/XmlAttribute.cpp | ktotheoz/pixellight | 43a661e762034054b47766d7e38d94baf22d2038 | [
"MIT"
] | 83 | 2015-01-08T15:06:14.000Z | 2021-07-20T17:07:00.000Z | Base/PLCore/src/Xml/XmlAttribute.cpp | PixelLightFoundation/pixellight | 43a661e762034054b47766d7e38d94baf22d2038 | [
"MIT"
] | 27 | 2019-06-18T06:46:07.000Z | 2020-02-02T11:11:28.000Z | Base/PLCore/src/Xml/XmlAttribute.cpp | naetherm/PixelLight | d7666f5b49020334cbb5debbee11030f34cced56 | [
"MIT"
] | 40 | 2015-02-25T18:24:34.000Z | 2021-03-06T09:01:48.000Z | /*********************************************************\
* File: XmlAttribute.cpp *
*
* Copyright (C) 2002-2013 The PixelLight Team (http://www.pixellight.org/)
*
* This file is part of PixelLight.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software
* and associated documentation files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or
* substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
* BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
\*********************************************************/
//[-------------------------------------------------------]
//[ Includes ]
//[-------------------------------------------------------]
#include <stdio.h>
#include "PLCore/File/File.h"
#include "PLCore/Xml/XmlParsingData.h"
#include "PLCore/Xml/XmlDocument.h"
#include "PLCore/Xml/XmlAttribute.h"
//[-------------------------------------------------------]
//[ Namespace ]
//[-------------------------------------------------------]
namespace PLCore {
//[-------------------------------------------------------]
//[ Public functions ]
//[-------------------------------------------------------]
/**
* @brief
* Default constructor
*/
XmlAttribute::XmlAttribute() :
m_pDocument(nullptr),
m_pPreviousAttribute(nullptr),
m_pNextAttribute(nullptr)
{
}
/**
* @brief
* Destructor
*/
XmlAttribute::~XmlAttribute()
{
}
/**
* @brief
* Examines the value string
*/
XmlBase::EQueryResult XmlAttribute::QueryIntValue(int &nValue) const
{
int nBackup = nValue;
EQueryResult nResult = (sscanf(m_sValue.GetASCII(), "%d", &nValue) == 1) ? Success : WrongType;
if (nResult != Success)
nValue = nBackup;
return nResult;
}
/**
* @brief
* Examines the value string
*/
XmlBase::EQueryResult XmlAttribute::QueryDoubleValue(double &dValue) const
{
double dBackup = dValue;
EQueryResult nResult = (sscanf(m_sValue.GetASCII(), "%lf", &dValue) == 1) ? Success : WrongType;
if (nResult != Success)
dValue = dBackup;
return nResult;
}
//[-------------------------------------------------------]
//[ Public virtual XmlBase functions ]
//[-------------------------------------------------------]
bool XmlAttribute::Save(File &cFile, uint32 nDepth)
{
String sName, sValue;
EncodeString(m_sName, sName);
EncodeString(m_sValue, sValue);
if (sValue.IsSubstring('\"'))
cFile.Print(sName + "='" + sValue + '\'');
else
cFile.Print(sName + "=\"" + sValue + '\"');
// Done
return true;
}
String XmlAttribute::ToString(uint32 nDepth) const
{
String sName, sValue;
EncodeString(m_sName, sName);
EncodeString(m_sValue, sValue);
if (sValue.IsSubstring('\"'))
return sName + "='" + sValue + '\'';
else
return sName + "=\"" + sValue + '\"';
}
const char *XmlAttribute::Parse(const char *pszData, XmlParsingData *pData, EEncoding nEncoding)
{
pszData = SkipWhiteSpace(pszData, nEncoding);
if (!pszData || !*pszData)
return nullptr; // Error!
if (pData) {
pData->Stamp(pszData, nEncoding);
m_cCursor = pData->Cursor();
}
// Read the name, the '=' and the value
const char *pszError = pszData;
pszData = ReadName(pszData, m_sName, nEncoding);
if (!pszData || !*pszData) {
// Set error code
if (m_pDocument)
m_pDocument->SetError(ErrorReadingAttributes, pszError, pData, nEncoding);
// Error!
return nullptr;
}
pszData = SkipWhiteSpace(pszData, nEncoding);
if (!pszData || !*pszData || *pszData != '=') {
// Set error code
if (m_pDocument)
m_pDocument->SetError(ErrorReadingAttributes, pszData, pData, nEncoding);
// Error!
return nullptr;
}
++pszData; // skip '='
pszData = SkipWhiteSpace(pszData, nEncoding);
if (!pszData || !*pszData) {
// Set error code
if (m_pDocument)
m_pDocument->SetError(ErrorReadingAttributes, pszData, pData, nEncoding);
// Error!
return nullptr;
}
// Constants
const char szSingleQuote = '\'';
const char szDoubleQuote = '\"';
if (*pszData == szSingleQuote) {
++pszData;
const char *pszEnd = "\'"; // Single quote in string
pszData = ReadText(pszData, m_sValue, false, pszEnd, false, nEncoding);
} else if (*pszData == szDoubleQuote) {
++pszData;
const char *pszEnd = "\""; // Double quote in string
pszData = ReadText(pszData, m_sValue, false, pszEnd, false, nEncoding);
} else {
// All attribute values should be in single or double quotes.
// But this is such a common error that the parser will try
// its best, even without them.
m_sValue = "";
while ( pszData && *pszData // Existence
&& !IsWhiteSpace( *pszData ) // Whitespace
&& *pszData != '/' && *pszData != '>' ) { // Tag end
if (*pszData == szSingleQuote || *pszData == szDoubleQuote) {
// We did not have an opening quote but seem to have a closing one. Give up and throw an error.
// Set error code
if (m_pDocument)
m_pDocument->SetError(ErrorReadingAttributes, pszData, pData, nEncoding);
// Error!
return nullptr;
}
m_sValue += *pszData;
++pszData;
}
}
// Done
return pszData;
}
//[-------------------------------------------------------]
//[ Private functions ]
//[-------------------------------------------------------]
/**
* @brief
* Copy constructor
*/
XmlAttribute::XmlAttribute(const XmlAttribute &cSource) :
m_pDocument(nullptr),
m_pPreviousAttribute(nullptr),
m_pNextAttribute(nullptr)
{
// No implementation because the copy constructor is never used
}
/**
* @brief
* Copy operator
*/
XmlAttribute &XmlAttribute::operator =(const XmlAttribute &cSource)
{
// No implementation because the copy operator is never used
return *this;
}
//[-------------------------------------------------------]
//[ Namespace ]
//[-------------------------------------------------------]
} // PLCore
| 28.923404 | 99 | 0.575254 | ktotheoz |
bae03e902140e51b613d5a106808a6c13f035087 | 2,575 | cc | C++ | lite/arm/math/shuffle_channel.cc | banbishan/Paddle-Lite | 02517c12c31609f413a1c47a83e25d3fbff07074 | [
"Apache-2.0"
] | 1 | 2019-08-21T05:54:42.000Z | 2019-08-21T05:54:42.000Z | lite/arm/math/shuffle_channel.cc | banbishan/Paddle-Lite | 02517c12c31609f413a1c47a83e25d3fbff07074 | [
"Apache-2.0"
] | null | null | null | lite/arm/math/shuffle_channel.cc | banbishan/Paddle-Lite | 02517c12c31609f413a1c47a83e25d3fbff07074 | [
"Apache-2.0"
] | 1 | 2019-10-11T09:34:49.000Z | 2019-10-11T09:34:49.000Z | // Copyright (c) 2019 PaddlePaddle Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include "lite/arm/math/shuffle_channel.h"
#include <typeinfo>
#include "lite/arm/math/funcs.h"
namespace paddle {
namespace lite {
namespace arm {
namespace math {
template <typename Dtype>
void shuffle_kernel(
Dtype* output, const Dtype* input, int group_row, int group_col, int len) {
for (int i = 0; i < group_row; ++i) {
for (int j = 0; j < group_col; ++j) {
const Dtype* p_i = input + (i * group_col + j) * len;
Dtype* p_o = output + (j * group_row + i) * len;
memcpy(p_o, p_i, len * sizeof(Dtype));
}
}
}
template <>
void shuffle_channel<float>(const float* inputs,
float* outputs,
int group,
int num,
int channel,
int height,
int width) {
int fea_size = channel * height * width;
int spatial_size = height * width;
int group_row = group;
int group_col = channel / group;
for (int i = 0; i < num; ++i) {
shuffle_kernel(outputs + i * fea_size,
inputs + i * fea_size,
group_row,
group_col,
spatial_size);
}
}
template <>
void shuffle_channel<char>(const char* inputs,
char* outputs,
int group,
int num,
int channel,
int height,
int width) {
int fea_size = channel * height * width;
int spatial_size = height * width;
int group_row = group;
int group_col = channel / group;
for (int i = 0; i < num; ++i) {
shuffle_kernel(outputs + i * fea_size,
inputs + i * fea_size,
group_row,
group_col,
spatial_size);
}
}
} // namespace math
} // namespace arm
} // namespace lite
} // namespace paddle
| 31.402439 | 79 | 0.555728 | banbishan |
bae04be8750d9747a35a419a739f3ca3f5f0bc34 | 148 | cpp | C++ | src/Property.cpp | barsnadcat/space_tycoon_model | 6029746f2e1a8e9585ba6fa5913f2690e9ea2d91 | [
"MIT"
] | null | null | null | src/Property.cpp | barsnadcat/space_tycoon_model | 6029746f2e1a8e9585ba6fa5913f2690e9ea2d91 | [
"MIT"
] | null | null | null | src/Property.cpp | barsnadcat/space_tycoon_model | 6029746f2e1a8e9585ba6fa5913f2690e9ea2d91 | [
"MIT"
] | null | null | null | #include <Property.h>
ObjectSP Property::GetOwner() const
{
return mOwner.lock();
}
void Property::SetOwner(ObjectSP owner)
{
mOwner = owner;
}
| 12.333333 | 39 | 0.709459 | barsnadcat |
bae15dcebe76e6e7d8d7b579ca465deded4cb9d6 | 3,759 | hpp | C++ | src/sensor_configuration.hpp | gsbecerrag/cppagent | f64b1906be32b43656b905e1f5d17c4e7ccbf094 | [
"Apache-2.0"
] | null | null | null | src/sensor_configuration.hpp | gsbecerrag/cppagent | f64b1906be32b43656b905e1f5d17c4e7ccbf094 | [
"Apache-2.0"
] | null | null | null | src/sensor_configuration.hpp | gsbecerrag/cppagent | f64b1906be32b43656b905e1f5d17c4e7ccbf094 | [
"Apache-2.0"
] | null | null | null | //
// Copyright Copyright 2009-2019, AMT – The Association For Manufacturing Technology (“AMT”)
// All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
#pragma once
#include "component_configuration.hpp"
#include "globals.hpp"
#include <utility>
#include <vector>
namespace mtconnect
{
class SensorConfiguration : public ComponentConfiguration
{
public:
struct Calibration
{
Calibration(std::string date, std::string nextDate, std::string initials)
: m_date(std::move(date)),
m_nextDate(std::move(nextDate)),
m_initials(std::move(initials))
{
}
Calibration(const Calibration &other)
: m_date(other.m_date), m_nextDate(other.m_nextDate), m_initials(other.m_initials)
{
}
Calibration()
{
}
~Calibration()
{
}
std::string m_date;
std::string m_nextDate;
std::string m_initials;
};
class Channel
{
public:
Channel(std::string calibrationDate, std::string nextCalibrationDate, std::string initials,
const std::map<std::string, std::string> &attrs)
: m_attributes(attrs),
m_calibration(std::move(calibrationDate), std::move(nextCalibrationDate),
std::move(initials))
{
}
Channel(const Channel &other)
: m_attributes(other.m_attributes),
m_description(other.m_description),
m_calibration(other.m_calibration)
{
}
~Channel()
{
}
void setDescription(const std::string &desc)
{
m_description = desc;
}
const std::string &getDescription() const
{
return m_description;
}
const std::map<std::string, std::string> &getAttributes() const
{
return m_attributes;
}
const Calibration &getCalibration() const
{
return m_calibration;
}
protected:
std::map<std::string, std::string> m_attributes;
std::string m_description;
Calibration m_calibration;
};
// Sensor Configuration begins here
public:
SensorConfiguration(std::string firmwareVer, std::string calibrationDate,
std::string nextCalibrationDate, std::string initials, std::string rest)
: m_firmwareVersion(std::move(firmwareVer)),
m_calibration(std::move(calibrationDate), std::move(nextCalibrationDate),
std::move(initials)),
m_rest(std::move(rest))
{
}
virtual ~SensorConfiguration()
{
}
void addChannel(const Channel &channel)
{
m_channels.emplace_back(channel);
}
const std::vector<Channel> &getChannels() const
{
return m_channels;
}
const Calibration &getCalibration() const
{
return m_calibration;
}
const std::string &getRest() const
{
return m_rest;
}
const std::string &getFirmwareVersion() const
{
return m_firmwareVersion;
}
protected:
std::string m_firmwareVersion;
Calibration m_calibration;
std::string m_rest;
std::vector<Channel> m_channels;
};
} // namespace mtconnect
| 26.659574 | 97 | 0.621708 | gsbecerrag |
bae3a9f93960469136c83bf8de62eaff77843471 | 2,143 | cc | C++ | iree/hal/cts/descriptor_set_test.cc | NatashaKnk/iree | e4bafcf8b11041c3279f4a8620a3096c5aebf33a | [
"Apache-2.0"
] | null | null | null | iree/hal/cts/descriptor_set_test.cc | NatashaKnk/iree | e4bafcf8b11041c3279f4a8620a3096c5aebf33a | [
"Apache-2.0"
] | 4 | 2021-01-05T09:58:18.000Z | 2021-02-11T10:50:12.000Z | iree/hal/cts/descriptor_set_test.cc | marbre/iree | ce1af180c87ed4b4501d4a7b6f2b2617624440c0 | [
"Apache-2.0"
] | null | null | null | // Copyright 2021 The IREE Authors
//
// Licensed under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
#include <cstddef>
#include <string>
#include <vector>
#include "iree/base/api.h"
#include "iree/hal/api.h"
#include "iree/hal/cts/cts_test_base.h"
#include "iree/hal/testing/driver_registry.h"
#include "iree/testing/gtest.h"
#include "iree/testing/status_matchers.h"
namespace iree {
namespace hal {
namespace cts {
class DescriptorSetTest : public CtsTestBase {};
// TODO(scotttodd): enable once any driver implements non-push descriptor sets
// * also test with buffers in the bindings
// * also test usage in iree_hal_command_buffer_bind_descriptor_set
TEST_P(DescriptorSetTest, DISABLED_CreateWithTwoBindings) {
iree_hal_descriptor_set_layout_t* descriptor_set_layout;
iree_hal_descriptor_set_layout_binding_t descriptor_set_layout_bindings[] = {
{/*binding=*/0, /*type=*/IREE_HAL_DESCRIPTOR_TYPE_STORAGE_BUFFER},
{/*binding=*/1, /*type=*/IREE_HAL_DESCRIPTOR_TYPE_STORAGE_BUFFER},
};
IREE_ASSERT_OK(iree_hal_descriptor_set_layout_create(
device_, IREE_HAL_DESCRIPTOR_SET_LAYOUT_USAGE_TYPE_IMMUTABLE,
IREE_ARRAYSIZE(descriptor_set_layout_bindings),
descriptor_set_layout_bindings, &descriptor_set_layout));
iree_hal_descriptor_set_binding_t descriptor_set_bindings[] = {
{/*binding=*/0, /*buffer=*/NULL, /*offset=*/0, /*length=*/0},
{/*binding=*/1, /*buffer=*/NULL, /*offset=*/0, /*length=*/0},
};
iree_hal_descriptor_set_t* descriptor_set;
IREE_ASSERT_OK(iree_hal_descriptor_set_create(
device_, descriptor_set_layout, IREE_ARRAYSIZE(descriptor_set_bindings),
descriptor_set_bindings, &descriptor_set));
iree_hal_descriptor_set_release(descriptor_set);
iree_hal_descriptor_set_layout_release(descriptor_set_layout);
}
INSTANTIATE_TEST_SUITE_P(
AllDrivers, DescriptorSetTest,
::testing::ValuesIn(testing::EnumerateAvailableDrivers()),
GenerateTestName());
} // namespace cts
} // namespace hal
} // namespace iree
| 35.716667 | 79 | 0.766682 | NatashaKnk |
bae520d44586e26d1692d2350f307fd7ebbe6fe8 | 6,208 | hpp | C++ | include/o80/standalone.hpp | intelligent-soft-robots/o80 | 61ab6bab0fc1015337dcb26150cfb23414202bd0 | [
"BSD-3-Clause"
] | 3 | 2020-08-24T09:57:29.000Z | 2021-04-20T15:43:09.000Z | include/o80/standalone.hpp | intelligent-soft-robots/o80 | 61ab6bab0fc1015337dcb26150cfb23414202bd0 | [
"BSD-3-Clause"
] | 9 | 2020-10-15T14:55:08.000Z | 2021-06-29T08:38:17.000Z | include/o80/standalone.hpp | intelligent-soft-robots/o80 | 61ab6bab0fc1015337dcb26150cfb23414202bd0 | [
"BSD-3-Clause"
] | 5 | 2020-07-02T14:05:50.000Z | 2021-10-04T17:19:28.000Z | // Copyright (c) 2019 Max Planck Gesellschaft
// Author : Vincent Berenz
#pragma once
#include "o80/back_end.hpp"
#include "o80/burster.hpp"
#include "o80/driver.hpp"
#include "o80/frequency_manager.hpp"
#include "o80/observation.hpp"
#include "o80/time.hpp"
#include "o80_internal/standalone_runner.hpp"
#include "synchronizer/leader.hpp"
namespace o80
{
/**
* ! if an instance of Standalone of the related segment_id is
* running, will send a stop request to this standalone.
*/
void please_stop(std::string segment_id)
{
shared_memory::set<bool>(segment_id, "should_stop", true);
try
{
synchronizer::Leader leader(segment_id + "_synchronizer");
leader.pulse();
}
catch (...)
{
}
}
/**
* ! A Standalone encapsulates and organize the
* the communication between a (robot_interfaces) driver, a
* (robot_interfaces) frontend, a (robot_interfaces) backend and
* a (o80) backend : at each iteration, information about the current state of
* the robot actuators are passed by the frontend to the backend,
* which passes to the driver desired states values.
* @tparam QUEUE_SIZE number of commands that can be hosted
* in the command queue at any point of time.
* Exceptions will be
* thrown if more commands are queued.
* @tparam NB_ACTUATORS number of actuators of the robot
* @tparam RI_ACTION template to the (robot_interfaces) frontend
* @tparam ROBOT_OUT template to the (robot_interfaces) frontend
* @tparam o80_STATE template to the (o80) BackEnd
* @tparam EXTENDED_STATE class encapsulating supplementary arbitrary
* information (i.e. supplementary to the current actuators state) that will be
* sent from the (robot_interfaces) frontend to the backend (which will add
* these information to the observations)
*/
template <int QUEUE_SIZE,
int NB_ACTUATORS,
class DRIVER,
class o80_STATE,
class o80_EXTENDED_STATE>
class Standalone
{
public:
static constexpr int queue_size = QUEUE_SIZE;
static constexpr int nb_actuators = NB_ACTUATORS;
public:
typedef std::shared_ptr<DRIVER> DriverPtr;
typedef o80_STATE o80State;
typedef o80_EXTENDED_STATE o80ExtendedState;
typedef DRIVER o80DRIVER;
private:
typedef BackEnd<QUEUE_SIZE, NB_ACTUATORS, o80_STATE, o80_EXTENDED_STATE>
o80Backend;
public:
/**
* Creates instances of:
* - (robot_interfaces) backend
* - (robot interfaces) frontend
* - (o80) BackEnd
* @param ri_driver robot_interfaces robot driver
* @param frequency desired frequency
* @param segment_id shared memory segment id for o80 BackEnd.
*/
Standalone(DriverPtr driver_ptr, double frequency, std::string segment_id);
~Standalone();
/**
* ! Starts the robot interfaces backend
*/
void start();
/**
* ! Stops the robot interfaces backend
*/
void stop();
/**
* ! - If bursting is false, performs one iteration and then wait for the
* time requied to match the desired frequency.
* - If bursting is true, hang until the o80
* FrontEnd calls "burst".
*
*/
bool spin(bool bursting = false);
/**
* ! Similar to spin, and the extended state is added to the observation
* that is written to the shared memory by the o80 BackEnd.
*
*/
bool spin(o80_EXTENDED_STATE& extended_state, bool bursting = false);
/**
* ! user code to convert the observation read from robot_interfaces
* frontend into the current o80 States.
*/
virtual o80::States<NB_ACTUATORS, o80_STATE> convert(
const typename DRIVER::DRIVER_OUT& observation) = 0;
/**
* ! user code to convert the desired states generated by the o80 BackEnd
* into action required by the robot_interfaces frontend.
*/
virtual typename DRIVER::DRIVER_IN convert(
const o80::States<NB_ACTUATORS, o80_STATE>& states) = 0;
/**
* ! converts the observation as returned by the robot_interfaces
* frontend into the o80 extended state (optional)
*/
virtual void enrich_extended_state(
o80_EXTENDED_STATE& extended_state,
const typename DRIVER::DRIVER_OUT& observation){};
private:
bool iterate(const TimePoint& time_now, o80_EXTENDED_STATE& extended_state);
private:
double frequency_;
Microseconds period_;
FrequencyManager frequency_manager_;
TimePoint now_;
std::shared_ptr<Burster> burster_;
std::string segment_id_;
DriverPtr driver_ptr_;
o80Backend o8o_backend_;
};
template <class RobotDriver, class o80Standalone, typename... Args>
void start_action_timed_standalone(std::string segment_id,
double frequency,
bool bursting,
Args&&... args);
/**
* @brief instantiates instances of (robot_interfaces) RobotDriver
* and of (o80) Standalone,
* and starts them in a thread. A runtime exception is thrown
* if another standalone of the same segment_id has already
* been started.
* tparam Args template arguments of the driver
* param segment id o80 BackEnd segment id
* param frequency frequency at which the standalone will iterate
* (non bursting mode)
* param bursting if true, will run in bursting mode, i.e.
* the standalone will iterate only when the o80
* frontend calls its burst function.
* param args arguments for the driver
*/
template <class RobotDriver, class o80Standalone, typename... Args>
void start_standalone(std::string segment_id,
double frequency,
bool bursting,
Args&&... args);
/**
* ! Stop the standalone of the specified segment_id.
* A runtime error is thrown if no such standalone is running.
*/
void stop_standalone(std::string segment_id);
/**
* ! Returns true if the standalone is iterating.
* (returns also false if the standalone does not exist)
*/
bool standalone_is_running(std::string segment_id);
#include "standalone.hxx"
} // namespace o80
| 32.333333 | 80 | 0.676385 | intelligent-soft-robots |
bae7a775e596886e63c58c30d94314ac79438201 | 72,498 | cpp | C++ | Tools/STM32FW/STM32Cube_FW_F7_V1.16.2/Projects/STM32F769I_EVAL/Demonstrations/TouchGFX/Gui/generated/images/src/Audio/pause_notPressed.cpp | ramkumarkoppu/NUCLEO-F767ZI-ESW | 85e129d71ee8eccbd0b94b5e07e75b6b91679ee8 | [
"MIT"
] | null | null | null | Tools/STM32FW/STM32Cube_FW_F7_V1.16.2/Projects/STM32F769I_EVAL/Demonstrations/TouchGFX/Gui/generated/images/src/Audio/pause_notPressed.cpp | ramkumarkoppu/NUCLEO-F767ZI-ESW | 85e129d71ee8eccbd0b94b5e07e75b6b91679ee8 | [
"MIT"
] | null | null | null | Tools/STM32FW/STM32Cube_FW_F7_V1.16.2/Projects/STM32F769I_EVAL/Demonstrations/TouchGFX/Gui/generated/images/src/Audio/pause_notPressed.cpp | ramkumarkoppu/NUCLEO-F767ZI-ESW | 85e129d71ee8eccbd0b94b5e07e75b6b91679ee8 | [
"MIT"
] | null | null | null | // Generated by imageconverter. Please, do not edit!
#include <touchgfx/hal/Config.hpp>
LOCATION_EXTFLASH_PRAGMA
KEEP extern const unsigned char _pause_notPressed[] LOCATION_EXTFLASH_ATTRIBUTE = { // 60x60 ARGB8888 pixels.
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf7,0xf5,0xf4,0xff,0xf7,0xf5,0xf3,0xff,0xf7,0xf4,0xf3,0xff,0xf7,0xf5,0xf4,0xff,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf7,0xf5,0xf4,0xff,0xf7,0xf5,0xf4,0xff,0xf7,0xf5,0xf3,0xff,0xf7,0xf4,0xf3,0xff,0xf7,0xf5,0xf3,0xff,0xf7,0xf5,0xf3,0xff,0xf7,0xf5,0xf4,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf7,0xf5,0xf4,0xff,0xf2,0xee,0xed,0xff,0xed,0xe7,0xe7,0xff,0xe9,0xe2,0xe1,0xff,0xe7,0xe0,0xdf,0xff,0xe6,0xdf,0xde,0xff,0xe6,0xdf,0xde,0xff,0xe6,0xdf,0xde,0xff,0xe7,0xe1,0xdf,0xff,0xe9,0xe3,0xe1,0xff,0xf0,0xeb,0xea,0xff,0xf7,0xf4,0xf4,0xff,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf5,0xf2,0xf1,0xff,0xed,0xe9,0xe7,0xff,0xe7,0xe1,0xdf,0xff,0xe6,0xe0,0xde,0xff,
0xe6,0xdf,0xde,0xff,0xe6,0xdf,0xde,0xff,0xe6,0xdf,0xde,0xff,0xe7,0xe0,0xde,0xff,0xe8,0xe2,0xdf,0xff,0xed,0xe8,0xe7,0xff,0xf3,0xef,0xee,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0xeb,0xe6,0xe4,0xff,0xde,0xd5,0xd2,0xff,0xd2,0xc5,0xc2,0xff,0xc8,0xb8,0xb4,0xff,0xc3,0xb2,0xae,0xff,0xc1,0xb0,0xab,0xff,0xc0,0xaf,0xab,0xff,0xc1,0xb0,0xac,0xff,0xc4,0xb3,0xaf,0xff,0xc8,0xb9,0xb5,0xff,0xd8,0xce,0xcc,0xff,0xeb,0xe6,0xe4,0xff,0xf6,0xf3,0xf3,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf2,0xee,0xec,0xff,0xe6,0xdf,0xdd,0xff,0xd4,0xc8,0xc4,0xff,0xc3,0xb4,0xaf,0xff,0xc2,0xb1,0xac,0xff,0xc0,0xaf,0xab,0xff,0xc0,0xaf,0xab,0xff,0xc0,0xaf,0xab,0xff,0xc2,0xb1,0xac,0xff,
0xc6,0xb6,0xb1,0xff,0xd2,0xc6,0xc3,0xff,0xe0,0xd7,0xd5,0xff,0xec,0xe7,0xe6,0xff,0xf7,0xf5,0xf4,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf5,0xf2,0xf2,0xff,0xde,0xd5,0xd3,0xff,0xc9,0xb9,0xb5,0xff,0xb4,0x9f,0x99,0xff,0xa3,0x8a,0x82,0xff,
0x9b,0x80,0x78,0xff,0x97,0x7b,0x73,0xff,0x96,0x7a,0x72,0xff,0x98,0x7c,0x74,0xff,0x9c,0x81,0x7a,0xff,0xa3,0x8b,0x84,0xff,0xbf,0xae,0xa9,0xff,0xde,0xd5,0xd2,0xff,0xf0,0xec,0xeb,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf5,0xf1,0xf0,0xff,0xe9,0xe2,0xe0,0xff,0xd5,0xc9,0xc6,0xff,0xb7,0xa3,0x9d,0xff,0x9c,0x82,0x79,0xff,0x99,0x7d,0x75,0xff,0x97,0x7a,0x73,0xff,0x96,0x79,0x72,0xff,0x96,0x7a,0x72,0xff,0x98,0x7d,0x74,0xff,0x9f,0x86,0x7d,0xff,0xb4,0xa0,0x9a,0xff,0xca,0xbc,0xb8,0xff,0xe0,0xd7,0xd5,0xff,
0xf2,0xee,0xed,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf2,0xef,0xee,0xff,0xd4,0xc9,0xc5,0xff,0xb7,0xa4,0x9e,0xff,0x9c,0x81,0x79,0xff,0x85,0x64,0x5a,0xff,0x7b,0x57,0x4d,0xff,0x76,0x51,0x47,0xff,0x75,0x4f,0x45,0xff,0x77,0x52,0x48,0xff,
0x7c,0x59,0x4f,0xff,0x86,0x66,0x5c,0xff,0xab,0x94,0x8e,0xff,0xd3,0xc8,0xc4,0xff,0xec,0xe6,0xe5,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf1,0xed,0xec,0xff,0xe1,0xd9,0xd7,0xff,
0xc7,0xb8,0xb4,0xff,0x9f,0x85,0x7e,0xff,0x7d,0x5a,0x4f,0xff,0x78,0x54,0x49,0xff,0x76,0x51,0x46,0xff,0x75,0x4f,0x45,0xff,0x75,0x50,0x45,0xff,0x77,0x53,0x48,0xff,0x80,0x5f,0x54,0xff,0x9c,0x82,0x7a,0xff,0xba,0xa7,0xa1,0xff,0xd6,0xca,0xc7,0xff,0xee,0xe9,0xe8,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0xed,0xec,0xff,0xce,0xc1,0xbd,0xff,0xad,0x97,0x90,0xff,0x8e,0x70,0x66,0xff,0x74,0x4f,0x44,0xff,0x69,0x40,0x34,0xff,0x63,0x39,0x2d,0xff,0x62,0x38,0x2b,0xff,0x65,0x3b,0x2f,0xff,0x6b,0x43,0x37,0xff,0x75,0x51,0x46,0xff,0x9f,0x86,0x7e,0xff,0xcd,0xc0,0xbc,0xff,
0xe9,0xe3,0xe1,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xee,0xea,0xea,0xff,0xdd,0xd4,0xd1,0xff,0xbf,0xaf,0xaa,0xff,0x92,0x75,0x6c,0xff,0x6b,0x43,0x37,0xff,0x66,0x3d,0x30,0xff,
0x63,0x39,0x2c,0xff,0x62,0x37,0x2b,0xff,0x62,0x38,0x2c,0xff,0x65,0x3c,0x2f,0xff,0x6f,0x49,0x3d,0xff,0x8f,0x71,0x68,0xff,0xb0,0x9b,0x94,0xff,0xd0,0xc3,0xbf,0xff,0xeb,0xe6,0xe4,0xff,0xf7,0xf5,0xf4,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xef,0xeb,0xea,0xff,
0xcb,0xbe,0xb9,0xff,0xa8,0x90,0x88,0xff,0x86,0x66,0x5c,0xff,0x6b,0x44,0x37,0xff,0x5e,0x34,0x26,0xff,0x59,0x2c,0x1e,0xff,0x57,0x2b,0x1d,0xff,0x5a,0x2e,0x20,0xff,0x61,0x37,0x29,0xff,0x6c,0x46,0x3a,0xff,0x98,0x7e,0x76,0xff,0xc9,0xbc,0xb8,0xff,0xe7,0xe2,0xdf,0xff,0xf6,0xf5,0xf4,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xed,0xe9,0xe8,0xff,0xda,0xd1,0xce,0xff,0xbb,0xaa,0xa4,0xff,0x8a,0x6c,0x62,0xff,0x61,0x37,0x2a,0xff,0x5b,0x30,0x22,0xff,0x58,0x2c,0x1e,0xff,0x57,0x2a,0x1c,0xff,0x58,0x2b,0x1e,0xff,0x5a,0x2e,0x22,0xff,
0x66,0x3d,0x30,0xff,0x87,0x68,0x5e,0xff,0xab,0x94,0x8d,0xff,0xcd,0xbf,0xbb,0xff,0xea,0xe4,0xe2,0xff,0xf6,0xf4,0xf4,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xef,0xeb,0xea,0xff,0xcb,0xbe,0xb9,0xff,0xa8,0x90,0x88,0xff,0x86,0x66,0x5c,0xff,0x6b,0x44,0x37,0xff,
0x5e,0x34,0x26,0xff,0x59,0x2c,0x1e,0xff,0x57,0x2b,0x1d,0xff,0x5a,0x2e,0x20,0xff,0x61,0x37,0x29,0xff,0x6c,0x46,0x3a,0xff,0x98,0x7e,0x76,0xff,0xc9,0xbc,0xb8,0xff,0xe7,0xe2,0xdf,0xff,0xf6,0xf5,0xf4,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xed,0xe9,0xe8,0xff,0xda,0xd1,0xce,0xff,0xbb,0xaa,0xa4,0xff,0x8a,0x6c,0x62,0xff,0x61,0x37,0x2a,0xff,0x5b,0x30,0x22,0xff,0x58,0x2c,0x1e,0xff,0x57,0x2a,0x1c,0xff,0x58,0x2b,0x1e,0xff,0x5a,0x2e,0x22,0xff,0x66,0x3d,0x30,0xff,0x87,0x68,0x5e,0xff,0xab,0x94,0x8d,0xff,0xcd,0xbf,0xbb,0xff,
0xea,0xe4,0xe2,0xff,0xf6,0xf4,0xf4,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xef,0xeb,0xea,0xff,0xcb,0xbe,0xb9,0xff,0xa8,0x90,0x88,0xff,0x86,0x66,0x5c,0xff,0x6b,0x44,0x37,0xff,0x5e,0x34,0x26,0xff,0x59,0x2c,0x1e,0xff,0x57,0x2b,0x1d,0xff,0x5a,0x2e,0x20,0xff,
0x61,0x37,0x29,0xff,0x6c,0x46,0x3a,0xff,0x98,0x7e,0x76,0xff,0xc9,0xbc,0xb8,0xff,0xe7,0xe2,0xdf,0xff,0xf6,0xf5,0xf4,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xed,0xe9,0xe8,0xff,0xda,0xd1,0xce,0xff,
0xbb,0xaa,0xa4,0xff,0x8a,0x6c,0x62,0xff,0x61,0x37,0x2a,0xff,0x5b,0x30,0x22,0xff,0x58,0x2c,0x1e,0xff,0x57,0x2a,0x1c,0xff,0x58,0x2b,0x1e,0xff,0x5a,0x2e,0x22,0xff,0x66,0x3d,0x30,0xff,0x87,0x68,0x5e,0xff,0xab,0x94,0x8d,0xff,0xcd,0xbf,0xbb,0xff,0xea,0xe4,0xe2,0xff,0xf6,0xf4,0xf4,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xef,0xeb,0xea,0xff,0xcb,0xbe,0xb9,0xff,0xa8,0x90,0x88,0xff,0x86,0x66,0x5c,0xff,0x6b,0x44,0x37,0xff,0x5e,0x34,0x26,0xff,0x59,0x2c,0x1e,0xff,0x57,0x2b,0x1d,0xff,0x5a,0x2e,0x20,0xff,0x61,0x37,0x29,0xff,0x6c,0x46,0x3a,0xff,0x98,0x7e,0x76,0xff,0xc9,0xbc,0xb8,0xff,
0xe7,0xe2,0xdf,0xff,0xf6,0xf5,0xf4,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xed,0xe9,0xe8,0xff,0xda,0xd1,0xce,0xff,0xbb,0xaa,0xa4,0xff,0x8a,0x6c,0x62,0xff,0x61,0x37,0x2a,0xff,0x5b,0x30,0x22,0xff,
0x58,0x2c,0x1e,0xff,0x57,0x2a,0x1c,0xff,0x58,0x2b,0x1e,0xff,0x5a,0x2e,0x22,0xff,0x66,0x3d,0x30,0xff,0x87,0x68,0x5e,0xff,0xab,0x94,0x8d,0xff,0xcd,0xbf,0xbb,0xff,0xea,0xe4,0xe2,0xff,0xf6,0xf4,0xf4,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xef,0xeb,0xea,0xff,
0xcb,0xbe,0xb9,0xff,0xa8,0x90,0x88,0xff,0x86,0x66,0x5c,0xff,0x6b,0x44,0x37,0xff,0x5e,0x34,0x26,0xff,0x59,0x2c,0x1e,0xff,0x57,0x2b,0x1d,0xff,0x5a,0x2e,0x20,0xff,0x61,0x37,0x29,0xff,0x6c,0x46,0x3a,0xff,0x98,0x7e,0x76,0xff,0xc9,0xbc,0xb8,0xff,0xe7,0xe2,0xdf,0xff,0xf6,0xf5,0xf4,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xed,0xe9,0xe8,0xff,0xda,0xd1,0xce,0xff,0xbb,0xaa,0xa4,0xff,0x8a,0x6c,0x62,0xff,0x61,0x37,0x2a,0xff,0x5b,0x30,0x22,0xff,0x58,0x2c,0x1e,0xff,0x57,0x2a,0x1c,0xff,0x58,0x2b,0x1e,0xff,0x5a,0x2e,0x22,0xff,
0x66,0x3d,0x30,0xff,0x87,0x68,0x5e,0xff,0xab,0x94,0x8d,0xff,0xcd,0xbf,0xbb,0xff,0xea,0xe4,0xe2,0xff,0xf6,0xf4,0xf4,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xef,0xeb,0xea,0xff,0xcb,0xbe,0xb9,0xff,0xa8,0x90,0x88,0xff,0x86,0x66,0x5c,0xff,0x6b,0x44,0x37,0xff,
0x5e,0x34,0x26,0xff,0x59,0x2c,0x1e,0xff,0x57,0x2b,0x1d,0xff,0x5a,0x2e,0x20,0xff,0x61,0x37,0x29,0xff,0x6c,0x46,0x3a,0xff,0x98,0x7e,0x76,0xff,0xc9,0xbc,0xb8,0xff,0xe7,0xe2,0xdf,0xff,0xf6,0xf5,0xf4,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xed,0xe9,0xe8,0xff,0xda,0xd1,0xce,0xff,0xbb,0xaa,0xa4,0xff,0x8a,0x6c,0x62,0xff,0x61,0x37,0x2a,0xff,0x5b,0x30,0x22,0xff,0x58,0x2c,0x1e,0xff,0x57,0x2a,0x1c,0xff,0x58,0x2b,0x1e,0xff,0x5a,0x2e,0x22,0xff,0x66,0x3d,0x30,0xff,0x87,0x68,0x5e,0xff,0xab,0x94,0x8d,0xff,0xcd,0xbf,0xbb,0xff,
0xea,0xe4,0xe2,0xff,0xf6,0xf4,0xf4,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xef,0xeb,0xea,0xff,0xcb,0xbe,0xb9,0xff,0xa8,0x90,0x88,0xff,0x86,0x66,0x5c,0xff,0x6b,0x44,0x37,0xff,0x5e,0x34,0x26,0xff,0x59,0x2c,0x1e,0xff,0x57,0x2b,0x1d,0xff,0x5a,0x2e,0x20,0xff,
0x61,0x37,0x29,0xff,0x6c,0x46,0x3a,0xff,0x98,0x7e,0x76,0xff,0xc9,0xbc,0xb8,0xff,0xe7,0xe2,0xdf,0xff,0xf6,0xf5,0xf4,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xed,0xe9,0xe8,0xff,0xda,0xd1,0xce,0xff,
0xbb,0xaa,0xa4,0xff,0x8a,0x6c,0x62,0xff,0x61,0x37,0x2a,0xff,0x5b,0x30,0x22,0xff,0x58,0x2c,0x1e,0xff,0x57,0x2a,0x1c,0xff,0x58,0x2b,0x1e,0xff,0x5a,0x2e,0x22,0xff,0x66,0x3d,0x30,0xff,0x87,0x68,0x5e,0xff,0xab,0x94,0x8d,0xff,0xcd,0xbf,0xbb,0xff,0xea,0xe4,0xe2,0xff,0xf6,0xf4,0xf4,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xef,0xeb,0xea,0xff,0xcb,0xbe,0xb9,0xff,0xa8,0x90,0x88,0xff,0x86,0x66,0x5c,0xff,0x6b,0x44,0x37,0xff,0x5e,0x34,0x26,0xff,0x59,0x2c,0x1e,0xff,0x57,0x2b,0x1d,0xff,0x5a,0x2e,0x20,0xff,0x61,0x37,0x29,0xff,0x6c,0x46,0x3a,0xff,0x98,0x7e,0x76,0xff,0xc9,0xbc,0xb8,0xff,
0xe7,0xe2,0xdf,0xff,0xf6,0xf5,0xf4,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xed,0xe9,0xe8,0xff,0xda,0xd1,0xce,0xff,0xbb,0xaa,0xa4,0xff,0x8a,0x6c,0x62,0xff,0x61,0x37,0x2a,0xff,0x5b,0x30,0x22,0xff,
0x58,0x2c,0x1e,0xff,0x57,0x2a,0x1c,0xff,0x58,0x2b,0x1e,0xff,0x5a,0x2e,0x22,0xff,0x66,0x3d,0x30,0xff,0x87,0x68,0x5e,0xff,0xab,0x94,0x8d,0xff,0xcd,0xbf,0xbb,0xff,0xea,0xe4,0xe2,0xff,0xf6,0xf4,0xf4,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xef,0xeb,0xea,0xff,
0xcb,0xbe,0xb9,0xff,0xa8,0x90,0x88,0xff,0x86,0x66,0x5c,0xff,0x6b,0x44,0x37,0xff,0x5e,0x34,0x26,0xff,0x59,0x2c,0x1e,0xff,0x57,0x2b,0x1d,0xff,0x5a,0x2e,0x20,0xff,0x61,0x37,0x29,0xff,0x6c,0x46,0x3a,0xff,0x98,0x7e,0x76,0xff,0xc9,0xbc,0xb8,0xff,0xe7,0xe2,0xdf,0xff,0xf6,0xf5,0xf4,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xed,0xe9,0xe8,0xff,0xda,0xd1,0xce,0xff,0xbb,0xaa,0xa4,0xff,0x8a,0x6c,0x62,0xff,0x61,0x37,0x2a,0xff,0x5b,0x30,0x22,0xff,0x58,0x2c,0x1e,0xff,0x57,0x2a,0x1c,0xff,0x58,0x2b,0x1e,0xff,0x5a,0x2e,0x22,0xff,
0x66,0x3d,0x30,0xff,0x87,0x68,0x5e,0xff,0xab,0x94,0x8d,0xff,0xcd,0xbf,0xbb,0xff,0xea,0xe4,0xe2,0xff,0xf6,0xf4,0xf4,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xef,0xeb,0xea,0xff,0xcb,0xbe,0xb9,0xff,0xa8,0x90,0x88,0xff,0x86,0x66,0x5c,0xff,0x6b,0x44,0x37,0xff,
0x5e,0x34,0x26,0xff,0x59,0x2c,0x1e,0xff,0x57,0x2b,0x1d,0xff,0x5a,0x2e,0x20,0xff,0x61,0x37,0x29,0xff,0x6c,0x46,0x3a,0xff,0x98,0x7e,0x76,0xff,0xc9,0xbc,0xb8,0xff,0xe7,0xe2,0xdf,0xff,0xf6,0xf5,0xf4,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xed,0xe9,0xe8,0xff,0xda,0xd1,0xce,0xff,0xbb,0xaa,0xa4,0xff,0x8a,0x6c,0x62,0xff,0x61,0x37,0x2a,0xff,0x5b,0x30,0x22,0xff,0x58,0x2c,0x1e,0xff,0x57,0x2a,0x1c,0xff,0x58,0x2b,0x1e,0xff,0x5a,0x2e,0x22,0xff,0x66,0x3d,0x30,0xff,0x87,0x68,0x5e,0xff,0xab,0x94,0x8d,0xff,0xcd,0xbf,0xbb,0xff,
0xea,0xe4,0xe2,0xff,0xf6,0xf4,0xf4,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xef,0xeb,0xea,0xff,0xcb,0xbe,0xb9,0xff,0xa8,0x90,0x88,0xff,0x86,0x66,0x5c,0xff,0x6b,0x44,0x37,0xff,0x5e,0x34,0x26,0xff,0x59,0x2c,0x1e,0xff,0x57,0x2b,0x1d,0xff,0x5a,0x2e,0x20,0xff,
0x61,0x37,0x29,0xff,0x6c,0x46,0x3a,0xff,0x98,0x7e,0x76,0xff,0xc9,0xbc,0xb8,0xff,0xe7,0xe2,0xdf,0xff,0xf6,0xf5,0xf4,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xed,0xe9,0xe8,0xff,0xda,0xd1,0xce,0xff,
0xbb,0xaa,0xa4,0xff,0x8a,0x6c,0x62,0xff,0x61,0x37,0x2a,0xff,0x5b,0x30,0x22,0xff,0x58,0x2c,0x1e,0xff,0x57,0x2a,0x1c,0xff,0x58,0x2b,0x1e,0xff,0x5a,0x2e,0x22,0xff,0x66,0x3d,0x30,0xff,0x87,0x68,0x5e,0xff,0xab,0x94,0x8d,0xff,0xcd,0xbf,0xbb,0xff,0xea,0xe4,0xe2,0xff,0xf6,0xf4,0xf4,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xef,0xeb,0xea,0xff,0xcb,0xbe,0xb9,0xff,0xa8,0x90,0x88,0xff,0x86,0x66,0x5c,0xff,0x6b,0x44,0x37,0xff,0x5e,0x34,0x26,0xff,0x59,0x2c,0x1e,0xff,0x57,0x2b,0x1d,0xff,0x5a,0x2e,0x20,0xff,0x61,0x37,0x29,0xff,0x6c,0x46,0x3a,0xff,0x98,0x7e,0x76,0xff,0xc9,0xbc,0xb8,0xff,
0xe7,0xe2,0xdf,0xff,0xf6,0xf5,0xf4,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xed,0xe9,0xe8,0xff,0xda,0xd1,0xce,0xff,0xbb,0xaa,0xa4,0xff,0x8a,0x6c,0x62,0xff,0x61,0x37,0x2a,0xff,0x5b,0x30,0x22,0xff,
0x58,0x2c,0x1e,0xff,0x57,0x2a,0x1c,0xff,0x58,0x2b,0x1e,0xff,0x5a,0x2e,0x22,0xff,0x66,0x3d,0x30,0xff,0x87,0x68,0x5e,0xff,0xab,0x94,0x8d,0xff,0xcd,0xbf,0xbb,0xff,0xea,0xe4,0xe2,0xff,0xf6,0xf4,0xf4,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xef,0xeb,0xea,0xff,
0xcb,0xbe,0xb9,0xff,0xa8,0x90,0x88,0xff,0x86,0x66,0x5c,0xff,0x6b,0x44,0x37,0xff,0x5e,0x34,0x26,0xff,0x59,0x2c,0x1e,0xff,0x57,0x2b,0x1d,0xff,0x5a,0x2e,0x20,0xff,0x61,0x37,0x29,0xff,0x6c,0x46,0x3a,0xff,0x98,0x7e,0x76,0xff,0xc9,0xbc,0xb8,0xff,0xe7,0xe2,0xdf,0xff,0xf6,0xf5,0xf4,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xed,0xe9,0xe8,0xff,0xda,0xd1,0xce,0xff,0xbb,0xaa,0xa4,0xff,0x8a,0x6c,0x62,0xff,0x61,0x37,0x2a,0xff,0x5b,0x30,0x22,0xff,0x58,0x2c,0x1e,0xff,0x57,0x2a,0x1c,0xff,0x58,0x2b,0x1e,0xff,0x5a,0x2e,0x22,0xff,
0x66,0x3d,0x30,0xff,0x87,0x68,0x5e,0xff,0xab,0x94,0x8d,0xff,0xcd,0xbf,0xbb,0xff,0xea,0xe4,0xe2,0xff,0xf6,0xf4,0xf4,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xef,0xeb,0xea,0xff,0xcb,0xbe,0xb9,0xff,0xa8,0x90,0x88,0xff,0x86,0x66,0x5c,0xff,0x6b,0x44,0x37,0xff,
0x5e,0x34,0x26,0xff,0x59,0x2c,0x1e,0xff,0x57,0x2b,0x1d,0xff,0x5a,0x2e,0x20,0xff,0x61,0x37,0x29,0xff,0x6c,0x46,0x3a,0xff,0x98,0x7e,0x76,0xff,0xc9,0xbc,0xb8,0xff,0xe7,0xe2,0xdf,0xff,0xf6,0xf5,0xf4,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xed,0xe9,0xe8,0xff,0xda,0xd1,0xce,0xff,0xbb,0xaa,0xa4,0xff,0x8a,0x6c,0x62,0xff,0x61,0x37,0x2a,0xff,0x5b,0x30,0x22,0xff,0x58,0x2c,0x1e,0xff,0x57,0x2a,0x1c,0xff,0x58,0x2b,0x1e,0xff,0x5a,0x2e,0x22,0xff,0x66,0x3d,0x30,0xff,0x87,0x68,0x5e,0xff,0xab,0x94,0x8d,0xff,0xcd,0xbf,0xbb,0xff,
0xea,0xe4,0xe2,0xff,0xf6,0xf4,0xf4,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xef,0xeb,0xea,0xff,0xcb,0xbe,0xb9,0xff,0xa8,0x90,0x88,0xff,0x86,0x66,0x5c,0xff,0x6b,0x44,0x37,0xff,0x5e,0x34,0x26,0xff,0x59,0x2c,0x1e,0xff,0x57,0x2b,0x1d,0xff,0x5a,0x2e,0x20,0xff,
0x61,0x37,0x29,0xff,0x6c,0x46,0x3a,0xff,0x98,0x7e,0x76,0xff,0xc9,0xbc,0xb8,0xff,0xe7,0xe2,0xdf,0xff,0xf6,0xf5,0xf4,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xed,0xe9,0xe8,0xff,0xda,0xd1,0xce,0xff,
0xbb,0xaa,0xa4,0xff,0x8a,0x6c,0x62,0xff,0x61,0x37,0x2a,0xff,0x5b,0x30,0x22,0xff,0x58,0x2c,0x1e,0xff,0x57,0x2a,0x1c,0xff,0x58,0x2b,0x1e,0xff,0x5a,0x2e,0x22,0xff,0x66,0x3d,0x30,0xff,0x87,0x68,0x5e,0xff,0xab,0x94,0x8d,0xff,0xcd,0xbf,0xbb,0xff,0xea,0xe4,0xe2,0xff,0xf6,0xf4,0xf4,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xef,0xeb,0xea,0xff,0xcb,0xbe,0xb9,0xff,0xa8,0x90,0x88,0xff,0x86,0x66,0x5c,0xff,0x6b,0x44,0x37,0xff,0x5e,0x34,0x26,0xff,0x59,0x2c,0x1e,0xff,0x57,0x2b,0x1d,0xff,0x5a,0x2e,0x20,0xff,0x61,0x37,0x29,0xff,0x6c,0x46,0x3a,0xff,0x98,0x7e,0x76,0xff,0xc9,0xbc,0xb8,0xff,
0xe7,0xe2,0xdf,0xff,0xf6,0xf5,0xf4,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xed,0xe9,0xe8,0xff,0xda,0xd1,0xce,0xff,0xbb,0xaa,0xa4,0xff,0x8a,0x6c,0x62,0xff,0x61,0x37,0x2a,0xff,0x5b,0x30,0x22,0xff,
0x58,0x2c,0x1e,0xff,0x57,0x2a,0x1c,0xff,0x58,0x2b,0x1e,0xff,0x5a,0x2e,0x22,0xff,0x66,0x3d,0x30,0xff,0x87,0x68,0x5e,0xff,0xab,0x94,0x8d,0xff,0xcd,0xbf,0xbb,0xff,0xea,0xe4,0xe2,0xff,0xf6,0xf4,0xf4,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xef,0xeb,0xea,0xff,
0xcb,0xbe,0xb9,0xff,0xa8,0x90,0x88,0xff,0x86,0x66,0x5c,0xff,0x6b,0x44,0x37,0xff,0x5e,0x34,0x26,0xff,0x59,0x2c,0x1e,0xff,0x57,0x2b,0x1d,0xff,0x5a,0x2e,0x20,0xff,0x61,0x37,0x29,0xff,0x6c,0x46,0x3a,0xff,0x98,0x7e,0x76,0xff,0xc9,0xbc,0xb8,0xff,0xe7,0xe2,0xdf,0xff,0xf6,0xf5,0xf4,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xed,0xe9,0xe8,0xff,0xda,0xd1,0xce,0xff,0xbb,0xaa,0xa4,0xff,0x8a,0x6c,0x62,0xff,0x61,0x37,0x2a,0xff,0x5b,0x30,0x22,0xff,0x58,0x2c,0x1e,0xff,0x57,0x2a,0x1c,0xff,0x58,0x2b,0x1e,0xff,0x5a,0x2e,0x22,0xff,
0x66,0x3d,0x30,0xff,0x87,0x68,0x5e,0xff,0xab,0x94,0x8d,0xff,0xcd,0xbf,0xbb,0xff,0xea,0xe4,0xe2,0xff,0xf6,0xf4,0xf4,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xef,0xeb,0xea,0xff,0xcb,0xbe,0xb9,0xff,0xa8,0x90,0x88,0xff,0x86,0x66,0x5c,0xff,0x6b,0x44,0x37,0xff,
0x5e,0x34,0x26,0xff,0x59,0x2c,0x1e,0xff,0x57,0x2b,0x1d,0xff,0x5a,0x2e,0x20,0xff,0x61,0x37,0x29,0xff,0x6c,0x46,0x3a,0xff,0x98,0x7e,0x76,0xff,0xc9,0xbc,0xb8,0xff,0xe7,0xe2,0xdf,0xff,0xf6,0xf5,0xf4,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xed,0xe9,0xe8,0xff,0xda,0xd1,0xce,0xff,0xbb,0xaa,0xa4,0xff,0x8a,0x6c,0x62,0xff,0x61,0x37,0x2a,0xff,0x5b,0x30,0x22,0xff,0x58,0x2c,0x1e,0xff,0x57,0x2a,0x1c,0xff,0x58,0x2b,0x1e,0xff,0x5a,0x2e,0x22,0xff,0x66,0x3d,0x30,0xff,0x87,0x68,0x5e,0xff,0xab,0x94,0x8d,0xff,0xcd,0xbf,0xbb,0xff,
0xea,0xe4,0xe2,0xff,0xf6,0xf4,0xf4,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xef,0xeb,0xea,0xff,0xcb,0xbe,0xb9,0xff,0xa8,0x90,0x88,0xff,0x86,0x66,0x5c,0xff,0x6b,0x44,0x37,0xff,0x5e,0x34,0x26,0xff,0x59,0x2c,0x1e,0xff,0x57,0x2b,0x1d,0xff,0x5a,0x2e,0x20,0xff,
0x61,0x37,0x29,0xff,0x6c,0x46,0x3a,0xff,0x98,0x7e,0x76,0xff,0xc9,0xbc,0xb8,0xff,0xe7,0xe2,0xdf,0xff,0xf6,0xf5,0xf4,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xed,0xe9,0xe8,0xff,0xda,0xd1,0xce,0xff,
0xbb,0xaa,0xa4,0xff,0x8a,0x6c,0x62,0xff,0x61,0x37,0x2a,0xff,0x5b,0x30,0x22,0xff,0x58,0x2c,0x1e,0xff,0x57,0x2a,0x1c,0xff,0x58,0x2b,0x1e,0xff,0x5a,0x2e,0x22,0xff,0x66,0x3d,0x30,0xff,0x87,0x68,0x5e,0xff,0xab,0x94,0x8d,0xff,0xcd,0xbf,0xbb,0xff,0xea,0xe4,0xe2,0xff,0xf6,0xf4,0xf4,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xef,0xeb,0xea,0xff,0xcb,0xbe,0xb9,0xff,0xa8,0x90,0x88,0xff,0x86,0x66,0x5c,0xff,0x6b,0x44,0x37,0xff,0x5e,0x34,0x26,0xff,0x59,0x2c,0x1e,0xff,0x57,0x2b,0x1d,0xff,0x5a,0x2e,0x20,0xff,0x61,0x37,0x29,0xff,0x6c,0x46,0x3a,0xff,0x98,0x7e,0x76,0xff,0xc9,0xbc,0xb8,0xff,
0xe7,0xe2,0xdf,0xff,0xf6,0xf5,0xf4,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xed,0xe9,0xe8,0xff,0xda,0xd1,0xce,0xff,0xbb,0xaa,0xa4,0xff,0x8a,0x6c,0x62,0xff,0x61,0x37,0x2a,0xff,0x5b,0x30,0x22,0xff,
0x58,0x2c,0x1e,0xff,0x57,0x2a,0x1c,0xff,0x58,0x2b,0x1e,0xff,0x5a,0x2e,0x22,0xff,0x66,0x3d,0x30,0xff,0x87,0x68,0x5e,0xff,0xab,0x94,0x8d,0xff,0xcd,0xbf,0xbb,0xff,0xea,0xe4,0xe2,0xff,0xf6,0xf4,0xf4,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xef,0xeb,0xea,0xff,
0xcb,0xbe,0xb9,0xff,0xa8,0x90,0x88,0xff,0x86,0x66,0x5c,0xff,0x6b,0x44,0x37,0xff,0x5e,0x34,0x26,0xff,0x59,0x2c,0x1e,0xff,0x57,0x2b,0x1d,0xff,0x5a,0x2e,0x20,0xff,0x61,0x37,0x29,0xff,0x6c,0x46,0x3a,0xff,0x98,0x7e,0x76,0xff,0xc9,0xbc,0xb8,0xff,0xe7,0xe2,0xdf,0xff,0xf6,0xf5,0xf4,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xed,0xe9,0xe8,0xff,0xda,0xd1,0xce,0xff,0xbb,0xaa,0xa4,0xff,0x8a,0x6c,0x62,0xff,0x61,0x37,0x2a,0xff,0x5b,0x30,0x22,0xff,0x58,0x2c,0x1e,0xff,0x57,0x2a,0x1c,0xff,0x58,0x2b,0x1e,0xff,0x5a,0x2e,0x22,0xff,
0x66,0x3d,0x30,0xff,0x87,0x68,0x5e,0xff,0xab,0x94,0x8d,0xff,0xcd,0xbf,0xbb,0xff,0xea,0xe4,0xe2,0xff,0xf6,0xf4,0xf4,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xef,0xeb,0xea,0xff,0xcb,0xbe,0xb9,0xff,0xa8,0x90,0x88,0xff,0x86,0x66,0x5c,0xff,0x6b,0x44,0x37,0xff,
0x5e,0x34,0x26,0xff,0x59,0x2c,0x1e,0xff,0x57,0x2b,0x1d,0xff,0x5a,0x2e,0x20,0xff,0x61,0x37,0x29,0xff,0x6c,0x46,0x3a,0xff,0x98,0x7e,0x76,0xff,0xc9,0xbc,0xb8,0xff,0xe7,0xe2,0xdf,0xff,0xf6,0xf5,0xf4,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xed,0xe9,0xe8,0xff,0xda,0xd1,0xce,0xff,0xbb,0xaa,0xa4,0xff,0x8a,0x6c,0x62,0xff,0x61,0x37,0x2a,0xff,0x5b,0x30,0x22,0xff,0x58,0x2c,0x1e,0xff,0x57,0x2a,0x1c,0xff,0x58,0x2b,0x1e,0xff,0x5a,0x2e,0x22,0xff,0x66,0x3d,0x30,0xff,0x87,0x68,0x5e,0xff,0xab,0x94,0x8d,0xff,0xcd,0xbf,0xbb,0xff,
0xea,0xe4,0xe2,0xff,0xf6,0xf4,0xf4,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xef,0xeb,0xea,0xff,0xcb,0xbe,0xb9,0xff,0xa8,0x90,0x88,0xff,0x86,0x66,0x5c,0xff,0x6b,0x44,0x37,0xff,0x5e,0x34,0x26,0xff,0x59,0x2c,0x1e,0xff,0x57,0x2b,0x1d,0xff,0x5a,0x2e,0x20,0xff,
0x61,0x37,0x29,0xff,0x6c,0x46,0x3a,0xff,0x98,0x7e,0x76,0xff,0xc9,0xbc,0xb8,0xff,0xe7,0xe2,0xdf,0xff,0xf6,0xf5,0xf4,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xed,0xe9,0xe8,0xff,0xda,0xd1,0xce,0xff,
0xbb,0xaa,0xa4,0xff,0x8a,0x6c,0x62,0xff,0x61,0x37,0x2a,0xff,0x5b,0x30,0x22,0xff,0x58,0x2c,0x1e,0xff,0x57,0x2a,0x1c,0xff,0x58,0x2b,0x1e,0xff,0x5a,0x2e,0x22,0xff,0x66,0x3d,0x30,0xff,0x87,0x68,0x5e,0xff,0xab,0x94,0x8d,0xff,0xcd,0xbf,0xbb,0xff,0xea,0xe4,0xe2,0xff,0xf6,0xf4,0xf4,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xef,0xeb,0xea,0xff,0xcb,0xbe,0xb9,0xff,0xa8,0x90,0x88,0xff,0x86,0x66,0x5c,0xff,0x6b,0x44,0x37,0xff,0x5e,0x34,0x26,0xff,0x59,0x2c,0x1e,0xff,0x57,0x2b,0x1d,0xff,0x5a,0x2e,0x20,0xff,0x61,0x37,0x29,0xff,0x6c,0x46,0x3a,0xff,0x98,0x7e,0x76,0xff,0xc9,0xbc,0xb8,0xff,
0xe7,0xe2,0xdf,0xff,0xf6,0xf5,0xf4,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xed,0xe9,0xe8,0xff,0xda,0xd1,0xce,0xff,0xbb,0xaa,0xa4,0xff,0x8a,0x6c,0x62,0xff,0x61,0x37,0x2a,0xff,0x5b,0x30,0x22,0xff,
0x58,0x2c,0x1e,0xff,0x57,0x2a,0x1c,0xff,0x58,0x2b,0x1e,0xff,0x5a,0x2e,0x22,0xff,0x66,0x3d,0x30,0xff,0x87,0x68,0x5e,0xff,0xab,0x94,0x8d,0xff,0xcd,0xbf,0xbb,0xff,0xea,0xe4,0xe2,0xff,0xf6,0xf4,0xf4,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xef,0xeb,0xea,0xff,
0xcb,0xbe,0xb9,0xff,0xa8,0x90,0x88,0xff,0x86,0x66,0x5c,0xff,0x6b,0x44,0x37,0xff,0x5e,0x34,0x26,0xff,0x59,0x2c,0x1e,0xff,0x57,0x2b,0x1d,0xff,0x5a,0x2e,0x20,0xff,0x61,0x37,0x29,0xff,0x6c,0x46,0x3a,0xff,0x98,0x7e,0x76,0xff,0xc9,0xbc,0xb8,0xff,0xe7,0xe2,0xdf,0xff,0xf6,0xf5,0xf4,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xed,0xe9,0xe8,0xff,0xda,0xd1,0xce,0xff,0xbb,0xaa,0xa4,0xff,0x8a,0x6c,0x62,0xff,0x61,0x37,0x2a,0xff,0x5b,0x30,0x22,0xff,0x58,0x2c,0x1e,0xff,0x57,0x2a,0x1c,0xff,0x58,0x2b,0x1e,0xff,0x5a,0x2e,0x22,0xff,
0x66,0x3d,0x30,0xff,0x87,0x68,0x5e,0xff,0xab,0x94,0x8d,0xff,0xcd,0xbf,0xbb,0xff,0xea,0xe4,0xe2,0xff,0xf6,0xf4,0xf4,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xef,0xeb,0xea,0xff,0xcb,0xbe,0xb9,0xff,0xa8,0x90,0x88,0xff,0x86,0x66,0x5c,0xff,0x6b,0x44,0x37,0xff,
0x5e,0x34,0x26,0xff,0x59,0x2c,0x1e,0xff,0x57,0x2b,0x1d,0xff,0x5a,0x2e,0x20,0xff,0x61,0x37,0x29,0xff,0x6c,0x46,0x3a,0xff,0x98,0x7e,0x76,0xff,0xc9,0xbc,0xb8,0xff,0xe7,0xe2,0xdf,0xff,0xf6,0xf5,0xf4,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xed,0xe9,0xe8,0xff,0xda,0xd1,0xce,0xff,0xbb,0xaa,0xa4,0xff,0x8a,0x6c,0x62,0xff,0x61,0x37,0x2a,0xff,0x5b,0x30,0x22,0xff,0x58,0x2c,0x1e,0xff,0x57,0x2a,0x1c,0xff,0x58,0x2b,0x1e,0xff,0x5a,0x2e,0x22,0xff,0x66,0x3d,0x30,0xff,0x87,0x68,0x5e,0xff,0xab,0x94,0x8d,0xff,0xcd,0xbf,0xbb,0xff,
0xea,0xe4,0xe2,0xff,0xf6,0xf4,0xf4,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xef,0xeb,0xea,0xff,0xcb,0xbe,0xb9,0xff,0xa8,0x90,0x88,0xff,0x86,0x66,0x5c,0xff,0x6b,0x44,0x37,0xff,0x5e,0x34,0x26,0xff,0x59,0x2c,0x1e,0xff,0x57,0x2b,0x1d,0xff,0x5a,0x2e,0x20,0xff,
0x61,0x37,0x29,0xff,0x6c,0x46,0x3a,0xff,0x98,0x7e,0x76,0xff,0xc9,0xbc,0xb8,0xff,0xe7,0xe2,0xdf,0xff,0xf6,0xf5,0xf4,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xed,0xe9,0xe8,0xff,0xda,0xd1,0xce,0xff,
0xbb,0xaa,0xa4,0xff,0x8a,0x6c,0x62,0xff,0x61,0x37,0x2a,0xff,0x5b,0x30,0x22,0xff,0x58,0x2c,0x1e,0xff,0x57,0x2a,0x1c,0xff,0x58,0x2b,0x1e,0xff,0x5a,0x2e,0x22,0xff,0x66,0x3d,0x30,0xff,0x87,0x68,0x5e,0xff,0xab,0x94,0x8d,0xff,0xcd,0xbf,0xbb,0xff,0xea,0xe4,0xe2,0xff,0xf6,0xf4,0xf4,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xef,0xeb,0xea,0xff,0xcb,0xbe,0xb9,0xff,0xa8,0x90,0x88,0xff,0x86,0x66,0x5c,0xff,0x6b,0x44,0x37,0xff,0x5e,0x34,0x26,0xff,0x59,0x2c,0x1e,0xff,0x57,0x2b,0x1d,0xff,0x5a,0x2e,0x20,0xff,0x61,0x37,0x29,0xff,0x6c,0x46,0x3a,0xff,0x98,0x7e,0x76,0xff,0xc9,0xbc,0xb8,0xff,
0xe7,0xe2,0xdf,0xff,0xf6,0xf5,0xf4,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xed,0xe9,0xe8,0xff,0xda,0xd1,0xce,0xff,0xbb,0xaa,0xa4,0xff,0x8a,0x6c,0x62,0xff,0x61,0x37,0x2a,0xff,0x5b,0x30,0x22,0xff,
0x58,0x2c,0x1e,0xff,0x57,0x2a,0x1c,0xff,0x58,0x2b,0x1e,0xff,0x5a,0x2e,0x22,0xff,0x66,0x3d,0x30,0xff,0x87,0x68,0x5e,0xff,0xab,0x94,0x8d,0xff,0xcd,0xbf,0xbb,0xff,0xea,0xe4,0xe2,0xff,0xf6,0xf4,0xf4,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xef,0xeb,0xea,0xff,
0xcb,0xbe,0xb9,0xff,0xa8,0x90,0x88,0xff,0x86,0x66,0x5c,0xff,0x6b,0x44,0x37,0xff,0x5e,0x34,0x26,0xff,0x59,0x2c,0x1e,0xff,0x57,0x2b,0x1d,0xff,0x5a,0x2e,0x20,0xff,0x61,0x37,0x29,0xff,0x6c,0x46,0x3a,0xff,0x98,0x7e,0x76,0xff,0xc9,0xbc,0xb8,0xff,0xe7,0xe2,0xdf,0xff,0xf6,0xf5,0xf4,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xed,0xe9,0xe8,0xff,0xda,0xd1,0xce,0xff,0xbb,0xaa,0xa4,0xff,0x8a,0x6c,0x62,0xff,0x61,0x37,0x2a,0xff,0x5b,0x30,0x22,0xff,0x58,0x2c,0x1e,0xff,0x57,0x2a,0x1c,0xff,0x58,0x2b,0x1e,0xff,0x5a,0x2e,0x22,0xff,
0x66,0x3d,0x30,0xff,0x87,0x68,0x5e,0xff,0xab,0x94,0x8d,0xff,0xcd,0xbf,0xbb,0xff,0xea,0xe4,0xe2,0xff,0xf6,0xf4,0xf4,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xef,0xeb,0xea,0xff,0xcb,0xbe,0xb9,0xff,0xa8,0x90,0x88,0xff,0x86,0x66,0x5c,0xff,0x6b,0x44,0x37,0xff,
0x5e,0x34,0x26,0xff,0x59,0x2c,0x1e,0xff,0x57,0x2b,0x1d,0xff,0x5a,0x2e,0x20,0xff,0x61,0x37,0x29,0xff,0x6c,0x46,0x3a,0xff,0x98,0x7e,0x76,0xff,0xc9,0xbc,0xb8,0xff,0xe7,0xe2,0xdf,0xff,0xf6,0xf5,0xf4,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xed,0xe9,0xe8,0xff,0xda,0xd1,0xce,0xff,0xbb,0xaa,0xa4,0xff,0x8a,0x6c,0x62,0xff,0x61,0x37,0x2a,0xff,0x5b,0x30,0x22,0xff,0x58,0x2c,0x1e,0xff,0x57,0x2a,0x1c,0xff,0x58,0x2b,0x1e,0xff,0x5a,0x2e,0x22,0xff,0x66,0x3d,0x30,0xff,0x87,0x68,0x5e,0xff,0xab,0x94,0x8d,0xff,0xcd,0xbf,0xbb,0xff,
0xea,0xe4,0xe2,0xff,0xf6,0xf4,0xf4,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xef,0xeb,0xea,0xff,0xcb,0xbe,0xb9,0xff,0xa8,0x90,0x88,0xff,0x86,0x66,0x5c,0xff,0x6b,0x44,0x37,0xff,0x5e,0x34,0x26,0xff,0x59,0x2c,0x1e,0xff,0x57,0x2b,0x1d,0xff,0x5a,0x2e,0x20,0xff,
0x61,0x37,0x29,0xff,0x6c,0x46,0x3a,0xff,0x98,0x7e,0x76,0xff,0xc9,0xbc,0xb8,0xff,0xe7,0xe2,0xdf,0xff,0xf6,0xf5,0xf4,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xed,0xe9,0xe8,0xff,0xda,0xd1,0xce,0xff,
0xbb,0xaa,0xa4,0xff,0x8a,0x6c,0x62,0xff,0x61,0x37,0x2a,0xff,0x5b,0x30,0x22,0xff,0x58,0x2c,0x1e,0xff,0x57,0x2a,0x1c,0xff,0x58,0x2b,0x1e,0xff,0x5a,0x2e,0x22,0xff,0x66,0x3d,0x30,0xff,0x87,0x68,0x5e,0xff,0xab,0x94,0x8d,0xff,0xcd,0xbf,0xbb,0xff,0xea,0xe4,0xe2,0xff,0xf6,0xf4,0xf4,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xef,0xeb,0xea,0xff,0xcb,0xbe,0xb9,0xff,0xa8,0x90,0x88,0xff,0x86,0x66,0x5c,0xff,0x6b,0x44,0x37,0xff,0x5e,0x34,0x26,0xff,0x59,0x2c,0x1e,0xff,0x57,0x2b,0x1d,0xff,0x5a,0x2e,0x20,0xff,0x61,0x37,0x29,0xff,0x6c,0x46,0x3a,0xff,0x98,0x7e,0x76,0xff,0xc9,0xbc,0xb8,0xff,
0xe7,0xe2,0xdf,0xff,0xf6,0xf5,0xf4,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xed,0xe9,0xe8,0xff,0xda,0xd1,0xce,0xff,0xbb,0xaa,0xa4,0xff,0x8a,0x6c,0x62,0xff,0x61,0x37,0x2a,0xff,0x5b,0x30,0x22,0xff,
0x58,0x2c,0x1e,0xff,0x57,0x2a,0x1c,0xff,0x58,0x2b,0x1e,0xff,0x5a,0x2e,0x22,0xff,0x66,0x3d,0x30,0xff,0x87,0x68,0x5e,0xff,0xab,0x94,0x8d,0xff,0xcd,0xbf,0xbb,0xff,0xea,0xe4,0xe2,0xff,0xf6,0xf4,0xf4,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xef,0xeb,0xea,0xff,
0xcb,0xbe,0xb9,0xff,0xa8,0x90,0x88,0xff,0x86,0x66,0x5c,0xff,0x6b,0x44,0x37,0xff,0x5e,0x34,0x26,0xff,0x59,0x2c,0x1e,0xff,0x57,0x2b,0x1d,0xff,0x5a,0x2e,0x20,0xff,0x61,0x37,0x29,0xff,0x6c,0x46,0x3a,0xff,0x98,0x7e,0x76,0xff,0xc9,0xbc,0xb8,0xff,0xe7,0xe2,0xdf,0xff,0xf6,0xf5,0xf4,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xed,0xe9,0xe8,0xff,0xda,0xd1,0xce,0xff,0xbb,0xaa,0xa4,0xff,0x8a,0x6c,0x62,0xff,0x61,0x37,0x2a,0xff,0x5b,0x30,0x22,0xff,0x58,0x2c,0x1e,0xff,0x57,0x2a,0x1c,0xff,0x58,0x2b,0x1e,0xff,0x5a,0x2e,0x22,0xff,
0x66,0x3d,0x30,0xff,0x87,0x68,0x5e,0xff,0xab,0x94,0x8d,0xff,0xcd,0xbf,0xbb,0xff,0xea,0xe4,0xe2,0xff,0xf6,0xf4,0xf4,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xef,0xeb,0xea,0xff,0xcb,0xbe,0xb9,0xff,0xa8,0x90,0x88,0xff,0x86,0x66,0x5c,0xff,0x6b,0x44,0x37,0xff,
0x5e,0x34,0x26,0xff,0x59,0x2c,0x1e,0xff,0x57,0x2b,0x1d,0xff,0x5a,0x2e,0x20,0xff,0x61,0x37,0x29,0xff,0x6c,0x46,0x3a,0xff,0x98,0x7e,0x76,0xff,0xc9,0xbc,0xb8,0xff,0xe7,0xe2,0xdf,0xff,0xf6,0xf5,0xf4,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xed,0xe9,0xe8,0xff,0xda,0xd1,0xce,0xff,0xbb,0xaa,0xa4,0xff,0x8a,0x6c,0x62,0xff,0x61,0x37,0x2a,0xff,0x5b,0x30,0x22,0xff,0x58,0x2c,0x1e,0xff,0x57,0x2a,0x1c,0xff,0x58,0x2b,0x1e,0xff,0x5a,0x2e,0x22,0xff,0x66,0x3d,0x30,0xff,0x87,0x68,0x5e,0xff,0xab,0x94,0x8d,0xff,0xcd,0xbf,0xbb,0xff,
0xea,0xe4,0xe2,0xff,0xf6,0xf4,0xf4,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xef,0xeb,0xea,0xff,0xcb,0xbe,0xb9,0xff,0xa8,0x90,0x88,0xff,0x86,0x66,0x5c,0xff,0x6b,0x44,0x37,0xff,0x5e,0x34,0x26,0xff,0x59,0x2c,0x1e,0xff,0x57,0x2b,0x1d,0xff,0x5a,0x2e,0x20,0xff,
0x61,0x37,0x29,0xff,0x6c,0x46,0x3a,0xff,0x98,0x7e,0x76,0xff,0xc9,0xbc,0xb8,0xff,0xe7,0xe2,0xdf,0xff,0xf6,0xf5,0xf4,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xed,0xe9,0xe8,0xff,0xda,0xd1,0xce,0xff,
0xbb,0xaa,0xa4,0xff,0x8a,0x6c,0x62,0xff,0x61,0x37,0x2a,0xff,0x5b,0x30,0x22,0xff,0x58,0x2c,0x1e,0xff,0x57,0x2a,0x1c,0xff,0x58,0x2b,0x1e,0xff,0x5a,0x2e,0x22,0xff,0x66,0x3d,0x30,0xff,0x87,0x68,0x5e,0xff,0xab,0x94,0x8d,0xff,0xcd,0xbf,0xbb,0xff,0xea,0xe4,0xe2,0xff,0xf6,0xf4,0xf4,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xef,0xeb,0xea,0xff,0xcb,0xbe,0xb9,0xff,0xa8,0x91,0x89,0xff,0x87,0x67,0x5d,0xff,0x6c,0x45,0x38,0xff,0x60,0x35,0x28,0xff,0x5a,0x2d,0x20,0xff,0x58,0x2c,0x1e,0xff,0x5b,0x30,0x22,0xff,0x61,0x38,0x2b,0xff,0x6d,0x47,0x3b,0xff,0x99,0x7f,0x77,0xff,0xca,0xbd,0xb8,0xff,
0xe7,0xe2,0xdf,0xff,0xf6,0xf5,0xf4,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xed,0xe9,0xe8,0xff,0xda,0xd2,0xce,0xff,0xbb,0xaa,0xa5,0xff,0x8b,0x6d,0x64,0xff,0x62,0x38,0x2b,0xff,0x5c,0x31,0x23,0xff,
0x5a,0x2d,0x1f,0xff,0x58,0x2b,0x1d,0xff,0x59,0x2c,0x1f,0xff,0x5c,0x30,0x22,0xff,0x67,0x3e,0x31,0xff,0x88,0x69,0x5f,0xff,0xac,0x95,0x8e,0xff,0xcd,0xc0,0xbb,0xff,0xea,0xe4,0xe2,0xff,0xf6,0xf4,0xf4,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0xec,0xeb,0xff,
0xcc,0xbe,0xba,0xff,0xa9,0x93,0x8b,0xff,0x89,0x6a,0x60,0xff,0x6f,0x48,0x3c,0xff,0x62,0x38,0x2b,0xff,0x5d,0x31,0x24,0xff,0x5b,0x2f,0x21,0xff,0x5e,0x33,0x26,0xff,0x64,0x3b,0x2e,0xff,0x70,0x4a,0x3e,0xff,0x9b,0x81,0x79,0xff,0xcb,0xbe,0xb9,0xff,0xe7,0xe2,0xe0,0xff,0xf7,0xf5,0xf4,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xee,0xea,0xe8,0xff,0xdb,0xd3,0xcf,0xff,0xbc,0xac,0xa6,0xff,0x8d,0x70,0x66,0xff,0x64,0x3b,0x2f,0xff,0x5f,0x34,0x27,0xff,0x5c,0x30,0x23,0xff,0x5b,0x2f,0x21,0xff,0x5c,0x30,0x22,0xff,0x5e,0x33,0x26,0xff,
0x69,0x41,0x35,0xff,0x8b,0x6b,0x61,0xff,0xad,0x97,0x90,0xff,0xce,0xc1,0xbc,0xff,0xea,0xe4,0xe3,0xff,0xf7,0xf4,0xf4,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0xec,0xeb,0xff,0xce,0xc2,0xbe,0xff,0xad,0x98,0x91,0xff,0x8e,0x71,0x67,0xff,0x75,0x51,0x44,0xff,
0x6a,0x42,0x35,0xff,0x64,0x3b,0x2e,0xff,0x62,0x39,0x2c,0xff,0x65,0x3d,0x2f,0xff,0x6b,0x44,0x38,0xff,0x76,0x52,0x47,0xff,0xa0,0x87,0x7f,0xff,0xcd,0xc1,0xbc,0xff,0xe9,0xe3,0xe1,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xee,0xeb,0xea,0xff,0xdc,0xd4,0xd2,0xff,0xbf,0xaf,0xab,0xff,0x92,0x76,0x6d,0xff,0x6b,0x44,0x38,0xff,0x66,0x3d,0x30,0xff,0x64,0x3a,0x2d,0xff,0x62,0x39,0x2c,0xff,0x63,0x39,0x2c,0xff,0x66,0x3d,0x30,0xff,0x70,0x4a,0x3e,0xff,0x90,0x72,0x69,0xff,0xb1,0x9c,0x95,0xff,0xd0,0xc4,0xbf,0xff,
0xeb,0xe6,0xe4,0xff,0xf7,0xf5,0xf4,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf3,0xef,0xee,0xff,0xd5,0xcb,0xc7,0xff,0xb9,0xa7,0xa1,0xff,0x9f,0x86,0x7e,0xff,0x89,0x6a,0x60,0xff,0x80,0x5e,0x53,0xff,0x7b,0x58,0x4c,0xff,0x79,0x56,0x4b,0xff,0x7c,0x59,0x4e,0xff,
0x81,0x60,0x55,0xff,0x8b,0x6b,0x62,0xff,0xae,0x98,0x92,0xff,0xd4,0xca,0xc6,0xff,0xec,0xe7,0xe6,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf1,0xee,0xec,0xff,0xe2,0xdb,0xd8,0xff,
0xc9,0xbb,0xb7,0xff,0xa2,0x8a,0x82,0xff,0x80,0x60,0x55,0xff,0x7d,0x5a,0x4f,0xff,0x7a,0x57,0x4c,0xff,0x79,0x56,0x4a,0xff,0x7a,0x56,0x4b,0xff,0x7c,0x59,0x4e,0xff,0x85,0x65,0x5a,0xff,0xa0,0x87,0x7f,0xff,0xbc,0xaa,0xa4,0xff,0xd7,0xcd,0xc9,0xff,0xee,0xea,0xe8,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf6,0xf2,0xf2,0xff,0xdf,0xd6,0xd4,0xff,0xc9,0xbb,0xb6,0xff,0xb5,0xa1,0x9b,0xff,0xa4,0x8c,0x84,0xff,0x9c,0x82,0x7a,0xff,0x99,0x7d,0x75,0xff,0x98,0x7c,0x73,0xff,0x99,0x7e,0x76,0xff,0x9e,0x83,0x7b,0xff,0xa5,0x8d,0x85,0xff,0xc0,0xb0,0xaa,0xff,0xde,0xd6,0xd3,0xff,
0xf0,0xec,0xeb,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf4,0xf2,0xf0,0xff,0xe9,0xe3,0xe1,0xff,0xd5,0xca,0xc7,0xff,0xb7,0xa5,0x9f,0xff,0x9d,0x84,0x7b,0xff,0x9a,0x80,0x76,0xff,
0x98,0x7d,0x74,0xff,0x97,0x7c,0x73,0xff,0x98,0x7c,0x73,0xff,0x9a,0x7f,0x76,0xff,0xa1,0x88,0x7f,0xff,0xb6,0xa2,0x9c,0xff,0xcb,0xbe,0xb9,0xff,0xe0,0xd8,0xd5,0xff,0xf1,0xee,0xed,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0xea,0xe4,0xe3,0xff,0xdc,0xd2,0xd0,0xff,0xcf,0xc2,0xbe,0xff,0xc4,0xb4,0xaf,0xff,0xbf,0xae,0xa9,0xff,0xbd,0xab,0xa6,0xff,0xbc,0xaa,0xa5,0xff,0xbd,0xac,0xa6,0xff,0xc0,0xae,0xaa,0xff,0xc5,0xb5,0xb0,0xff,0xd6,0xcb,0xc8,0xff,0xea,0xe5,0xe2,0xff,0xf5,0xf3,0xf2,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0xed,0xec,0xff,0xe3,0xdd,0xdb,0xff,0xd0,0xc4,0xc0,0xff,0xbf,0xaf,0xaa,0xff,0xbd,0xac,0xa7,0xff,0xbc,0xab,0xa5,0xff,0xbc,0xaa,0xa4,0xff,0xbc,0xaa,0xa5,0xff,0xbd,0xac,0xa6,0xff,
0xc2,0xb2,0xac,0xff,0xcf,0xc3,0xbf,0xff,0xdd,0xd5,0xd2,0xff,0xeb,0xe6,0xe4,0xff,0xf6,0xf4,0xf3,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf5,0xf2,0xf1,0xff,0xee,0xea,0xe8,0xff,0xe8,0xe2,0xe0,0xff,0xe3,0xdb,0xd9,0xff,
0xe1,0xd8,0xd6,0xff,0xdf,0xd7,0xd4,0xff,0xdf,0xd7,0xd4,0xff,0xe0,0xd7,0xd5,0xff,0xe1,0xd8,0xd6,0xff,0xe3,0xdb,0xd9,0xff,0xec,0xe6,0xe5,0xff,0xf5,0xf3,0xf2,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf2,0xef,0xee,0xff,0xe8,0xe3,0xe1,0xff,0xe0,0xd9,0xd6,0xff,0xe0,0xd7,0xd5,0xff,0xdf,0xd7,0xd4,0xff,0xdf,0xd6,0xd4,0xff,0xdf,0xd6,0xd4,0xff,0xe0,0xd8,0xd4,0xff,0xe2,0xdb,0xd7,0xff,0xe8,0xe2,0xe1,0xff,0xef,0xeb,0xea,0xff,0xf5,0xf3,0xf2,0xff,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
};
| 259.849462 | 320 | 0.797001 | ramkumarkoppu |
bae8894cb56f6176b4e986035fc0576c6c344218 | 17,458 | cc | C++ | src/i18n_data/locale/lzh_TW.cc | rqb500/fast_io | 672d28065b74eda3969eb2218ff18b3ca89dbca4 | [
"MIT"
] | 157 | 2021-07-12T07:19:15.000Z | 2022-02-16T02:22:45.000Z | src/i18n_data/locale/lzh_TW.cc | rqb500/fast_io | 672d28065b74eda3969eb2218ff18b3ca89dbca4 | [
"MIT"
] | 7 | 2021-08-02T05:06:23.000Z | 2021-12-26T10:32:18.000Z | src/i18n_data/locale/lzh_TW.cc | rqb500/fast_io | 672d28065b74eda3969eb2218ff18b3ca89dbca4 | [
"MIT"
] | 15 | 2021-07-17T19:58:14.000Z | 2021-12-30T15:37:32.000Z | #include"../localedef.h"
namespace fast_io_i18n
{
namespace
{
inline constexpr std::size_t numeric_grouping_storage[]{4};
inline constexpr basic_lc_time_era<char> time_era_storage[]{{.direction=true,.offset=2,.start_date_year=1913,.start_date_month=1,.start_date_day=1,.end_date_special=1,.era_name=tsc("民國"),.era_format=tsc("%EC%Ey年")},{.direction=true,.offset=1,.start_date_year=1912,.start_date_month=1,.start_date_day=1,.end_date_year=1912,.end_date_month=12,.end_date_day=31,.era_name=tsc("民國"),.era_format=tsc("%EC元年")},{.direction=true,.offset=1,.start_date_year=1911,.start_date_month=12,.start_date_day=31,.end_date_special=-1,.era_name=tsc("民前"),.era_format=tsc("%EC%Ey年")}};
inline constexpr basic_io_scatter_t<char> time_alt_digits_storage[]{tsc("〇"),tsc("一"),tsc("二"),tsc("三"),tsc("四"),tsc("五"),tsc("六"),tsc("七"),tsc("八"),tsc("九"),tsc("十"),tsc("十一"),tsc("十二"),tsc("十三"),tsc("十四"),tsc("十五"),tsc("十六"),tsc("十七"),tsc("十八"),tsc("十九"),tsc("廿"),tsc("廿一"),tsc("廿二"),tsc("廿三"),tsc("廿四"),tsc("廿五"),tsc("廿六"),tsc("廿七"),tsc("廿八"),tsc("廿九"),tsc("卅"),tsc("卅一")};
inline constexpr lc_all lc_all_global{.identification={.title=tsc("Literary Chinese locale for the Republic of China"),.source=tsc("fast_io"),.address=tsc("https://gitee.com/qabeowjbtkwb/fast_io"),.contact=tsc("fast_io"),.email=tsc("[email protected];[email protected]"),.tel=tsc(""),.fax=tsc(""),.language=tsc("Literary Chinese"),.territory=tsc("Taiwan"),.revision=tsc("0.1"),.date=tsc("2013-06-02")},.monetary={.int_curr_symbol=tsc("TWD "),.currency_symbol=tsc("NT$"),.mon_decimal_point=tsc("."),.mon_thousands_sep=tsc(","),.mon_grouping={numeric_grouping_storage,1},.positive_sign=tsc(""),.negative_sign=tsc("-"),.int_frac_digits=2,.frac_digits=2,.p_cs_precedes=1,.p_sep_by_space=0,.n_cs_precedes=1,.n_sep_by_space=0,.int_p_cs_precedes=1,.int_p_sep_by_space=0,.int_n_cs_precedes=1,.int_n_sep_by_space=0,.p_sign_posn=1,.n_sign_posn=1,.int_p_sign_posn=1,.int_n_sign_posn=1},.numeric={.decimal_point=tsc("."),.thousands_sep=tsc(","),.grouping={numeric_grouping_storage,1}},.time={.abday={tsc("日"),tsc("一"),tsc("二"),tsc("三"),tsc("四"),tsc("五"),tsc("六")},.day={tsc("週日"),tsc("週一"),tsc("週二"),tsc("週三"),tsc("週四"),tsc("週五"),tsc("週六")},.abmon={tsc(" 一 "),tsc(" 二 "),tsc(" 三 "),tsc(" 四 "),tsc(" 五 "),tsc(" 六 "),tsc(" 七 "),tsc(" 八 "),tsc(" 九 "),tsc(" 十 "),tsc("十一"),tsc("十二")},.mon={tsc("一月"),tsc("二月"),tsc("三月"),tsc("四月"),tsc("五月"),tsc("六月"),tsc("七月"),tsc("八月"),tsc("九月"),tsc("十月"),tsc("十一月"),tsc("十二月")},.d_t_fmt=tsc("%OC%Oy年%B%Od日 (%A) %OH時%OM分%OS秒"),.d_fmt=tsc("%OC%Oy年%B%Od日"),.t_fmt=tsc("%OH時%OM分%OS秒"),.t_fmt_ampm=tsc("%p %OI時%OM分%OS秒"),.date_fmt=tsc("公曆 %C%Oy年 %B %Oe日 %A %OH時%OM分%OS秒"),.am_pm={tsc("朝"),tsc("暮")},.era={time_era_storage,3},.alt_digits={time_alt_digits_storage,32},.week={7,19971130,1}},.messages={.yesexpr=tsc("^[+1yYyY是]"),.noexpr=tsc("^[-0nNnN非]")},.paper={.width=210,.height=297},.telephone={.tel_int_fmt=tsc("+%c-%a-%l"),.tel_dom_fmt=tsc("%A-%l"),.int_select=tsc("00"),.int_prefix=tsc("886")},.name={.name_fmt=tsc("%f%d%t%g"),.name_gen=tsc("君"),.name_miss=tsc("女"),.name_mr=tsc("子"),.name_mrs=tsc("氏"),.name_ms=tsc("娘")},.address={.postal_fmt=tsc("%c%N%T%N%s %h %e %r%N%b%N%d%N%f%N%a%N"),.country_name=tsc("中華民國"),.country_post=tsc("TW"),.country_ab2=tsc("TW"),.country_ab3=tsc("TWN"),.country_num=158,.country_car=tsc("RC"),.country_isbn=tsc("957"),.lang_name=tsc("漢語文言"),.lang_term=tsc("lzh"),.lang_lib=tsc("lzh")},.measurement={.measurement=1}};
inline constexpr basic_lc_time_era<wchar_t> wtime_era_storage[]{{.direction=true,.offset=2,.start_date_year=1913,.start_date_month=1,.start_date_day=1,.end_date_special=1,.era_name=tsc(L"民國"),.era_format=tsc(L"%EC%Ey年")},{.direction=true,.offset=1,.start_date_year=1912,.start_date_month=1,.start_date_day=1,.end_date_year=1912,.end_date_month=12,.end_date_day=31,.era_name=tsc(L"民國"),.era_format=tsc(L"%EC元年")},{.direction=true,.offset=1,.start_date_year=1911,.start_date_month=12,.start_date_day=31,.end_date_special=-1,.era_name=tsc(L"民前"),.era_format=tsc(L"%EC%Ey年")}};
inline constexpr basic_io_scatter_t<wchar_t> wtime_alt_digits_storage[]{tsc(L"〇"),tsc(L"一"),tsc(L"二"),tsc(L"三"),tsc(L"四"),tsc(L"五"),tsc(L"六"),tsc(L"七"),tsc(L"八"),tsc(L"九"),tsc(L"十"),tsc(L"十一"),tsc(L"十二"),tsc(L"十三"),tsc(L"十四"),tsc(L"十五"),tsc(L"十六"),tsc(L"十七"),tsc(L"十八"),tsc(L"十九"),tsc(L"廿"),tsc(L"廿一"),tsc(L"廿二"),tsc(L"廿三"),tsc(L"廿四"),tsc(L"廿五"),tsc(L"廿六"),tsc(L"廿七"),tsc(L"廿八"),tsc(L"廿九"),tsc(L"卅"),tsc(L"卅一")};
inline constexpr wlc_all wlc_all_global{.identification={.title=tsc(L"Literary Chinese locale for the Republic of China"),.source=tsc(L"fast_io"),.address=tsc(L"https://gitee.com/qabeowjbtkwb/fast_io"),.contact=tsc(L"fast_io"),.email=tsc(L"[email protected];[email protected]"),.tel=tsc(L""),.fax=tsc(L""),.language=tsc(L"Literary Chinese"),.territory=tsc(L"Taiwan"),.revision=tsc(L"0.1"),.date=tsc(L"2013-06-02")},.monetary={.int_curr_symbol=tsc(L"TWD "),.currency_symbol=tsc(L"NT$"),.mon_decimal_point=tsc(L"."),.mon_thousands_sep=tsc(L","),.mon_grouping={numeric_grouping_storage,1},.positive_sign=tsc(L""),.negative_sign=tsc(L"-"),.int_frac_digits=2,.frac_digits=2,.p_cs_precedes=1,.p_sep_by_space=0,.n_cs_precedes=1,.n_sep_by_space=0,.int_p_cs_precedes=1,.int_p_sep_by_space=0,.int_n_cs_precedes=1,.int_n_sep_by_space=0,.p_sign_posn=1,.n_sign_posn=1,.int_p_sign_posn=1,.int_n_sign_posn=1},.numeric={.decimal_point=tsc(L"."),.thousands_sep=tsc(L","),.grouping={numeric_grouping_storage,1}},.time={.abday={tsc(L"日"),tsc(L"一"),tsc(L"二"),tsc(L"三"),tsc(L"四"),tsc(L"五"),tsc(L"六")},.day={tsc(L"週日"),tsc(L"週一"),tsc(L"週二"),tsc(L"週三"),tsc(L"週四"),tsc(L"週五"),tsc(L"週六")},.abmon={tsc(L" 一 "),tsc(L" 二 "),tsc(L" 三 "),tsc(L" 四 "),tsc(L" 五 "),tsc(L" 六 "),tsc(L" 七 "),tsc(L" 八 "),tsc(L" 九 "),tsc(L" 十 "),tsc(L"十一"),tsc(L"十二")},.mon={tsc(L"一月"),tsc(L"二月"),tsc(L"三月"),tsc(L"四月"),tsc(L"五月"),tsc(L"六月"),tsc(L"七月"),tsc(L"八月"),tsc(L"九月"),tsc(L"十月"),tsc(L"十一月"),tsc(L"十二月")},.d_t_fmt=tsc(L"%OC%Oy年%B%Od日 (%A) %OH時%OM分%OS秒"),.d_fmt=tsc(L"%OC%Oy年%B%Od日"),.t_fmt=tsc(L"%OH時%OM分%OS秒"),.t_fmt_ampm=tsc(L"%p %OI時%OM分%OS秒"),.date_fmt=tsc(L"公曆 %C%Oy年 %B %Oe日 %A %OH時%OM分%OS秒"),.am_pm={tsc(L"朝"),tsc(L"暮")},.era={wtime_era_storage,3},.alt_digits={wtime_alt_digits_storage,32},.week={7,19971130,1}},.messages={.yesexpr=tsc(L"^[+1yYyY是]"),.noexpr=tsc(L"^[-0nNnN非]")},.paper={.width=210,.height=297},.telephone={.tel_int_fmt=tsc(L"+%c-%a-%l"),.tel_dom_fmt=tsc(L"%A-%l"),.int_select=tsc(L"00"),.int_prefix=tsc(L"886")},.name={.name_fmt=tsc(L"%f%d%t%g"),.name_gen=tsc(L"君"),.name_miss=tsc(L"女"),.name_mr=tsc(L"子"),.name_mrs=tsc(L"氏"),.name_ms=tsc(L"娘")},.address={.postal_fmt=tsc(L"%c%N%T%N%s %h %e %r%N%b%N%d%N%f%N%a%N"),.country_name=tsc(L"中華民國"),.country_post=tsc(L"TW"),.country_ab2=tsc(L"TW"),.country_ab3=tsc(L"TWN"),.country_num=158,.country_car=tsc(L"RC"),.country_isbn=tsc(L"957"),.lang_name=tsc(L"漢語文言"),.lang_term=tsc(L"lzh"),.lang_lib=tsc(L"lzh")},.measurement={.measurement=1}};
inline constexpr basic_lc_time_era<char8_t> u8time_era_storage[]{{.direction=true,.offset=2,.start_date_year=1913,.start_date_month=1,.start_date_day=1,.end_date_special=1,.era_name=tsc(u8"民國"),.era_format=tsc(u8"%EC%Ey年")},{.direction=true,.offset=1,.start_date_year=1912,.start_date_month=1,.start_date_day=1,.end_date_year=1912,.end_date_month=12,.end_date_day=31,.era_name=tsc(u8"民國"),.era_format=tsc(u8"%EC元年")},{.direction=true,.offset=1,.start_date_year=1911,.start_date_month=12,.start_date_day=31,.end_date_special=-1,.era_name=tsc(u8"民前"),.era_format=tsc(u8"%EC%Ey年")}};
inline constexpr basic_io_scatter_t<char8_t> u8time_alt_digits_storage[]{tsc(u8"〇"),tsc(u8"一"),tsc(u8"二"),tsc(u8"三"),tsc(u8"四"),tsc(u8"五"),tsc(u8"六"),tsc(u8"七"),tsc(u8"八"),tsc(u8"九"),tsc(u8"十"),tsc(u8"十一"),tsc(u8"十二"),tsc(u8"十三"),tsc(u8"十四"),tsc(u8"十五"),tsc(u8"十六"),tsc(u8"十七"),tsc(u8"十八"),tsc(u8"十九"),tsc(u8"廿"),tsc(u8"廿一"),tsc(u8"廿二"),tsc(u8"廿三"),tsc(u8"廿四"),tsc(u8"廿五"),tsc(u8"廿六"),tsc(u8"廿七"),tsc(u8"廿八"),tsc(u8"廿九"),tsc(u8"卅"),tsc(u8"卅一")};
inline constexpr u8lc_all u8lc_all_global{.identification={.title=tsc(u8"Literary Chinese locale for the Republic of China"),.source=tsc(u8"fast_io"),.address=tsc(u8"https://gitee.com/qabeowjbtkwb/fast_io"),.contact=tsc(u8"fast_io"),.email=tsc(u8"[email protected];[email protected]"),.tel=tsc(u8""),.fax=tsc(u8""),.language=tsc(u8"Literary Chinese"),.territory=tsc(u8"Taiwan"),.revision=tsc(u8"0.1"),.date=tsc(u8"2013-06-02")},.monetary={.int_curr_symbol=tsc(u8"TWD "),.currency_symbol=tsc(u8"NT$"),.mon_decimal_point=tsc(u8"."),.mon_thousands_sep=tsc(u8","),.mon_grouping={numeric_grouping_storage,1},.positive_sign=tsc(u8""),.negative_sign=tsc(u8"-"),.int_frac_digits=2,.frac_digits=2,.p_cs_precedes=1,.p_sep_by_space=0,.n_cs_precedes=1,.n_sep_by_space=0,.int_p_cs_precedes=1,.int_p_sep_by_space=0,.int_n_cs_precedes=1,.int_n_sep_by_space=0,.p_sign_posn=1,.n_sign_posn=1,.int_p_sign_posn=1,.int_n_sign_posn=1},.numeric={.decimal_point=tsc(u8"."),.thousands_sep=tsc(u8","),.grouping={numeric_grouping_storage,1}},.time={.abday={tsc(u8"日"),tsc(u8"一"),tsc(u8"二"),tsc(u8"三"),tsc(u8"四"),tsc(u8"五"),tsc(u8"六")},.day={tsc(u8"週日"),tsc(u8"週一"),tsc(u8"週二"),tsc(u8"週三"),tsc(u8"週四"),tsc(u8"週五"),tsc(u8"週六")},.abmon={tsc(u8" 一 "),tsc(u8" 二 "),tsc(u8" 三 "),tsc(u8" 四 "),tsc(u8" 五 "),tsc(u8" 六 "),tsc(u8" 七 "),tsc(u8" 八 "),tsc(u8" 九 "),tsc(u8" 十 "),tsc(u8"十一"),tsc(u8"十二")},.mon={tsc(u8"一月"),tsc(u8"二月"),tsc(u8"三月"),tsc(u8"四月"),tsc(u8"五月"),tsc(u8"六月"),tsc(u8"七月"),tsc(u8"八月"),tsc(u8"九月"),tsc(u8"十月"),tsc(u8"十一月"),tsc(u8"十二月")},.d_t_fmt=tsc(u8"%OC%Oy年%B%Od日 (%A) %OH時%OM分%OS秒"),.d_fmt=tsc(u8"%OC%Oy年%B%Od日"),.t_fmt=tsc(u8"%OH時%OM分%OS秒"),.t_fmt_ampm=tsc(u8"%p %OI時%OM分%OS秒"),.date_fmt=tsc(u8"公曆 %C%Oy年 %B %Oe日 %A %OH時%OM分%OS秒"),.am_pm={tsc(u8"朝"),tsc(u8"暮")},.era={u8time_era_storage,3},.alt_digits={u8time_alt_digits_storage,32},.week={7,19971130,1}},.messages={.yesexpr=tsc(u8"^[+1yYyY是]"),.noexpr=tsc(u8"^[-0nNnN非]")},.paper={.width=210,.height=297},.telephone={.tel_int_fmt=tsc(u8"+%c-%a-%l"),.tel_dom_fmt=tsc(u8"%A-%l"),.int_select=tsc(u8"00"),.int_prefix=tsc(u8"886")},.name={.name_fmt=tsc(u8"%f%d%t%g"),.name_gen=tsc(u8"君"),.name_miss=tsc(u8"女"),.name_mr=tsc(u8"子"),.name_mrs=tsc(u8"氏"),.name_ms=tsc(u8"娘")},.address={.postal_fmt=tsc(u8"%c%N%T%N%s %h %e %r%N%b%N%d%N%f%N%a%N"),.country_name=tsc(u8"中華民國"),.country_post=tsc(u8"TW"),.country_ab2=tsc(u8"TW"),.country_ab3=tsc(u8"TWN"),.country_num=158,.country_car=tsc(u8"RC"),.country_isbn=tsc(u8"957"),.lang_name=tsc(u8"漢語文言"),.lang_term=tsc(u8"lzh"),.lang_lib=tsc(u8"lzh")},.measurement={.measurement=1}};
inline constexpr basic_lc_time_era<char16_t> u16time_era_storage[]{{.direction=true,.offset=2,.start_date_year=1913,.start_date_month=1,.start_date_day=1,.end_date_special=1,.era_name=tsc(u"民國"),.era_format=tsc(u"%EC%Ey年")},{.direction=true,.offset=1,.start_date_year=1912,.start_date_month=1,.start_date_day=1,.end_date_year=1912,.end_date_month=12,.end_date_day=31,.era_name=tsc(u"民國"),.era_format=tsc(u"%EC元年")},{.direction=true,.offset=1,.start_date_year=1911,.start_date_month=12,.start_date_day=31,.end_date_special=-1,.era_name=tsc(u"民前"),.era_format=tsc(u"%EC%Ey年")}};
inline constexpr basic_io_scatter_t<char16_t> u16time_alt_digits_storage[]{tsc(u"〇"),tsc(u"一"),tsc(u"二"),tsc(u"三"),tsc(u"四"),tsc(u"五"),tsc(u"六"),tsc(u"七"),tsc(u"八"),tsc(u"九"),tsc(u"十"),tsc(u"十一"),tsc(u"十二"),tsc(u"十三"),tsc(u"十四"),tsc(u"十五"),tsc(u"十六"),tsc(u"十七"),tsc(u"十八"),tsc(u"十九"),tsc(u"廿"),tsc(u"廿一"),tsc(u"廿二"),tsc(u"廿三"),tsc(u"廿四"),tsc(u"廿五"),tsc(u"廿六"),tsc(u"廿七"),tsc(u"廿八"),tsc(u"廿九"),tsc(u"卅"),tsc(u"卅一")};
inline constexpr u16lc_all u16lc_all_global{.identification={.title=tsc(u"Literary Chinese locale for the Republic of China"),.source=tsc(u"fast_io"),.address=tsc(u"https://gitee.com/qabeowjbtkwb/fast_io"),.contact=tsc(u"fast_io"),.email=tsc(u"[email protected];[email protected]"),.tel=tsc(u""),.fax=tsc(u""),.language=tsc(u"Literary Chinese"),.territory=tsc(u"Taiwan"),.revision=tsc(u"0.1"),.date=tsc(u"2013-06-02")},.monetary={.int_curr_symbol=tsc(u"TWD "),.currency_symbol=tsc(u"NT$"),.mon_decimal_point=tsc(u"."),.mon_thousands_sep=tsc(u","),.mon_grouping={numeric_grouping_storage,1},.positive_sign=tsc(u""),.negative_sign=tsc(u"-"),.int_frac_digits=2,.frac_digits=2,.p_cs_precedes=1,.p_sep_by_space=0,.n_cs_precedes=1,.n_sep_by_space=0,.int_p_cs_precedes=1,.int_p_sep_by_space=0,.int_n_cs_precedes=1,.int_n_sep_by_space=0,.p_sign_posn=1,.n_sign_posn=1,.int_p_sign_posn=1,.int_n_sign_posn=1},.numeric={.decimal_point=tsc(u"."),.thousands_sep=tsc(u","),.grouping={numeric_grouping_storage,1}},.time={.abday={tsc(u"日"),tsc(u"一"),tsc(u"二"),tsc(u"三"),tsc(u"四"),tsc(u"五"),tsc(u"六")},.day={tsc(u"週日"),tsc(u"週一"),tsc(u"週二"),tsc(u"週三"),tsc(u"週四"),tsc(u"週五"),tsc(u"週六")},.abmon={tsc(u" 一 "),tsc(u" 二 "),tsc(u" 三 "),tsc(u" 四 "),tsc(u" 五 "),tsc(u" 六 "),tsc(u" 七 "),tsc(u" 八 "),tsc(u" 九 "),tsc(u" 十 "),tsc(u"十一"),tsc(u"十二")},.mon={tsc(u"一月"),tsc(u"二月"),tsc(u"三月"),tsc(u"四月"),tsc(u"五月"),tsc(u"六月"),tsc(u"七月"),tsc(u"八月"),tsc(u"九月"),tsc(u"十月"),tsc(u"十一月"),tsc(u"十二月")},.d_t_fmt=tsc(u"%OC%Oy年%B%Od日 (%A) %OH時%OM分%OS秒"),.d_fmt=tsc(u"%OC%Oy年%B%Od日"),.t_fmt=tsc(u"%OH時%OM分%OS秒"),.t_fmt_ampm=tsc(u"%p %OI時%OM分%OS秒"),.date_fmt=tsc(u"公曆 %C%Oy年 %B %Oe日 %A %OH時%OM分%OS秒"),.am_pm={tsc(u"朝"),tsc(u"暮")},.era={u16time_era_storage,3},.alt_digits={u16time_alt_digits_storage,32},.week={7,19971130,1}},.messages={.yesexpr=tsc(u"^[+1yYyY是]"),.noexpr=tsc(u"^[-0nNnN非]")},.paper={.width=210,.height=297},.telephone={.tel_int_fmt=tsc(u"+%c-%a-%l"),.tel_dom_fmt=tsc(u"%A-%l"),.int_select=tsc(u"00"),.int_prefix=tsc(u"886")},.name={.name_fmt=tsc(u"%f%d%t%g"),.name_gen=tsc(u"君"),.name_miss=tsc(u"女"),.name_mr=tsc(u"子"),.name_mrs=tsc(u"氏"),.name_ms=tsc(u"娘")},.address={.postal_fmt=tsc(u"%c%N%T%N%s %h %e %r%N%b%N%d%N%f%N%a%N"),.country_name=tsc(u"中華民國"),.country_post=tsc(u"TW"),.country_ab2=tsc(u"TW"),.country_ab3=tsc(u"TWN"),.country_num=158,.country_car=tsc(u"RC"),.country_isbn=tsc(u"957"),.lang_name=tsc(u"漢語文言"),.lang_term=tsc(u"lzh"),.lang_lib=tsc(u"lzh")},.measurement={.measurement=1}};
inline constexpr basic_lc_time_era<char32_t> u32time_era_storage[]{{.direction=true,.offset=2,.start_date_year=1913,.start_date_month=1,.start_date_day=1,.end_date_special=1,.era_name=tsc(U"民國"),.era_format=tsc(U"%EC%Ey年")},{.direction=true,.offset=1,.start_date_year=1912,.start_date_month=1,.start_date_day=1,.end_date_year=1912,.end_date_month=12,.end_date_day=31,.era_name=tsc(U"民國"),.era_format=tsc(U"%EC元年")},{.direction=true,.offset=1,.start_date_year=1911,.start_date_month=12,.start_date_day=31,.end_date_special=-1,.era_name=tsc(U"民前"),.era_format=tsc(U"%EC%Ey年")}};
inline constexpr basic_io_scatter_t<char32_t> u32time_alt_digits_storage[]{tsc(U"〇"),tsc(U"一"),tsc(U"二"),tsc(U"三"),tsc(U"四"),tsc(U"五"),tsc(U"六"),tsc(U"七"),tsc(U"八"),tsc(U"九"),tsc(U"十"),tsc(U"十一"),tsc(U"十二"),tsc(U"十三"),tsc(U"十四"),tsc(U"十五"),tsc(U"十六"),tsc(U"十七"),tsc(U"十八"),tsc(U"十九"),tsc(U"廿"),tsc(U"廿一"),tsc(U"廿二"),tsc(U"廿三"),tsc(U"廿四"),tsc(U"廿五"),tsc(U"廿六"),tsc(U"廿七"),tsc(U"廿八"),tsc(U"廿九"),tsc(U"卅"),tsc(U"卅一")};
inline constexpr u32lc_all u32lc_all_global{.identification={.title=tsc(U"Literary Chinese locale for the Republic of China"),.source=tsc(U"fast_io"),.address=tsc(U"https://gitee.com/qabeowjbtkwb/fast_io"),.contact=tsc(U"fast_io"),.email=tsc(U"[email protected];[email protected]"),.tel=tsc(U""),.fax=tsc(U""),.language=tsc(U"Literary Chinese"),.territory=tsc(U"Taiwan"),.revision=tsc(U"0.1"),.date=tsc(U"2013-06-02")},.monetary={.int_curr_symbol=tsc(U"TWD "),.currency_symbol=tsc(U"NT$"),.mon_decimal_point=tsc(U"."),.mon_thousands_sep=tsc(U","),.mon_grouping={numeric_grouping_storage,1},.positive_sign=tsc(U""),.negative_sign=tsc(U"-"),.int_frac_digits=2,.frac_digits=2,.p_cs_precedes=1,.p_sep_by_space=0,.n_cs_precedes=1,.n_sep_by_space=0,.int_p_cs_precedes=1,.int_p_sep_by_space=0,.int_n_cs_precedes=1,.int_n_sep_by_space=0,.p_sign_posn=1,.n_sign_posn=1,.int_p_sign_posn=1,.int_n_sign_posn=1},.numeric={.decimal_point=tsc(U"."),.thousands_sep=tsc(U","),.grouping={numeric_grouping_storage,1}},.time={.abday={tsc(U"日"),tsc(U"一"),tsc(U"二"),tsc(U"三"),tsc(U"四"),tsc(U"五"),tsc(U"六")},.day={tsc(U"週日"),tsc(U"週一"),tsc(U"週二"),tsc(U"週三"),tsc(U"週四"),tsc(U"週五"),tsc(U"週六")},.abmon={tsc(U" 一 "),tsc(U" 二 "),tsc(U" 三 "),tsc(U" 四 "),tsc(U" 五 "),tsc(U" 六 "),tsc(U" 七 "),tsc(U" 八 "),tsc(U" 九 "),tsc(U" 十 "),tsc(U"十一"),tsc(U"十二")},.mon={tsc(U"一月"),tsc(U"二月"),tsc(U"三月"),tsc(U"四月"),tsc(U"五月"),tsc(U"六月"),tsc(U"七月"),tsc(U"八月"),tsc(U"九月"),tsc(U"十月"),tsc(U"十一月"),tsc(U"十二月")},.d_t_fmt=tsc(U"%OC%Oy年%B%Od日 (%A) %OH時%OM分%OS秒"),.d_fmt=tsc(U"%OC%Oy年%B%Od日"),.t_fmt=tsc(U"%OH時%OM分%OS秒"),.t_fmt_ampm=tsc(U"%p %OI時%OM分%OS秒"),.date_fmt=tsc(U"公曆 %C%Oy年 %B %Oe日 %A %OH時%OM分%OS秒"),.am_pm={tsc(U"朝"),tsc(U"暮")},.era={u32time_era_storage,3},.alt_digits={u32time_alt_digits_storage,32},.week={7,19971130,1}},.messages={.yesexpr=tsc(U"^[+1yYyY是]"),.noexpr=tsc(U"^[-0nNnN非]")},.paper={.width=210,.height=297},.telephone={.tel_int_fmt=tsc(U"+%c-%a-%l"),.tel_dom_fmt=tsc(U"%A-%l"),.int_select=tsc(U"00"),.int_prefix=tsc(U"886")},.name={.name_fmt=tsc(U"%f%d%t%g"),.name_gen=tsc(U"君"),.name_miss=tsc(U"女"),.name_mr=tsc(U"子"),.name_mrs=tsc(U"氏"),.name_ms=tsc(U"娘")},.address={.postal_fmt=tsc(U"%c%N%T%N%s %h %e %r%N%b%N%d%N%f%N%a%N"),.country_name=tsc(U"中華民國"),.country_post=tsc(U"TW"),.country_ab2=tsc(U"TW"),.country_ab3=tsc(U"TWN"),.country_num=158,.country_car=tsc(U"RC"),.country_isbn=tsc(U"957"),.lang_name=tsc(U"漢語文言"),.lang_term=tsc(U"lzh"),.lang_lib=tsc(U"lzh")},.measurement={.measurement=1}};
}
}
#include"../main.h" | 396.772727 | 2,556 | 0.682782 | rqb500 |
baea97d88e0f1d4897bb6ab6d6bb965c3baa0b7e | 14,457 | cpp | C++ | Lib/LLVMJIT/EmitFunction.cpp | PiotrSikora/WAVM | da97d6bcf421ac5d8b40ccccc8d36d4ba01a0356 | [
"BSD-3-Clause"
] | null | null | null | Lib/LLVMJIT/EmitFunction.cpp | PiotrSikora/WAVM | da97d6bcf421ac5d8b40ccccc8d36d4ba01a0356 | [
"BSD-3-Clause"
] | null | null | null | Lib/LLVMJIT/EmitFunction.cpp | PiotrSikora/WAVM | da97d6bcf421ac5d8b40ccccc8d36d4ba01a0356 | [
"BSD-3-Clause"
] | null | null | null | #include <stdint.h>
#include <initializer_list>
#include <memory>
#include <string>
#include <vector>
#include "EmitFunctionContext.h"
#include "EmitModuleContext.h"
#include "LLVMJITPrivate.h"
#include "WAVM/IR/Module.h"
#include "WAVM/IR/OperatorPrinter.h"
#include "WAVM/IR/Operators.h"
#include "WAVM/IR/Types.h"
#include "WAVM/Inline/Assert.h"
#include "WAVM/Inline/BasicTypes.h"
#include "WAVM/Inline/Errors.h"
#include "WAVM/Logging/Logging.h"
PUSH_DISABLE_WARNINGS_FOR_LLVM_HEADERS
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/Twine.h"
#include "llvm/IR/Argument.h"
#include "llvm/IR/BasicBlock.h"
#include "llvm/IR/Constant.h"
#include "llvm/IR/Constants.h"
#include "llvm/IR/DIBuilder.h"
#include "llvm/IR/DebugInfoMetadata.h"
#include "llvm/IR/Function.h"
#include "llvm/IR/GlobalValue.h"
#include "llvm/IR/IRBuilder.h"
#include "llvm/IR/Instructions.h"
#include "llvm/IR/Intrinsics.h"
#include "llvm/IR/Module.h"
#include "llvm/IR/Type.h"
#include "llvm/IR/Value.h"
#include "llvm/Support/raw_ostream.h"
POP_DISABLE_WARNINGS_FOR_LLVM_HEADERS
namespace llvm {
class Metadata;
}
#define ENABLE_LOGGING 0
#define EMIT_ENTER_EXIT_HOOKS 0
using namespace WAVM;
using namespace WAVM::IR;
using namespace WAVM::LLVMJIT;
using namespace WAVM::Runtime;
// Creates a PHI node for the argument of branches to a basic block.
PHIVector EmitFunctionContext::createPHIs(llvm::BasicBlock* basicBlock, IR::TypeTuple type)
{
auto originalBlock = irBuilder.GetInsertBlock();
irBuilder.SetInsertPoint(basicBlock);
PHIVector result;
for(Uptr elementIndex = 0; elementIndex < type.size(); ++elementIndex)
{ result.push_back(irBuilder.CreatePHI(asLLVMType(llvmContext, type[elementIndex]), 2)); }
if(originalBlock) { irBuilder.SetInsertPoint(originalBlock); }
return result;
}
// Bitcasts a LLVM value to a canonical type for the corresponding WebAssembly type. This is
// currently just used to map all the various vector types to a canonical type for the vector width.
llvm::Value* EmitFunctionContext::coerceToCanonicalType(llvm::Value* value)
{
if(value->getType()->isVectorTy())
{
switch(value->getType()->getScalarSizeInBits() * value->getType()->getVectorNumElements())
{
case 128: return irBuilder.CreateBitCast(value, llvmContext.i64x2Type);
default: Errors::unreachable();
};
}
else if(value->getType()->isX86_MMXTy())
{
return irBuilder.CreateBitCast(value, llvmContext.i64x2Type);
}
else
{
return value;
}
}
// Debug logging.
void EmitFunctionContext::logOperator(const std::string& operatorDescription)
{
if(ENABLE_LOGGING)
{
std::string controlStackString;
for(Uptr stackIndex = 0; stackIndex < controlStack.size(); ++stackIndex)
{
if(!controlStack[stackIndex].isReachable) { controlStackString += "("; }
switch(controlStack[stackIndex].type)
{
case ControlContext::Type::function: controlStackString += "F"; break;
case ControlContext::Type::block: controlStackString += "B"; break;
case ControlContext::Type::ifThen: controlStackString += "I"; break;
case ControlContext::Type::ifElse: controlStackString += "E"; break;
case ControlContext::Type::loop: controlStackString += "L"; break;
case ControlContext::Type::try_: controlStackString += "T"; break;
case ControlContext::Type::catch_: controlStackString += "C"; break;
default: Errors::unreachable();
};
if(!controlStack[stackIndex].isReachable) { controlStackString += ")"; }
}
std::string stackString;
const Uptr stackBase = controlStack.size() == 0 ? 0 : controlStack.back().outerStackSize;
for(Uptr stackIndex = 0; stackIndex < stack.size(); ++stackIndex)
{
if(stackIndex == stackBase) { stackString += "| "; }
{
llvm::raw_string_ostream stackTypeStream(stackString);
stack[stackIndex]->getType()->print(stackTypeStream, true);
}
stackString += " ";
}
if(stack.size() == stackBase) { stackString += "|"; }
Log::printf(Log::debug,
"%-50s %-50s %-50s\n",
controlStackString.c_str(),
operatorDescription.c_str(),
stackString.c_str());
}
}
// Traps a divide-by-zero
void EmitFunctionContext::trapDivideByZero(llvm::Value* divisor)
{
emitConditionalTrapIntrinsic(
irBuilder.CreateICmpEQ(divisor, llvm::Constant::getNullValue(divisor->getType())),
"divideByZeroOrIntegerOverflowTrap",
FunctionType(),
{});
}
// Traps on (x / 0) or (INT_MIN / -1).
void EmitFunctionContext::trapDivideByZeroOrIntegerOverflow(ValueType type,
llvm::Value* left,
llvm::Value* right)
{
emitConditionalTrapIntrinsic(
irBuilder.CreateOr(
irBuilder.CreateAnd(
irBuilder.CreateICmpEQ(left,
type == ValueType::i32
? emitLiteral(llvmContext, (U32)INT32_MIN)
: emitLiteral(llvmContext, (U64)INT64_MIN)),
irBuilder.CreateICmpEQ(right,
type == ValueType::i32 ? emitLiteral(llvmContext, (U32)-1)
: emitLiteral(llvmContext, (U64)-1))),
irBuilder.CreateICmpEQ(right, llvmContext.typedZeroConstants[(Uptr)type])),
"divideByZeroOrIntegerOverflowTrap",
FunctionType(),
{});
}
// Emits a call to a WAVM intrinsic function.
ValueVector EmitFunctionContext::emitRuntimeIntrinsic(
const char* intrinsicName,
FunctionType intrinsicType,
const std::initializer_list<llvm::Value*>& args)
{
llvm::Function* intrinsicFunction = moduleContext.llvmModule->getFunction(intrinsicName);
if(!intrinsicFunction)
{
intrinsicFunction = llvm::Function::Create(
asLLVMType(llvmContext, intrinsicType, CallingConvention::intrinsic),
llvm::Function::ExternalLinkage,
intrinsicName,
moduleContext.llvmModule);
intrinsicFunction->setCallingConv(asLLVMCallingConv(CallingConvention::intrinsic));
}
return emitCallOrInvoke(intrinsicFunction,
args,
intrinsicType,
CallingConvention::intrinsic,
getInnermostUnwindToBlock());
}
// A helper function to emit a conditional call to a non-returning intrinsic function.
void EmitFunctionContext::emitConditionalTrapIntrinsic(
llvm::Value* booleanCondition,
const char* intrinsicName,
FunctionType intrinsicType,
const std::initializer_list<llvm::Value*>& args)
{
auto trueBlock
= llvm::BasicBlock::Create(llvmContext, llvm::Twine(intrinsicName) + "Trap", function);
auto endBlock
= llvm::BasicBlock::Create(llvmContext, llvm::Twine(intrinsicName) + "Skip", function);
irBuilder.CreateCondBr(
booleanCondition, trueBlock, endBlock, moduleContext.likelyFalseBranchWeights);
irBuilder.SetInsertPoint(trueBlock);
emitRuntimeIntrinsic(intrinsicName, intrinsicType, args);
irBuilder.CreateUnreachable();
irBuilder.SetInsertPoint(endBlock);
}
//
// Control structure operators
//
void EmitFunctionContext::pushControlStack(ControlContext::Type type,
TypeTuple resultTypes,
llvm::BasicBlock* endBlock,
const PHIVector& endPHIs,
llvm::BasicBlock* elseBlock,
const ValueVector& elseArgs)
{
// The unreachable operator filtering should filter out any opcodes that call pushControlStack.
if(controlStack.size()) { errorUnless(controlStack.back().isReachable); }
controlStack.push_back({type,
endBlock,
endPHIs,
elseBlock,
elseArgs,
resultTypes,
stack.size(),
branchTargetStack.size(),
true});
}
void EmitFunctionContext::pushBranchTarget(TypeTuple branchArgumentType,
llvm::BasicBlock* branchTargetBlock,
const PHIVector& branchTargetPHIs)
{
branchTargetStack.push_back({branchArgumentType, branchTargetBlock, branchTargetPHIs});
}
void EmitFunctionContext::branchToEndOfControlContext()
{
ControlContext& currentContext = controlStack.back();
if(currentContext.isReachable)
{
// If the control context expects a result, take it from the operand stack and add it to the
// control context's end PHI.
for(Iptr resultIndex = Iptr(currentContext.resultTypes.size()) - 1; resultIndex >= 0;
--resultIndex)
{
llvm::Value* result = pop();
currentContext.endPHIs[resultIndex]->addIncoming(coerceToCanonicalType(result),
irBuilder.GetInsertBlock());
}
// Branch to the control context's end.
irBuilder.CreateBr(currentContext.endBlock);
}
wavmAssert(stack.size() == currentContext.outerStackSize);
}
void EmitFunctionContext::enterUnreachable()
{
// Unwind the operand stack to the outer control context.
wavmAssert(controlStack.back().outerStackSize <= stack.size());
stack.resize(controlStack.back().outerStackSize);
// Mark the current control context as unreachable: this will cause the outer loop to stop
// dispatching operators to us until an else/end for the current control context is reached.
controlStack.back().isReachable = false;
}
// A do-nothing visitor used to decode past unreachable operators (but supporting logging, and
// passing the end operator through).
struct UnreachableOpVisitor
{
typedef void Result;
UnreachableOpVisitor(EmitFunctionContext& inContext)
: context(inContext), unreachableControlDepth(0)
{
}
#define VISIT_OP(opcode, name, nameString, Imm, ...) \
void name(Imm imm) {}
ENUM_NONCONTROL_OPERATORS(VISIT_OP)
VISIT_OP(_, unknown, "unknown", Opcode)
#undef VISIT_OP
// Keep track of control structure nesting level in unreachable code, so we know when we reach
// the end of the unreachable code.
void block(ControlStructureImm) { ++unreachableControlDepth; }
void loop(ControlStructureImm) { ++unreachableControlDepth; }
void if_(ControlStructureImm) { ++unreachableControlDepth; }
// If an else or end opcode would signal an end to the unreachable code, then pass it through to
// the IR emitter.
void else_(NoImm imm)
{
if(!unreachableControlDepth) { context.else_(imm); }
}
void end(NoImm imm)
{
if(!unreachableControlDepth) { context.end(imm); }
else
{
--unreachableControlDepth;
}
}
void try_(ControlStructureImm imm) { ++unreachableControlDepth; }
void catch_(ExceptionTypeImm imm)
{
if(!unreachableControlDepth) { context.catch_(imm); }
}
void catch_all(NoImm imm)
{
if(!unreachableControlDepth) { context.catch_all(imm); }
}
private:
EmitFunctionContext& context;
Uptr unreachableControlDepth;
};
void EmitFunctionContext::emit()
{
// Create debug info for the function.
llvm::SmallVector<llvm::Metadata*, 10> diFunctionParameterTypes;
for(auto parameterType : functionType.params())
{ diFunctionParameterTypes.push_back(moduleContext.diValueTypes[(Uptr)parameterType]); }
auto diParamArray = moduleContext.diBuilder.getOrCreateTypeArray(diFunctionParameterTypes);
auto diFunctionType = moduleContext.diBuilder.createSubroutineType(diParamArray);
diFunction = moduleContext.diBuilder.createFunction(moduleContext.diModuleScope,
function->getName(),
function->getName(),
moduleContext.diModuleScope,
0,
diFunctionType,
false,
true,
0);
function->setSubprogram(diFunction);
// Create the return basic block, and push the root control context for the function.
auto returnBlock = llvm::BasicBlock::Create(llvmContext, "return", function);
auto returnPHIs = createPHIs(returnBlock, functionType.results());
pushControlStack(
ControlContext::Type::function, functionType.results(), returnBlock, returnPHIs);
pushBranchTarget(functionType.results(), returnBlock, returnPHIs);
// Create an initial basic block for the function.
auto entryBasicBlock = llvm::BasicBlock::Create(llvmContext, "entry", function);
irBuilder.SetInsertPoint(entryBasicBlock);
// Create and initialize allocas for the memory and table base parameters.
auto llvmArgIt = function->arg_begin();
initContextVariables(&*llvmArgIt++);
// Create and initialize allocas for all the locals and parameters.
for(Uptr localIndex = 0;
localIndex < functionType.params().size() + functionDef.nonParameterLocalTypes.size();
++localIndex)
{
auto localType
= localIndex < functionType.params().size()
? functionType.params()[localIndex]
: functionDef.nonParameterLocalTypes[localIndex - functionType.params().size()];
auto localPointer = irBuilder.CreateAlloca(asLLVMType(llvmContext, localType), nullptr, "");
localPointers.push_back(localPointer);
if(localIndex < functionType.params().size())
{
// Copy the parameter value into the local that stores it.
irBuilder.CreateStore(&*llvmArgIt, localPointer);
++llvmArgIt;
}
else
{
// Initialize non-parameter locals to zero.
irBuilder.CreateStore(llvmContext.typedZeroConstants[(Uptr)localType], localPointer);
}
}
if(EMIT_ENTER_EXIT_HOOKS)
{
emitRuntimeIntrinsic(
"debugEnterFunction",
FunctionType({}, {ValueType::anyfunc}),
{llvm::ConstantExpr::getSub(
llvm::ConstantExpr::getPtrToInt(function, llvmContext.iptrType),
emitLiteral(llvmContext, Uptr(offsetof(Runtime::Function, code))))});
}
// Decode the WebAssembly opcodes and emit LLVM IR for them.
OperatorDecoderStream decoder(functionDef.code);
UnreachableOpVisitor unreachableOpVisitor(*this);
OperatorPrinter operatorPrinter(irModule, functionDef);
Uptr opIndex = 0;
while(decoder && controlStack.size())
{
irBuilder.SetCurrentDebugLocation(
llvm::DILocation::get(llvmContext, (unsigned int)opIndex++, 0, diFunction));
if(ENABLE_LOGGING) { logOperator(decoder.decodeOpWithoutConsume(operatorPrinter)); }
if(controlStack.back().isReachable) { decoder.decodeOp(*this); }
else
{
decoder.decodeOp(unreachableOpVisitor);
}
};
wavmAssert(irBuilder.GetInsertBlock() == returnBlock);
if(EMIT_ENTER_EXIT_HOOKS)
{
emitRuntimeIntrinsic(
"debugExitFunction",
FunctionType({}, {ValueType::anyfunc}),
{llvm::ConstantExpr::getSub(
llvm::ConstantExpr::getPtrToInt(function, llvmContext.iptrType),
emitLiteral(llvmContext, Uptr(offsetof(Runtime::Function, code))))});
}
// Emit the function return.
emitReturn(functionType.results(), stack);
// If a local escape block was created, add a localescape intrinsic to it with the accumulated
// local escape allocas, and insert it before the function's entry block.
if(localEscapeBlock)
{
irBuilder.SetInsertPoint(localEscapeBlock);
callLLVMIntrinsic({}, llvm::Intrinsic::localescape, pendingLocalEscapes);
irBuilder.CreateBr(&function->getEntryBlock());
localEscapeBlock->moveBefore(&function->getEntryBlock());
}
}
| 33.006849 | 100 | 0.733486 | PiotrSikora |
baf09f99e6e50bd9a1869e067dd782f0de68f36d | 17,240 | hpp | C++ | ld64-409.12/src/ld/parsers/generic_dylib_file.hpp | JunyiXie/ld64 | ffaa615b31ff1baa5d6249e4d9a6a21c2ae603ae | [
"Apache-2.0"
] | null | null | null | ld64-409.12/src/ld/parsers/generic_dylib_file.hpp | JunyiXie/ld64 | ffaa615b31ff1baa5d6249e4d9a6a21c2ae603ae | [
"Apache-2.0"
] | null | null | null | ld64-409.12/src/ld/parsers/generic_dylib_file.hpp | JunyiXie/ld64 | ffaa615b31ff1baa5d6249e4d9a6a21c2ae603ae | [
"Apache-2.0"
] | null | null | null | /* -*- mode: C++; c-basic-offset: 4; tab-width: 4 -*-
*
* Copyright (c) 2015 Apple Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this
* file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
#ifndef __GENERIC_DYLIB_FILE_H__
#define __GENERIC_DYLIB_FILE_H__
#include "ld.hpp"
#include "Options.h"
#include <unordered_map>
#include <unordered_set>
namespace generic {
namespace dylib {
// forward reference
template <typename A> class File;
//
// An ExportAtom has no content. It exists so that the linker can track which
// imported symbols came from which dynamic libraries.
//
template <typename A>
class ExportAtom final : public ld::Atom
{
public:
ExportAtom(const File<A>& f, const char* nm, bool weakDef, bool tlv,
typename A::P::uint_t address)
: ld::Atom(f._importProxySection, ld::Atom::definitionProxy,
(weakDef ? ld::Atom::combineByName : ld::Atom::combineNever),
ld::Atom::scopeLinkageUnit,
(tlv ? ld::Atom::typeTLV : ld::Atom::typeUnclassified),
symbolTableNotIn, false, false, false, ld::Atom::Alignment(0)),
_file(f),
_name(nm),
_address(address)
{}
// overrides of ld::Atom
virtual const ld::File* file() const override final { return &_file; }
virtual const char* name() const override final { return _name; }
virtual uint64_t size() const override final { return 0; }
virtual uint64_t objectAddress() const override final { return _address; }
virtual void copyRawContent(uint8_t buffer[]) const override final { }
virtual void setScope(Scope) { }
private:
using pint_t = typename A::P::uint_t;
virtual ~ExportAtom() {}
const File<A>& _file;
const char* _name;
pint_t _address;
};
//
// An ImportAtom has no content. It exists so that when linking a main executable flat-namespace
// the imports of all flat dylibs are checked
//
template <typename A>
class ImportAtom final : public ld::Atom
{
public:
ImportAtom(File<A>& f, std::vector<const char*>& imports);
// overrides of ld::Atom
virtual ld::File* file() const override final { return &_file; }
virtual const char* name() const override final { return "import-atom"; }
virtual uint64_t size() const override final { return 0; }
virtual uint64_t objectAddress() const override final { return 0; }
virtual ld::Fixup::iterator fixupsBegin() const override final { return &_undefs[0]; }
virtual ld::Fixup::iterator fixupsEnd() const override final { return &_undefs[_undefs.size()]; }
virtual void copyRawContent(uint8_t buffer[]) const override final { }
virtual void setScope(Scope) { }
private:
virtual ~ImportAtom() {}
File<A>& _file;
mutable std::vector<ld::Fixup> _undefs;
};
template <typename A>
ImportAtom<A>::ImportAtom(File<A>& f, std::vector<const char*>& imports)
: ld::Atom(f._flatDummySection, ld::Atom::definitionRegular, ld::Atom::combineNever,
ld::Atom::scopeTranslationUnit, ld::Atom::typeUnclassified, symbolTableNotIn, false,
false, false, ld::Atom::Alignment(0)),
_file(f)
{
for(auto *name : imports)
_undefs.emplace_back(0, ld::Fixup::k1of1, ld::Fixup::kindNone, false, strdup(name));
}
//
// A generic representation for the dynamic library files we support (Mach-O and text-based stubs).
// Common state and functionality is consolidated in this class.
//
template <typename A>
class File : public ld::dylib::File
{
public:
File(const char* path, time_t mTime, ld::File::Ordinal ordinal, const ld::VersionSet& platforms,
bool allowWeakImports, bool linkingFlatNamespace, bool hoistImplicitPublicDylibs,
bool allowSimToMacOSX, bool addVers);
// overrides of ld::File
virtual bool forEachAtom(ld::File::AtomHandler&) const override final;
virtual bool justInTimeforEachAtom(const char* name, ld::File::AtomHandler&) const override final;
virtual uint8_t swiftVersion() const override final { return _swiftVersion; }
virtual ld::Bitcode* getBitcode() const override final { return _bitcode.get(); }
// overrides of ld::dylib::File
virtual void processIndirectLibraries(ld::dylib::File::DylibHandler*, bool addImplicitDylibs) override;
virtual bool providedExportAtom() const override final { return _providedAtom; }
virtual const char* parentUmbrella() const override final { return _parentUmbrella; }
virtual const std::vector<const char*>* allowableClients() const override final { return _allowableClients.empty() ? nullptr : &_allowableClients; }
virtual const std::vector<const char*>& rpaths() const override final { return _rpaths; }
virtual bool hasWeakExternals() const override final { return _hasWeakExports; }
virtual bool deadStrippable() const override final { return _deadStrippable; }
virtual bool hasWeakDefinition(const char* name) const override final;
virtual bool hasPublicInstallName() const override final { return _hasPublicInstallName; }
virtual bool allSymbolsAreWeakImported() const override final;
virtual bool installPathVersionSpecific() const override final { return _installPathOverride; }
virtual bool appExtensionSafe() const override final { return _appExtensionSafe; };
bool wrongOS() const { return _wrongOS; }
private:
using pint_t = typename A::P::uint_t;
friend class ExportAtom<A>;
friend class ImportAtom<A>;
struct CStringHash {
std::size_t operator()(const char* __s) const {
unsigned long __h = 0;
for ( ; *__s; ++__s)
__h = 5 * __h + *__s;
return size_t(__h);
};
};
protected:
struct AtomAndWeak { ld::Atom* atom; bool weakDef; bool tlv; pint_t address; };
struct Dependent {
const char* path;
File<A>* dylib;
bool reExport;
Dependent(const char* path, bool reExport)
: path(path), dylib(nullptr), reExport(reExport) {}
};
struct ReExportChain { ReExportChain* prev; const File* file; };
private:
using NameToAtomMap = std::unordered_map<const char*, AtomAndWeak, ld::CStringHash, ld::CStringEquals>;
using NameSet = std::unordered_set<const char*, CStringHash, ld::CStringEquals>;
std::pair<bool, bool> hasWeakDefinitionImpl(const char* name) const;
bool containsOrReExports(const char* name, bool& weakDef, bool& tlv, pint_t& addr) const;
void assertNoReExportCycles(ReExportChain*) const;
protected:
bool isPublicLocation(const char* path) const;
private:
ld::Section _importProxySection;
ld::Section _flatDummySection;
mutable bool _providedAtom;
bool _indirectDylibsProcessed;
protected:
mutable NameToAtomMap _atoms;
NameSet _ignoreExports;
std::vector<Dependent> _dependentDylibs;
ImportAtom<A>* _importAtom;
std::vector<const char*> _allowableClients;
std::vector<const char*> _rpaths;
const char* _parentUmbrella;
std::unique_ptr<ld::Bitcode> _bitcode;
ld::VersionSet _platforms;
uint8_t _swiftVersion;
bool _wrongOS;
bool _linkingFlat;
bool _noRexports;
bool _explictReExportFound;
bool _implicitlyLinkPublicDylibs;
bool _installPathOverride;
bool _hasWeakExports;
bool _deadStrippable;
bool _hasPublicInstallName;
bool _appExtensionSafe;
const bool _allowWeakImports;
const bool _allowSimToMacOSXLinking;
const bool _addVersionLoadCommand;
static bool _s_logHashtable;
};
template <typename A>
bool File<A>::_s_logHashtable = false;
template <typename A>
File<A>::File(const char* path, time_t mTime, ld::File::Ordinal ord, const ld::VersionSet& platforms,
bool allowWeakImports, bool linkingFlatNamespace,
bool hoistImplicitPublicDylibs,
bool allowSimToMacOSX, bool addVers)
: ld::dylib::File(path, mTime, ord),
_importProxySection("__TEXT", "__import", ld::Section::typeImportProxies, true),
_flatDummySection("__LINKEDIT", "__flat_dummy", ld::Section::typeLinkEdit, true),
_providedAtom(false),
_indirectDylibsProcessed(false),
_importAtom(nullptr),
_parentUmbrella(nullptr),
_platforms(platforms),
_swiftVersion(0),
_wrongOS(false),
_linkingFlat(linkingFlatNamespace),
_noRexports(false),
_explictReExportFound(false),
_implicitlyLinkPublicDylibs(hoistImplicitPublicDylibs),
_installPathOverride(false),
_hasWeakExports(false),
_deadStrippable(false),
_hasPublicInstallName(false),
_appExtensionSafe(false),
_allowWeakImports(allowWeakImports),
_allowSimToMacOSXLinking(allowSimToMacOSX),
_addVersionLoadCommand(addVers)
{
}
template <typename A>
std::pair<bool, bool> File<A>::hasWeakDefinitionImpl(const char* name) const
{
const auto pos = _atoms.find(name);
if ( pos != this->_atoms.end() )
return std::make_pair(true, pos->second.weakDef);
// look in re-exported libraries.
for (const auto &dep : _dependentDylibs) {
if ( dep.reExport ) {
auto ret = dep.dylib->hasWeakDefinitionImpl(name);
if ( ret.first )
return ret;
}
}
return std::make_pair(false, false);
}
template <typename A>
bool File<A>::hasWeakDefinition(const char* name) const
{
// If we are supposed to ignore this export, then pretend we don't have it.
if ( _ignoreExports.count(name) != 0 )
return false;
return hasWeakDefinitionImpl(name).second;
}
template <typename A>
bool File<A>::containsOrReExports(const char* name, bool& weakDef, bool& tlv, pint_t& addr) const
{
if ( _ignoreExports.count(name) != 0 )
return false;
// check myself
const auto pos = _atoms.find(name);
if ( pos != _atoms.end() ) {
weakDef = pos->second.weakDef;
tlv = pos->second.tlv;
addr = pos->second.address;
return true;
}
// check dylibs I re-export
for (const auto& dep : _dependentDylibs) {
if ( dep.reExport && !dep.dylib->implicitlyLinked() ) {
if ( dep.dylib->containsOrReExports(name, weakDef, tlv, addr) )
return true;
}
}
return false;
}
template <typename A>
bool File<A>::forEachAtom(ld::File::AtomHandler& handler) const
{
handler.doFile(*this);
// if doing flatnamespace and need all this dylib's imports resolve
// add atom which references alls undefines in this dylib
if ( _importAtom != nullptr ) {
handler.doAtom(*_importAtom);
return true;
}
return false;
}
template <typename A>
bool File<A>::justInTimeforEachAtom(const char* name, ld::File::AtomHandler& handler) const
{
// If we are supposed to ignore this export, then pretend we don't have it.
if ( _ignoreExports.count(name) != 0 )
return false;
AtomAndWeak bucket;
if ( containsOrReExports(name, bucket.weakDef, bucket.tlv, bucket.address) ) {
bucket.atom = new ExportAtom<A>(*this, name, bucket.weakDef, bucket.tlv, bucket.address);
_atoms[name] = bucket;
_providedAtom = true;
if ( _s_logHashtable )
fprintf(stderr, "getJustInTimeAtomsFor: %s found in %s\n", name, this->path());
// call handler with new export atom
handler.doAtom(*bucket.atom);
return true;
}
return false;
}
template <typename A>
void File<A>::assertNoReExportCycles(ReExportChain* prev) const
{
// recursively check my re-exported dylibs
ReExportChain chain = { prev, this };
for (const auto &dep : _dependentDylibs) {
if ( dep.reExport ) {
auto* child = dep.dylib;
// check child is not already in chain
for (auto* p = prev; p != nullptr; p = p->prev) {
if ( p->file == child ) {
throwf("cycle in dylib re-exports with %s and %s", child->path(), this->path());
}
}
if ( dep.dylib != nullptr )
dep.dylib->assertNoReExportCycles(&chain);
}
}
}
template <typename A>
void File<A>::processIndirectLibraries(ld::dylib::File::DylibHandler* handler, bool addImplicitDylibs)
{
// only do this once
if ( _indirectDylibsProcessed )
return;
const static bool log = false;
if ( log )
fprintf(stderr, "processIndirectLibraries(%s)\n", this->installPath());
if ( _linkingFlat ) {
for (auto &dep : _dependentDylibs)
dep.dylib = (File<A>*)handler->findDylib(dep.path, this, false);
}
else if ( _noRexports ) {
// MH_NO_REEXPORTED_DYLIBS bit set, then nothing to do
}
else {
// two-level, might have re-exports
for (auto &dep : this->_dependentDylibs) {
if ( dep.reExport ) {
if ( log )
fprintf(stderr, "processIndirectLibraries() parent=%s, child=%s\n", this->installPath(), dep.path);
// a LC_REEXPORT_DYLIB, LC_SUB_UMBRELLA or LC_SUB_LIBRARY says we re-export this child
dep.dylib = (File<A>*)handler->findDylib(dep.path, this, this->speculativelyLoaded());
if ( dep.dylib->hasPublicInstallName() && !dep.dylib->wrongOS() ) {
// promote this child to be automatically added as a direct dependent if this already is
if ( (this->explicitlyLinked() || this->implicitlyLinked()) && (strcmp(dep.path, dep.dylib->installPath()) == 0) ) {
if ( log )
fprintf(stderr, "processIndirectLibraries() implicitly linking %s\n", dep.dylib->installPath());
dep.dylib->setImplicitlyLinked();
}
else if ( dep.dylib->explicitlyLinked() || dep.dylib->implicitlyLinked() ) {
if ( log )
fprintf(stderr, "processIndirectLibraries() parent is not directly linked, but child is, so no need to re-export child\n");
}
else {
if ( log )
fprintf(stderr, "processIndirectLibraries() parent is not directly linked, so parent=%s will re-export child=%s\n", this->installPath(), dep.path);
}
}
else {
// add all child's symbols to me
if ( log )
fprintf(stderr, "processIndirectLibraries() child is not public, so parent=%s will re-export child=%s\n", this->installPath(), dep.path);
}
}
else if ( !_explictReExportFound ) {
// see if child contains LC_SUB_FRAMEWORK with my name
dep.dylib = (File<A>*)handler->findDylib(dep.path, this, this->speculativelyLoaded());
const char* parentUmbrellaName = dep.dylib->parentUmbrella();
if ( parentUmbrellaName != nullptr ) {
const char* parentName = this->path();
const char* lastSlash = strrchr(parentName, '/');
if ( (lastSlash != nullptr) && (strcmp(&lastSlash[1], parentUmbrellaName) == 0) ) {
// add all child's symbols to me
dep.reExport = true;
if ( log )
fprintf(stderr, "processIndirectLibraries() umbrella=%s will re-export child=%s\n", this->installPath(), dep.path);
}
}
}
}
}
// check for re-export cycles
ReExportChain chain = { nullptr, this };
this->assertNoReExportCycles(&chain);
_indirectDylibsProcessed = true;
}
template <typename A>
bool File<A>::isPublicLocation(const char* path) const
{
// -no_implicit_dylibs disables this optimization
if ( ! _implicitlyLinkPublicDylibs )
return false;
// /usr/lib is a public location
if ( (strncmp(path, "/usr/lib/", 9) == 0) && (strchr(&path[9], '/') == nullptr) )
return true;
// /System/Library/Frameworks/ is a public location
if ( strncmp(path, "/System/Library/Frameworks/", 27) == 0 ) {
const char* frameworkDot = strchr(&path[27], '.');
// but only top level framework
// /System/Library/Frameworks/Foo.framework/Versions/A/Foo ==> true
// /System/Library/Frameworks/Foo.framework/Resources/libBar.dylib ==> false
// /System/Library/Frameworks/Foo.framework/Frameworks/Bar.framework/Bar ==> false
// /System/Library/Frameworks/Foo.framework/Frameworks/Xfoo.framework/XFoo ==> false
if ( frameworkDot != nullptr ) {
int frameworkNameLen = frameworkDot - &path[27];
if ( strncmp(&path[strlen(path)-frameworkNameLen-1], &path[26], frameworkNameLen+1) == 0 )
return true;
}
}
return false;
}
// <rdar://problem/5529626> If only weak_import symbols are used, linker should use LD_LOAD_WEAK_DYLIB
template <typename A>
bool File<A>::allSymbolsAreWeakImported() const
{
bool foundNonWeakImport = false;
bool foundWeakImport = false;
//fprintf(stderr, "%s:\n", this->path());
for (const auto &it : _atoms) {
auto* atom = it.second.atom;
if ( atom != nullptr ) {
if ( atom->weakImported() )
foundWeakImport = true;
else
foundNonWeakImport = true;
//fprintf(stderr, " weak_import=%d, name=%s\n", atom->weakImported(), it->first);
}
}
// don't automatically weak link dylib with no imports
// so at least one weak import symbol and no non-weak-imported symbols must be found
return foundWeakImport && !foundNonWeakImport;
}
} // end namespace dylib
} // end namespace generic
#endif // __GENERIC_DYLIB_FILE_H__
| 34.549098 | 154 | 0.697796 | JunyiXie |
baf114b85d6487359c785c1b5b16238b52255f0d | 23,596 | cpp | C++ | lgc/patch/SystemValues.cpp | yjaelex/llpc | 9cdcc2a8494396b10794b6557a5a5a4bded13029 | [
"MIT"
] | null | null | null | lgc/patch/SystemValues.cpp | yjaelex/llpc | 9cdcc2a8494396b10794b6557a5a5a4bded13029 | [
"MIT"
] | null | null | null | lgc/patch/SystemValues.cpp | yjaelex/llpc | 9cdcc2a8494396b10794b6557a5a5a4bded13029 | [
"MIT"
] | null | null | null | /*
***********************************************************************************************************************
*
* Copyright (c) 2018-2020 Advanced Micro Devices, Inc. All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
**********************************************************************************************************************/
/**
***********************************************************************************************************************
* @file SystemValues.cpp
* @brief LLPC source file: per-shader per-pass generating and cache of shader system pointers
***********************************************************************************************************************
*/
#include "SystemValues.h"
#include "lgc/state/PipelineState.h"
#include "lgc/state/TargetInfo.h"
#include "llvm/IR/Constants.h"
#include "llvm/IR/Instructions.h"
#define DEBUG_TYPE "lgc-system-values"
using namespace lgc;
using namespace llvm;
// =====================================================================================================================
// Initialize this ShaderSystemValues if it was previously uninitialized.
//
// @param pipelineState : Pipeline state
// @param entryPoint : Shader entrypoint
void ShaderSystemValues::initialize(PipelineState *pipelineState, Function *entryPoint) {
if (!m_entryPoint) {
m_entryPoint = entryPoint;
m_shaderStage = getShaderStage(entryPoint);
m_context = &entryPoint->getParent()->getContext();
m_pipelineState = pipelineState;
assert(m_shaderStage != ShaderStageInvalid);
assert(m_pipelineState->getShaderInterfaceData(m_shaderStage)->entryArgIdxs.initialized);
}
}
// =====================================================================================================================
// Get ES-GS ring buffer descriptor (for VS/TES output or GS input)
Value *ShaderSystemValues::getEsGsRingBufDesc() {
if (!m_esGsRingBufDesc) {
unsigned tableOffset = 0;
switch (m_shaderStage) {
case ShaderStageVertex:
case ShaderStageTessEval:
tableOffset = SiDrvTableEsRingOutOffs;
break;
case ShaderStageGeometry:
tableOffset = SiDrvTableGsRingInOffs;
break;
default:
llvm_unreachable("Should never be called!");
break;
}
// Ensure we have got the global table pointer first, and insert new code after that.
BuilderBase builder(getInternalGlobalTablePtr()->getNextNode());
m_esGsRingBufDesc = loadDescFromDriverTable(tableOffset, builder);
if (m_shaderStage != ShaderStageGeometry && m_pipelineState->getTargetInfo().getGfxIpVersion().major >= 8) {
// NOTE: For GFX8+, we have to explicitly set DATA_FORMAT for GS-VS ring buffer descriptor for
// VS/TES output.
m_esGsRingBufDesc = setRingBufferDataFormat(m_esGsRingBufDesc, BUF_DATA_FORMAT_32, builder);
}
}
return m_esGsRingBufDesc;
}
// =====================================================================================================================
// Get the descriptor for tessellation factor (TF) buffer (TCS output)
Value *ShaderSystemValues::getTessFactorBufDesc() {
assert(m_shaderStage == ShaderStageTessControl);
if (!m_tfBufDesc) {
// Ensure we have got the global table pointer first, and insert new code after that.
BuilderBase builder(getInternalGlobalTablePtr()->getNextNode());
m_tfBufDesc = loadDescFromDriverTable(SiDrvTableTfBufferOffs, builder);
}
return m_tfBufDesc;
}
// =====================================================================================================================
// Extract value of primitive ID (TCS)
Value *ShaderSystemValues::getPrimitiveId() {
assert(m_shaderStage == ShaderStageTessControl);
if (!m_primitiveId) {
auto intfData = m_pipelineState->getShaderInterfaceData(m_shaderStage);
m_primitiveId = getFunctionArgument(m_entryPoint, intfData->entryArgIdxs.tcs.patchId, "patchId");
}
return m_primitiveId;
}
// =====================================================================================================================
// Get invocation ID (TCS)
Value *ShaderSystemValues::getInvocationId() {
assert(m_shaderStage == ShaderStageTessControl);
if (!m_invocationId) {
auto insertPos = &*m_entryPoint->front().getFirstInsertionPt();
auto intfData = m_pipelineState->getShaderInterfaceData(m_shaderStage);
// invocationId = relPatchId[12:8]
Value *args[] = {getFunctionArgument(m_entryPoint, intfData->entryArgIdxs.tcs.relPatchId, "relPatchId"),
ConstantInt::get(Type::getInt32Ty(*m_context), 8),
ConstantInt::get(Type::getInt32Ty(*m_context), 5)};
m_invocationId =
emitCall("llvm.amdgcn.ubfe.i32", Type::getInt32Ty(*m_context), args, Attribute::ReadNone, insertPos);
}
return m_invocationId;
}
// =====================================================================================================================
// Get relative patchId (TCS)
Value *ShaderSystemValues::getRelativeId() {
assert(m_shaderStage == ShaderStageTessControl);
if (!m_relativeId) {
auto insertPos = &*m_entryPoint->front().getFirstInsertionPt();
auto intfData = m_pipelineState->getShaderInterfaceData(m_shaderStage);
auto relPatchId = getFunctionArgument(m_entryPoint, intfData->entryArgIdxs.tcs.relPatchId, "relPatchId");
// relativeId = relPatchId[7:0]
m_relativeId =
BinaryOperator::CreateAnd(relPatchId, ConstantInt::get(Type::getInt32Ty(*m_context), 0xFF), "", insertPos);
}
return m_relativeId;
}
// =====================================================================================================================
// Get offchip LDS descriptor (TCS and TES)
Value *ShaderSystemValues::getOffChipLdsDesc() {
assert(m_shaderStage == ShaderStageTessControl || m_shaderStage == ShaderStageTessEval);
if (!m_offChipLdsDesc) {
// Ensure we have got the global table pointer first, and insert new code after that.
BuilderBase builder(getInternalGlobalTablePtr()->getNextNode());
m_offChipLdsDesc = loadDescFromDriverTable(SiDrvTableHsBuffeR0Offs, builder);
}
return m_offChipLdsDesc;
}
// =====================================================================================================================
// Get tessellated coordinate (TES)
Value *ShaderSystemValues::getTessCoord() {
assert(m_shaderStage == ShaderStageTessEval);
if (!m_tessCoord) {
auto insertPos = &*m_entryPoint->front().getFirstInsertionPt();
auto intfData = m_pipelineState->getShaderInterfaceData(m_shaderStage);
Value *tessCoordX = getFunctionArgument(m_entryPoint, intfData->entryArgIdxs.tes.tessCoordX, "tessCoordX");
Value *tessCoordY = getFunctionArgument(m_entryPoint, intfData->entryArgIdxs.tes.tessCoordY, "tessCoordY");
Value *tessCoordZ = BinaryOperator::CreateFAdd(tessCoordX, tessCoordY, "", insertPos);
tessCoordZ =
BinaryOperator::CreateFSub(ConstantFP::get(Type::getFloatTy(*m_context), 1.0f), tessCoordZ, "", insertPos);
auto primitiveMode = m_pipelineState->getShaderModes()->getTessellationMode().primitiveMode;
tessCoordZ =
primitiveMode == PrimitiveMode::Triangles ? tessCoordZ : ConstantFP::get(Type::getFloatTy(*m_context), 0.0f);
m_tessCoord = UndefValue::get(FixedVectorType::get(Type::getFloatTy(*m_context), 3));
m_tessCoord = InsertElementInst::Create(m_tessCoord, tessCoordX, ConstantInt::get(Type::getInt32Ty(*m_context), 0),
"", insertPos);
m_tessCoord = InsertElementInst::Create(m_tessCoord, tessCoordY, ConstantInt::get(Type::getInt32Ty(*m_context), 1),
"", insertPos);
m_tessCoord = InsertElementInst::Create(m_tessCoord, tessCoordZ, ConstantInt::get(Type::getInt32Ty(*m_context), 2),
"", insertPos);
}
return m_tessCoord;
}
// =====================================================================================================================
// Get ES -> GS offsets (GS in)
Value *ShaderSystemValues::getEsGsOffsets() {
assert(m_shaderStage == ShaderStageGeometry);
if (!m_esGsOffsets) {
auto insertPos = &*m_entryPoint->front().getFirstInsertionPt();
auto intfData = m_pipelineState->getShaderInterfaceData(m_shaderStage);
m_esGsOffsets = UndefValue::get(FixedVectorType::get(Type::getInt32Ty(*m_context), 6));
for (unsigned i = 0; i < InterfaceData::MaxEsGsOffsetCount; ++i) {
auto esGsOffset =
getFunctionArgument(m_entryPoint, intfData->entryArgIdxs.gs.esGsOffsets[i], Twine("esGsOffset") + Twine(i));
m_esGsOffsets = InsertElementInst::Create(m_esGsOffsets, esGsOffset,
ConstantInt::get(Type::getInt32Ty(*m_context), i), "", insertPos);
}
}
return m_esGsOffsets;
}
// =====================================================================================================================
// Get GS -> VS ring buffer descriptor (GS out and copy shader in)
//
// @param streamId : Stream ID, always 0 for copy shader
Value *ShaderSystemValues::getGsVsRingBufDesc(unsigned streamId) {
assert(m_shaderStage == ShaderStageGeometry || m_shaderStage == ShaderStageCopyShader);
if (m_gsVsRingBufDescs.size() <= streamId)
m_gsVsRingBufDescs.resize(streamId + 1);
if (!m_gsVsRingBufDescs[streamId]) {
// Ensure we have got the global table pointer first, and insert new code after that.
BuilderBase builder(getInternalGlobalTablePtr()->getNextNode());
if (m_shaderStage == ShaderStageGeometry) {
const auto resUsage = m_pipelineState->getShaderResourceUsage(m_shaderStage);
// Geometry shader, using GS-VS ring for output.
Value *desc = loadDescFromDriverTable(SiDrvTableGsRingOuT0Offs + streamId, builder);
unsigned outLocStart = 0;
for (int i = 0; i < streamId; ++i)
outLocStart += resUsage->inOutUsage.gs.outLocCount[i];
// streamSize[streamId] = outLocCount[streamId] * 4 * sizeof(unsigned)
// streamOffset = (streamSize[0] + ... + streamSize[streamId - 1]) * 64 * outputVertices
unsigned baseAddr = outLocStart * m_pipelineState->getShaderModes()->getGeometryShaderMode().outputVertices *
sizeof(unsigned) * 4 * 64;
// Patch GS-VS ring buffer descriptor base address for GS output
Value *gsVsOutRingBufDescElem0 = builder.CreateExtractElement(desc, (uint64_t)0);
gsVsOutRingBufDescElem0 = builder.CreateAdd(gsVsOutRingBufDescElem0, builder.getInt32(baseAddr));
desc = builder.CreateInsertElement(desc, gsVsOutRingBufDescElem0, (uint64_t)0);
// Patch GS-VS ring buffer descriptor stride for GS output
Value *gsVsRingBufDescElem1 = builder.CreateExtractElement(desc, (uint64_t)1);
// Clear stride in SRD dword1
SqBufRsrcWord1 strideClearMask = {};
strideClearMask.u32All = UINT32_MAX;
strideClearMask.bits.stride = 0;
gsVsRingBufDescElem1 = builder.CreateAnd(gsVsRingBufDescElem1, builder.getInt32(strideClearMask.u32All));
// Calculate and set stride in SRD dword1
unsigned gsVsStride = m_pipelineState->getShaderModes()->getGeometryShaderMode().outputVertices *
resUsage->inOutUsage.gs.outLocCount[streamId] * sizeof(unsigned) * 4;
SqBufRsrcWord1 strideSetValue = {};
strideSetValue.bits.stride = gsVsStride;
gsVsRingBufDescElem1 = builder.CreateOr(gsVsRingBufDescElem1, builder.getInt32(strideSetValue.u32All));
desc = builder.CreateInsertElement(desc, gsVsRingBufDescElem1, (uint64_t)1);
if (m_pipelineState->getTargetInfo().getGfxIpVersion().major >= 8) {
// NOTE: For GFX8+, we have to explicitly set DATA_FORMAT for GS-VS ring buffer descriptor.
desc = setRingBufferDataFormat(desc, BUF_DATA_FORMAT_32, builder);
}
m_gsVsRingBufDescs[streamId] = desc;
} else {
// Copy shader, using GS-VS ring for input.
assert(streamId == 0);
m_gsVsRingBufDescs[streamId] = loadDescFromDriverTable(SiDrvTableVsRingInOffs, builder);
}
}
return m_gsVsRingBufDescs[streamId];
}
// =====================================================================================================================
// Get pointers to emit counters (GS)
ArrayRef<Value *> ShaderSystemValues::getEmitCounterPtr() {
assert(m_shaderStage == ShaderStageGeometry);
if (m_emitCounterPtrs.empty()) {
// TODO: We should only insert those offsets required by the specified input primitive.
// Setup GS emit vertex counter
auto &dataLayout = m_entryPoint->getParent()->getDataLayout();
auto insertPos = &*m_entryPoint->front().getFirstInsertionPt();
for (int i = 0; i < MaxGsStreams; ++i) {
auto emitCounterPtr =
new AllocaInst(Type::getInt32Ty(*m_context), dataLayout.getAllocaAddrSpace(), "", insertPos);
new StoreInst(ConstantInt::get(Type::getInt32Ty(*m_context), 0), emitCounterPtr, insertPos);
m_emitCounterPtrs.push_back(emitCounterPtr);
}
}
return m_emitCounterPtrs;
}
// =====================================================================================================================
// Get internal global table pointer as pointer to i8.
Instruction *ShaderSystemValues::getInternalGlobalTablePtr() {
if (!m_internalGlobalTablePtr) {
auto ptrTy = Type::getInt8Ty(*m_context)->getPointerTo(ADDR_SPACE_CONST);
// Global table is always the first function argument
m_internalGlobalTablePtr = makePointer(getFunctionArgument(m_entryPoint, 0, "globalTable"), ptrTy, InvalidValue);
}
return m_internalGlobalTablePtr;
}
// =====================================================================================================================
// Get internal per shader table pointer as pointer to i8.
Value *ShaderSystemValues::getInternalPerShaderTablePtr() {
if (!m_internalPerShaderTablePtr) {
auto ptrTy = Type::getInt8Ty(*m_context)->getPointerTo(ADDR_SPACE_CONST);
// Per shader table is always the second function argument
m_internalPerShaderTablePtr =
makePointer(getFunctionArgument(m_entryPoint, 1, "perShaderTable"), ptrTy, InvalidValue);
}
return m_internalPerShaderTablePtr;
}
// =====================================================================================================================
// Get stream-out buffer descriptor
//
// @param xfbBuffer : Transform feedback buffer ID
Value *ShaderSystemValues::getStreamOutBufDesc(unsigned xfbBuffer) {
if (m_streamOutBufDescs.size() <= xfbBuffer)
m_streamOutBufDescs.resize(xfbBuffer + 1);
if (!m_streamOutBufDescs[xfbBuffer]) {
auto streamOutTablePtr = getStreamOutTablePtr();
auto insertPos = streamOutTablePtr->getNextNode();
Value *idxs[] = {ConstantInt::get(Type::getInt64Ty(*m_context), 0),
ConstantInt::get(Type::getInt64Ty(*m_context), xfbBuffer)};
auto streamOutBufDescPtr = GetElementPtrInst::Create(nullptr, streamOutTablePtr, idxs, "", insertPos);
streamOutBufDescPtr->setMetadata(MetaNameUniform, MDNode::get(streamOutBufDescPtr->getContext(), {}));
auto streamOutBufDescTy = streamOutBufDescPtr->getType()->getPointerElementType();
auto streamOutBufDesc = new LoadInst(streamOutBufDescTy, streamOutBufDescPtr, "", false, Align(16), insertPos);
streamOutBufDesc->setMetadata(LLVMContext::MD_invariant_load, MDNode::get(streamOutBufDesc->getContext(), {}));
m_streamOutBufDescs[xfbBuffer] = streamOutBufDesc;
}
return m_streamOutBufDescs[xfbBuffer];
}
// =====================================================================================================================
// Get stream-out buffer table pointer
Instruction *ShaderSystemValues::getStreamOutTablePtr() {
assert(m_shaderStage == ShaderStageVertex || m_shaderStage == ShaderStageTessEval ||
m_shaderStage == ShaderStageCopyShader);
if (!m_streamOutTablePtr) {
auto intfData = m_pipelineState->getShaderInterfaceData(m_shaderStage);
unsigned entryArgIdx = 0;
// Get the SGPR number of the stream-out table pointer.
switch (m_shaderStage) {
case ShaderStageVertex:
entryArgIdx = intfData->entryArgIdxs.vs.streamOutData.tablePtr;
break;
case ShaderStageTessEval:
entryArgIdx = intfData->entryArgIdxs.tes.streamOutData.tablePtr;
break;
case ShaderStageCopyShader:
entryArgIdx = intfData->userDataUsage.gs.copyShaderStreamOutTable;
break;
default:
llvm_unreachable("Should never be called!");
break;
}
assert(entryArgIdx != 0);
// Get the 64-bit extended node value.
auto streamOutTablePtrLow = getFunctionArgument(m_entryPoint, entryArgIdx, "streamOutTable");
auto streamOutTablePtrTy = PointerType::get(
ArrayType::get(FixedVectorType::get(Type::getInt32Ty(*m_context), 4), MaxTransformFeedbackBuffers),
ADDR_SPACE_CONST);
m_streamOutTablePtr = makePointer(streamOutTablePtrLow, streamOutTablePtrTy, InvalidValue);
}
return m_streamOutTablePtr;
}
// =====================================================================================================================
// Make 64-bit pointer of specified type from 32-bit int, extending with the specified value, or PC if InvalidValue
//
// @param lowValue : 32-bit int value to extend
// @param ptrTy : Type that result pointer needs to be
// @param highValue : Value to use for high part, or InvalidValue to use PC
Instruction *ShaderSystemValues::makePointer(Value *lowValue, Type *ptrTy, unsigned highValue) {
// Insert extending code after pLowValue if it is an instruction.
Instruction *insertPos = nullptr;
auto lowValueInst = dyn_cast<Instruction>(lowValue);
if (lowValueInst)
insertPos = lowValueInst->getNextNode();
else
insertPos = &*m_entryPoint->front().getFirstInsertionPt();
Value *extendedPtrValue = nullptr;
if (highValue == InvalidValue) {
// Use PC.
if (!m_pc || isa<Instruction>(lowValue)) {
// Either
// 1. there is no existing code to s_getpc and cast it, or
// 2. there is existing code, but pLowValue is an instruction, so it is more complex to figure
// out whether it is before or after pLowValue in the code. We generate new s_getpc code anyway
// and rely on subsequent CSE to common it up.
// Insert the s_getpc code at the start of the function, so a later call into here knows it can
// reuse this PC if its pLowValue is an arg rather than an instruction.
auto pcInsertPos = &*m_entryPoint->front().getFirstInsertionPt();
Value *pc = emitCall("llvm.amdgcn.s.getpc", Type::getInt64Ty(*m_context), ArrayRef<Value *>(), {}, pcInsertPos);
m_pc = new BitCastInst(pc, FixedVectorType::get(Type::getInt32Ty(*m_context), 2), "", insertPos);
} else
insertPos = m_pc->getNextNode();
extendedPtrValue = m_pc;
} else {
// Use constant highValue value.
Constant *elements[] = {UndefValue::get(lowValue->getType()), ConstantInt::get(lowValue->getType(), highValue)};
extendedPtrValue = ConstantVector::get(elements);
}
extendedPtrValue = InsertElementInst::Create(extendedPtrValue, lowValue,
ConstantInt::get(Type::getInt32Ty(*m_context), 0), "", insertPos);
extendedPtrValue =
CastInst::Create(Instruction::BitCast, extendedPtrValue, Type::getInt64Ty(*m_context), "", insertPos);
return CastInst::Create(Instruction::IntToPtr, extendedPtrValue, ptrTy, "", insertPos);
}
// =====================================================================================================================
// Load descriptor from driver table.
// If the caller sets builder's insert point to the start of the function, it should ensure that it first calls
// getInternalGlobalTablePtr(). Otherwise there is a danger that code is inserted in the wrong order, giving
// invalid IR.
//
// @param tableOffset : Byte offset in driver table
// @param builder : Builder to use for insertion
Instruction *ShaderSystemValues::loadDescFromDriverTable(unsigned tableOffset, BuilderBase &builder) {
auto globalTable = getInternalGlobalTablePtr();
Type *descTy = FixedVectorType::get(builder.getInt32Ty(), 4);
globalTable = cast<Instruction>(builder.CreateBitCast(globalTable, descTy->getPointerTo(ADDR_SPACE_CONST)));
Value *descPtr = builder.CreateGEP(descTy, globalTable, builder.getInt32(tableOffset));
LoadInst *desc = builder.CreateLoad(descTy, descPtr);
return desc;
}
// =====================================================================================================================
// Explicitly set the DATA_FORMAT of ring buffer descriptor.
//
// @param bufDesc : Buffer Descriptor
// @param dataFormat : Data format
// @param builder : Builder to use for inserting instructions
Value *ShaderSystemValues::setRingBufferDataFormat(Value *bufDesc, unsigned dataFormat, BuilderBase &builder) const {
Value *elem3 = builder.CreateExtractElement(bufDesc, (uint64_t)3);
SqBufRsrcWord3 dataFormatClearMask;
dataFormatClearMask.u32All = UINT32_MAX;
// TODO: This code needs to be fixed for gfx10; buffer format is handled differently.
dataFormatClearMask.gfx6.dataFormat = 0;
elem3 = builder.CreateAnd(elem3, builder.getInt32(dataFormatClearMask.u32All));
SqBufRsrcWord3 dataFormatSetValue = {};
dataFormatSetValue.gfx6.dataFormat = dataFormat;
elem3 = builder.CreateOr(elem3, builder.getInt32(dataFormatSetValue.u32All));
return builder.CreateInsertElement(bufDesc, elem3, (uint64_t)3);
}
// =====================================================================================================================
// Find resource node by descriptor set ID
//
// @param descSet : Descriptor set to find
unsigned ShaderSystemValues::findResourceNodeByDescSet(unsigned descSet) {
auto userDataNodes = m_pipelineState->getUserDataNodes();
for (unsigned i = 0; i < userDataNodes.size(); ++i) {
auto node = &userDataNodes[i];
if (node->type == ResourceNodeType::DescriptorTableVaPtr && node->innerTable[0].set == descSet)
return i;
}
return InvalidValue;
}
// =====================================================================================================================
// Test if shadow descriptor table is enabled
bool ShaderSystemValues::isShadowDescTableEnabled() const {
return m_pipelineState->getOptions().shadowDescriptorTable != ShadowDescriptorTableDisable;
}
| 48.954357 | 120 | 0.638201 | yjaelex |
baf152b3b1e5e183e9ec41271d3a9037faf84ed2 | 8,180 | hpp | C++ | src/storage_manager/http.hpp | publiqnet/publiq.pp | 0865494edaa22ea2e3238aaf01cdb9e457535933 | [
"MIT"
] | 4 | 2019-11-20T17:27:57.000Z | 2021-01-05T09:46:20.000Z | src/storage_manager/http.hpp | publiqnet/publiq.pp | 0865494edaa22ea2e3238aaf01cdb9e457535933 | [
"MIT"
] | null | null | null | src/storage_manager/http.hpp | publiqnet/publiq.pp | 0865494edaa22ea2e3238aaf01cdb9e457535933 | [
"MIT"
] | 2 | 2019-01-10T14:10:26.000Z | 2020-03-01T05:55:05.000Z | #pragma once
#include "storage_manager_message.hpp"
#include <belt.pp/global.hpp>
#include <belt.pp/parser.hpp>
#include <belt.pp/http.hpp>
#include <string>
#include <vector>
#include <utility>
#include <unordered_map>
#include <set>
using std::string;
using std::vector;
using std::pair;
using std::unordered_map;
namespace storage_manager
{
namespace http
{
string check_arguments(unordered_map<string, string>& arguments,
std::set<string> const& all_arguments,
std::set<string> const& ui64_arguments)
{
for (auto const& it : arguments)
if (it.second.empty() ||
all_arguments.find(it.first) == all_arguments.end())
return "invalid argument: " + it.first;
size_t pos;
for (auto const& it : ui64_arguments)
if (arguments.find(it) != arguments.end())
{
beltpp::stoui64(arguments[it], pos);
if (arguments[it].size() != pos)
return "invalid argument: " + it + " " + arguments[it];
}
return string();
}
beltpp::detail::pmsg_all request_failed(string const& message)
{
auto p = ::beltpp::new_void_unique_ptr<ManagerMessage::Failed>();
ManagerMessage::Failed & ref = *reinterpret_cast<ManagerMessage::Failed*>(p.get());
ref.message = message;
return ::beltpp::detail::pmsg_all(ManagerMessage::Failed::rtt,
std::move(p),
&ManagerMessage::Failed::pvoid_saver);
}
inline
string response(beltpp::detail::session_special_data& ssd,
beltpp::packet const& pc)
{
if (pc.type() == ManagerMessage::Failed::rtt)
return beltpp::http::http_not_found(ssd, pc.to_string());
else
return beltpp::http::http_response(ssd, pc.to_string());
}
template <beltpp::detail::pmsg_all (*fallback_message_list_load)(
std::string::const_iterator&,
std::string::const_iterator const&,
beltpp::detail::session_special_data&,
void*)>
beltpp::detail::pmsg_all message_list_load(
std::string::const_iterator& iter_scan_begin,
std::string::const_iterator const& iter_scan_end,
beltpp::detail::session_special_data& ssd,
void* putl)
{
auto it_fallback = iter_scan_begin;
ssd.session_specal_handler = nullptr;
ssd.autoreply.clear();
auto protocol_error = [&iter_scan_begin, &iter_scan_end, &ssd]()
{
ssd.session_specal_handler = nullptr;
ssd.autoreply.clear();
iter_scan_begin = iter_scan_end;
return ::beltpp::detail::pmsg_all(size_t(-2),
::beltpp::void_unique_nullptr(),
nullptr);
};
string posted;
auto result = beltpp::http::protocol(ssd,
iter_scan_begin,
iter_scan_end,
it_fallback,
10 * 1024, // enough length
64 * 1024, // header max size
10 * 1024 * 1024, // content max size
posted);
auto code = result.first;
auto& ss = result.second;
if (code == beltpp::e_three_state_result::error &&
ss.status == beltpp::http::detail::scan_status::clean)
{
return fallback_message_list_load(iter_scan_begin, iter_scan_end, ssd, putl);
}
else if (code == beltpp::e_three_state_result::error)
return protocol_error();
else if (code == beltpp::e_three_state_result::attempt)
{
iter_scan_begin = it_fallback;
return ::beltpp::detail::pmsg_all(size_t(-1),
::beltpp::void_unique_nullptr(),
nullptr);
}
else// if (code == beltpp::e_three_state_result::success)
{
ssd.session_specal_handler = &response;
ssd.autoreply.clear();
if (ss.type == beltpp::http::detail::scan_status::get &&
ss.resource.path.size() == 2 &&
ss.resource.path.front() == "import")
{
auto p = ::beltpp::new_void_unique_ptr<ManagerMessage::ImportStorageRequest>();
ManagerMessage::ImportStorageRequest& ref = *reinterpret_cast<ManagerMessage::ImportStorageRequest*>(p.get());
ref.address = ss.resource.path.back();
return ::beltpp::detail::pmsg_all(ManagerMessage::ImportStorageRequest::rtt,
std::move(p),
&ManagerMessage::ImportStorageRequest::pvoid_saver);
}
if (ss.type == beltpp::http::detail::scan_status::get &&
ss.resource.path.size() == 2 &&
ss.resource.path.front() == "clear")
{
auto p = ::beltpp::new_void_unique_ptr<ManagerMessage::ClearStorageRequest>();
ManagerMessage::ClearStorageRequest& ref = *reinterpret_cast<ManagerMessage::ClearStorageRequest*>(p.get());
ref.address = ss.resource.path.back();
return ::beltpp::detail::pmsg_all(ManagerMessage::ClearStorageRequest::rtt,
std::move(p),
&ManagerMessage::ClearStorageRequest::pvoid_saver);
}
else if (ss.type == beltpp::http::detail::scan_status::get &&
ss.resource.path.size() == 1 &&
ss.resource.path.front() == "head_block")
{
auto p = ::beltpp::new_void_unique_ptr<ManagerMessage::HeadBlockRequest>();
return ::beltpp::detail::pmsg_all(ManagerMessage::HeadBlockRequest::rtt,
std::move(p),
&ManagerMessage::HeadBlockRequest::pvoid_saver);
}
else if (ss.type == beltpp::http::detail::scan_status::get &&
ss.resource.path.size() == 1 &&
ss.resource.path.front() == "storages")
{
auto p = ::beltpp::new_void_unique_ptr<ManagerMessage::StoragesRequest>();
return ::beltpp::detail::pmsg_all(ManagerMessage::StoragesRequest::rtt,
std::move(p),
&ManagerMessage::StoragesRequest::pvoid_saver);
}
else if (ss.type == beltpp::http::detail::scan_status::get &&
ss.resource.path.size() == 1 &&
ss.resource.path.front() == "protocol")
{
ssd.session_specal_handler = nullptr;
ssd.autoreply = beltpp::http::http_response(ssd, ManagerMessage::detail::meta_json_schema());
return ::beltpp::detail::pmsg_all(size_t(-1),
::beltpp::void_unique_nullptr(),
nullptr);
}
else
{
ssd.session_specal_handler = nullptr;
string message("noo! \r\n");
for (auto const& dir : ss.resource.path)
message += "/" + dir;
message += "\r\n";
for (auto const& arg : ss.resource.arguments)
message += (arg.first + ": " + arg.second + "\r\n");
message += "\r\n";
message += "\r\n";
for (auto const& prop : ss.resource.properties)
message += (prop.first + ": " + prop.second + "\r\n");
message += "that's an error! \r\n";
message += "here's the protocol, by the way \r\n";
ssd.autoreply = beltpp::http::http_not_found(ssd,
message +
ManagerMessage::detail::meta_json_schema());
return ::beltpp::detail::pmsg_all(size_t(-1),
::beltpp::void_unique_nullptr(),
nullptr);
}
}
}
}
}
| 39.326923 | 122 | 0.52335 | publiqnet |
baf546b2a628f8a072563078937e6d0832273155 | 1,609 | cpp | C++ | dynamic/wrappers/cell_based/ChemotacticForce2.cppwg.cpp | jmsgrogan/PyChaste | 48a9863d2c941c71e47ecb72e917b477ba5c1413 | [
"FTL"
] | 6 | 2017-02-04T16:10:53.000Z | 2021-07-01T08:03:16.000Z | dynamic/wrappers/cell_based/ChemotacticForce2.cppwg.cpp | jmsgrogan/PyChaste | 48a9863d2c941c71e47ecb72e917b477ba5c1413 | [
"FTL"
] | 6 | 2017-06-22T08:50:41.000Z | 2019-12-15T20:17:29.000Z | dynamic/wrappers/cell_based/ChemotacticForce2.cppwg.cpp | jmsgrogan/PyChaste | 48a9863d2c941c71e47ecb72e917b477ba5c1413 | [
"FTL"
] | 3 | 2017-05-15T21:33:58.000Z | 2019-10-27T21:43:07.000Z | #include <pybind11/pybind11.h>
#include <pybind11/stl.h>
#include <set>
#include <vector>
#include <string>
#include <map>
#include "SmartPointers.hpp"
#include "UblasIncludes.hpp"
#include "ChemotacticForce.hpp"
#include "ChemotacticForce2.cppwg.hpp"
namespace py = pybind11;
typedef ChemotacticForce<2 > ChemotacticForce2;
PYBIND11_DECLARE_HOLDER_TYPE(T, boost::shared_ptr<T>);
class ChemotacticForce2_Overloads : public ChemotacticForce2{
public:
using ChemotacticForce2::ChemotacticForce;
void AddForceContribution(::AbstractCellPopulation<2, 2> & rCellPopulation) override {
PYBIND11_OVERLOAD(
void,
ChemotacticForce2,
AddForceContribution,
rCellPopulation);
}
void OutputForceParameters(::out_stream & rParamsFile) override {
PYBIND11_OVERLOAD(
void,
ChemotacticForce2,
OutputForceParameters,
rParamsFile);
}
};
void register_ChemotacticForce2_class(py::module &m){
py::class_<ChemotacticForce2 , ChemotacticForce2_Overloads , boost::shared_ptr<ChemotacticForce2 > , AbstractForce<2, 2> >(m, "ChemotacticForce2")
.def(py::init< >())
.def(
"AddForceContribution",
(void(ChemotacticForce2::*)(::AbstractCellPopulation<2, 2> &)) &ChemotacticForce2::AddForceContribution,
" " , py::arg("rCellPopulation") )
.def(
"OutputForceParameters",
(void(ChemotacticForce2::*)(::out_stream &)) &ChemotacticForce2::OutputForceParameters,
" " , py::arg("rParamsFile") )
;
}
| 32.836735 | 148 | 0.665009 | jmsgrogan |
2404a07e65bc995a03523fb00126b6e24acaa686 | 730,115 | cpp | C++ | test/normalize_to_nfkc_018.cpp | jan-moeller/text | c61e51c82dfb0ae6e74200c01ce040fa6db730c4 | [
"BSL-1.0"
] | null | null | null | test/normalize_to_nfkc_018.cpp | jan-moeller/text | c61e51c82dfb0ae6e74200c01ce040fa6db730c4 | [
"BSL-1.0"
] | null | null | null | test/normalize_to_nfkc_018.cpp | jan-moeller/text | c61e51c82dfb0ae6e74200c01ce040fa6db730c4 | [
"BSL-1.0"
] | null | null | null | // Warning! This file is autogenerated.
#include <boost/text/normalize_string.hpp>
#include <boost/text/utility.hpp>
#include <boost/text/string_utility.hpp>
#include <gtest/gtest.h>
#include <algorithm>
TEST(normalization, nfkc_018_000)
{
// B0A0;B0A0;1102 1161 11AF;B0A0;1102 1161 11AF;
// (날; 날; 날; 날; 날; ) HANGUL SYLLABLE NAL
{
std::array<uint32_t, 1> const c1 = {{ 0xB0A0 }};
std::array<uint32_t, 1> const c2 = {{ 0xB0A0 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1161, 0x11AF }};
std::array<uint32_t, 1> const c4 = {{ 0xB0A0 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1161, 0x11AF }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_001)
{
// B0A1;B0A1;1102 1161 11B0;B0A1;1102 1161 11B0;
// (낡; 낡; 낡; 낡; 낡; ) HANGUL SYLLABLE NALG
{
std::array<uint32_t, 1> const c1 = {{ 0xB0A1 }};
std::array<uint32_t, 1> const c2 = {{ 0xB0A1 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1161, 0x11B0 }};
std::array<uint32_t, 1> const c4 = {{ 0xB0A1 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1161, 0x11B0 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_002)
{
// B0A2;B0A2;1102 1161 11B1;B0A2;1102 1161 11B1;
// (낢; 낢; 낢; 낢; 낢; ) HANGUL SYLLABLE NALM
{
std::array<uint32_t, 1> const c1 = {{ 0xB0A2 }};
std::array<uint32_t, 1> const c2 = {{ 0xB0A2 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1161, 0x11B1 }};
std::array<uint32_t, 1> const c4 = {{ 0xB0A2 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1161, 0x11B1 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_003)
{
// B0A3;B0A3;1102 1161 11B2;B0A3;1102 1161 11B2;
// (낣; 낣; 낣; 낣; 낣; ) HANGUL SYLLABLE NALB
{
std::array<uint32_t, 1> const c1 = {{ 0xB0A3 }};
std::array<uint32_t, 1> const c2 = {{ 0xB0A3 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1161, 0x11B2 }};
std::array<uint32_t, 1> const c4 = {{ 0xB0A3 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1161, 0x11B2 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_004)
{
// B0A4;B0A4;1102 1161 11B3;B0A4;1102 1161 11B3;
// (낤; 낤; 낤; 낤; 낤; ) HANGUL SYLLABLE NALS
{
std::array<uint32_t, 1> const c1 = {{ 0xB0A4 }};
std::array<uint32_t, 1> const c2 = {{ 0xB0A4 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1161, 0x11B3 }};
std::array<uint32_t, 1> const c4 = {{ 0xB0A4 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1161, 0x11B3 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_005)
{
// B0A5;B0A5;1102 1161 11B4;B0A5;1102 1161 11B4;
// (낥; 낥; 낥; 낥; 낥; ) HANGUL SYLLABLE NALT
{
std::array<uint32_t, 1> const c1 = {{ 0xB0A5 }};
std::array<uint32_t, 1> const c2 = {{ 0xB0A5 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1161, 0x11B4 }};
std::array<uint32_t, 1> const c4 = {{ 0xB0A5 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1161, 0x11B4 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_006)
{
// B0A6;B0A6;1102 1161 11B5;B0A6;1102 1161 11B5;
// (낦; 낦; 낦; 낦; 낦; ) HANGUL SYLLABLE NALP
{
std::array<uint32_t, 1> const c1 = {{ 0xB0A6 }};
std::array<uint32_t, 1> const c2 = {{ 0xB0A6 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1161, 0x11B5 }};
std::array<uint32_t, 1> const c4 = {{ 0xB0A6 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1161, 0x11B5 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_007)
{
// B0A7;B0A7;1102 1161 11B6;B0A7;1102 1161 11B6;
// (낧; 낧; 낧; 낧; 낧; ) HANGUL SYLLABLE NALH
{
std::array<uint32_t, 1> const c1 = {{ 0xB0A7 }};
std::array<uint32_t, 1> const c2 = {{ 0xB0A7 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1161, 0x11B6 }};
std::array<uint32_t, 1> const c4 = {{ 0xB0A7 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1161, 0x11B6 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_008)
{
// B0A8;B0A8;1102 1161 11B7;B0A8;1102 1161 11B7;
// (남; 남; 남; 남; 남; ) HANGUL SYLLABLE NAM
{
std::array<uint32_t, 1> const c1 = {{ 0xB0A8 }};
std::array<uint32_t, 1> const c2 = {{ 0xB0A8 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1161, 0x11B7 }};
std::array<uint32_t, 1> const c4 = {{ 0xB0A8 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1161, 0x11B7 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_009)
{
// B0A9;B0A9;1102 1161 11B8;B0A9;1102 1161 11B8;
// (납; 납; 납; 납; 납; ) HANGUL SYLLABLE NAB
{
std::array<uint32_t, 1> const c1 = {{ 0xB0A9 }};
std::array<uint32_t, 1> const c2 = {{ 0xB0A9 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1161, 0x11B8 }};
std::array<uint32_t, 1> const c4 = {{ 0xB0A9 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1161, 0x11B8 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_010)
{
// B0AA;B0AA;1102 1161 11B9;B0AA;1102 1161 11B9;
// (낪; 낪; 낪; 낪; 낪; ) HANGUL SYLLABLE NABS
{
std::array<uint32_t, 1> const c1 = {{ 0xB0AA }};
std::array<uint32_t, 1> const c2 = {{ 0xB0AA }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1161, 0x11B9 }};
std::array<uint32_t, 1> const c4 = {{ 0xB0AA }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1161, 0x11B9 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_011)
{
// B0AB;B0AB;1102 1161 11BA;B0AB;1102 1161 11BA;
// (낫; 낫; 낫; 낫; 낫; ) HANGUL SYLLABLE NAS
{
std::array<uint32_t, 1> const c1 = {{ 0xB0AB }};
std::array<uint32_t, 1> const c2 = {{ 0xB0AB }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1161, 0x11BA }};
std::array<uint32_t, 1> const c4 = {{ 0xB0AB }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1161, 0x11BA }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_012)
{
// B0AC;B0AC;1102 1161 11BB;B0AC;1102 1161 11BB;
// (났; 났; 났; 났; 났; ) HANGUL SYLLABLE NASS
{
std::array<uint32_t, 1> const c1 = {{ 0xB0AC }};
std::array<uint32_t, 1> const c2 = {{ 0xB0AC }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1161, 0x11BB }};
std::array<uint32_t, 1> const c4 = {{ 0xB0AC }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1161, 0x11BB }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_013)
{
// B0AD;B0AD;1102 1161 11BC;B0AD;1102 1161 11BC;
// (낭; 낭; 낭; 낭; 낭; ) HANGUL SYLLABLE NANG
{
std::array<uint32_t, 1> const c1 = {{ 0xB0AD }};
std::array<uint32_t, 1> const c2 = {{ 0xB0AD }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1161, 0x11BC }};
std::array<uint32_t, 1> const c4 = {{ 0xB0AD }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1161, 0x11BC }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_014)
{
// B0AE;B0AE;1102 1161 11BD;B0AE;1102 1161 11BD;
// (낮; 낮; 낮; 낮; 낮; ) HANGUL SYLLABLE NAJ
{
std::array<uint32_t, 1> const c1 = {{ 0xB0AE }};
std::array<uint32_t, 1> const c2 = {{ 0xB0AE }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1161, 0x11BD }};
std::array<uint32_t, 1> const c4 = {{ 0xB0AE }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1161, 0x11BD }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_015)
{
// B0AF;B0AF;1102 1161 11BE;B0AF;1102 1161 11BE;
// (낯; 낯; 낯; 낯; 낯; ) HANGUL SYLLABLE NAC
{
std::array<uint32_t, 1> const c1 = {{ 0xB0AF }};
std::array<uint32_t, 1> const c2 = {{ 0xB0AF }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1161, 0x11BE }};
std::array<uint32_t, 1> const c4 = {{ 0xB0AF }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1161, 0x11BE }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_016)
{
// B0B0;B0B0;1102 1161 11BF;B0B0;1102 1161 11BF;
// (낰; 낰; 낰; 낰; 낰; ) HANGUL SYLLABLE NAK
{
std::array<uint32_t, 1> const c1 = {{ 0xB0B0 }};
std::array<uint32_t, 1> const c2 = {{ 0xB0B0 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1161, 0x11BF }};
std::array<uint32_t, 1> const c4 = {{ 0xB0B0 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1161, 0x11BF }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_017)
{
// B0B1;B0B1;1102 1161 11C0;B0B1;1102 1161 11C0;
// (낱; 낱; 낱; 낱; 낱; ) HANGUL SYLLABLE NAT
{
std::array<uint32_t, 1> const c1 = {{ 0xB0B1 }};
std::array<uint32_t, 1> const c2 = {{ 0xB0B1 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1161, 0x11C0 }};
std::array<uint32_t, 1> const c4 = {{ 0xB0B1 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1161, 0x11C0 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_018)
{
// B0B2;B0B2;1102 1161 11C1;B0B2;1102 1161 11C1;
// (낲; 낲; 낲; 낲; 낲; ) HANGUL SYLLABLE NAP
{
std::array<uint32_t, 1> const c1 = {{ 0xB0B2 }};
std::array<uint32_t, 1> const c2 = {{ 0xB0B2 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1161, 0x11C1 }};
std::array<uint32_t, 1> const c4 = {{ 0xB0B2 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1161, 0x11C1 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_019)
{
// B0B3;B0B3;1102 1161 11C2;B0B3;1102 1161 11C2;
// (낳; 낳; 낳; 낳; 낳; ) HANGUL SYLLABLE NAH
{
std::array<uint32_t, 1> const c1 = {{ 0xB0B3 }};
std::array<uint32_t, 1> const c2 = {{ 0xB0B3 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1161, 0x11C2 }};
std::array<uint32_t, 1> const c4 = {{ 0xB0B3 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1161, 0x11C2 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_020)
{
// B0B4;B0B4;1102 1162;B0B4;1102 1162;
// (내; 내; 내; 내; 내; ) HANGUL SYLLABLE NAE
{
std::array<uint32_t, 1> const c1 = {{ 0xB0B4 }};
std::array<uint32_t, 1> const c2 = {{ 0xB0B4 }};
std::array<uint32_t, 2> const c3 = {{ 0x1102, 0x1162 }};
std::array<uint32_t, 1> const c4 = {{ 0xB0B4 }};
std::array<uint32_t, 2> const c5 = {{ 0x1102, 0x1162 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_021)
{
// B0B5;B0B5;1102 1162 11A8;B0B5;1102 1162 11A8;
// (낵; 낵; 낵; 낵; 낵; ) HANGUL SYLLABLE NAEG
{
std::array<uint32_t, 1> const c1 = {{ 0xB0B5 }};
std::array<uint32_t, 1> const c2 = {{ 0xB0B5 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1162, 0x11A8 }};
std::array<uint32_t, 1> const c4 = {{ 0xB0B5 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1162, 0x11A8 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_022)
{
// B0B6;B0B6;1102 1162 11A9;B0B6;1102 1162 11A9;
// (낶; 낶; 낶; 낶; 낶; ) HANGUL SYLLABLE NAEGG
{
std::array<uint32_t, 1> const c1 = {{ 0xB0B6 }};
std::array<uint32_t, 1> const c2 = {{ 0xB0B6 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1162, 0x11A9 }};
std::array<uint32_t, 1> const c4 = {{ 0xB0B6 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1162, 0x11A9 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_023)
{
// B0B7;B0B7;1102 1162 11AA;B0B7;1102 1162 11AA;
// (낷; 낷; 낷; 낷; 낷; ) HANGUL SYLLABLE NAEGS
{
std::array<uint32_t, 1> const c1 = {{ 0xB0B7 }};
std::array<uint32_t, 1> const c2 = {{ 0xB0B7 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1162, 0x11AA }};
std::array<uint32_t, 1> const c4 = {{ 0xB0B7 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1162, 0x11AA }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_024)
{
// B0B8;B0B8;1102 1162 11AB;B0B8;1102 1162 11AB;
// (낸; 낸; 낸; 낸; 낸; ) HANGUL SYLLABLE NAEN
{
std::array<uint32_t, 1> const c1 = {{ 0xB0B8 }};
std::array<uint32_t, 1> const c2 = {{ 0xB0B8 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1162, 0x11AB }};
std::array<uint32_t, 1> const c4 = {{ 0xB0B8 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1162, 0x11AB }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_025)
{
// B0B9;B0B9;1102 1162 11AC;B0B9;1102 1162 11AC;
// (낹; 낹; 낹; 낹; 낹; ) HANGUL SYLLABLE NAENJ
{
std::array<uint32_t, 1> const c1 = {{ 0xB0B9 }};
std::array<uint32_t, 1> const c2 = {{ 0xB0B9 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1162, 0x11AC }};
std::array<uint32_t, 1> const c4 = {{ 0xB0B9 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1162, 0x11AC }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_026)
{
// B0BA;B0BA;1102 1162 11AD;B0BA;1102 1162 11AD;
// (낺; 낺; 낺; 낺; 낺; ) HANGUL SYLLABLE NAENH
{
std::array<uint32_t, 1> const c1 = {{ 0xB0BA }};
std::array<uint32_t, 1> const c2 = {{ 0xB0BA }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1162, 0x11AD }};
std::array<uint32_t, 1> const c4 = {{ 0xB0BA }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1162, 0x11AD }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_027)
{
// B0BB;B0BB;1102 1162 11AE;B0BB;1102 1162 11AE;
// (낻; 낻; 낻; 낻; 낻; ) HANGUL SYLLABLE NAED
{
std::array<uint32_t, 1> const c1 = {{ 0xB0BB }};
std::array<uint32_t, 1> const c2 = {{ 0xB0BB }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1162, 0x11AE }};
std::array<uint32_t, 1> const c4 = {{ 0xB0BB }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1162, 0x11AE }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_028)
{
// B0BC;B0BC;1102 1162 11AF;B0BC;1102 1162 11AF;
// (낼; 낼; 낼; 낼; 낼; ) HANGUL SYLLABLE NAEL
{
std::array<uint32_t, 1> const c1 = {{ 0xB0BC }};
std::array<uint32_t, 1> const c2 = {{ 0xB0BC }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1162, 0x11AF }};
std::array<uint32_t, 1> const c4 = {{ 0xB0BC }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1162, 0x11AF }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_029)
{
// B0BD;B0BD;1102 1162 11B0;B0BD;1102 1162 11B0;
// (낽; 낽; 낽; 낽; 낽; ) HANGUL SYLLABLE NAELG
{
std::array<uint32_t, 1> const c1 = {{ 0xB0BD }};
std::array<uint32_t, 1> const c2 = {{ 0xB0BD }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1162, 0x11B0 }};
std::array<uint32_t, 1> const c4 = {{ 0xB0BD }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1162, 0x11B0 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_030)
{
// B0BE;B0BE;1102 1162 11B1;B0BE;1102 1162 11B1;
// (낾; 낾; 낾; 낾; 낾; ) HANGUL SYLLABLE NAELM
{
std::array<uint32_t, 1> const c1 = {{ 0xB0BE }};
std::array<uint32_t, 1> const c2 = {{ 0xB0BE }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1162, 0x11B1 }};
std::array<uint32_t, 1> const c4 = {{ 0xB0BE }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1162, 0x11B1 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_031)
{
// B0BF;B0BF;1102 1162 11B2;B0BF;1102 1162 11B2;
// (낿; 낿; 낿; 낿; 낿; ) HANGUL SYLLABLE NAELB
{
std::array<uint32_t, 1> const c1 = {{ 0xB0BF }};
std::array<uint32_t, 1> const c2 = {{ 0xB0BF }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1162, 0x11B2 }};
std::array<uint32_t, 1> const c4 = {{ 0xB0BF }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1162, 0x11B2 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_032)
{
// B0C0;B0C0;1102 1162 11B3;B0C0;1102 1162 11B3;
// (냀; 냀; 냀; 냀; 냀; ) HANGUL SYLLABLE NAELS
{
std::array<uint32_t, 1> const c1 = {{ 0xB0C0 }};
std::array<uint32_t, 1> const c2 = {{ 0xB0C0 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1162, 0x11B3 }};
std::array<uint32_t, 1> const c4 = {{ 0xB0C0 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1162, 0x11B3 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_033)
{
// B0C1;B0C1;1102 1162 11B4;B0C1;1102 1162 11B4;
// (냁; 냁; 냁; 냁; 냁; ) HANGUL SYLLABLE NAELT
{
std::array<uint32_t, 1> const c1 = {{ 0xB0C1 }};
std::array<uint32_t, 1> const c2 = {{ 0xB0C1 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1162, 0x11B4 }};
std::array<uint32_t, 1> const c4 = {{ 0xB0C1 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1162, 0x11B4 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_034)
{
// B0C2;B0C2;1102 1162 11B5;B0C2;1102 1162 11B5;
// (냂; 냂; 냂; 냂; 냂; ) HANGUL SYLLABLE NAELP
{
std::array<uint32_t, 1> const c1 = {{ 0xB0C2 }};
std::array<uint32_t, 1> const c2 = {{ 0xB0C2 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1162, 0x11B5 }};
std::array<uint32_t, 1> const c4 = {{ 0xB0C2 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1162, 0x11B5 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_035)
{
// B0C3;B0C3;1102 1162 11B6;B0C3;1102 1162 11B6;
// (냃; 냃; 냃; 냃; 냃; ) HANGUL SYLLABLE NAELH
{
std::array<uint32_t, 1> const c1 = {{ 0xB0C3 }};
std::array<uint32_t, 1> const c2 = {{ 0xB0C3 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1162, 0x11B6 }};
std::array<uint32_t, 1> const c4 = {{ 0xB0C3 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1162, 0x11B6 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_036)
{
// B0C4;B0C4;1102 1162 11B7;B0C4;1102 1162 11B7;
// (냄; 냄; 냄; 냄; 냄; ) HANGUL SYLLABLE NAEM
{
std::array<uint32_t, 1> const c1 = {{ 0xB0C4 }};
std::array<uint32_t, 1> const c2 = {{ 0xB0C4 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1162, 0x11B7 }};
std::array<uint32_t, 1> const c4 = {{ 0xB0C4 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1162, 0x11B7 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_037)
{
// B0C5;B0C5;1102 1162 11B8;B0C5;1102 1162 11B8;
// (냅; 냅; 냅; 냅; 냅; ) HANGUL SYLLABLE NAEB
{
std::array<uint32_t, 1> const c1 = {{ 0xB0C5 }};
std::array<uint32_t, 1> const c2 = {{ 0xB0C5 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1162, 0x11B8 }};
std::array<uint32_t, 1> const c4 = {{ 0xB0C5 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1162, 0x11B8 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_038)
{
// B0C6;B0C6;1102 1162 11B9;B0C6;1102 1162 11B9;
// (냆; 냆; 냆; 냆; 냆; ) HANGUL SYLLABLE NAEBS
{
std::array<uint32_t, 1> const c1 = {{ 0xB0C6 }};
std::array<uint32_t, 1> const c2 = {{ 0xB0C6 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1162, 0x11B9 }};
std::array<uint32_t, 1> const c4 = {{ 0xB0C6 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1162, 0x11B9 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_039)
{
// B0C7;B0C7;1102 1162 11BA;B0C7;1102 1162 11BA;
// (냇; 냇; 냇; 냇; 냇; ) HANGUL SYLLABLE NAES
{
std::array<uint32_t, 1> const c1 = {{ 0xB0C7 }};
std::array<uint32_t, 1> const c2 = {{ 0xB0C7 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1162, 0x11BA }};
std::array<uint32_t, 1> const c4 = {{ 0xB0C7 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1162, 0x11BA }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_040)
{
// B0C8;B0C8;1102 1162 11BB;B0C8;1102 1162 11BB;
// (냈; 냈; 냈; 냈; 냈; ) HANGUL SYLLABLE NAESS
{
std::array<uint32_t, 1> const c1 = {{ 0xB0C8 }};
std::array<uint32_t, 1> const c2 = {{ 0xB0C8 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1162, 0x11BB }};
std::array<uint32_t, 1> const c4 = {{ 0xB0C8 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1162, 0x11BB }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_041)
{
// B0C9;B0C9;1102 1162 11BC;B0C9;1102 1162 11BC;
// (냉; 냉; 냉; 냉; 냉; ) HANGUL SYLLABLE NAENG
{
std::array<uint32_t, 1> const c1 = {{ 0xB0C9 }};
std::array<uint32_t, 1> const c2 = {{ 0xB0C9 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1162, 0x11BC }};
std::array<uint32_t, 1> const c4 = {{ 0xB0C9 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1162, 0x11BC }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_042)
{
// B0CA;B0CA;1102 1162 11BD;B0CA;1102 1162 11BD;
// (냊; 냊; 냊; 냊; 냊; ) HANGUL SYLLABLE NAEJ
{
std::array<uint32_t, 1> const c1 = {{ 0xB0CA }};
std::array<uint32_t, 1> const c2 = {{ 0xB0CA }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1162, 0x11BD }};
std::array<uint32_t, 1> const c4 = {{ 0xB0CA }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1162, 0x11BD }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_043)
{
// B0CB;B0CB;1102 1162 11BE;B0CB;1102 1162 11BE;
// (냋; 냋; 냋; 냋; 냋; ) HANGUL SYLLABLE NAEC
{
std::array<uint32_t, 1> const c1 = {{ 0xB0CB }};
std::array<uint32_t, 1> const c2 = {{ 0xB0CB }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1162, 0x11BE }};
std::array<uint32_t, 1> const c4 = {{ 0xB0CB }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1162, 0x11BE }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_044)
{
// B0CC;B0CC;1102 1162 11BF;B0CC;1102 1162 11BF;
// (냌; 냌; 냌; 냌; 냌; ) HANGUL SYLLABLE NAEK
{
std::array<uint32_t, 1> const c1 = {{ 0xB0CC }};
std::array<uint32_t, 1> const c2 = {{ 0xB0CC }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1162, 0x11BF }};
std::array<uint32_t, 1> const c4 = {{ 0xB0CC }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1162, 0x11BF }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_045)
{
// B0CD;B0CD;1102 1162 11C0;B0CD;1102 1162 11C0;
// (냍; 냍; 냍; 냍; 냍; ) HANGUL SYLLABLE NAET
{
std::array<uint32_t, 1> const c1 = {{ 0xB0CD }};
std::array<uint32_t, 1> const c2 = {{ 0xB0CD }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1162, 0x11C0 }};
std::array<uint32_t, 1> const c4 = {{ 0xB0CD }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1162, 0x11C0 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_046)
{
// B0CE;B0CE;1102 1162 11C1;B0CE;1102 1162 11C1;
// (냎; 냎; 냎; 냎; 냎; ) HANGUL SYLLABLE NAEP
{
std::array<uint32_t, 1> const c1 = {{ 0xB0CE }};
std::array<uint32_t, 1> const c2 = {{ 0xB0CE }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1162, 0x11C1 }};
std::array<uint32_t, 1> const c4 = {{ 0xB0CE }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1162, 0x11C1 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_047)
{
// B0CF;B0CF;1102 1162 11C2;B0CF;1102 1162 11C2;
// (냏; 냏; 냏; 냏; 냏; ) HANGUL SYLLABLE NAEH
{
std::array<uint32_t, 1> const c1 = {{ 0xB0CF }};
std::array<uint32_t, 1> const c2 = {{ 0xB0CF }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1162, 0x11C2 }};
std::array<uint32_t, 1> const c4 = {{ 0xB0CF }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1162, 0x11C2 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_048)
{
// B0D0;B0D0;1102 1163;B0D0;1102 1163;
// (냐; 냐; 냐; 냐; 냐; ) HANGUL SYLLABLE NYA
{
std::array<uint32_t, 1> const c1 = {{ 0xB0D0 }};
std::array<uint32_t, 1> const c2 = {{ 0xB0D0 }};
std::array<uint32_t, 2> const c3 = {{ 0x1102, 0x1163 }};
std::array<uint32_t, 1> const c4 = {{ 0xB0D0 }};
std::array<uint32_t, 2> const c5 = {{ 0x1102, 0x1163 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_049)
{
// B0D1;B0D1;1102 1163 11A8;B0D1;1102 1163 11A8;
// (냑; 냑; 냑; 냑; 냑; ) HANGUL SYLLABLE NYAG
{
std::array<uint32_t, 1> const c1 = {{ 0xB0D1 }};
std::array<uint32_t, 1> const c2 = {{ 0xB0D1 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1163, 0x11A8 }};
std::array<uint32_t, 1> const c4 = {{ 0xB0D1 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1163, 0x11A8 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_050)
{
// B0D2;B0D2;1102 1163 11A9;B0D2;1102 1163 11A9;
// (냒; 냒; 냒; 냒; 냒; ) HANGUL SYLLABLE NYAGG
{
std::array<uint32_t, 1> const c1 = {{ 0xB0D2 }};
std::array<uint32_t, 1> const c2 = {{ 0xB0D2 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1163, 0x11A9 }};
std::array<uint32_t, 1> const c4 = {{ 0xB0D2 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1163, 0x11A9 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_051)
{
// B0D3;B0D3;1102 1163 11AA;B0D3;1102 1163 11AA;
// (냓; 냓; 냓; 냓; 냓; ) HANGUL SYLLABLE NYAGS
{
std::array<uint32_t, 1> const c1 = {{ 0xB0D3 }};
std::array<uint32_t, 1> const c2 = {{ 0xB0D3 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1163, 0x11AA }};
std::array<uint32_t, 1> const c4 = {{ 0xB0D3 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1163, 0x11AA }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_052)
{
// B0D4;B0D4;1102 1163 11AB;B0D4;1102 1163 11AB;
// (냔; 냔; 냔; 냔; 냔; ) HANGUL SYLLABLE NYAN
{
std::array<uint32_t, 1> const c1 = {{ 0xB0D4 }};
std::array<uint32_t, 1> const c2 = {{ 0xB0D4 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1163, 0x11AB }};
std::array<uint32_t, 1> const c4 = {{ 0xB0D4 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1163, 0x11AB }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_053)
{
// B0D5;B0D5;1102 1163 11AC;B0D5;1102 1163 11AC;
// (냕; 냕; 냕; 냕; 냕; ) HANGUL SYLLABLE NYANJ
{
std::array<uint32_t, 1> const c1 = {{ 0xB0D5 }};
std::array<uint32_t, 1> const c2 = {{ 0xB0D5 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1163, 0x11AC }};
std::array<uint32_t, 1> const c4 = {{ 0xB0D5 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1163, 0x11AC }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_054)
{
// B0D6;B0D6;1102 1163 11AD;B0D6;1102 1163 11AD;
// (냖; 냖; 냖; 냖; 냖; ) HANGUL SYLLABLE NYANH
{
std::array<uint32_t, 1> const c1 = {{ 0xB0D6 }};
std::array<uint32_t, 1> const c2 = {{ 0xB0D6 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1163, 0x11AD }};
std::array<uint32_t, 1> const c4 = {{ 0xB0D6 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1163, 0x11AD }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_055)
{
// B0D7;B0D7;1102 1163 11AE;B0D7;1102 1163 11AE;
// (냗; 냗; 냗; 냗; 냗; ) HANGUL SYLLABLE NYAD
{
std::array<uint32_t, 1> const c1 = {{ 0xB0D7 }};
std::array<uint32_t, 1> const c2 = {{ 0xB0D7 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1163, 0x11AE }};
std::array<uint32_t, 1> const c4 = {{ 0xB0D7 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1163, 0x11AE }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_056)
{
// B0D8;B0D8;1102 1163 11AF;B0D8;1102 1163 11AF;
// (냘; 냘; 냘; 냘; 냘; ) HANGUL SYLLABLE NYAL
{
std::array<uint32_t, 1> const c1 = {{ 0xB0D8 }};
std::array<uint32_t, 1> const c2 = {{ 0xB0D8 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1163, 0x11AF }};
std::array<uint32_t, 1> const c4 = {{ 0xB0D8 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1163, 0x11AF }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_057)
{
// B0D9;B0D9;1102 1163 11B0;B0D9;1102 1163 11B0;
// (냙; 냙; 냙; 냙; 냙; ) HANGUL SYLLABLE NYALG
{
std::array<uint32_t, 1> const c1 = {{ 0xB0D9 }};
std::array<uint32_t, 1> const c2 = {{ 0xB0D9 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1163, 0x11B0 }};
std::array<uint32_t, 1> const c4 = {{ 0xB0D9 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1163, 0x11B0 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_058)
{
// B0DA;B0DA;1102 1163 11B1;B0DA;1102 1163 11B1;
// (냚; 냚; 냚; 냚; 냚; ) HANGUL SYLLABLE NYALM
{
std::array<uint32_t, 1> const c1 = {{ 0xB0DA }};
std::array<uint32_t, 1> const c2 = {{ 0xB0DA }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1163, 0x11B1 }};
std::array<uint32_t, 1> const c4 = {{ 0xB0DA }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1163, 0x11B1 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_059)
{
// B0DB;B0DB;1102 1163 11B2;B0DB;1102 1163 11B2;
// (냛; 냛; 냛; 냛; 냛; ) HANGUL SYLLABLE NYALB
{
std::array<uint32_t, 1> const c1 = {{ 0xB0DB }};
std::array<uint32_t, 1> const c2 = {{ 0xB0DB }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1163, 0x11B2 }};
std::array<uint32_t, 1> const c4 = {{ 0xB0DB }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1163, 0x11B2 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_060)
{
// B0DC;B0DC;1102 1163 11B3;B0DC;1102 1163 11B3;
// (냜; 냜; 냜; 냜; 냜; ) HANGUL SYLLABLE NYALS
{
std::array<uint32_t, 1> const c1 = {{ 0xB0DC }};
std::array<uint32_t, 1> const c2 = {{ 0xB0DC }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1163, 0x11B3 }};
std::array<uint32_t, 1> const c4 = {{ 0xB0DC }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1163, 0x11B3 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_061)
{
// B0DD;B0DD;1102 1163 11B4;B0DD;1102 1163 11B4;
// (냝; 냝; 냝; 냝; 냝; ) HANGUL SYLLABLE NYALT
{
std::array<uint32_t, 1> const c1 = {{ 0xB0DD }};
std::array<uint32_t, 1> const c2 = {{ 0xB0DD }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1163, 0x11B4 }};
std::array<uint32_t, 1> const c4 = {{ 0xB0DD }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1163, 0x11B4 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_062)
{
// B0DE;B0DE;1102 1163 11B5;B0DE;1102 1163 11B5;
// (냞; 냞; 냞; 냞; 냞; ) HANGUL SYLLABLE NYALP
{
std::array<uint32_t, 1> const c1 = {{ 0xB0DE }};
std::array<uint32_t, 1> const c2 = {{ 0xB0DE }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1163, 0x11B5 }};
std::array<uint32_t, 1> const c4 = {{ 0xB0DE }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1163, 0x11B5 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_063)
{
// B0DF;B0DF;1102 1163 11B6;B0DF;1102 1163 11B6;
// (냟; 냟; 냟; 냟; 냟; ) HANGUL SYLLABLE NYALH
{
std::array<uint32_t, 1> const c1 = {{ 0xB0DF }};
std::array<uint32_t, 1> const c2 = {{ 0xB0DF }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1163, 0x11B6 }};
std::array<uint32_t, 1> const c4 = {{ 0xB0DF }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1163, 0x11B6 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_064)
{
// B0E0;B0E0;1102 1163 11B7;B0E0;1102 1163 11B7;
// (냠; 냠; 냠; 냠; 냠; ) HANGUL SYLLABLE NYAM
{
std::array<uint32_t, 1> const c1 = {{ 0xB0E0 }};
std::array<uint32_t, 1> const c2 = {{ 0xB0E0 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1163, 0x11B7 }};
std::array<uint32_t, 1> const c4 = {{ 0xB0E0 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1163, 0x11B7 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_065)
{
// B0E1;B0E1;1102 1163 11B8;B0E1;1102 1163 11B8;
// (냡; 냡; 냡; 냡; 냡; ) HANGUL SYLLABLE NYAB
{
std::array<uint32_t, 1> const c1 = {{ 0xB0E1 }};
std::array<uint32_t, 1> const c2 = {{ 0xB0E1 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1163, 0x11B8 }};
std::array<uint32_t, 1> const c4 = {{ 0xB0E1 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1163, 0x11B8 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_066)
{
// B0E2;B0E2;1102 1163 11B9;B0E2;1102 1163 11B9;
// (냢; 냢; 냢; 냢; 냢; ) HANGUL SYLLABLE NYABS
{
std::array<uint32_t, 1> const c1 = {{ 0xB0E2 }};
std::array<uint32_t, 1> const c2 = {{ 0xB0E2 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1163, 0x11B9 }};
std::array<uint32_t, 1> const c4 = {{ 0xB0E2 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1163, 0x11B9 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_067)
{
// B0E3;B0E3;1102 1163 11BA;B0E3;1102 1163 11BA;
// (냣; 냣; 냣; 냣; 냣; ) HANGUL SYLLABLE NYAS
{
std::array<uint32_t, 1> const c1 = {{ 0xB0E3 }};
std::array<uint32_t, 1> const c2 = {{ 0xB0E3 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1163, 0x11BA }};
std::array<uint32_t, 1> const c4 = {{ 0xB0E3 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1163, 0x11BA }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_068)
{
// B0E4;B0E4;1102 1163 11BB;B0E4;1102 1163 11BB;
// (냤; 냤; 냤; 냤; 냤; ) HANGUL SYLLABLE NYASS
{
std::array<uint32_t, 1> const c1 = {{ 0xB0E4 }};
std::array<uint32_t, 1> const c2 = {{ 0xB0E4 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1163, 0x11BB }};
std::array<uint32_t, 1> const c4 = {{ 0xB0E4 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1163, 0x11BB }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_069)
{
// B0E5;B0E5;1102 1163 11BC;B0E5;1102 1163 11BC;
// (냥; 냥; 냥; 냥; 냥; ) HANGUL SYLLABLE NYANG
{
std::array<uint32_t, 1> const c1 = {{ 0xB0E5 }};
std::array<uint32_t, 1> const c2 = {{ 0xB0E5 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1163, 0x11BC }};
std::array<uint32_t, 1> const c4 = {{ 0xB0E5 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1163, 0x11BC }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_070)
{
// B0E6;B0E6;1102 1163 11BD;B0E6;1102 1163 11BD;
// (냦; 냦; 냦; 냦; 냦; ) HANGUL SYLLABLE NYAJ
{
std::array<uint32_t, 1> const c1 = {{ 0xB0E6 }};
std::array<uint32_t, 1> const c2 = {{ 0xB0E6 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1163, 0x11BD }};
std::array<uint32_t, 1> const c4 = {{ 0xB0E6 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1163, 0x11BD }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_071)
{
// B0E7;B0E7;1102 1163 11BE;B0E7;1102 1163 11BE;
// (냧; 냧; 냧; 냧; 냧; ) HANGUL SYLLABLE NYAC
{
std::array<uint32_t, 1> const c1 = {{ 0xB0E7 }};
std::array<uint32_t, 1> const c2 = {{ 0xB0E7 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1163, 0x11BE }};
std::array<uint32_t, 1> const c4 = {{ 0xB0E7 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1163, 0x11BE }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_072)
{
// B0E8;B0E8;1102 1163 11BF;B0E8;1102 1163 11BF;
// (냨; 냨; 냨; 냨; 냨; ) HANGUL SYLLABLE NYAK
{
std::array<uint32_t, 1> const c1 = {{ 0xB0E8 }};
std::array<uint32_t, 1> const c2 = {{ 0xB0E8 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1163, 0x11BF }};
std::array<uint32_t, 1> const c4 = {{ 0xB0E8 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1163, 0x11BF }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_073)
{
// B0E9;B0E9;1102 1163 11C0;B0E9;1102 1163 11C0;
// (냩; 냩; 냩; 냩; 냩; ) HANGUL SYLLABLE NYAT
{
std::array<uint32_t, 1> const c1 = {{ 0xB0E9 }};
std::array<uint32_t, 1> const c2 = {{ 0xB0E9 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1163, 0x11C0 }};
std::array<uint32_t, 1> const c4 = {{ 0xB0E9 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1163, 0x11C0 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_074)
{
// B0EA;B0EA;1102 1163 11C1;B0EA;1102 1163 11C1;
// (냪; 냪; 냪; 냪; 냪; ) HANGUL SYLLABLE NYAP
{
std::array<uint32_t, 1> const c1 = {{ 0xB0EA }};
std::array<uint32_t, 1> const c2 = {{ 0xB0EA }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1163, 0x11C1 }};
std::array<uint32_t, 1> const c4 = {{ 0xB0EA }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1163, 0x11C1 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_075)
{
// B0EB;B0EB;1102 1163 11C2;B0EB;1102 1163 11C2;
// (냫; 냫; 냫; 냫; 냫; ) HANGUL SYLLABLE NYAH
{
std::array<uint32_t, 1> const c1 = {{ 0xB0EB }};
std::array<uint32_t, 1> const c2 = {{ 0xB0EB }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1163, 0x11C2 }};
std::array<uint32_t, 1> const c4 = {{ 0xB0EB }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1163, 0x11C2 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_076)
{
// B0EC;B0EC;1102 1164;B0EC;1102 1164;
// (냬; 냬; 냬; 냬; 냬; ) HANGUL SYLLABLE NYAE
{
std::array<uint32_t, 1> const c1 = {{ 0xB0EC }};
std::array<uint32_t, 1> const c2 = {{ 0xB0EC }};
std::array<uint32_t, 2> const c3 = {{ 0x1102, 0x1164 }};
std::array<uint32_t, 1> const c4 = {{ 0xB0EC }};
std::array<uint32_t, 2> const c5 = {{ 0x1102, 0x1164 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_077)
{
// B0ED;B0ED;1102 1164 11A8;B0ED;1102 1164 11A8;
// (냭; 냭; 냭; 냭; 냭; ) HANGUL SYLLABLE NYAEG
{
std::array<uint32_t, 1> const c1 = {{ 0xB0ED }};
std::array<uint32_t, 1> const c2 = {{ 0xB0ED }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1164, 0x11A8 }};
std::array<uint32_t, 1> const c4 = {{ 0xB0ED }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1164, 0x11A8 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_078)
{
// B0EE;B0EE;1102 1164 11A9;B0EE;1102 1164 11A9;
// (냮; 냮; 냮; 냮; 냮; ) HANGUL SYLLABLE NYAEGG
{
std::array<uint32_t, 1> const c1 = {{ 0xB0EE }};
std::array<uint32_t, 1> const c2 = {{ 0xB0EE }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1164, 0x11A9 }};
std::array<uint32_t, 1> const c4 = {{ 0xB0EE }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1164, 0x11A9 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_079)
{
// B0EF;B0EF;1102 1164 11AA;B0EF;1102 1164 11AA;
// (냯; 냯; 냯; 냯; 냯; ) HANGUL SYLLABLE NYAEGS
{
std::array<uint32_t, 1> const c1 = {{ 0xB0EF }};
std::array<uint32_t, 1> const c2 = {{ 0xB0EF }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1164, 0x11AA }};
std::array<uint32_t, 1> const c4 = {{ 0xB0EF }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1164, 0x11AA }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_080)
{
// B0F0;B0F0;1102 1164 11AB;B0F0;1102 1164 11AB;
// (냰; 냰; 냰; 냰; 냰; ) HANGUL SYLLABLE NYAEN
{
std::array<uint32_t, 1> const c1 = {{ 0xB0F0 }};
std::array<uint32_t, 1> const c2 = {{ 0xB0F0 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1164, 0x11AB }};
std::array<uint32_t, 1> const c4 = {{ 0xB0F0 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1164, 0x11AB }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_081)
{
// B0F1;B0F1;1102 1164 11AC;B0F1;1102 1164 11AC;
// (냱; 냱; 냱; 냱; 냱; ) HANGUL SYLLABLE NYAENJ
{
std::array<uint32_t, 1> const c1 = {{ 0xB0F1 }};
std::array<uint32_t, 1> const c2 = {{ 0xB0F1 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1164, 0x11AC }};
std::array<uint32_t, 1> const c4 = {{ 0xB0F1 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1164, 0x11AC }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_082)
{
// B0F2;B0F2;1102 1164 11AD;B0F2;1102 1164 11AD;
// (냲; 냲; 냲; 냲; 냲; ) HANGUL SYLLABLE NYAENH
{
std::array<uint32_t, 1> const c1 = {{ 0xB0F2 }};
std::array<uint32_t, 1> const c2 = {{ 0xB0F2 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1164, 0x11AD }};
std::array<uint32_t, 1> const c4 = {{ 0xB0F2 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1164, 0x11AD }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_083)
{
// B0F3;B0F3;1102 1164 11AE;B0F3;1102 1164 11AE;
// (냳; 냳; 냳; 냳; 냳; ) HANGUL SYLLABLE NYAED
{
std::array<uint32_t, 1> const c1 = {{ 0xB0F3 }};
std::array<uint32_t, 1> const c2 = {{ 0xB0F3 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1164, 0x11AE }};
std::array<uint32_t, 1> const c4 = {{ 0xB0F3 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1164, 0x11AE }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_084)
{
// B0F4;B0F4;1102 1164 11AF;B0F4;1102 1164 11AF;
// (냴; 냴; 냴; 냴; 냴; ) HANGUL SYLLABLE NYAEL
{
std::array<uint32_t, 1> const c1 = {{ 0xB0F4 }};
std::array<uint32_t, 1> const c2 = {{ 0xB0F4 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1164, 0x11AF }};
std::array<uint32_t, 1> const c4 = {{ 0xB0F4 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1164, 0x11AF }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_085)
{
// B0F5;B0F5;1102 1164 11B0;B0F5;1102 1164 11B0;
// (냵; 냵; 냵; 냵; 냵; ) HANGUL SYLLABLE NYAELG
{
std::array<uint32_t, 1> const c1 = {{ 0xB0F5 }};
std::array<uint32_t, 1> const c2 = {{ 0xB0F5 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1164, 0x11B0 }};
std::array<uint32_t, 1> const c4 = {{ 0xB0F5 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1164, 0x11B0 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_086)
{
// B0F6;B0F6;1102 1164 11B1;B0F6;1102 1164 11B1;
// (냶; 냶; 냶; 냶; 냶; ) HANGUL SYLLABLE NYAELM
{
std::array<uint32_t, 1> const c1 = {{ 0xB0F6 }};
std::array<uint32_t, 1> const c2 = {{ 0xB0F6 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1164, 0x11B1 }};
std::array<uint32_t, 1> const c4 = {{ 0xB0F6 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1164, 0x11B1 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_087)
{
// B0F7;B0F7;1102 1164 11B2;B0F7;1102 1164 11B2;
// (냷; 냷; 냷; 냷; 냷; ) HANGUL SYLLABLE NYAELB
{
std::array<uint32_t, 1> const c1 = {{ 0xB0F7 }};
std::array<uint32_t, 1> const c2 = {{ 0xB0F7 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1164, 0x11B2 }};
std::array<uint32_t, 1> const c4 = {{ 0xB0F7 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1164, 0x11B2 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_088)
{
// B0F8;B0F8;1102 1164 11B3;B0F8;1102 1164 11B3;
// (냸; 냸; 냸; 냸; 냸; ) HANGUL SYLLABLE NYAELS
{
std::array<uint32_t, 1> const c1 = {{ 0xB0F8 }};
std::array<uint32_t, 1> const c2 = {{ 0xB0F8 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1164, 0x11B3 }};
std::array<uint32_t, 1> const c4 = {{ 0xB0F8 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1164, 0x11B3 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_089)
{
// B0F9;B0F9;1102 1164 11B4;B0F9;1102 1164 11B4;
// (냹; 냹; 냹; 냹; 냹; ) HANGUL SYLLABLE NYAELT
{
std::array<uint32_t, 1> const c1 = {{ 0xB0F9 }};
std::array<uint32_t, 1> const c2 = {{ 0xB0F9 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1164, 0x11B4 }};
std::array<uint32_t, 1> const c4 = {{ 0xB0F9 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1164, 0x11B4 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_090)
{
// B0FA;B0FA;1102 1164 11B5;B0FA;1102 1164 11B5;
// (냺; 냺; 냺; 냺; 냺; ) HANGUL SYLLABLE NYAELP
{
std::array<uint32_t, 1> const c1 = {{ 0xB0FA }};
std::array<uint32_t, 1> const c2 = {{ 0xB0FA }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1164, 0x11B5 }};
std::array<uint32_t, 1> const c4 = {{ 0xB0FA }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1164, 0x11B5 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_091)
{
// B0FB;B0FB;1102 1164 11B6;B0FB;1102 1164 11B6;
// (냻; 냻; 냻; 냻; 냻; ) HANGUL SYLLABLE NYAELH
{
std::array<uint32_t, 1> const c1 = {{ 0xB0FB }};
std::array<uint32_t, 1> const c2 = {{ 0xB0FB }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1164, 0x11B6 }};
std::array<uint32_t, 1> const c4 = {{ 0xB0FB }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1164, 0x11B6 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_092)
{
// B0FC;B0FC;1102 1164 11B7;B0FC;1102 1164 11B7;
// (냼; 냼; 냼; 냼; 냼; ) HANGUL SYLLABLE NYAEM
{
std::array<uint32_t, 1> const c1 = {{ 0xB0FC }};
std::array<uint32_t, 1> const c2 = {{ 0xB0FC }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1164, 0x11B7 }};
std::array<uint32_t, 1> const c4 = {{ 0xB0FC }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1164, 0x11B7 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_093)
{
// B0FD;B0FD;1102 1164 11B8;B0FD;1102 1164 11B8;
// (냽; 냽; 냽; 냽; 냽; ) HANGUL SYLLABLE NYAEB
{
std::array<uint32_t, 1> const c1 = {{ 0xB0FD }};
std::array<uint32_t, 1> const c2 = {{ 0xB0FD }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1164, 0x11B8 }};
std::array<uint32_t, 1> const c4 = {{ 0xB0FD }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1164, 0x11B8 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_094)
{
// B0FE;B0FE;1102 1164 11B9;B0FE;1102 1164 11B9;
// (냾; 냾; 냾; 냾; 냾; ) HANGUL SYLLABLE NYAEBS
{
std::array<uint32_t, 1> const c1 = {{ 0xB0FE }};
std::array<uint32_t, 1> const c2 = {{ 0xB0FE }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1164, 0x11B9 }};
std::array<uint32_t, 1> const c4 = {{ 0xB0FE }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1164, 0x11B9 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_095)
{
// B0FF;B0FF;1102 1164 11BA;B0FF;1102 1164 11BA;
// (냿; 냿; 냿; 냿; 냿; ) HANGUL SYLLABLE NYAES
{
std::array<uint32_t, 1> const c1 = {{ 0xB0FF }};
std::array<uint32_t, 1> const c2 = {{ 0xB0FF }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1164, 0x11BA }};
std::array<uint32_t, 1> const c4 = {{ 0xB0FF }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1164, 0x11BA }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_096)
{
// B100;B100;1102 1164 11BB;B100;1102 1164 11BB;
// (넀; 넀; 넀; 넀; 넀; ) HANGUL SYLLABLE NYAESS
{
std::array<uint32_t, 1> const c1 = {{ 0xB100 }};
std::array<uint32_t, 1> const c2 = {{ 0xB100 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1164, 0x11BB }};
std::array<uint32_t, 1> const c4 = {{ 0xB100 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1164, 0x11BB }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_097)
{
// B101;B101;1102 1164 11BC;B101;1102 1164 11BC;
// (넁; 넁; 넁; 넁; 넁; ) HANGUL SYLLABLE NYAENG
{
std::array<uint32_t, 1> const c1 = {{ 0xB101 }};
std::array<uint32_t, 1> const c2 = {{ 0xB101 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1164, 0x11BC }};
std::array<uint32_t, 1> const c4 = {{ 0xB101 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1164, 0x11BC }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_098)
{
// B102;B102;1102 1164 11BD;B102;1102 1164 11BD;
// (넂; 넂; 넂; 넂; 넂; ) HANGUL SYLLABLE NYAEJ
{
std::array<uint32_t, 1> const c1 = {{ 0xB102 }};
std::array<uint32_t, 1> const c2 = {{ 0xB102 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1164, 0x11BD }};
std::array<uint32_t, 1> const c4 = {{ 0xB102 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1164, 0x11BD }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_099)
{
// B103;B103;1102 1164 11BE;B103;1102 1164 11BE;
// (넃; 넃; 넃; 넃; 넃; ) HANGUL SYLLABLE NYAEC
{
std::array<uint32_t, 1> const c1 = {{ 0xB103 }};
std::array<uint32_t, 1> const c2 = {{ 0xB103 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1164, 0x11BE }};
std::array<uint32_t, 1> const c4 = {{ 0xB103 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1164, 0x11BE }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_100)
{
// B104;B104;1102 1164 11BF;B104;1102 1164 11BF;
// (넄; 넄; 넄; 넄; 넄; ) HANGUL SYLLABLE NYAEK
{
std::array<uint32_t, 1> const c1 = {{ 0xB104 }};
std::array<uint32_t, 1> const c2 = {{ 0xB104 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1164, 0x11BF }};
std::array<uint32_t, 1> const c4 = {{ 0xB104 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1164, 0x11BF }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_101)
{
// B105;B105;1102 1164 11C0;B105;1102 1164 11C0;
// (넅; 넅; 넅; 넅; 넅; ) HANGUL SYLLABLE NYAET
{
std::array<uint32_t, 1> const c1 = {{ 0xB105 }};
std::array<uint32_t, 1> const c2 = {{ 0xB105 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1164, 0x11C0 }};
std::array<uint32_t, 1> const c4 = {{ 0xB105 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1164, 0x11C0 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_102)
{
// B106;B106;1102 1164 11C1;B106;1102 1164 11C1;
// (넆; 넆; 넆; 넆; 넆; ) HANGUL SYLLABLE NYAEP
{
std::array<uint32_t, 1> const c1 = {{ 0xB106 }};
std::array<uint32_t, 1> const c2 = {{ 0xB106 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1164, 0x11C1 }};
std::array<uint32_t, 1> const c4 = {{ 0xB106 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1164, 0x11C1 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_103)
{
// B107;B107;1102 1164 11C2;B107;1102 1164 11C2;
// (넇; 넇; 넇; 넇; 넇; ) HANGUL SYLLABLE NYAEH
{
std::array<uint32_t, 1> const c1 = {{ 0xB107 }};
std::array<uint32_t, 1> const c2 = {{ 0xB107 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1164, 0x11C2 }};
std::array<uint32_t, 1> const c4 = {{ 0xB107 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1164, 0x11C2 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_104)
{
// B108;B108;1102 1165;B108;1102 1165;
// (너; 너; 너; 너; 너; ) HANGUL SYLLABLE NEO
{
std::array<uint32_t, 1> const c1 = {{ 0xB108 }};
std::array<uint32_t, 1> const c2 = {{ 0xB108 }};
std::array<uint32_t, 2> const c3 = {{ 0x1102, 0x1165 }};
std::array<uint32_t, 1> const c4 = {{ 0xB108 }};
std::array<uint32_t, 2> const c5 = {{ 0x1102, 0x1165 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_105)
{
// B109;B109;1102 1165 11A8;B109;1102 1165 11A8;
// (넉; 넉; 넉; 넉; 넉; ) HANGUL SYLLABLE NEOG
{
std::array<uint32_t, 1> const c1 = {{ 0xB109 }};
std::array<uint32_t, 1> const c2 = {{ 0xB109 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1165, 0x11A8 }};
std::array<uint32_t, 1> const c4 = {{ 0xB109 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1165, 0x11A8 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_106)
{
// B10A;B10A;1102 1165 11A9;B10A;1102 1165 11A9;
// (넊; 넊; 넊; 넊; 넊; ) HANGUL SYLLABLE NEOGG
{
std::array<uint32_t, 1> const c1 = {{ 0xB10A }};
std::array<uint32_t, 1> const c2 = {{ 0xB10A }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1165, 0x11A9 }};
std::array<uint32_t, 1> const c4 = {{ 0xB10A }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1165, 0x11A9 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_107)
{
// B10B;B10B;1102 1165 11AA;B10B;1102 1165 11AA;
// (넋; 넋; 넋; 넋; 넋; ) HANGUL SYLLABLE NEOGS
{
std::array<uint32_t, 1> const c1 = {{ 0xB10B }};
std::array<uint32_t, 1> const c2 = {{ 0xB10B }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1165, 0x11AA }};
std::array<uint32_t, 1> const c4 = {{ 0xB10B }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1165, 0x11AA }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_108)
{
// B10C;B10C;1102 1165 11AB;B10C;1102 1165 11AB;
// (넌; 넌; 넌; 넌; 넌; ) HANGUL SYLLABLE NEON
{
std::array<uint32_t, 1> const c1 = {{ 0xB10C }};
std::array<uint32_t, 1> const c2 = {{ 0xB10C }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1165, 0x11AB }};
std::array<uint32_t, 1> const c4 = {{ 0xB10C }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1165, 0x11AB }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_109)
{
// B10D;B10D;1102 1165 11AC;B10D;1102 1165 11AC;
// (넍; 넍; 넍; 넍; 넍; ) HANGUL SYLLABLE NEONJ
{
std::array<uint32_t, 1> const c1 = {{ 0xB10D }};
std::array<uint32_t, 1> const c2 = {{ 0xB10D }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1165, 0x11AC }};
std::array<uint32_t, 1> const c4 = {{ 0xB10D }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1165, 0x11AC }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_110)
{
// B10E;B10E;1102 1165 11AD;B10E;1102 1165 11AD;
// (넎; 넎; 넎; 넎; 넎; ) HANGUL SYLLABLE NEONH
{
std::array<uint32_t, 1> const c1 = {{ 0xB10E }};
std::array<uint32_t, 1> const c2 = {{ 0xB10E }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1165, 0x11AD }};
std::array<uint32_t, 1> const c4 = {{ 0xB10E }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1165, 0x11AD }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_111)
{
// B10F;B10F;1102 1165 11AE;B10F;1102 1165 11AE;
// (넏; 넏; 넏; 넏; 넏; ) HANGUL SYLLABLE NEOD
{
std::array<uint32_t, 1> const c1 = {{ 0xB10F }};
std::array<uint32_t, 1> const c2 = {{ 0xB10F }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1165, 0x11AE }};
std::array<uint32_t, 1> const c4 = {{ 0xB10F }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1165, 0x11AE }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_112)
{
// B110;B110;1102 1165 11AF;B110;1102 1165 11AF;
// (널; 널; 널; 널; 널; ) HANGUL SYLLABLE NEOL
{
std::array<uint32_t, 1> const c1 = {{ 0xB110 }};
std::array<uint32_t, 1> const c2 = {{ 0xB110 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1165, 0x11AF }};
std::array<uint32_t, 1> const c4 = {{ 0xB110 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1165, 0x11AF }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_113)
{
// B111;B111;1102 1165 11B0;B111;1102 1165 11B0;
// (넑; 넑; 넑; 넑; 넑; ) HANGUL SYLLABLE NEOLG
{
std::array<uint32_t, 1> const c1 = {{ 0xB111 }};
std::array<uint32_t, 1> const c2 = {{ 0xB111 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1165, 0x11B0 }};
std::array<uint32_t, 1> const c4 = {{ 0xB111 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1165, 0x11B0 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_114)
{
// B112;B112;1102 1165 11B1;B112;1102 1165 11B1;
// (넒; 넒; 넒; 넒; 넒; ) HANGUL SYLLABLE NEOLM
{
std::array<uint32_t, 1> const c1 = {{ 0xB112 }};
std::array<uint32_t, 1> const c2 = {{ 0xB112 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1165, 0x11B1 }};
std::array<uint32_t, 1> const c4 = {{ 0xB112 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1165, 0x11B1 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_115)
{
// B113;B113;1102 1165 11B2;B113;1102 1165 11B2;
// (넓; 넓; 넓; 넓; 넓; ) HANGUL SYLLABLE NEOLB
{
std::array<uint32_t, 1> const c1 = {{ 0xB113 }};
std::array<uint32_t, 1> const c2 = {{ 0xB113 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1165, 0x11B2 }};
std::array<uint32_t, 1> const c4 = {{ 0xB113 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1165, 0x11B2 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_116)
{
// B114;B114;1102 1165 11B3;B114;1102 1165 11B3;
// (넔; 넔; 넔; 넔; 넔; ) HANGUL SYLLABLE NEOLS
{
std::array<uint32_t, 1> const c1 = {{ 0xB114 }};
std::array<uint32_t, 1> const c2 = {{ 0xB114 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1165, 0x11B3 }};
std::array<uint32_t, 1> const c4 = {{ 0xB114 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1165, 0x11B3 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_117)
{
// B115;B115;1102 1165 11B4;B115;1102 1165 11B4;
// (넕; 넕; 넕; 넕; 넕; ) HANGUL SYLLABLE NEOLT
{
std::array<uint32_t, 1> const c1 = {{ 0xB115 }};
std::array<uint32_t, 1> const c2 = {{ 0xB115 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1165, 0x11B4 }};
std::array<uint32_t, 1> const c4 = {{ 0xB115 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1165, 0x11B4 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_118)
{
// B116;B116;1102 1165 11B5;B116;1102 1165 11B5;
// (넖; 넖; 넖; 넖; 넖; ) HANGUL SYLLABLE NEOLP
{
std::array<uint32_t, 1> const c1 = {{ 0xB116 }};
std::array<uint32_t, 1> const c2 = {{ 0xB116 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1165, 0x11B5 }};
std::array<uint32_t, 1> const c4 = {{ 0xB116 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1165, 0x11B5 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_119)
{
// B117;B117;1102 1165 11B6;B117;1102 1165 11B6;
// (넗; 넗; 넗; 넗; 넗; ) HANGUL SYLLABLE NEOLH
{
std::array<uint32_t, 1> const c1 = {{ 0xB117 }};
std::array<uint32_t, 1> const c2 = {{ 0xB117 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1165, 0x11B6 }};
std::array<uint32_t, 1> const c4 = {{ 0xB117 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1165, 0x11B6 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_120)
{
// B118;B118;1102 1165 11B7;B118;1102 1165 11B7;
// (넘; 넘; 넘; 넘; 넘; ) HANGUL SYLLABLE NEOM
{
std::array<uint32_t, 1> const c1 = {{ 0xB118 }};
std::array<uint32_t, 1> const c2 = {{ 0xB118 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1165, 0x11B7 }};
std::array<uint32_t, 1> const c4 = {{ 0xB118 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1165, 0x11B7 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_121)
{
// B119;B119;1102 1165 11B8;B119;1102 1165 11B8;
// (넙; 넙; 넙; 넙; 넙; ) HANGUL SYLLABLE NEOB
{
std::array<uint32_t, 1> const c1 = {{ 0xB119 }};
std::array<uint32_t, 1> const c2 = {{ 0xB119 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1165, 0x11B8 }};
std::array<uint32_t, 1> const c4 = {{ 0xB119 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1165, 0x11B8 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_122)
{
// B11A;B11A;1102 1165 11B9;B11A;1102 1165 11B9;
// (넚; 넚; 넚; 넚; 넚; ) HANGUL SYLLABLE NEOBS
{
std::array<uint32_t, 1> const c1 = {{ 0xB11A }};
std::array<uint32_t, 1> const c2 = {{ 0xB11A }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1165, 0x11B9 }};
std::array<uint32_t, 1> const c4 = {{ 0xB11A }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1165, 0x11B9 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_123)
{
// B11B;B11B;1102 1165 11BA;B11B;1102 1165 11BA;
// (넛; 넛; 넛; 넛; 넛; ) HANGUL SYLLABLE NEOS
{
std::array<uint32_t, 1> const c1 = {{ 0xB11B }};
std::array<uint32_t, 1> const c2 = {{ 0xB11B }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1165, 0x11BA }};
std::array<uint32_t, 1> const c4 = {{ 0xB11B }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1165, 0x11BA }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_124)
{
// B11C;B11C;1102 1165 11BB;B11C;1102 1165 11BB;
// (넜; 넜; 넜; 넜; 넜; ) HANGUL SYLLABLE NEOSS
{
std::array<uint32_t, 1> const c1 = {{ 0xB11C }};
std::array<uint32_t, 1> const c2 = {{ 0xB11C }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1165, 0x11BB }};
std::array<uint32_t, 1> const c4 = {{ 0xB11C }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1165, 0x11BB }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_125)
{
// B11D;B11D;1102 1165 11BC;B11D;1102 1165 11BC;
// (넝; 넝; 넝; 넝; 넝; ) HANGUL SYLLABLE NEONG
{
std::array<uint32_t, 1> const c1 = {{ 0xB11D }};
std::array<uint32_t, 1> const c2 = {{ 0xB11D }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1165, 0x11BC }};
std::array<uint32_t, 1> const c4 = {{ 0xB11D }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1165, 0x11BC }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_126)
{
// B11E;B11E;1102 1165 11BD;B11E;1102 1165 11BD;
// (넞; 넞; 넞; 넞; 넞; ) HANGUL SYLLABLE NEOJ
{
std::array<uint32_t, 1> const c1 = {{ 0xB11E }};
std::array<uint32_t, 1> const c2 = {{ 0xB11E }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1165, 0x11BD }};
std::array<uint32_t, 1> const c4 = {{ 0xB11E }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1165, 0x11BD }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_127)
{
// B11F;B11F;1102 1165 11BE;B11F;1102 1165 11BE;
// (넟; 넟; 넟; 넟; 넟; ) HANGUL SYLLABLE NEOC
{
std::array<uint32_t, 1> const c1 = {{ 0xB11F }};
std::array<uint32_t, 1> const c2 = {{ 0xB11F }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1165, 0x11BE }};
std::array<uint32_t, 1> const c4 = {{ 0xB11F }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1165, 0x11BE }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_128)
{
// B120;B120;1102 1165 11BF;B120;1102 1165 11BF;
// (넠; 넠; 넠; 넠; 넠; ) HANGUL SYLLABLE NEOK
{
std::array<uint32_t, 1> const c1 = {{ 0xB120 }};
std::array<uint32_t, 1> const c2 = {{ 0xB120 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1165, 0x11BF }};
std::array<uint32_t, 1> const c4 = {{ 0xB120 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1165, 0x11BF }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_129)
{
// B121;B121;1102 1165 11C0;B121;1102 1165 11C0;
// (넡; 넡; 넡; 넡; 넡; ) HANGUL SYLLABLE NEOT
{
std::array<uint32_t, 1> const c1 = {{ 0xB121 }};
std::array<uint32_t, 1> const c2 = {{ 0xB121 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1165, 0x11C0 }};
std::array<uint32_t, 1> const c4 = {{ 0xB121 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1165, 0x11C0 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_130)
{
// B122;B122;1102 1165 11C1;B122;1102 1165 11C1;
// (넢; 넢; 넢; 넢; 넢; ) HANGUL SYLLABLE NEOP
{
std::array<uint32_t, 1> const c1 = {{ 0xB122 }};
std::array<uint32_t, 1> const c2 = {{ 0xB122 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1165, 0x11C1 }};
std::array<uint32_t, 1> const c4 = {{ 0xB122 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1165, 0x11C1 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_131)
{
// B123;B123;1102 1165 11C2;B123;1102 1165 11C2;
// (넣; 넣; 넣; 넣; 넣; ) HANGUL SYLLABLE NEOH
{
std::array<uint32_t, 1> const c1 = {{ 0xB123 }};
std::array<uint32_t, 1> const c2 = {{ 0xB123 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1165, 0x11C2 }};
std::array<uint32_t, 1> const c4 = {{ 0xB123 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1165, 0x11C2 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_132)
{
// B124;B124;1102 1166;B124;1102 1166;
// (네; 네; 네; 네; 네; ) HANGUL SYLLABLE NE
{
std::array<uint32_t, 1> const c1 = {{ 0xB124 }};
std::array<uint32_t, 1> const c2 = {{ 0xB124 }};
std::array<uint32_t, 2> const c3 = {{ 0x1102, 0x1166 }};
std::array<uint32_t, 1> const c4 = {{ 0xB124 }};
std::array<uint32_t, 2> const c5 = {{ 0x1102, 0x1166 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_133)
{
// B125;B125;1102 1166 11A8;B125;1102 1166 11A8;
// (넥; 넥; 넥; 넥; 넥; ) HANGUL SYLLABLE NEG
{
std::array<uint32_t, 1> const c1 = {{ 0xB125 }};
std::array<uint32_t, 1> const c2 = {{ 0xB125 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1166, 0x11A8 }};
std::array<uint32_t, 1> const c4 = {{ 0xB125 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1166, 0x11A8 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_134)
{
// B126;B126;1102 1166 11A9;B126;1102 1166 11A9;
// (넦; 넦; 넦; 넦; 넦; ) HANGUL SYLLABLE NEGG
{
std::array<uint32_t, 1> const c1 = {{ 0xB126 }};
std::array<uint32_t, 1> const c2 = {{ 0xB126 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1166, 0x11A9 }};
std::array<uint32_t, 1> const c4 = {{ 0xB126 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1166, 0x11A9 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_135)
{
// B127;B127;1102 1166 11AA;B127;1102 1166 11AA;
// (넧; 넧; 넧; 넧; 넧; ) HANGUL SYLLABLE NEGS
{
std::array<uint32_t, 1> const c1 = {{ 0xB127 }};
std::array<uint32_t, 1> const c2 = {{ 0xB127 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1166, 0x11AA }};
std::array<uint32_t, 1> const c4 = {{ 0xB127 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1166, 0x11AA }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_136)
{
// B128;B128;1102 1166 11AB;B128;1102 1166 11AB;
// (넨; 넨; 넨; 넨; 넨; ) HANGUL SYLLABLE NEN
{
std::array<uint32_t, 1> const c1 = {{ 0xB128 }};
std::array<uint32_t, 1> const c2 = {{ 0xB128 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1166, 0x11AB }};
std::array<uint32_t, 1> const c4 = {{ 0xB128 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1166, 0x11AB }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_137)
{
// B129;B129;1102 1166 11AC;B129;1102 1166 11AC;
// (넩; 넩; 넩; 넩; 넩; ) HANGUL SYLLABLE NENJ
{
std::array<uint32_t, 1> const c1 = {{ 0xB129 }};
std::array<uint32_t, 1> const c2 = {{ 0xB129 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1166, 0x11AC }};
std::array<uint32_t, 1> const c4 = {{ 0xB129 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1166, 0x11AC }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_138)
{
// B12A;B12A;1102 1166 11AD;B12A;1102 1166 11AD;
// (넪; 넪; 넪; 넪; 넪; ) HANGUL SYLLABLE NENH
{
std::array<uint32_t, 1> const c1 = {{ 0xB12A }};
std::array<uint32_t, 1> const c2 = {{ 0xB12A }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1166, 0x11AD }};
std::array<uint32_t, 1> const c4 = {{ 0xB12A }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1166, 0x11AD }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_139)
{
// B12B;B12B;1102 1166 11AE;B12B;1102 1166 11AE;
// (넫; 넫; 넫; 넫; 넫; ) HANGUL SYLLABLE NED
{
std::array<uint32_t, 1> const c1 = {{ 0xB12B }};
std::array<uint32_t, 1> const c2 = {{ 0xB12B }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1166, 0x11AE }};
std::array<uint32_t, 1> const c4 = {{ 0xB12B }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1166, 0x11AE }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_140)
{
// B12C;B12C;1102 1166 11AF;B12C;1102 1166 11AF;
// (넬; 넬; 넬; 넬; 넬; ) HANGUL SYLLABLE NEL
{
std::array<uint32_t, 1> const c1 = {{ 0xB12C }};
std::array<uint32_t, 1> const c2 = {{ 0xB12C }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1166, 0x11AF }};
std::array<uint32_t, 1> const c4 = {{ 0xB12C }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1166, 0x11AF }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_141)
{
// B12D;B12D;1102 1166 11B0;B12D;1102 1166 11B0;
// (넭; 넭; 넭; 넭; 넭; ) HANGUL SYLLABLE NELG
{
std::array<uint32_t, 1> const c1 = {{ 0xB12D }};
std::array<uint32_t, 1> const c2 = {{ 0xB12D }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1166, 0x11B0 }};
std::array<uint32_t, 1> const c4 = {{ 0xB12D }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1166, 0x11B0 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_142)
{
// B12E;B12E;1102 1166 11B1;B12E;1102 1166 11B1;
// (넮; 넮; 넮; 넮; 넮; ) HANGUL SYLLABLE NELM
{
std::array<uint32_t, 1> const c1 = {{ 0xB12E }};
std::array<uint32_t, 1> const c2 = {{ 0xB12E }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1166, 0x11B1 }};
std::array<uint32_t, 1> const c4 = {{ 0xB12E }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1166, 0x11B1 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_143)
{
// B12F;B12F;1102 1166 11B2;B12F;1102 1166 11B2;
// (넯; 넯; 넯; 넯; 넯; ) HANGUL SYLLABLE NELB
{
std::array<uint32_t, 1> const c1 = {{ 0xB12F }};
std::array<uint32_t, 1> const c2 = {{ 0xB12F }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1166, 0x11B2 }};
std::array<uint32_t, 1> const c4 = {{ 0xB12F }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1166, 0x11B2 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_144)
{
// B130;B130;1102 1166 11B3;B130;1102 1166 11B3;
// (넰; 넰; 넰; 넰; 넰; ) HANGUL SYLLABLE NELS
{
std::array<uint32_t, 1> const c1 = {{ 0xB130 }};
std::array<uint32_t, 1> const c2 = {{ 0xB130 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1166, 0x11B3 }};
std::array<uint32_t, 1> const c4 = {{ 0xB130 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1166, 0x11B3 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_145)
{
// B131;B131;1102 1166 11B4;B131;1102 1166 11B4;
// (넱; 넱; 넱; 넱; 넱; ) HANGUL SYLLABLE NELT
{
std::array<uint32_t, 1> const c1 = {{ 0xB131 }};
std::array<uint32_t, 1> const c2 = {{ 0xB131 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1166, 0x11B4 }};
std::array<uint32_t, 1> const c4 = {{ 0xB131 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1166, 0x11B4 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_146)
{
// B132;B132;1102 1166 11B5;B132;1102 1166 11B5;
// (넲; 넲; 넲; 넲; 넲; ) HANGUL SYLLABLE NELP
{
std::array<uint32_t, 1> const c1 = {{ 0xB132 }};
std::array<uint32_t, 1> const c2 = {{ 0xB132 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1166, 0x11B5 }};
std::array<uint32_t, 1> const c4 = {{ 0xB132 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1166, 0x11B5 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_147)
{
// B133;B133;1102 1166 11B6;B133;1102 1166 11B6;
// (넳; 넳; 넳; 넳; 넳; ) HANGUL SYLLABLE NELH
{
std::array<uint32_t, 1> const c1 = {{ 0xB133 }};
std::array<uint32_t, 1> const c2 = {{ 0xB133 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1166, 0x11B6 }};
std::array<uint32_t, 1> const c4 = {{ 0xB133 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1166, 0x11B6 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_148)
{
// B134;B134;1102 1166 11B7;B134;1102 1166 11B7;
// (넴; 넴; 넴; 넴; 넴; ) HANGUL SYLLABLE NEM
{
std::array<uint32_t, 1> const c1 = {{ 0xB134 }};
std::array<uint32_t, 1> const c2 = {{ 0xB134 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1166, 0x11B7 }};
std::array<uint32_t, 1> const c4 = {{ 0xB134 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1166, 0x11B7 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_149)
{
// B135;B135;1102 1166 11B8;B135;1102 1166 11B8;
// (넵; 넵; 넵; 넵; 넵; ) HANGUL SYLLABLE NEB
{
std::array<uint32_t, 1> const c1 = {{ 0xB135 }};
std::array<uint32_t, 1> const c2 = {{ 0xB135 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1166, 0x11B8 }};
std::array<uint32_t, 1> const c4 = {{ 0xB135 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1166, 0x11B8 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_150)
{
// B136;B136;1102 1166 11B9;B136;1102 1166 11B9;
// (넶; 넶; 넶; 넶; 넶; ) HANGUL SYLLABLE NEBS
{
std::array<uint32_t, 1> const c1 = {{ 0xB136 }};
std::array<uint32_t, 1> const c2 = {{ 0xB136 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1166, 0x11B9 }};
std::array<uint32_t, 1> const c4 = {{ 0xB136 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1166, 0x11B9 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_151)
{
// B137;B137;1102 1166 11BA;B137;1102 1166 11BA;
// (넷; 넷; 넷; 넷; 넷; ) HANGUL SYLLABLE NES
{
std::array<uint32_t, 1> const c1 = {{ 0xB137 }};
std::array<uint32_t, 1> const c2 = {{ 0xB137 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1166, 0x11BA }};
std::array<uint32_t, 1> const c4 = {{ 0xB137 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1166, 0x11BA }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_152)
{
// B138;B138;1102 1166 11BB;B138;1102 1166 11BB;
// (넸; 넸; 넸; 넸; 넸; ) HANGUL SYLLABLE NESS
{
std::array<uint32_t, 1> const c1 = {{ 0xB138 }};
std::array<uint32_t, 1> const c2 = {{ 0xB138 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1166, 0x11BB }};
std::array<uint32_t, 1> const c4 = {{ 0xB138 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1166, 0x11BB }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_153)
{
// B139;B139;1102 1166 11BC;B139;1102 1166 11BC;
// (넹; 넹; 넹; 넹; 넹; ) HANGUL SYLLABLE NENG
{
std::array<uint32_t, 1> const c1 = {{ 0xB139 }};
std::array<uint32_t, 1> const c2 = {{ 0xB139 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1166, 0x11BC }};
std::array<uint32_t, 1> const c4 = {{ 0xB139 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1166, 0x11BC }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_154)
{
// B13A;B13A;1102 1166 11BD;B13A;1102 1166 11BD;
// (넺; 넺; 넺; 넺; 넺; ) HANGUL SYLLABLE NEJ
{
std::array<uint32_t, 1> const c1 = {{ 0xB13A }};
std::array<uint32_t, 1> const c2 = {{ 0xB13A }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1166, 0x11BD }};
std::array<uint32_t, 1> const c4 = {{ 0xB13A }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1166, 0x11BD }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_155)
{
// B13B;B13B;1102 1166 11BE;B13B;1102 1166 11BE;
// (넻; 넻; 넻; 넻; 넻; ) HANGUL SYLLABLE NEC
{
std::array<uint32_t, 1> const c1 = {{ 0xB13B }};
std::array<uint32_t, 1> const c2 = {{ 0xB13B }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1166, 0x11BE }};
std::array<uint32_t, 1> const c4 = {{ 0xB13B }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1166, 0x11BE }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_156)
{
// B13C;B13C;1102 1166 11BF;B13C;1102 1166 11BF;
// (넼; 넼; 넼; 넼; 넼; ) HANGUL SYLLABLE NEK
{
std::array<uint32_t, 1> const c1 = {{ 0xB13C }};
std::array<uint32_t, 1> const c2 = {{ 0xB13C }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1166, 0x11BF }};
std::array<uint32_t, 1> const c4 = {{ 0xB13C }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1166, 0x11BF }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_157)
{
// B13D;B13D;1102 1166 11C0;B13D;1102 1166 11C0;
// (넽; 넽; 넽; 넽; 넽; ) HANGUL SYLLABLE NET
{
std::array<uint32_t, 1> const c1 = {{ 0xB13D }};
std::array<uint32_t, 1> const c2 = {{ 0xB13D }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1166, 0x11C0 }};
std::array<uint32_t, 1> const c4 = {{ 0xB13D }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1166, 0x11C0 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_158)
{
// B13E;B13E;1102 1166 11C1;B13E;1102 1166 11C1;
// (넾; 넾; 넾; 넾; 넾; ) HANGUL SYLLABLE NEP
{
std::array<uint32_t, 1> const c1 = {{ 0xB13E }};
std::array<uint32_t, 1> const c2 = {{ 0xB13E }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1166, 0x11C1 }};
std::array<uint32_t, 1> const c4 = {{ 0xB13E }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1166, 0x11C1 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_159)
{
// B13F;B13F;1102 1166 11C2;B13F;1102 1166 11C2;
// (넿; 넿; 넿; 넿; 넿; ) HANGUL SYLLABLE NEH
{
std::array<uint32_t, 1> const c1 = {{ 0xB13F }};
std::array<uint32_t, 1> const c2 = {{ 0xB13F }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1166, 0x11C2 }};
std::array<uint32_t, 1> const c4 = {{ 0xB13F }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1166, 0x11C2 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_160)
{
// B140;B140;1102 1167;B140;1102 1167;
// (녀; 녀; 녀; 녀; 녀; ) HANGUL SYLLABLE NYEO
{
std::array<uint32_t, 1> const c1 = {{ 0xB140 }};
std::array<uint32_t, 1> const c2 = {{ 0xB140 }};
std::array<uint32_t, 2> const c3 = {{ 0x1102, 0x1167 }};
std::array<uint32_t, 1> const c4 = {{ 0xB140 }};
std::array<uint32_t, 2> const c5 = {{ 0x1102, 0x1167 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_161)
{
// B141;B141;1102 1167 11A8;B141;1102 1167 11A8;
// (녁; 녁; 녁; 녁; 녁; ) HANGUL SYLLABLE NYEOG
{
std::array<uint32_t, 1> const c1 = {{ 0xB141 }};
std::array<uint32_t, 1> const c2 = {{ 0xB141 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1167, 0x11A8 }};
std::array<uint32_t, 1> const c4 = {{ 0xB141 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1167, 0x11A8 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_162)
{
// B142;B142;1102 1167 11A9;B142;1102 1167 11A9;
// (녂; 녂; 녂; 녂; 녂; ) HANGUL SYLLABLE NYEOGG
{
std::array<uint32_t, 1> const c1 = {{ 0xB142 }};
std::array<uint32_t, 1> const c2 = {{ 0xB142 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1167, 0x11A9 }};
std::array<uint32_t, 1> const c4 = {{ 0xB142 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1167, 0x11A9 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_163)
{
// B143;B143;1102 1167 11AA;B143;1102 1167 11AA;
// (녃; 녃; 녃; 녃; 녃; ) HANGUL SYLLABLE NYEOGS
{
std::array<uint32_t, 1> const c1 = {{ 0xB143 }};
std::array<uint32_t, 1> const c2 = {{ 0xB143 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1167, 0x11AA }};
std::array<uint32_t, 1> const c4 = {{ 0xB143 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1167, 0x11AA }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_164)
{
// B144;B144;1102 1167 11AB;B144;1102 1167 11AB;
// (년; 년; 년; 년; 년; ) HANGUL SYLLABLE NYEON
{
std::array<uint32_t, 1> const c1 = {{ 0xB144 }};
std::array<uint32_t, 1> const c2 = {{ 0xB144 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1167, 0x11AB }};
std::array<uint32_t, 1> const c4 = {{ 0xB144 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1167, 0x11AB }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_165)
{
// B145;B145;1102 1167 11AC;B145;1102 1167 11AC;
// (녅; 녅; 녅; 녅; 녅; ) HANGUL SYLLABLE NYEONJ
{
std::array<uint32_t, 1> const c1 = {{ 0xB145 }};
std::array<uint32_t, 1> const c2 = {{ 0xB145 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1167, 0x11AC }};
std::array<uint32_t, 1> const c4 = {{ 0xB145 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1167, 0x11AC }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_166)
{
// B146;B146;1102 1167 11AD;B146;1102 1167 11AD;
// (녆; 녆; 녆; 녆; 녆; ) HANGUL SYLLABLE NYEONH
{
std::array<uint32_t, 1> const c1 = {{ 0xB146 }};
std::array<uint32_t, 1> const c2 = {{ 0xB146 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1167, 0x11AD }};
std::array<uint32_t, 1> const c4 = {{ 0xB146 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1167, 0x11AD }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_167)
{
// B147;B147;1102 1167 11AE;B147;1102 1167 11AE;
// (녇; 녇; 녇; 녇; 녇; ) HANGUL SYLLABLE NYEOD
{
std::array<uint32_t, 1> const c1 = {{ 0xB147 }};
std::array<uint32_t, 1> const c2 = {{ 0xB147 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1167, 0x11AE }};
std::array<uint32_t, 1> const c4 = {{ 0xB147 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1167, 0x11AE }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_168)
{
// B148;B148;1102 1167 11AF;B148;1102 1167 11AF;
// (녈; 녈; 녈; 녈; 녈; ) HANGUL SYLLABLE NYEOL
{
std::array<uint32_t, 1> const c1 = {{ 0xB148 }};
std::array<uint32_t, 1> const c2 = {{ 0xB148 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1167, 0x11AF }};
std::array<uint32_t, 1> const c4 = {{ 0xB148 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1167, 0x11AF }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_169)
{
// B149;B149;1102 1167 11B0;B149;1102 1167 11B0;
// (녉; 녉; 녉; 녉; 녉; ) HANGUL SYLLABLE NYEOLG
{
std::array<uint32_t, 1> const c1 = {{ 0xB149 }};
std::array<uint32_t, 1> const c2 = {{ 0xB149 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1167, 0x11B0 }};
std::array<uint32_t, 1> const c4 = {{ 0xB149 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1167, 0x11B0 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_170)
{
// B14A;B14A;1102 1167 11B1;B14A;1102 1167 11B1;
// (녊; 녊; 녊; 녊; 녊; ) HANGUL SYLLABLE NYEOLM
{
std::array<uint32_t, 1> const c1 = {{ 0xB14A }};
std::array<uint32_t, 1> const c2 = {{ 0xB14A }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1167, 0x11B1 }};
std::array<uint32_t, 1> const c4 = {{ 0xB14A }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1167, 0x11B1 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_171)
{
// B14B;B14B;1102 1167 11B2;B14B;1102 1167 11B2;
// (녋; 녋; 녋; 녋; 녋; ) HANGUL SYLLABLE NYEOLB
{
std::array<uint32_t, 1> const c1 = {{ 0xB14B }};
std::array<uint32_t, 1> const c2 = {{ 0xB14B }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1167, 0x11B2 }};
std::array<uint32_t, 1> const c4 = {{ 0xB14B }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1167, 0x11B2 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_172)
{
// B14C;B14C;1102 1167 11B3;B14C;1102 1167 11B3;
// (녌; 녌; 녌; 녌; 녌; ) HANGUL SYLLABLE NYEOLS
{
std::array<uint32_t, 1> const c1 = {{ 0xB14C }};
std::array<uint32_t, 1> const c2 = {{ 0xB14C }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1167, 0x11B3 }};
std::array<uint32_t, 1> const c4 = {{ 0xB14C }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1167, 0x11B3 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_173)
{
// B14D;B14D;1102 1167 11B4;B14D;1102 1167 11B4;
// (녍; 녍; 녍; 녍; 녍; ) HANGUL SYLLABLE NYEOLT
{
std::array<uint32_t, 1> const c1 = {{ 0xB14D }};
std::array<uint32_t, 1> const c2 = {{ 0xB14D }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1167, 0x11B4 }};
std::array<uint32_t, 1> const c4 = {{ 0xB14D }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1167, 0x11B4 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_174)
{
// B14E;B14E;1102 1167 11B5;B14E;1102 1167 11B5;
// (녎; 녎; 녎; 녎; 녎; ) HANGUL SYLLABLE NYEOLP
{
std::array<uint32_t, 1> const c1 = {{ 0xB14E }};
std::array<uint32_t, 1> const c2 = {{ 0xB14E }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1167, 0x11B5 }};
std::array<uint32_t, 1> const c4 = {{ 0xB14E }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1167, 0x11B5 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_175)
{
// B14F;B14F;1102 1167 11B6;B14F;1102 1167 11B6;
// (녏; 녏; 녏; 녏; 녏; ) HANGUL SYLLABLE NYEOLH
{
std::array<uint32_t, 1> const c1 = {{ 0xB14F }};
std::array<uint32_t, 1> const c2 = {{ 0xB14F }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1167, 0x11B6 }};
std::array<uint32_t, 1> const c4 = {{ 0xB14F }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1167, 0x11B6 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_176)
{
// B150;B150;1102 1167 11B7;B150;1102 1167 11B7;
// (념; 념; 념; 념; 념; ) HANGUL SYLLABLE NYEOM
{
std::array<uint32_t, 1> const c1 = {{ 0xB150 }};
std::array<uint32_t, 1> const c2 = {{ 0xB150 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1167, 0x11B7 }};
std::array<uint32_t, 1> const c4 = {{ 0xB150 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1167, 0x11B7 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_177)
{
// B151;B151;1102 1167 11B8;B151;1102 1167 11B8;
// (녑; 녑; 녑; 녑; 녑; ) HANGUL SYLLABLE NYEOB
{
std::array<uint32_t, 1> const c1 = {{ 0xB151 }};
std::array<uint32_t, 1> const c2 = {{ 0xB151 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1167, 0x11B8 }};
std::array<uint32_t, 1> const c4 = {{ 0xB151 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1167, 0x11B8 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_178)
{
// B152;B152;1102 1167 11B9;B152;1102 1167 11B9;
// (녒; 녒; 녒; 녒; 녒; ) HANGUL SYLLABLE NYEOBS
{
std::array<uint32_t, 1> const c1 = {{ 0xB152 }};
std::array<uint32_t, 1> const c2 = {{ 0xB152 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1167, 0x11B9 }};
std::array<uint32_t, 1> const c4 = {{ 0xB152 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1167, 0x11B9 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_179)
{
// B153;B153;1102 1167 11BA;B153;1102 1167 11BA;
// (녓; 녓; 녓; 녓; 녓; ) HANGUL SYLLABLE NYEOS
{
std::array<uint32_t, 1> const c1 = {{ 0xB153 }};
std::array<uint32_t, 1> const c2 = {{ 0xB153 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1167, 0x11BA }};
std::array<uint32_t, 1> const c4 = {{ 0xB153 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1167, 0x11BA }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_180)
{
// B154;B154;1102 1167 11BB;B154;1102 1167 11BB;
// (녔; 녔; 녔; 녔; 녔; ) HANGUL SYLLABLE NYEOSS
{
std::array<uint32_t, 1> const c1 = {{ 0xB154 }};
std::array<uint32_t, 1> const c2 = {{ 0xB154 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1167, 0x11BB }};
std::array<uint32_t, 1> const c4 = {{ 0xB154 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1167, 0x11BB }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_181)
{
// B155;B155;1102 1167 11BC;B155;1102 1167 11BC;
// (녕; 녕; 녕; 녕; 녕; ) HANGUL SYLLABLE NYEONG
{
std::array<uint32_t, 1> const c1 = {{ 0xB155 }};
std::array<uint32_t, 1> const c2 = {{ 0xB155 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1167, 0x11BC }};
std::array<uint32_t, 1> const c4 = {{ 0xB155 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1167, 0x11BC }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_182)
{
// B156;B156;1102 1167 11BD;B156;1102 1167 11BD;
// (녖; 녖; 녖; 녖; 녖; ) HANGUL SYLLABLE NYEOJ
{
std::array<uint32_t, 1> const c1 = {{ 0xB156 }};
std::array<uint32_t, 1> const c2 = {{ 0xB156 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1167, 0x11BD }};
std::array<uint32_t, 1> const c4 = {{ 0xB156 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1167, 0x11BD }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_183)
{
// B157;B157;1102 1167 11BE;B157;1102 1167 11BE;
// (녗; 녗; 녗; 녗; 녗; ) HANGUL SYLLABLE NYEOC
{
std::array<uint32_t, 1> const c1 = {{ 0xB157 }};
std::array<uint32_t, 1> const c2 = {{ 0xB157 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1167, 0x11BE }};
std::array<uint32_t, 1> const c4 = {{ 0xB157 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1167, 0x11BE }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_184)
{
// B158;B158;1102 1167 11BF;B158;1102 1167 11BF;
// (녘; 녘; 녘; 녘; 녘; ) HANGUL SYLLABLE NYEOK
{
std::array<uint32_t, 1> const c1 = {{ 0xB158 }};
std::array<uint32_t, 1> const c2 = {{ 0xB158 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1167, 0x11BF }};
std::array<uint32_t, 1> const c4 = {{ 0xB158 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1167, 0x11BF }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_185)
{
// B159;B159;1102 1167 11C0;B159;1102 1167 11C0;
// (녙; 녙; 녙; 녙; 녙; ) HANGUL SYLLABLE NYEOT
{
std::array<uint32_t, 1> const c1 = {{ 0xB159 }};
std::array<uint32_t, 1> const c2 = {{ 0xB159 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1167, 0x11C0 }};
std::array<uint32_t, 1> const c4 = {{ 0xB159 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1167, 0x11C0 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_186)
{
// B15A;B15A;1102 1167 11C1;B15A;1102 1167 11C1;
// (녚; 녚; 녚; 녚; 녚; ) HANGUL SYLLABLE NYEOP
{
std::array<uint32_t, 1> const c1 = {{ 0xB15A }};
std::array<uint32_t, 1> const c2 = {{ 0xB15A }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1167, 0x11C1 }};
std::array<uint32_t, 1> const c4 = {{ 0xB15A }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1167, 0x11C1 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_187)
{
// B15B;B15B;1102 1167 11C2;B15B;1102 1167 11C2;
// (녛; 녛; 녛; 녛; 녛; ) HANGUL SYLLABLE NYEOH
{
std::array<uint32_t, 1> const c1 = {{ 0xB15B }};
std::array<uint32_t, 1> const c2 = {{ 0xB15B }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1167, 0x11C2 }};
std::array<uint32_t, 1> const c4 = {{ 0xB15B }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1167, 0x11C2 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_188)
{
// B15C;B15C;1102 1168;B15C;1102 1168;
// (녜; 녜; 녜; 녜; 녜; ) HANGUL SYLLABLE NYE
{
std::array<uint32_t, 1> const c1 = {{ 0xB15C }};
std::array<uint32_t, 1> const c2 = {{ 0xB15C }};
std::array<uint32_t, 2> const c3 = {{ 0x1102, 0x1168 }};
std::array<uint32_t, 1> const c4 = {{ 0xB15C }};
std::array<uint32_t, 2> const c5 = {{ 0x1102, 0x1168 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_189)
{
// B15D;B15D;1102 1168 11A8;B15D;1102 1168 11A8;
// (녝; 녝; 녝; 녝; 녝; ) HANGUL SYLLABLE NYEG
{
std::array<uint32_t, 1> const c1 = {{ 0xB15D }};
std::array<uint32_t, 1> const c2 = {{ 0xB15D }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1168, 0x11A8 }};
std::array<uint32_t, 1> const c4 = {{ 0xB15D }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1168, 0x11A8 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_190)
{
// B15E;B15E;1102 1168 11A9;B15E;1102 1168 11A9;
// (녞; 녞; 녞; 녞; 녞; ) HANGUL SYLLABLE NYEGG
{
std::array<uint32_t, 1> const c1 = {{ 0xB15E }};
std::array<uint32_t, 1> const c2 = {{ 0xB15E }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1168, 0x11A9 }};
std::array<uint32_t, 1> const c4 = {{ 0xB15E }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1168, 0x11A9 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_191)
{
// B15F;B15F;1102 1168 11AA;B15F;1102 1168 11AA;
// (녟; 녟; 녟; 녟; 녟; ) HANGUL SYLLABLE NYEGS
{
std::array<uint32_t, 1> const c1 = {{ 0xB15F }};
std::array<uint32_t, 1> const c2 = {{ 0xB15F }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1168, 0x11AA }};
std::array<uint32_t, 1> const c4 = {{ 0xB15F }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1168, 0x11AA }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_192)
{
// B160;B160;1102 1168 11AB;B160;1102 1168 11AB;
// (녠; 녠; 녠; 녠; 녠; ) HANGUL SYLLABLE NYEN
{
std::array<uint32_t, 1> const c1 = {{ 0xB160 }};
std::array<uint32_t, 1> const c2 = {{ 0xB160 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1168, 0x11AB }};
std::array<uint32_t, 1> const c4 = {{ 0xB160 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1168, 0x11AB }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_193)
{
// B161;B161;1102 1168 11AC;B161;1102 1168 11AC;
// (녡; 녡; 녡; 녡; 녡; ) HANGUL SYLLABLE NYENJ
{
std::array<uint32_t, 1> const c1 = {{ 0xB161 }};
std::array<uint32_t, 1> const c2 = {{ 0xB161 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1168, 0x11AC }};
std::array<uint32_t, 1> const c4 = {{ 0xB161 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1168, 0x11AC }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_194)
{
// B162;B162;1102 1168 11AD;B162;1102 1168 11AD;
// (녢; 녢; 녢; 녢; 녢; ) HANGUL SYLLABLE NYENH
{
std::array<uint32_t, 1> const c1 = {{ 0xB162 }};
std::array<uint32_t, 1> const c2 = {{ 0xB162 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1168, 0x11AD }};
std::array<uint32_t, 1> const c4 = {{ 0xB162 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1168, 0x11AD }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_195)
{
// B163;B163;1102 1168 11AE;B163;1102 1168 11AE;
// (녣; 녣; 녣; 녣; 녣; ) HANGUL SYLLABLE NYED
{
std::array<uint32_t, 1> const c1 = {{ 0xB163 }};
std::array<uint32_t, 1> const c2 = {{ 0xB163 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1168, 0x11AE }};
std::array<uint32_t, 1> const c4 = {{ 0xB163 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1168, 0x11AE }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_196)
{
// B164;B164;1102 1168 11AF;B164;1102 1168 11AF;
// (녤; 녤; 녤; 녤; 녤; ) HANGUL SYLLABLE NYEL
{
std::array<uint32_t, 1> const c1 = {{ 0xB164 }};
std::array<uint32_t, 1> const c2 = {{ 0xB164 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1168, 0x11AF }};
std::array<uint32_t, 1> const c4 = {{ 0xB164 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1168, 0x11AF }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_197)
{
// B165;B165;1102 1168 11B0;B165;1102 1168 11B0;
// (녥; 녥; 녥; 녥; 녥; ) HANGUL SYLLABLE NYELG
{
std::array<uint32_t, 1> const c1 = {{ 0xB165 }};
std::array<uint32_t, 1> const c2 = {{ 0xB165 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1168, 0x11B0 }};
std::array<uint32_t, 1> const c4 = {{ 0xB165 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1168, 0x11B0 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_198)
{
// B166;B166;1102 1168 11B1;B166;1102 1168 11B1;
// (녦; 녦; 녦; 녦; 녦; ) HANGUL SYLLABLE NYELM
{
std::array<uint32_t, 1> const c1 = {{ 0xB166 }};
std::array<uint32_t, 1> const c2 = {{ 0xB166 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1168, 0x11B1 }};
std::array<uint32_t, 1> const c4 = {{ 0xB166 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1168, 0x11B1 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
TEST(normalization, nfkc_018_199)
{
// B167;B167;1102 1168 11B2;B167;1102 1168 11B2;
// (녧; 녧; 녧; 녧; 녧; ) HANGUL SYLLABLE NYELB
{
std::array<uint32_t, 1> const c1 = {{ 0xB167 }};
std::array<uint32_t, 1> const c2 = {{ 0xB167 }};
std::array<uint32_t, 3> const c3 = {{ 0x1102, 0x1168, 0x11B2 }};
std::array<uint32_t, 1> const c4 = {{ 0xB167 }};
std::array<uint32_t, 3> const c5 = {{ 0x1102, 0x1168, 0x11B2 }};
EXPECT_TRUE(boost::text::normalized_nfc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c2.begin(), c2.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c3.begin(), c3.end()));
EXPECT_TRUE(boost::text::normalized_nfc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfkc(c4.begin(), c4.end()));
EXPECT_TRUE(boost::text::normalized_nfd(c5.begin(), c5.end()));
EXPECT_TRUE(boost::text::normalized_nfkd(c5.begin(), c5.end()));
{
boost::text::string str = boost::text::to_string(c1.begin(), c1.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c2.begin(), c2.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c3.begin(), c3.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c4.begin(), c4.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
{
boost::text::string str = boost::text::to_string(c5.begin(), c5.end());
boost::text::normalize_to_nfkc(str);
boost::text::utf32_range utf32_range(str);
EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size());
auto c4_it = c4.begin();
int i = 0;
for (auto x : utf32_range) {
EXPECT_EQ(x, *c4_it) << "iteration " << i;
++c4_it;
++i;
}
}
}
}
| 36.85216 | 88 | 0.500888 | jan-moeller |
240801f7d228a5b63f027555fe651fb67be580cf | 7,466 | cpp | C++ | ql/experimental/math/convolvedstudentt.cpp | mshojatalab/QuantLib | 7801a0fb3226bc1b001e310bacdd35ddb2e51661 | [
"BSD-3-Clause"
] | null | null | null | ql/experimental/math/convolvedstudentt.cpp | mshojatalab/QuantLib | 7801a0fb3226bc1b001e310bacdd35ddb2e51661 | [
"BSD-3-Clause"
] | 1 | 2022-02-24T02:22:30.000Z | 2022-02-24T02:22:30.000Z | ql/experimental/math/convolvedstudentt.cpp | sweemer/QuantLib | 1341223e3d839dd77bb7231d0913809f01437740 | [
"BSD-3-Clause"
] | null | null | null | /* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
Copyright (C) 2014 Jose Aparicio
This file is part of QuantLib, a free-software/open-source library
for financial quantitative analysts and developers - http://quantlib.org/
QuantLib is free software: you can redistribute it and/or modify it
under the terms of the QuantLib license. You should have received a
copy of the license along with this program; if not, please email
<[email protected]>. The license is also available online at
<http://quantlib.org/license.shtml>.
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the license for more details.
*/
#include <ql/experimental/math/convolvedstudentt.hpp>
#include <ql/errors.hpp>
#include <ql/math/factorial.hpp>
#include <ql/math/distributions/normaldistribution.hpp>
#include <ql/math/solvers1d/brent.hpp>
#include <ql/math/functional.hpp>
#if defined(__GNUC__) && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 8)) || (__GNUC__ > 4))
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-local-typedefs"
#endif
#include <boost/math/distributions/students_t.hpp>
#if defined(__GNUC__) && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 8)) || (__GNUC__ > 4))
#pragma GCC diagnostic pop
#endif
namespace QuantLib {
CumulativeBehrensFisher::CumulativeBehrensFisher(const std::vector<Integer>& degreesFreedom,
const std::vector<Real>& factors)
: degreesFreedom_(degreesFreedom), factors_(factors), polyConvolved_(std::vector<Real>(1, 1.))
{
QL_REQUIRE(degreesFreedom.size() == factors.size(),
"Incompatible sizes in convolution.");
for (int i : degreesFreedom) {
QL_REQUIRE(i % 2 != 0, "Even degree of freedom not allowed");
QL_REQUIRE(i >= 0, "Negative degree of freedom not allowed");
}
for(Size i=0; i<degreesFreedom_.size(); i++)
polynCharFnc_.push_back(polynCharactT((degreesFreedom[i]-1)/2));
// adjust the polynomial coefficients by the factors in the linear
// combination:
for(Size i=0; i<degreesFreedom_.size(); i++) {
Real multiplier = 1.;
for(Size k=1; k<polynCharFnc_[i].size(); k++) {
multiplier *= std::abs(factors_[i]);
polynCharFnc_[i][k] *= multiplier;
}
}
//convolution, here it is a product of polynomials and exponentials
for (auto& i : polynCharFnc_)
polyConvolved_ = convolveVectorPolynomials(polyConvolved_, i);
// trim possible zeros that might have arised:
auto it = polyConvolved_.rbegin();
while (it != polyConvolved_.rend()) {
if (*it == 0.) {
polyConvolved_.pop_back();
it = polyConvolved_.rbegin();
}else{
break;
}
}
// cache 'a' value (the exponent)
for(Size i=0; i<degreesFreedom_.size(); i++)
a_ += std::sqrt(static_cast<Real>(degreesFreedom_[i]))
* std::abs(factors_[i]);
a2_ = a_ * a_;
}
std::vector<Real> CumulativeBehrensFisher::polynCharactT(Natural n) const {
Natural nu = 2 * n +1;
std::vector<Real> low(1,1.), high(1,1.);
high.push_back(std::sqrt(static_cast<Real>(nu)));
if(n==0) return low;
if(n==1) return high;
for(Size k=1; k<n; k++) {
std::vector<Real> recursionFactor(1,0.); // 0 coef
recursionFactor.push_back(0.); // 1 coef
recursionFactor.push_back(nu/((2.*k+1.)*(2.*k-1.))); // 2 coef
std::vector<Real> lowUp =
convolveVectorPolynomials(recursionFactor, low);
//add them up:
for(Size i=0; i<high.size(); i++)
lowUp[i] += high[i];
low = high;
high = lowUp;
}
return high;
}
std::vector<Real> CumulativeBehrensFisher::convolveVectorPolynomials(
const std::vector<Real>& v1,
const std::vector<Real>& v2) const {
#if defined(QL_EXTRA_SAFETY_CHECKS)
QL_REQUIRE(!v1.empty() && !v2.empty(),
"Incorrect vectors in polynomial.");
#endif
const std::vector<Real>& shorter = v1.size() < v2.size() ? v1 : v2;
const std::vector<Real>& longer = (v1 == shorter) ? v2 : v1;
Size newDegree = v1.size()+v2.size()-2;
std::vector<Real> resultB(newDegree+1, 0.);
for(Size polyOrdr=0; polyOrdr<resultB.size(); polyOrdr++) {
for(Size i=std::max<Integer>(0, polyOrdr-longer.size()+1);
i<=std::min(polyOrdr, shorter.size()-1); i++)
resultB[polyOrdr] += shorter[i]*longer[polyOrdr-i];
}
return resultB;
}
Probability CumulativeBehrensFisher::operator()(const Real x) const {
// 1st & 0th terms with the table integration
Real integral = polyConvolved_[0] * std::atan(x/a_);
Real squared = a2_ + x*x;
Real rootsqr = std::sqrt(squared);
Real atan2xa = std::atan2(-x,a_);
if(polyConvolved_.size()>1)
integral += polyConvolved_[1] * x/squared;
for(Size exponent = 2; exponent <polyConvolved_.size(); exponent++) {
integral -= polyConvolved_[exponent] *
Factorial::get(exponent-1) * std::sin((exponent)*atan2xa)
/std::pow(rootsqr, static_cast<Real>(exponent));
}
return .5 + integral / M_PI;
}
Probability
CumulativeBehrensFisher::density(const Real x) const {
Real squared = a2_ + x*x;
Real integral = polyConvolved_[0] * a_ / squared;
Real rootsqr = std::sqrt(squared);
Real atan2xa = std::atan2(-x,a_);
for(Size exponent=1; exponent <polyConvolved_.size(); exponent++) {
integral += polyConvolved_[exponent] *
Factorial::get(exponent) * std::cos((exponent+1)*atan2xa)
/std::pow(rootsqr, static_cast<Real>(exponent+1) );
}
return integral / M_PI;
}
InverseCumulativeBehrensFisher::InverseCumulativeBehrensFisher(
const std::vector<Integer>& degreesFreedom,
const std::vector<Real>& factors,
Real accuracy)
: normSqr_(std::inner_product(factors.begin(), factors.end(),
factors.begin(), 0.)),
accuracy_(accuracy), distrib_(degreesFreedom, factors) { }
Real InverseCumulativeBehrensFisher::operator()(const Probability q) const {
Probability effectiveq;
Real sign;
// since the distrib is symmetric solve only on the right side:
if(q==0.5) {
return 0.;
}else if(q < 0.5) {
sign = -1.;
effectiveq = 1.-q;
}else{
sign = 1.;
effectiveq = q;
}
Real xMin =
InverseCumulativeNormal::standard_value(effectiveq) * normSqr_;
// inversion will fail at the Brent's bounds-check if this is not enough
// (q is very close to 1.), in a bad combination fails around 1.-1.e-7
Real xMax = 1.e6;
return sign *
Brent().solve([&](Real x){ return distrib_(x) - effectiveq; },
accuracy_, (xMin+xMax)/2., xMin, xMax);
}
}
| 39.712766 | 98 | 0.590008 | mshojatalab |
24098da66848085bd93b0932879a148d792798be | 1,169 | cpp | C++ | samples/snippets/cpp/VS_Snippets_CLR/Thread.GetSetTrySetApartmentState/cpp/source.cpp | hamarb123/dotnet-api-docs | 6aeb55784944a2f1f5e773b657791cbd73a92dd4 | [
"CC-BY-4.0",
"MIT"
] | 421 | 2018-04-01T01:57:50.000Z | 2022-03-28T15:24:42.000Z | samples/snippets/cpp/VS_Snippets_CLR/Thread.GetSetTrySetApartmentState/cpp/source.cpp | hamarb123/dotnet-api-docs | 6aeb55784944a2f1f5e773b657791cbd73a92dd4 | [
"CC-BY-4.0",
"MIT"
] | 5,797 | 2018-04-02T21:12:23.000Z | 2022-03-31T23:54:38.000Z | samples/snippets/cpp/VS_Snippets_CLR/Thread.GetSetTrySetApartmentState/cpp/source.cpp | hamarb123/dotnet-api-docs | 6aeb55784944a2f1f5e773b657791cbd73a92dd4 | [
"CC-BY-4.0",
"MIT"
] | 1,482 | 2018-03-31T11:26:20.000Z | 2022-03-30T22:36:45.000Z | //<Snippet1>
using namespace System;
using namespace System::Threading;
void ThreadProc()
{
Thread::Sleep(2000);
};
void main()
{
Thread^ t = gcnew Thread(gcnew ThreadStart(ThreadProc));
Console::WriteLine("Before setting apartment state: {0}",
t->GetApartmentState());
t->SetApartmentState(ApartmentState::STA);
Console::WriteLine("After setting apartment state: {0}",
t->GetApartmentState());
bool result = t->TrySetApartmentState(ApartmentState::MTA);
Console::WriteLine("Try to change state: {0}", result);
t->Start();
Thread::Sleep(500);
try
{
t->TrySetApartmentState(ApartmentState::STA);
}
catch (ThreadStateException^)
{
Console::WriteLine("ThreadStateException occurs " +
"if apartment state is set after starting thread.");
}
t->Join();
}
/* This code example produces the following output:
Before setting apartment state: Unknown
After setting apartment state: STA
Try to change state: False
ThreadStateException occurs if apartment state is set after starting thread.
*/
//</Snippet1>
| 24.354167 | 77 | 0.645851 | hamarb123 |
240d0bd98074ecfc35e23fee72c00e6de7406f84 | 19,435 | hpp | C++ | domain/include/cstone/tree/octree_internal.hpp | lks1248/SPH-EXA | af6d2307f022a1892606008e290ab9cba6f683f7 | [
"MIT"
] | 16 | 2022-01-17T19:50:38.000Z | 2022-03-28T08:09:58.000Z | domain/include/cstone/tree/octree_internal.hpp | sguera/SPH-EXA_mini-app | 0cac399d43118bda1ed2a5e42b593eb18ca55c30 | [
"MIT"
] | 33 | 2021-12-06T12:42:41.000Z | 2022-03-31T10:56:49.000Z | domain/include/cstone/tree/octree_internal.hpp | sguera/SPH-EXA_mini-app | 0cac399d43118bda1ed2a5e42b593eb18ca55c30 | [
"MIT"
] | 13 | 2021-12-06T09:12:52.000Z | 2022-03-28T08:07:38.000Z | /*
* MIT License
*
* Copyright (c) 2021 CSCS, ETH Zurich
* 2021 University of Basel
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
/*! @file
* @brief Compute the internal part of a cornerstone octree
*
* @author Sebastian Keller <[email protected]>
*
* General algorithm:
* cornerstone octree (leaves) -> internal binary radix tree -> internal octree
*
* Like the cornerstone octree, the internal octree is stored in a linear memory layout
* with tree nodes placed next to each other in a single buffer. Construction
* is fully parallel and non-recursive and non-iterative. Traversal is possible non-recursively
* in an iterative fashion with a local stack.
*/
#pragma once
#include <iterator>
#include <vector>
#include "cstone/cuda/annotation.hpp"
#include "cstone/primitives/gather.hpp"
#include "cstone/sfc/sfc.hpp"
#include "cstone/tree/octree.hpp"
#include "cstone/util/gsl-lite.hpp"
namespace cstone
{
/*! @brief map a binary node index to an octree node index
*
* @tparam KeyType 32- or 64-bit unsigned integer
* @param key a cornerstone leaf cell key
* @param level the subdivision level of @p key
* @return the index offset
*
* if
* - cstree is a cornerstone leaf array
* - l = commonPrefix(cstree[j], cstree[j+1]), l % 3 == 0
* - k = cstree[j]
*
* then i = (j + binaryKeyWeight(k, l) / 7 equals the index of the internal octree node with key k,
* see unit test of this function for an illustration
*/
template<class KeyType>
HOST_DEVICE_FUN constexpr TreeNodeIndex binaryKeyWeight(KeyType key, unsigned level)
{
TreeNodeIndex ret = 0;
for (unsigned l = 1; l <= level + 1; ++l)
{
unsigned digit = octalDigit(key, l);
ret += digitWeight(digit);
}
return ret;
}
/*! @brief combine internal and leaf tree parts into a single array with the nodeKey prefixes
*
* @tparam KeyType unsigned 32- or 64-bit integer
* @param[in] leaves cornerstone SFC keys, length numLeafNodes + 1
* @param[in] numInternalNodes number of internal octree nodes
* @param[in] numLeafNodes total number of nodes
* @param[in] binaryToOct translation map from binary to octree nodes
* @param[out] prefixes output octree SFC keys, length @p numInternalNodes + numLeafNodes
* NOTE: keys are prefixed with Warren-Salmon placeholder bits!
* @param[out] internalToLeaf iota 0,1,2,3,... sequence for later use, length same as @p prefixes
*/
template<class KeyType>
void createUnsortedLayoutCpu(const KeyType* leaves,
TreeNodeIndex numInternalNodes,
TreeNodeIndex numLeafNodes,
KeyType* prefixes,
TreeNodeIndex* internalToLeaf)
{
#pragma omp parallel for schedule(static)
for (TreeNodeIndex tid = 0; tid < numLeafNodes; ++tid)
{
KeyType key = leaves[tid];
unsigned level = treeLevel(leaves[tid + 1] - key);
prefixes[tid + numInternalNodes] = encodePlaceholderBit(key, 3 * level);
internalToLeaf[tid + numInternalNodes] = tid + numInternalNodes;
unsigned prefixLength = commonPrefix(key, leaves[tid + 1]);
if (prefixLength % 3 == 0 && tid < numLeafNodes - 1)
{
TreeNodeIndex octIndex = (tid + binaryKeyWeight(key, prefixLength / 3)) / 7;
prefixes[octIndex] = encodePlaceholderBit(key, prefixLength);
internalToLeaf[octIndex] = octIndex;
}
}
}
/*! @brief extract parent/child relationships from binary tree and translate to sorted order
*
* @tparam KeyType unsigned 32- or 64-bit integer
* @param[in] prefixes octree node prefixes in Warren-Salmon format
* @param[in] numInternalNodes number of internal octree nodes
* @param[in] leafToInternal translation map from unsorted layout to level/SFC sorted octree layout
* length is total number of octree nodes, internal + leaves
* @param[in] levelRange indices of the first node at each level
* @param[out] childOffsets octree node index of first child for each node, length is total number of nodes
* @param[out] parents parent index of for each node which is the first of 8 siblings
* i.e. the parent of node i is stored at parents[(i - 1)/8]
*/
template<class KeyType>
void linkTreeCpu(const KeyType* prefixes,
TreeNodeIndex numInternalNodes,
const TreeNodeIndex* leafToInternal,
const TreeNodeIndex* levelRange,
TreeNodeIndex* childOffsets,
TreeNodeIndex* parents)
{
#pragma omp parallel for schedule(static)
for (TreeNodeIndex i = 0; i < numInternalNodes; ++i)
{
TreeNodeIndex idxA = leafToInternal[i];
KeyType prefix = prefixes[idxA];
KeyType nodeKey = decodePlaceholderBit(prefix);
unsigned prefixLength = decodePrefixLength(prefix);
unsigned level = prefixLength / 3;
assert(level < maxTreeLevel<KeyType>{});
KeyType childPrefix = encodePlaceholderBit(nodeKey, prefixLength + 3);
TreeNodeIndex leafSearchStart = levelRange[level + 1];
TreeNodeIndex leafSearchEnd = levelRange[level + 2];
TreeNodeIndex childIdx =
stl::lower_bound(prefixes + leafSearchStart, prefixes + leafSearchEnd, childPrefix) - prefixes;
if (childIdx != leafSearchEnd && childPrefix == prefixes[childIdx])
{
childOffsets[idxA] = childIdx;
// We only store the parent once for every group of 8 siblings.
// This works as long as each node always has 8 siblings.
// Subtract one because the root has no siblings.
parents[(childIdx - 1) / 8] = idxA;
}
}
}
//! @brief determine the octree subdivision level boundaries
template<class KeyType>
void getLevelRangeCpu(const KeyType* nodeKeys, TreeNodeIndex numNodes, TreeNodeIndex* levelRange)
{
for (unsigned level = 0; level <= maxTreeLevel<KeyType>{}; ++level)
{
auto it = std::lower_bound(nodeKeys, nodeKeys + numNodes, encodePlaceholderBit(KeyType(0), 3 * level));
levelRange[level] = TreeNodeIndex(it - nodeKeys);
}
levelRange[maxTreeLevel<KeyType>{} + 1] = numNodes;
}
/*! @brief construct the internal octree part of a given octree leaf cell array on the GPU
*
* @tparam KeyType unsigned 32- or 64-bit integer
* @param[in] cstoneTree GPU buffer with the SFC leaf cell keys
*/
template<class KeyType>
void buildInternalOctreeCpu(const KeyType* cstoneTree,
TreeNodeIndex numLeafNodes,
TreeNodeIndex numInternalNodes,
KeyType* prefixes,
TreeNodeIndex* childOffsets,
TreeNodeIndex* parents,
TreeNodeIndex* levelRange,
TreeNodeIndex* internalToLeaf,
TreeNodeIndex* leafToInternal)
{
TreeNodeIndex numNodes = numInternalNodes + numLeafNodes;
createUnsortedLayoutCpu(cstoneTree, numInternalNodes, numLeafNodes, prefixes, internalToLeaf);
sort_by_key(prefixes, prefixes + numNodes, internalToLeaf);
#pragma omp parallel for schedule(static)
for (TreeNodeIndex i = 0; i < numNodes; ++i)
{
leafToInternal[internalToLeaf[i]] = i;
}
#pragma omp parallel for schedule(static)
for (TreeNodeIndex i = 0; i < numNodes; ++i)
{
internalToLeaf[i] -= numInternalNodes;
}
getLevelRangeCpu(prefixes, numNodes, levelRange);
std::fill(childOffsets, childOffsets + numNodes, 0);
linkTreeCpu(prefixes, numInternalNodes, leafToInternal, levelRange, childOffsets, parents);
}
template<class K>
class FocusedOctreeCore;
template<class KeyType>
class Octree
{
public:
Octree() = default;
//! @brief update tree, copying from externally provided leaf keys
void update(const KeyType* leaves, TreeNodeIndex numLeafNodes)
{
cstoneTree_.resize(numLeafNodes + 1);
omp_copy(leaves, leaves + numLeafNodes + 1, cstoneTree_.data());
updateInternalTree();
}
//! @brief regenerates the internal tree, assuming cstoneTree_ has been changed from the outside
void updateInternalTree()
{
resize(nNodes(cstoneTree_));
buildInternalOctreeCpu(cstoneTree_.data(), numLeafNodes_, numInternalNodes_, prefixes_.data(),
childOffsets_.data(), parents_.data(), levelRange_.data(), internalToLeaf_.data(),
leafToInternal_.data());
}
//! @brief rebalance based on leaf counts only, optimized version that avoids unnecessary allocations
bool rebalance(unsigned bucketSize, gsl::span<const unsigned> counts)
{
assert(childOffsets_.size() >= cstoneTree_.size());
bool converged =
rebalanceDecision(cstoneTree_.data(), counts.data(), numLeafNodes_, bucketSize, childOffsets_.data());
rebalanceTree(cstoneTree_, prefixes_, childOffsets_.data());
swap(cstoneTree_, prefixes_);
updateInternalTree();
return converged;
}
//! @brief return a const view of the cstone leaf array
gsl::span<const KeyType> treeLeaves() const { return cstoneTree_; }
//! @brief return const pointer to node(cell) SFC keys
gsl::span<const KeyType> nodeKeys() const { return prefixes_; }
//! @brief return const pointer to child offsets array
gsl::span<const TreeNodeIndex> childOffsets() const { return childOffsets_; }
//! @brief return const pointer to the cell parents array
gsl::span<const TreeNodeIndex> parents() const { return parents_; }
//! @brief stores the first internal node index of each tree subdivision level
gsl::span<const TreeNodeIndex> levelRange() const { return levelRange_; }
//! @brief converts a cornerstone index into an internal index
gsl::span<const TreeNodeIndex> internalOrder() const
{
return {leafToInternal_.data() + numInternalNodes_, size_t(numLeafNodes_)};
}
//! @brief converts an internal index into a cornerstone index
gsl::span<const TreeNodeIndex> toLeafOrder() const { return {internalToLeaf_.data(), size_t(numTreeNodes())}; }
//! @brief total number of nodes in the tree
inline TreeNodeIndex numTreeNodes() const { return levelRange_.back(); }
//! @brief return number of nodes per tree level
inline TreeNodeIndex numTreeNodes(unsigned level) const { return levelRange_[level + 1] - levelRange_[level]; }
//! @brief number of leaf nodes in the tree
inline TreeNodeIndex numLeafNodes() const { return numLeafNodes_; }
//! @brief number of internal nodes in the tree, equal to (numLeafNodes()-1) / 7
inline TreeNodeIndex numInternalNodes() const { return numInternalNodes_; }
/*! @brief check whether node is a leaf
*
* @param[in] node node index, range [0:numTreeNodes()]
* @return true or false
*/
inline bool isLeaf(TreeNodeIndex node) const { return childOffsets_[node] == 0; }
//! @brief check if node is the root node
inline bool isRoot(TreeNodeIndex node) const { return node == levelRange_[0]; }
/*! @brief return child node index
*
* @param[in] node node index, range [0:numInternalNodes()]
* @param[in] octant octant index, range [0:8]
* @return child node index, range [0:nNodes()]
*
* If @p node is not internal, behavior is undefined.
* Query with isLeaf(node) before calling this function.
*/
inline TreeNodeIndex child(TreeNodeIndex node, int octant) const
{
assert(node < TreeNodeIndex(childOffsets_.size()));
return childOffsets_[node] + octant;
}
//! @brief Index of parent node. Note: the root node is its own parent
inline TreeNodeIndex parent(TreeNodeIndex node) const { return node ? parents_[(node - 1) / 8] : 0; }
//! @brief lowest SFC key contained int the geometrical box of @p node
inline KeyType codeStart(TreeNodeIndex node) const { return decodePlaceholderBit(prefixes_[node]); }
//! @brief highest SFC key contained in the geometrical box of @p node
inline KeyType codeEnd(TreeNodeIndex node) const
{
KeyType prefix = prefixes_[node];
assert(decodePrefixLength(prefix) % 3 == 0);
return decodePlaceholderBit(prefix) + (1ul << (3 * maxTreeLevel<KeyType>{} - decodePrefixLength(prefix)));
}
/*! @brief octree subdivision level for @p node
*
* Returns 0 for the root node. Highest value is maxTreeLevel<KeyType>{}.
*/
inline unsigned level(TreeNodeIndex node) const { return decodePrefixLength(prefixes_[node]) / 3; }
//! @brief return the index of the first node at subdivision level @p level
inline TreeNodeIndex levelOffset(unsigned level) const { return levelRange_[level]; }
/*! @brief convert a leaf index (indexed from first leaf starting from 0) to 0-indexed from root
*
* @param[in] node leaf node index, range [0:numLeafNodes()]
* @return octree index, relative to the root node
*/
[[nodiscard]] inline TreeNodeIndex toInternal(TreeNodeIndex node) const
{
assert(size_t(node + numInternalNodes()) < leafToInternal_.size());
return leafToInternal_[node + numInternalNodes()];
}
/*! @brief returns index of @p node in the cornerstone tree used for construction
*
* @param node node in [0:numTreeNodes()]
* @return the index in the cornerstone tree used for construction if @p node is a leaf
* such that this->codeStart(node) == cstoneTree[this->cstoneIndex(node)]
* If node is not a leaf, the return value is negative.
*/
[[nodiscard]] inline TreeNodeIndex cstoneIndex(TreeNodeIndex node) const
{
assert(size_t(node) < internalToLeaf_.size());
return internalToLeaf_[node];
}
/*! @brief finds the index of the node with SFC key range [startKey:endKey]
*
* @param startKey lower SFC key
* @param endKey upper SFC key
* @return The index i of the node that satisfies codeStart(i) == startKey
* and codeEnd(i) == endKey, or numTreeNodes() if no such node exists.
*/
TreeNodeIndex locate(KeyType startKey, KeyType endKey) const
{
//! prefixLength is 3 * treeLevel(endKey - startKey)
unsigned prefixLength = countLeadingZeros(endKey - startKey - 1) - unusedBits<KeyType>{};
return locate(encodePlaceholderBit(startKey, prefixLength));
}
TreeNodeIndex locate(KeyType nodeKey) const
{
unsigned level = decodePrefixLength(nodeKey) / 3;
auto it = std::lower_bound(prefixes_.begin() + levelRange_[level], prefixes_.begin() + levelRange_[level + 1],
nodeKey);
if (it != prefixes_.end() && *it == nodeKey) { return it - prefixes_.begin(); }
else { return numTreeNodes(); }
}
private:
friend class FocusedOctreeCore<KeyType>;
void resize(TreeNodeIndex numCsLeafNodes)
{
numLeafNodes_ = numCsLeafNodes;
numInternalNodes_ = (numLeafNodes_ - 1) / 7;
TreeNodeIndex numNodes = numLeafNodes_ + numInternalNodes_;
prefixes_.resize(numNodes);
// +1 to accommodate nodeOffsets in FocusedOctreeCore::update when numNodes == 1
childOffsets_.resize(numNodes + 1);
parents_.resize((numNodes - 1) / 8);
/*! Apart from the root at level 0, there are maxTreeLevel<KeyType>{} non-trivial levels.
* For convenience, we also store the root offset, even though the root is always a single node
* at offset 0. So in total there are maxTreeLevel<KeyType>{}+1 levels and we need
* another +1 to store the last upper bound which is equal to the total number of nodes in the tree.
*/
levelRange_.resize(maxTreeLevel<KeyType>{} + 2);
internalToLeaf_.resize(numNodes);
leafToInternal_.resize(numNodes);
}
TreeNodeIndex numLeafNodes_{0};
TreeNodeIndex numInternalNodes_{0};
using Alloc = util::DefaultInitAdaptor<TreeNodeIndex>;
//! @brief the SFC key and level of each node (Warren-Salmon placeholder-bit), length = numNodes
std::vector<KeyType> prefixes_;
//! @brief the index of the first child of each node, a value of 0 indicates a leaf, length = numNodes
std::vector<TreeNodeIndex, Alloc> childOffsets_;
//! @brief stores the parent index for every group of 8 sibling nodes, length the (numNodes - 1) / 8
std::vector<TreeNodeIndex, Alloc> parents_;
//! @brief store the first node index of every tree level, length = maxTreeLevel + 2
std::vector<TreeNodeIndex, Alloc> levelRange_;
//! @brief maps between the (level-key) sorted layout B and the unsorted intermediate binary layout A
std::vector<TreeNodeIndex, Alloc> internalToLeaf_;
std::vector<TreeNodeIndex, Alloc> leafToInternal_;
//! @brief the cornerstone leaf SFC key array
std::vector<KeyType> cstoneTree_;
};
template<class T, class CombinationFunction>
void upsweep(gsl::span<const TreeNodeIndex> levelOffset,
gsl::span<const TreeNodeIndex> childOffsets,
T* quantities,
CombinationFunction&& combinationFunction)
{
int currentLevel = levelOffset.size() - 2;
for (; currentLevel >= 0; --currentLevel)
{
TreeNodeIndex start = levelOffset[currentLevel];
TreeNodeIndex end = levelOffset[currentLevel + 1];
#pragma omp parallel for schedule(static)
for (TreeNodeIndex i = start; i < end; ++i)
{
cstone::TreeNodeIndex firstChild = childOffsets[i];
if (firstChild) { quantities[i] = combinationFunction(i, firstChild, quantities); }
}
}
}
template<class T>
struct SumCombination
{
T operator()(TreeNodeIndex /*nodeIdx*/, TreeNodeIndex c, const T* Q)
{
return Q[c] + Q[c + 1] + Q[c + 2] + Q[c + 3] + Q[c + 4] + Q[c + 5] + Q[c + 6] + Q[c + 7];
}
};
} // namespace cstone
| 42.80837 | 118 | 0.65912 | lks1248 |
240fe05ae04d8a9487c4e0d10f1aa6fd4826d31e | 446 | cpp | C++ | nucleo-l433/blink/src/main.cpp | Paolo-Maffei/stm32x | 790aa03a365952c8a3cf8fd334ae307c2130fedb | [
"Unlicense"
] | 2 | 2021-03-11T10:33:37.000Z | 2022-02-12T19:35:55.000Z | nucleo-l433/blink/src/main.cpp | Paolo-Maffei/stm32x | 790aa03a365952c8a3cf8fd334ae307c2130fedb | [
"Unlicense"
] | null | null | null | nucleo-l433/blink/src/main.cpp | Paolo-Maffei/stm32x | 790aa03a365952c8a3cf8fd334ae307c2130fedb | [
"Unlicense"
] | null | null | null | #include <jee.h>
UartBufDev< PinA<2>, PinA<3> > console;
int printf(const char* fmt, ...) {
va_list ap; va_start(ap, fmt); veprintf(console.putc, fmt, ap); va_end(ap);
return 0;
}
PinB<13> led;
int main() {
console.init();
console.baud(115200, fullSpeedClock());
led.mode(Pinmode::out);
while (1) {
printf("%d\n", ticks);
led = 1;
wait_ms(100);
led = 0;
wait_ms(400);
}
}
| 17.153846 | 79 | 0.542601 | Paolo-Maffei |
24128b28629146d03e39f378236104401a51c8e3 | 7,931 | cpp | C++ | src/RageUtil/Sound/RageSoundReader_ChannelSplit.cpp | thenerdie/etterna | 341b7c506c785e3a15e7af18814791aefff5c958 | [
"MIT"
] | null | null | null | src/RageUtil/Sound/RageSoundReader_ChannelSplit.cpp | thenerdie/etterna | 341b7c506c785e3a15e7af18814791aefff5c958 | [
"MIT"
] | null | null | null | src/RageUtil/Sound/RageSoundReader_ChannelSplit.cpp | thenerdie/etterna | 341b7c506c785e3a15e7af18814791aefff5c958 | [
"MIT"
] | null | null | null | /*
* Output a sound from the channels of another sound.
*
* This is intended for splitting a FileReader, and assumes the
* GetStreamToSourceRatio of the source is 1.0.
*
* If multiple readers are created, they should be read in parallel. If their
* source position drifts apart, the data between will be buffered to prevent
* seeking the source.
*
* The resulting sounds have as many channels as the largest destination channel
* specified; multiple sounds on the same channel are mixed together; empty
* channels are silent.
*
* Create two mono sounds from one stereo sound, one playing the left channel
* and one playing the right: RageSoundSplitter split(pSource);
* RageSoundReader_Split *pLeft = split.CreateSound();
* pLeft->AddSourceChannelToSound( 0, 0 );
* RageSoundReader_Split *pRight = split.CreateSound();
* pRight->AddSourceChannelToSound( 1, 0 );
*
* Convert a stereo sound to mono:
* RageSoundSplitter split(pSource);
* RageSoundReader_Split *pMono = split.CreateSound();
* pMono->AddSourceChannelToSound( 0, 0 );
* pMono->AddSourceChannelToSound( 1, 0 );
*
* Convert a mono sound to stereo (RageSoundReader_Pan will do this faster):
* RageSoundSplitter split(pSource);
* RageSoundReader_Split *pStereo = split.CreateSound();
* pStereo->AddSourceChannelToSound( 0, 0 );
* pStereo->AddSourceChannelToSound( 0, 1 );
*/
#include "Etterna/Globals/global.h"
#include "Etterna/Models/Misc/Foreach.h"
#include "RageSoundMixBuffer.h"
#include "RageSoundReader_ChannelSplit.h"
#include "RageUtil/Utils/RageUtil.h"
#include <climits>
#include <set>
class RageSoundReader_Split;
/* This class is refcounted, freed when all RageSoundReader_Split and
* RageSoundSplitter classes release it. */
class RageSoundSplitterImpl
{
public:
explicit RageSoundSplitterImpl(RageSoundReader* pSource)
{
m_iRefCount = 1;
m_pSource = pSource;
m_iBufferPositionFrames = 0;
}
~RageSoundSplitterImpl() { delete m_pSource; }
static void Release(RageSoundSplitterImpl* pImpl)
{
--pImpl->m_iRefCount;
if (pImpl->m_iRefCount == 0)
delete pImpl;
}
/* Request that m_sBuffer contain frames [iStartFrame,iStartFrame+iFrames).
*/
int ReadBuffer();
int m_iRefCount;
RageSoundReader* m_pSource;
set<RageSoundReader_Split*> m_apSounds;
/* m_sBuffer[0] corresponds to frame number m_iBufferPositionFrames. */
int m_iBufferPositionFrames;
vector<float> m_sBuffer;
};
int
RageSoundReader_Split::GetLength() const
{
return m_pImpl->m_pSource->GetLength();
}
int
RageSoundReader_Split::GetLength_Fast() const
{
return m_pImpl->m_pSource->GetLength_Fast();
}
int
RageSoundReader_Split::GetSampleRate() const
{
return m_pImpl->m_pSource->GetSampleRate();
}
unsigned
RageSoundReader_Split::GetNumChannels() const
{
return m_iNumOutputChannels;
}
int
RageSoundReader_Split::GetNextSourceFrame() const
{
return m_iPositionFrame;
}
float
RageSoundReader_Split::GetStreamToSourceRatio() const
{
return 1.0f;
}
RString
RageSoundReader_Split::GetError() const
{
return m_pImpl->m_pSource->GetError();
}
RageSoundReader_Split::RageSoundReader_Split(RageSoundSplitterImpl* pImpl)
{
m_pImpl = pImpl;
++m_pImpl->m_iRefCount;
m_pImpl->m_apSounds.insert(this);
m_iNumOutputChannels = 0;
m_iPositionFrame = 0;
m_iRequestFrames = 0;
}
RageSoundReader_Split::RageSoundReader_Split(const RageSoundReader_Split& cpy)
: RageSoundReader(cpy)
{
m_pImpl = cpy.m_pImpl;
++m_pImpl->m_iRefCount;
m_pImpl->m_apSounds.insert(this);
m_aChannels = cpy.m_aChannels;
m_iNumOutputChannels = cpy.m_iNumOutputChannels;
m_iPositionFrame = cpy.m_iPositionFrame;
m_iRequestFrames = cpy.m_iRequestFrames;
}
RageSoundReader_Split::~RageSoundReader_Split()
{
m_pImpl->m_apSounds.erase(this);
RageSoundSplitterImpl::Release(m_pImpl);
}
int
RageSoundReader_Split::SetPosition(int iFrame)
{
m_iPositionFrame = iFrame;
/* We can't tell whether we're past EOF. We can't ReadBuffer here, because
* the other sounds using this same source probably haven't seeked yet, so
* seeking to the beginning of the file would buffer between there and the
* position of those sounds. Just return success, and we'll return EOF in
* Read if needed. */
return 1;
}
bool
RageSoundReader_Split::SetProperty(const RString& sProperty, float fValue)
{
return m_pImpl->m_pSource->SetProperty(sProperty, fValue);
}
int
RageSoundReader_Split::Read(float* pBuf, int iFrames)
{
m_iRequestFrames = iFrames;
int iRet = m_pImpl->ReadBuffer();
int iSamplesAvailable = m_pImpl->m_sBuffer.size();
const float* pSrc = &m_pImpl->m_sBuffer[0];
if (m_pImpl->m_iBufferPositionFrames < m_iPositionFrame) {
int iSkipFrames = m_iPositionFrame - m_pImpl->m_iBufferPositionFrames;
int iSkipSamples = iSkipFrames * m_pImpl->m_pSource->GetNumChannels();
pSrc += iSkipSamples;
iSamplesAvailable -= iSkipSamples;
}
int iFramesWanted = iFrames;
int iFramesAvailable =
iSamplesAvailable / (m_pImpl->m_pSource->GetNumChannels());
/* Report any errors from Read() if we don't have any data buffered to
* return. If we do have data, finish returning it first. */
if (iFramesAvailable == 0 && iRet < 0)
return iRet;
iFramesAvailable = min(iFramesAvailable, iFramesWanted);
{
RageSoundMixBuffer mix;
for (int i = 0; i < (int)m_aChannels.size(); ++i) {
const ChannelMap& chan = m_aChannels[i];
mix.SetWriteOffset(chan.m_iToChannel);
mix.write(pSrc + chan.m_iFromChannel,
iFramesAvailable,
m_pImpl->m_pSource->GetNumChannels(),
m_iNumOutputChannels);
}
mix.read(pBuf);
}
m_iPositionFrame += iFramesAvailable;
/* We no longer need the data we requested. Clear our request, so the
* memory can be freed. */
m_iRequestFrames = 0;
m_pImpl->ReadBuffer();
return iFramesAvailable;
}
int
RageSoundSplitterImpl::ReadBuffer()
{
/* Discard any bytes that are no longer requested by any sound. */
int iMinFrameRequested = INT_MAX;
int iMaxFrameRequested = INT_MIN;
FOREACHS(RageSoundReader_Split*, m_apSounds, snd)
{
iMinFrameRequested = min(iMinFrameRequested, (*snd)->m_iPositionFrame);
iMaxFrameRequested =
max(iMaxFrameRequested,
(*snd)->m_iPositionFrame + (*snd)->m_iRequestFrames);
}
if (iMinFrameRequested > m_iBufferPositionFrames) {
int iEraseFrames = iMinFrameRequested - m_iBufferPositionFrames;
iEraseFrames = min(iEraseFrames, (int)m_sBuffer.size());
m_sBuffer.erase(m_sBuffer.begin(),
m_sBuffer.begin() +
iEraseFrames * m_pSource->GetNumChannels());
m_iBufferPositionFrames += iEraseFrames;
}
if (iMinFrameRequested != m_iBufferPositionFrames) {
m_pSource->SetPosition(iMinFrameRequested);
m_iBufferPositionFrames = iMinFrameRequested;
m_sBuffer.clear();
}
int iFramesBuffered = m_sBuffer.size() / m_pSource->GetNumChannels();
int iFramesToRead =
iMaxFrameRequested - (m_iBufferPositionFrames + iFramesBuffered);
if (iFramesToRead <= 0)
return 1; // requested data already buffered
int iSamplesToRead = iFramesToRead * m_pSource->GetNumChannels();
int iOldSizeSamples = m_sBuffer.size();
m_sBuffer.resize(iOldSizeSamples + iSamplesToRead);
int iGotFrames =
m_pSource->Read(&m_sBuffer[0] + iOldSizeSamples, iFramesToRead);
if (iGotFrames < 0) {
m_sBuffer.resize(iOldSizeSamples);
return iGotFrames;
}
int iGotSamples = iGotFrames * m_pSource->GetNumChannels();
m_sBuffer.resize(iOldSizeSamples + iGotSamples);
return 1;
}
void
RageSoundReader_Split::AddSourceChannelToSound(int iFromChannel, int iToChannel)
{
m_aChannels.push_back(ChannelMap(iFromChannel, iToChannel));
m_iNumOutputChannels = max(m_iNumOutputChannels, iToChannel + 1);
}
RageSoundSplitter::RageSoundSplitter(RageSoundReader* pSource)
{
m_pImpl = new RageSoundSplitterImpl(pSource);
}
RageSoundSplitter::~RageSoundSplitter()
{
RageSoundSplitterImpl::Release(m_pImpl);
}
RageSoundReader_Split*
RageSoundSplitter::CreateSound()
{
return new RageSoundReader_Split(m_pImpl);
}
| 27.730769 | 80 | 0.756147 | thenerdie |
24141cd68a03022af0af7dc1abf9c81d2e68802f | 1,581 | cc | C++ | win/win_util_unittest.cc | chinmaygarde/flutter_base | 40e46434df6711b5c219823d3a01ffa1f2fb10d6 | [
"BSD-3-Clause"
] | 20 | 2015-08-26T06:46:00.000Z | 2019-02-27T09:05:58.000Z | win/win_util_unittest.cc | chinmaygarde/flutter_base | 40e46434df6711b5c219823d3a01ffa1f2fb10d6 | [
"BSD-3-Clause"
] | 1 | 2021-05-05T11:11:31.000Z | 2021-05-05T11:11:31.000Z | win/win_util_unittest.cc | chinmaygarde/flutter_base | 40e46434df6711b5c219823d3a01ffa1f2fb10d6 | [
"BSD-3-Clause"
] | 7 | 2016-02-09T09:28:14.000Z | 2020-07-25T19:03:36.000Z | // Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include <windows.h>
#include "base/basictypes.h"
#include "base/strings/string_util.h"
#include "base/win/win_util.h"
#include "base/win/windows_version.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace base {
namespace win {
namespace {
// Saves the current thread's locale ID when initialized, and restores it when
// the instance is going out of scope.
class ThreadLocaleSaver {
public:
ThreadLocaleSaver() : original_locale_id_(GetThreadLocale()) {}
~ThreadLocaleSaver() { SetThreadLocale(original_locale_id_); }
private:
LCID original_locale_id_;
DISALLOW_COPY_AND_ASSIGN(ThreadLocaleSaver);
};
} // namespace
// The test is somewhat silly, because the Vista bots some have UAC enabled
// and some have it disabled. At least we check that it does not crash.
TEST(BaseWinUtilTest, TestIsUACEnabled) {
if (GetVersion() >= base::win::VERSION_VISTA) {
UserAccountControlIsEnabled();
} else {
EXPECT_TRUE(UserAccountControlIsEnabled());
}
}
TEST(BaseWinUtilTest, TestGetUserSidString) {
std::wstring user_sid;
EXPECT_TRUE(GetUserSidString(&user_sid));
EXPECT_TRUE(!user_sid.empty());
}
TEST(BaseWinUtilTest, TestGetNonClientMetrics) {
NONCLIENTMETRICS_XP metrics = {0};
GetNonClientMetrics(&metrics);
EXPECT_GT(metrics.cbSize, 0u);
EXPECT_GT(metrics.iScrollWidth, 0);
EXPECT_GT(metrics.iScrollHeight, 0);
}
} // namespace win
} // namespace base
| 26.79661 | 78 | 0.748893 | chinmaygarde |
2415f1317e5f29e7055d22b53be96449b8ae3569 | 51,453 | cpp | C++ | Source/General/Driver/Filter/ASTC/Core/astcenc_ideal_endpoints_and_weights.cpp | paintdream/paintsnow | 3a1cbc9e571eaa2e62a3a2d60f75817b45f0c781 | [
"MIT"
] | 15 | 2016-09-17T16:29:42.000Z | 2021-11-24T06:21:27.000Z | Source/General/Driver/Filter/ASTC/Core/astcenc_ideal_endpoints_and_weights.cpp | paintdream/paintsnow | 3a1cbc9e571eaa2e62a3a2d60f75817b45f0c781 | [
"MIT"
] | null | null | null | Source/General/Driver/Filter/ASTC/Core/astcenc_ideal_endpoints_and_weights.cpp | paintdream/paintsnow | 3a1cbc9e571eaa2e62a3a2d60f75817b45f0c781 | [
"MIT"
] | 3 | 2017-04-07T13:33:57.000Z | 2021-03-31T02:04:48.000Z | // SPDX-License-Identifier: Apache-2.0
// ----------------------------------------------------------------------------
// Copyright 2011-2021 Arm Limited
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may not
// use this file except in compliance with the License. You may obtain a copy
// of the License at:
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
// License for the specific language governing permissions and limitations
// under the License.
// ----------------------------------------------------------------------------
#if !defined(ASTCENC_DECOMPRESS_ONLY)
/**
* @brief Functions for computing color endpoints and texel weights.
*/
#include <cassert>
#include "astcenc_internal.h"
#include "astcenc_vecmathlib.h"
static void compute_endpoints_and_ideal_weights_1_comp(
const block_size_descriptor* bsd,
const partition_info* pt,
const imageblock* blk,
const error_weight_block* ewb,
endpoints_and_weights* ei,
unsigned int component
) {
int partition_count = pt->partition_count;
ei->ep.partition_count = partition_count;
promise(partition_count > 0);
int texel_count = bsd->texel_count;
promise(texel_count > 0);
float lowvalues[4] { 1e10f, 1e10f, 1e10f, 1e10f };
float highvalues[4] { -1e10f, -1e10f, -1e10f, -1e10f };
float partition_error_scale[4];
float linelengths_rcp[4];
const float *error_weights = nullptr;
const float* data_vr = nullptr;
assert(component < 4);
switch (component)
{
case 0:
error_weights = ewb->texel_weight_r;
data_vr = blk->data_r;
break;
case 1:
error_weights = ewb->texel_weight_g;
data_vr = blk->data_g;
break;
case 2:
error_weights = ewb->texel_weight_b;
data_vr = blk->data_b;
break;
default:
error_weights = ewb->texel_weight_a;
data_vr = blk->data_a;
break;
}
for (int i = 0; i < texel_count; i++)
{
if (error_weights[i] > 1e-10f)
{
float value = data_vr[i];
int partition = pt->partition_of_texel[i];
lowvalues[partition] = astc::min(value, lowvalues[partition]);
highvalues[partition] = astc::max(value, highvalues[partition]);
}
}
vmask4 sep_mask = vint4::lane_id() == vint4(component);
for (int i = 0; i < partition_count; i++)
{
float diff = highvalues[i] - lowvalues[i];
if (diff < 0)
{
lowvalues[i] = 0.0f;
highvalues[i] = 0.0f;
}
diff = astc::max(diff, 1e-7f);
partition_error_scale[i] = diff * diff;
linelengths_rcp[i] = 1.0f / diff;
ei->ep.endpt0[i] = select(blk->data_min, vfloat4(lowvalues[i]), sep_mask);
ei->ep.endpt1[i] = select(blk->data_max, vfloat4(highvalues[i]), sep_mask);
}
bool is_constant_wes = true;
float constant_wes = partition_error_scale[pt->partition_of_texel[0]] * error_weights[0];
for (int i = 0; i < texel_count; i++)
{
float value = data_vr[i];
int partition = pt->partition_of_texel[i];
value -= lowvalues[partition];
value *= linelengths_rcp[partition];
value = astc::clamp1f(value);
ei->weights[i] = value;
ei->weight_error_scale[i] = partition_error_scale[partition] * error_weights[i];
assert(!astc::isnan(ei->weight_error_scale[i]));
is_constant_wes = is_constant_wes && ei->weight_error_scale[i] == constant_wes;
}
ei->is_constant_weight_error_scale = is_constant_wes;
}
static void compute_endpoints_and_ideal_weights_2_comp(
const block_size_descriptor* bsd,
const partition_info* pt,
const imageblock* blk,
const error_weight_block * ewb,
endpoints_and_weights* ei,
int component1,
int component2
) {
int partition_count = pt->partition_count;
ei->ep.partition_count = partition_count;
promise(partition_count > 0);
int texel_count = bsd->texel_count;
promise(texel_count > 0);
partition_metrics pms[4];
const float *error_weights;
const float* data_vr = nullptr;
const float* data_vg = nullptr;
if (component1 == 0 && component2 == 1)
{
error_weights = ewb->texel_weight_rg;
data_vr = blk->data_r;
data_vg = blk->data_g;
}
else if (component1 == 0 && component2 == 2)
{
error_weights = ewb->texel_weight_rb;
data_vr = blk->data_r;
data_vg = blk->data_b;
}
else // (component1 == 1 && component2 == 2)
{
error_weights = ewb->texel_weight_gb;
data_vr = blk->data_g;
data_vg = blk->data_b;
}
float lowparam[4] { 1e10f, 1e10f, 1e10f, 1e10f };
float highparam[4] { -1e10f, -1e10f, -1e10f, -1e10f };
line2 lines[4];
float scale[4];
float length_squared[4];
compute_avgs_and_dirs_2_comp(pt, blk, ewb, component1, component2, pms);
for (int i = 0; i < partition_count; i++)
{
float2 dir = pms[i].dir.swz<0, 1>();
if (dir.r + dir.g < 0.0f)
{
dir = float2(0.0f) - dir;
}
lines[i].a = pms[i].avg.swz<0, 1>();
if (dot(dir, dir) == 0.0f)
{
lines[i].b = normalize(float2(1.0f));
}
else
{
lines[i].b = normalize(dir);
}
}
for (int i = 0; i < texel_count; i++)
{
if (error_weights[i] > 1e-10f)
{
int partition = pt->partition_of_texel[i];
float2 point = float2(data_vr[i], data_vg[i]) * float2(pms[partition].color_scale.lane<0>(), pms[partition].color_scale.lane<0>());
line2 l = lines[partition];
float param = dot(point - l.a, l.b);
ei->weights[i] = param;
lowparam[partition] = astc::min(param, lowparam[partition]);
highparam[partition] = astc::max(param, highparam[partition]);
}
else
{
ei->weights[i] = -1e38f;
}
}
float2 lowvalues[4];
float2 highvalues[4];
for (int i = 0; i < partition_count; i++)
{
float length = highparam[i] - lowparam[i];
if (length < 0.0f) // case for when none of the texels had any weight
{
lowparam[i] = 0.0f;
highparam[i] = 1e-7f;
}
// it is possible for a uniform-color partition to produce length=0; this
// causes NaN-production and NaN-propagation later on. Set length to
// a small value to avoid this problem.
length = astc::max(length, 1e-7f);
length_squared[i] = length * length;
scale[i] = 1.0f / length;
float2 ep0 = lines[i].a + lines[i].b * lowparam[i];
float2 ep1 = lines[i].a + lines[i].b * highparam[i];
ep0.r /= pms[i].color_scale.lane<0>();
ep0.g /= pms[i].color_scale.lane<1>();
ep1.r /= pms[i].color_scale.lane<0>();
ep1.g /= pms[i].color_scale.lane<1>();
lowvalues[i] = ep0;
highvalues[i] = ep1;
}
vmask4 comp1_mask = vint4::lane_id() == vint4(component1);
vmask4 comp2_mask = vint4::lane_id() == vint4(component2);
for (int i = 0; i < partition_count; i++)
{
vfloat4 ep0 = select(blk->data_min, vfloat4(lowvalues[i].r), comp1_mask);
vfloat4 ep1 = select(blk->data_max, vfloat4(highvalues[i].r), comp1_mask);
ei->ep.endpt0[i] = select(ep0, vfloat4(lowvalues[i].g), comp2_mask);
ei->ep.endpt1[i] = select(ep1, vfloat4(highvalues[i].g), comp2_mask);
}
bool is_constant_wes = true;
float constant_wes = length_squared[pt->partition_of_texel[0]] * error_weights[0];
for (int i = 0; i < texel_count; i++)
{
int partition = pt->partition_of_texel[i];
float idx = (ei->weights[i] - lowparam[partition]) * scale[partition];
idx = astc::clamp1f(idx);
ei->weights[i] = idx;
ei->weight_error_scale[i] = length_squared[partition] * error_weights[i];
assert(!astc::isnan(ei->weight_error_scale[i]));
is_constant_wes = is_constant_wes && ei->weight_error_scale[i] == constant_wes;
}
ei->is_constant_weight_error_scale = is_constant_wes;
}
static void compute_endpoints_and_ideal_weights_3_comp(
const block_size_descriptor* bsd,
const partition_info* pt,
const imageblock* blk,
const error_weight_block* ewb,
endpoints_and_weights* ei,
int omitted_component
) {
int partition_count = pt->partition_count;
ei->ep.partition_count = partition_count;
promise(partition_count > 0);
int texel_count= bsd->texel_count;
promise(texel_count > 0);
partition_metrics pms[4];
const float *error_weights;
const float* data_vr = nullptr;
const float* data_vg = nullptr;
const float* data_vb = nullptr;
if (omitted_component == 0)
{
error_weights = ewb->texel_weight_gba;
data_vr = blk->data_g;
data_vg = blk->data_b;
data_vb = blk->data_a;
}
else if (omitted_component == 1)
{
error_weights = ewb->texel_weight_rba;
data_vr = blk->data_r;
data_vg = blk->data_b;
data_vb = blk->data_a;
}
else if (omitted_component == 2)
{
error_weights = ewb->texel_weight_rga;
data_vr = blk->data_r;
data_vg = blk->data_g;
data_vb = blk->data_a;
}
else
{
error_weights = ewb->texel_weight_rgb;
data_vr = blk->data_r;
data_vg = blk->data_g;
data_vb = blk->data_b;
}
float lowparam[4] { 1e10f, 1e10f, 1e10f, 1e10f };
float highparam[4] { -1e10f, -1e10f, -1e10f, -1e10f };
line3 lines[4];
float scale[4];
float length_squared[4];
compute_avgs_and_dirs_3_comp(pt, blk, ewb, omitted_component, pms);
for (int i = 0; i < partition_count; i++)
{
vfloat4 dir = pms[i].dir;
if (hadd_rgb_s(dir) < 0.0f)
{
dir = vfloat4(0.0f) - dir;
}
lines[i].a = pms[i].avg;
lines[i].b = normalize_safe(dir, unit3());
}
for (int i = 0; i < texel_count; i++)
{
if (error_weights[i] > 1e-10f)
{
int partition = pt->partition_of_texel[i];
vfloat4 point = vfloat4(data_vr[i], data_vg[i], data_vb[i], 0.0f) * pms[partition].color_scale;
line3 l = lines[partition];
float param = dot3_s(point - l.a, l.b);
ei->weights[i] = param;
lowparam[partition] = astc::min(param, lowparam[partition]);
highparam[partition] = astc::max(param, highparam[partition]);
}
else
{
ei->weights[i] = -1e38f;
}
}
for (int i = 0; i < partition_count; i++)
{
float length = highparam[i] - lowparam[i];
if (length < 0) // case for when none of the texels had any weight
{
lowparam[i] = 0.0f;
highparam[i] = 1e-7f;
}
// it is possible for a uniform-color partition to produce length=0; this
// causes NaN-production and NaN-propagation later on. Set length to
// a small value to avoid this problem.
length = astc::max(length, 1e-7f);
length_squared[i] = length * length;
scale[i] = 1.0f / length;
vfloat4 ep0 = lines[i].a + lines[i].b * lowparam[i];
vfloat4 ep1 = lines[i].a + lines[i].b * highparam[i];
ep0 = ep0 / pms[i].color_scale;
ep1 = ep1 / pms[i].color_scale;
vfloat4 bmin = blk->data_min;
vfloat4 bmax = blk->data_max;
// TODO: Probably a programmatic vector permute we can do here ...
assert(omitted_component < 4);
switch (omitted_component)
{
case 0:
ei->ep.endpt0[i] = vfloat4(bmin.lane<0>(), ep0.lane<0>(), ep0.lane<1>(), ep0.lane<2>());
ei->ep.endpt1[i] = vfloat4(bmax.lane<0>(), ep1.lane<0>(), ep1.lane<1>(), ep1.lane<2>());
break;
case 1:
ei->ep.endpt0[i] = vfloat4(ep0.lane<0>(), bmin.lane<1>(), ep0.lane<1>(), ep0.lane<2>());
ei->ep.endpt1[i] = vfloat4(ep1.lane<0>(), bmax.lane<1>(), ep1.lane<1>(), ep1.lane<2>());
break;
case 2:
ei->ep.endpt0[i] = vfloat4(ep0.lane<0>(), ep0.lane<1>(), bmin.lane<2>(), ep0.lane<2>());
ei->ep.endpt1[i] = vfloat4(ep1.lane<0>(), ep1.lane<1>(), bmax.lane<2>(), ep1.lane<2>());
break;
default:
ei->ep.endpt0[i] = vfloat4(ep0.lane<0>(), ep0.lane<1>(), ep0.lane<2>(), bmin.lane<3>());
ei->ep.endpt1[i] = vfloat4(ep1.lane<0>(), ep1.lane<1>(), ep1.lane<2>(), bmax.lane<3>());
break;
}
}
bool is_constant_wes = true;
float constant_wes = length_squared[pt->partition_of_texel[0]] * error_weights[0];
for (int i = 0; i < texel_count; i++)
{
int partition = pt->partition_of_texel[i];
float idx = (ei->weights[i] - lowparam[partition]) * scale[partition];
idx = astc::clamp1f(idx);
ei->weights[i] = idx;
ei->weight_error_scale[i] = length_squared[partition] * error_weights[i];
assert(!astc::isnan(ei->weight_error_scale[i]));
is_constant_wes = is_constant_wes && ei->weight_error_scale[i] == constant_wes;
}
ei->is_constant_weight_error_scale = is_constant_wes;
}
static void compute_endpoints_and_ideal_weights_4_comp(
const block_size_descriptor* bsd,
const partition_info* pt,
const imageblock* blk,
const error_weight_block* ewb,
endpoints_and_weights* ei
) {
const float *error_weights = ewb->texel_weight;
int partition_count = pt->partition_count;
int texel_count= bsd->texel_count;
promise(texel_count > 0);
promise(partition_count > 0);
float lowparam[4] { 1e10, 1e10, 1e10, 1e10 };
float highparam[4] { -1e10, -1e10, -1e10, -1e10 };
line4 lines[4];
float scale[4];
float length_squared[4];
partition_metrics pms[4];
compute_avgs_and_dirs_4_comp(pt, blk, ewb, pms);
// if the direction-vector ends up pointing from light to dark, FLIP IT!
// this will make the first endpoint the darkest one.
for (int i = 0; i < partition_count; i++)
{
vfloat4 dir = pms[i].dir;
if (hadd_rgb_s(dir) < 0.0f)
{
dir = vfloat4::zero() - dir;
}
lines[i].a = pms[i].avg;
if (dot_s(dir, dir) == 0.0f)
{
lines[i].b = normalize(vfloat4(1.0f));
}
else
{
lines[i].b = normalize(dir);
}
}
for (int i = 0; i < texel_count; i++)
{
if (error_weights[i] > 1e-10f)
{
int partition = pt->partition_of_texel[i];
vfloat4 point = blk->texel(i) * pms[partition].color_scale;
line4 l = lines[partition];
float param = dot_s(point - l.a, l.b);
ei->weights[i] = param;
lowparam[partition] = astc::min(param, lowparam[partition]);
highparam[partition] = astc::max(param, highparam[partition]);
}
else
{
ei->weights[i] = -1e38f;
}
}
for (int i = 0; i < partition_count; i++)
{
float length = highparam[i] - lowparam[i];
if (length < 0)
{
lowparam[i] = 0.0f;
highparam[i] = 1e-7f;
}
// it is possible for a uniform-color partition to produce length=0; this
// causes NaN-production and NaN-propagation later on. Set length to
// a small value to avoid this problem.
length = astc::max(length, 1e-7f);
length_squared[i] = length * length;
scale[i] = 1.0f / length;
vfloat4 ep0 = lines[i].a + lines[i].b * lowparam[i];
vfloat4 ep1 = lines[i].a + lines[i].b * highparam[i];
ei->ep.endpt0[i] = ep0 / pms[i].color_scale;
ei->ep.endpt1[i] = ep1 / pms[i].color_scale;
}
bool is_constant_wes = true;
float constant_wes = length_squared[pt->partition_of_texel[0]] * error_weights[0];
for (int i = 0; i < texel_count; i++)
{
int partition = pt->partition_of_texel[i];
float idx = (ei->weights[i] - lowparam[partition]) * scale[partition];
idx = astc::clamp1f(idx);
ei->weights[i] = idx;
ei->weight_error_scale[i] = error_weights[i] * length_squared[partition];
assert(!astc::isnan(ei->weight_error_scale[i]));
is_constant_wes = is_constant_wes && ei->weight_error_scale[i] == constant_wes;
}
ei->is_constant_weight_error_scale = is_constant_wes;
}
/*
For a given partitioning, compute: for each partition, the ideal endpoint colors;
these define a color line for the partition. for each pixel, the ideal position of the pixel on the partition's
color line. for each pixel, the length of the color line.
These data allow us to assess the error introduced by removing and quantizing the per-pixel weights.
*/
void compute_endpoints_and_ideal_weights_1plane(
const block_size_descriptor* bsd,
const partition_info* pt,
const imageblock* blk,
const error_weight_block* ewb,
endpoints_and_weights* ei
) {
int uses_alpha = imageblock_uses_alpha(blk);
if (uses_alpha)
{
compute_endpoints_and_ideal_weights_4_comp(bsd, pt, blk, ewb, ei);
}
else
{
compute_endpoints_and_ideal_weights_3_comp(bsd, pt, blk, ewb, ei, 3);
}
}
void compute_endpoints_and_ideal_weights_2planes(
const block_size_descriptor* bsd,
const partition_info* pt,
const imageblock* blk,
const error_weight_block* ewb,
int plane2_component,
endpoints_and_weights* ei1,
endpoints_and_weights* ei2
) {
int uses_alpha = imageblock_uses_alpha(blk);
assert(plane2_component < 4);
switch (plane2_component)
{
case 0: // separate weights for red
if (uses_alpha)
{
compute_endpoints_and_ideal_weights_3_comp(bsd, pt, blk, ewb, ei1, 0);
}
else
{
compute_endpoints_and_ideal_weights_2_comp(bsd, pt, blk, ewb, ei1, 1, 2);
}
compute_endpoints_and_ideal_weights_1_comp(bsd, pt, blk, ewb, ei2, 0);
break;
case 1: // separate weights for green
if (uses_alpha)
{
compute_endpoints_and_ideal_weights_3_comp(bsd, pt, blk, ewb, ei1, 1);
}
else
{
compute_endpoints_and_ideal_weights_2_comp(bsd, pt, blk, ewb, ei1, 0, 2);
}
compute_endpoints_and_ideal_weights_1_comp(bsd, pt, blk, ewb, ei2, 1);
break;
case 2: // separate weights for blue
if (uses_alpha)
{
compute_endpoints_and_ideal_weights_3_comp(bsd, pt, blk, ewb, ei1, 2);
}
else
{
compute_endpoints_and_ideal_weights_2_comp(bsd, pt, blk, ewb, ei1, 0, 1);
}
compute_endpoints_and_ideal_weights_1_comp(bsd, pt, blk, ewb, ei2, 2);
break;
default: // separate weights for alpha
assert(uses_alpha);
compute_endpoints_and_ideal_weights_3_comp(bsd, pt, blk, ewb, ei1, 3);
compute_endpoints_and_ideal_weights_1_comp(bsd, pt, blk, ewb, ei2, 3);
break;
}
}
/*
After having computed ideal weights for the case where a weight exists for
every texel, we want to compute the ideal weights for the case where weights
exist only for some texels.
We do this with a steepest-descent grid solver; this works as follows:
* First, for each actual weight, perform a weighted averaging based on the
texels affected by the weight.
* Then, set step size to <some initial value>
* Then, repeat:
1: First, compute for each weight how much the error will change
if we change the weight by an infinitesimal amount.
2: This produces a vector that points the direction we should step in.
Normalize this vector.
3: Perform a step
4: Check if the step actually improved the error. If it did, perform
another step in the same direction; repeat until error no longer
improves. If the *first* step did not improve error, then we halve
the step size.
5: If the step size dropped down below <some threshold value>,
then we quit, else we go back to #1.
Subroutines: one routine to apply a step and compute the step's effect on
the error one routine to compute the error change of an infinitesimal
weight change
Data structures needed:
For every decimation pattern, we need:
* For each weight, a list of <texel, weight> tuples that tell which texels
the weight influences.
* For each texel, a list of <texel, weight> tuples that tell which weights
go into a given texel.
*/
float compute_error_of_weight_set_1plane(
const endpoints_and_weights* eai,
const decimation_table* dt,
const float* weights
) {
vfloat4 error_summav = vfloat4::zero();
float error_summa = 0.0f;
int texel_count = dt->texel_count;
int i = 0;
// Process SIMD-width texel coordinates at at time while we can
int clipped_texel_count = round_down_to_simd_multiple_vla(texel_count);
for (/* */; i < clipped_texel_count; i += ASTCENC_SIMD_WIDTH)
{
// Compute the bilinear interpolation of the decimated weight grid
vfloat current_values = bilinear_infill_vla(*dt, weights, i);
// Compute the error between the computed value and the ideal weight
vfloat actual_values = loada(&(eai->weights[i]));
vfloat diff = current_values - actual_values;
vfloat significance = loada(&(eai->weight_error_scale[i]));
vfloat error = diff * diff * significance;
haccumulate(error_summav, error);
}
// Loop tail
// Error is buffered and accumulated in blocks of 4 to ensure that
// the partial sums added to the accumulator are invariant with the
// vector implementation, irrespective of vector size ...
#if CMAKE_ANDROID
__attribute__((aligned(16))) float errorsum_tmp[4] { 0 };
#else
alignas(16) float errorsum_tmp[4] { 0 };
#endif
for (/* */; i < texel_count; i++)
{
float current_value = bilinear_infill(*dt, weights, i);
float valuedif = current_value - eai->weights[i];
float error = valuedif * valuedif * eai->weight_error_scale[i];
// Accumulate error sum in the temporary array
int error_index = i & 0x3;
errorsum_tmp[error_index] = error;
#if ASTCENC_SIMD_WIDTH == 8
// Zero the temporary staging buffer every 4 items unless last. Note
// that this block can only trigger for 6x5 blocks, all other partials
// tails are shorter than 4 ...
if ((i & 0x7) == 0x03)
{
haccumulate(error_summav, vfloat4::loada(errorsum_tmp));
storea(vfloat4::zero(), errorsum_tmp);
}
#endif
}
// Accumulate the loop tail using the vfloat4 swizzle
haccumulate(error_summav, vfloat4::loada(errorsum_tmp));
// Resolve the final scalar accumulator sum
haccumulate(error_summa, error_summav);
return error_summa;
}
float compute_error_of_weight_set_2planes(
const endpoints_and_weights* eai1,
const endpoints_and_weights* eai2,
const decimation_table* dt,
const float* weights1,
const float* weights2
) {
float error_summa = 0.0f;
int texel_count = dt->texel_count;
int i = 0;
vfloat4 error_summav = vfloat4::zero();
// Process SIMD-width texel coordinates at at time while we can
int clipped_texel_count = round_down_to_simd_multiple_vla(texel_count);
for (/* */; i < clipped_texel_count; i += ASTCENC_SIMD_WIDTH)
{
// Plane 1
// Compute the bilinear interpolation of the decimated weight grid
vfloat current_values1 = bilinear_infill_vla(*dt, weights1, i);
// Compute the error between the computed value and the ideal weight
vfloat actual_values1 = loada(&(eai1->weights[i]));
vfloat diff = current_values1 - actual_values1;
vfloat error1 = diff * diff * loada(&(eai1->weight_error_scale[i]));
// Plane 2
// Compute the bilinear interpolation of the decimated weight grid
vfloat current_values2 = bilinear_infill_vla(*dt, weights2, i);
// Compute the error between the computed value and the ideal weight
vfloat actual_values2 = loada(&(eai2->weights[i]));
diff = current_values2 - actual_values2;
vfloat error2 = diff * diff * loada(&(eai2->weight_error_scale[i]));
haccumulate(error_summav, error1 + error2);
}
// Loop tail
// Error is buffered and accumulated in blocks of 4 to ensure that
// the partial sums added to the accumulator are invariant with the
// vector implementation, irrespective of vector size ...
#if CMAKE_ANDROID
__attribute__((aligned(16))) float errorsum_tmp[4]{ 0 };
#else
alignas(16) float errorsum_tmp[4]{ 0 };
#endif
for (/* */; i < texel_count; i++)
{
// Plane 1
float current_value1 = bilinear_infill(*dt, weights1, i);
float valuedif1 = current_value1 - eai1->weights[i];
float error1 = valuedif1 * valuedif1 * eai1->weight_error_scale[i];
// Plane 2
float current_value2 = bilinear_infill(*dt, weights2, i);
float valuedif2 = current_value2 - eai2->weights[i];
float error2 = valuedif2 * valuedif2 * eai2->weight_error_scale[i];
// Accumulate error sum in the temporary array
int error_index = i & 0x3;
errorsum_tmp[error_index] = error1 + error2;
#if ASTCENC_SIMD_WIDTH == 8
// Zero the temporary staging buffer every 4 items unless last. Note
// that this block can only trigger for 6x5 blocks, all other partials
// tails are shorter than 4 ...
if ((i & 0x7) == 0x03)
{
haccumulate(error_summav, vfloat4::loada(errorsum_tmp));
storea(vfloat4::zero(), errorsum_tmp);
}
#endif
}
// Accumulate the loop tail using the vfloat4 swizzle
haccumulate(error_summav, vfloat4::loada(errorsum_tmp));
// Resolve the final scalar accumulator sum
haccumulate(error_summa, error_summav);
return error_summa;
}
/* See header for documentation. */
// Note: This function is vectorized, but needs to use gathers to access the
// decimation table structures so vectorization is currently only enabled for
// AVX2. The implementation loops over decimated weights, and then texels for
// each weight. We know the backing memory is "large enough" we can can
// overshoot the weight count to always use full vectors without a loop tail.
// The inner loop operates on 8 weights, each of which may have a different
// number of texels referenced by it. We iterate over the max reference count,
// and then use lane masks to disable lanes that are no longer in scope.
void compute_ideal_weights_for_decimation_table(
const endpoints_and_weights& eai_in,
endpoints_and_weights& eai_out,
const decimation_table& dt,
float* RESTRICT weight_set,
float* RESTRICT weights
) {
int texel_count = dt.texel_count;
int weight_count = dt.weight_count;
promise(texel_count > 0);
promise(weight_count > 0);
// This function includes a copy of the epw from eai_in to eai_out. We do it
// here because we want to load the data anyway, so we can avoid loading it
// from memory twice.
eai_out.ep = eai_in.ep;
eai_out.is_constant_weight_error_scale = eai_in.is_constant_weight_error_scale;
// Ensure that the end of the output arrays that are used for SIMD paths later are filled so we
// can safely run SIMD elsewhere without a loop tail. Note that this is always safe as weight
// arrays always contain space for 64 elements
int simd_weight_count = round_up_to_simd_multiple_vla(weight_count);
for (int i = weight_count; i < simd_weight_count; i++)
{
weight_set[i] = 0.0f;
}
// If we have a 1:1 mapping just shortcut the computation - clone the
// weights into both the weight set and the output epw copy.
if (texel_count == weight_count)
{
for (int i = 0; i < texel_count; i++)
{
assert(i == dt.weight_texel[0][i]);
weight_set[i] = eai_in.weights[i];
weights[i] = eai_in.weight_error_scale[i];
eai_out.weights[i] = eai_in.weights[i];
eai_out.weight_error_scale[i] = eai_in.weight_error_scale[i];
}
return;
}
// If we don't have a 1:1 mapping just clone the weights into the output
// epw copy and then do the full algorithm to decimate weights.
else
{
for (int i = 0; i < texel_count; i++)
{
eai_out.weights[i] = eai_in.weights[i];
eai_out.weight_error_scale[i] = eai_in.weight_error_scale[i];
}
}
// Otherwise compute an estimate and perform single refinement iteration
#if CMAKE_ANDROID
__attribute__((aligned(ASTCENC_VECALIGN))) float infilled_weights[MAX_TEXELS_PER_BLOCK];
#else
alignas(ASTCENC_VECALIGN) float infilled_weights[MAX_TEXELS_PER_BLOCK];
#endif
// Compute an initial average for each decimated weight
bool constant_wes = eai_in.is_constant_weight_error_scale;
vfloat weight_error_scale(eai_in.weight_error_scale[0]);
// This overshoots - this is OK as we initialize the array tails in the
// decimation table structures to safe values ...
for (int i = 0; i < weight_count; i += ASTCENC_SIMD_WIDTH)
{
// Accumulate error weighting of all the texels using this weight
vint weight_texel_count(dt.weight_texel_count + i);
// Start with a small value to avoid div-by-zero later
vfloat weight_weight(1e-10f);
vfloat initial_weight = vfloat::zero();
int b = std::max(weight_texel_count.m[0], weight_texel_count.m[1]);
int c = std::max(weight_texel_count.m[2], weight_texel_count.m[3]);
int max_texel_count = std::max(b, c);
promise(max_texel_count > 0);
for (int j = 0; j < max_texel_count; j++)
{
// Not all lanes may actually use j texels, so mask out if idle
vmask active = weight_texel_count > vint(j);
vint texel(dt.weight_texel[j] + i);
texel = select(vint::zero(), texel, active);
vfloat weight = loada(dt.weights_flt[j] + i);
weight = select(vfloat::zero(), weight, active);
if (!constant_wes)
{
weight_error_scale = gatherf(eai_in.weight_error_scale, texel);
}
vfloat contrib_weight = weight * weight_error_scale;
weight_weight += contrib_weight;
initial_weight += gatherf(eai_in.weights, texel) * contrib_weight;
}
storea(weight_weight, weights + i);
storea(initial_weight / weight_weight, weight_set + i);
}
// Populate the interpolated weight grid based on the initital average
// Process SIMD-width texel coordinates at at time while we can
int is = 0;
int clipped_texel_count = round_down_to_simd_multiple_vla(texel_count);
for (/* */; is < clipped_texel_count; is += ASTCENC_SIMD_WIDTH)
{
vfloat weight = bilinear_infill_vla(dt, weight_set, is);
storea(weight, infilled_weights + is);
}
// Loop tail
for (/* */; is < texel_count; is++)
{
infilled_weights[is] = bilinear_infill(dt, weight_set, is);
}
// Perform a single iteration of refinement
constexpr float stepsize = 0.25f;
constexpr float chd_scale = -TEXEL_WEIGHT_SUM;
for (int i = 0; i < weight_count; i += ASTCENC_SIMD_WIDTH)
{
// Start with a small value to avoid div-by-zero later
vfloat weight_val = loada(weight_set + i);
// Accumulate error weighting of all the texels using this weight
vfloat error_change0(1e-10f);
vfloat error_change1(0.0f);
// Accumulate error weighting of all the texels using this weight
vint weight_texel_count(dt.weight_texel_count + i);
int b = std::max(weight_texel_count.m[0], weight_texel_count.m[1]);
int c = std::max(weight_texel_count.m[2], weight_texel_count.m[3]);
int max_texel_count = std::max(b, c);
promise(max_texel_count > 0);
for (int j = 0; j < max_texel_count; j++)
{
// Not all lanes may actually use j texels, so mask out if idle
vmask active = weight_texel_count > vint(j);
vint texel(dt.weight_texel[j] + i);
texel = select(vint::zero(), texel, active);
vfloat contrib_weight = loada(dt.weights_flt[j] + i);
contrib_weight = select(vfloat::zero(), contrib_weight, active);
if (!constant_wes)
{
weight_error_scale = gatherf((const float*)eai_in.weight_error_scale, texel);
}
vfloat scale = weight_error_scale * contrib_weight;
vfloat old_weight = gatherf(infilled_weights, texel);
vfloat ideal_weight = gatherf(eai_in.weights, texel);
error_change0 = error_change0 + contrib_weight * scale;
error_change1 = error_change1 + (old_weight - ideal_weight) * scale;
}
vfloat step = (error_change1 * chd_scale) / error_change0;
step = clamp(-stepsize, stepsize, step);
// update the weight
storea(weight_val + step, weight_set + i);
}
}
/*
For a decimation table, try to compute an optimal weight set, assuming
that the weights are quantized and subject to a transfer function.
We do this as follows:
First, we take the initial weights and quantize them. This is our initial estimate.
Then, go through the weights one by one; try to perturb then up and down one weight at a
time; apply any perturbations that improve overall error
Repeat until we have made a complete processing pass over all weights without
triggering any perturbations *OR* we have run 4 full passes.
*/
void compute_quantized_weights_for_decimation_table(
const decimation_table* dt,
float low_bound,
float high_bound,
const float* weight_set_in,
float* weight_set_out,
uint8_t* quantized_weight_set,
int quant_level
) {
int weight_count = dt->weight_count;
promise(weight_count > 0);
const quantization_and_transfer_table *qat = &(quant_and_xfer_tables[quant_level]);
static const int quant_levels[12] { 2,3,4,5,6,8,10,12,16,20,24,32 };
float quant_level_m1 = (float)(quant_levels[quant_level] - 1);
// Quantize the weight set using both the specified low/high bounds
// and the standard 0..1 weight bounds.
assert(high_bound > low_bound);
float rscale = high_bound - low_bound;
float scale = 1.0f / rscale;
float scaled_low_bound = low_bound * scale;
rscale *= 1.0f / 64.0f;
vfloat scalev(scale);
vfloat scaled_low_boundv(scaled_low_bound);
vfloat quant_level_m1v(quant_level_m1);
vfloat rscalev(rscale);
vfloat low_boundv(low_bound);
// This runs to the rounded-up SIMD size, which is safe as the loop tail is filled with known
// safe data in compute_ideal_weights_for_decimation_table and arrays are always 64 elements
for (int i = 0; i < weight_count; i += ASTCENC_SIMD_WIDTH)
{
vfloat ix = loada(&weight_set_in[i]) * scalev - scaled_low_boundv;
ix = clampzo(ix);
// Look up the two closest indexes and return the one that was closest
vfloat ix1 = ix * quant_level_m1v;
vint weightl = float_to_int(ix1);
vint weighth = weightl + vint(1);
vfloat ixl = gatherf(qat->unquantized_value_unsc, weightl);
vfloat ixh = gatherf(qat->unquantized_value_unsc, weighth);
vmask mask = (ixl + ixh) < (vfloat(128.0f) * ix);
vint weight = select(weightl, weighth, mask);
ixl = select(ixl, ixh, mask);
// Invert the weight-scaling that was done initially
storea(ixl * rscalev + low_boundv, &weight_set_out[i]);
vint scm = gatheri(qat->scramble_map, weight);
vint scn = pack_low_bytes(scm);
store_nbytes(scn, &quantized_weight_set[i]);
}
}
static inline vfloat4 compute_rgbovec(
vfloat4 rgba_weight_sum,
vfloat4 weight_weight_sum,
vfloat4 rgbq_sum,
float psum
) {
// Compute the rgb+offset for HDR endpoint mode #7. Since the matrix needed
// has a regular structure, we can simplify the inverse calculation. This
// gives us ~24 multiplications, down from 96 for a generic inverse
// mat[0] = vfloat4(rgba_ws.x, 0.0f, 0.0f, wght_ws.x);
// mat[1] = vfloat4( 0.0f, rgba_ws.y, 0.0f, wght_ws.y);
// mat[2] = vfloat4( 0.0f, 0.0f, rgba_ws.z, wght_ws.z);
// mat[3] = vfloat4(wght_ws.x, wght_ws.y, wght_ws.z, psum);
// mat = invert(mat);
float X = rgba_weight_sum.lane<0>();
float Y = rgba_weight_sum.lane<1>();
float Z = rgba_weight_sum.lane<2>();
float P = weight_weight_sum.lane<0>();
float Q = weight_weight_sum.lane<1>();
float R = weight_weight_sum.lane<2>();
float S = psum;
float PP = P * P;
float QQ = Q * Q;
float RR = R * R;
float SZmRR = S * Z - RR;
float DT = SZmRR * Y - Z * QQ;
float YP = Y * P;
float QX = Q * X;
float YX = Y * X;
float mZYP = -Z * YP;
float mZQX = -Z * QX;
float mRYX = -R * YX;
float ZQP = Z * Q * P;
float RYP = R * YP;
float RQX = R * QX;
// Compute the reciprocal of matrix determinant.
float rdet = 1.0f / (DT * X + mZYP * P);
// Actually compute the adjugate matrix, not the inverse, and apply the
// multiplication by 1/det to the vector separately.
vfloat4 mat0(DT, ZQP, RYP, mZYP);
vfloat4 mat1(ZQP, SZmRR * X - Z * PP, RQX, mZQX);
vfloat4 mat2(RYP, RQX, (S * Y - QQ) * X - Y * PP, mRYX);
vfloat4 mat3(mZYP, mZQX, mRYX, Z * YX);
vfloat4 vect = rgbq_sum * rdet;
return vfloat4(dot_s(mat0, vect),
dot_s(mat1, vect),
dot_s(mat2, vect),
dot_s(mat3, vect));
}
/* for a given weight set, we wish to recompute the colors so that they are optimal for a particular weight set. */
void recompute_ideal_colors_2planes(
int weight_quant_mode,
endpoints* ep, // contains the endpoints we wish to update
vfloat4* rgbs_vectors, // used to return RGBS-vectors for endpoint mode #6
vfloat4* rgbo_vectors, // used to return RGBO-vectors for endpoint mode #7
const uint8_t* weight_set8_plane1, // Plane 1 weight set
const uint8_t* weight_set8_plane2, // Plane 2 weight set
int plane2_component, // Color component for 2nd plane of weights
const partition_info* pt,
const decimation_table* dt,
const imageblock* blk, // picture-block containing the actual data.
const error_weight_block* ewb
) {
int weight_count = dt->weight_count;
int partition_count = pt->partition_count;
promise(weight_count > 0);
promise(partition_count > 0);
const quantization_and_transfer_table *qat = &(quant_and_xfer_tables[weight_quant_mode]);
float weight_set[MAX_WEIGHTS_PER_BLOCK];
float plane2_weight_set[MAX_WEIGHTS_PER_BLOCK];
for (int i = 0; i < weight_count; i++)
{
weight_set[i] = qat->unquantized_value[weight_set8_plane1[i]] * (1.0f / 64.0f);
plane2_weight_set[i] = qat->unquantized_value[weight_set8_plane2[i]] * (1.0f / 64.0f);
}
for (int i = 0; i < partition_count; i++)
{
vfloat4 rgba_sum(1e-17f);
vfloat4 rgba_weight_sum(1e-17f);
int texel_count = pt->partition_texel_count[i];
const uint8_t *texel_indexes = pt->texels_of_partition[i];
for (int j = 0; j < texel_count; j++)
{
int tix = texel_indexes[j];
vfloat4 rgba = blk->texel(tix);
vfloat4 error_weight = ewb->error_weights[tix];
rgba_sum += rgba * error_weight;
rgba_weight_sum += error_weight;
}
vfloat4 scale_direction = normalize((rgba_sum * (1.0f / rgba_weight_sum)).swz<0, 1, 2>());
float scale_max = 0.0f;
float scale_min = 1e10f;
float wmin1 = 1.0f;
float wmax1 = 0.0f;
float wmin2 = 1.0f;
float wmax2 = 0.0f;
vfloat4 left_sum = vfloat4::zero();
vfloat4 middle_sum = vfloat4::zero();
vfloat4 right_sum = vfloat4::zero();
vfloat4 left2_sum = vfloat4::zero();
vfloat4 middle2_sum = vfloat4::zero();
vfloat4 right2_sum = vfloat4::zero();
vfloat4 lmrs_sum = vfloat4::zero();
vfloat4 color_vec_x = vfloat4::zero();
vfloat4 color_vec_y = vfloat4::zero();
float2 scale_vec = float2(0.0f);
vfloat4 weight_weight_sum = vfloat4(1e-17f);
float psum = 1e-17f;
// FIXME: the loop below has too many responsibilities, making it inefficient.
for (int j = 0; j < texel_count; j++)
{
int tix = texel_indexes[j];
vfloat4 rgba = blk->texel(tix);
vfloat4 color_weight = ewb->error_weights[tix];
// FIXME: move this calculation out to the color block.
float ls_weight = hadd_rgb_s(color_weight);
float idx0 = bilinear_infill(*dt, weight_set, tix);
float om_idx0 = 1.0f - idx0;
wmin1 = astc::min(idx0, wmin1);
wmax1 = astc::max(idx0, wmax1);
float scale = dot3_s(scale_direction, rgba);
scale_min = astc::min(scale, scale_min);
scale_max = astc::max(scale, scale_max);
vfloat4 left = color_weight * (om_idx0 * om_idx0);
vfloat4 middle = color_weight * (om_idx0 * idx0);
vfloat4 right = color_weight * (idx0 * idx0);
vfloat4 lmrs = vfloat4(om_idx0 * om_idx0,
om_idx0 * idx0,
idx0 * idx0,
0.0f) * ls_weight;
left_sum += left;
middle_sum += middle;
right_sum += right;
lmrs_sum += lmrs;
float idx1 = 0.0f;
float om_idx1 = 0.0f;
idx1 = bilinear_infill(*dt, plane2_weight_set, tix);
om_idx1 = 1.0f - idx1;
wmin2 = astc::min(idx1, wmin2);
wmax2 = astc::max(idx1, wmax2);
vfloat4 left2 = color_weight * (om_idx1 * om_idx1);
vfloat4 middle2 = color_weight * (om_idx1 * idx1);
vfloat4 right2 = color_weight * (idx1 * idx1);
left2_sum += left2;
middle2_sum += middle2;
right2_sum += right2;
vmask4 p2_mask = vint4::lane_id() == vint4(plane2_component);
vfloat4 color_idx = select(vfloat4(idx0), vfloat4(idx1), p2_mask);
vfloat4 cwprod = color_weight * rgba;
vfloat4 cwiprod = cwprod * color_idx;
color_vec_y += cwiprod;
color_vec_x += cwprod - cwiprod;
scale_vec += float2(om_idx0, idx0) * (ls_weight * scale);
weight_weight_sum += (color_weight * color_idx);
psum += dot3_s(color_weight * color_idx, color_idx);
}
// calculations specific to mode #7, the HDR RGB-scale mode.
// FIXME: Can we skip this for LDR textures?
vfloat4 rgbq_sum = color_vec_x + color_vec_y;
rgbq_sum.set_lane<3>(hadd_rgb_s(color_vec_y));
vfloat4 rgbovec = compute_rgbovec(rgba_weight_sum, weight_weight_sum,
rgbq_sum, psum);
rgbo_vectors[i] = rgbovec;
// We will occasionally get a failure due to the use of a singular
// (non-invertible) matrix. Record whether such a failure has taken
// place; if it did, compute rgbo_vectors[] with a different method
// later on.
float chkval = dot_s(rgbovec, rgbovec);
int rgbo_fail = chkval != chkval;
// Initialize the luminance and scale vectors with a reasonable
// default, just in case the subsequent calculation blows up.
float scalediv = scale_min * (1.0f / astc::max(scale_max, 1e-10f));
scalediv = astc::clamp1f(scalediv);
vfloat4 sds = scale_direction * scale_max;
rgbs_vectors[i] = vfloat4(sds.lane<0>(), sds.lane<1>(), sds.lane<2>(), scalediv);
if (wmin1 >= wmax1 * 0.999f)
{
// if all weights in the partition were equal, then just take average
// of all colors in the partition and use that as both endpoint colors.
vfloat4 avg = (color_vec_x + color_vec_y) * (1.0f / rgba_weight_sum);
vmask4 p1_mask = vint4::lane_id() != vint4(plane2_component);
vmask4 notnan_mask = avg == avg;
vmask4 full_mask = p1_mask & notnan_mask;
ep->endpt0[i] = select(ep->endpt0[i], avg, full_mask);
ep->endpt1[i] = select(ep->endpt1[i], avg, full_mask);
rgbs_vectors[i] = vfloat4(sds.lane<0>(), sds.lane<1>(), sds.lane<2>(), 1.0f);
}
else
{
// otherwise, complete the analytic calculation of ideal-endpoint-values
// for the given set of texel weights and pixel colors.
vfloat4 color_det1 = (left_sum * right_sum) - (middle_sum * middle_sum);
vfloat4 color_rdet1 = 1.0f / color_det1;
float ls_det1 = (lmrs_sum.lane<0>() * lmrs_sum.lane<2>()) - (lmrs_sum.lane<1>() * lmrs_sum.lane<1>());
float ls_rdet1 = 1.0f / ls_det1;
vfloat4 color_mss1 = (left_sum * left_sum)
+ (2.0f * middle_sum * middle_sum)
+ (right_sum * right_sum);
float ls_mss1 = (lmrs_sum.lane<0>() * lmrs_sum.lane<0>())
+ (2.0f * lmrs_sum.lane<1>() * lmrs_sum.lane<1>())
+ (lmrs_sum.lane<2>() * lmrs_sum.lane<2>());
vfloat4 ep0 = (right_sum * color_vec_x - middle_sum * color_vec_y) * color_rdet1;
vfloat4 ep1 = (left_sum * color_vec_y - middle_sum * color_vec_x) * color_rdet1;
float scale_ep0 = (lmrs_sum.lane<2>() * scale_vec.r - lmrs_sum.lane<1>() * scale_vec.g) * ls_rdet1;
float scale_ep1 = (lmrs_sum.lane<0>() * scale_vec.g - lmrs_sum.lane<1>() * scale_vec.r) * ls_rdet1;
vmask4 p1_mask = vint4::lane_id() != vint4(plane2_component);
vmask4 det_mask = abs(color_det1) > (color_mss1 * 1e-4f);
vmask4 notnan_mask = (ep0 == ep0) & (ep1 == ep1);
vmask4 full_mask = p1_mask & det_mask & notnan_mask;
ep->endpt0[i] = select(ep->endpt0[i], ep0, full_mask);
ep->endpt1[i] = select(ep->endpt1[i], ep1, full_mask);
if (fabsf(ls_det1) > (ls_mss1 * 1e-4f) && scale_ep0 == scale_ep0 && scale_ep1 == scale_ep1 && scale_ep0 < scale_ep1)
{
float scalediv2 = scale_ep0 * (1.0f / scale_ep1);
vfloat4 sdsm = scale_direction * scale_ep1;
rgbs_vectors[i] = vfloat4(sdsm.lane<0>(), sdsm.lane<1>(), sdsm.lane<2>(), scalediv2);
}
}
if (wmin2 >= wmax2 * 0.999f)
{
// if all weights in the partition were equal, then just take average
// of all colors in the partition and use that as both endpoint colors.
vfloat4 avg = (color_vec_x + color_vec_y) * (1.0f / rgba_weight_sum);
vmask4 p2_mask = vint4::lane_id() == vint4(plane2_component);
vmask4 notnan_mask = avg == avg;
vmask4 full_mask = p2_mask & notnan_mask;
ep->endpt0[i] = select(ep->endpt0[i], avg, full_mask);
ep->endpt1[i] = select(ep->endpt1[i], avg, full_mask);
}
else
{
// otherwise, complete the analytic calculation of ideal-endpoint-values
// for the given set of texel weights and pixel colors.
vfloat4 color_det2 = (left2_sum * right2_sum) - (middle2_sum * middle2_sum);
vfloat4 color_rdet2 = 1.0f / color_det2;
vfloat4 color_mss2 = (left2_sum * left2_sum)
+ (2.0f * middle2_sum * middle2_sum)
+ (right2_sum * right2_sum);
vfloat4 ep0 = (right2_sum * color_vec_x - middle2_sum * color_vec_y) * color_rdet2;
vfloat4 ep1 = (left2_sum * color_vec_y - middle2_sum * color_vec_x) * color_rdet2;
vmask4 p2_mask = vint4::lane_id() == vint4(plane2_component);
vmask4 det_mask = abs(color_det2) > (color_mss2 * 1e-4f);
vmask4 notnan_mask = (ep0 == ep0) & (ep1 == ep1);
vmask4 full_mask = p2_mask & det_mask & notnan_mask;
ep->endpt0[i] = select(ep->endpt0[i], ep0, full_mask);
ep->endpt1[i] = select(ep->endpt1[i], ep1, full_mask);
}
// if the calculation of an RGB-offset vector failed, try to compute
// a somewhat-sensible value anyway
if (rgbo_fail)
{
vfloat4 v0 = ep->endpt0[i];
vfloat4 v1 = ep->endpt1[i];
float avgdif = hadd_rgb_s(v1 - v0) * (1.0f / 3.0f);
avgdif = astc::max(avgdif, 0.0f);
vfloat4 avg = (v0 + v1) * 0.5f;
vfloat4 ep0 = avg - vfloat4(avgdif) * 0.5f;
rgbo_vectors[i] = vfloat4(ep0.lane<0>(), ep0.lane<1>(), ep0.lane<2>(), avgdif);
}
}
}
/* for a given weight set, we wish to recompute the colors so that they are optimal for a particular weight set. */
void recompute_ideal_colors_1plane(
int weight_quant_mode,
endpoints* ep, // contains the endpoints we wish to update
vfloat4* rgbs_vectors, // used to return RGBS-vectors for endpoint mode #6
vfloat4* rgbo_vectors, // used to return RGBO-vectors for endpoint mode #7
const uint8_t* weight_set8, // the current set of weight values
const partition_info* pt,
const decimation_table* dt,
const imageblock* blk, // picture-block containing the actual data.
const error_weight_block* ewb
) {
int weight_count = dt->weight_count;
int partition_count = pt->partition_count;
promise(weight_count > 0);
promise(partition_count > 0);
const quantization_and_transfer_table *qat = &(quant_and_xfer_tables[weight_quant_mode]);
float weight_set[MAX_WEIGHTS_PER_BLOCK];
for (int i = 0; i < weight_count; i++)
{
weight_set[i] = qat->unquantized_value[weight_set8[i]] * (1.0f / 64.0f);
}
for (int i = 0; i < partition_count; i++)
{
vfloat4 rgba_sum(1e-17f);
vfloat4 rgba_weight_sum(1e-17f);
int texel_count = pt->partition_texel_count[i];
const uint8_t *texel_indexes = pt->texels_of_partition[i];
promise(texel_count > 0);
for (int j = 0; j < texel_count; j++)
{
int tix = texel_indexes[j];
vfloat4 rgba = blk->texel(tix);
vfloat4 error_weight = ewb->error_weights[tix];
rgba_sum += rgba * error_weight;
rgba_weight_sum += error_weight;
}
vfloat4 scale_direction = normalize((rgba_sum * (1.0f / rgba_weight_sum)).swz<0, 1, 2>());
float scale_max = 0.0f;
float scale_min = 1e10f;
float wmin1 = 1.0f;
float wmax1 = 0.0f;
vfloat4 left_sum = vfloat4::zero();
vfloat4 middle_sum = vfloat4::zero();
vfloat4 right_sum = vfloat4::zero();
vfloat4 lmrs_sum = vfloat4::zero();
vfloat4 color_vec_x = vfloat4::zero();
vfloat4 color_vec_y = vfloat4::zero();
float2 scale_vec = float2(0.0f);
vfloat4 weight_weight_sum = vfloat4(1e-17f);
float psum = 1e-17f;
// FIXME: the loop below has too many responsibilities, making it inefficient.
for (int j = 0; j < texel_count; j++)
{
int tix = texel_indexes[j];
vfloat4 rgba = blk->texel(tix);
vfloat4 color_weight = ewb->error_weights[tix];
// FIXME: move this calculation out to the color block.
float ls_weight = hadd_rgb_s(color_weight);
float idx0 = bilinear_infill(*dt, weight_set, tix);
float om_idx0 = 1.0f - idx0;
wmin1 = astc::min(idx0, wmin1);
wmax1 = astc::max(idx0, wmax1);
float scale = dot3_s(scale_direction, rgba);
scale_min = astc::min(scale, scale_min);
scale_max = astc::max(scale, scale_max);
vfloat4 left = color_weight * (om_idx0 * om_idx0);
vfloat4 middle = color_weight * (om_idx0 * idx0);
vfloat4 right = color_weight * (idx0 * idx0);
vfloat4 lmrs = vfloat4(om_idx0 * om_idx0,
om_idx0 * idx0,
idx0 * idx0,
0.0f) * ls_weight;
left_sum += left;
middle_sum += middle;
right_sum += right;
lmrs_sum += lmrs;
vfloat4 color_idx(idx0);
vfloat4 cwprod = color_weight * rgba;
vfloat4 cwiprod = cwprod * color_idx;
color_vec_y += cwiprod;
color_vec_x += cwprod - cwiprod;
scale_vec += (float2(om_idx0, idx0) * (ls_weight * scale));
weight_weight_sum += color_weight * color_idx;
psum += dot3_s(color_weight * color_idx, color_idx);
}
// calculations specific to mode #7, the HDR RGB-scale mode.
// FIXME: Can we skip this for LDR textures?
vfloat4 rgbq_sum = color_vec_x + color_vec_y;
rgbq_sum.set_lane<3>(hadd_rgb_s(color_vec_y));
vfloat4 rgbovec = compute_rgbovec(rgba_weight_sum, weight_weight_sum,
rgbq_sum, psum);
rgbo_vectors[i] = rgbovec;
// We will occasionally get a failure due to the use of a singular
// (non-invertible) matrix. Record whether such a failure has taken
// place; if it did, compute rgbo_vectors[] with a different method
// later on.
float chkval = dot_s(rgbovec, rgbovec);
int rgbo_fail = chkval != chkval;
// Initialize the luminance and scale vectors with a reasonable
// default, just in case the subsequent calculation blows up.
float scalediv = scale_min * (1.0f / astc::max(scale_max, 1e-10f));
scalediv = astc::clamp1f(scalediv);
vfloat4 sds = scale_direction * scale_max;
rgbs_vectors[i] = vfloat4(sds.lane<0>(), sds.lane<1>(), sds.lane<2>(), scalediv);
if (wmin1 >= wmax1 * 0.999f)
{
// if all weights in the partition were equal, then just take average
// of all colors in the partition and use that as both endpoint colors.
vfloat4 avg = (color_vec_x + color_vec_y) * (1.0f / rgba_weight_sum);
vmask4 notnan_mask = avg == avg;
ep->endpt0[i] = select(ep->endpt0[i], avg, notnan_mask);
ep->endpt1[i] = select(ep->endpt1[i], avg, notnan_mask);
rgbs_vectors[i] = vfloat4(sds.lane<0>(), sds.lane<1>(), sds.lane<2>(), 1.0f);
}
else
{
// otherwise, complete the analytic calculation of ideal-endpoint-values
// for the given set of texel weights and pixel colors.
vfloat4 color_det1 = (left_sum * right_sum) - (middle_sum * middle_sum);
vfloat4 color_rdet1 = 1.0f / color_det1;
float ls_det1 = (lmrs_sum.lane<0>() * lmrs_sum.lane<2>()) - (lmrs_sum.lane<1>() * lmrs_sum.lane<1>());
float ls_rdet1 = 1.0f / ls_det1;
vfloat4 color_mss1 = (left_sum * left_sum)
+ (2.0f * middle_sum * middle_sum)
+ (right_sum * right_sum);
float ls_mss1 = (lmrs_sum.lane<0>() * lmrs_sum.lane<0>())
+ (2.0f * lmrs_sum.lane<1>() * lmrs_sum.lane<1>())
+ (lmrs_sum.lane<2>() * lmrs_sum.lane<2>());
vfloat4 ep0 = (right_sum * color_vec_x - middle_sum * color_vec_y) * color_rdet1;
vfloat4 ep1 = (left_sum * color_vec_y - middle_sum * color_vec_x) * color_rdet1;
vmask4 det_mask = abs(color_det1) > (color_mss1 * 1e-4f);
vmask4 notnan_mask = (ep0 == ep0) & (ep1 == ep1);
vmask4 full_mask = det_mask & notnan_mask;
ep->endpt0[i] = select(ep->endpt0[i], ep0, full_mask);
ep->endpt1[i] = select(ep->endpt1[i], ep1, full_mask);
float scale_ep0 = (lmrs_sum.lane<2>() * scale_vec.r - lmrs_sum.lane<1>() * scale_vec.g) * ls_rdet1;
float scale_ep1 = (lmrs_sum.lane<0>() * scale_vec.g - lmrs_sum.lane<1>() * scale_vec.r) * ls_rdet1;
if (fabsf(ls_det1) > (ls_mss1 * 1e-4f) && scale_ep0 == scale_ep0 && scale_ep1 == scale_ep1 && scale_ep0 < scale_ep1)
{
float scalediv2 = scale_ep0 * (1.0f / scale_ep1);
vfloat4 sdsm = scale_direction * scale_ep1;
rgbs_vectors[i] = vfloat4(sdsm.lane<0>(), sdsm.lane<1>(), sdsm.lane<2>(), scalediv2);
}
}
// if the calculation of an RGB-offset vector failed, try to compute
// a somewhat-sensible value anyway
if (rgbo_fail)
{
vfloat4 v0 = ep->endpt0[i];
vfloat4 v1 = ep->endpt1[i];
float avgdif = hadd_rgb_s(v1 - v0) * (1.0f / 3.0f);
avgdif = astc::max(avgdif, 0.0f);
vfloat4 avg = (v0 + v1) * 0.5f;
vfloat4 ep0 = avg - vfloat4(avgdif) * 0.5f;
rgbo_vectors[i] = vfloat4(ep0.lane<0>(), ep0.lane<1>(), ep0.lane<2>(), avgdif);
}
}
}
#endif
| 31.938547 | 134 | 0.68478 | paintdream |
24162d68791ad302d220367b919a7c2ca053bf91 | 18,445 | cc | C++ | Models/LocaleMessage.pb.cc | wpscott/AcFunDanmaku-C- | c1b834dbb7133fd9d3908a8e0840747b759bdb0f | [
"MIT"
] | null | null | null | Models/LocaleMessage.pb.cc | wpscott/AcFunDanmaku-C- | c1b834dbb7133fd9d3908a8e0840747b759bdb0f | [
"MIT"
] | null | null | null | Models/LocaleMessage.pb.cc | wpscott/AcFunDanmaku-C- | c1b834dbb7133fd9d3908a8e0840747b759bdb0f | [
"MIT"
] | null | null | null | // Generated by the protocol buffer compiler. DO NOT EDIT!
// source: LocaleMessage.proto
#include "LocaleMessage.pb.h"
#include <algorithm>
#include <google/protobuf/io/coded_stream.h>
#include <google/protobuf/extension_set.h>
#include <google/protobuf/wire_format_lite.h>
#include <google/protobuf/descriptor.h>
#include <google/protobuf/generated_message_reflection.h>
#include <google/protobuf/reflection_ops.h>
#include <google/protobuf/wire_format.h>
// @@protoc_insertion_point(includes)
#include <google/protobuf/port_def.inc>
extern PROTOBUF_INTERNAL_EXPORT_LocaleMessage_2eproto ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<0> scc_info_LocaleMessage_ErrorMessageEntry_DoNotUse_LocaleMessage_2eproto;
namespace AcFunDanmu {
class LocaleMessage_ErrorMessageEntry_DoNotUseDefaultTypeInternal {
public:
::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed<LocaleMessage_ErrorMessageEntry_DoNotUse> _instance;
} _LocaleMessage_ErrorMessageEntry_DoNotUse_default_instance_;
class LocaleMessageDefaultTypeInternal {
public:
::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed<LocaleMessage> _instance;
} _LocaleMessage_default_instance_;
} // namespace AcFunDanmu
static void InitDefaultsscc_info_LocaleMessage_LocaleMessage_2eproto() {
GOOGLE_PROTOBUF_VERIFY_VERSION;
{
void* ptr = &::AcFunDanmu::_LocaleMessage_default_instance_;
new (ptr) ::AcFunDanmu::LocaleMessage();
::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr);
}
}
::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<1> scc_info_LocaleMessage_LocaleMessage_2eproto =
{{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 1, 0, InitDefaultsscc_info_LocaleMessage_LocaleMessage_2eproto}, {
&scc_info_LocaleMessage_ErrorMessageEntry_DoNotUse_LocaleMessage_2eproto.base,}};
static void InitDefaultsscc_info_LocaleMessage_ErrorMessageEntry_DoNotUse_LocaleMessage_2eproto() {
GOOGLE_PROTOBUF_VERIFY_VERSION;
{
void* ptr = &::AcFunDanmu::_LocaleMessage_ErrorMessageEntry_DoNotUse_default_instance_;
new (ptr) ::AcFunDanmu::LocaleMessage_ErrorMessageEntry_DoNotUse();
}
}
::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<0> scc_info_LocaleMessage_ErrorMessageEntry_DoNotUse_LocaleMessage_2eproto =
{{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 0, 0, InitDefaultsscc_info_LocaleMessage_ErrorMessageEntry_DoNotUse_LocaleMessage_2eproto}, {}};
static ::PROTOBUF_NAMESPACE_ID::Metadata file_level_metadata_LocaleMessage_2eproto[2];
static constexpr ::PROTOBUF_NAMESPACE_ID::EnumDescriptor const** file_level_enum_descriptors_LocaleMessage_2eproto = nullptr;
static constexpr ::PROTOBUF_NAMESPACE_ID::ServiceDescriptor const** file_level_service_descriptors_LocaleMessage_2eproto = nullptr;
const ::PROTOBUF_NAMESPACE_ID::uint32 TableStruct_LocaleMessage_2eproto::offsets[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = {
PROTOBUF_FIELD_OFFSET(::AcFunDanmu::LocaleMessage_ErrorMessageEntry_DoNotUse, _has_bits_),
PROTOBUF_FIELD_OFFSET(::AcFunDanmu::LocaleMessage_ErrorMessageEntry_DoNotUse, _internal_metadata_),
~0u, // no _extensions_
~0u, // no _oneof_case_
~0u, // no _weak_field_map_
PROTOBUF_FIELD_OFFSET(::AcFunDanmu::LocaleMessage_ErrorMessageEntry_DoNotUse, key_),
PROTOBUF_FIELD_OFFSET(::AcFunDanmu::LocaleMessage_ErrorMessageEntry_DoNotUse, value_),
0,
1,
~0u, // no _has_bits_
PROTOBUF_FIELD_OFFSET(::AcFunDanmu::LocaleMessage, _internal_metadata_),
~0u, // no _extensions_
~0u, // no _oneof_case_
~0u, // no _weak_field_map_
PROTOBUF_FIELD_OFFSET(::AcFunDanmu::LocaleMessage, locale_),
PROTOBUF_FIELD_OFFSET(::AcFunDanmu::LocaleMessage, errormessage_),
};
static const ::PROTOBUF_NAMESPACE_ID::internal::MigrationSchema schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = {
{ 0, 7, sizeof(::AcFunDanmu::LocaleMessage_ErrorMessageEntry_DoNotUse)},
{ 9, -1, sizeof(::AcFunDanmu::LocaleMessage)},
};
static ::PROTOBUF_NAMESPACE_ID::Message const * const file_default_instances[] = {
reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&::AcFunDanmu::_LocaleMessage_ErrorMessageEntry_DoNotUse_default_instance_),
reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&::AcFunDanmu::_LocaleMessage_default_instance_),
};
const char descriptor_table_protodef_LocaleMessage_2eproto[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) =
"\n\023LocaleMessage.proto\022\nAcFunDanmu\"\227\001\n\rLo"
"caleMessage\022\016\n\006locale\030\001 \001(\t\022A\n\014errorMess"
"age\030\002 \003(\0132+.AcFunDanmu.LocaleMessage.Err"
"orMessageEntry\0323\n\021ErrorMessageEntry\022\013\n\003k"
"ey\030\001 \001(\005\022\r\n\005value\030\002 \001(\t:\0028\001b\006proto3"
;
static const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable*const descriptor_table_LocaleMessage_2eproto_deps[1] = {
};
static ::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase*const descriptor_table_LocaleMessage_2eproto_sccs[2] = {
&scc_info_LocaleMessage_LocaleMessage_2eproto.base,
&scc_info_LocaleMessage_ErrorMessageEntry_DoNotUse_LocaleMessage_2eproto.base,
};
static ::PROTOBUF_NAMESPACE_ID::internal::once_flag descriptor_table_LocaleMessage_2eproto_once;
const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_LocaleMessage_2eproto = {
false, false, descriptor_table_protodef_LocaleMessage_2eproto, "LocaleMessage.proto", 195,
&descriptor_table_LocaleMessage_2eproto_once, descriptor_table_LocaleMessage_2eproto_sccs, descriptor_table_LocaleMessage_2eproto_deps, 2, 0,
schemas, file_default_instances, TableStruct_LocaleMessage_2eproto::offsets,
file_level_metadata_LocaleMessage_2eproto, 2, file_level_enum_descriptors_LocaleMessage_2eproto, file_level_service_descriptors_LocaleMessage_2eproto,
};
// Force running AddDescriptors() at dynamic initialization time.
static bool dynamic_init_dummy_LocaleMessage_2eproto = (static_cast<void>(::PROTOBUF_NAMESPACE_ID::internal::AddDescriptors(&descriptor_table_LocaleMessage_2eproto)), true);
namespace AcFunDanmu {
// ===================================================================
LocaleMessage_ErrorMessageEntry_DoNotUse::LocaleMessage_ErrorMessageEntry_DoNotUse() {}
LocaleMessage_ErrorMessageEntry_DoNotUse::LocaleMessage_ErrorMessageEntry_DoNotUse(::PROTOBUF_NAMESPACE_ID::Arena* arena)
: SuperType(arena) {}
void LocaleMessage_ErrorMessageEntry_DoNotUse::MergeFrom(const LocaleMessage_ErrorMessageEntry_DoNotUse& other) {
MergeFromInternal(other);
}
::PROTOBUF_NAMESPACE_ID::Metadata LocaleMessage_ErrorMessageEntry_DoNotUse::GetMetadata() const {
return GetMetadataStatic();
}
void LocaleMessage_ErrorMessageEntry_DoNotUse::MergeFrom(
const ::PROTOBUF_NAMESPACE_ID::Message& other) {
::PROTOBUF_NAMESPACE_ID::Message::MergeFrom(other);
}
// ===================================================================
class LocaleMessage::_Internal {
public:
};
LocaleMessage::LocaleMessage(::PROTOBUF_NAMESPACE_ID::Arena* arena)
: ::PROTOBUF_NAMESPACE_ID::Message(arena),
errormessage_(arena) {
SharedCtor();
RegisterArenaDtor(arena);
// @@protoc_insertion_point(arena_constructor:AcFunDanmu.LocaleMessage)
}
LocaleMessage::LocaleMessage(const LocaleMessage& from)
: ::PROTOBUF_NAMESPACE_ID::Message() {
_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
errormessage_.MergeFrom(from.errormessage_);
locale_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
if (!from._internal_locale().empty()) {
locale_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_locale(),
GetArena());
}
// @@protoc_insertion_point(copy_constructor:AcFunDanmu.LocaleMessage)
}
void LocaleMessage::SharedCtor() {
::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&scc_info_LocaleMessage_LocaleMessage_2eproto.base);
locale_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
}
LocaleMessage::~LocaleMessage() {
// @@protoc_insertion_point(destructor:AcFunDanmu.LocaleMessage)
SharedDtor();
_internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}
void LocaleMessage::SharedDtor() {
GOOGLE_DCHECK(GetArena() == nullptr);
locale_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
}
void LocaleMessage::ArenaDtor(void* object) {
LocaleMessage* _this = reinterpret_cast< LocaleMessage* >(object);
(void)_this;
}
void LocaleMessage::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) {
}
void LocaleMessage::SetCachedSize(int size) const {
_cached_size_.Set(size);
}
const LocaleMessage& LocaleMessage::default_instance() {
::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&::scc_info_LocaleMessage_LocaleMessage_2eproto.base);
return *internal_default_instance();
}
void LocaleMessage::Clear() {
// @@protoc_insertion_point(message_clear_start:AcFunDanmu.LocaleMessage)
::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
errormessage_.Clear();
locale_.ClearToEmpty();
_internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}
const char* LocaleMessage::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) {
#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
while (!ctx->Done(&ptr)) {
::PROTOBUF_NAMESPACE_ID::uint32 tag;
ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag);
CHK_(ptr);
switch (tag >> 3) {
// string locale = 1;
case 1:
if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 10)) {
auto str = _internal_mutable_locale();
ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx);
CHK_(::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, "AcFunDanmu.LocaleMessage.locale"));
CHK_(ptr);
} else goto handle_unusual;
continue;
// map<int32, string> errorMessage = 2;
case 2:
if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 18)) {
ptr -= 1;
do {
ptr += 1;
ptr = ctx->ParseMessage(&errormessage_, ptr);
CHK_(ptr);
if (!ctx->DataAvailable(ptr)) break;
} while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<18>(ptr));
} else goto handle_unusual;
continue;
default: {
handle_unusual:
if ((tag & 7) == 4 || tag == 0) {
ctx->SetLastTag(tag);
goto success;
}
ptr = UnknownFieldParse(tag,
_internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(),
ptr, ctx);
CHK_(ptr != nullptr);
continue;
}
} // switch
} // while
success:
return ptr;
failure:
ptr = nullptr;
goto success;
#undef CHK_
}
::PROTOBUF_NAMESPACE_ID::uint8* LocaleMessage::_InternalSerialize(
::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
// @@protoc_insertion_point(serialize_to_array_start:AcFunDanmu.LocaleMessage)
::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
(void) cached_has_bits;
// string locale = 1;
if (this->locale().size() > 0) {
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String(
this->_internal_locale().data(), static_cast<int>(this->_internal_locale().length()),
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE,
"AcFunDanmu.LocaleMessage.locale");
target = stream->WriteStringMaybeAliased(
1, this->_internal_locale(), target);
}
// map<int32, string> errorMessage = 2;
if (!this->_internal_errormessage().empty()) {
typedef ::PROTOBUF_NAMESPACE_ID::Map< ::PROTOBUF_NAMESPACE_ID::int32, std::string >::const_pointer
ConstPtr;
typedef ::PROTOBUF_NAMESPACE_ID::internal::SortItem< ::PROTOBUF_NAMESPACE_ID::int32, ConstPtr > SortItem;
typedef ::PROTOBUF_NAMESPACE_ID::internal::CompareByFirstField<SortItem> Less;
struct Utf8Check {
static void Check(ConstPtr p) {
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String(
p->second.data(), static_cast<int>(p->second.length()),
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE,
"AcFunDanmu.LocaleMessage.ErrorMessageEntry.value");
}
};
if (stream->IsSerializationDeterministic() &&
this->_internal_errormessage().size() > 1) {
::std::unique_ptr<SortItem[]> items(
new SortItem[this->_internal_errormessage().size()]);
typedef ::PROTOBUF_NAMESPACE_ID::Map< ::PROTOBUF_NAMESPACE_ID::int32, std::string >::size_type size_type;
size_type n = 0;
for (::PROTOBUF_NAMESPACE_ID::Map< ::PROTOBUF_NAMESPACE_ID::int32, std::string >::const_iterator
it = this->_internal_errormessage().begin();
it != this->_internal_errormessage().end(); ++it, ++n) {
items[static_cast<ptrdiff_t>(n)] = SortItem(&*it);
}
::std::sort(&items[0], &items[static_cast<ptrdiff_t>(n)], Less());
for (size_type i = 0; i < n; i++) {
target = LocaleMessage_ErrorMessageEntry_DoNotUse::Funcs::InternalSerialize(2, items[static_cast<ptrdiff_t>(i)].second->first, items[static_cast<ptrdiff_t>(i)].second->second, target, stream);
Utf8Check::Check(&(*items[static_cast<ptrdiff_t>(i)].second));
}
} else {
for (::PROTOBUF_NAMESPACE_ID::Map< ::PROTOBUF_NAMESPACE_ID::int32, std::string >::const_iterator
it = this->_internal_errormessage().begin();
it != this->_internal_errormessage().end(); ++it) {
target = LocaleMessage_ErrorMessageEntry_DoNotUse::Funcs::InternalSerialize(2, it->first, it->second, target, stream);
Utf8Check::Check(&(*it));
}
}
}
if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray(
_internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream);
}
// @@protoc_insertion_point(serialize_to_array_end:AcFunDanmu.LocaleMessage)
return target;
}
size_t LocaleMessage::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:AcFunDanmu.LocaleMessage)
size_t total_size = 0;
::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
// map<int32, string> errorMessage = 2;
total_size += 1 *
::PROTOBUF_NAMESPACE_ID::internal::FromIntSize(this->_internal_errormessage_size());
for (::PROTOBUF_NAMESPACE_ID::Map< ::PROTOBUF_NAMESPACE_ID::int32, std::string >::const_iterator
it = this->_internal_errormessage().begin();
it != this->_internal_errormessage().end(); ++it) {
total_size += LocaleMessage_ErrorMessageEntry_DoNotUse::Funcs::ByteSizeLong(it->first, it->second);
}
// string locale = 1;
if (this->locale().size() > 0) {
total_size += 1 +
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
this->_internal_locale());
}
if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
return ::PROTOBUF_NAMESPACE_ID::internal::ComputeUnknownFieldsSize(
_internal_metadata_, total_size, &_cached_size_);
}
int cached_size = ::PROTOBUF_NAMESPACE_ID::internal::ToCachedSize(total_size);
SetCachedSize(cached_size);
return total_size;
}
void LocaleMessage::MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) {
// @@protoc_insertion_point(generalized_merge_from_start:AcFunDanmu.LocaleMessage)
GOOGLE_DCHECK_NE(&from, this);
const LocaleMessage* source =
::PROTOBUF_NAMESPACE_ID::DynamicCastToGenerated<LocaleMessage>(
&from);
if (source == nullptr) {
// @@protoc_insertion_point(generalized_merge_from_cast_fail:AcFunDanmu.LocaleMessage)
::PROTOBUF_NAMESPACE_ID::internal::ReflectionOps::Merge(from, this);
} else {
// @@protoc_insertion_point(generalized_merge_from_cast_success:AcFunDanmu.LocaleMessage)
MergeFrom(*source);
}
}
void LocaleMessage::MergeFrom(const LocaleMessage& from) {
// @@protoc_insertion_point(class_specific_merge_from_start:AcFunDanmu.LocaleMessage)
GOOGLE_DCHECK_NE(&from, this);
_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
(void) cached_has_bits;
errormessage_.MergeFrom(from.errormessage_);
if (from.locale().size() > 0) {
_internal_set_locale(from._internal_locale());
}
}
void LocaleMessage::CopyFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) {
// @@protoc_insertion_point(generalized_copy_from_start:AcFunDanmu.LocaleMessage)
if (&from == this) return;
Clear();
MergeFrom(from);
}
void LocaleMessage::CopyFrom(const LocaleMessage& from) {
// @@protoc_insertion_point(class_specific_copy_from_start:AcFunDanmu.LocaleMessage)
if (&from == this) return;
Clear();
MergeFrom(from);
}
bool LocaleMessage::IsInitialized() const {
return true;
}
void LocaleMessage::InternalSwap(LocaleMessage* other) {
using std::swap;
_internal_metadata_.Swap<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(&other->_internal_metadata_);
errormessage_.Swap(&other->errormessage_);
locale_.Swap(&other->locale_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena());
}
::PROTOBUF_NAMESPACE_ID::Metadata LocaleMessage::GetMetadata() const {
return GetMetadataStatic();
}
// @@protoc_insertion_point(namespace_scope)
} // namespace AcFunDanmu
PROTOBUF_NAMESPACE_OPEN
template<> PROTOBUF_NOINLINE ::AcFunDanmu::LocaleMessage_ErrorMessageEntry_DoNotUse* Arena::CreateMaybeMessage< ::AcFunDanmu::LocaleMessage_ErrorMessageEntry_DoNotUse >(Arena* arena) {
return Arena::CreateMessageInternal< ::AcFunDanmu::LocaleMessage_ErrorMessageEntry_DoNotUse >(arena);
}
template<> PROTOBUF_NOINLINE ::AcFunDanmu::LocaleMessage* Arena::CreateMaybeMessage< ::AcFunDanmu::LocaleMessage >(Arena* arena) {
return Arena::CreateMessageInternal< ::AcFunDanmu::LocaleMessage >(arena);
}
PROTOBUF_NAMESPACE_CLOSE
// @@protoc_insertion_point(global_scope)
#include <google/protobuf/port_undef.inc>
| 44.55314 | 200 | 0.758254 | wpscott |
241639cc3f2214a8c5df38f579bfe756df9d631f | 2,166 | cpp | C++ | at2021b/past202104v/13.cpp | akouryy/competitive-programming-2021 | b5c65f5d6337d67e2e68c7c9c4d5832f661d571c | [
"MIT"
] | null | null | null | at2021b/past202104v/13.cpp | akouryy/competitive-programming-2021 | b5c65f5d6337d67e2e68c7c9c4d5832f661d571c | [
"MIT"
] | null | null | null | at2021b/past202104v/13.cpp | akouryy/competitive-programming-2021 | b5c65f5d6337d67e2e68c7c9c4d5832f661d571c | [
"MIT"
] | null | null | null | #include "base.hpp"
//#include "consts.hpp"
/* include禁止(コピペする) */
/*! http://codeforces.com/blog/entry/1256 http://codeforces.com/blog/entry/18051 */
constexpr int N = 262144; /*- たぶん2^xじゃなくても大丈夫 */
int same[N*2]; /*- 1, 2 3, 4 5 6 7, 8 9 10 11 12 13 14 15 */
int val[N*2]; /*- 1, 2 3, 4 5 6 7, 8 9 10 11 12 13 14 15 */
struct SegTree {
map<int, int> count;
int nPair;
SegTree(const VI& A) {
nPair = 0;
times(N, i) {
if(i < size(A)) {
val[i + N] = A[i];
nPair += count[A[i]]++;
} else {
val[i + N] = -1;
}
same[i] = false;
same[i + N] = true;
}
}
/** [l, r) 0-based **/
void update(int a, int b, int v) {
update(a, b, v, 1, 0, N);
}
void update(int a, int b, int v, int k, int l, int r) {
if(r <= a || b <= l) return;
dd a; b; v; k; l; r; a <= l && r <= b; same[k]; val[k];
if(a <= l && r <= b) {
if(same[k]) {
int xx = r - l;
dd count[val[k]]; count[v]; nPair; xx;
nPair -= count[val[k]] * (count[val[k]] - 1) / 2;
count[val[k]] -= xx;
nPair += count[val[k]] * (count[val[k]] - 1) / 2;
nPair -= count[v] * (count[v] - 1) / 2;
count[v] += xx;
nPair += count[v] * (count[v] - 1) / 2;
dd count[val[k]]; count[v]; nPair;
} else {
update(a, b, v, k * 2, l, (l + r) / 2);
update(a, b, v, k * 2 + 1, (l + r) / 2, r);
}
same[k] = true;
val[k] = v;
} else {
if(same[k]) {
same[k * 2] = same[k * 2 + 1] = true;
val[k * 2] = val[k * 2 + 1] = val[k];
}
update(a, b, v, k * 2, l, (l + r) / 2);
update(a, b, v, k * 2 + 1, (l + r) / 2, r);
if(same[k * 2] && same[k * 2 + 1] && val[k * 2] == val[k * 2 + 1]) {
same[k] = true;
val[k] = val[k * 2];
} else {
same[k] = false;
}
}
}
};
void solve() {
/* wt.ten
N NA Q Q(L- R X)
*/
int N,Q;cin>>N;VI A(N);times(N,i0){cin>>A[i0];}cin>>Q;VI L(Q),R(Q),X(Q);times(Q,i0){cin>>L[i0]>>R[i0]>>X[i0];
--L[i0];}
SegTree st(A);
times(Q, i) {
dd i;
st.update(L[i], R[i], X[i]);
cout << st.nPair ln;
}
}
| 25.482353 | 111 | 0.420591 | akouryy |
241887b579b10b9adafd612d00d96e1f9d7fb52e | 24,810 | cpp | C++ | Experiment_Test/ThirdGL/ThirdGL/Src/Chapter15/Block/Block.cpp | HelloWorld115/My_Test | c32524c7b8b970627200a767b86d1e4080b94a14 | [
"Apache-2.0"
] | null | null | null | Experiment_Test/ThirdGL/ThirdGL/Src/Chapter15/Block/Block.cpp | HelloWorld115/My_Test | c32524c7b8b970627200a767b86d1e4080b94a14 | [
"Apache-2.0"
] | null | null | null | Experiment_Test/ThirdGL/ThirdGL/Src/Chapter15/Block/Block.cpp | HelloWorld115/My_Test | c32524c7b8b970627200a767b86d1e4080b94a14 | [
"Apache-2.0"
] | null | null | null | // Block.cpp
// OpenGL SuperBible, Chapter 1
// Demonstrates an assortment of basic 3D concepts
// Program by Richard S. Wright Jr.
#include <glew.h>
#include <glxew.h>
#include <GLTools.h> // OpenGL toolkit
#include <GLMatrixStack.h>
#include <GLFrame.h>
#include <GLFrustum.h>
#include <GLBatch.h>
#include <GLGeometryTransform.h>
#include <math.h>
#ifdef linux
#include <cstdlib>
#endif
/////////////////////////////////////////////////////////////////////////////////
// An assortment of needed classes
GLShaderManager shaderManager;
GLMatrixStack modelViewMatrix;
GLMatrixStack projectionMatrix;
GLFrame cameraFrame;
GLFrustum viewFrustum;
GLBatch cubeBatch;
GLBatch floorBatch;
GLBatch topBlock;
GLBatch frontBlock;
GLBatch leftBlock;
GLGeometryTransform transformPipeline;
M3DMatrix44f shadowMatrix;
// Keep track of effects step
int nStep = 0;
// Lighting data
GLfloat lightAmbient[] = { 0.2f, 0.2f, 0.2f, 1.0f };
GLfloat lightDiffuse[] = { 0.7f, 0.7f, 0.7f, 1.0f };
GLfloat lightSpecular[] = { 0.9f, 0.9f, 0.9f };
GLfloat vLightPos[] = { -8.0f, 20.0f, 100.0f, 1.0f };
GLuint textures[4];
void EarlyInitGLXfnPointers()
{
glGenVertexArraysAPPLE = (void(*)(GLsizei, const GLuint*))glXGetProcAddressARB((GLubyte*)"glGenVertexArrays");
glBindVertexArrayAPPLE = (void(*)(const GLuint))glXGetProcAddressARB((GLubyte*)"glBindVertexArray");
glDeleteVertexArraysAPPLE = (void(*)(GLsizei, const GLuint*))glXGetProcAddressARB((GLubyte*)"glGenVertexArrays");
glXCreateContextAttribsARB = (GLXContext(*)(Display* dpy, GLXFBConfig config, GLXContext share_context, Bool direct, const int *attrib_list))glXGetProcAddressARB((GLubyte*)"glXCreateContextAttribsARB");
glXChooseFBConfig = (GLXFBConfig*(*)(Display *dpy, int screen, const int *attrib_list, int *nelements))glXGetProcAddressARB((GLubyte*)"glXChooseFBConfig");
glXGetVisualFromFBConfig = (XVisualInfo*(*)(Display *dpy, GLXFBConfig config))glXGetProcAddressARB((GLubyte*)"glXGetVisualFromFBConfig");
}
///////////////////////////////////////////////////////////////////////////////
// Make a cube out of a batch of triangles. Texture coordinates and normals
// are also provided.
void MakeCube(GLBatch& cubeBatch)
{
cubeBatch.Begin(GL_TRIANGLES, 36, 1);
/////////////////////////////////////////////
// Top of cube
cubeBatch.Normal3f(0.0f, 1.0f, 0.0f);
cubeBatch.MultiTexCoord2f(0, 1.0f, 1.0f);
cubeBatch.Vertex3f(1.0f, 1.0f, 1.0f);
cubeBatch.Normal3f(0.0f, 1.0f, 0.0f);
cubeBatch.MultiTexCoord2f(0, 1.0f, 0.0f);
cubeBatch.Vertex3f(1.0f, 1.0f, -1.0f);
cubeBatch.Normal3f(0.0f, 1.0f, 0.0f);
cubeBatch.MultiTexCoord2f(0, 0.0f, 0.0f);
cubeBatch.Vertex3f(-1.0f, 1.0f, -1.0f);
cubeBatch.Normal3f(0.0f, 1.0f, 0.0f);
cubeBatch.MultiTexCoord2f(0, 1.0f, 1.0f);
cubeBatch.Vertex3f(1.0f, 1.0f, 1.0f);
cubeBatch.Normal3f(0.0f, 1.0f, 0.0f);
cubeBatch.MultiTexCoord2f(0, 0.0f, 0.0f);
cubeBatch.Vertex3f(-1.0f, 1.0f, -1.0f);
cubeBatch.Normal3f(0.0f, 1.0f, 0.0f);
cubeBatch.MultiTexCoord2f(0, 0.0f, 1.0f);
cubeBatch.Vertex3f(-1.0f, 1.0f, 1.0f);
////////////////////////////////////////////
// Bottom of cube
cubeBatch.Normal3f(0.0f, -1.0f, 0.0f);
cubeBatch.MultiTexCoord2f(0, 0.0f, 0.0f);
cubeBatch.Vertex3f(-1.0f, -1.0f, -1.0f);
cubeBatch.Normal3f(0.0f, -1.0f, 0.0f);
cubeBatch.MultiTexCoord2f(0, 1.0f, 0.0f);
cubeBatch.Vertex3f(1.0f, -1.0f, -1.0f);
cubeBatch.Normal3f(0.0f, -1.0f, 0.0f);
cubeBatch.MultiTexCoord2f(0, 1.0f, 1.0f);
cubeBatch.Vertex3f(1.0f, -1.0f, 1.0f);
cubeBatch.Normal3f(0.0f, -1.0f, 0.0f);
cubeBatch.MultiTexCoord2f(0, 0.0f, 1.0f);
cubeBatch.Vertex3f(-1.0f, -1.0f, 1.0f);
cubeBatch.Normal3f(0.0f, -1.0f, 0.0f);
cubeBatch.MultiTexCoord2f(0, 0.0f, 0.0f);
cubeBatch.Vertex3f(-1.0f, -1.0f, -1.0f);
cubeBatch.Normal3f(0.0f, -1.0f, 0.0f);
cubeBatch.MultiTexCoord2f(0, 1.0f, 1.0f);
cubeBatch.Vertex3f(1.0f, -1.0f, 1.0f);
///////////////////////////////////////////
// Left side of cube
cubeBatch.Normal3f(-1.0f, 0.0f, 0.0f);
cubeBatch.MultiTexCoord2f(0, 1.0f, 1.0f);
cubeBatch.Vertex3f(-1.0f, 1.0f, 1.0f);
cubeBatch.Normal3f(-1.0f, 0.0f, 0.0f);
cubeBatch.MultiTexCoord2f(0, 1.0f, 0.0f);
cubeBatch.Vertex3f(-1.0f, 1.0f, -1.0f);
cubeBatch.Normal3f(-1.0f, 0.0f, 0.0f);
cubeBatch.MultiTexCoord2f(0, 0.0f, 0.0f);
cubeBatch.Vertex3f(-1.0f, -1.0f, -1.0f);
cubeBatch.Normal3f(-1.0f, 0.0f, 0.0f);
cubeBatch.MultiTexCoord2f(0, 1.0f, 1.0f);
cubeBatch.Vertex3f(-1.0f, 1.0f, 1.0f);
cubeBatch.Normal3f(-1.0f, 0.0f, 0.0f);
cubeBatch.MultiTexCoord2f(0, 0.0f, 0.0f);
cubeBatch.Vertex3f(-1.0f, -1.0f, -1.0f);
cubeBatch.Normal3f(-1.0f, 0.0f, 0.0f);
cubeBatch.MultiTexCoord2f(0, 0.0f, 1.0f);
cubeBatch.Vertex3f(-1.0f, -1.0f, 1.0f);
// Right side of cube
cubeBatch.Normal3f(1.0f, 0.0f, 0.0f);
cubeBatch.MultiTexCoord2f(0, 0.0f, 0.0f);
cubeBatch.Vertex3f(1.0f, -1.0f, -1.0f);
cubeBatch.Normal3f(1.0f, 0.0f, 0.0f);
cubeBatch.MultiTexCoord2f(0, 1.0f, 0.0f);
cubeBatch.Vertex3f(1.0f, 1.0f, -1.0f);
cubeBatch.Normal3f(1.0f, 0.0f, 0.0f);
cubeBatch.MultiTexCoord2f(0, 1.0f, 1.0f);
cubeBatch.Vertex3f(1.0f, 1.0f, 1.0f);
cubeBatch.Normal3f(1.0f, 0.0f, 0.0f);
cubeBatch.MultiTexCoord2f(0, 1.0f, 1.0f);
cubeBatch.Vertex3f(1.0f, 1.0f, 1.0f);
cubeBatch.Normal3f(1.0f, 0.0f, 0.0f);
cubeBatch.MultiTexCoord2f(0, 0.0f, 1.0f);
cubeBatch.Vertex3f(1.0f, -1.0f, 1.0f);
cubeBatch.Normal3f(1.0f, 0.0f, 0.0f);
cubeBatch.MultiTexCoord2f(0, 0.0f, 0.0f);
cubeBatch.Vertex3f(1.0f, -1.0f, -1.0f);
// Front and Back
// Front
cubeBatch.Normal3f(0.0f, 0.0f, 1.0f);
cubeBatch.MultiTexCoord2f(0, 1.0f, 0.0f);
cubeBatch.Vertex3f(1.0f, -1.0f, 1.0f);
cubeBatch.Normal3f(0.0f, 0.0f, 1.0f);
cubeBatch.MultiTexCoord2f(0, 1.0f, 1.0f);
cubeBatch.Vertex3f(1.0f, 1.0f, 1.0f);
cubeBatch.Normal3f(0.0f, 0.0f, 1.0f);
cubeBatch.MultiTexCoord2f(0, 0.0f, 1.0f);
cubeBatch.Vertex3f(-1.0f, 1.0f, 1.0f);
cubeBatch.Normal3f(0.0f, 0.0f, 1.0f);
cubeBatch.MultiTexCoord2f(0, 0.0f, 1.0f);
cubeBatch.Vertex3f(-1.0f, 1.0f, 1.0f);
cubeBatch.Normal3f(0.0f, 0.0f, 1.0f);
cubeBatch.MultiTexCoord2f(0, 0.0f, 0.0f);
cubeBatch.Vertex3f(-1.0f, -1.0f, 1.0f);
cubeBatch.Normal3f(0.0f, 0.0f, 1.0f);
cubeBatch.MultiTexCoord2f(0, 1.0f, 0.0f);
cubeBatch.Vertex3f(1.0f, -1.0f, 1.0f);
// Back
cubeBatch.Normal3f(0.0f, 0.0f, -1.0f);
cubeBatch.MultiTexCoord2f(0, 1.0f, 0.0f);
cubeBatch.Vertex3f(1.0f, -1.0f, -1.0f);
cubeBatch.Normal3f(0.0f, 0.0f, -1.0f);
cubeBatch.MultiTexCoord2f(0, 0.0f, 0.0f);
cubeBatch.Vertex3f(-1.0f, -1.0f, -1.0f);
cubeBatch.Normal3f(0.0f, 0.0f, -1.0f);
cubeBatch.MultiTexCoord2f(0, 0.0f, 1.0f);
cubeBatch.Vertex3f(-1.0f, 1.0f, -1.0f);
cubeBatch.Normal3f(0.0f, 0.0f, -1.0f);
cubeBatch.MultiTexCoord2f(0, 0.0f, 1.0f);
cubeBatch.Vertex3f(-1.0f, 1.0f, -1.0f);
cubeBatch.Normal3f(0.0f, 0.0f, -1.0f);
cubeBatch.MultiTexCoord2f(0, 1.0f, 1.0f);
cubeBatch.Vertex3f(1.0f, 1.0f, -1.0f);
cubeBatch.Normal3f(0.0f, 0.0f, -1.0f);
cubeBatch.MultiTexCoord2f(0, 1.0f, 0.0f);
cubeBatch.Vertex3f(1.0f, -1.0f, -1.0f);
cubeBatch.End();
}
/////////////////////////////////////////////////////////////////////////////
// Make the floor, just the verts and texture coordinates, no normals
void MakeFloor(GLBatch& floorBatch)
{
GLfloat x = 5.0f;
GLfloat y = -1.0f;
floorBatch.Begin(GL_TRIANGLE_FAN, 4, 1);
floorBatch.MultiTexCoord2f(0, 0.0f, 0.0f);
floorBatch.Vertex3f(-x, y, x);
floorBatch.MultiTexCoord2f(0, 1.0f, 0.0f);
floorBatch.Vertex3f(x, y, x);
floorBatch.MultiTexCoord2f(0, 1.0f, 1.0f);
floorBatch.Vertex3f(x, y, -x);
floorBatch.MultiTexCoord2f(0, 0.0f, 1.0f);
floorBatch.Vertex3f(-x, y, -x);
floorBatch.End();
}
typedef struct RenderContextRec
{
GLXContext ctx;
Display *dpy;
Window win;
int nWinWidth;
int nWinHeight;
} RenderContext;
void CreateWindow(RenderContext *rcx)
{
XSetWindowAttributes winAttribs;
GLint winmask;
GLint nMajorVer = 0;
GLint nMinorVer = 0;
XVisualInfo *visualInfo;
GLXFBConfig *fbConfigs;
int numConfigs = 0;
static int fbAttribs[] = {
GLX_RENDER_TYPE, GLX_RGBA_BIT,
GLX_X_RENDERABLE, True,
GLX_DRAWABLE_TYPE, GLX_WINDOW_BIT,
GLX_DOUBLEBUFFER, True,
GLX_RED_SIZE, 8,
GLX_BLUE_SIZE, 8,
GLX_GREEN_SIZE, 8,
0 };
// Tell X we are going to use the display
rcx->dpy = XOpenDisplay(NULL);
// Get Version info
glXQueryVersion(rcx->dpy, &nMajorVer, &nMinorVer);
printf("Supported GLX version - %d.%d\n", nMajorVer, nMinorVer);
if(nMajorVer == 1 && nMinorVer < 2)
{
printf("ERROR: GLX 1.2 or greater is necessary\n");
XCloseDisplay(rcx->dpy);
exit(0);
}
// Get a new fb config that meets our attrib requirements
fbConfigs = glXChooseFBConfig(rcx->dpy, DefaultScreen(rcx->dpy), fbAttribs, &numConfigs);
visualInfo = glXGetVisualFromFBConfig(rcx->dpy, fbConfigs[0]);
// Now create an X window
winAttribs.event_mask = ExposureMask | VisibilityChangeMask |
KeyPressMask | PointerMotionMask |
StructureNotifyMask ;
winAttribs.border_pixel = 0;
winAttribs.bit_gravity = StaticGravity;
winAttribs.colormap = XCreateColormap(rcx->dpy,
RootWindow(rcx->dpy, visualInfo->screen),
visualInfo->visual, AllocNone);
winmask = CWBorderPixel | CWBitGravity | CWEventMask| CWColormap;
rcx->win = XCreateWindow(rcx->dpy, DefaultRootWindow(rcx->dpy), 20, 20,
rcx->nWinWidth, rcx->nWinHeight, 0,
visualInfo->depth, InputOutput,
visualInfo->visual, winmask, &winAttribs);
XMapWindow(rcx->dpy, rcx->win);
// Also create a new GL context for rendering
GLint attribs[] = {
GLX_CONTEXT_MAJOR_VERSION_ARB, 3,
GLX_CONTEXT_MINOR_VERSION_ARB, 2,
0 };
rcx->ctx = glXCreateContextAttribsARB(rcx->dpy, fbConfigs[0], 0, True, attribs);
glXMakeCurrent(rcx->dpy, rcx->win, rcx->ctx);
GLenum err = glewInit();
if (GLEW_OK != err)
{
/* Problem: glewInit failed, something is seriously wrong. */
fprintf(stderr, "Error: %s\n", glewGetErrorString(err));
}
}
///////////////////////////////////////////////////////////////////////////////
// This function does any needed initialization on the rendering context.
// This is the first opportunity to do any OpenGL related tasks.
void SetupRC(RenderContext *rcx)
{
GLbyte *pBytes;
GLint nWidth, nHeight, nComponents;
GLenum format;
shaderManager.InitializeStockShaders();
// Black background
glClearColor(0.0f, 0.0f, 0.0f, 1.0f );
glEnable(GL_DEPTH_TEST);
glLineWidth(2.5f);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);
transformPipeline.SetMatrixStacks(modelViewMatrix, projectionMatrix);
cameraFrame.MoveForward(-15.0f);
cameraFrame.MoveUp(6.0f);
cameraFrame.RotateLocalX(float(m3dDegToRad(20.0f)));
MakeCube(cubeBatch);
MakeFloor(floorBatch);
// Make top
topBlock.Begin(GL_TRIANGLE_FAN, 4, 1);
topBlock.Normal3f(0.0f, 1.0f, 0.0f);
topBlock.MultiTexCoord2f(0, 0.0f, 0.0f);
topBlock.Vertex3f(-1.0f, 1.0f, 1.0f);
topBlock.Normal3f(0.0f, 1.0f, 0.0f);
topBlock.MultiTexCoord2f(0, 1.0f, 0.0f);
topBlock.Vertex3f(1.0f, 1.0f, 1.0f);
topBlock.Normal3f(0.0f, 1.0f, 0.0f);
topBlock.MultiTexCoord2f(0, 1.0f, 1.0f);
topBlock.Vertex3f(1.0f, 1.0f, -1.0f);
topBlock.Normal3f(0.0f, 1.0f, 0.0f);
topBlock.MultiTexCoord2f(0, 0.0f, 1.0f);
topBlock.Vertex3f(-1.0f, 1.0f, -1.0f);
topBlock.End();
// Make Front
frontBlock.Begin(GL_TRIANGLE_FAN, 4, 1);
frontBlock.Normal3f(0.0f, 0.0f, 1.0f);
frontBlock.MultiTexCoord2f(0, 0.0f, 0.0f);
frontBlock.Vertex3f(-1.0f, -1.0f, 1.0f);
frontBlock.Normal3f(0.0f, 0.0f, 1.0f);
frontBlock.MultiTexCoord2f(0, 1.0f, 0.0f);
frontBlock.Vertex3f(1.0f, -1.0f, 1.0f);
frontBlock.Normal3f(0.0f, 0.0f, 1.0f);
frontBlock.MultiTexCoord2f(0, 1.0f, 1.0f);
frontBlock.Vertex3f(1.0f, 1.0f, 1.0f);
frontBlock.Normal3f(0.0f, 0.0f, 1.0f);
frontBlock.MultiTexCoord2f(0, 0.0f, 1.0f);
frontBlock.Vertex3f(-1.0f, 1.0f, 1.0f);
frontBlock.End();
// Make left
leftBlock.Begin(GL_TRIANGLE_FAN, 4, 1);
leftBlock.Normal3f(-1.0f, 0.0f, 0.0f);
leftBlock.MultiTexCoord2f(0, 0.0f, 0.0f);
leftBlock.Vertex3f(-1.0f, -1.0f, -1.0f);
leftBlock.Normal3f(-1.0f, 0.0f, 0.0f);
leftBlock.MultiTexCoord2f(0, 1.0f, 0.0f);
leftBlock.Vertex3f(-1.0f, -1.0f, 1.0f);
leftBlock.Normal3f(-1.0f, 0.0f, 0.0f);
leftBlock.MultiTexCoord2f(0, 1.0f, 1.0f);
leftBlock.Vertex3f(-1.0f, 1.0f, 1.0f);
leftBlock.Normal3f(-1.0f, 0.0f, 0.0f);
leftBlock.MultiTexCoord2f(0, 0.0f, 1.0f);
leftBlock.Vertex3f(-1.0f, 1.0f, -1.0f);
leftBlock.End();
// Create shadow projection matrix
GLfloat floorPlane[] = { 0.0f, 1.0f, 0.0f, 1.0f};
m3dMakePlanarShadowMatrix(shadowMatrix, floorPlane, vLightPos);
// Load up four textures
glGenTextures(4, textures);
// Wood floor
pBytes = gltReadTGABits("floor.tga", &nWidth, &nHeight, &nComponents, &format);
glBindTexture(GL_TEXTURE_2D, textures[0]);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexImage2D(GL_TEXTURE_2D,0,nComponents,nWidth, nHeight, 0,
format, GL_UNSIGNED_BYTE, pBytes);
free(pBytes);
// One of the block faces
pBytes = gltReadTGABits("Block4.tga", &nWidth, &nHeight, &nComponents, &format);
glBindTexture(GL_TEXTURE_2D, textures[1]);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexImage2D(GL_TEXTURE_2D,0,nComponents,nWidth, nHeight, 0,
format, GL_UNSIGNED_BYTE, pBytes);
free(pBytes);
// Another block face
pBytes = gltReadTGABits("Block5.tga", &nWidth, &nHeight, &nComponents, &format);
glBindTexture(GL_TEXTURE_2D, textures[2]);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexImage2D(GL_TEXTURE_2D,0,nComponents,nWidth, nHeight, 0,
format, GL_UNSIGNED_BYTE, pBytes);
free(pBytes);
// Yet another block face
pBytes = gltReadTGABits("Block6.tga", &nWidth, &nHeight, &nComponents, &format);
glBindTexture(GL_TEXTURE_2D, textures[3]);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexImage2D(GL_TEXTURE_2D,0,nComponents,nWidth, nHeight, 0,
format, GL_UNSIGNED_BYTE, pBytes);
free(pBytes);
}
///////////////////////////////////////////////////////////////////////////////
// Render the block
void RenderBlock(void)
{
GLfloat vRed[] = { 1.0f, 0.0f, 0.0f, 1.0f};
GLfloat vWhite[] = { 1.0f, 1.0f, 1.0f, 1.0f };
switch(nStep)
{
// Wire frame
case 0:
glEnable(GL_BLEND);
glEnable(GL_LINE_SMOOTH);
shaderManager.UseStockShader(GLT_SHADER_FLAT, transformPipeline.GetModelViewProjectionMatrix(), vRed);
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
glDisable(GL_CULL_FACE);
// Draw the cube
cubeBatch.Draw();
break;
// Wire frame, but not the back side... we also want the block to be in the stencil buffer
case 1:
shaderManager.UseStockShader(GLT_SHADER_FLAT, transformPipeline.GetModelViewProjectionMatrix(), vRed);
// Draw (back side) solid block in stencil buffer
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
glEnable(GL_STENCIL_TEST);
glStencilFunc(GL_NEVER, 0, 0);
glStencilOp(GL_INCR, GL_INCR, GL_INCR);
glFrontFace(GL_CW);
cubeBatch.Draw();
glFrontFace(GL_CCW);
glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);
glDisable(GL_STENCIL_TEST);
glEnable(GL_BLEND);
glEnable(GL_LINE_SMOOTH);
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
// Draw the front side cube
cubeBatch.Draw();
break;
// Solid
case 2:
shaderManager.UseStockShader(GLT_SHADER_FLAT, transformPipeline.GetModelViewProjectionMatrix(), vRed);
// Draw the cube
cubeBatch.Draw();
break;
// Lit
case 3:
shaderManager.UseStockShader(GLT_SHADER_POINT_LIGHT_DIFF, modelViewMatrix.GetMatrix(),
projectionMatrix.GetMatrix(), vLightPos, vRed);
// Draw the cube
cubeBatch.Draw();
break;
// Textured & Lit
case 4:
case 5:
default:
glBindTexture(GL_TEXTURE_2D, textures[2]);
shaderManager.UseStockShader(GLT_SHADER_TEXTURE_POINT_LIGHT_DIFF, modelViewMatrix.GetMatrix(),
projectionMatrix.GetMatrix(), vLightPos, vWhite, 0);
glBindTexture(GL_TEXTURE_2D, textures[1]);
topBlock.Draw();
glBindTexture(GL_TEXTURE_2D, textures[2]);
frontBlock.Draw();
glBindTexture(GL_TEXTURE_2D, textures[3]);
leftBlock.Draw();
break;
}
// Put everything back
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
glEnable(GL_CULL_FACE);
glDisable(GL_BLEND);
glDisable(GL_LINE_SMOOTH);
glDisable(GL_STENCIL_TEST);
}
///////////////////////////////////////////////////////////////////////////////
// Render the floor
void RenderFloor(void)
{
GLfloat vBrown [] = { 0.55f, 0.292f, 0.09f, 1.0f};
GLfloat vFloor[] = { 1.0f, 1.0f, 1.0f, 0.6f };
switch(nStep)
{
// Wire frame
case 0:
glEnable(GL_BLEND);
glEnable(GL_LINE_SMOOTH);
shaderManager.UseStockShader(GLT_SHADER_FLAT, transformPipeline.GetModelViewProjectionMatrix(), vBrown);
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
glDisable(GL_CULL_FACE);
break;
// Wire frame, but not the back side.. and only where stencil == 0
case 1:
glEnable(GL_BLEND);
glEnable(GL_LINE_SMOOTH);
glEnable(GL_STENCIL_TEST);
glStencilFunc(GL_EQUAL, 0, 0xff);
shaderManager.UseStockShader(GLT_SHADER_FLAT, transformPipeline.GetModelViewProjectionMatrix(), vBrown);
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
break;
// Solid
case 2:
case 3:
shaderManager.UseStockShader(GLT_SHADER_FLAT, transformPipeline.GetModelViewProjectionMatrix(), vBrown);
break;
// Textured
case 4:
case 5:
default:
glBindTexture(GL_TEXTURE_2D, textures[0]);
shaderManager.UseStockShader(GLT_SHADER_TEXTURE_MODULATE, transformPipeline.GetModelViewProjectionMatrix(), vFloor, 0);
break;
}
// Draw the floor
floorBatch.Draw();
// Put everything back
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
glEnable(GL_CULL_FACE);
glDisable(GL_BLEND);
glDisable(GL_LINE_SMOOTH);
glDisable(GL_STENCIL_TEST);
}
///////////////////////////////////////////////////////////////////////////////
// Called to draw scene
void RenderScene(RenderContext *rcx)
{
// Clear the window with current clearing color
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
modelViewMatrix.PushMatrix();
M3DMatrix44f mCamera;
cameraFrame.GetCameraMatrix(mCamera);
modelViewMatrix.MultMatrix(mCamera);
// Reflection step... draw cube upside down, the floor
// blended on top of it
if(nStep == 5)
{
glDisable(GL_CULL_FACE);
modelViewMatrix.PushMatrix();
modelViewMatrix.Scale(1.0f, -1.0f, 1.0f);
modelViewMatrix.Translate(0.0f, 2.0f, 0.0f);
modelViewMatrix.Rotate(35.0f, 0.0f, 1.0f, 0.0f);
RenderBlock();
modelViewMatrix.PopMatrix();
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
RenderFloor();
glDisable(GL_BLEND);
}
modelViewMatrix.PushMatrix();
// Draw normally
modelViewMatrix.Rotate(35.0f, 0.0f, 1.0f, 0.0f);
RenderBlock();
modelViewMatrix.PopMatrix();
// If not the reflection pass, draw floor last
if(nStep != 5)
RenderFloor();
modelViewMatrix.PopMatrix();
// Flush drawing commands
glXSwapBuffers(rcx->dpy, rcx->win);
}
///////////////////////////////////////////////////////////////////////////////
// A normal ASCII key has been pressed.
// In this case, advance the scene when the space bar is pressed
void KeyPressFunc(unsigned char key)
{
if(key == 65)
{
nStep++;
if(nStep > 5)
nStep = 0;
}
}
///////////////////////////////////////////////////////////////////////////////
// Window has changed size, or has just been created. In either case, we need
// to use the window dimensions to set the viewport and the projection matrix.
void ChangeSize(int w, int h)
{
glViewport(0, 0, w, h);
viewFrustum.SetPerspective(35.0f, float(w) / float(h), 1.0f, 500.0f);
projectionMatrix.LoadMatrix(viewFrustum.GetProjectionMatrix());
modelViewMatrix.LoadIdentity();
}
void Cleanup(RenderContext *rcx)
{
glDeleteTextures(4,textures);
// Unbind the context before deleting
glXMakeCurrent(rcx->dpy, None, NULL);
glXDestroyContext(rcx->dpy, rcx->ctx);
rcx->ctx = NULL;
XDestroyWindow(rcx->dpy, rcx->win);
rcx->win = (Window)NULL;
XCloseDisplay(rcx->dpy);
rcx->dpy = 0;
}
///////////////////////////////////////////////////////////////////////////////
// Main entry point
int main(int argc, char* argv[])
{
Bool bWinMapped = False;
RenderContext rcx;
gltSetWorkingDirectory(argv[0]);
GLuint vertexArrayObject;
EarlyInitGLXfnPointers();
// Set initial window size
rcx.nWinWidth = 800;
rcx.nWinHeight = 600;
// Setup X window and GLX context
CreateWindow(&rcx);
SetupRC(&rcx);
ChangeSize(rcx.nWinWidth, rcx.nWinHeight);
// Draw the first frame before checking for messages
RenderScene(&rcx);
// Execute loop the whole time the app runs
for(;;)
{
XEvent newEvent;
XWindowAttributes winData;
// Watch for new X events
XNextEvent(rcx.dpy, &newEvent);
switch(newEvent.type)
{
case UnmapNotify:
bWinMapped = False;
break;
case MapNotify :
bWinMapped = True;
case ConfigureNotify:
XGetWindowAttributes(rcx.dpy, rcx.win, &winData);
rcx.nWinHeight = winData.height;
rcx.nWinWidth = winData.width;
ChangeSize(rcx.nWinWidth, rcx.nWinHeight);
break;
case KeyPress:
KeyPressFunc(newEvent.xkey.keycode);
break;
case DestroyNotify:
Cleanup(&rcx);
exit(0);
break;
}
if(bWinMapped)
{
RenderScene(&rcx);
}
}
Cleanup(&rcx);
return 0;
}
| 32.012903 | 203 | 0.608222 | HelloWorld115 |
2419d4c7b56e4b7732264e7de20a7e83c192c18e | 8,265 | cpp | C++ | core/blockchain/impl/key_value_block_storage.cpp | lamafab/kagome | 988bc6d93314ca58b320a9d83dcbc4cd3b87b7bb | [
"Apache-2.0"
] | null | null | null | core/blockchain/impl/key_value_block_storage.cpp | lamafab/kagome | 988bc6d93314ca58b320a9d83dcbc4cd3b87b7bb | [
"Apache-2.0"
] | null | null | null | core/blockchain/impl/key_value_block_storage.cpp | lamafab/kagome | 988bc6d93314ca58b320a9d83dcbc4cd3b87b7bb | [
"Apache-2.0"
] | null | null | null | /**
* Copyright Soramitsu Co., Ltd. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
*/
#include "blockchain/impl/key_value_block_storage.hpp"
#include "blockchain/impl/storage_util.hpp"
#include "scale/scale.hpp"
OUTCOME_CPP_DEFINE_CATEGORY(kagome::blockchain,
KeyValueBlockStorage::Error,
e) {
using E = kagome::blockchain::KeyValueBlockStorage::Error;
switch (e) {
case E::BLOCK_EXISTS:
return "Block already exists on the chain";
case E::BODY_DOES_NOT_EXIST:
return "Block body was not found";
case E::JUSTIFICATION_DOES_NOT_EXIST:
return "Justification was not found";
}
return "Unknown error";
}
namespace kagome::blockchain {
using primitives::Block;
using primitives::BlockId;
using storage::face::MapCursor;
using storage::face::WriteBatch;
using Buffer = common::Buffer;
using Prefix = prefix::Prefix;
KeyValueBlockStorage::KeyValueBlockStorage(
std::shared_ptr<storage::BufferStorage> storage,
std::shared_ptr<crypto::Hasher> hasher)
: storage_{std::move(storage)},
hasher_{std::move(hasher)},
logger_{common::createLogger("Block Storage:")} {}
outcome::result<std::shared_ptr<KeyValueBlockStorage>>
KeyValueBlockStorage::createWithGenesis(
common::Buffer state_root,
const std::shared_ptr<storage::BufferStorage> &storage,
std::shared_ptr<crypto::Hasher> hasher,
const GenesisHandler &on_genesis_created) {
KeyValueBlockStorage block_storage(storage, std::move(hasher));
// TODO(Harrm) check that storage is actually empty
// state root type is Hash256, however for consistency with spec root hash
// returns buffer. So we need this conversion
OUTCOME_TRY(state_root_blob,
common::Hash256::fromSpan(state_root.toVector()));
auto extrinsics_root_buf = trieRoot({});
// same reason for conversion as few lines above
OUTCOME_TRY(extrinsics_root,
common::Hash256::fromSpan(extrinsics_root_buf.toVector()));
// genesis block initialization
primitives::Block genesis_block;
genesis_block.header.number = 0;
genesis_block.header.extrinsics_root = extrinsics_root;
genesis_block.header.state_root = state_root_blob;
// the rest of the fields have default value
OUTCOME_TRY(block_storage.putBlock(genesis_block));
on_genesis_created(genesis_block);
return std::make_shared<KeyValueBlockStorage>(block_storage);
}
outcome::result<primitives::BlockHeader> KeyValueBlockStorage::getBlockHeader(
const primitives::BlockId &id) const {
OUTCOME_TRY(encoded_header, getWithPrefix(*storage_, Prefix::HEADER, id));
OUTCOME_TRY(header, scale::decode<primitives::BlockHeader>(encoded_header));
return std::move(header);
}
outcome::result<primitives::BlockBody> KeyValueBlockStorage::getBlockBody(
const primitives::BlockId &id) const {
OUTCOME_TRY(block_data, getBlockData(id));
if (block_data.body) {
return block_data.body.value();
}
return Error::BODY_DOES_NOT_EXIST;
}
outcome::result<primitives::BlockData> KeyValueBlockStorage::getBlockData(
const primitives::BlockId &id) const {
OUTCOME_TRY(encoded_block_data,
getWithPrefix(*storage_, Prefix::BLOCK_DATA, id));
OUTCOME_TRY(block_data,
scale::decode<primitives::BlockData>(encoded_block_data));
return std::move(block_data);
}
outcome::result<primitives::Justification>
KeyValueBlockStorage::getJustification(
const primitives::BlockId &block) const {
OUTCOME_TRY(block_data, getBlockData(block));
if (block_data.justification) {
return block_data.justification.value();
}
return Error::JUSTIFICATION_DOES_NOT_EXIST;
}
outcome::result<primitives::BlockHash> KeyValueBlockStorage::putBlockHeader(
const primitives::BlockHeader &header) {
OUTCOME_TRY(encoded_header, scale::encode(header));
auto block_hash = hasher_->blake2b_256(encoded_header);
OUTCOME_TRY(putWithPrefix(*storage_,
Prefix::HEADER,
header.number,
block_hash,
Buffer{std::move(encoded_header)}));
return block_hash;
}
outcome::result<void> KeyValueBlockStorage::putBlockData(
primitives::BlockNumber block_number,
const primitives::BlockData &block_data) {
primitives::BlockData to_insert;
// if block data does not exist, put a new one. Otherwise get the old one
// and merge with the new one. During the merge new block data fields have
// higher priority over the old ones (old ones should be rewritten)
auto existing_block_data_res = getBlockData(block_data.hash);
if (not existing_block_data_res) {
to_insert = block_data;
} else {
auto existing_data = existing_block_data_res.value();
// add all the fields from the new block_data
to_insert.header =
block_data.header ? block_data.header : existing_data.header;
to_insert.body = block_data.body ? block_data.body : existing_data.body;
to_insert.justification = block_data.justification
? block_data.justification
: existing_data.justification;
to_insert.message_queue = block_data.message_queue
? block_data.message_queue
: existing_data.message_queue;
to_insert.receipt =
block_data.receipt ? block_data.receipt : existing_data.receipt;
}
OUTCOME_TRY(encoded_block_data, scale::encode(to_insert));
OUTCOME_TRY(putWithPrefix(*storage_,
Prefix::BLOCK_DATA,
block_number,
block_data.hash,
Buffer{encoded_block_data}));
return outcome::success();
}
outcome::result<primitives::BlockHash> KeyValueBlockStorage::putBlock(
const primitives::Block &block) {
auto block_in_storage =
getWithPrefix(*storage_, Prefix::HEADER, block.header.number);
if (block_in_storage.has_value()) {
return Error::BLOCK_EXISTS;
}
if (block_in_storage.error() != blockchain::Error::BLOCK_NOT_FOUND) {
return block_in_storage.error();
}
// insert our block's parts into the database-
OUTCOME_TRY(block_hash, putBlockHeader(block.header));
primitives::BlockData block_data;
block_data.hash = block_hash;
block_data.header = block.header;
block_data.body = block.body;
OUTCOME_TRY(putBlockData(block.header.number, block_data));
logger_->info("Added block. Number: {}. Hash: {}. State root: {}",
block.header.number,
block_hash.toHex(),
block.header.state_root.toHex());
return block_hash;
}
outcome::result<void> KeyValueBlockStorage::putJustification(
const primitives::Justification &j,
const primitives::BlockHash &hash,
const primitives::BlockNumber &block_number) {
// insert justification into the database as a part of BlockData
primitives::BlockData block_data{.hash = hash, .justification = j};
OUTCOME_TRY(putBlockData(block_number, block_data));
return outcome::success();
}
outcome::result<void> KeyValueBlockStorage::removeBlock(
const primitives::BlockHash &hash,
const primitives::BlockNumber &number) {
auto block_lookup_key = numberAndHashToLookupKey(number, hash);
auto header_lookup_key = prependPrefix(block_lookup_key, Prefix::HEADER);
if (auto rm_res = storage_->remove(header_lookup_key); !rm_res) {
logger_->error("could not remove header from the storage: {}",
rm_res.error().message());
return rm_res;
}
auto body_lookup_key = prependPrefix(block_lookup_key, Prefix::BLOCK_DATA);
if (auto rm_res = storage_->remove(body_lookup_key); !rm_res) {
logger_->error("could not remove body from the storage: {}",
rm_res.error().message());
return rm_res;
}
return outcome::success();
}
} // namespace kagome::blockchain
| 38.621495 | 80 | 0.67441 | lamafab |
241bcc8e1235101d63e6a2af2164737d99ba7e83 | 32,070 | cc | C++ | cc/lispmds-import.cc | acorg/acmacs-chart-2 | 0e95cf11ee71d9c383a0ef5cc619edc8afbeda76 | [
"MIT"
] | null | null | null | cc/lispmds-import.cc | acorg/acmacs-chart-2 | 0e95cf11ee71d9c383a0ef5cc619edc8afbeda76 | [
"MIT"
] | null | null | null | cc/lispmds-import.cc | acorg/acmacs-chart-2 | 0e95cf11ee71d9c383a0ef5cc619edc8afbeda76 | [
"MIT"
] | null | null | null | #include <set>
#include <vector>
#include <limits>
#include <regex>
#include <cmath>
#include "acmacs-base/string.hh"
#include "acmacs-base/enumerate.hh"
#include "acmacs-base/fmt.hh"
#include "acmacs-chart-2/lispmds-import.hh"
#include "acmacs-chart-2/lispmds-encode.hh"
using namespace acmacs::chart;
// ----------------------------------------------------------------------
static std::vector<double> native_column_bases(const acmacs::lispmds::value& aData);
static std::vector<double> column_bases(const acmacs::lispmds::value& aData, size_t aProjectionNo);
static std::pair<std::shared_ptr<acmacs::chart::ColumnBases>, acmacs::chart::MinimumColumnBasis> forced_column_bases(const acmacs::lispmds::value& aData, size_t aProjectionNo);
// ----------------------------------------------------------------------
static inline size_t number_of_antigens(const acmacs::lispmds::value& aData)
{
return acmacs::lispmds::size(aData, 0, 1);
} // number_of_antigens
static inline size_t number_of_sera(const acmacs::lispmds::value& aData)
{
return acmacs::lispmds::size(aData, 0, 2);
} // number_of_sera
static inline const acmacs::lispmds::value& projection_data(const acmacs::lispmds::value& aData, size_t aProjectionNo)
{
if (acmacs::lispmds::empty(aData, ":STARTING-COORDSS"))
return acmacs::lispmds::get(aData, ":BATCH-RUNS", aProjectionNo);
else if (aProjectionNo == 0)
return acmacs::lispmds::get(aData, ":STARTING-COORDSS");
else
return acmacs::lispmds::get(aData, ":BATCH-RUNS", aProjectionNo - 1);
} // LispmdsProjection::data
static inline const acmacs::lispmds::value& projection_layout(const acmacs::lispmds::value& aData, size_t aProjectionNo)
{
if (acmacs::lispmds::empty(aData, ":STARTING-COORDSS"))
return acmacs::lispmds::get(aData, ":BATCH-RUNS", aProjectionNo, 0);
else if (aProjectionNo == 0)
return acmacs::lispmds::get(aData, ":STARTING-COORDSS");
else
return acmacs::lispmds::get(aData, ":BATCH-RUNS", aProjectionNo - 1, 0);
} // LispmdsProjection::data
// ----------------------------------------------------------------------
std::vector<double> native_column_bases(const acmacs::lispmds::value& aData)
{
std::vector<double> cb(number_of_sera(aData), 0);
for (const auto& row : std::get<acmacs::lispmds::list>(acmacs::lispmds::get(aData, 0, 3))) {
for (auto [sr_no, titer_v] : acmacs::enumerate(std::get<acmacs::lispmds::list>(row))) {
std::visit(
[&cb, sr_no = sr_no](auto&& titer) {
using T = std::decay_t<decltype(titer)>;
if constexpr (std::is_same_v<T, acmacs::lispmds::symbol>) {
double titer_d;
switch (titer[0]) {
case '<':
titer_d = std::stod(titer->substr(1));
if (titer_d > cb[sr_no])
cb[sr_no] = titer_d;
break;
case '>':
titer_d = std::stod(titer->substr(1)) + 1;
if (titer_d > cb[sr_no])
cb[sr_no] = titer_d;
break;
default:
break;
}
}
else if constexpr (std::is_same_v<T, acmacs::lispmds::number>) {
const double titer_d = titer;
if (titer_d > cb[sr_no])
cb[sr_no] = titer_d;
}
else
throw acmacs::lispmds::type_mismatch{fmt::format("Unexpected titer type: {}", typeid(T).name())};
},
titer_v);
}
}
return cb;
} // native_column_bases
// ----------------------------------------------------------------------
std::vector<double> column_bases(const acmacs::lispmds::value& aData, size_t aProjectionNo)
{
const auto num_antigens = number_of_antigens(aData);
const auto num_sera = number_of_sera(aData);
const auto number_of_points = num_antigens + num_sera;
const auto& cb = std::get<acmacs::lispmds::list>(acmacs::lispmds::get(projection_layout(aData, aProjectionNo), number_of_points, 0, 1));
std::vector<double> result(num_sera);
using diff_t = decltype(cb.end() - cb.begin());
std::transform(cb.begin() + static_cast<diff_t>(num_antigens), cb.begin() + static_cast<diff_t>(number_of_points), result.begin(), [](const auto& val) -> double { return std::get<acmacs::lispmds::number>(val); });
return result;
} // column_bases
// ----------------------------------------------------------------------
std::pair<std::shared_ptr<acmacs::chart::ColumnBases>, acmacs::chart::MinimumColumnBasis> forced_column_bases(const acmacs::lispmds::value& aData, size_t aProjectionNo)
{
try {
const auto native_cb = native_column_bases(aData);
const auto cb = column_bases(aData, aProjectionNo);
if (native_cb == cb) {
return {nullptr, acmacs::chart::MinimumColumnBasis()};
}
else {
const double min_forced = *std::min_element(cb.begin(), cb.end());
std::decay_t<decltype(native_cb)> native_upgraded(native_cb.size());
std::transform(native_cb.begin(), native_cb.end(), native_upgraded.begin(), [min_forced](double b) -> double { return std::max(b, min_forced); });
// std::cerr << "INFO: native: " << native_cb << '\n';
// std::cerr << "INFO: forced: " << cb << '\n';
// std::cerr << "INFO: upgrad: " << native_upgraded << '\n';
if (native_upgraded == cb)
return {nullptr, acmacs::chart::MinimumColumnBasis(min_forced)};
else
return {std::make_shared<LispmdsColumnBases>(cb), acmacs::chart::MinimumColumnBasis()};
}
}
catch (acmacs::lispmds::keyword_no_found&) {
return {nullptr, acmacs::chart::MinimumColumnBasis()};
}
catch (acmacs::lispmds::error& err) {
fmt::print(stderr, "WARNING: broken save: {}\n", err);
return {nullptr, acmacs::chart::MinimumColumnBasis()};
}
} // forced_column_bases
// ----------------------------------------------------------------------
ChartP acmacs::chart::lispmds_import(std::string_view aData, Verify aVerify)
{
try {
auto chart = std::make_shared<LispmdsChart>(acmacs::lispmds::parse_string(aData));
chart->verify_data(aVerify);
return chart;
}
catch (std::exception& err) {
fmt::print(stderr, "ERROR: lispmds_import: {}\n", err);
throw;
}
} // acmacs::chart::lispmds_import
// ----------------------------------------------------------------------
void LispmdsChart::verify_data(Verify) const
{
try {
if (number_of_antigens() == 0)
throw import_error("no antigens");
if (number_of_sera() == 0)
throw import_error("no sera (genetic tables are not supported)");
}
catch (std::exception& err) {
throw import_error{fmt::format("[lispmds]: structure verification failed: {}", err)};
}
} // LispmdsChart::verify_data
// ----------------------------------------------------------------------
InfoP LispmdsChart::info() const
{
return std::make_shared<LispmdsInfo>(mData);
} // LispmdsChart::info
// ----------------------------------------------------------------------
AntigensP LispmdsChart::antigens() const
{
return std::make_shared<LispmdsAntigens>(mData);
} // LispmdsChart::antigens
// ----------------------------------------------------------------------
SeraP LispmdsChart::sera() const
{
return std::make_shared<LispmdsSera>(mData);
} // LispmdsChart::sera
// ----------------------------------------------------------------------
TitersP LispmdsChart::titers() const
{
return std::make_shared<LispmdsTiters>(mData);
} // LispmdsChart::titers
// ----------------------------------------------------------------------
ColumnBasesP LispmdsChart::forced_column_bases(MinimumColumnBasis /*aMinimumColumnBasis*/) const
{
return ::forced_column_bases(mData, 0).first;
} // LispmdsChart::forced_column_bases
// ----------------------------------------------------------------------
ProjectionsP LispmdsChart::projections() const
{
if (!projections_)
projections_ = std::make_shared<LispmdsProjections>(*this, mData);
return projections_;
} // LispmdsChart::projections
// ----------------------------------------------------------------------
PlotSpecP LispmdsChart::plot_spec() const
{
return std::make_shared<LispmdsPlotSpec>(mData);
} // LispmdsChart::plot_spec
// ----------------------------------------------------------------------
size_t LispmdsChart::number_of_antigens() const
{
return ::number_of_antigens(mData);
} // LispmdsChart::number_of_antigens
// ----------------------------------------------------------------------
size_t LispmdsChart::number_of_sera() const
{
return ::number_of_sera(mData);
} // LispmdsChart::number_of_sera
// ----------------------------------------------------------------------
std::string LispmdsInfo::name(Compute) const
{
if (acmacs::lispmds::size(mData, 0) >= 5)
return lispmds_decode(std::get<acmacs::lispmds::symbol>(acmacs::lispmds::get(mData, 0, 4)));
else
return {};
} // LispmdsInfo::name
// ----------------------------------------------------------------------
static inline std::string antigen_name(const acmacs::lispmds::value& aData, size_t aIndex)
{
return *std::get<acmacs::lispmds::symbol>(acmacs::lispmds::get(aData, 0, 1, aIndex));
}
// ----------------------------------------------------------------------
acmacs::virus::name_t LispmdsAntigen::name() const
{
acmacs::virus::name_t name;
acmacs::virus::Reassortant reassortant;
acmacs::virus::Passage passage;
Annotations annotations;
lispmds_antigen_name_decode(antigen_name(mData, mIndex), name, reassortant, passage, annotations);
return name;
} // LispmdsAntigen::name
// ----------------------------------------------------------------------
acmacs::virus::Passage LispmdsAntigen::passage() const
{
acmacs::virus::name_t name;
acmacs::virus::Reassortant reassortant;
acmacs::virus::Passage passage;
Annotations annotations;
lispmds_antigen_name_decode(antigen_name(mData, mIndex), name, reassortant, passage, annotations);
return passage;
} // LispmdsAntigen::passage
// ----------------------------------------------------------------------
acmacs::virus::Reassortant LispmdsAntigen::reassortant() const
{
acmacs::virus::name_t name;
acmacs::virus::Reassortant reassortant;
acmacs::virus::Passage passage;
Annotations annotations;
lispmds_antigen_name_decode(antigen_name(mData, mIndex), name, reassortant, passage, annotations);
return reassortant;
} // LispmdsAntigen::reassortant
// ----------------------------------------------------------------------
Annotations LispmdsAntigen::annotations() const
{
acmacs::virus::name_t name;
acmacs::virus::Reassortant reassortant;
acmacs::virus::Passage passage;
Annotations annotations;
lispmds_antigen_name_decode(antigen_name(mData, mIndex), name, reassortant, passage, annotations);
return annotations;
} // LispmdsAntigen::annotations
// ----------------------------------------------------------------------
bool LispmdsAntigen::reference() const
{
try {
const auto& val = acmacs::lispmds::get(mData, ":REFERENCE-ANTIGENS");
if (acmacs::lispmds::empty(val))
return false;
const auto name = antigen_name(mData, mIndex);
const auto& val_l = std::get<acmacs::lispmds::list>(val);
return std::find_if(val_l.begin(), val_l.end(), [&name](const auto& ev) -> bool { return std::get<acmacs::lispmds::symbol>(ev) == acmacs::lispmds::symbol{name}; }) != val_l.end();
}
catch (acmacs::lispmds::keyword_no_found&) {
return false;
}
} // LispmdsAntigen::reference
// ----------------------------------------------------------------------
static inline std::string serum_name(const acmacs::lispmds::value& aData, size_t aIndex)
{
return *std::get<acmacs::lispmds::symbol>(acmacs::lispmds::get(aData, 0, 2, aIndex));
}
// ----------------------------------------------------------------------
acmacs::virus::name_t LispmdsSerum::name() const
{
acmacs::virus::name_t name;
acmacs::virus::Reassortant reassortant;
SerumId serum_id;
Annotations annotations;
lispmds_serum_name_decode(serum_name(mData, mIndex), name, reassortant, annotations, serum_id);
return name;
} // LispmdsSerum::name
// ----------------------------------------------------------------------
acmacs::virus::Reassortant LispmdsSerum::reassortant() const
{
acmacs::virus::name_t name;
acmacs::virus::Reassortant reassortant;
SerumId serum_id;
Annotations annotations;
lispmds_serum_name_decode(serum_name(mData, mIndex), name, reassortant, annotations, serum_id);
return reassortant;
} // LispmdsSerum::reassortant
// ----------------------------------------------------------------------
Annotations LispmdsSerum::annotations() const
{
acmacs::virus::name_t name;
acmacs::virus::Reassortant reassortant;
SerumId serum_id;
Annotations annotations;
lispmds_serum_name_decode(serum_name(mData, mIndex), name, reassortant, annotations, serum_id);
return annotations;
} // LispmdsSerum::annotations
// ----------------------------------------------------------------------
SerumId LispmdsSerum::serum_id() const
{
acmacs::virus::name_t name;
acmacs::virus::Reassortant reassortant;
SerumId serum_id;
Annotations annotations;
lispmds_serum_name_decode(serum_name(mData, mIndex), name, reassortant, annotations, serum_id);
return serum_id;
} // LispmdsSerum::serum_id
// ----------------------------------------------------------------------
size_t LispmdsAntigens::size() const
{
return number_of_antigens(mData);
} // LispmdsAntigens::size
// ----------------------------------------------------------------------
AntigenP LispmdsAntigens::operator[](size_t aIndex) const
{
return std::make_shared<LispmdsAntigen>(mData, aIndex);
} // LispmdsAntigens::operator[]
// ----------------------------------------------------------------------
size_t LispmdsSera::size() const
{
return number_of_sera(mData);
} // LispmdsSera::size
// ----------------------------------------------------------------------
SerumP LispmdsSera::operator[](size_t aIndex) const
{
return std::make_shared<LispmdsSerum>(mData, aIndex);
} // LispmdsSera::operator[]
// ----------------------------------------------------------------------
Titer LispmdsTiters::titer(size_t aAntigenNo, size_t aSerumNo) const
{
return std::visit(
[](auto&& titer_x) -> Titer {
using T = std::decay_t<decltype(titer_x)>;
if constexpr (std::is_same_v<T, acmacs::lispmds::symbol>) {
if (titer_x[0] == '*')
return Titer{std::string(1, titer_x[0])};
return Titer{fmt::format("{}{}", titer_x[0], std::lround(std::exp2(std::stod(titer_x->substr(1))) * 10))};
}
else if constexpr (std::is_same_v<T, acmacs::lispmds::number>) {
return Titer{fmt::format("{}", std::lround(std::exp2(static_cast<double>(titer_x)) * 10))};
}
else
throw acmacs::lispmds::type_mismatch{fmt::format("Unexpected titer type: {}", typeid(T).name())};
},
acmacs::lispmds::get(mData, 0, 3, aAntigenNo, aSerumNo));
} // LispmdsTiters::titer
// ----------------------------------------------------------------------
size_t LispmdsTiters::number_of_antigens() const
{
return acmacs::lispmds::size(mData, 0, 3);
} // LispmdsTiters::number_of_antigens
// ----------------------------------------------------------------------
size_t LispmdsTiters::number_of_sera() const
{
return acmacs::lispmds::size(mData, 0, 3, 0);
} // LispmdsTiters::number_of_sera
// ----------------------------------------------------------------------
inline bool is_dontcare(const acmacs::lispmds::value& titer)
{
return std::visit(
[](auto&& arg) -> bool {
using T = std::decay_t<decltype(arg)>;
if constexpr (std::is_same_v<T, acmacs::lispmds::symbol>)
return arg[0] == '*';
else if constexpr (std::is_same_v<T, acmacs::lispmds::number>)
return false;
else
throw acmacs::lispmds::type_mismatch{fmt::format("Unexpected titer type: {}", typeid(T).name())};
},
titer);
}
// ----------------------------------------------------------------------
size_t LispmdsTiters::number_of_non_dont_cares() const
{
size_t result = 0;
for (const auto& row : std::get<acmacs::lispmds::list>(acmacs::lispmds::get(mData, 0, 3))) {
for (const auto& titer : std::get<acmacs::lispmds::list>(row)) {
if (!is_dontcare(titer))
++result;
}
}
return result;
} // LispmdsTiters::number_of_non_dont_cares
// ----------------------------------------------------------------------
size_t LispmdsTiters::titrations_for_antigen(size_t antigen_no) const
{
size_t result = 0;
const auto& row = std::get<acmacs::lispmds::list>(acmacs::lispmds::get(mData, 0, 3))[antigen_no];
for (const auto& titer : std::get<acmacs::lispmds::list>(row)) {
if (!is_dontcare(titer))
++result;
}
return result;
} // LispmdsTiters::titrations_for_antigen
// ----------------------------------------------------------------------
size_t LispmdsTiters::titrations_for_serum(size_t serum_no) const
{
size_t result = 0;
for (const auto& row : std::get<acmacs::lispmds::list>(acmacs::lispmds::get(mData, 0, 3))) {
if (!is_dontcare(std::get<acmacs::lispmds::list>(row)[serum_no]))
++result;
}
return result;
} // LispmdsTiters::titrations_for_serum
// ----------------------------------------------------------------------
void LispmdsProjection::check() const
{
try {
if (auto nd = layout()->number_of_dimensions(); *nd > 5)
throw import_error{fmt::format("[lispmds] projection {} has unsupported number of dimensions: {}", projection_no(), nd)};
}
catch (std::exception& err) {
throw import_error{fmt::format("[lispmds] projection {} reading error: {}", projection_no(), err)};
}
} // LispmdsProjection::check
// ----------------------------------------------------------------------
std::optional<double> LispmdsProjection::stored_stress() const
{
return std::visit(
[](auto&& arg) -> std::optional<double> {
using T = std::decay_t<decltype(arg)>;
if constexpr (std::is_same_v<T, acmacs::lispmds::number>)
return static_cast<double>(arg);
else
return {};
},
acmacs::lispmds::get(projection_data(mData, projection_no()), 1));
} // LispmdsProjection::stress
// ----------------------------------------------------------------------
class LispmdsLayout : public acmacs::Layout
{
public:
LispmdsLayout(const acmacs::lispmds::value& aData, size_t aNumberOfAntigens, size_t aNumberOfSera)
: acmacs::Layout(aNumberOfAntigens + aNumberOfSera, acmacs::number_of_dimensions_t{acmacs::lispmds::size(aData, 0)})
{
auto target = Vec::begin();
for (size_t p_no = 0; p_no < number_of_points(); ++p_no) {
const auto& point = acmacs::lispmds::get(aData, p_no);
if (const auto ps = acmacs::lispmds::size(point); ps == *number_of_dimensions()) {
for (auto dim : acmacs::range(ps))
*target++ = std::get<acmacs::lispmds::number>(acmacs::lispmds::get(point, dim));
}
else if (ps > 0)
throw invalid_data(fmt::format("LispmdsLayout: point has invalid number of coordinates: {}, expected 0 or {}", ps, number_of_dimensions()));
else
target += static_cast<decltype(target)::difference_type>(*number_of_dimensions());
}
}
}; // class LispmdsLayout
// ----------------------------------------------------------------------
std::shared_ptr<acmacs::Layout> LispmdsProjection::layout() const
{
// std::cerr << "antigens: " << mNumberOfAntigens << " sera: " << mNumberOfSera << " points: " << (mNumberOfAntigens + mNumberOfSera) << '\n';
if (!layout_)
layout_ = std::make_shared<LispmdsLayout>(projection_layout(mData, projection_no()), mNumberOfAntigens, mNumberOfSera);
return layout_;
} // LispmdsProjection::layout
// ----------------------------------------------------------------------
acmacs::number_of_dimensions_t LispmdsProjection::number_of_dimensions() const
{
return acmacs::number_of_dimensions_t{acmacs::lispmds::size(projection_layout(mData, projection_no()), 0)};
} // LispmdsProjection::number_of_dimensions
// ----------------------------------------------------------------------
ColumnBasesP LispmdsProjection::forced_column_bases() const
{
return ::forced_column_bases(mData, projection_no()).first;
} // LispmdsProjection::forced_column_bases
// ----------------------------------------------------------------------
acmacs::chart::MinimumColumnBasis LispmdsProjection::minimum_column_basis() const
{
return ::forced_column_bases(mData, projection_no()).second;
} // LispmdsProjection::minimum_column_basis
// ----------------------------------------------------------------------
acmacs::Transformation LispmdsProjection::transformation() const
{
acmacs::Transformation result;
try {
if (const auto& coord_tr = acmacs::lispmds::get(mData, ":CANVAS-COORD-TRANSFORMATIONS"); !acmacs::lispmds::empty(coord_tr)) {
try {
if (const auto& v0 = acmacs::lispmds::get(coord_tr, ":CANVAS-BASIS-VECTOR-0"); !acmacs::lispmds::empty(v0)) {
result.a() = std::get<acmacs::lispmds::number>(acmacs::lispmds::get(v0, 0));
result.c() = std::get<acmacs::lispmds::number>(acmacs::lispmds::get(v0, 1));
}
}
catch (std::exception&) {
}
try {
if (const auto& v1 = acmacs::lispmds::get(coord_tr, ":CANVAS-BASIS-VECTOR-1"); !acmacs::lispmds::empty(v1)) {
result.b() = std::get<acmacs::lispmds::number>(acmacs::lispmds::get(v1, 0));
result.d() = std::get<acmacs::lispmds::number>(acmacs::lispmds::get(v1, 1));
}
}
catch (std::exception&) {
}
try {
if (static_cast<double>(std::get<acmacs::lispmds::number>(acmacs::lispmds::get(coord_tr, ":CANVAS-X-COORD-SCALE"))) < 0) {
result.a() = - result.a();
result.c() = - result.c();
}
}
catch (std::exception&) {
}
try {
if (static_cast<double>(std::get<acmacs::lispmds::number>(acmacs::lispmds::get(coord_tr, ":CANVAS-Y-COORD-SCALE"))) < 0) {
result.b() = - result.b();
result.d() = - result.d();
}
}
catch (std::exception&) {
}
}
}
catch (acmacs::lispmds::keyword_no_found&) {
}
return result;
} // LispmdsProjection::transformation
// ----------------------------------------------------------------------
UnmovablePoints LispmdsProjection::unmovable() const
{
// :UNMOVEABLE-COORDS '(87 86 85 83 82 80 81)
try {
const auto& val = std::get<acmacs::lispmds::list>(acmacs::lispmds::get(mData, ":UNMOVEABLE-COORDS"));
return {val.begin(), val.end(), [](const auto& v) -> size_t { return std::get<acmacs::lispmds::number>(v); }};
}
catch (std::exception&) {
return {};
}
} // LispmdsProjection::unmovable
// ----------------------------------------------------------------------
DisconnectedPoints LispmdsProjection::disconnected() const
{
// std::cerr << "WARNING: LispmdsProjection::disconnected not implemented\n";
return {};
} // LispmdsProjection::disconnected
// ----------------------------------------------------------------------
AvidityAdjusts LispmdsProjection::avidity_adjusts() const
{
try {
const auto num_points = layout()->number_of_points();
const acmacs::lispmds::list& cb = std::get<acmacs::lispmds::list>(acmacs::lispmds::get(projection_layout(mData, projection_no()), num_points, 0, 1));
AvidityAdjusts result(num_points);
for (size_t i = 0; i < num_points; ++i)
result[i] = std::exp2(static_cast<double>(std::get<acmacs::lispmds::number>(cb[num_points + i])));
return result;
}
catch (acmacs::lispmds::error& err) {
fmt::print(stderr, "ERROR: [lispmds avidity_adjusts] broken save: {}\n", err);
return {};
}
catch (std::exception& err) {
fmt::print(stderr, "ERROR: [lispmds avidity_adjusts]: {}\n", err);
throw;
}
} // LispmdsProjection::avidity_adjusts
// ----------------------------------------------------------------------
bool LispmdsProjections::empty() const
{
return acmacs::lispmds::empty(mData, ":STARTING-COORDSS") && acmacs::lispmds::empty(mData, ":BATCH-RUNS");
} // LispmdsProjections::empty
// ----------------------------------------------------------------------
size_t LispmdsProjections::size() const
{
size_t result = 0;
if (!acmacs::lispmds::empty(mData, ":STARTING-COORDSS"))
++result;
try {
result += acmacs::lispmds::size(mData, ":BATCH-RUNS");
}
catch (acmacs::lispmds::error&) {
}
return result;
} // LispmdsProjections::size
// ----------------------------------------------------------------------
ProjectionP LispmdsProjections::operator[](size_t aIndex) const
{
if (!projections_[aIndex])
projections_[aIndex] = std::make_shared<LispmdsProjection>(chart(), mData, aIndex, number_of_antigens(mData), number_of_sera(mData));
return projections_[aIndex];
} // LispmdsProjections::operator[]
// ----------------------------------------------------------------------
bool LispmdsPlotSpec::empty() const
{
try {
return acmacs::lispmds::empty(mData, ":PLOT-SPEC");
}
catch (std::exception&) {
return true;
}
} // LispmdsPlotSpec::empty
// ----------------------------------------------------------------------
DrawingOrder LispmdsPlotSpec::drawing_order() const
{
// :RAISE-POINTS 'NIL
// :LOWER-POINTS 'NIL
// don't know how drawing order is stored
return {};
} // LispmdsPlotSpec::drawing_order
// ----------------------------------------------------------------------
Color LispmdsPlotSpec::error_line_positive_color() const
{
return RED;
} // LispmdsPlotSpec::error_line_positive_color
// ----------------------------------------------------------------------
Color LispmdsPlotSpec::error_line_negative_color() const
{
return BLUE;
} // LispmdsPlotSpec::error_line_negative_color
// ----------------------------------------------------------------------
acmacs::PointStyle LispmdsPlotSpec::style(size_t aPointNo) const
{
acmacs::PointStyle result;
extract_style(result, aPointNo);
return result;
} // LispmdsPlotSpec::style
// ----------------------------------------------------------------------
std::vector<acmacs::PointStyle> LispmdsPlotSpec::all_styles() const
{
try {
const auto number_of_points = acmacs::lispmds::size(mData, 0, 1) + acmacs::lispmds::size(mData, 0, 2);
std::vector<acmacs::PointStyle> result(number_of_points);
for (size_t point_no = 0; point_no < number_of_points; ++point_no) {
extract_style(result[point_no], point_no);
}
return result;
}
catch (std::exception& err) {
AD_WARNING("[lispmds]: cannot get point styles: {}", err);
}
return {};
} // LispmdsPlotSpec::all_styles
// ----------------------------------------------------------------------
size_t LispmdsPlotSpec::number_of_points() const
{
try {
return acmacs::lispmds::size(mData, 0, 1) + acmacs::lispmds::size(mData, 0, 2);
}
catch (std::exception& err) {
AD_WARNING("[lispmds]: cannot get point styles: {}", err);
return 0;
}
} // LispmdsPlotSpec::number_of_points
// ----------------------------------------------------------------------
void LispmdsPlotSpec::extract_style(acmacs::PointStyle& aTarget, size_t aPointNo) const
{
std::string name = aPointNo < number_of_antigens(mData)
? static_cast<std::string>(std::get<acmacs::lispmds::symbol>(acmacs::lispmds::get(mData, 0, 1, aPointNo))) + "-AG"
: static_cast<std::string>(std::get<acmacs::lispmds::symbol>(acmacs::lispmds::get(mData, 0, 2, aPointNo - number_of_antigens(mData)))) + "-SR";
const auto& plot_spec = std::get<acmacs::lispmds::list>(acmacs::lispmds::get(mData, ":PLOT-SPEC"));
for (const auto& pstyle : plot_spec) {
if (std::get<acmacs::lispmds::symbol>(acmacs::lispmds::get(pstyle, 0)) == acmacs::lispmds::symbol{name}) {
extract_style(aTarget, std::get<acmacs::lispmds::list>(pstyle));
break;
}
}
} // LispmdsPlotSpec::extract_style
// ----------------------------------------------------------------------
void LispmdsPlotSpec::extract_style(acmacs::PointStyle& aTarget, const acmacs::lispmds::list& aSource) const
{
try {
aTarget.size(Pixels{static_cast<double>(std::get<acmacs::lispmds::number>(aSource[":DS"])) / acmacs::lispmds::DS_SCALE});
// if antigen also divide size by 2 ?
}
catch (std::exception&) {
}
try {
aTarget.label_text(*std::get<acmacs::lispmds::string>(aSource[":WN"]));
aTarget.label().shown = !aTarget.label_text().empty();
}
catch (std::exception&) {
}
try {
aTarget.shape(PointShape{*std::get<acmacs::lispmds::string>(aSource[":SH"])});
}
catch (std::exception&) {
}
try {
aTarget.label().size = Pixels{static_cast<double>(std::get<acmacs::lispmds::number>(aSource[":NS"])) / acmacs::lispmds::NS_SCALE};
}
catch (std::exception&) {
}
try {
if (const auto label_color = std::get<acmacs::lispmds::string>(aSource[":NC"]); label_color != acmacs::lispmds::string{"{}"})
aTarget.label().color = acmacs::color::Modifier{Color(*label_color)};
}
catch (std::exception&) {
}
try {
if (const auto fill_color = std::get<acmacs::lispmds::string>(aSource[":CO"]); fill_color != acmacs::lispmds::string{"{}"})
aTarget.fill(Color(*fill_color));
else
aTarget.fill(TRANSPARENT);
}
catch (std::exception&) {
}
try {
if (const auto outline_color = std::get<acmacs::lispmds::string>(aSource[":OC"]); outline_color != acmacs::lispmds::string{"{}"})
aTarget.outline(Color(*outline_color));
else
aTarget.outline(TRANSPARENT);
}
catch (std::exception&) {
}
try {
aTarget.fill(acmacs::color::Modifier{acmacs::color::Modifier::transparency_set{static_cast<double>(std::get<acmacs::lispmds::number>(aSource[":TR"]))}});
}
catch (std::exception&) {
}
} // LispmdsPlotSpec::extract_style
// ----------------------------------------------------------------------
/// Local Variables:
/// eval: (if (fboundp 'eu-rename-buffer) (eu-rename-buffer))
/// End:
| 35.125958 | 217 | 0.536296 | acorg |
241cd8fda7f5c03f59f7136ca1325baf92064849 | 3,123 | hpp | C++ | src/stan/math/prim/mat/prob/multi_normal_prec_rng.hpp | alashworth/stan-monorepo | 75596bc1f860ededd7b3e9ae9002aea97ee1cd46 | [
"BSD-3-Clause"
] | 1 | 2019-09-06T15:53:17.000Z | 2019-09-06T15:53:17.000Z | src/stan/math/prim/mat/prob/multi_normal_prec_rng.hpp | alashworth/stan-monorepo | 75596bc1f860ededd7b3e9ae9002aea97ee1cd46 | [
"BSD-3-Clause"
] | 8 | 2019-01-17T18:51:16.000Z | 2019-01-17T18:51:39.000Z | src/stan/math/prim/mat/prob/multi_normal_prec_rng.hpp | alashworth/stan-monorepo | 75596bc1f860ededd7b3e9ae9002aea97ee1cd46 | [
"BSD-3-Clause"
] | null | null | null | #ifndef STAN_MATH_PRIM_MAT_PROB_MULTI_NORMAL_PREC_RNG_HPP
#define STAN_MATH_PRIM_MAT_PROB_MULTI_NORMAL_PREC_RNG_HPP
#include <stan/math/prim/meta.hpp>
#include <stan/math/prim/mat/err/check_pos_definite.hpp>
#include <stan/math/prim/mat/err/check_symmetric.hpp>
#include <stan/math/prim/mat/fun/Eigen.hpp>
#include <stan/math/prim/scal/err/check_finite.hpp>
#include <stan/math/prim/scal/err/check_positive.hpp>
#include <boost/random/normal_distribution.hpp>
#include <boost/random/variate_generator.hpp>
namespace stan {
namespace math {
/**
* Return a multivariate normal random variate with the given location
* and precision using the specified random number generator.
*
* mu can be either an Eigen::VectorXd, an Eigen::RowVectorXd, or a
* std::vector of either of those types.
*
* @tparam T_loc Type of location paramater
* @tparam RNG Type of pseudo-random number generator
* @param mu (Sequence of) location parameter(s)
* @param S Precision matrix
* @param rng random number generator
* @throw std::domain_error if S is not positive definite, or
* std::invalid_argument if the length of (each) mu is not equal to
* the number of rows and columns in S
*/
template <typename T_loc, class RNG>
inline typename StdVectorBuilder<true, Eigen::VectorXd, T_loc>::type
multi_normal_prec_rng(const T_loc &mu, const Eigen::MatrixXd &S, RNG &rng) {
using boost::normal_distribution;
using boost::variate_generator;
static const char *function = "multi_normal_prec_rng";
check_positive(function, "Precision matrix rows", S.rows());
check_finite(function, "Precision matrix", S);
check_symmetric(function, "Precision matrix", S);
Eigen::LLT<Eigen::MatrixXd> llt_of_S = S.llt();
check_pos_definite(function, "precision matrix argument", llt_of_S);
vector_seq_view<T_loc> mu_vec(mu);
check_positive(function, "number of location parameter vectors",
mu_vec.size());
size_t size_mu = mu_vec[0].size();
size_t N = mu_vec.size();
for (size_t i = 1; i < N; i++) {
int size_mu_new = mu_vec[i].size();
check_size_match(function,
"Size of one of the vectors of "
"the location variable",
size_mu_new,
"Size of another vector of the "
"location variable",
size_mu);
}
for (size_t i = 0; i < N; i++) {
check_finite(function, "Location parameter", mu_vec[i]);
}
check_size_match(function, "Rows of location parameter", size_mu, "Rows of S",
S.rows());
StdVectorBuilder<true, Eigen::VectorXd, T_loc> output(N);
variate_generator<RNG &, normal_distribution<>> std_normal_rng(
rng, normal_distribution<>(0, 1));
for (size_t n = 0; n < N; ++n) {
Eigen::VectorXd z(S.cols());
for (int i = 0; i < S.cols(); i++)
z(i) = std_normal_rng();
output[n] = Eigen::VectorXd(mu_vec[n]) + llt_of_S.matrixU().solve(z);
}
return output.data();
}
} // namespace math
} // namespace stan
#endif
| 34.318681 | 81 | 0.663465 | alashworth |
241da46294ca59fa72f34e7c7b3c4ef8a3f5fbf7 | 739 | cpp | C++ | src/tests/testutil.cpp | sbu-fsl/Lintel | b9e603aaec630c8d3fae2f21fc156582d11d84c9 | [
"BSD-3-Clause"
] | null | null | null | src/tests/testutil.cpp | sbu-fsl/Lintel | b9e603aaec630c8d3fae2f21fc156582d11d84c9 | [
"BSD-3-Clause"
] | 1 | 2020-10-05T21:20:36.000Z | 2020-10-05T21:56:51.000Z | src/tests/testutil.cpp | sbu-fsl/Lintel | b9e603aaec630c8d3fae2f21fc156582d11d84c9 | [
"BSD-3-Clause"
] | null | null | null | /* -*-C++-*- */
/*
(c) Copyright 2008, Hewlett-Packard Development Company, LP
See the file named COPYING for license details
*/
/** @file
Tests for TestUtil
*/
#include <Lintel/TestUtil.hpp>
int main(int, char **) {
INVARIANT(true, "...");
TEST_INVARIANTMSG(FATAL_ERROR("die now"), "die now");
TEST_INVARIANTMSG(INVARIANT(false, boost::format("foo %s") % "bar"), "foo bar");
TEST_INVARIANTMSG(SINVARIANT(false), "No additional details provided");
TEST_INVARIANTMSG(FATAL_ERROR(boost::format("%1% %d")),
"Exception evaluating boost::format(\"%1% %d\")");
TEST_INVARIANTMSG(INVARIANT(1 == 0, "expected to fail"), "wrong test msg");
FATAL_ERROR("should not get here");
return 0;
}
| 28.423077 | 84 | 0.641407 | sbu-fsl |
241dd3108e9fd07f8e6ab5591a1775f9154f943c | 10,320 | cpp | C++ | graph/L3/src/op_wcc.cpp | Geekdude/Vitis_Libraries | bca52cee88c07e9ccbec90c00e6df98f4b450ec1 | [
"Apache-2.0"
] | 1 | 2021-04-19T20:40:02.000Z | 2021-04-19T20:40:02.000Z | graph/L3/src/op_wcc.cpp | Geekdude/Vitis_Libraries | bca52cee88c07e9ccbec90c00e6df98f4b450ec1 | [
"Apache-2.0"
] | null | null | null | graph/L3/src/op_wcc.cpp | Geekdude/Vitis_Libraries | bca52cee88c07e9ccbec90c00e6df98f4b450ec1 | [
"Apache-2.0"
] | 1 | 2021-04-28T05:58:38.000Z | 2021-04-28T05:58:38.000Z | /*
* Copyright 2020 Xilinx, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#pragma once
#ifndef _XF_GRAPH_L3_OP_WCC_CPP_
#define _XF_GRAPH_L3_OP_WCC_CPP_
#include "op_wcc.hpp"
namespace xf {
namespace graph {
namespace L3 {
void createHandleWCC(clHandle& handle, const char* kernelName, const char* pXclbin, int32_t IDDevice) {
// Platform related operations
std::vector<cl::Device> devices = xcl::get_xil_devices();
handle.device = devices[IDDevice];
handle.context = cl::Context(handle.device);
handle.q = cl::CommandQueue(handle.context, handle.device,
CL_QUEUE_PROFILING_ENABLE | CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE);
std::string devName = handle.device.getInfo<CL_DEVICE_NAME>();
printf("INFO: Found Device=%s\n", devName.c_str());
handle.xclBins = xcl::import_binary_file(pXclbin);
std::vector<cl::Device> devices2;
devices2.push_back(handle.device);
handle.program = cl::Program(handle.context, devices2, handle.xclBins);
}
uint32_t opWCC::cuPerBoardWCC;
uint32_t opWCC::dupNmWCC;
void opWCC::setHWInfo(uint32_t numDev, uint32_t CUmax) {
maxCU = CUmax;
deviceNm = numDev;
cuPerBoardWCC = maxCU / deviceNm;
handles = new clHandle[CUmax];
};
void opWCC::freeWCC() {
for (int i = 0; i < maxCU; ++i) {
delete[] handles[i].buffer;
}
delete[] handles;
};
void opWCC::cuRelease(xrmContext* ctx, xrmCuResource* resR) {
while (!xrmCuRelease(ctx, resR)) {
};
free(resR);
};
void opWCC::init(char* kernelName, char* xclbinFile, uint32_t* deviceIDs, uint32_t* cuIDs, unsigned int requestLoad) {
dupNmWCC = 100 / requestLoad;
cuPerBoardWCC /= dupNmWCC;
uint32_t bufferNm = 8;
unsigned int cnt = 0;
unsigned int cntCU = 0;
unsigned int* handleID = new unsigned int[maxCU];
handleID[0] = cnt;
handles[0].deviceID = deviceIDs[0];
handles[0].cuID = cuIDs[0];
handles[0].dupID = 0;
std::thread th[maxCU];
// th[0] = std::thread(&createHandleWCC, std::ref(handles[cnt]), kernelName, xclbinFile, deviceIDs[cnt]);
createHandleWCC(handles[cnt], kernelName, xclbinFile, deviceIDs[cnt]);
handles[cnt].buffer = new cl::Buffer[bufferNm];
unsigned int prev = deviceIDs[0];
unsigned int prevCU = cuIDs[0];
deviceOffset.push_back(0);
for (int i = 1; i < maxCU; ++i) {
handles[i].deviceID = deviceIDs[i];
handles[i].cuID = cuIDs[i];
handles[i].dupID = i % dupNmWCC;
// th[i] = std::thread(&createHandleWCC, std::ref(handles[i]), kernelName, xclbinFile, deviceIDs[i]);
createHandleWCC(handles[i], kernelName, xclbinFile, deviceIDs[i]);
handles[i].buffer = new cl::Buffer[bufferNm];
if (deviceIDs[i] != prev) {
prev = deviceIDs[i];
deviceOffset.push_back(i);
}
}
delete[] handleID;
}
void opWCC::migrateMemObj(clHandle* hds,
bool type,
unsigned int num_runs,
std::vector<cl::Memory>& ob,
std::vector<cl::Event>* evIn,
cl::Event* evOut) {
for (int i = 0; i < num_runs; ++i) {
hds[0].q.enqueueMigrateMemObjects(ob, type, evIn, evOut); // 0 : migrate from host to dev
}
};
void opWCC::bufferInit(clHandle* hds,
std::string instanceName0,
xf::graph::Graph<uint32_t, uint32_t> g,
uint32_t* offsetsG2,
uint32_t* indicesG2,
uint32_t* offsetsTmp1,
uint32_t* offsetsTmp2,
uint32_t* queue,
uint32_t* result,
cl::Kernel& kernel0,
std::vector<cl::Memory>& ob_in,
std::vector<cl::Memory>& ob_out) {
cl::Device device = hds[0].device;
const char* instanceName = instanceName0.c_str();
// Creating Context and Command Queue for selected Device
cl::Context context = hds[0].context;
cl::CommandQueue q = hds[0].q;
std::string devName = device.getInfo<CL_DEVICE_NAME>();
printf("INFO: Found Device=%s\n", devName.c_str());
std::vector<cl::Device> devices;
devices.push_back(hds[0].device);
cl::Program program = hds[0].program;
kernel0 = cl::Kernel(program, instanceName);
std::cout << "INFO: Kernel has been created" << std::endl;
std::vector<cl_mem_ext_ptr_t> mext_in = std::vector<cl_mem_ext_ptr_t>(8);
mext_in[0] = {(unsigned int)(3) | XCL_MEM_TOPOLOGY, g.offsetsCSR, kernel0()};
mext_in[1] = {(unsigned int)(2) | XCL_MEM_TOPOLOGY, g.indicesCSR, kernel0()};
mext_in[2] = {(unsigned int)(6) | XCL_MEM_TOPOLOGY, offsetsG2, kernel0()};
mext_in[3] = {(unsigned int)(5) | XCL_MEM_TOPOLOGY, indicesG2, kernel0()};
mext_in[4] = {(unsigned int)(7) | XCL_MEM_TOPOLOGY, offsetsTmp1, kernel0()};
mext_in[5] = {(unsigned int)(8) | XCL_MEM_TOPOLOGY, offsetsTmp2, kernel0()};
mext_in[6] = {(unsigned int)(10) | XCL_MEM_TOPOLOGY, queue, kernel0()};
mext_in[7] = {(unsigned int)(12) | XCL_MEM_TOPOLOGY, result, kernel0()};
uint32_t numVertices = g.nodeNum;
uint32_t numEdges = g.edgeNum;
// create device buffer and map dev buf to host buf
hds[0].buffer[1] = cl::Buffer(context, CL_MEM_EXT_PTR_XILINX | CL_MEM_USE_HOST_PTR | CL_MEM_READ_WRITE,
sizeof(uint32_t) * numEdges, &mext_in[1]);
hds[0].buffer[0] = cl::Buffer(context, CL_MEM_EXT_PTR_XILINX | CL_MEM_USE_HOST_PTR | CL_MEM_READ_WRITE,
sizeof(uint32_t) * (numVertices + 1), &mext_in[0]);
hds[0].buffer[3] = cl::Buffer(context, CL_MEM_EXT_PTR_XILINX | CL_MEM_USE_HOST_PTR | CL_MEM_READ_WRITE,
sizeof(uint32_t) * numEdges, &mext_in[3]);
hds[0].buffer[2] = cl::Buffer(context, CL_MEM_EXT_PTR_XILINX | CL_MEM_USE_HOST_PTR | CL_MEM_READ_WRITE,
sizeof(uint32_t) * (numVertices + 1), &mext_in[2]);
hds[0].buffer[4] = cl::Buffer(context, CL_MEM_EXT_PTR_XILINX | CL_MEM_USE_HOST_PTR | CL_MEM_READ_WRITE,
sizeof(uint32_t) * (numVertices + 1), &mext_in[4]);
hds[0].buffer[5] = cl::Buffer(context, CL_MEM_EXT_PTR_XILINX | CL_MEM_USE_HOST_PTR | CL_MEM_READ_WRITE,
sizeof(uint32_t) * (numVertices + 1), &mext_in[5]);
hds[0].buffer[6] = cl::Buffer(context, CL_MEM_EXT_PTR_XILINX | CL_MEM_USE_HOST_PTR | CL_MEM_READ_WRITE,
sizeof(uint32_t) * numVertices, &mext_in[6]);
hds[0].buffer[7] = cl::Buffer(context, CL_MEM_EXT_PTR_XILINX | CL_MEM_USE_HOST_PTR | CL_MEM_READ_WRITE,
sizeof(uint32_t) * numVertices, &mext_in[7]);
ob_in.push_back(hds[0].buffer[0]);
ob_in.push_back(hds[0].buffer[1]);
ob_out.push_back(hds[0].buffer[7]);
kernel0.setArg(0, g.edgeNum); // edge number
kernel0.setArg(1, g.nodeNum); // node number
kernel0.setArg(2, hds[0].buffer[1]); // indicee
kernel0.setArg(3, hds[0].buffer[0]); // offsets
kernel0.setArg(4, hds[0].buffer[3]); // indices G2
kernel0.setArg(5, hds[0].buffer[3]); // indices G2
kernel0.setArg(6, hds[0].buffer[2]); // offsets G2
kernel0.setArg(7, hds[0].buffer[4]); // offsetsTmp1
kernel0.setArg(8, hds[0].buffer[5]); // offsetsTmp2
kernel0.setArg(9, hds[0].buffer[6]); // queue
kernel0.setArg(10, hds[0].buffer[6]); // queue
kernel0.setArg(11, hds[0].buffer[7]); // result
kernel0.setArg(12, hds[0].buffer[7]); // result
};
int opWCC::cuExecute(
clHandle* hds, cl::Kernel& kernel0, unsigned int num_runs, std::vector<cl::Event>* evIn, cl::Event* evOut) {
for (int i = 0; i < num_runs; ++i) {
hds[0].q.enqueueTask(kernel0, evIn, evOut);
}
return 0;
}
int opWCC::compute(unsigned int deviceID,
unsigned int cuID,
unsigned int channelID,
xrmContext* ctx,
xrmCuResource* resR,
std::string instanceName,
clHandle* handles,
xf::graph::Graph<uint32_t, uint32_t> g,
uint32_t* result) {
clHandle* hds = &handles[channelID + cuID * dupNmWCC + deviceID * dupNmWCC * cuPerBoardWCC];
cl::Kernel kernel0;
std::vector<cl::Memory> ob_in;
std::vector<cl::Memory> ob_out;
unsigned int num_runs = 1;
uint32_t numVertices = g.nodeNum;
uint32_t numEdges = g.edgeNum;
uint32_t* indicesG2 = aligned_alloc<uint32_t>(numEdges);
uint32_t* offsetsG2 = aligned_alloc<uint32_t>(numVertices + 1);
uint32_t* offsetsTmp1 = aligned_alloc<uint32_t>(numVertices + 1);
uint32_t* offsetsTmp2 = aligned_alloc<uint32_t>(numVertices + 1);
uint32_t* queue = aligned_alloc<uint32_t>(numVertices);
std::vector<cl::Event> events_write(1);
std::vector<cl::Event> events_kernel(num_runs);
std::vector<cl::Event> events_read(1);
bufferInit(hds, instanceName, g, offsetsG2, indicesG2, offsetsTmp1, offsetsTmp2, queue, result, kernel0, ob_in,
ob_out);
migrateMemObj(hds, 0, num_runs, ob_in, nullptr, &events_write[0]);
int ret = cuExecute(hds, kernel0, num_runs, &events_write, &events_kernel[0]);
migrateMemObj(hds, 1, num_runs, ob_out, &events_kernel, &events_read[0]);
events_read[0].wait();
cuRelease(ctx, resR);
free(indicesG2);
free(offsetsG2);
free(offsetsTmp1);
free(offsetsTmp2);
free(queue);
return ret;
};
event<int> opWCC::addwork(xf::graph::Graph<uint32_t, uint32_t> g, uint32_t* result) {
return createL3(task_queue[0], &(compute), handles, g, result);
};
} // L3
} // graph
} // xf
#endif
| 40 | 118 | 0.624419 | Geekdude |
241f4f92829d38940c6b9d78a7b4361262134f77 | 16,173 | cpp | C++ | src/lib/asn1/ASN1Writer.cpp | rgoliver/connectedhomeip | 1bbbed11464a4895a4c50c519c67e81b490ac06d | [
"Apache-2.0"
] | 2 | 2021-03-30T00:47:43.000Z | 2021-05-14T08:54:59.000Z | src/lib/asn1/ASN1Writer.cpp | rgoliver/connectedhomeip | 1bbbed11464a4895a4c50c519c67e81b490ac06d | [
"Apache-2.0"
] | null | null | null | src/lib/asn1/ASN1Writer.cpp | rgoliver/connectedhomeip | 1bbbed11464a4895a4c50c519c67e81b490ac06d | [
"Apache-2.0"
] | null | null | null | /*
*
* Copyright (c) 2020-2021 Project CHIP Authors
* Copyright (c) 2013-2017 Nest Labs, Inc.
* All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @file
* This file implements an object for writing Abstract Syntax
* Notation One (ASN.1) encoded data.
*
*/
#ifndef __STDC_LIMIT_MACROS
#define __STDC_LIMIT_MACROS
#endif
#include <ctype.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <asn1/ASN1.h>
#include <core/CHIPCore.h>
#include <core/CHIPEncoding.h>
#include <core/CHIPTLV.h>
#include <support/CodeUtils.h>
namespace chip {
namespace ASN1 {
using namespace chip::Encoding;
enum
{
kLengthFieldReserveSize = 5,
kMaxElementLength = INT32_MAX,
kUnkownLength = -1,
kUnknownLengthMarker = 0xFF
};
void ASN1Writer::Init(uint8_t * buf, uint32_t maxLen)
{
mBuf = buf;
mWritePoint = buf;
mBufEnd = buf + maxLen;
mBufEnd = reinterpret_cast<uint8_t *>(reinterpret_cast<uintptr_t>(mBufEnd) & ~3); // align on 32bit boundary
mDeferredLengthList = reinterpret_cast<uint8_t **>(mBufEnd);
}
void ASN1Writer::InitNullWriter(void)
{
mBuf = nullptr;
mWritePoint = nullptr;
mBufEnd = nullptr;
mDeferredLengthList = nullptr;
}
ASN1_ERROR ASN1Writer::Finalize()
{
if (mBuf != nullptr)
{
uint8_t * compactPoint = mBuf;
uint8_t * spanStart = mBuf;
for (uint8_t ** listEntry = reinterpret_cast<uint8_t **>(mBufEnd); listEntry > mDeferredLengthList;)
{
uint8_t * lenField = *--listEntry;
uint8_t lenFieldFirstByte = *lenField;
if (lenFieldFirstByte == kUnknownLengthMarker)
return ASN1_ERROR_INVALID_STATE;
uint8_t lenOfLen = (lenFieldFirstByte < 128) ? 1 : (lenFieldFirstByte & 0x7f) + 1;
uint8_t * spanEnd = lenField + lenOfLen;
if (spanStart == compactPoint)
compactPoint = spanEnd;
else
{
uint32_t spanLen = spanEnd - spanStart;
memmove(compactPoint, spanStart, spanLen);
compactPoint += spanLen;
}
spanStart = lenField + kLengthFieldReserveSize;
}
if (spanStart > compactPoint)
{
uint32_t spanLen = mWritePoint - spanStart;
memmove(compactPoint, spanStart, spanLen);
compactPoint += spanLen;
}
mWritePoint = compactPoint;
}
return ASN1_NO_ERROR;
}
uint16_t ASN1Writer::GetLengthWritten() const
{
return (mBuf != nullptr) ? mWritePoint - mBuf : 0;
}
ASN1_ERROR ASN1Writer::PutInteger(int64_t val)
{
uint8_t encodedVal[8];
uint8_t valStart, valLen;
BigEndian::Put64(encodedVal, static_cast<uint64_t>(val));
for (valStart = 0; valStart < 7; valStart++)
{
if (encodedVal[valStart] == 0x00 && (encodedVal[valStart + 1] & 0x80) == 0)
continue;
if (encodedVal[valStart] == 0xFF && (encodedVal[valStart + 1] & 0x80) == 0x80)
continue;
break;
}
valLen = 8 - valStart;
return PutValue(kASN1TagClass_Universal, kASN1UniversalTag_Integer, false, encodedVal + valStart, valLen);
}
ASN1_ERROR ASN1Writer::PutBoolean(bool val)
{
// Do nothing for a null writer.
VerifyOrReturnError(mBuf != nullptr, ASN1_NO_ERROR);
ReturnErrorOnFailure(EncodeHead(kASN1TagClass_Universal, kASN1UniversalTag_Boolean, false, 1));
*mWritePoint++ = (val) ? 0xFF : 0;
return ASN1_NO_ERROR;
}
ASN1_ERROR ASN1Writer::PutObjectId(const uint8_t * val, uint16_t valLen)
{
return PutValue(kASN1TagClass_Universal, kASN1UniversalTag_ObjectId, false, val, valLen);
}
ASN1_ERROR ASN1Writer::PutString(uint32_t tag, const char * val, uint16_t valLen)
{
return PutValue(kASN1TagClass_Universal, tag, false, (const uint8_t *) val, valLen);
}
ASN1_ERROR ASN1Writer::PutOctetString(const uint8_t * val, uint16_t valLen)
{
return PutValue(kASN1TagClass_Universal, kASN1UniversalTag_OctetString, false, val, valLen);
}
ASN1_ERROR ASN1Writer::PutOctetString(uint8_t cls, uint32_t tag, const uint8_t * val, uint16_t valLen)
{
return PutValue(cls, tag, false, val, valLen);
}
ASN1_ERROR ASN1Writer::PutOctetString(uint8_t cls, uint32_t tag, chip::TLV::TLVReader & val)
{
return PutValue(cls, tag, false, val);
}
static uint8_t ReverseBits(uint8_t v)
{
// swap adjacent bits
v = ((v >> 1) & 0x55) | ((v & 0x55) << 1);
// swap adjacent bit pairs
v = ((v >> 2) & 0x33) | ((v & 0x33) << 2);
// swap nibbles
v = (v >> 4) | (v << 4);
return v;
}
static uint8_t HighestBit(uint32_t v)
{
uint32_t highestBit = 0;
if (v > 0xFFFF)
{
highestBit = 16;
v >>= 16;
}
if (v > 0xFF)
{
highestBit |= 8;
v >>= 8;
}
if (v > 0xF)
{
highestBit |= 4;
v >>= 4;
}
if (v > 0x3)
{
highestBit |= 2;
v >>= 2;
}
highestBit |= (v >> 1);
return highestBit;
}
ASN1_ERROR ASN1Writer::PutBitString(uint32_t val)
{
uint8_t len;
// Do nothing for a null writer.
VerifyOrReturnError(mBuf != nullptr, ASN1_NO_ERROR);
if (val == 0)
len = 1;
else if (val < 256)
len = 2;
else if (val < 65536)
len = 3;
else if (val < (1 << 24))
len = 4;
else
len = 5;
ReturnErrorOnFailure(EncodeHead(kASN1TagClass_Universal, kASN1UniversalTag_BitString, false, len));
if (val == 0)
mWritePoint[0] = 0;
else
{
mWritePoint[1] = ReverseBits(static_cast<uint8_t>(val));
if (len >= 3)
{
val >>= 8;
mWritePoint[2] = ReverseBits(static_cast<uint8_t>(val));
if (len >= 4)
{
val >>= 8;
mWritePoint[3] = ReverseBits(static_cast<uint8_t>(val));
if (len == 5)
{
val >>= 8;
mWritePoint[4] = ReverseBits(static_cast<uint8_t>(val));
}
}
}
mWritePoint[0] = 7 - HighestBit(val);
}
mWritePoint += len;
return ASN1_NO_ERROR;
}
ASN1_ERROR ASN1Writer::PutBitString(uint8_t unusedBitCount, const uint8_t * encodedBits, uint16_t encodedBitsLen)
{
// Do nothing for a null writer.
VerifyOrReturnError(mBuf != nullptr, ASN1_NO_ERROR);
ReturnErrorOnFailure(EncodeHead(kASN1TagClass_Universal, kASN1UniversalTag_BitString, false, encodedBitsLen + 1));
*mWritePoint++ = unusedBitCount;
memcpy(mWritePoint, encodedBits, encodedBitsLen);
mWritePoint += encodedBitsLen;
return ASN1_NO_ERROR;
}
ASN1_ERROR ASN1Writer::PutBitString(uint8_t unusedBitCount, chip::TLV::TLVReader & encodedBits)
{
uint32_t encodedBitsLen;
// Do nothing for a null writer.
VerifyOrReturnError(mBuf != nullptr, ASN1_NO_ERROR);
encodedBitsLen = encodedBits.GetLength();
ReturnErrorOnFailure(EncodeHead(kASN1TagClass_Universal, kASN1UniversalTag_BitString, false, encodedBitsLen + 1));
*mWritePoint++ = unusedBitCount;
encodedBits.GetBytes(mWritePoint, encodedBitsLen);
mWritePoint += encodedBitsLen;
return ASN1_NO_ERROR;
}
static void itoa2(uint32_t val, uint8_t * buf)
{
buf[1] = '0' + (val % 10);
val /= 10;
buf[0] = '0' + (val % 10);
}
ASN1_ERROR ASN1Writer::PutTime(const ASN1UniversalTime & val)
{
uint8_t buf[15];
itoa2(val.Year / 100, buf);
itoa2(val.Year, buf + 2);
itoa2(val.Month, buf + 4);
itoa2(val.Day, buf + 6);
itoa2(val.Hour, buf + 8);
itoa2(val.Minute, buf + 10);
itoa2(val.Second, buf + 12);
buf[14] = 'Z';
// X.509/RFC5280 mandates that times before 2050 UTC must be encoded as ASN.1 UTCTime values, while
// times equal or greater than 2050 must be encoded as GeneralizedTime values. The only difference
// (in the context of X.509 DER) is that GeneralizedTimes are encoded with a 4 digit year, while
// UTCTimes are encoded with a two-digit year.
//
if (val.Year >= 2050)
return PutValue(kASN1TagClass_Universal, kASN1UniversalTag_GeneralizedTime, false, buf, 15);
else
return PutValue(kASN1TagClass_Universal, kASN1UniversalTag_UTCTime, false, buf + 2, 13);
}
ASN1_ERROR ASN1Writer::PutNull()
{
return EncodeHead(kASN1TagClass_Universal, kASN1UniversalTag_Null, false, 0);
}
ASN1_ERROR ASN1Writer::StartConstructedType(uint8_t cls, uint32_t tag)
{
return EncodeHead(cls, tag, true, kUnkownLength);
}
ASN1_ERROR ASN1Writer::EndConstructedType()
{
return WriteDeferredLength();
}
ASN1_ERROR ASN1Writer::StartEncapsulatedType(uint8_t cls, uint32_t tag, bool bitStringEncoding)
{
// Do nothing for a null writer.
VerifyOrReturnError(mBuf != nullptr, ASN1_NO_ERROR);
ReturnErrorOnFailure(EncodeHead(cls, tag, false, kUnkownLength));
// If the encapsulating type is BIT STRING, encode the unused bit count field. Since the BIT
// STRING contains an ASN.1 DER encoding, and ASN.1 DER encodings are always multiples of 8 bits,
// the unused bit count is always 0.
if (bitStringEncoding)
{
if (mWritePoint == reinterpret_cast<uint8_t *>(mDeferredLengthList))
return ASN1_ERROR_OVERFLOW;
*mWritePoint++ = 0;
}
return ASN1_NO_ERROR;
}
ASN1_ERROR ASN1Writer::EndEncapsulatedType()
{
return WriteDeferredLength();
}
ASN1_ERROR ASN1Writer::PutValue(uint8_t cls, uint32_t tag, bool isConstructed, const uint8_t * val, uint16_t valLen)
{
// Do nothing for a null writer.
VerifyOrReturnError(mBuf != nullptr, ASN1_NO_ERROR);
ReturnErrorOnFailure(EncodeHead(cls, tag, isConstructed, valLen));
memcpy(mWritePoint, val, valLen);
mWritePoint += valLen;
return ASN1_NO_ERROR;
}
ASN1_ERROR ASN1Writer::PutValue(uint8_t cls, uint32_t tag, bool isConstructed, chip::TLV::TLVReader & val)
{
uint32_t valLen;
// Do nothing for a null writer.
VerifyOrReturnError(mBuf != nullptr, ASN1_NO_ERROR);
valLen = val.GetLength();
ReturnErrorOnFailure(EncodeHead(cls, tag, isConstructed, valLen));
val.GetBytes(mWritePoint, valLen);
mWritePoint += valLen;
return ASN1_NO_ERROR;
}
ASN1_ERROR ASN1Writer::EncodeHead(uint8_t cls, uint32_t tag, bool isConstructed, int32_t len)
{
uint8_t bytesForLen;
uint32_t totalLen;
// Do nothing for a null writer.
VerifyOrReturnError(mBuf != nullptr, ASN1_NO_ERROR);
// Only tags <= 31 supported. The implication of this is that encoded tags are exactly 1 byte long.
VerifyOrReturnError(tag <= 0x1F, ASN1_ERROR_UNSUPPORTED_ENCODING);
// Only positive and kUnkownLength values are supported for len input.
VerifyOrReturnError(len >= 0 || len == kUnkownLength, ASN1_ERROR_UNSUPPORTED_ENCODING);
// Compute the number of bytes required to encode the length.
bytesForLen = BytesForLength(len);
// If the element length is unknown, allocate a new entry in the deferred-length list.
//
// The deferred-length list is a list of "pointers" (represented as offsets into mBuf)
// to length fields for which the length of the element was unknown at the time the element
// head was written. Examples include constructed types such as SEQUENCE and SET, as well
// non-constructed types that encapsulate other ASN.1 types (e.g. OCTET STRINGS that contain
// BER/DER encodings). The final lengths are filled in later, at the time the encoding is
// complete (e.g. when EndConstructed() is called).
//
if (len == kUnkownLength)
mDeferredLengthList--;
// Make sure there's enough space to encode the entire value without bumping into the deferred length
// list at the end of the buffer.
totalLen = 1 + bytesForLen + (len != kUnkownLength ? len : 0);
VerifyOrReturnError((mWritePoint + totalLen) <= reinterpret_cast<uint8_t *>(mDeferredLengthList), ASN1_ERROR_OVERFLOW);
// Write the tag byte.
*mWritePoint++ = cls | (isConstructed ? 0x20 : 0) | tag;
// Encode the length if it is known.
if (len != kUnkownLength)
EncodeLength(mWritePoint, bytesForLen, len);
// ... otherwise place a marker in the first byte of the length to indicate that the length is unknown
// and save a pointer to the length field in the deferred-length list.
else
{
*mWritePoint = kUnknownLengthMarker;
*mDeferredLengthList = mWritePoint;
}
mWritePoint += bytesForLen;
return ASN1_NO_ERROR;
}
ASN1_ERROR ASN1Writer::WriteDeferredLength()
{
uint8_t ** listEntry;
uint32_t lenAdj;
// Do nothing for a null writer.
VerifyOrReturnError(mBuf != nullptr, ASN1_NO_ERROR);
lenAdj = kLengthFieldReserveSize;
// Scan the deferred-length list in reverse order looking for the most recent entry where
// the length is still unknown. This entry represents the "container" element whose encoding
// is now complete.
for (listEntry = mDeferredLengthList; listEntry < reinterpret_cast<uint8_t **>(mBufEnd); listEntry++)
{
// Get a pointer to the deferred-length field.
uint8_t * lenField = *listEntry;
// Get the first byte of the length field.
uint8_t lenFieldFirstByte = *lenField;
// If the length is marked as unknown...
if (lenFieldFirstByte == kUnknownLengthMarker)
{
// Compute the final length of the element's value (3 = bytes reserved for length).
uint32_t elemLen = (mWritePoint - lenField) - lenAdj;
// Return an error if the length exceeds the maximum value that can be encoded in the
// space reserved for the length.
VerifyOrReturnError(elemLen <= kMaxElementLength, ASN1_ERROR_LENGTH_OVERFLOW);
// Encode the final length of the element, overwriting the unknown length marker
// in the process. Note that the number of bytes consumed by the final length field
// may be smaller than the space that was reserved for the field. This will be fixed
// up when the Finalize() method is called.
uint8_t bytesForLen = BytesForLength(static_cast<int32_t>(elemLen));
EncodeLength(lenField, bytesForLen, elemLen);
return ASN1_NO_ERROR;
}
else
{
uint8_t bytesForLen = (lenFieldFirstByte < 128) ? 1 : (lenFieldFirstByte & 0x7f) + 1;
lenAdj += (kLengthFieldReserveSize - bytesForLen);
}
}
return ASN1_ERROR_INVALID_STATE;
}
/**
* Returns the number of bytes required to encode the length value.
*
* @param[in] len Parameter, which encoding length to be calculated.
*
* @return number of bytes required to encode the length value.
*/
uint8_t ASN1Writer::BytesForLength(int32_t len)
{
if (len == kUnkownLength)
return kLengthFieldReserveSize;
if (len < 128)
return 1;
if (len < 256)
return 2;
if (len < 65536)
return 3;
if (len < (1 << 24))
return 4;
return 5;
}
void ASN1Writer::EncodeLength(uint8_t * buf, uint8_t bytesForLen, int32_t lenToEncode)
{
if (bytesForLen == 1)
buf[0] = static_cast<uint8_t>(lenToEncode);
else
{
--bytesForLen;
buf[0] = 0x80 | bytesForLen;
do
{
buf[bytesForLen] = static_cast<uint8_t>(lenToEncode);
lenToEncode >>= 8;
} while (--bytesForLen);
}
}
} // namespace ASN1
} // namespace chip
| 29.675229 | 124 | 0.649292 | rgoliver |
24273ed7f7eafa6d5a842952903ad128d49625a9 | 1,022 | cpp | C++ | volume1/1024_19Nov2006_1408090.cpp | andriybuday/timus | a5cdc03f3ca8e7878220b8e0a0c72343f98ee1eb | [
"MIT"
] | null | null | null | volume1/1024_19Nov2006_1408090.cpp | andriybuday/timus | a5cdc03f3ca8e7878220b8e0a0c72343f98ee1eb | [
"MIT"
] | null | null | null | volume1/1024_19Nov2006_1408090.cpp | andriybuday/timus | a5cdc03f3ca8e7878220b8e0a0c72343f98ee1eb | [
"MIT"
] | null | null | null | #include <stdio.h>
void quickSortR(int* a, long N)
{
long i = 0, j = N;
int temp, p;
p = a[ N>>1 ];
do
{
while ( a[i] < p ) i++;
while ( a[j] > p ) j--;
if (i <= j) {
temp = a[i]; a[i] = a[j]; a[j] = temp;
i++; j--;
}
} while ( i<=j );
if ( j > 0 ) quickSortR(a, j);
if ( N > i ) quickSortR(a+i, N-i);
}
int NSD(int min, int max)
{
int temp = 1;
while(temp!=0)
{
if(min != 0)temp = max%min;
if(min == 0)continue;
max = min;
min = temp;
if(temp == 0)continue;
}
return max;
}
inline int NSK(int x, int y)
{
return x / NSD(x, y) * y;
}
int a[1002];
int k[1002];
int main()
{
int n, i, x;
scanf("%d", &n);
for(i = 1; i <= n; i++)
{
scanf("%d", &a[i]);
}
for(i = 1; i <= n; i++)
{
int j = i;
int count = 1;
while(a[j] != i)
{
j = a[j];
count++;
}
k[i] = count;
}
quickSortR(k, n);
int curr_NSK = k[1];
for(i = 1; i <= n; i++)
{
curr_NSK = NSK(curr_NSK, k[i]);
}
printf("%d", curr_NSK);
return 0;
}
| 11.483146 | 44 | 0.438356 | andriybuday |
242903ca6638e1a4100204828a3aab5ff794e4ab | 4,714 | cpp | C++ | Source/Constraint/imstkcpdPointTriangleCollisionConstraint.cpp | quantingxie/vibe | 965a79089ac3ec821ad65c45ac50e69bf32dc92f | [
"Apache-2.0"
] | 2 | 2020-08-14T07:21:30.000Z | 2021-08-30T09:39:09.000Z | Source/Constraint/imstkcpdPointTriangleCollisionConstraint.cpp | quantingxie/vibe | 965a79089ac3ec821ad65c45ac50e69bf32dc92f | [
"Apache-2.0"
] | null | null | null | Source/Constraint/imstkcpdPointTriangleCollisionConstraint.cpp | quantingxie/vibe | 965a79089ac3ec821ad65c45ac50e69bf32dc92f | [
"Apache-2.0"
] | 1 | 2020-08-14T07:00:31.000Z | 2020-08-14T07:00:31.000Z | #include "imstkcpdPointTriangleCollisionConstraint.h"
namespace cpd
{
void PointTriangleCollisionConstraint::initConstraint(ParticleObjectPtr p_object1, const size_t p_idx1, ParticleObjectPtr p_object2, const size_t p_idx2, const size_t p_idx3, const size_t p_idx4, double p_stiffness)
{
m_object = p_object1;
m_objectOther = p_object2;
m_stiffness = p_stiffness;
m_elasticityMatrix(0,0) = 0;
m_particleIDs[0] = p_idx1;
m_particleIDs[1] = p_idx2;
m_particleIDs[2] = p_idx3;
m_particleIDs[3] = p_idx4;
for (unsigned i = 0; i < 4; i++)
{
if (i < m_sizeCol[0])
m_invMass[i] = m_object->getInvMass(m_particleIDs[i]);
else
m_invMass[i] = m_objectOther->getInvMass(m_particleIDs[i]);
m_deltaDisplacement[i].setZero();
if (m_invMass[i] > EPS)
m_movable[i] = true;
else
m_movable[i] = false;
}
m_volume = m_object->getParticleProximity() + m_objectOther->getParticleProximity();
m_elasticityMatrix[0] = 0.0;
m_deno[0] = 0.0;
clearLamda();
computeDerivative();
}
void PointTriangleCollisionConstraint::updateConstraint()
{
m_delta[0] = m_delta[0] + m_deltaDisplacement[0] - m_deltaDisplacement[1];
m_delta[1] = m_delta[1] + m_deltaDisplacement[2] - m_deltaDisplacement[1];
m_delta[2] = m_delta[2] + m_deltaDisplacement[3] - m_deltaDisplacement[1];
//m_delta[1] = m_delta[1] + m_deltaDisplacement[3] - m_deltaDisplacement[1];
//m_delta[2] = m_delta[2] + m_deltaDisplacement[2] - m_deltaDisplacement[1];
m_Constraint[0] = m_delta[0].dot((m_delta[1].cross(m_delta[2])).normalized()) - m_volume;
}
void PointTriangleCollisionConstraint::computeDerivative()
{
m_delta[0] = m_object->getTemporaryPosition(m_particleIDs[0]) - m_objectOther->getTemporaryPosition(m_particleIDs[1]);
m_delta[1] = m_objectOther->getTemporaryPosition(m_particleIDs[2]) - m_objectOther->getTemporaryPosition(m_particleIDs[1]);
m_delta[2] = m_objectOther->getTemporaryPosition(m_particleIDs[3]) - m_objectOther->getTemporaryPosition(m_particleIDs[1]);
//m_delta[1] = m_objectOther->getTemporaryPosition(m_particleIDs[3]) - m_objectOther->getTemporaryPosition(m_particleIDs[1]);
//m_delta[2] = m_objectOther->getTemporaryPosition(m_particleIDs[2]) - m_objectOther->getTemporaryPosition(m_particleIDs[1]);
for (unsigned i = 0; i < 4; i++)
{
m_derivatives[i].fill(0.0);
}
}
bool PointTriangleCollisionConstraint::updateDenominator()
{
//std::cout << "C" << m_Constraint[0] << ", eps = " << EPS << std::endl;
if (m_Constraint[0] > EPS)
return false;
double coeff[4];
Vec3d n = m_delta[1].cross(m_delta[2]);
coeff[1] = n.dot(m_delta[1].cross(m_delta[0])) / (n.dot(n));
coeff[2] = n.dot(m_delta[0].cross(m_delta[2])) / (n.dot(n));
coeff[3] = (1.0 - coeff[1] - coeff[2]);
//coeff[1] = -n.dot(m_delta[1].cross(m_delta[0])) / (n.dot(n));
//coeff[2] = -n.dot(m_delta[0].cross(m_delta[2])) / (n.dot(n));
//coeff[3] = -(1.0 - coeff[1] - coeff[2]);
coeff[0] = 1.0;
if (coeff[1] < 0 || coeff[2] < 0 || coeff[3] < 0)
{
//if (coeff[1] > 0 || coeff[2] > 0 || coeff[3] > 0)
//{
return false;
}
for (unsigned i = 0; i < 4; i++)
{
//m_object->setParticleCollided(m_particleIDs[i]);
if (i < m_sizeCol[0])
m_object->setParticleCollided(m_particleIDs[i]);
else
m_objectOther->setParticleCollided(m_particleIDs[i]);
}
n.normalize();
for (unsigned i = 0; i < 4; i++)
{
for (unsigned j = 0; j < 3; j++)
{
m_derivatives[i][j] = coeff[i] * n[j];
}
}
double cmc = 0;
for (unsigned i = 0; i < 4; i++)
{
cmc += m_invMass[i] * coeff[i] * coeff[i];
}
if (abs(cmc) > EPS)
m_deno[0] = 1.0 / cmc;
else
m_deno[0] = 0.0;
return true;
}
void PointTriangleCollisionConstraint::computeForce()
{
Vec3d force;
double coeff;
for (unsigned i = 0; i < 4; i++)
{
coeff = m_lamdaList[0] * 0.5;
for (unsigned j = 0; j < 3; j++)
{
force[j] = coeff * m_derivatives[i][j];
}
}
#pragma omp critical
for (unsigned i = 0; i < 4; i++)
{
//m_object->addToConstraintForce(m_particleIDs[i], m_invMass[i] * force);
if (i < m_sizeCol[0])
m_object->addToConstraintForce(m_particleIDs[i], m_ID, m_invMass[i] * force);
else
m_objectOther->addToConstraintForce(m_particleIDs[i], m_ID, m_invMass[i] * force);
}
}
void PointTriangleCollisionConstraint::integrate(bool p_all)
{
}
void PointTriangleCollisionConstraint::initShapeFunction()
{
}
}
| 31.218543 | 217 | 0.622613 | quantingxie |
242a48a9c2f9af3f003c95dc58a386f2c5695554 | 6,376 | cpp | C++ | test/unit/alphabet/nucleotide/sam_dna16_test.cpp | qPCR4vir/seqan3 | 67ebf427dc1d49fb55e684acc108ed75d224f5d4 | [
"CC-BY-4.0",
"CC0-1.0"
] | null | null | null | test/unit/alphabet/nucleotide/sam_dna16_test.cpp | qPCR4vir/seqan3 | 67ebf427dc1d49fb55e684acc108ed75d224f5d4 | [
"CC-BY-4.0",
"CC0-1.0"
] | null | null | null | test/unit/alphabet/nucleotide/sam_dna16_test.cpp | qPCR4vir/seqan3 | 67ebf427dc1d49fb55e684acc108ed75d224f5d4 | [
"CC-BY-4.0",
"CC0-1.0"
] | null | null | null | // -----------------------------------------------------------------------------------------------------
// Copyright (c) 2006-2020, Knut Reinert & Freie Universität Berlin
// Copyright (c) 2016-2020, Knut Reinert & MPI für molekulare Genetik
// This file may be used, modified and/or redistributed under the terms of the 3-clause BSD-License
// shipped with this file and also available at: https://github.com/seqan/seqan3/blob/master/LICENSE.md
// -----------------------------------------------------------------------------------------------------
#include <seqan3/alphabet/nucleotide/sam_dna16.hpp>
#include <seqan3/core/detail/debug_stream_range.hpp>
#include <seqan3/utility/char_operations/predicate.hpp>
#include "../alphabet_constexpr_test_template.hpp"
#include "../alphabet_test_template.hpp"
#include "../semi_alphabet_constexpr_test_template.hpp"
#include "../semi_alphabet_test_template.hpp"
using seqan3::operator""_sam_dna16;
// ------------------------------------------------------------------
// sam_dna16 alphabet
// ------------------------------------------------------------------
INSTANTIATE_TYPED_TEST_SUITE_P(sam_dna16, alphabet, seqan3::sam_dna16, );
INSTANTIATE_TYPED_TEST_SUITE_P(sam_dna16, semi_alphabet_test, seqan3::sam_dna16, );
INSTANTIATE_TYPED_TEST_SUITE_P(sam_dna16, alphabet_constexpr, seqan3::sam_dna16, );
INSTANTIATE_TYPED_TEST_SUITE_P(sam_dna16, semi_alphabet_constexpr, seqan3::sam_dna16, );
// nucleotide test: (because the complement is not bijective for sam_dna16 we need to test it manually)
TEST(sam_dna16, nucleotide)
{
EXPECT_TRUE(seqan3::nucleotide_alphabet<seqan3::sam_dna16>);
EXPECT_TRUE(seqan3::nucleotide_alphabet<seqan3::sam_dna16 &>);
EXPECT_EQ(seqan3::complement('='_sam_dna16), 'N'_sam_dna16);
EXPECT_EQ(seqan3::complement('A'_sam_dna16), 'T'_sam_dna16);
EXPECT_EQ(seqan3::complement('C'_sam_dna16), 'G'_sam_dna16);
EXPECT_EQ(seqan3::complement('M'_sam_dna16), 'K'_sam_dna16);
EXPECT_EQ(seqan3::complement('G'_sam_dna16), 'C'_sam_dna16);
EXPECT_EQ(seqan3::complement('R'_sam_dna16), 'Y'_sam_dna16);
EXPECT_EQ(seqan3::complement('S'_sam_dna16), 'S'_sam_dna16);
EXPECT_EQ(seqan3::complement('V'_sam_dna16), 'B'_sam_dna16);
EXPECT_EQ(seqan3::complement('T'_sam_dna16), 'A'_sam_dna16);
EXPECT_EQ(seqan3::complement('W'_sam_dna16), 'W'_sam_dna16);
EXPECT_EQ(seqan3::complement('Y'_sam_dna16), 'R'_sam_dna16);
EXPECT_EQ(seqan3::complement('H'_sam_dna16), 'D'_sam_dna16);
EXPECT_EQ(seqan3::complement('K'_sam_dna16), 'M'_sam_dna16);
EXPECT_EQ(seqan3::complement('D'_sam_dna16), 'H'_sam_dna16);
EXPECT_EQ(seqan3::complement('B'_sam_dna16), 'V'_sam_dna16);
EXPECT_EQ(seqan3::complement('N'_sam_dna16), 'N'_sam_dna16);
}
TEST(sam_dna16, to_char_assign_char)
{
using rank_t = seqan3::alphabet_rank_t<seqan3::sam_dna16>;
for (rank_t rank = 0; rank < seqan3::alphabet_size<seqan3::sam_dna16>; ++rank)
{
char chr = seqan3::to_char(seqan3::assign_rank_to(rank, seqan3::sam_dna16{}));
EXPECT_EQ(seqan3::to_char(seqan3::sam_dna16{}.assign_char(chr)), chr);
}
EXPECT_EQ(seqan3::to_char(seqan3::sam_dna16{}.assign_char('a')), 'A');
EXPECT_EQ(seqan3::to_char(seqan3::sam_dna16{}.assign_char('c')), 'C');
EXPECT_EQ(seqan3::to_char(seqan3::sam_dna16{}.assign_char('g')), 'G');
EXPECT_EQ(seqan3::to_char(seqan3::sam_dna16{}.assign_char('t')), 'T');
EXPECT_EQ(seqan3::to_char(seqan3::sam_dna16{}.assign_char('U')), 'T');
EXPECT_EQ(seqan3::to_char(seqan3::sam_dna16{}.assign_char('!')), 'N');
}
TEST(sam_dna16, char_literal)
{
EXPECT_EQ(seqan3::to_char('A'_sam_dna16), 'A');
EXPECT_EQ(seqan3::to_char('C'_sam_dna16), 'C');
EXPECT_EQ(seqan3::to_char('G'_sam_dna16), 'G');
EXPECT_EQ(seqan3::to_char('U'_sam_dna16), 'T');
EXPECT_EQ(seqan3::to_char('T'_sam_dna16), 'T');
EXPECT_EQ(seqan3::to_char('R'_sam_dna16), 'R');
EXPECT_EQ(seqan3::to_char('Y'_sam_dna16), 'Y');
EXPECT_EQ(seqan3::to_char('S'_sam_dna16), 'S');
EXPECT_EQ(seqan3::to_char('W'_sam_dna16), 'W');
EXPECT_EQ(seqan3::to_char('K'_sam_dna16), 'K');
EXPECT_EQ(seqan3::to_char('M'_sam_dna16), 'M');
EXPECT_EQ(seqan3::to_char('B'_sam_dna16), 'B');
EXPECT_EQ(seqan3::to_char('D'_sam_dna16), 'D');
EXPECT_EQ(seqan3::to_char('H'_sam_dna16), 'H');
EXPECT_EQ(seqan3::to_char('V'_sam_dna16), 'V');
EXPECT_EQ(seqan3::to_char('='_sam_dna16), '=');
EXPECT_EQ(seqan3::to_char('N'_sam_dna16), 'N');
EXPECT_EQ(seqan3::to_char('!'_sam_dna16), 'N');
}
TEST(sam_dna16, string_literal)
{
seqan3::sam_dna16_vector v;
v.resize(5, 'A'_sam_dna16);
EXPECT_EQ(v, "AAAAA"_sam_dna16);
std::vector<seqan3::sam_dna16> w{'A'_sam_dna16,
'='_sam_dna16,
'G'_sam_dna16,
'T'_sam_dna16,
'U'_sam_dna16,
'N'_sam_dna16};
EXPECT_EQ(w, "A=GTTN"_sam_dna16);
}
TEST(sam_dna16, char_is_valid)
{
constexpr auto validator = seqan3::is_char<'A'> || seqan3::is_char<'C'> || seqan3::is_char<'G'> ||
seqan3::is_char<'T'> || seqan3::is_char<'U'> || seqan3::is_char<'a'> ||
seqan3::is_char<'c'> || seqan3::is_char<'g'> || seqan3::is_char<'t'> ||
seqan3::is_char<'u'> || seqan3::is_char<'N'> || seqan3::is_char<'n'> ||
seqan3::is_char<'R'> || seqan3::is_char<'Y'> || seqan3::is_char<'S'> ||
seqan3::is_char<'W'> || seqan3::is_char<'K'> || seqan3::is_char<'M'> ||
seqan3::is_char<'B'> || seqan3::is_char<'D'> || seqan3::is_char<'H'> ||
seqan3::is_char<'V'> || seqan3::is_char<'r'> || seqan3::is_char<'y'> ||
seqan3::is_char<'s'> || seqan3::is_char<'w'> || seqan3::is_char<'k'> ||
seqan3::is_char<'m'> || seqan3::is_char<'b'> || seqan3::is_char<'d'> ||
seqan3::is_char<'h'> || seqan3::is_char<'v'> || seqan3::is_char<'='>;
for (char c : std::views::iota(std::numeric_limits<char>::min(), std::numeric_limits<char>::max()))
EXPECT_EQ(seqan3::sam_dna16::char_is_valid(c), validator(c));
}
| 49.8125 | 104 | 0.604768 | qPCR4vir |
242facc4a20ac970c47acb13727499fb142e07fd | 3,634 | cpp | C++ | Source/MetaImg.cpp | AceyT/GBImg | f799cd7cb9aa7175e6ded79e1dc616e6fcb0cf1a | [
"MIT"
] | 1 | 2018-03-19T22:36:14.000Z | 2018-03-19T22:36:14.000Z | Source/MetaImg.cpp | AceyT/GBImg | f799cd7cb9aa7175e6ded79e1dc616e6fcb0cf1a | [
"MIT"
] | null | null | null | Source/MetaImg.cpp | AceyT/GBImg | f799cd7cb9aa7175e6ded79e1dc616e6fcb0cf1a | [
"MIT"
] | null | null | null | #include "MetaImg.hpp"
#include <cstring>
IndexedImage::~IndexedImage()
{
freeBuffer();
}
IndexedImage::IndexedImage(uint32_t _width, uint32_t _height) :
width(_width),
height(_height),
framesLowerBits(0),
framesUpperBits(0),
frameLoop(0),
transparentColor(0xFF),
colorMode((uint8_t)ColorMode::INDEXED),
imgData(nullptr),
size(0)
{
allocateBuffer();
}
IndexedImage::IndexedImage(const IndexedImage& other) :
width(other.width),
height(other.height),
framesLowerBits(other.framesLowerBits),
framesUpperBits(other.framesUpperBits),
frameLoop(other.frameLoop),
transparentColor(other.transparentColor),
colorMode(other.colorMode),
imgData(nullptr),
size(0)
{
allocateBuffer();
std::memcpy(imgData, other.imgData, size);
}
IndexedImage& IndexedImage::operator=(const IndexedImage& other)
{
if (&other != this)
{
freeBuffer();
width = other.width;
height = other.height;
framesLowerBits = other.framesLowerBits;
framesUpperBits = other.framesUpperBits;
frameLoop = other.frameLoop;
transparentColor = other.transparentColor;
colorMode = other.colorMode;
allocateBuffer();
if (other.imgData != nullptr)
std::memcpy(imgData, other.imgData, size);
}
return (*this);
}
void IndexedImage::allocateBuffer()
{
if (width > 0 && height > 0)
{
size = height * ((width+1) / 2);
imgData = new uint8_t[size];
std::memset(imgData, 0, size);
}
}
void IndexedImage::freeBuffer()
{
if (*this)
{
delete[] imgData;
imgData = nullptr;
size = 0;
}
}
uint8_t IndexedImage::getIdxByte(uint8_t x, uint8_t y) const
{
if (*this)
{
uint16_t offset = (y * ((width+1)/2) + x/2);
uint8_t value = imgData[offset];
if (x%2 == 0)
return (value >> 4 & 0x0F);
else
return (value & 0x0F);
}
return(0x00);
}
void IndexedImage::setIdxByte(uint8_t x, uint8_t y, uint8_t val)
{
if (*this)
{
uint16_t offset = (y * ((width+1)/2) + x/2);
uint8_t old = imgData[offset];
if (x%2 == 0)
imgData[offset] = ((val << 4) & 0xF0) + (old & 0x0F);
else
imgData[offset] = (old & 0xF0) + (val & 0x0F);
}
}
MetaImage::~MetaImage()
{
freeBuffer();
}
MetaImage::MetaImage(uint32_t _width, uint32_t _height) :
width(_width),
height(_height),
frames(0),
frameLoop(0),
transparentColor(0xFFFF),
colorMode((uint8_t)ColorMode::RGB_565),
imgData(nullptr),
size(0)
{
allocateBuffer();
}
MetaImage::MetaImage(const MetaImage& other) :
width(other.width),
height(other.height),
frames(other.frames),
frameLoop(other.frameLoop),
transparentColor(other.transparentColor),
colorMode(other.colorMode),
imgData(nullptr),
size(0)
{
allocateBuffer();
std::memcpy(imgData, other.imgData, size);
}
MetaImage& MetaImage::operator=(const MetaImage& other)
{
if (&other != this)
{
freeBuffer();
width = other.width;
height = other.height;
frames = other.frames;
frameLoop = other.frameLoop;
transparentColor = other.transparentColor;
colorMode = other.colorMode;
allocateBuffer();
if (other.imgData != nullptr)
std::memcpy(imgData, other.imgData, size);
}
return (*this);
}
void MetaImage::allocateBuffer()
{
if (width > 0 && height > 0)
{
size = height * width;
imgData = new uint16_t[size];
std::memset(imgData, 0, size);
}
}
void MetaImage::freeBuffer()
{
if (*this)
{
delete[] imgData;
imgData = nullptr;
size = 0;
}
}
RGB565 MetaImage::getColor(uint16_t x, uint16_t y) const
{
if (*this)
{
uint32_t offset = y * width + x;
return (imgData[offset]);
}
return(0x0000);
}
void MetaImage::setColor(uint16_t x, uint16_t y, RGB565 val)
{
if (*this)
{
uint32_t offset = y * width + x;
imgData[offset] = val;
}
}
| 18.446701 | 65 | 0.67749 | AceyT |
24316af1a7c54cf6fb8825727c98eb0ac574cd60 | 1,365 | cpp | C++ | ch13_ubuntu/src/frame.cpp | Little-Potato-1990/slambook2 | 9309c29ed2d2d7efe2fe7c35713faade91309efc | [
"MIT"
] | null | null | null | ch13_ubuntu/src/frame.cpp | Little-Potato-1990/slambook2 | 9309c29ed2d2d7efe2fe7c35713faade91309efc | [
"MIT"
] | null | null | null | ch13_ubuntu/src/frame.cpp | Little-Potato-1990/slambook2 | 9309c29ed2d2d7efe2fe7c35713faade91309efc | [
"MIT"
] | null | null | null | /*
* <one line to give the program's name and a brief idea of what it does.>
* Copyright (C) 2016 <copyright holder> <email>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#include "myslam/frame.h"
namespace myslam {
Frame::Frame(long id, double time_stamp, const SE3 &pose, const Mat &left,
const Mat &right)
: id_(id),
time_stamp_(time_stamp),
pose_(pose),
left_img_(left),
right_img_(right) {}
Frame::Ptr Frame::CreateFrame() {
static long factory_id = 0;
Frame::Ptr new_frame(new Frame);
new_frame->id_ = factory_id++;
return new_frame;
}
void Frame::SetKeyFrame() {
static long keyframe_factory_id = 0;
is_keyframe_ = true;
keyframe_id_ = keyframe_factory_id++;
}
} // namespace myslam
| 29.673913 | 74 | 0.701832 | Little-Potato-1990 |
24324a1ffde62b60851d6b01ac2a8b9ce366852c | 6,093 | cxx | C++ | Modules/Segmentation/LabelVoting/test/itkLabelVotingImageFilterTest.cxx | rmukh/ITK | 0fcfaf1288928a76c3ef2b3fcc8b6e53246bfbba | [
"Apache-2.0"
] | null | null | null | Modules/Segmentation/LabelVoting/test/itkLabelVotingImageFilterTest.cxx | rmukh/ITK | 0fcfaf1288928a76c3ef2b3fcc8b6e53246bfbba | [
"Apache-2.0"
] | null | null | null | Modules/Segmentation/LabelVoting/test/itkLabelVotingImageFilterTest.cxx | rmukh/ITK | 0fcfaf1288928a76c3ef2b3fcc8b6e53246bfbba | [
"Apache-2.0"
] | null | null | null | /*=========================================================================
*
* Copyright NumFOCUS
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0.txt
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*=========================================================================*/
#include "itkLabelVotingImageFilter.h"
#include "itkTestingMacros.h"
int
itkLabelVotingImageFilterTest(int, char *[])
{
// Define the dimension of the images
constexpr unsigned int Dimension = 3;
// Declare the pixel types of the images
using PixelType = unsigned int;
// Declare the types of the images
using ImageType = itk::Image<PixelType, Dimension>;
// Input data arrays for test images
const unsigned int dataImageA[8] = { 0, 1, 3, 3, 4, 6, 6, 0 };
const unsigned int dataImageB[8] = { 1, 1, 2, 4, 4, 5, 7, 1 };
const unsigned int dataImageC[8] = { 0, 2, 2, 3, 5, 5, 6, 8 };
// Correct combinations of input images
const unsigned int combinationABC[8] = { 0, 1, 2, 3, 4, 5, 6, 9 };
const unsigned int combinationAB[8] = { 8, 1, 8, 8, 4, 8, 8, 8 };
const unsigned int combinationABundecided255[8] = { 255, 1, 255, 255, 4, 255, 255, 255 };
// Declare the type of the index to access images
using IndexType = itk::Index<Dimension>;
// Declare the type of the size
using SizeType = itk::Size<Dimension>;
// Declare the type of the Region
using RegionType = itk::ImageRegion<Dimension>;
// Declare appropriate Iterator type for the images
using IteratorType = itk::ImageRegionIterator<ImageType>;
// Declare the type for the filter
using LabelVotingImageFilterType = itk::LabelVotingImageFilter<ImageType>;
// Create the input images
auto inputImageA = ImageType::New();
auto inputImageB = ImageType::New();
auto inputImageC = ImageType::New();
// Define their size, and start index
SizeType size;
size[0] = 2;
size[1] = 2;
size[2] = 2;
IndexType start;
start[0] = 0;
start[1] = 0;
start[2] = 0;
RegionType region;
region.SetIndex(start);
region.SetSize(size);
// Initialize Image A
inputImageA->SetLargestPossibleRegion(region);
inputImageA->SetBufferedRegion(region);
inputImageA->SetRequestedRegion(region);
inputImageA->Allocate();
IteratorType it = IteratorType(inputImageA, inputImageA->GetBufferedRegion());
for (int i = 0; i < 8; ++i, ++it)
{
it.Set(dataImageA[i]);
}
// Initialize Image B
inputImageB->SetLargestPossibleRegion(region);
inputImageB->SetBufferedRegion(region);
inputImageB->SetRequestedRegion(region);
inputImageB->Allocate();
it = IteratorType(inputImageB, inputImageB->GetBufferedRegion());
for (int i = 0; i < 8; ++i, ++it)
{
it.Set(dataImageB[i]);
}
// Initialize Image C
inputImageC->SetLargestPossibleRegion(region);
inputImageC->SetBufferedRegion(region);
inputImageC->SetRequestedRegion(region);
inputImageC->Allocate();
it = IteratorType(inputImageC, inputImageC->GetBufferedRegion());
for (int i = 0; i < 8; ++i, ++it)
{
it.Set(dataImageC[i]);
}
// Create the LabelVoting Filter
auto labelVotingFilter = LabelVotingImageFilterType::New();
ITK_EXERCISE_BASIC_OBJECT_METHODS(labelVotingFilter, LabelVotingImageFilter, ImageToImageFilter);
// Test with first two input images with undecided label set to 255
//
// Set the first two input images
labelVotingFilter->SetInput(0, inputImageA);
labelVotingFilter->SetInput(1, inputImageB);
// Set label for undecided pixels
labelVotingFilter->SetLabelForUndecidedPixels(255);
// Execute the filter
labelVotingFilter->Update();
// Get the filter output
ImageType::Pointer outputImage = labelVotingFilter->GetOutput();
// Compare to correct results
it = IteratorType(outputImage, outputImage->GetBufferedRegion());
for (unsigned int i = 0; i < 8; ++i, ++it)
{
if (combinationABundecided255[i] != it.Get())
{
std::cout << "Incorrect result using images A,B and undecided=255: "
<< "i = " << i << ", Expected = " << combinationABundecided255[i] << ", Received = " << it.Get()
<< "\n";
return EXIT_FAILURE;
}
}
// Test with first two input images
//
// unset undecided pixel label; reinstate automatic selection
labelVotingFilter->UnsetLabelForUndecidedPixels();
// Execute the filter
labelVotingFilter->Update();
// Get the filter output
outputImage = labelVotingFilter->GetOutput();
// Compare to correct results
it = IteratorType(outputImage, outputImage->GetBufferedRegion());
for (unsigned int i = 0; i < 8; ++i, ++it)
{
if (combinationAB[i] != it.Get())
{
std::cout << "Incorrect result using images A,B: i = " << i << ", Expected = " << combinationAB[i]
<< ", Received = " << it.Get() << "\n";
return EXIT_FAILURE;
}
}
// Test with all three input images
//
// Set the third input image
labelVotingFilter->SetInput(2, inputImageC);
// Execute the filter
labelVotingFilter->Update();
// Get the filter output
outputImage = labelVotingFilter->GetOutput();
// Compare to correct results
it = IteratorType(outputImage, outputImage->GetBufferedRegion());
for (unsigned int i = 0; i < 8; ++i, ++it)
{
if (combinationABC[i] != it.Get())
{
std::cout << "Incorrect result using images A,B,C: i = " << i << ", Expected = " << combinationABC[i]
<< ", Received = " << it.Get() << "\n";
return EXIT_FAILURE;
}
}
std::cout << "Test succeeded." << std::endl;
// All objects should be automatically destroyed at this point
return EXIT_SUCCESS;
}
| 29.293269 | 112 | 0.653701 | rmukh |
2434304dceb9fd76f54cffca7e929b8caabbab80 | 1,930 | cpp | C++ | CuriosityEngine/texturepack.cpp | GondalfGery/Entrophy-simulator | 2534a0c64e32bf3e492c98db1e87cef23d81cd59 | [
"MIT"
] | null | null | null | CuriosityEngine/texturepack.cpp | GondalfGery/Entrophy-simulator | 2534a0c64e32bf3e492c98db1e87cef23d81cd59 | [
"MIT"
] | null | null | null | CuriosityEngine/texturepack.cpp | GondalfGery/Entrophy-simulator | 2534a0c64e32bf3e492c98db1e87cef23d81cd59 | [
"MIT"
] | null | null | null | #include "texturepack.h"
void TexturePack::Bind()
{
//*****BACKGROUND******
glActiveTexture(GL_TEXTURE0 + 0);
glBindTexture(GL_TEXTURE_2D, m_backgroundTexture->GetTexture());
glActiveTexture(GL_TEXTURE0 + 1);
glBindTexture(GL_TEXTURE_2D, m_backgroundTexture->GetTexture()+sizeof(m_backgroundTexture->GetTexture()));
glActiveTexture(GL_TEXTURE0 + 2);
glBindTexture(GL_TEXTURE_2D, m_backgroundTexture->GetTexture()+sizeof(m_backgroundTexture->GetTexture())+sizeof(m_backgroundTexture->GetTexture()));
//*****R TEXTURE******
glActiveTexture(GL_TEXTURE0 + 3);
glBindTexture(GL_TEXTURE_2D, m_rTexture->GetTexture());
glActiveTexture(GL_TEXTURE0 + 4);
glBindTexture(GL_TEXTURE_2D, m_rTexture->GetTexture()+sizeof(m_rTexture->GetTexture()));
glActiveTexture(GL_TEXTURE0 + 5);
glBindTexture(GL_TEXTURE_2D, m_rTexture->GetTexture()+sizeof(m_rTexture->GetTexture())+sizeof(m_rTexture->GetTexture()));
//*****G TEXTURE******
glActiveTexture(GL_TEXTURE0 + 6);
glBindTexture(GL_TEXTURE_2D, m_gTexture->GetTexture());
glActiveTexture(GL_TEXTURE0 + 7);
glBindTexture(GL_TEXTURE_2D, m_gTexture->GetTexture()+sizeof(m_gTexture->GetTexture()));
glActiveTexture(GL_TEXTURE0 + 8);
glBindTexture(GL_TEXTURE_2D, m_gTexture->GetTexture()+sizeof(m_gTexture->GetTexture())+sizeof(m_gTexture->GetTexture()));
//*****B TEXTURE******
glActiveTexture(GL_TEXTURE0 + 9);
glBindTexture(GL_TEXTURE_2D, m_bTexture->GetTexture());
glActiveTexture(GL_TEXTURE0 + 10);
glBindTexture(GL_TEXTURE_2D, m_bTexture->GetTexture()+sizeof(m_bTexture->GetTexture()));
glActiveTexture(GL_TEXTURE0 + 11);
glBindTexture(GL_TEXTURE_2D, m_bTexture->GetTexture()+sizeof(m_bTexture->GetTexture())+sizeof(m_bTexture->GetTexture()));
//*****BLEND MAP******
glActiveTexture(GL_TEXTURE0 + 12);
glBindTexture(GL_TEXTURE_2D, m_blendMap->GetTexture());
}
| 39.387755 | 152 | 0.724352 | GondalfGery |
0f83d6480cb305953c9ecda7e84c08da56318083 | 235 | hpp | C++ | src/cxx_stubs/SFView_stub.hpp | reykjalin/ocaml-sfml | 50beb0b2ad77ecd0f1d6b5fd0723d33e2cd586c6 | [
"Zlib"
] | 16 | 2015-02-05T18:14:29.000Z | 2022-03-12T20:42:13.000Z | src/cxx_stubs/SFView_stub.hpp | reykjalin/ocaml-sfml | 50beb0b2ad77ecd0f1d6b5fd0723d33e2cd586c6 | [
"Zlib"
] | 4 | 2019-12-22T13:20:51.000Z | 2020-10-11T12:06:39.000Z | src/cxx_stubs/SFView_stub.hpp | reykjalin/ocaml-sfml | 50beb0b2ad77ecd0f1d6b5fd0723d33e2cd586c6 | [
"Zlib"
] | 5 | 2016-12-12T05:57:35.000Z | 2020-10-08T03:14:20.000Z | #ifndef _SF_VIEW_INC
#define _SF_VIEW_INC
#include <SFML/Graphics/View.hpp>
value Val_sfView(const sf::View *view, value origin = Val_unit);
#define SfView_val(view) (*(sf::View **)(Data_custom_val(view)))
#endif // _SF_VIEW_INC
| 18.076923 | 64 | 0.73617 | reykjalin |
0f8601e64b86a038ffccb51a6c9634fc46b89686 | 1,431 | cpp | C++ | src/lib/storage/fixed_size_attribute_vector.cpp | tjjordan/DYOD_SoSe21 | 9cf7af43f10caccbfa2b0583a43e991f24cd336c | [
"MIT"
] | 1 | 2022-01-25T09:03:56.000Z | 2022-01-25T09:03:56.000Z | src/lib/storage/fixed_size_attribute_vector.cpp | tjjordan/DYOD_SoSe21 | 9cf7af43f10caccbfa2b0583a43e991f24cd336c | [
"MIT"
] | 2 | 2022-02-10T14:25:25.000Z | 2022-03-12T20:19:12.000Z | src/lib/storage/fixed_size_attribute_vector.cpp | tjjordan/DYOD_SoSe21 | 9cf7af43f10caccbfa2b0583a43e991f24cd336c | [
"MIT"
] | null | null | null | #include "fixed_size_attribute_vector.hpp"
#include <limits>
#include <memory>
#include <sstream>
#include <string>
#include <utility>
#include <vector>
#include "type_cast.hpp"
#include "utils/assert.hpp"
namespace opossum {
template <typename uintX_t>
FixedSizeAttributeVector<uintX_t>::FixedSizeAttributeVector(const size_t size)
: _attribute_vector(std::vector<uintX_t>(size)) {}
// returns the value id at a given position
template <typename uintX_t>
ValueID FixedSizeAttributeVector<uintX_t>::get(const size_t index) const {
DebugAssert(index < size(), "Index out of bounds.");
return ValueID(_attribute_vector[index]);
}
// sets the value id at a given position
template <typename uintX_t>
void FixedSizeAttributeVector<uintX_t>::set(const size_t index, const ValueID value_id) {
DebugAssert(index < size(), "Index out of bounds.");
_attribute_vector[index] = static_cast<uintX_t>(value_id);
}
// returns the number of values
template <typename uintX_t>
size_t FixedSizeAttributeVector<uintX_t>::size() const {
return _attribute_vector.size();
}
// returns the width of biggest value id in bytes
template <typename uintX_t>
AttributeVectorWidth FixedSizeAttributeVector<uintX_t>::width() const {
return sizeof(uintX_t);
}
template class FixedSizeAttributeVector<uint8_t>;
template class FixedSizeAttributeVector<uint16_t>;
template class FixedSizeAttributeVector<uint32_t>;
} // namespace opossum
| 28.62 | 89 | 0.778477 | tjjordan |
0f8ddb3596bd6ca35b8bed8bbdf227b131caf340 | 570 | hpp | C++ | src/gui/guiutils.hpp | henryiii/spatial-model-editor | 2138d03ae4c7cc353b40324dfd1a3e763d7085d9 | [
"MIT"
] | 4 | 2019-07-18T15:05:09.000Z | 2020-03-14T09:50:07.000Z | src/gui/guiutils.hpp | henryiii/spatial-model-editor | 2138d03ae4c7cc353b40324dfd1a3e763d7085d9 | [
"MIT"
] | 418 | 2020-10-08T07:42:27.000Z | 2022-03-08T12:10:52.000Z | src/gui/guiutils.hpp | henryiii/spatial-model-editor | 2138d03ae4c7cc353b40324dfd1a3e763d7085d9 | [
"MIT"
] | 2 | 2021-09-02T11:20:38.000Z | 2021-10-13T14:05:32.000Z | #pragma once
#include <QImage>
#include <QString>
class QWidget;
class QMessageBox;
class QListWidget;
class QTreeWidget;
class QScrollArea;
void selectMatchingOrFirstItem(QListWidget *list, const QString &text = {});
void selectFirstChild(QTreeWidget *tree);
void selectMatchingOrFirstChild(QTreeWidget *list, const QString &text = {});
QImage getImageFromUser(QWidget *parent = nullptr,
const QString &title = "Import image");
void zoomScrollArea(QScrollArea *scrollArea, int zoomFactor,
const QPointF &relativePos);
| 24.782609 | 77 | 0.726316 | henryiii |
0f92a603808ebcde405ef673ae39d18a277470da | 1,332 | cpp | C++ | src/error.cpp | 1c0e/Abacus | 167b826aeef966014f185e3b5d376f39111c9e9e | [
"Apache-2.0"
] | 11 | 2021-01-12T00:45:49.000Z | 2022-01-17T06:22:17.000Z | src/error.cpp | 1c0e/Abacus | 167b826aeef966014f185e3b5d376f39111c9e9e | [
"Apache-2.0"
] | 3 | 2021-03-16T08:37:52.000Z | 2022-03-29T14:56:55.000Z | src/error.cpp | s3team/Abacus | 31bb80f7ce2b5cf52590c2627cf37e99e7b6a17b | [
"MIT"
] | 3 | 2021-05-09T06:57:42.000Z | 2021-11-23T13:06:17.000Z |
#include "error.hpp"
#include <iostream>
#include <map>
#include <string>
namespace tana {
void default_error_handler(const char *file, int line, const char *message) {
if (log_class == LOG_TYPE::MUTE) {
return;
}
std::string file_name(file);
std::string error_message(message);
std::cerr << "\n********************************" << std::endl;
std::cerr << "Error at :" << line << "\n";
std::cerr << "File name: " << file_name << "\n";
std::cerr << "Message: " << error_message << "\n";
std::cerr << "********************************\n" << std::endl;
// exit(0);
}
void default_warn_handler(const char *file, int line, const char *message) {
if (log_class == LOG_TYPE::INFO || log_class == LOG_TYPE::MUTE) {
return;
}
std::string file_name(file);
std::string error_message(message);
std::cerr << "\n********************************" << std::endl;
std::cerr << "Error at :" << line << "\n";
std::cerr << "File name: " << file_name << "\n";
std::cerr << "Message: " << error_message << "\n";
std::cerr << "********************************\n" << std::endl;
}
void debug_map(const std::map<int, uint32_t> &value_map) {
for (auto const &x : value_map) {
std::cout << x.first << ':' << std::hex << x.second << std::dec << " ";
}
std::cout << std::endl;
}
} // namespace tana | 28.956522 | 77 | 0.527027 | 1c0e |
0f9da20933837499f3b3387fa1a0b6da7397a92e | 4,401 | cpp | C++ | Source/SystemQOR/MSWindows/WinQL/System/Devices/Enumerator/WinQLRootDeviceEnumerator.cpp | mfaithfull/QOR | 0fa51789344da482e8c2726309265d56e7271971 | [
"BSL-1.0"
] | 9 | 2016-05-27T01:00:39.000Z | 2021-04-01T08:54:46.000Z | Source/SystemQOR/MSWindows/WinQL/System/Devices/Enumerator/WinQLRootDeviceEnumerator.cpp | mfaithfull/QOR | 0fa51789344da482e8c2726309265d56e7271971 | [
"BSL-1.0"
] | 1 | 2016-03-03T22:54:08.000Z | 2016-03-03T22:54:08.000Z | Source/SystemQOR/MSWindows/WinQL/System/Devices/Enumerator/WinQLRootDeviceEnumerator.cpp | mfaithfull/QOR | 0fa51789344da482e8c2726309265d56e7271971 | [
"BSL-1.0"
] | 4 | 2016-05-27T01:00:43.000Z | 2018-08-19T08:47:49.000Z | //WinQLRootDeviceEnumerator.cpp
// Copyright Querysoft Limited 2013, 2015, 2017
//
// Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following:
//
// The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by
// a source language processor.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
#include "SystemQOR/System.h"
#include "WinQL/CodeServices/WinQLPolicy.h"
#include "WinQL/Application/Threading/WinQLCriticalSection.h"
#include "WinQL/Application/ErrorSystem/WinQLError.h"
#include "WinQL/CodeServices/Text/WinString.h"
#include "WinQL/System/WinQLSystem.h"
#include "WinQL/System/Devices/Enumerator/WinQLRootDeviceEnumerator.h"
#include "WinQAPI/SetupAPI.h"
//--------------------------------------------------------------------------------
namespace nsWin32
{
using namespace nsWinQAPI;
//--------------------------------------------------------------------------------
__QOR_IMPLEMENT_OCLASS_LUID( CRootDeviceEnumerator );
//--------------------------------------------------------------------------------
CRootDeviceEnumerator::CRootDeviceEnumerator() : m_Library( CSetupAPI::Instance() )
{
_WINQ_FCONTEXT( "CRootDeviceEnumerator::CRootDeviceEnumerator" );
Enumerate();
}
//--------------------------------------------------------------------------------
unsigned int CRootDeviceEnumerator::Enumerate( void )
{
unsigned long ulEnumIndex = 0;
CTString strEnumerator( _TXT( "ROOT" ) );
unsigned long ulInitLength = 256;
unsigned long ulResult = 0;
CDeviceEnumerator::ref_type pEnumerator = new_shared_ref< CDeviceEnumerator >( strEnumerator );
TheSystem().As< nsWin32::CSystem >()->Devices( QOR_PP_SHARED_OBJECT_ACCESS )().RegisterEnumerator( strEnumerator, pEnumerator );
do
{
unsigned long ulLength = ulInitLength;
ulResult = m_Library.CM_Enumerate_Enumerators( ulEnumIndex, strEnumerator.GetBufferSetLength( static_cast< unsigned short >( ulLength ) ), &ulLength, 0 );
if( ulResult == CR_BUFFER_SMALL )
{
ulInitLength = ulLength + 1;
}
else
{
if( ulResult == CR_SUCCESS )
{
strEnumerator.ValidateBuffer( static_cast< unsigned short >( ulLength ) );
pEnumerator = new_shared_ref<CDeviceEnumerator>( strEnumerator );
TheSystem().As< nsWin32::CSystem >()->Devices( QOR_PP_SHARED_OBJECT_ACCESS )().RegisterEnumerator( strEnumerator, pEnumerator );
}
else
{
//TODO: Handle weirdness
}
ulEnumIndex++;
}
}while( ulResult != CR_NO_SUCH_VALUE );
return ulEnumIndex;
}
//--------------------------------------------------------------------------------
CRootDeviceEnumerator::CRootDeviceEnumerator( const CRootDeviceEnumerator& src ) : m_Library( CSetupAPI::Instance() )
{
_WINQ_FCONTEXT( "CRootDeviceEnumerator::CRootDeviceEnumerator" );
*this = src;
}
//--------------------------------------------------------------------------------
CRootDeviceEnumerator& CRootDeviceEnumerator::operator = ( const CRootDeviceEnumerator& src )
{
_WINQ_FCONTEXT( "CRootDeviceEnumerator::operator =" );
return *this;
}
//--------------------------------------------------------------------------------
CRootDeviceEnumerator::~CRootDeviceEnumerator()
{
_WINQ_FCONTEXT( "CRootDeviceEnumerator::~CRootDeviceEnumerator" );
}
}//nsWin32
| 41.130841 | 157 | 0.65417 | mfaithfull |
0f9f777ef3b011bbe225a7a50e6536d985bcef55 | 3,786 | cc | C++ | source/src/http/protocol/HttpProtocolDecoder.cc | ciscoruiz/wepa | e6d922157543c91b6804f11073424a0a9c6e8f51 | [
"MIT"
] | 2 | 2018-02-03T06:56:29.000Z | 2021-04-20T10:28:32.000Z | source/src/http/protocol/HttpProtocolDecoder.cc | ciscoruiz/wepa | e6d922157543c91b6804f11073424a0a9c6e8f51 | [
"MIT"
] | 8 | 2018-02-18T21:00:07.000Z | 2018-02-20T15:31:24.000Z | source/src/http/protocol/HttpProtocolDecoder.cc | ciscoruiz/wepa | e6d922157543c91b6804f11073424a0a9c6e8f51 | [
"MIT"
] | 1 | 2018-02-09T07:09:26.000Z | 2018-02-09T07:09:26.000Z | // MIT License
//
// Copyright (c) 2018 Francisco Ruiz ([email protected])
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
//
#include <coffee/http/protocol/HttpProtocolDecoder.hpp>
#include <coffee/http/protocol/defines.hpp>
#include <coffee/http/protocol/state/HttpProtocolState.hpp>
#include <coffee/http/protocol/state/HttpProtocolWaitingMessage.hpp>
#include <coffee/http/protocol/state/HttpProtocolWaitingContentLength.hpp>
#include <coffee/http/protocol/state/HttpProtocolWaitingBody.hpp>
#include <coffee/http/protocol/state/HttpProtocolReadBody.hpp>
using namespace coffee;
static http::protocol::state::HttpProtocolWaitingMessage stateWaitingMessage;
static http::protocol::state::HttpProtocolWaitingContentLength stateWaitingContentLength;
static http::protocol::state::HttpProtocolWaitingBody stateWaitingBody;
static http::protocol::state::HttpProtocolReadBody stateReadBody;
std::shared_ptr<http::HttpMessage> http::protocol::HttpProtocolDecoder::apply(const basis::DataBlock& dataBlock)
throw(basis::RuntimeException)
{
Token token;
setState(State::WaitingMessage);
m_result.reset();
m_bodyExpectedSize = 0;
while (readToken(dataBlock, token)) {
if (m_state->process(*this, token) == state::HttpProtocolState::ProcessResult::Completed) {
break;
}
}
if (!m_result) {
COFFEE_THROW_EXCEPTION("Unable to allocate an HTTP message");
}
return m_result;
}
bool http::protocol::HttpProtocolDecoder::readToken(const basis::DataBlock& dataBlock, protocol::Token& token)
throw(basis::RuntimeException)
{
static const int nchars = coffee_strlen(http::protocol::newLineCharacters);
if (token.currentPosition == dataBlock.size()) {
return false;
}
auto endToken = dataBlock.find(protocol::newLineCharacters, token.currentPosition);
if (endToken == std::string::npos) {
// Copy from the current position to the end
token.value = basis::DataBlock(dataBlock.data() + token.currentPosition, dataBlock.size() - token.currentPosition);
token.currentPosition = dataBlock.size();
return true;
}
if (endToken == token.currentPosition) {
// Empty token
token.value.clear();
token.currentPosition += nchars;
}
else {
token.value = basis::DataBlock(dataBlock.data() + token.currentPosition, endToken - token.currentPosition);
token.currentPosition = endToken + nchars;
}
return true;
}
void http::protocol::HttpProtocolDecoder::setState(const State::_v state)
noexcept
{
static const state::HttpProtocolState* states[] = { &stateWaitingMessage, &stateWaitingContentLength, &stateWaitingBody, &stateReadBody };
if (m_state != states[state]) {
m_state = states[state];
}
}
| 37.485149 | 141 | 0.744585 | ciscoruiz |
0fa03d7a5105acbccf51a2a319de4fdfe23a7b1f | 1,725 | cpp | C++ | Week 8/Lab/Week_8_Sample_Programs/Pr11-9.cpp | sugamkarki/NAMI-Year-II-Term-I-Software_Engineering | 39182816b670dcb75ec322e24b346a4cfeb80be0 | [
"Apache-2.0"
] | 3 | 2019-10-28T01:12:46.000Z | 2021-10-16T09:16:31.000Z | Week 8/Lab/Week_8_Sample_Programs/Pr11-9.cpp | sugamkarki/NAMI-Year-II-Term-I-Software_Engineering | 39182816b670dcb75ec322e24b346a4cfeb80be0 | [
"Apache-2.0"
] | null | null | null | Week 8/Lab/Week_8_Sample_Programs/Pr11-9.cpp | sugamkarki/NAMI-Year-II-Term-I-Software_Engineering | 39182816b670dcb75ec322e24b346a4cfeb80be0 | [
"Apache-2.0"
] | 4 | 2020-04-10T17:22:17.000Z | 2021-11-04T14:34:00.000Z | // This program demonstrates a union.
#include <iostream>
#include <iomanip>
using namespace std;
union PaySource
{
int hours; // Hours worked
float sales; // Amount of sales
};
int main()
{
PaySource employee1; // Define a union variable
char payType; // To hold the pay type
float payRate; // Hourly pay rate
float grossPay; // Gross pay
cout << fixed << showpoint << setprecision(2);
cout << "This program calculates either hourly wages or\n";
cout << "sales commission.\n";
// Get the pay type, hourly or commission.
cout << "Enter H for hourly wages or C for commission: ";
cin >> payType;
// Determine the gross pay, depending on the pay type.
if (payType == 'H' || payType == 'h')
{
// This is an hourly paid employee. Get the
// pay rate and hours worked.
cout << "What is the hourly pay rate? ";
cin >> payRate;
cout << "How many hours were worked? ";
cin >> employee1.hours;
// Calculate and display the gross pay.
grossPay = employee1.hours * payRate;
cout << "Gross pay: $" << grossPay << endl;
}
else if (payType == 'C' || payType == 'c')
{
// This is a commission-paid employee. Get the
// amount of sales.
cout << "What are the total sales for this employee? ";
cin >> employee1.sales;
// Calculate and display the gross pay.
grossPay = employee1.sales * 0.10;
cout << "Gross pay: $" << grossPay << endl;
}
else
{
// The user made an invalid selection.
cout << payType << " is not a valid selection.\n";
}
return 0;
} | 29.741379 | 63 | 0.566377 | sugamkarki |
0fa166751d178f1fb7e7f18be4914aa599ad222a | 546 | cpp | C++ | SDDD/changecode.cpp | hux8/SDD-Project | 1d589f88655f5a565f0c2efb5d60a3dd8ccc5c06 | [
"MIT"
] | null | null | null | SDDD/changecode.cpp | hux8/SDD-Project | 1d589f88655f5a565f0c2efb5d60a3dd8ccc5c06 | [
"MIT"
] | 1 | 2019-03-15T01:59:20.000Z | 2019-03-15T17:36:01.000Z | SDDD/changecode.cpp | hux8/SDD-Project | 1d589f88655f5a565f0c2efb5d60a3dd8ccc5c06 | [
"MIT"
] | 5 | 2018-10-25T23:14:30.000Z | 2018-11-05T18:43:46.000Z | #include "changecode.h"
#include "ui_changecode.h"
ChangeCode::ChangeCode(QWidget *parent) :
QDialog(parent),
ui(new Ui::ChangeCode)
{
ui->setupUi(this);
ui->error->setVisible(false);
}
ChangeCode::~ChangeCode()
{
delete ui;
}
void ChangeCode::accept()
{
//check if the code is new
if(ui->first->text()==ui->second->text())
emit changeCode(ui->first->text());
//update the code
else
{
ui->error->setVisible(true);
ui->first->setText("");
ui->second->setText("");
}
}
| 18.2 | 45 | 0.587912 | hux8 |
0fa2f3381fa2fce2d606117c7886e9156e9a79f2 | 2,377 | hpp | C++ | include/oglplus/imports/blend_file/reader.hpp | matus-chochlik/oglplus | 76dd964e590967ff13ddff8945e9dcf355e0c952 | [
"BSL-1.0"
] | 364 | 2015-01-01T09:38:23.000Z | 2022-03-22T05:32:00.000Z | include/oglplus/imports/blend_file/reader.hpp | matus-chochlik/oglplus | 76dd964e590967ff13ddff8945e9dcf355e0c952 | [
"BSL-1.0"
] | 55 | 2015-01-06T16:42:55.000Z | 2020-07-09T04:21:41.000Z | include/oglplus/imports/blend_file/reader.hpp | matus-chochlik/oglplus | 76dd964e590967ff13ddff8945e9dcf355e0c952 | [
"BSL-1.0"
] | 57 | 2015-01-07T18:35:49.000Z | 2022-03-22T05:32:04.000Z | /**
* @file oglplus/imports/blend_file/reader.hpp
* @brief Helper class for .blend file import basic input operations
*
* @author Matus Chochlik
*
* Copyright 2010-2019 Matus Chochlik. Distributed under the Boost
* Software License, Version 1.0. (See accompanying file
* LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
*/
#pragma once
#ifndef OGLPLUS_IMPORTS_BLEND_FILE_READER_1107121519_HPP
#define OGLPLUS_IMPORTS_BLEND_FILE_READER_1107121519_HPP
#include "utils.hpp"
#include <oglplus/config/compiler.hpp>
#include <cassert>
#include <cstddef>
#include <istream>
#include <sstream>
#include <stdexcept>
#include <string>
#include <vector>
namespace oglplus {
namespace imports {
// Internal helper class used for .blend file read operations
// Wraps around an istream and implements operations used by
// the loader
// NOTE: implementation detail, do not use
class BlendFileReader : public BlendFileUtils {
private:
std::istream& _input;
// peek at the next byte and return true if we are at EOF
bool _eof();
// composes error message and throws an exception
OGLPLUS_NORETURN
void _error(const std::string& message);
// reads a single char throws on error
char _read_char(const char* error_message);
// reads the specified number of bytes throws on error
void _raw_read(char* buffer, std::size_t size, const char* error_message);
// reads a string of the specified lenght,
// terminates by zero
// throws on error
void _read(char* buffer, std::size_t max, const char* error_message);
// reads until a delimiter is found,
// throws on error
void _read_until(
std::streambuf& sb, char delimiter, const char* error_message);
// skips the specified number of bytes
// throws on error
void _skip(std::size_t size, const char* error_message);
// aligns the input to the specified size
// throws on error
void _align(const std::size_t size, const char* error_message);
friend class BlendFileReaderClient;
public:
BlendFileReader(std::istream& input)
: BlendFileUtils(4)
, _input(input) {
}
};
} // namespace imports
} // namespace oglplus
#if !OGLPLUS_LINK_LIBRARY || defined(OGLPLUS_IMPLEMENTING_LIBRARY)
#include <oglplus/imports/blend_file/reader.ipp>
#endif // OGLPLUS_LINK_LIBRARY
#endif // include guard
| 27.964706 | 78 | 0.724443 | matus-chochlik |
0fa4a12e511a30a4ffcce86ee894d6b56272fc1c | 3,017 | cpp | C++ | src/coreclr/src/pal/tests/palsuite/threading/WaitForSingleObject/test1/test1.cpp | swaroop-sridhar/runtime | d0efddd932f6fb94c3e9436ab393fc390c7b2da9 | [
"MIT"
] | 52 | 2017-03-15T08:16:52.000Z | 2019-04-26T07:53:29.000Z | src/coreclr/src/pal/tests/palsuite/threading/WaitForSingleObject/test1/test1.cpp | swaroop-sridhar/runtime | d0efddd932f6fb94c3e9436ab393fc390c7b2da9 | [
"MIT"
] | 2 | 2020-03-25T06:25:42.000Z | 2022-02-25T21:30:33.000Z | src/coreclr/src/pal/tests/palsuite/threading/WaitForSingleObject/test1/test1.cpp | swaroop-sridhar/runtime | d0efddd932f6fb94c3e9436ab393fc390c7b2da9 | [
"MIT"
] | 14 | 2019-05-09T13:15:41.000Z | 2021-11-16T02:54:09.000Z | // Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
/*============================================================
**
** Source: test1.c
**
** Purpose: Test for WaitForSingleObjectTest. Create two events, one
** with a TRUE and one with FALSE intial state. Ensure that WaitForSingle
** returns correct values for each of these.
**
**
**=========================================================*/
#include <palsuite.h>
BOOL WaitForSingleObjectTest()
{
BOOL bRet = FALSE;
DWORD dwRet = 0;
LPSECURITY_ATTRIBUTES lpEventAttributes = 0;
BOOL bManualReset = TRUE;
BOOL bInitialState = TRUE;
HANDLE hEvent;
/* Create an event, and ensure the HANDLE is valid */
hEvent = CreateEvent(lpEventAttributes, bManualReset,
bInitialState, NULL);
if (hEvent != INVALID_HANDLE_VALUE)
{
/* Call WaitForSingleObject with 0 time on the event. It
should return WAIT_OBJECT_0
*/
dwRet = WaitForSingleObject(hEvent,0);
if (dwRet != WAIT_OBJECT_0)
{
Trace("WaitForSingleObjectTest:WaitForSingleObject failed (%x)\n", GetLastError());
}
else
{
bRet = CloseHandle(hEvent);
if (!bRet)
{
Trace("WaitForSingleObjectTest:CloseHandle failed (%x)\n", GetLastError());
}
}
}
else
{
Trace("WaitForSingleObjectTest:CreateEvent failed (%x)\n", GetLastError());
}
/* If the first section passed, Create another event, with the
intial state being FALSE this time.
*/
if (bRet)
{
bRet = FALSE;
bInitialState = FALSE;
hEvent = CreateEvent( lpEventAttributes,
bManualReset, bInitialState, NULL);
if (hEvent != INVALID_HANDLE_VALUE)
{
/* Test WaitForSingleObject and ensure that it returns
WAIT_TIMEOUT in this case.
*/
dwRet = WaitForSingleObject(hEvent,0);
if (dwRet != WAIT_TIMEOUT)
{
Trace("WaitForSingleObjectTest:WaitForSingleObject failed (%x)\n", GetLastError());
}
else
{
bRet = CloseHandle(hEvent);
if (!bRet)
{
Trace("WaitForSingleObjectTest:CloseHandle failed (%x)\n", GetLastError());
}
}
}
else
{
Trace("WaitForSingleObjectTest::CreateEvent failed (%x)\n", GetLastError());
}
}
return bRet;
}
int __cdecl main(int argc, char **argv)
{
if(0 != (PAL_Initialize(argc, argv)))
{
return ( FAIL );
}
if(!WaitForSingleObjectTest())
{
Fail ("Test failed\n");
}
PAL_Terminate();
return ( PASS );
}
| 24.933884 | 99 | 0.51939 | swaroop-sridhar |
0fa79fb15208fbecbbe8a16c6fd7756faa6d0c2a | 10,222 | cpp | C++ | Sharing/Src/Source/Common/Private/SessionImpl.cpp | darax/HoloToolkit | 5f7ddc5698dd10e83a252187983ec366d2062d08 | [
"MIT"
] | null | null | null | Sharing/Src/Source/Common/Private/SessionImpl.cpp | darax/HoloToolkit | 5f7ddc5698dd10e83a252187983ec366d2062d08 | [
"MIT"
] | null | null | null | Sharing/Src/Source/Common/Private/SessionImpl.cpp | darax/HoloToolkit | 5f7ddc5698dd10e83a252187983ec366d2062d08 | [
"MIT"
] | null | null | null | //////////////////////////////////////////////////////////////////////////
// SessionImpl.cpp
//
//
//
// Copyright (C) 2014 Microsoft Corp. All Rights Reserved
//////////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "NetworkConnectionImpl.h"
#include "SessionImpl.h"
#include "SessionMessageRouter.h"
#include "SessionManagerImpl.h"
XTOOLS_NAMESPACE_BEGIN
SessionImpl::SessionImpl(SessionManagerImpl* mgr, const ClientContextConstPtr& context, uint32 sessionID, SessionType sessionType, const std::string& name, const std::string& address, uint16 port)
: m_sessionMgr(mgr)
, m_context(context)
, m_curState(MachineSessionState::DISCONNECTED)
, m_listenerList(ListenerList::Create())
, m_id(sessionID)
, m_sessionType(sessionType)
, m_name(new XString(name))
, m_address(address)
, m_port(port)
{
m_sessionConnection = m_context->GetSessionConnection();
m_messageRouter.RegisterHandler(new MessageHandlerProxyT<const JoinSessionReply&>(CreateCallback2(this, &SessionImpl::OnJoinSessionReply)));
}
MachineSessionState SessionImpl::GetMachineSessionState() const
{
return m_curState;
}
void SessionImpl::AddListener(SessionListener* newListener)
{
m_listenerList->AddListener(newListener);
}
void SessionImpl::RemoveListener(SessionListener* oldListener)
{
m_listenerList->RemoveListener(oldListener);
}
bool SessionImpl::IsJoined() const
{
return m_curState == MachineSessionState::JOINED;
}
bool SessionImpl::Join()
{
// Cannot join a session while we're joined or currently attempting to join.
if (MachineSessionState::DISCONNECTED == m_curState)
{
LogInfo("Attempting to join session %s at %s:%i", m_name->GetString().c_str(), m_address.c_str(), m_port);
// Verify that no other sessions are already in a joining state.
int sessionCount = m_sessionMgr->GetSessionCount();
for (int i = 0; i < sessionCount; i++)
{
SessionPtr curSession = m_sessionMgr->GetSession(i);
// Fail if any sessions are in a pending state.
// TODO: Instead, we should just auto leave all non-disconnected sessions.
if (curSession->GetMachineSessionState() == MachineSessionState::JOINING)
{
LogError("SessionImpl::Join called while another session %s was in a joining state", curSession->GetName()->GetString().c_str());
curSession->Leave();
XTASSERT(curSession->GetMachineSessionState() == MachineSessionState::DISCONNECTED);
return false;
}
}
SessionPtr oldSession = m_sessionMgr->GetCurrentSession();
if (oldSession)
{
LogInfo("Automatically leaving existing session %s", oldSession->GetName()->GetString().c_str());
oldSession->Leave();
XTASSERT(oldSession->GetMachineSessionState() == MachineSessionState::DISCONNECTED);
XTASSERT(m_sessionMgr->GetCurrentSession() == NULL);
}
// Set out state to joining
SetState(MachineSessionState::JOINING);
// Set this as the current session for this machine
m_sessionMgr->SetCurrentSession(this);
// Attempting to join a new session; notify the listeners
m_listenerList->NotifyListeners(&SessionListener::OnJoiningSession);
// Attempt to open a connection to this session
XSocketPtr socket = m_context->GetXSocketManager()->OpenConnection(m_address, m_port);
if (XTVERIFY(socket))
{
// Initiate the handshake
HandshakeCallback callback = CreateCallback3(this, &SessionImpl::OnHandshakeComplete);
m_handshake = new NetworkHandshake(socket, new SessionHandshakeLogic(false), callback);
return true;
}
else
{
LogError("Join failed we failed to create a socket to the session at %s:%u.", m_address.c_str(), m_port);
}
}
else
{
LogError("Join failed because the current state is %s instead of DISCONNECTED", (m_curState == MachineSessionState::JOINING) ? "JOINING" : "JOINED");
}
return false;
}
void SessionImpl::Leave()
{
LogInfo("Leaving session %s at %s:%i", m_name->GetString().c_str(), m_address.c_str(), m_port);
SessionPtr currentSession = m_sessionMgr->GetCurrentSession();
if (currentSession == this)
{
bool isConnected = m_sessionConnection->IsConnected();
if (isConnected)
{
// Will cause OnDisconnected to be called
m_sessionConnection->Disconnect();
}
TeardownConnection();
XTASSERT(m_sessionMgr->GetCurrentSession() == NULL);
}
XTASSERT(GetMachineSessionState() == MachineSessionState::DISCONNECTED);
}
int32 SessionImpl::GetUserCount() const
{
return static_cast<int32>(m_users.size());
}
UserPtr SessionImpl::GetUser(int32 i)
{
if (i >= 0 && i < GetUserCount())
{
return m_users[i];
}
else
{
return NULL;
}
}
SessionType SessionImpl::GetSessionType() const
{
return m_sessionType;
}
const XStringPtr& SessionImpl::GetName() const
{
return m_name;
}
unsigned int SessionImpl::GetSessionId() const
{
return m_id;
}
void SessionImpl::SetSessionId(unsigned int id)
{
m_id = id;
}
NetworkConnectionPtr SessionImpl::GetSessionNetworkConnection() const
{
return m_sessionConnection;
}
void SessionImpl::SetState(MachineSessionState newState)
{
m_curState = newState;
}
void SessionImpl::AddUser(const UserPtr& newUser)
{
UserPtr existingUser = FindUser(newUser->GetID());
if (!existingUser)
{
m_users.push_back(newUser);
}
}
UserPtr SessionImpl::RemoveUser(UserID userID)
{
for (size_t i = 0; i < m_users.size(); ++i)
{
if (m_users[i]->GetID() == userID)
{
UserPtr user = m_users[i];
m_users.erase(m_users.begin() + i);
return user;
}
}
return NULL;
}
void SessionImpl::UpdateUser(const UserPtr& updatedUser)
{
// Expect this only to be called on sessions we are joined to.
XTASSERT(IsJoined());
UserPtr user = FindUser(updatedUser->GetID());
// Assert that we aren't updating for a user who's not present.
if (XTVERIFY(user))
{
UserChangedSessionMsg userUpdateMsg(m_id, user->GetName()->GetString(), user->GetID(), user->GetMuteState());
NetworkOutMessagePtr msg = m_sessionConnection->CreateMessage(MessageID::SessionControl);
msg->Write(new XString(userUpdateMsg.ToJSONString()));
m_sessionConnection->Send(msg);
}
}
UserPtr SessionImpl::FindUser(UserID userID) const
{
for (size_t i = 0; i < m_users.size(); ++i)
{
if (m_users[i]->GetID() == userID)
{
return m_users[i];
}
}
return NULL;
}
void SessionImpl::OnConnected(const NetworkConnectionPtr& connection)
{
// We have successfully connected to this session.
// Now send it information about us so it lets us in all the way
XTASSERT(m_curState == MachineSessionState::JOINING);
JoinSessionRequest request(
m_context->GetLocalUser()->GetName()->GetString(),
m_context->GetLocalUser()->GetID(),
m_context->GetLocalUser()->GetMuteState()
);
NetworkOutMessagePtr msg = connection->CreateMessage(MessageID::SessionControl);
msg->Write(new XString(request.ToJSONString()));
connection->Send(msg);
}
void SessionImpl::OnConnectFailed(const NetworkConnectionPtr&)
{
XTASSERT(m_curState == MachineSessionState::JOINING);
TeardownConnection();
}
void SessionImpl::OnDisconnected(const NetworkConnectionPtr&)
{
// Connection to the session has been lost; we are no longer joined
TeardownConnection();
}
void SessionImpl::OnMessageReceived(const NetworkConnectionPtr& connection, NetworkInMessage& message)
{
XStringPtr command = message.ReadString();
JSONMessagePtr jMsg = JSONMessage::CreateFromMessage(command->GetString());
// Route the incoming message to the appropriate function to handle it
if (!m_messageRouter.CallHandler(jMsg, connection))
{
// We got a bad or unexpected message from the server; break the connection
TeardownConnection();
}
}
void SessionImpl::OnJoinSessionReply(const JoinSessionReply& reply, const NetworkConnectionPtr&)
{
XTASSERT(m_curState == MachineSessionState::JOINING);
if (reply.GetResult())
{
LogInfo("Session Join Succeeded");
SetState(MachineSessionState::JOINED);
// Add the connection to the session to the Sync manager
m_context->GetSyncManager()->AddConnection(m_sessionConnection);
m_context->GetInternalSyncManager()->AddConnection(m_sessionConnection);
// Connect the tunnel between the secondary client and the session
m_tunnelBridge = new TunnelBridge(m_sessionConnection, m_context->GetPairedConnection());
AddUser(m_context->GetLocalUser());
m_sessionMgr->NotifyOnUserJoinedSessionListeners(this, m_context->GetLocalUser());
// Tell all listeners that we've successfully created the session.
m_listenerList->NotifyListeners(&SessionListener::OnJoinSucceeded);
}
else
{
LogInfo("Session Join Failed!");
Leave();
}
}
void SessionImpl::OnHandshakeComplete(const XSocketPtr& newConnection, SocketID, HandshakeResult result)
{
m_handshake = NULL;
if (newConnection && result == HandshakeResult::Success)
{
// Register to listen for SessionControl messages from the session
m_sessionConnection->AddListener(MessageID::SessionControl, this);
m_sessionConnection->SetSocket(newConnection);
}
else
{
LogInfo("Session: Handshake for session %s failed with error %u", m_name->GetString().c_str(), result);
XTASSERT(m_curState == MachineSessionState::JOINING);
Leave();
}
}
void SessionImpl::TeardownConnection()
{
MachineSessionState oldState = m_curState;
SetState(MachineSessionState::DISCONNECTED);
m_handshake = nullptr;
m_tunnelBridge = nullptr;
m_sessionConnection->RemoveListener(MessageID::SessionControl, this);
m_context->GetSyncManager()->RemoveConnection(m_sessionConnection);
m_context->GetInternalSyncManager()->RemoveConnection(m_sessionConnection);
m_sessionMgr->SetCurrentSession(NULL);
// Notify the listeners
if (oldState == MachineSessionState::JOINED)
{
m_listenerList->NotifyListeners(&SessionListener::OnSessionDisconnected);
}
else if (oldState == MachineSessionState::JOINING)
{
m_listenerList->NotifyListeners(&SessionListener::OnJoinFailed);
}
}
XTOOLS_NAMESPACE_END
| 25.683417 | 196 | 0.711407 | darax |
0faa1d597a62c211f319bb778d6c4785a7fd52f4 | 669 | hpp | C++ | PyMieSim/includes/LMT/includes/Definitions.hpp | MartinPdS/PyMieSim | 2560c7f4009df5d05bcb0ce8e929aa7baa7be8de | [
"MIT"
] | 6 | 2021-02-11T17:53:40.000Z | 2021-12-11T20:20:01.000Z | PyMieSim/includes/LMT/includes/Definitions.hpp | MartinPdS/PyMieSim | 2560c7f4009df5d05bcb0ce8e929aa7baa7be8de | [
"MIT"
] | 6 | 2021-05-12T04:33:26.000Z | 2021-11-14T05:25:19.000Z | PyMieSim/includes/LMT/includes/Definitions.hpp | MartinPdS/PyMieSim | 2560c7f4009df5d05bcb0ce8e929aa7baa7be8de | [
"MIT"
] | 3 | 2021-05-10T19:46:42.000Z | 2021-06-01T19:52:14.000Z | #ifndef DEF_H
#define DEF_H
#include "pybind11.hpp"
typedef unsigned int uint;
typedef std::complex<double> complex128;
typedef std::vector<double> DVector;
typedef std::vector<complex128> CVector;
typedef pybind11::array_t<double> ndarray;
typedef pybind11::array_t<complex128> Cndarray;
typedef std::vector<std::vector<double>> Matrix3;
typedef pybind11::array_t<size_t> Indarray;
typedef pybind11::buffer_info info;
#define J complex128(0.0,1.0)
#define PI (double)3.14159265358979323846264338
double EPSILON0 = 8.854187817620389e-12;
double C = 299792458.0 ;
#endif
| 25.730769 | 52 | 0.67713 | MartinPdS |
0fac56086f3cd6a06d615db843a6fbb93c6f304b | 522 | hxx | C++ | odb-tests-2.4.0/libcommon/common/config.hxx | edidada/odb | 78ed750a9dde65a627fc33078225410306c2e78b | [
"MIT"
] | null | null | null | odb-tests-2.4.0/libcommon/common/config.hxx | edidada/odb | 78ed750a9dde65a627fc33078225410306c2e78b | [
"MIT"
] | null | null | null | odb-tests-2.4.0/libcommon/common/config.hxx | edidada/odb | 78ed750a9dde65a627fc33078225410306c2e78b | [
"MIT"
] | null | null | null | // file : libcommon/common/config.hxx
// copyright : Copyright (c) 2005-2015 Code Synthesis Tools CC
// license : GNU GPL v2; see accompanying LICENSE file
#ifndef LIBCOMMON_COMMON_CONFIG_HXX
#define LIBCOMMON_COMMON_CONFIG_HXX
#ifdef HAVE_CONFIG_VC_H
# include <common/config-vc.h>
#else
# include <common/config.h>
// GCC supports strongly typed enums from 4.4 (forward -- 4.6),
// Clang -- 2.9 (3.1).
//
# ifdef HAVE_CXX11
# define HAVE_CXX11_ENUM
# endif
#endif
#endif // LIBCOMMON_COMMON_CONFIG_HXX
| 23.727273 | 63 | 0.727969 | edidada |
0fb02bebc89e077559a8771bf8a33cb5817f763a | 9,544 | cpp | C++ | LevelEditor/Edit/EShape.cpp | MlssingTexture/xray-sdk | 648de11d78fcc8088e802572da6187ee9b198f9f | [
"CC0-1.0"
] | 8 | 2016-01-25T20:18:51.000Z | 2019-03-06T07:00:04.000Z | LevelEditor/Edit/EShape.cpp | MlssingTexture/xray-sdk | 648de11d78fcc8088e802572da6187ee9b198f9f | [
"CC0-1.0"
] | null | null | null | LevelEditor/Edit/EShape.cpp | MlssingTexture/xray-sdk | 648de11d78fcc8088e802572da6187ee9b198f9f | [
"CC0-1.0"
] | 3 | 2016-02-14T01:20:43.000Z | 2021-02-03T11:19:11.000Z | //---------------------------------------------------------------------------
#include "stdafx.h"
#pragma hdrstop
#include "EShape.h"
#include "D3DUtils.h"
#include "du_box.h"
#include "Scene.h"
#define SHAPE_COLOR_TRANSP 0x1800FF00
#define SHAPE_COLOR_EDGE 0xFF202020
//---------------------------------------------------------------------------
#define SHAPE_CURRENT_VERSION 0x0001
//---------------------------------------------------------------------------
#define SHAPE_CHUNK_VERSION 0x0000
#define SHAPE_CHUNK_SHAPES 0x0001
//---------------------------------------------------------------------------
CEditShape::CEditShape(LPVOID data, LPCSTR name):CCustomObject(data,name)
{
Construct(data);
}
CEditShape::~CEditShape()
{
}
void CEditShape::Construct(LPVOID data)
{
ClassID = OBJCLASS_SHAPE;
m_DrawTranspColor = SHAPE_COLOR_TRANSP;
m_DrawEdgeColor = SHAPE_COLOR_EDGE;
m_Box.invalidate();
}
void CEditShape::OnUpdateTransform()
{
inherited::OnUpdateTransform();
}
void CEditShape::ComputeBounds()
{
m_Box.invalidate ();
for (ShapeIt it=shapes.begin(); it!=shapes.end(); it++){
switch (it->type){
case cfSphere:{
Fsphere& T = it->data.sphere;
Fvector P;
P.set (T.P); P.sub(T.R); m_Box.modify(P);
P.set (T.P); P.add(T.R); m_Box.modify(P);
}break;
case cfBox:{
Fvector P;
Fmatrix& T = it->data.box;
// Build points
Fvector p;
for (int i=0; i<DU_BOX_NUMVERTEX; i++){
T.transform_tiny (P,du_box_vertices[i]);
m_Box.modify (P);
}
}break;
}
}
m_Box.getsphere(m_Sphere.P,m_Sphere.R);
}
void CEditShape::SetScale(const Fvector& val)
{
if (shapes.size()==1){
switch (shapes[0].type){
case cfSphere:{
FScale.set(val.x,val.x,val.x);
}break;
case cfBox: FScale.set(val.x,val.y,val.z); break;
default: THROW;
}
}else{
FScale.set(val.x,val.x,val.x);
}
ComputeBounds ();
UpdateTransform ();
}
void CEditShape::ApplyScale()
{
for (ShapeIt it=shapes.begin(); it!=shapes.end(); it++){
switch (it->type){
case cfSphere:{
Fsphere& T = it->data.sphere;
FTransformS.transform_tiny(T.P);
T.R *= PScale.x;
}break;
case cfBox:{
Fmatrix& B = it->data.box;
B.mulA_43 (FTransformS);
}break;
}
}
FScale.set (1.f,1.f,1.f);
UpdateTransform (true);
ComputeBounds ();
}
void CEditShape::add_sphere(const Fsphere& S)
{
shapes.push_back(shape_def());
shapes.back().type = cfSphere;
shapes.back().data.sphere.set(S);
ComputeBounds();
}
void CEditShape::add_box(const Fmatrix& B)
{
shapes.push_back(shape_def());
shapes.back().type = cfBox;
shapes.back().data.box.set(B);
ComputeBounds();
}
void CEditShape::Attach(CEditShape* from)
{
ApplyScale ();
// transfer data
from->ApplyScale ();
Fmatrix M = from->_Transform();
M.mulA_43 (_ITransform());
for (ShapeIt it=from->shapes.begin(); it!=from->shapes.end(); it++){
switch (it->type){
case cfSphere:{
Fsphere& T = it->data.sphere;
M.transform_tiny(T.P);
add_sphere (T);
}break;
case cfBox:{
Fmatrix B = it->data.box;
B.mulA_43 (M);
add_box (B);
}break;
default: THROW;
}
}
// common
Scene->RemoveObject (from,true);
xr_delete (from);
ComputeBounds ();
}
void CEditShape::Detach()
{
if (shapes.size()>1){
Select (true);
ApplyScale ();
// create scene shapes
const Fmatrix& M = _Transform();
ShapeIt it=shapes.begin(); it++;
for (; it!=shapes.end(); it++){
string256 namebuffer;
Scene->GenObjectName (OBJCLASS_SHAPE, namebuffer, Name);
CEditShape* shape = (CEditShape*)Scene->GetOTools(ClassID)->CreateObject(0, namebuffer);
switch (it->type){
case cfSphere:{
Fsphere T = it->data.sphere;
M.transform_tiny(T.P);
shape->PPosition= T.P;
T.P.set (0,0,0);
shape->add_sphere(T);
}break;
case cfBox:{
Fmatrix B = it->data.box;
B.mulA_43 (M);
shape->PPosition= B.c;
B.c.set (0,0,0);
shape->add_box (B);
}break;
default: THROW;
}
Scene->AppendObject (shape,false);
shape->Select (true);
}
// erase shapes in base object
it=shapes.begin(); it++;
shapes.erase(it,shapes.end());
ComputeBounds();
Scene->UndoSave();
}
}
bool CEditShape::RayPick(float& distance, const Fvector& start, const Fvector& direction, SRayPickInfo* pinf)
{
float dist = distance;
for (ShapeIt it=shapes.begin(); it!=shapes.end(); it++){
switch (it->type){
case cfSphere:{
Fvector S,D;
Fmatrix M;
M.invert (FTransformR);
M.transform_dir (D,direction);
FITransform.transform_tiny(S,start);
Fsphere& T = it->data.sphere;
T.intersect (S,D,dist);
if (dist<=0.f) dist = distance;
}break;
case cfBox:{
Fbox box;
box.identity ();
Fmatrix BI;
BI.invert (it->data.box);
Fvector S,D,S1,D1,P;
FITransform.transform_tiny (S,start);
FITransform.transform_dir (D,direction);
BI.transform_tiny (S1,S);
BI.transform_dir (D1,D);
Fbox::ERP_Result rp_res = box.Pick2(S1,D1,P);
if (rp_res==Fbox::rpOriginOutside){
it->data.box.transform_tiny (P);
FTransform.transform_tiny (P);
P.sub (start);
dist = P.magnitude();
}
}break;
}
}
if (dist<distance){
distance = dist;
return true;
}
return false;
}
bool CEditShape::FrustumPick(const CFrustum& frustum)
{
const Fmatrix& M = _Transform();
for (ShapeIt it=shapes.begin(); it!=shapes.end(); it++){
switch (it->type){
case cfSphere:{
Fvector C;
Fsphere& T = it->data.sphere;
M.transform_tiny(C,T.P);
if (frustum.testSphere_dirty(C,T.R*FScale.x)) return true;
}break;
case cfBox:{
Fbox box;
box.identity ();
Fmatrix B = it->data.box;
B.mulA_43 (_Transform());
box.xform (B);
u32 mask = 0xff;
if (frustum.testAABB(box.data(),mask)) return true;
}break;
}
}
return false;
}
bool CEditShape::GetBox(Fbox& box)
{
if (m_Box.is_valid()){
box.xform(m_Box,FTransform);
return true;
}
return false;
}
bool CEditShape::Load(IReader& F)
{
R_ASSERT(F.find_chunk(SHAPE_CHUNK_VERSION));
u16 vers = F.r_u16();
if (SHAPE_CURRENT_VERSION!=vers){
ELog.DlgMsg( mtError, "CEditShape: unsupported version. Object can't load.");
return false;
}
inherited::Load (F);
R_ASSERT(F.find_chunk(SHAPE_CHUNK_SHAPES));
shapes.resize (F.r_u32());
F.r (shapes.begin(),shapes.size()*sizeof(shape_def));
ComputeBounds();
return true;
}
void CEditShape::Save(IWriter& F)
{
inherited::Save (F);
F.open_chunk (SHAPE_CHUNK_VERSION);
F.w_u16 (SHAPE_CURRENT_VERSION);
F.close_chunk ();
F.open_chunk (SHAPE_CHUNK_SHAPES);
F.w_u32 (shapes.size());
F.w (shapes.begin(),shapes.size()*sizeof(shape_def));
F.close_chunk ();
}
void CEditShape::FillProp(LPCSTR pref, PropItemVec& values)
{
inherited::FillProp(pref,values);
}
void CEditShape::Render(int priority, bool strictB2F)
{
inherited::Render(priority, strictB2F);
if (1==priority){
if (strictB2F){
Device.SetShader (Device.m_WireShader);
Device.SetRS (D3DRS_CULLMODE,D3DCULL_NONE);
u32 clr = Selected()?subst_alpha(m_DrawTranspColor, color_get_A(m_DrawTranspColor)*2):m_DrawTranspColor;
Fvector zero ={0.f,0.f,0.f};
for (ShapeIt it=shapes.begin(); it!=shapes.end(); it++){
switch(it->type){
case cfSphere:{
Fsphere& S = it->data.sphere;
Fmatrix B;
B.scale (S.R,S.R,S.R);
B.translate_over (S.P);
B.mulA_43 (_Transform());
RCache.set_xform_world(B);
Device.SetShader (Device.m_WireShader);
DU.DrawCross (zero,1.f,m_DrawEdgeColor,false);
DU.DrawIdentSphere (true,true,clr,m_DrawEdgeColor);
}break;
case cfBox:
Fmatrix B = it->data.box;
B.mulA_43 (_Transform());
RCache.set_xform_world(B);
DU.DrawIdentBox (true,true,clr,m_DrawEdgeColor);
break;
}
}
Device.SetRS(D3DRS_CULLMODE,D3DCULL_CCW);
}else{
if( Selected()&&m_Box.is_valid() ){
Device.SetShader (Device.m_SelectionShader);
RCache.set_xform_world (_Transform());
u32 clr = Locked()?0xFFFF0000:0xFFFFFFFF;
Device.SetShader (Device.m_WireShader);
DU.DrawSelectionBox (m_Box,&clr);
}
}
}
}
void CEditShape::OnFrame()
{
inherited::OnFrame();
}
void CEditShape::OnShowHint(AStringVec& dest)
{
}
| 26.292011 | 121 | 0.538977 | MlssingTexture |
0fb271150037c157633a72bd0ce5156b7569951d | 3,387 | cpp | C++ | lib/Runtime/Base/LeaveScriptObject.cpp | Taritsyn/ChakraCore | b6042191545a823fcf9d53df2b09d160d5808f51 | [
"MIT"
] | 8,664 | 2016-01-13T17:33:19.000Z | 2019-05-06T19:55:36.000Z | lib/Runtime/Base/LeaveScriptObject.cpp | Taritsyn/ChakraCore | b6042191545a823fcf9d53df2b09d160d5808f51 | [
"MIT"
] | 5,058 | 2016-01-13T17:57:02.000Z | 2019-05-04T15:41:54.000Z | lib/Runtime/Base/LeaveScriptObject.cpp | Taritsyn/ChakraCore | b6042191545a823fcf9d53df2b09d160d5808f51 | [
"MIT"
] | 1,367 | 2016-01-13T17:54:57.000Z | 2019-04-29T18:16:27.000Z | //-------------------------------------------------------------------------------------------------------
// Copyright (C) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
//-------------------------------------------------------------------------------------------------------
#include "RuntimeBasePch.h"
namespace Js
{
EnterScriptObject::EnterScriptObject(ScriptContext* scriptContext, ScriptEntryExitRecord* entryExitRecord,
void * returnAddress, void * addrOfReturnAddress, bool doCleanup, bool isCallRoot, bool hasCaller)
{
Assert(scriptContext);
#ifdef PROFILE_EXEC
scriptContext->ProfileBegin(Js::RunPhase);
#endif
if (scriptContext->GetThreadContext() &&
scriptContext->GetThreadContext()->IsNoScriptScope())
{
FromDOM_NoScriptScope_unrecoverable_error();
}
// Keep a copy locally so the optimizer can just copy prop it to the dtor
this->scriptContext = scriptContext;
this->entryExitRecord = entryExitRecord;
this->doCleanup = doCleanup;
this->isCallRoot = isCallRoot;
this->hr = NOERROR;
this->hasForcedEnter =
#ifdef ENABLE_SCRIPT_DEBUGGING
scriptContext->GetDebugContext() != nullptr ?
scriptContext->GetDebugContext()->GetProbeContainer()->isForcedToEnterScriptStart :
#endif
false;
// Initialize the entry exit record
entryExitRecord->returnAddrOfScriptEntryFunction = returnAddress;
entryExitRecord->addrOfReturnAddrOfScriptEntryFunction = addrOfReturnAddress;
entryExitRecord->hasCaller = hasCaller;
entryExitRecord->scriptContext = scriptContext;
#ifdef EXCEPTION_CHECK
entryExitRecord->handledExceptionType = ExceptionCheck::ClearHandledExceptionType();
#endif
#if DBG_DUMP
entryExitRecord->isCallRoot = isCallRoot;
#endif
if (!scriptContext->IsClosed())
{
library = scriptContext->GetLibrary();
}
try
{
AUTO_NESTED_HANDLED_EXCEPTION_TYPE(ExceptionType_OutOfMemory);
scriptContext->GetThreadContext()->PushHostScriptContext(scriptContext->GetHostScriptContext());
}
catch (Js::OutOfMemoryException)
{
this->hr = E_OUTOFMEMORY;
}
BEGIN_NO_EXCEPTION
{
// We can not have any exception in the constructor, otherwise the destructor will
// not run and we might be in an inconsistent state
// Put any code that may raise an exception in OnScriptStart
scriptContext->GetThreadContext()->EnterScriptStart(entryExitRecord, doCleanup);
}
END_NO_EXCEPTION
}
void EnterScriptObject::VerifyEnterScript()
{
if (FAILED(hr))
{
Assert(hr == E_OUTOFMEMORY);
throw Js::OutOfMemoryException();
}
}
EnterScriptObject::~EnterScriptObject()
{
scriptContext->OnScriptEnd(isCallRoot, hasForcedEnter);
if (SUCCEEDED(hr))
{
scriptContext->GetThreadContext()->PopHostScriptContext();
}
scriptContext->GetThreadContext()->EnterScriptEnd(entryExitRecord, doCleanup);
#ifdef PROFILE_EXEC
scriptContext->ProfileEnd(Js::RunPhase);
#endif
}
};
| 36.031915 | 110 | 0.621494 | Taritsyn |
0fb39d8862baeda7c568b8029e112bf159f96684 | 978 | cpp | C++ | 10487/src.cpp | sabingoyek/uva-online-judge | 78be271d440ff3b9b1b038fb83343ba46ea60843 | [
"MIT"
] | null | null | null | 10487/src.cpp | sabingoyek/uva-online-judge | 78be271d440ff3b9b1b038fb83343ba46ea60843 | [
"MIT"
] | null | null | null | 10487/src.cpp | sabingoyek/uva-online-judge | 78be271d440ff3b9b1b038fb83343ba46ea60843 | [
"MIT"
] | null | null | null | #include <bits/stdc++.h>
using namespace std;
int main() {
// your code goes here
int n, test_case = 0;
while(true){
scanf("%d", &n);
if(n == 0){
break;
} else{
test_case++;
vector<int> numbers;
int tmp, m;
for(int i = 0; i < n; i++){
scanf("%d", &tmp);
numbers.push_back(tmp);
}
/*for(int i = 0; i < n; i++)
printf("%d ", numbers[i]);
printf("\n");*/
vector<int>sum;
for(int i = 0; i < n; i++){
for(int j = i+1; j < n; j++){
sum.push_back(numbers[i] + numbers[j]);
}
}
/*
for(int i = 0; i < sum.size(); i++)
printf("%d ", sum[i]);
printf("\n");*/
scanf("%d", &m);
int q;
printf("Case %d:\n", test_case);
for(int i = 0; i < m; i++){
scanf("%d", &q);
int ans = sum[0];
for(int i = 1; i < sum.size(); i++){
if(abs(sum[i] - q) < abs(ans - q)){
ans = sum[i];
}
}
printf("Closest sum to %d is %d.\n", q, ans);
}
}
}
return 0;
}
| 16.862069 | 49 | 0.445808 | sabingoyek |
0fb7dba0d35ba3341831e928733118eeeb60c1bb | 1,040 | cpp | C++ | p1130.cpp | ThinkiNOriginal/PTA-Advanced | 55cae28f76102964d0f6fd728dd62d6eba980c49 | [
"MIT"
] | null | null | null | p1130.cpp | ThinkiNOriginal/PTA-Advanced | 55cae28f76102964d0f6fd728dd62d6eba980c49 | [
"MIT"
] | null | null | null | p1130.cpp | ThinkiNOriginal/PTA-Advanced | 55cae28f76102964d0f6fd728dd62d6eba980c49 | [
"MIT"
] | null | null | null | #include <string>
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>
using namespace std;
struct Node {
string val;
Node* left;
Node* right;
};
string infix(Node* tree) {
static string res;
if (tree) {
if (tree -> left or tree -> right)
res += '(';
infix(tree -> left);
res += tree -> val;
infix(tree -> right);
if (tree -> right or tree -> left)
res += ')';
}
return res;
}
int main() {
int N;
scanf("%d", &N);
vector<Node> tree(N + 1);
vector<bool> root(N + 1, true);
for (int i = 1; i <= N; i++) {
string val;
int l, r;
cin >> val >> l >> r;
tree[i].val = val;
if (l != -1) {
tree[i].left = &tree[l];
root[l] = false;
}
if (r != -1) {
tree[i].right = &tree[r];
root[r]= false;
}
}
int rootP = -1;
for (int i = 1; i <= N; i++) {
if (root[i]) {
rootP = i;
break;
}
}
auto res = infix(&tree[rootP]);
int len = res.size();
if (res[0] == '(') {
res.erase(len - 1, 1);
res.erase(0, 1);
}
cout << res << endl;
return 0;
}
| 14.246575 | 36 | 0.511538 | ThinkiNOriginal |
0fbd172e36f976bebca2e21cc1e1dea9caf32a7e | 1,442 | cpp | C++ | ext/stub/javax/imageio/ImageIO_ContainsFilter-stub.cpp | pebble2015/cpoi | 6dcc0c5e13e3e722b4ef9fd0baffbf62bf71ead6 | [
"Apache-2.0"
] | null | null | null | ext/stub/javax/imageio/ImageIO_ContainsFilter-stub.cpp | pebble2015/cpoi | 6dcc0c5e13e3e722b4ef9fd0baffbf62bf71ead6 | [
"Apache-2.0"
] | null | null | null | ext/stub/javax/imageio/ImageIO_ContainsFilter-stub.cpp | pebble2015/cpoi | 6dcc0c5e13e3e722b4ef9fd0baffbf62bf71ead6 | [
"Apache-2.0"
] | null | null | null | // Generated from /Library/Java/JavaVirtualMachines/jdk1.8.0_144.jdk/Contents/Home/jre/lib/rt.jar
#include <javax/imageio/ImageIO_ContainsFilter.hpp>
extern void unimplemented_(const char16_t* name);
javax::imageio::ImageIO_ContainsFilter::ImageIO_ContainsFilter(const ::default_init_tag&)
: super(*static_cast< ::default_init_tag* >(0))
{
clinit();
}
javax::imageio::ImageIO_ContainsFilter::ImageIO_ContainsFilter(::java::lang::reflect::Method* method, ::java::lang::String* name)
: ImageIO_ContainsFilter(*static_cast< ::default_init_tag* >(0))
{
ctor(method, name);
}
void ::javax::imageio::ImageIO_ContainsFilter::ctor(::java::lang::reflect::Method* method, ::java::lang::String* name)
{ /* stub */
/* super::ctor(); */
unimplemented_(u"void ::javax::imageio::ImageIO_ContainsFilter::ctor(::java::lang::reflect::Method* method, ::java::lang::String* name)");
}
bool javax::imageio::ImageIO_ContainsFilter::filter(::java::lang::Object* elt)
{ /* stub */
unimplemented_(u"bool javax::imageio::ImageIO_ContainsFilter::filter(::java::lang::Object* elt)");
return 0;
}
extern java::lang::Class *class_(const char16_t *c, int n);
java::lang::Class* javax::imageio::ImageIO_ContainsFilter::class_()
{
static ::java::lang::Class* c = ::class_(u"javax.imageio.ImageIO.ContainsFilter", 36);
return c;
}
java::lang::Class* javax::imageio::ImageIO_ContainsFilter::getClass0()
{
return class_();
}
| 33.534884 | 142 | 0.712899 | pebble2015 |
0fbd343c82f39328aa0cfe80a3dc9f33d6327680 | 10,276 | hpp | C++ | include/nodamushi/svd/normalized/Register.hpp | nodamushi/nsvd-reader | cf3a840aaac78d5791df1cf045596ec20dc03257 | [
"CC0-1.0"
] | null | null | null | include/nodamushi/svd/normalized/Register.hpp | nodamushi/nsvd-reader | cf3a840aaac78d5791df1cf045596ec20dc03257 | [
"CC0-1.0"
] | null | null | null | include/nodamushi/svd/normalized/Register.hpp | nodamushi/nsvd-reader | cf3a840aaac78d5791df1cf045596ec20dc03257 | [
"CC0-1.0"
] | null | null | null | /*!
@brief normalized register
@file nodamushi/svd/normalized/Register.hpp
*/
/*
* These codes are licensed under CC0.
* http://creativecommons.org/publicdomain/zero/1.0/
*/
#ifndef NODAMUSHI_SVD_NORMALIZED_REGISTER_HPP
#define NODAMUSHI_SVD_NORMALIZED_REGISTER_HPP
# include <sstream>
# include "nodamushi/svd/normalized/node_container.hpp"
# include "nodamushi/svd/normalized/WriteConstraint.hpp"
namespace nodamushi{
namespace svd{
namespace normalized{
/*
* Normalized register class.
* if STRREF is string_view or something like it,
* the reference source of string is the value of nodamushi::svd::Register instance member.
*
* @see http://www.keil.com/pack/doc/CMSIS/SVD/html/elem_registers.html#elem_register
*/
template<typename STRREF>struct Register
{
using Field = ::nodamushi::svd::normalized::Field<STRREF>;
using Cluster= ::nodamushi::svd::normalized::Cluster<STRREF>;
using Peripheral= ::nodamushi::svd::normalized::Peripheral<STRREF>;
using this_t = Register<STRREF>;
using p_ptr = parent_ptr<Peripheral>;
using p2_ptr = parent_ptr<Cluster>;
private:
p_ptr parent; //!< perihperal parent pointer
p2_ptr parent2; //!< cluster parent pointer
public:
//! @brief derivedFrom attribute
path<STRREF> derivedFrom;
/**
* @brief <name> of this register without peripheral.prependToName and peripheral.appendToName
* @see get_name_with_appendix()
*/
std::string name;
//! @brief <displayName>
std::string displayName;
//! @brief dimemsion information object.
dim_info dim;
//! @brief <description>
STRREF description;
//! @brief <alternateGroup>
STRREF alternateGroup;
//! @brief <alternateRegister>
STRREF alternateRegister;
/**
@brief <addressOffset>
@par
If you nead an absolute address, call the get_address() method.
If you nead a relative address from the baseAddress of peripheral,call the get_address_offset() method.
@see get_address()
@see get_address_offset()
*/
uint64_t addressOffset;
/**
@brief <size>
@see get_size()
*/
nullable<uint32_t> size;
/**
@brief <access>
@see get_access()
*/
nullable<Access> access;
/**
@brief <protection>
@see get_protection()
*/
nullable<Protection> protection;
/**
@brief <resetValue>
@see get_resetValue()
*/
nullable<uint64_t> resetValue;
/**
@brief <resetMask>
@see get_resetMask()
*/
nullable<uint64_t> resetMask;
/**
@brief <dataType>
@see get_dataType()
*/
nullable<DataType> dataType;
//! @brief <modifiedWriteValues>
ModifiedWriteValues modifiedWriteValues;
//! @brief <readAction>
ReadAction readAction;
//! @brief <writeConstraint>
WriteConstraint writeConstraint;
/*!
@brief <field> elements list. This list is sorted by lsb of field.
Field class does not prohibit copying,
but basically it should be treated with a reference.
@code
auto& f = reg.fields[x];
@endcode
*/
list<Field> fields;
//-----------------------------------------------------------
/**
* @brief get name with peripheral.prependToName and peripheral.appendToName
*/
std::string get_name_with_appendix()const noexcept{
auto p = get_peripheral();
if(p && p->has_register_name_appendix()){
std::stringstream s;
if(! p->prependToName.empty())
s << p->prependToName;
if(p->appendToName.empty())
s << name;
else{
bool arr=dim.is_array() && name.length() > 3;
if(arr){
size_t l = name.length()-3;
while(l != 1){
if(name[l] == '[')break;
l--;
}
if(name[l] == '['){
s.write(name.data(),l);
}else{
s << name;
arr = false;
}
}else
s << name;
s << p->appendToName;
if(arr)
s <<'['<<dim.index << ']';
}
return s.str();
}
return name;
}
/**
@brief get parent cluster pointer
@return parent peripheral pointer or nullptr.
@see get_parent2()
*/
node_ptr<Peripheral> get_parent() noexcept{return parent.lock();}
//! @return parent peripheral pointer or nullptr.
node_ptr<Peripheral const> get_parent()const noexcept{return parent.lock();}
/**
@brief get parent cluster pointer
@return parent cluster pointer or nullptr.
@see get_parent()
*/
node_ptr<Cluster> get_parent2() noexcept{return parent2.lock();}
//! @brief parent cluster pointer or nullptr.
node_ptr<Cluster const> get_parent2()const noexcept{return parent2.lock();}
//! @brief find the Peripheral to which this register belongs.
node_ptr<Peripheral const> get_peripheral()const noexcept{return find_parent_peripheral(*this);}
//! @brief find the Peripheral to which this register belongs.
node_ptr<Peripheral> get_peripheral()noexcept{return find_parent_peripheral(*this);}
//! @brief calculate an absolute address
uint64_t get_address()const{ return calc_address(*this);}
//! @brief a relative address from the baseAddress of the peripheral
uint64_t get_address_offset()const{ return calc_offset(*this);}
//! @brief get path
::nodamushi::svd::path<> get_path()const
{
::nodamushi::svd::path<> p;
path_helper(*this,p);
return p;
}
/**
@brief resolve the dataType.
The default type is determined by the size.(size=8 : uint8_t,size=32: uint32_t)
*/
DataType get_dataType()const{
return dataType.get<this_t,get_default_dataType<this_t>>(this);
}
//! @brief resolve the value of size and return it.
uint32_t get_size()const{
return size.get<this_t,get_default_size<this_t>>(this);
}
//! @brief resolve the value of resetValue and return it.
uint64_t get_resetValue()const{
return resetValue.get<this_t,get_default_resetValue<this_t>>(this);
}
//! @brief resolve the value of resetMask and return it.
uint64_t get_resetMask()const{
return resetMask.get<this_t,get_default_resetMask<this_t>>(this);
}
//! @brief resolve the value of access and return it.
Access get_access()const{
return access.get<this_t,get_default_access<this_t>>(this);
}
//! @brief resolve the value of protection and return it.
Protection get_protection()const{
return protection.get<this_t,get_default_protection<this_t>>(this);
}
//! @brief resolve the value of modifiedWriteValues and return it.
ModifiedWriteValues get_modifiedWriteValues()const{return modifiedWriteValues;}
ReadAction get_readAction()const{return readAction;}
//-------------------------------------------
/**
* @brief find path element
* @param p path
* @param pindex the first index of serach path. default is 0.
* @return element pointer
*/
template<typename STR>
node_ptr<void> find(const ::nodamushi::svd::path<STR>& p,size_t pindex=0)
{
const size_t ps = p.size();
if(ps > pindex){
string_ref n = p[pindex];
if(auto c = __find_helper(fields,n)){
if(ps == pindex + 1)return c;
else return c->find(p,pindex+1);
}
}
return {};
}
/**
* @brief find field element
* @param p path
* @param pindex the first index of serach path. default is 0.
* @return element pointer
*/
template<typename STR>
node_ptr<Field> find_field(::nodamushi::svd::path<STR>& p,size_t pindex=0)
{
const size_t ps = p.size();
if(ps == pindex+1){
string_ref n = p[pindex];
return __find_helper(fields,n);
}
return {};
}
//-------------------------------------------
template<typename T>
Register(const T& n)://don't change name
parent(),
parent2(),
derivedFrom(),
name(n.name),
displayName(make_dim_displayName_helper(n.svd)(n.dim.index)),
dim(n.dim),
__NORMALIZED_DERIVED_FROM(description),
__NORMALIZED_DERIVED_FROM(alternateGroup),
__NORMALIZED_DERIVED_FROM(alternateRegister),
__NORMALIZED_DERIVED_FROM(addressOffset),
__NORMALIZED_DERIVED_FROM(size),
__NORMALIZED_DERIVED_FROM(access),
__NORMALIZED_DERIVED_FROM(protection),
__NORMALIZED_DERIVED_FROM(resetValue),
__NORMALIZED_DERIVED_FROM(resetMask),
__NORMALIZED_DERIVED_FROM(dataType),
__NORMALIZED_DERIVED_FROM(modifiedWriteValues),
__NORMALIZED_DERIVED_FROM(readAction),
__NORMALIZED_DERIVED_FROM_MEMBER(writeConstraint),
fields(n.fields.size())
{
if(n.svd.derivedFrom)
derivedFrom = n.svd.derivedFrom.get();
// add dim offset
if(n.dim && n.dim.index!=0){
__NORMALIZED_DERIVED_FROM_HELPER(dimIncrement);
size_t inc = 1;
if(dimIncrement)
inc = *dimIncrement;
addressOffset += inc * n.dim.index;
}
for(const auto& f:n.fields)
fields.emplace_back(f);
// sort by lsb
fields.sort([](const Field& a,const Field& b)->bool
{return a.lsb() < b.lsb();});
}
void update_parent(p_ptr& new_parent,node_ptr<this_t>& me)
{
parent = new_parent;
parent2= {};
update_parent_of_children(fields,me);
}
void update_parent(p2_ptr& new_parent,node_ptr<this_t>& me)
{
parent2= new_parent;
parent = {};
update_parent_of_children(fields,me);
}
/**
* @brief sort field by lsb, and call Field.sort
*/
void sort()
{
std::sort(fields.ptr_begin(),fields.ptr_end(),
[](auto x,auto y){
const auto lsbx = x->lsb();
const auto lsby = y->lsb();
return lsbx < lsby;
});
for(auto& f:fields)
f.sort();
}
};
//---------- Visitor --------------------
__NX_NORM_HANDLE_VISIT(Register)
{
namespace nv = ::nodamushi::visitor;
using r = nv::result;
r ret;
// visit register / cluster
ret = CONTROLLER::apply(t.fields,v);
if(ret == r::BREAK)return ret;
if(ret == r::SKIP)return r::CONTINUE;
return r::CONTINUE;
}};
//--------------------------------------------
}}} // end namespace svd
#endif // NODAMUSHI_SVD_NORMALIZED_REGISTER_HPP
| 29.613833 | 107 | 0.635072 | nodamushi |
0fc0a177cad09bce23bf64f9ef768e147b5e5d42 | 1,909 | cpp | C++ | ndk-basic/src/main/cpp/sample-lib.cpp | syusikoku/NDKDemo | 92322273b16366ae30e0c239df6bfaaf2a6ab958 | [
"W3C",
"OLDAP-2.3"
] | null | null | null | ndk-basic/src/main/cpp/sample-lib.cpp | syusikoku/NDKDemo | 92322273b16366ae30e0c239df6bfaaf2a6ab958 | [
"W3C",
"OLDAP-2.3"
] | null | null | null | ndk-basic/src/main/cpp/sample-lib.cpp | syusikoku/NDKDemo | 92322273b16366ae30e0c239df6bfaaf2a6ab958 | [
"W3C",
"OLDAP-2.3"
] | null | null | null | #include <jni.h>
#include <string>
#include <android/log.h>
#include <sys/inotify.h>
#define LOG_TAG "zy"
#include <unistd.h>
#include <malloc.h>
#define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG, LOG_TAG, __VA_ARGS__)
#define LOGF(...) __android_log_print(ANDROID_LOG_DEBUG, LOG_TAG, __VA_ARGS__)
extern "C"
JNIEXPORT jint JNICALL
Java_com_example_nd_JNI_plus(JNIEnv *env, jobject obj, jint a, jint b) {
LOGD(LOG_TAG, "call Java_com_example_nd_JNI_plus");
return a + b;
}
extern "C"
JNIEXPORT void JNICALL
Java_com_example_nd_JNI_callUnInstallListener(JNIEnv *env, jobject obj, jint versionSdk,
jstring path) {
/*
fork()子进程
创建监听文件
初始化inotify实例
注册监听事件
调用read函数开始监听
卸载反馈统计
*/
LOGD("------------------------");
LOGF("------------------------");
const char *path_str = env->GetStringUTFChars(path, 0);
pid_t pid = fork();
if (pid < 0) {
LOGD("克隆失败");
} else if (pid > 0) {
LOGD("父进程");
} else {
LOGD("子进程!");
//*******************在这里进程操作*****************
LOGD("你好,终端研发部");
int fuileDescript = inotify_init();
int watch = inotify_add_watch(fuileDescript, path_str, IN_DELETE_SELF);
void *p = malloc(sizeof(struct inotify_event));
read(fuileDescript, p, sizeof(struct inotify_event));
inotify_rm_watch(fuileDescript, watch);
LOGD(LOG_TAG, "接下来进行操作,来条状网页!!!");
if (versionSdk < 17) {
//am start -a android.intent.action.VIEW -d
execlp("am", "am", "start", "-a", "android.intent.action.VIEW", "-d",
"https://github.com/syusikoku", NULL);
} else {
execlp("am", "am", "start", "--user", "0", "-a", "android.intent.action.VIEW", "-d",
"https://github.com/syusikoku", NULL);
}
}
env->ReleaseStringUTFChars(path, path_str);
} | 31.295082 | 96 | 0.577266 | syusikoku |
0fc143ee7694b39857b3bc1e985a6c3a7ad0177e | 48,745 | cpp | C++ | src/rpggame/rpgio.cpp | Hirato/lamiae | c8a94794035d313420ea56b2bf9dd603fe06f520 | [
"Zlib"
] | 68 | 2015-01-26T14:03:42.000Z | 2022-02-28T06:08:24.000Z | src/rpggame/rpgio.cpp | Hirato/lamiae | c8a94794035d313420ea56b2bf9dd603fe06f520 | [
"Zlib"
] | 13 | 2015-01-09T21:57:27.000Z | 2022-02-20T11:25:39.000Z | src/rpggame/rpgio.cpp | Hirato/lamiae | c8a94794035d313420ea56b2bf9dd603fe06f520 | [
"Zlib"
] | 18 | 2015-01-08T14:15:21.000Z | 2021-12-27T16:14:07.000Z | #include "rpggame.h"
extern bool reloadtexture(const char *name); //texture.cpp
namespace rpgio
{
#define SAVE_VERSION 49
#define COMPAT_VERSION 49
#define SAVE_MAGIC "RPGS"
/**
SAVING STUFF
STRINGS - use writestring(stream *, char *)
HASHES - see strings
VECTORS - write an int corresponding to the number of elements, then write the elements
POINTERS - convert to reference, if this is not possible don't save it
VEC - use writevec macro, you need to write all 3 coordinates independantly
LOADING STUFF
STRINGS - use readstring(stream *)
HASHES - use READHASH macros and if needed, NOTNULL and VERIFYHASH macros
VECTORS - read the next int, and use that as the basis of knowing how many elements to load
POINTERS - read the reference and convert it back to a pointer of the intended object. If this can't be done reliably don't save it
VEC - use readvec macro, you need to read all 3 coordinates independantly
REMINDERS
HOW MANY - don't forget to indicate how many times you need to repeat the loop; there should be a amcro that helps with this
ORDER - you must read and write items in the same order
LITTLE ENDIAN - pullil add getlil for single values and lilswap for arrays and objects are going to be your bestest friends
POINTERS - they change each run, remember that, for convention, use -1 for players
ARGUMENTS - as a argument to a function, ORDER IS NOT RESPECTED, use with extreme care
TIME - the difference of lastmillis is taken and applied on save and load - use countdown timers instead if possible.
ORDER
they are to coincide with the order of the item structs, and before the map functions, the order in which crap is stored there
*/
#define readvec(v) \
v.x = f->getlil<float>(); \
v.y = f->getlil<float>(); \
v.z = f->getlil<float>(); \
if(DEBUG_IO) \
DEBUGF("Read vec (%f, %f, %f) from file", v.x, v.y, v.z);
#define writevec(v) \
f->putlil(v.x); \
f->putlil(v.y); \
f->putlil(v.z); \
if(DEBUG_IO) \
DEBUGF("Wrote vec (%f, %f, %f) to file", v.x, v.y, v.z);
#define CHECKEOF(f, val) \
if((f).end()) \
{ \
abort = true; \
ERRORF("Unexpected EoF at " __FILE__ ":%i; aborting - You should report this.", __LINE__); \
return val; \
}
#define NOTNULL(f, val) \
if(!f) \
{ \
abort = true; \
ERRORF("Encountered unexpected NULL value for " #f " at " __FILE__ ":%i; aborting.", __LINE__); \
return val; \
}
#define READHASH(val) \
do { \
const char *_str = readstring(f); \
if(_str) val = game::queryhashpool(_str); \
else val = NULL; \
delete[] _str; \
} while(0);
#define READHASHEXTENDED(val, ht) \
do { \
const char *_str = readstring(f); \
if(_str) val = ht.access(_str); \
else val = NULL; \
delete[] _str; \
} while(0);
struct saveheader
{
char magic[4];
int sversion; //save
int gversion; //game
};
bool abort = false;
mapinfo *lastmap = NULL;
rpgent *entfromnum(int num)
{
if(num == -2)
return NULL;
if(num == -1)
return game::player1;
else if(num >= lastmap->objs.length())
{
WARNINGF("invalid entity num (%i), possible corruption", num);
return NULL;
}
return lastmap->objs[num];
}
int enttonum(rpgent *ent)
{
if(ent == NULL)
return -2;
if(ent == game::player1)
return -1;
int i = lastmap->objs.find(game::player1);
if(i != -1)
{
int num = lastmap->objs.find(ent);
if(num > i)
num--;
return num;
}
else
return lastmap->objs.find(ent);
}
struct reference
{
int ind;
mapinfo *map;
rpgent *&ref;
reference(int i, mapinfo *m, rpgent *&r) : ind(i), map(m), ref(r) {}
~reference() {}
};
vector<reference> updates;
const char *readstring(stream *f)
{
int len = f->getlil<int>();
char *s = NULL;
if(len)
{
int fsize = f->size() - f->tell();
if(len < 0 || len > fsize)
{
ERRORF("Cannot read %i characters from file, there are %i bytes remaining, aborting", len, fsize);
abort = true;
return NULL;
}
s = new char[len];
f->read(s, len);
if(DEBUG_IO)
DEBUGF("Read \"%s\" from file (%i)", s, len);
}
return s;
}
void writestring(stream *f, const char *s)
{
int len = s ? strlen(s) + 1 : 0;
f->putlil(len);
if(!len) return;
f->write(s, len);
if(DEBUG_IO)
DEBUGF("Wrote \"%s\" to file (%i)", s, len);
}
void readfaction(stream *f, faction *fact)
{
int num = f->getlil<int>();
if(DEBUG_IO)
DEBUGF("reading %i relations", num);
loopi(num)
{
CHECKEOF(*f, )
const char *fac = readstring(f);
int val = f->getlil<short>();
if(fact && game::factions.access(fac))
fact->setrelation(game::queryhashpool(fac), val);
else
WARNINGF("Faction %s does not exist, ignoring relation of %i", fac, val);
delete[] fac;
}
}
void writefaction(stream *f, faction *fact)
{
f->putlil(fact->relations.length());
if(DEBUG_IO)
DEBUGF("saving %i relations", fact->relations.length());
enumeratekt(fact->relations, const char *, fac, short, relation,
if(DEBUG_IO)
DEBUGF("writing: factions[%s]->relations[%s] (%i)", fact->key, fac, relation);
writestring(f, fac);
f->putlil(relation);
)
}
void readrecipe(stream *f, recipe *rec)
{
int flags = f->getlil<int>();
if(rec) rec->flags |= flags;
}
void writerecipe(stream *f, recipe *rec)
{
f->putlil( rec->flags & recipe::SAVE);
}
void readmerchant(stream *f, merchant *mer)
{
int credit = f->getlil<int>();
if(mer) mer->credit = credit;
}
void writemerchant(stream *f, merchant *mer)
{
f->putlil(mer->credit);
}
item *readitem(stream *f, item *it = NULL)
{
if(!it) it = new item();
delete[] it->name;
delete[] it->icon;
delete[] it->description;
delete[] it->mdl;
it->name = readstring(f);
it->icon = readstring(f);
it->description = readstring(f);
it->mdl = readstring(f);
NOTNULL(it->mdl, it);
preloadmodel(it->mdl);
READHASHEXTENDED(it->script, game::scripts);
READHASH(it->base);
NOTNULL(it->script, it)
NOTNULL(it->base, it);
readvec(it->colour)
it->quantity = f->getlil<int>();
it->category = f->getlil<int>();
it->flags = f->getlil<int>();
it->value = f->getlil<int>();
it->maxdurability = f->getlil<int>();
it->charges = f->getlil<int>();
it->scale = f->getlil<float>();
it->weight = f->getlil<float>();
it->durability = f->getlil<float>();
it->recovery = f->getlil<float>();
rpgscript::keeplocal((it->locals = f->getlil<int>()));
int uses = f->getlil<int>();
loopi(uses)
{
CHECKEOF(*f,it)
int type = f->getlil<int>();
use *u = NULL;
switch(type)
{
case USE_WEAPON:
{
if(!u) u = it->uses.add(new use_weapon(NULL));
use_weapon *wp = (use_weapon *) u;
READHASHEXTENDED(wp->projeffect, game::effects)
READHASHEXTENDED(wp->traileffect, game::effects)
READHASHEXTENDED(wp->deatheffect, game::effects)
READHASHEXTENDED(wp->ammo, game::ammotypes)
NOTNULL(wp->ammo, it);
wp->range = f->getlil<int>();
wp->angle = f->getlil<int>();
wp->lifetime = f->getlil<int>();
wp->gravity = f->getlil<int>();
wp->cost = f->getlil<int>();
wp->pflags = f->getlil<int>();
wp->target = f->getlil<int>();
wp->radius = f->getlil<int>();
wp->kickback = f->getlil<int>();
wp->recoil = f->getlil<int>();
wp->charge = f->getlil<int>();
wp->basecharge = f->getlil<float>();
wp->mincharge = f->getlil<float>();
wp->maxcharge = f->getlil<float>();
wp->elasticity = f->getlil<float>();
wp->speed = f->getlil<float>();
}
[[fallthrough]];
case USE_ARMOUR:
{
if(!u) u = it->uses.add(new use_armour(NULL));
use_armour *ar = (use_armour *) u;
delete[] ar->vwepmdl;
delete[] ar->hudmdl;
ar->vwepmdl = readstring(f);
ar->hudmdl = readstring(f);
if(ar->vwepmdl) preloadmodel(ar->vwepmdl);
if(ar->hudmdl) preloadmodel(ar->hudmdl);
READHASHEXTENDED(ar->idlefx, game::effects);
ar->slots = f->getlil<int>();
ar->skill = f->getlil<int>();
loopj(STAT_MAX) ar->reqs.attrs[j] = f->getlil<short>();
loopj(SKILL_MAX) ar->reqs.skills[j] = f->getlil<short>();
}
[[fallthrough]];
case USE_CONSUME:
{
if(!u) u = it->uses.add(new use(NULL));
delete[] u->name;
delete[] u->description;
delete[] u->icon;
u->name = readstring(f);
u->description = readstring(f);
u->icon = readstring(f);
READHASHEXTENDED(u->script, game::scripts);
NOTNULL(u->script, it);
u->cooldown = f->getlil<int>();
u->chargeflags = f->getlil<int>();
int efx = f->getlil<int>();
loopj(efx)
{
CHECKEOF(*f, it)
statusgroup *status = NULL;
READHASHEXTENDED(status, game::statuses);
NOTNULL(status, it);
int e = f->getlil<int>();
float m = f->getlil<float>();
u->effects.add(new inflict(status, e, m));
}
break;
}
}
}
return it;
}
void writeitem(stream *f, item *it)
{
writestring(f, it->name);
writestring(f, it->icon);
writestring(f, it->description);
writestring(f, it->mdl);
writestring(f, it->script->key);
writestring(f, it->base);
writevec(it->colour)
f->putlil(it->quantity);
f->putlil(it->category);
f->putlil(it->flags);
f->putlil(it->value);
f->putlil(it->maxdurability);
f->putlil(it->charges);
f->putlil(it->scale);
f->putlil(it->weight);
f->putlil(it->durability);
f->putlil(it->recovery);
f->putlil(it->locals);
f->putlil(it->uses.length());
loopv(it->uses)
{
f->putlil(it->uses[i]->type);
switch(it->uses[i]->type)
{
case USE_WEAPON:
{
use_weapon *wp = (use_weapon *) it->uses[i];
writestring(f, wp->projeffect ? wp->projeffect->key : NULL);
writestring(f, wp->traileffect ? wp->traileffect->key : NULL);
writestring(f, wp->deatheffect ? wp->deatheffect->key : NULL);
writestring(f, wp->ammo->key);
f->putlil(wp->range);
f->putlil(wp->angle);
f->putlil(wp->lifetime);
f->putlil(wp->gravity);
f->putlil(wp->cost);
f->putlil(wp->pflags);
f->putlil(wp->target);
f->putlil(wp->radius);
f->putlil(wp->kickback);
f->putlil(wp->recoil);
f->putlil(wp->charge);
f->putlil(wp->basecharge);
f->putlil(wp->mincharge);
f->putlil(wp->maxcharge);
f->putlil(wp->elasticity);
f->putlil(wp->speed);
}
[[fallthrough]];
case USE_ARMOUR:
{
use_armour *ar = (use_armour *) it->uses[i];
writestring(f, ar->vwepmdl);
writestring(f, ar->hudmdl);
writestring(f, ar->idlefx ? ar->idlefx->key : NULL);
f->putlil(ar->slots);
f->putlil(ar->skill);
loopj(STAT_MAX) f->putlil<short>(ar->reqs.attrs[j]);
loopj(SKILL_MAX) f->putlil<short>(ar->reqs.skills[j]);
}
[[fallthrough]];
case USE_CONSUME:
{
use *u = it->uses[i];
writestring(f, u->name);
writestring(f, u->description);
writestring(f, u->icon);
writestring(f, u->script->key);
f->putlil(u->cooldown);
f->putlil(u->chargeflags);
f->putlil(u->effects.length());
loopvj(u->effects)
{
writestring(f, u->effects[j]->status->key);
f->putlil(u->effects[j]->element);
f->putlil(u->effects[j]->mul);
}
break;
}
}
}
}
vector<rpgchar *> characters;
rpgent *readent(stream *f, rpgent *ent = NULL)
{
int type = f->getlil<int>();
if(ent)
type = ent->type();
switch(type)
{
case ENT_CHAR:
{
if(!ent) ent = new rpgchar();
rpgchar *loading = (rpgchar *) ent;
characters.add(loading);
delete[] loading->name;
delete[] loading->mdl;
delete[] loading->portrait;
loading->name = readstring(f);
loading->mdl = readstring(f);
loading->portrait = readstring(f);
readvec(loading->colour);
NOTNULL(loading->mdl, ent);
preloadmodel(loading->mdl);
#define x(var, type) loading->base.var = f->getlil<type>();
loopi(STAT_MAX) x(baseattrs[i], short)
loopi(SKILL_MAX) x(baseskills[i], short)
loopi(STAT_MAX) x(deltaattrs[i], short)
loopi(SKILL_MAX) x(deltaskills[i], short)
loopi(ATTACK_MAX) x(bonusthresh[i], short)
loopi(ATTACK_MAX) x(bonusresist[i], short)
x(bonushealth, int)
x(bonusmana, int)
x(bonusmovespeed, int)
x(bonusjumpvel, int)
x(bonuscarry, int)
x(bonuscrit, int)
x(bonushregen, float)
x(bonusmregen, float)
loopi(ATTACK_MAX) x(deltathresh[i], short)
loopi(ATTACK_MAX) x(deltaresist[i], short)
x(deltahealth, int)
x(deltamana, int)
x(deltamovespeed, int)
x(deltajumpvel, int)
x(deltacarry, int)
x(deltacrit, int)
x(deltahregen, float)
x(deltamregen, float)
#undef x
READHASHEXTENDED(loading->script, game::scripts)
READHASHEXTENDED(loading->faction, game::factions)
READHASHEXTENDED(loading->merchant, game::merchants)
NOTNULL(loading->script, ent)
NOTNULL(loading->faction, ent)
if(loading->merchant) NOTNULL(loading->merchant, ent)
loading->health = f->getlil<float>();
loading->mana = f->getlil<float>();
loading->scale = f->getlil<float>();
loading->lastaction = f->getlil<int>() + lastmillis;
vector<item *> items;
int num = f->getlil<int>();
loopi(num)
{
CHECKEOF(*f, ent)
item *it = items.add(readitem(f));
if(abort) {delete it; return ent;}
loading->inventory.access(it->base, vector<item *>()).add(it);
}
int equiplen = f->getlil<int>();
loopi(equiplen)
{
CHECKEOF(*f, ent)
int idx = f->getlil<int>();
int use = f->getlil<int>();
//validate equipment
items[idx]->quantity++;
loading->equip(items[idx], use);
}
break;
}
case ENT_ITEM:
{
if(!ent) ent = new rpgitem();
rpgitem *loading = (rpgitem *) ent;
readitem(f, loading);
if(abort) return ent;
break;
}
case ENT_OBSTACLE:
{
if(!ent) ent = new rpgobstacle();
rpgobstacle *loading = (rpgobstacle *) ent;
delete loading->mdl;
loading->mdl = readstring(f);
NOTNULL(loading->mdl, ent);
preloadmodel(loading->mdl);
READHASHEXTENDED(loading->script, game::scripts);
NOTNULL(loading->script, ent);
readvec(loading->colour);
loading->weight = f->getlil<int>();
loading->flags = f->getlil<int>();
loading->scale = f->getlil<float>();
break;
}
case ENT_CONTAINER:
{
if(!ent) ent = new rpgcontainer();
rpgcontainer *loading = (rpgcontainer *) ent;
delete[] loading->mdl;
delete[] loading->name;
loading->mdl = readstring(f);
loading->name = readstring(f);
NOTNULL(loading->mdl, ent);
preloadmodel(loading->mdl);
READHASHEXTENDED(loading->faction, game::factions)
READHASHEXTENDED(loading->merchant, game::merchants)
READHASHEXTENDED(loading->script, game::scripts)
if(loading->faction) NOTNULL(loading->faction, ent);
if(loading->merchant) NOTNULL(loading->merchant, ent);
NOTNULL(loading->script, ent)
readvec(loading->colour);
loading->capacity = f->getlil<int>();
loading->lock = f->getlil<int>();
loading->magelock = f->getlil<int>();
loading->scale = f->getlil<float>();
int items = f->getlil<int>();
loopi(items)
{
CHECKEOF(*f, ent)
item *it = readitem(f);
if(abort) { delete it; return ent; }
loading->inventory.access(it->base, vector<item *>()).add(it);
}
break;
}
case ENT_PLATFORM:
{
if(!ent) ent = new rpgplatform();
rpgplatform *loading = (rpgplatform *) ent;
delete[] loading->mdl;
loading->mdl = readstring(f);
NOTNULL(loading->mdl, ent);
preloadmodel(loading->mdl);
READHASHEXTENDED(loading->script, game::scripts)
NOTNULL(loading->script, ent)
readvec(loading->colour);
loading->speed = f->getlil<int>();
loading->flags = f->getlil<int>();
loading->scale = f->getlil<float>();
int steps = f->getlil<int>();
loopi(steps)
{
CHECKEOF(*f, ent)
vector<int> &detours = loading->routes.access(f->getlil<int>(), vector<int>());
int routes = f->getlil<int>();
loopj(routes) detours.add(f->getlil<int>());
}
loading->target = f->getlil<int>();
break;
}
case ENT_TRIGGER:
{
if(!ent) ent = new rpgtrigger();
rpgtrigger *loading = (rpgtrigger *) ent;
delete[] loading->mdl;
delete[] loading->name;
loading->mdl = readstring(f);
NOTNULL(loading->mdl, ent);
preloadmodel(loading->mdl);
loading->name = readstring(f);
READHASHEXTENDED(loading->script, game::scripts)
NOTNULL(loading->script, ent)
readvec(loading->colour);
loading->flags = f->getlil<int>();
loading->lasttrigger = f->getlil<int>() + lastmillis;
loading->scale = f->getlil<float>();
break;
}
default:
ERRORF("unknown entity type %i", type);
abort = true;
return NULL;
}
rpgscript::keeplocal((ent->locals = f->getlil<int>()));
int numeffs = f->getlil<int>();
loopi(numeffs)
{
CHECKEOF(*f, ent)
victimeffect *eff = new victimeffect();
ent->seffects.add(eff);
updates.add(reference(f->getlil<int>(), lastmap, eff->owner));
READHASHEXTENDED(eff->group, game::statuses);
NOTNULL(eff->group, ent);
eff->elem = f->getlil<int>();
int numstat = f->getlil<int>();
loopj(numstat)
{
CHECKEOF(*f, ent)
int type = f->getlil<int>();
status *st = NULL;
switch(type)
{
case STATUS_POLYMORPH:
{
st = eff->effects.add(new status_polymorph());
status_polymorph *poly = (status_polymorph *) st;
poly->mdl = readstring(f);
break;
}
case STATUS_LIGHT:
{
st = eff->effects.add(new status_light());
status_light *light = (status_light *) st;
readvec(light->colour);
break;
}
case STATUS_SCRIPT:
{
st = eff->effects.add(new status_script());
status_script *scr = (status_script *) st;
scr->script = readstring(f);
break;
}
case STATUS_SIGNAL:
{
st = eff->effects.add(new status_signal());
status_signal *sig = (status_signal *) st;
sig->signal = readstring(f);
break;
}
default:
st = eff->effects.add(new status_generic());
break;
}
st->type = type;
st->duration = f->getlil<int>();
st->remain = f->getlil<int>();
st->strength = f->getlil<int>();
st->variance = f->getlil<float>();
eff->effects.add(st);
}
}
ent->maxheight = f->getlil<float>();
ent->eyeheight = f->getlil<float>();
readvec(ent->o);
ent->newpos = ent->o;
readvec(ent->vel);
readvec(ent->falling);
ent->yaw = f->getlil<float>();
ent->pitch = f->getlil<float>();
ent->roll = f->getlil<float>();
ent->timeinair = f->getlil<int>();
ent->state = f->getchar();
ent->editstate = f->getchar();
return ent;
}
void writeent(stream *f, rpgent *d)
{
f->putlil(d->type());
switch(d->type())
{
case ENT_CHAR:
{
rpgchar *saving = (rpgchar *) d;
writestring(f, saving->name);
writestring(f, saving->mdl);
writestring(f, saving->portrait);
writevec(saving->colour)
#define x(var) f->putlil(saving->base.var);
loopi(STAT_MAX) x(baseattrs[i])
loopi(SKILL_MAX) x(baseskills[i])
loopi(STAT_MAX) x(deltaattrs[i])
loopi(SKILL_MAX) x(deltaskills[i])
loopi(ATTACK_MAX) x(bonusthresh[i])
loopi(ATTACK_MAX) x(bonusresist[i])
x(bonushealth)
x(bonusmana)
x(bonusmovespeed)
x(bonusjumpvel)
x(bonuscarry)
x(bonuscrit)
x(bonushregen)
x(bonusmregen)
loopi(ATTACK_MAX) x(deltathresh[i])
loopi(ATTACK_MAX) x(deltaresist[i])
x(deltahealth)
x(deltamana)
x(deltamovespeed)
x(deltajumpvel)
x(deltacarry)
x(deltacrit)
x(deltahregen)
x(deltamregen)
#undef x
writestring(f, saving->script->key);
writestring(f, saving->faction->key);
writestring(f, saving->merchant ? saving->merchant->key : NULL);
f->putlil(saving->health);
f->putlil(saving->mana);
f->putlil(saving->scale);
f->putlil(saving->lastaction - lastmillis);
vector<item *> items;
enumerate(saving->inventory, vector<item *>, stack,
loopvj(stack) items.add(stack[j]);
)
f->putlil(items.length());
loopv(items) writeitem(f, items[i]);
f->putlil(saving->equipped.length());
loopv(saving->equipped)
{
f->putlil(items.find(saving->equipped[i]->it));
f->putlil(saving->equipped[i]->use);
}
break;
}
case ENT_ITEM:
{
rpgitem *saving = (rpgitem *) d;
writeitem(f, saving);
break;
}
case ENT_OBSTACLE:
{
rpgobstacle *saving = (rpgobstacle *) d;
writestring(f, saving->mdl);
writestring(f, saving->script->key);
writevec(saving->colour)
f->putlil(saving->weight);
f->putlil(saving->flags);
f->putlil(saving->scale);
break;
}
case ENT_CONTAINER:
{
rpgcontainer *saving = (rpgcontainer *) d;
writestring(f, saving->mdl);
writestring(f, saving->name);
writestring(f, saving->faction ? saving->faction->key : NULL);
writestring(f, saving->merchant ? saving->merchant->key : NULL);
writestring(f, saving->script->key );
writevec(saving->colour)
f->putlil(saving->capacity);
f->putlil(saving->lock);
f->putlil(saving->magelock);
f->putlil(saving->scale);
vector<item *> items;
enumerate(saving->inventory, vector<item *>, stack,
loopvj(stack) items.add(stack[j]);
)
f->putlil(items.length());
loopv(items) writeitem(f, items[i]);
break;
}
case ENT_PLATFORM:
{
rpgplatform *saving = (rpgplatform *) d;
writestring(f, saving->mdl);
writestring(f, saving->script->key);
writevec(saving->colour)
f->putlil(saving->speed);
f->putlil(saving->flags);
f->putlil(saving->scale);
f->putlil(saving->routes.length());
enumeratekt(saving->routes, int, stop, vector<int>, routes,
f->putlil(stop);
f->putlil(routes.length());
loopvj(routes)
f->putlil(routes[j]);
);
f->putlil(saving->target);
break;
}
case ENT_TRIGGER:
{
rpgtrigger *saving = (rpgtrigger *) d;
writestring(f, saving->mdl);
writestring(f, saving->name);
writestring(f, saving->script->key);
writevec(saving->colour)
f->putlil(saving->flags);
f->putlil(saving->lasttrigger - lastmillis);
f->putlil(saving->scale);
break;
}
default:
ERRORF("unsupported ent type %i, aborting", d->type());
return;
}
f->putlil(d->locals);
f->putlil(d->seffects.length());
loopv(d->seffects)
{
f->putlil(enttonum(d->seffects[i]->owner));
writestring(f, d->seffects[i]->group->key);
f->putlil(d->seffects[i]->elem);
f->putlil(d->seffects[i]->effects.length());
loopvj(d->seffects[i]->effects)
{
status *st = d->seffects[i]->effects[j];
f->putlil(st->type);
switch(st->type)
{
case STATUS_POLYMORPH:
{
status_polymorph *poly = (status_polymorph *) st;
writestring(f, poly->mdl);
break;
}
case STATUS_LIGHT:
{
status_light *light = (status_light *) st;
writevec(light->colour);
break;
}
case STATUS_SCRIPT:
{
status_script *scr = (status_script *) st;
writestring(f, scr->script);
break;
}
case STATUS_SIGNAL:
{
status_signal *sig = (status_signal *) st;
writestring(f, sig->signal);
break;
}
}
f->putlil(st->duration);
f->putlil(st->remain);
f->putlil(st->strength);
f->putlil(st->variance);
}
}
f->putlil(d->maxheight);
f->putlil(d->eyeheight);
writevec(d->o);
writevec(d->vel);
writevec(d->falling);
f->putlil(d->yaw);
f->putlil(d->pitch);
f->putlil(d->roll);
f->putlil(d->timeinair);
f->putchar(d->state);
f->putchar(d->editstate);
}
mapinfo *readmap(stream *f)
{
const char *name = readstring(f);
mapinfo *loading = game::accessmap(name);
lastmap = loading;
loading->name = name;
READHASHEXTENDED(loading->script, game::mapscripts);
NOTNULL(loading->script, loading);
loading->flags = f->getlil<int>();
loading->loaded = f->getchar();
int numobjs = f->getlil<int>(),
numactions = f->getlil<int>(),
numprojs = f->getlil<int>(),
numaeffects = f->getlil<int>(),
numblips = f->getlil<int>();
rpgscript::keeplocal((loading->locals = f->getlil<int>()));
loopi(numobjs)
{
CHECKEOF(*f, loading)
loading->objs.add(readent(f));
}
loopvrev(updates)
{
CHECKEOF(*f, loading)
if(updates[i].map == lastmap)
updates[i].ref = entfromnum(updates[i].ind);
}
loopi(numactions)
{
CHECKEOF(*f, loading)
action *act = NULL;
int type = f->getlil<int>();
switch(type)
{
case ACTION_TELEPORT:
{
int ent = f->getlil<int>();
if(!entfromnum(ent))
{//how'd that happen?
WARNINGF("loaded teleport loadaction for invalid ent? ignoring");
f->getlil<int>();
f->getlil<int>();
continue;
}
int d = f->getlil<int>();
int t = f->getlil<int>();
act = new action_teleport(entfromnum(ent), d, t);
break;
}
case ACTION_SPAWN:
{
const char *id = NULL;
READHASH(id)
NOTNULL(id, loading)
int tag = f->getlil<int>(),
ent = f->getlil<int>(),
amount = f->getlil<int>(),
qty = f->getlil<int>();
act = new action_spawn(tag, ent, id, amount, qty);
break;
}
case ACTION_SCRIPT:
{
act = new action_script(readstring(f));
break;
}
}
loading->loadactions.add(act);
}
loopk(numprojs)
{
CHECKEOF(*f, loading)
projectile *p = loading->projs.add(new projectile());
p->owner = (rpgchar *) entfromnum(f->getlil<int>());
if(p->owner && p->owner->type() != ENT_CHAR)
p->owner = NULL;
int wep = f->getlil<int>();
int ammo = f->getlil<int>();
int use = f->getlil<int>();
int ause = f->getlil<int>();
if(p->owner)
{
enumerate(p->owner->inventory, vector<item *>, stack,
if(stack.inrange(wep))
p->item = equipment(stack[wep], use);
if(stack.inrange(ammo))
p->ammo = equipment(stack[ammo], ause);
wep -= stack.length();
ammo -= stack.length();
)
}
readvec(p->o); readvec(p->dir); readvec(p->emitpos);
p->lastemit = 0; //should emit immediately
p->gravity = f->getlil<int>();
p->deleted = f->getchar();
p->pflags = f->getlil<int>();
p->time = f->getlil<int>();
p->dist = f->getlil<int>();
READHASHEXTENDED(p->projfx, game::effects)
READHASHEXTENDED(p->trailfx, game::effects)
READHASHEXTENDED(p->deathfx, game::effects)
p->radius = f->getlil<int>();
p->elasticity = f->getlil<float>();
p->charge = f->getlil<float>();
p->chargeflags = f->getlil<int>();
}
loopi(numaeffects)
{
CHECKEOF(*f, loading)
areaeffect *aeff = loading->aeffects.add(new areaeffect());
aeff->owner = entfromnum(f->getlil<int>());
readvec(aeff->o);
aeff->lastemit = 0; //should emit immediately
READHASHEXTENDED(aeff->group, game::statuses)
NOTNULL(aeff->group, loading);
READHASHEXTENDED(aeff->fx, game::effects)
if(aeff->fx) NOTNULL(aeff->fx, loading);
aeff->elem = f->getlil<int>();
aeff->radius = f->getlil<int>();
int numstat = f->getlil<int>();
loopj(numstat)
{
CHECKEOF(*f, loading)
int type = f->getlil<int>();
status *st = NULL;
switch(type)
{
case STATUS_POLYMORPH:
{
status_polymorph *poly = new status_polymorph();
st = aeff->effects.add(poly);
poly->mdl = readstring(f);
NOTNULL(poly->mdl, loading);
preloadmodel(poly->mdl);
break;
}
case STATUS_LIGHT:
{
status_light *light = new status_light();
st = aeff->effects.add(light);
readvec(light->colour);
break;
}
case STATUS_SCRIPT:
{
status_script *scr = new status_script();
st = aeff->effects.add(scr);
scr->script = readstring(f);
break;
}
case STATUS_SIGNAL:
{
status_signal *sig = new status_signal();
st = aeff->effects.add(sig);
sig->signal = readstring(f);
break;
}
default:
st = aeff->effects.add(new status_generic());
break;
}
st->type = type;
st->duration = f->getlil<int>();
st->remain = f->getlil<int>();
st->strength = f->getlil<int>();
st->variance = f->getlil<float>();
}
}
loopi(numblips)
{
///FIXME finalize blip structure and write me
}
lastmap = NULL;
return loading;
}
void writemap(stream *f, mapinfo *saving)
{
lastmap = saving;
writestring(f, saving->name);
writestring(f, saving->script->key);
f->putlil(saving->flags);
f->putchar(saving->loaded);
f->putlil(saving->objs.length());
f->putlil(saving->loadactions.length());
f->putlil(saving->projs.length());
f->putlil(saving->aeffects.length());
f->putlil(saving->blips.length());
f->putlil(saving->locals);
loopv(saving->objs)
{
writeent(f, saving->objs[i]);
}
loopv(saving->loadactions)
{
f->putlil(saving->loadactions[i]->type());
switch(saving->loadactions[i]->type())
{
case ACTION_TELEPORT:
{
action_teleport *act = (action_teleport *) saving->loadactions[i];
f->putlil(enttonum(act->ent));
f->putlil(act->dest);
f->putlil(act->etype);
break;
}
case ACTION_SPAWN:
{
action_spawn *spw = (action_spawn *) saving->loadactions[i];
writestring(f, spw->id);
f->putlil(spw->tag);
f->putlil(spw->ent);
f->putlil(spw->amount);
f->putlil(spw->qty);
break;
}
case ACTION_SCRIPT:
writestring(f, ((action_script *) saving->loadactions[i])->script);
break;
}
}
loopv(saving->projs)
{
projectile *p = saving->projs[i];
f->putlil(enttonum(p->owner));
int offset = 0;
int wep = -1;
int ammo = -1;
if(p->owner)
{
enumerate(p->owner->inventory, vector<item *>, stack,
if(stack.find(p->item.it) >= 0)
wep = stack.find(p->item.it) + offset;
if(stack.find(p->ammo.it) >= 0)
ammo = stack.find(p->ammo.it) + offset;
offset += stack.length();
)
}
f->putlil(wep);
f->putlil(ammo);
f->putlil(p->item.use);
f->putlil(p->ammo.use);
writevec(p->o); writevec(p->dir); writevec(p->emitpos);
//f->putlil(p->lastemit);
f->putlil(p->gravity);
f->putchar(p->deleted);
f->putlil(p->pflags);
f->putlil(p->time);
f->putlil(p->dist);
writestring(f, p->projfx ? p->projfx->key : NULL);
writestring(f, p->trailfx ? p->trailfx->key : NULL);
writestring(f, p->deathfx ? p->deathfx->key : NULL);
f->putlil(p->radius);
f->putlil(p->elasticity);
f->putlil(p->charge);
f->putlil(p->chargeflags);
}
loopv(saving->aeffects)
{
areaeffect *aeff = saving->aeffects[i];
f->putlil(enttonum(aeff->owner));
writevec(aeff->o);
writestring(f, aeff->group ? aeff->group->key : NULL);
writestring(f, aeff->fx ? aeff->fx->key : NULL);
f->putlil(aeff->elem);
f->putlil(aeff->radius);
f->putlil(aeff->effects.length());
loopvj(aeff->effects)
{
status *st = aeff->effects[i];
f->putlil(st->type);
switch(st->type)
{
case STATUS_POLYMORPH:
{
status_polymorph *poly = (status_polymorph *) st;
writestring(f, poly->mdl);
break;
}
case STATUS_LIGHT:
{
status_light *light = (status_light *) st;
writevec(light->colour);
break;
}
case STATUS_SCRIPT:
{
status_script *scr = (status_script *) st;
writestring(f, scr->script);
break;
}
case STATUS_SIGNAL:
{
status_signal *sig = (status_signal *) st;
writestring(f, sig->signal);
break;
}
}
f->putlil(st->duration);
f->putlil(st->remain);
f->putlil(st->strength);
f->putlil(st->variance);
}
}
loopv(saving->blips)
{
///FIXME finalize blip structure and write me
}
lastmap = NULL;
}
//don't mind the ::blah, just a namespace collision with rpgio:: when we want it from the global scope
void writereferences(stream *f, const vector<mapinfo *> &maps, hashnameset< ::reference> &stack)
{
f->putlil(stack.length());
enumerate(stack, ::reference, saving,
writestring(f, saving.name);
f->putchar(saving.immutable);
f->putlil(saving.list.length());
loopvj(saving.list)
{
::reference::ref &sav = saving.list[j];
char type = sav.type;
if(sav.ptr == NULL)
{
if(DEBUG_IO)
DEBUGF("reference %s:%i of type %i is null, saving as T_INVALID", saving.name, j, type);
type = ::reference::T_INVALID;
}
switch(type)
{
case ::reference::T_CHAR:
case ::reference::T_ITEM:
case ::reference::T_OBSTACLE:
case ::reference::T_CONTAINER:
case ::reference::T_PLATFORM:
case ::reference::T_TRIGGER:
{
int map = -1;
int ent = -1;
if(sav.ptr == game::player1) { map = ent = -1; }
else loopvj(maps)
{
ent = maps[j]->objs.find(sav.ptr);
if(ent >= 0) {map = j; break;}
}
if(map < 0 && ent < 0 && sav.ptr != game::player1)
{
WARNINGF("char/item/object reference \"%s\" points to non-player entity that does not exist", saving.name);
f->putchar(::reference::T_INVALID);
continue;
}
if(DEBUG_IO)
DEBUGF("writing reference %s as rpgent reference: %i %i", saving.name, map, ent);
f->putchar(type);
f->putlil(map);
f->putlil(ent);
break;
}
case ::reference::T_MAP:
{
f->putchar(type);
int map = maps.find(sav.ptr);
f->putlil(map);
if(DEBUG_IO) DEBUGF("writing reference %s:%i as map reference: %i", saving.name, j, map);
break;
}
case ::reference::T_INV:
{
int map = -1;
int ent = -1;
const char *base = saving.getinv(j)->base;
int offset = -1;
{
vector <item *> *stack = game::player1->inventory.access(base);
if(stack) offset = stack->find(sav.ptr);
}
if(offset < 0) loopv(maps)
{
loopvj(maps[i]->objs)
{
vector<item *> *stack = NULL;
if(maps[i]->objs[j]->type() == ENT_CHAR)
stack = ((rpgchar *) maps[i]->objs[j])->inventory.access(base);
else if(maps[i]->objs[j]->type() == ENT_CONTAINER)
stack = ((rpgcontainer *) maps[i]->objs[j])->inventory.access(base);
if(stack) offset = stack->find(sav.ptr);
if(offset >= 0) { ent = j; break; }
}
if(offset >= 0) { map = i; break; }
}
if(offset < 0)
{
WARNINGF("inv reference \"%s:%i\" points to an item that does not exist", saving.name, j);
f->putchar(::reference::T_INVALID);
continue;
}
if(DEBUG_IO) DEBUGF("writing reference \"%s:%i\" as type T_INV with indices: %i %i %s %i", saving.name, j, map, ent, base, offset);
f->putchar(type);
f->putlil(map);
f->putlil(ent);
writestring(f, base);
f->putlil(offset);
break;
}
//
default:
ERRORF("unsupported reference type %i for reference %s:%i, saving as T_INVALID", sav.type, saving.name, j);
// Temporary reference types below this line...
[[fallthrough]];
case ::reference::T_EQUIP:
case ::reference::T_VEFFECT:
case ::reference::T_AEFFECT:
type = ::reference::T_INVALID;
[[fallthrough]];
case ::reference::T_INVALID:
if(DEBUG_IO) DEBUGF("writing null reference %s:%i", saving.name, j);
f->putchar(type);
break;
}
}
)
}
void readreferences(stream *f, const vector<mapinfo *> &maps, hashnameset< ::reference> &stack)
{
int num = f->getlil<int>();
loopi(num)
{
CHECKEOF(*f, )
const char *name = NULL;
READHASH(name);
NOTNULL(name, )
::reference *loading = stack.access(name);
if(loading)
{
WARNINGF("reference \"%s\" appears to have already been loaded", name);
loading->dump();
}
else
{
if(DEBUG_IO) DEBUGF("Creating reference \"%s\"", name);
loading = &stack[name];
loading->name = name;
}
loading->immutable = f->getchar();
int len = f->getlil<int>();
loopj(len)
{
char type = f->getchar();
switch(type)
{
case ::reference::T_CHAR:
case ::reference::T_ITEM:
case ::reference::T_OBSTACLE:
case ::reference::T_CONTAINER:
case ::reference::T_PLATFORM:
case ::reference::T_TRIGGER:
{
int map = f->getlil<int>();
int ent = f->getlil<int>();
if(map == -1 && ent == -1)
{
if(DEBUG_IO) DEBUGF("reading player char reference %s:%i", loading->name, j);
loading->pushref(game::player1, true);
}
else if(maps.inrange(map) && maps[map]->objs.inrange(ent))
{
if(DEBUG_IO) DEBUGF("reading valid rpgent reference %s:%i -> %i %i", loading->name, j, map, ent);
loading->pushref(maps[map]->objs[ent], true);
}
else WARNINGF("rpgent reference %s:%i -> %i %i - indices out of range", loading->name, j, map, ent);
break;
}
case ::reference::T_MAP:
{
int map = f->getlil<int>();
if(DEBUG_IO) DEBUGF("reading map reference %s:%i -> %i", loading->name, j, map);
if(maps.inrange(map)) loading->pushref(maps[map], true);
break;
}
case ::reference::T_INV:
{
int map = f->getlil<int>();
int ent = f->getlil<int>();
const char *base = NULL;
READHASH(base);
NOTNULL(base, )
int offset = f->getlil<int>();
if(DEBUG_IO) DEBUGF("reading T_INV reference %s:%i with values %i %i %s %i...", loading->name, j, map, ent, base, offset);
vector <item *> *stack = NULL;
if(map == -1 && ent == -1)
stack = game::player1->inventory.access(base);
else if (maps.inrange(map) && maps[map]->objs.inrange(ent))
{
if(maps[map]->objs[ent]->type() == ENT_CHAR)
stack = ((rpgchar *) maps[map]->objs[ent])->inventory.access(base);
else if(maps[map]->objs[ent]->type() == ENT_CONTAINER)
stack = ((rpgcontainer *) maps[map]->objs[ent])->inventory.access(base);
}
if(stack && stack->inrange(offset))
{
if(DEBUG_IO) DEBUGF("Loading T_INV reference to %p successfully", (*stack)[offset]);
loading->pushref((*stack)[offset], true);
}
else
WARNINGF("T_INV reference %s:%i has out of range values: %i %i %s %i, loading failed", loading->name, j, map, ent, base, offset);
break;
}
//Temporary types below this line
case ::reference::T_EQUIP:
case ::reference::T_VEFFECT:
case ::reference::T_AEFFECT:
WARNINGF("volatile reference type found for reference %s:%i, assuming invalid", loading->name, j);
[[fallthrough]];
case ::reference::T_INVALID:
if(DEBUG_IO) DEBUGF("reading now null reference %s:%i", loading->name, j);
loading->pushref(NULL, true);
break;
default:
ERRORF("unsupported reference type %i for reference %s:%i, this will cause issues; aborting", type, loading->name, j);
abort = true;
return;
}
}
}
}
void writedelayscript(stream *f, const vector<mapinfo *> &maps, delayscript *saving)
{
writereferences(f, maps, saving->refs);
writestring(f, saving->script);
f->putlil(saving->remaining);
}
void readdelayscript(stream *f, const vector<mapinfo *> &maps, delayscript *loading)
{
readreferences(f, maps, loading->refs);
loading->script = readstring(f);
loading->remaining = f->getlil<int>();
}
void writejournal(stream *f, journal *saving)
{
writestring(f, saving->name);
f->putlil(saving->status);
f->putlil(saving->entries.length());
loopv(saving->entries)
writestring(f, saving->entries[i]);
}
void readjournal(stream *f)
{
const char *name = NULL;
READHASH(name);
NOTNULL(name, )
journal *journ = &game::journals[name];
if(journ->name)
WARNINGF("additional instance of journal %s exists, merging", name);
journ->name = name;
journ->status = f->getlil<int>();
int entries = f->getlil<int>();
loopi(entries)
journ->entries.add(readstring(f));
}
void writelocal(stream *f, localinst *saving)
{
f->putchar(saving ? saving->shared : 0);
int n = 0;
if(saving) n = saving->variables.length();
f->putlil(n);
if(saving) enumerate(saving->variables, rpgvar, var,
writestring(f, var.name);
writestring(f, var.value);
)
}
void readlocal(stream *f, int i)
{
if(!rpgscript::locals.inrange(i))
rpgscript::alloclocal(false);
localinst *loading = rpgscript::locals[i];
loading->refs = 0;
loading->shared = f->getchar();
int n = f->getlil<int>();
loopj(n)
{
CHECKEOF(*f, )
const char *name = NULL;
READHASH(name);
NOTNULL(name, );
const char *value = readstring(f);
rpgvar &var = loading->variables[name];
if(var.value) delete[] var.value;
var.name = name;
var.value = value;
}
}
void writetimer(stream *f, vector<mapinfo *> &maps, timer *saving)
{
writestring(f, saving->name);
writestring(f, saving->cond);
writestring(f, saving->script);
f->putlil(saving->delay);
f->putlil(saving->remaining);
}
void readtimer(stream *f, vector<mapinfo *> &maps)
{
const char *name;
READHASH(name);
NOTNULL(name, );
bool del = false;
timer *loading;
if(rpgscript::timers.access(name))
{
if(DEBUG_IO) DEBUGF("Timer %s already exists, restoring countdown only", name);
del = true;
loading = new timer();
}
else loading = &rpgscript::timers[name];
loading->name = name;
loading->cond = readstring(f);
loading->script = readstring(f);
loading->delay = f->getlil<int>();
loading->remaining = f->getlil<int>();
if(del)
{
rpgscript::timers[name].remaining = loading->remaining;
delete loading;
}
}
void loadgame(const char *name)
{
defformatstring(file, "%s/%s.sgz", game::datapath("saves"), name);
stream *f = opengzfile(file, "rb");
if(!f)
{
ERRORF("unable to read file: %s", file);
return;
}
saveheader hdr;
f->read(&hdr, sizeof(saveheader));
lilswap(&hdr.sversion, 2);
if(hdr.sversion < COMPAT_VERSION || hdr.sversion > SAVE_VERSION || strncmp(hdr.magic, SAVE_MAGIC, 4))
{
ERRORF("Unsupported version or corrupt save: %i (%i) - %4.4s (%s)", hdr.sversion, SAVE_VERSION, hdr.magic, SAVE_MAGIC);
delete f;
return;
}
if(DEBUG_IO)
DEBUGF("supported save: %i %4.4s", hdr.sversion, hdr.magic);
vector<mapinfo *> maps;
const char *data = readstring(f);
const char *curmap = readstring(f);
const char *cpmap = readstring(f);
int cpnum = f->getlil<int>();
abort = !game::newgame(data, true);
if(cpmap) game::setcheckpoint(cpmap, cpnum);
delete[] data;
delete[] cpmap;
if(game::compatversion > hdr.gversion)
{
ERRORF("saved game is of game version %i, last compatible version is %i; aborting", hdr.gversion, game::compatversion);
abort = true;
goto cleanup;
}
if(!curmap || abort)
{
ERRORF("No map in progress?");
abort = true; goto cleanup;
}
lastmap = game::accessmap(curmap);
int num;
#define READ(m, b) \
num = f->getlil<int>(); \
loopi(num) \
{ \
if(abort) goto cleanup; \
if(f->end()) \
{ \
ERRORF("unexpected EoF, aborting"); \
abort = true; goto cleanup; \
} \
if(DEBUG_IO) \
DEBUGF("reading " #m " %i of %i", i + 1, num); \
b; \
}
///TODO redo hotkeys
// READ(hotkey,
// int b = f->getlil<int>();
// int u = f->getlil<int>();
// game::hotkeys.add(equipment(b, u));
// )
READ(faction,
const char *key = NULL;
READHASH(key);
faction *fac = game::factions.access(key);
if(!fac) WARNINGF("reading faction %s as a dummy", key);
readfaction(f, fac);
);
READ(recipe,
const char *key = NULL;
READHASH(key);
recipe *r = game::recipes.access(key);
if(!r) WARNINGF("reading recipe %s as a dummy", key);
readrecipe(f, r);
);
READ(merchant,
const char *key = NULL;
READHASH(key);
merchant *m = game::merchants.access(key);
if(!m) WARNINGF("reading merchant %s as a dummy", key);
readmerchant(f, m);
);
READ(variable,
const char *name = NULL;
READHASH(name);
const char *v = readstring(f);
if(!rpgscript::setglobal(name, v, false))
WARNINGF("reloading the game added variable \"%s\"", name);
)
READ(locals stack,
readlocal(f, i);
)
readent(f, game::player1);
READ(mapinfo, maps.add(readmap(f)));
READ(reference stack,
if(!rpgscript::stack.inrange(i)) rpgscript::pushstack();
readreferences(f, maps, *rpgscript::stack[i]);
)
READ(delayscript stack,
rpgscript::delaystack.add(new delayscript());
readdelayscript(f, maps, rpgscript::delaystack[i]);
)
READ(global timers, readtimer(f, maps); )
READ(journal bucket,
readjournal(f);
)
#undef READ
if(!abort) loopv(characters)
characters[i]->compactinventory(NULL);
cleanup:
delete f;
characters.shrink(0);
updates.shrink(0);
rpgscript::cleanlocals();
if(abort)
{
ERRORF("aborted - something went seriously wrong");
localdisconnect();
delete[] curmap;
return;
}
game::transfer = true;
game::openworld(curmap);
delete[] curmap;
//the game is compatible but is an older version
//this is to update things to a newer version if such changes are required
for(int v = hdr.gversion; v < game::gameversion; v++)
{
defformatstring(signal, "import %i", v);
if(DEBUG_IO)
DEBUGF("the game is outdated, currently version %i - sending \"%s\" to do any needed changes", v, signal);
enumerate(game::mapdata, mapinfo, map,
map.getsignal(signal, true, NULL);
)
}
}
COMMAND(loadgame, "s");
void savegame(const char *name)
{
if(!game::connected || !game::curmap)
{
ERRORF("No game in progress, can't save");
return;
}
else if(!game::cansave())
{
conoutf("You may not save at this time");
return;
}
defformatstring(file, "%s/%s.sgz.tmp", game::datapath("saves"), name);
stream *f = opengzfile(path(file), "wb");
if(!f)
{
ERRORF("failed to create savegame");
return;
}
saveheader hdr;
hdr.sversion = SAVE_VERSION;
hdr.gversion = game::gameversion;
memcpy(hdr.magic, SAVE_MAGIC, 4);
lilswap(&hdr.sversion, 2);
f->write(&hdr, sizeof(saveheader));
writestring(f, game::data);
writestring(f, game::curmap->name);
writestring(f, game::cpmap);
f->putlil(game::cpnum);
#define WRITE(m, v, b) \
f->putlil(v.length()); \
loopv(v) \
{ \
if(DEBUG_IO) \
DEBUGF("Writing " #m " %i of %i", i + 1, v.length()); \
b; \
}
#define WRITEHT(m, ht, t, b) \
if(DEBUG_IO) DEBUGF("Writing %i " #m "(s)", (ht).length()); \
f->putlil((ht).length()); \
enumerate(ht, t, entry, \
writestring(f, entry.key); \
if(DEBUG_IO) \
DEBUGF("Writing " #m " %s to file...", entry.key); \
b; \
)
///TODO redo hotkeys
// WRITE(hotkey, game::hotkeys,
// f->putlil(game::hotkeys[i].base);
// f->putlil(game::hotkeys[i].use);
// )
WRITEHT(faction, game::factions, faction,
writefaction(f, &entry);
)
WRITEHT(recipe, game::recipes, recipe,
writerecipe(f, &entry);
)
WRITEHT(merchant, game::merchants, merchant,
writemerchant(f, &entry);
)
vector<rpgvar *> vars;
enumerate(game::variables, rpgvar, var, vars.add(&var));
WRITE(variable, vars,
writestring(f, vars[i]->name);
writestring(f, vars[i]->value);
)
WRITE(locals stack, rpgscript::locals,
writelocal(f, rpgscript::locals[i]);
)
writeent(f, game::player1);
game::curmap->objs.removeobj(game::player1);
vector<mapinfo *> maps;
enumerate(game::mapdata, mapinfo, map, maps.add(&map););
WRITE(map, maps, writemap(f, maps[i]));
WRITE(reference stack, rpgscript::stack,
writereferences(f, maps, *rpgscript::stack[i]);
)
WRITE(delayscript stack, rpgscript::delaystack,
writedelayscript(f, maps, rpgscript::delaystack[i]);
)
vector<timer *> timers;
enumerate(rpgscript::timers, timer, t, timers.add(&t));
WRITE(global timer, timers,
writetimer(f, maps, timers[i]);
)
vector<journal *> journ;
enumerate(game::journals, journal, bucket,
journ.add(&bucket);
)
WRITE(journal bucket, journ,
writejournal(f, journ[i]);
)
game::curmap->objs.add(game::player1);
DELETEP(f);
string final;
copystring(final, file, strlen(file) - 3);
backup(file, final);
conoutf("Game saved successfully to %s", final);
copystring(file + strlen(file) - 8, ".png", 5);
scaledscreenshot(file, 2, 256, 256);
reloadtexture(file);
}
COMMAND(savegame, "s");
}
| 24.119248 | 137 | 0.598851 | Hirato |
0fc1f37a38b5d513e821111d5f5c2192eb9bc554 | 140 | hpp | C++ | Iridium/Utility/Allocator.hpp | lordharambae/Iridium | 40997d7082f7f80e38338af358fdca2a5ac3af63 | [
"BSD-3-Clause"
] | null | null | null | Iridium/Utility/Allocator.hpp | lordharambae/Iridium | 40997d7082f7f80e38338af358fdca2a5ac3af63 | [
"BSD-3-Clause"
] | null | null | null | Iridium/Utility/Allocator.hpp | lordharambae/Iridium | 40997d7082f7f80e38338af358fdca2a5ac3af63 | [
"BSD-3-Clause"
] | null | null | null | #pragma once
#ifndef ALLOCATOR_HPP
#define ALLOCATOR_HPP
namespace Iridium {
namespace Utility {
class Allocator {};
}
}
#endif
| 8.75 | 21 | 0.707143 | lordharambae |
0fc5fb72f3fe232b80609e6d7e9af660a71996e1 | 5,788 | cpp | C++ | extension/app/handler.cpp | vvalceanu/mozilla-vpn-client | bd682c5b7b12bb49e1b1c555f1ca973484b8ce5a | [
"MIT"
] | 222 | 2020-11-21T05:55:56.000Z | 2022-03-29T16:20:03.000Z | extension/app/handler.cpp | vvalceanu/mozilla-vpn-client | bd682c5b7b12bb49e1b1c555f1ca973484b8ce5a | [
"MIT"
] | 1,893 | 2020-11-16T19:31:50.000Z | 2022-03-31T21:51:31.000Z | extension/app/handler.cpp | vvalceanu/mozilla-vpn-client | bd682c5b7b12bb49e1b1c555f1ca973484b8ce5a | [
"MIT"
] | 68 | 2020-11-19T19:08:16.000Z | 2022-03-25T20:07:59.000Z | /* 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 "handler.h"
#include "constants.h"
#include "logger.h"
#include <iostream>
#ifndef MVPN_WINDOWS
# include <sys/select.h>
#else
# include <fcntl.h>
# include <io.h>
#endif
using namespace nlohmann;
using namespace std;
#ifdef MVPN_WINDOWS
static bool setBinaryMode(FILE* file) {
if (_setmode(_fileno(file), _O_BINARY) == -1) {
Logger::log("Failed to set BINARY mode");
return false;
}
if (setvbuf(file, NULL, _IONBF, 0) != 0) {
Logger::log("Failed to set no-buffering mode");
return false;
}
return true;
}
#endif
int Handler::run() {
#ifdef MVPN_WINDOWS
if (!setBinaryMode(stdin)) {
Logger::log("Failed to set STDIN in binary mode");
return 1;
}
if (!setBinaryMode(stdout)) {
Logger::log("Failed to set STDOUT in binary mode");
return 1;
}
#endif
while (true) {
// Let's see if we need to connect to the VPN client before reading any
// message. We don't care about the result of this operation because we can
// start reading from STDIN and retry the connection later on.
maybeConnect();
bool readStdin = false;
bool readVpnConnection = false;
#ifdef MVPN_WINDOWS
HANDLE handles[3];
handles[0] = GetStdHandle(STD_INPUT_HANDLE);
handles[1] = INVALID_HANDLE_VALUE;
handles[2] = INVALID_HANDLE_VALUE;
int count = 1;
if (m_vpnConnection.connected()) {
handles[1] = WSACreateEvent();
if (handles[1] == WSA_INVALID_EVENT) {
Logger::log("Failed to create a WSA event");
return 1;
}
if (WSAEventSelect(m_vpnConnection.socket(), handles[1], FD_READ) ==
SOCKET_ERROR) {
Logger::log("Failed to associate the event with the socket");
return 1;
}
++count;
}
// We use the following call only to "wait".
WaitForMultipleObjectsEx(count, handles, FALSE, INFINITE, FALSE);
readStdin = (WaitForSingleObjectEx(handles[0], 0, FALSE) == WAIT_OBJECT_0);
readVpnConnection =
(m_vpnConnection.connected() &&
WaitForSingleObjectEx(handles[1], 0, FALSE) == WAIT_OBJECT_0);
#else // POSIX
fd_set rfds;
int nfds = 0; // the STDIN
FD_ZERO(&rfds);
FD_SET(0, &rfds);
if (m_vpnConnection.connected()) {
FD_SET(m_vpnConnection.socket(), &rfds);
nfds = m_vpnConnection.socket();
}
int rv = select(nfds + 1, &rfds, NULL, NULL, NULL);
if (rv == -1) {
return 1;
}
if (!rv) {
continue;
}
readStdin = FD_ISSET(0, &rfds);
readVpnConnection = m_vpnConnection.connected() &&
FD_ISSET(m_vpnConnection.socket(), &rfds);
#endif
// Something to read from STDIN
if (readStdin) {
Logger::log("STDIN message received");
json message;
if (!readMessage(message)) {
return 1;
}
// This is mainly for testing.
if (message == "bridge_ping") {
if (!writeMessage("bridge_pong")) {
return 1;
}
continue;
}
// Maybe we are not connected yet. We need to be connected to send the
// message to the VPN client.
if (!maybeConnect()) {
Logger::log("VPN Client not connected");
if (!writeVpnNotConnected()) {
return 1;
}
continue;
}
// The VPN can be terminated at any time. Let's treat it as a non-fatal
// error.
if (!m_vpnConnection.writeMessage(message)) {
assert(!m_vpnConnection.connected());
if (!writeVpnNotConnected()) {
return 1;
}
continue;
}
}
// Something to read from the VPN client
if (m_vpnConnection.connected() && readVpnConnection) {
json message;
if (!m_vpnConnection.readMessage(message)) {
assert(!m_vpnConnection.connected());
continue;
}
if (!writeMessage(message)) {
return 1;
}
}
}
return 0;
}
bool Handler::maybeConnect() {
if (m_vpnConnection.connected()) {
return true;
}
return m_vpnConnection.connect();
}
// Retrieve a message from the STDIN.
// static
bool Handler::readMessage(json& output) {
char rawLength[sizeof(uint32_t)];
if (fread(rawLength, sizeof(char), sizeof(uint32_t), stdin) !=
sizeof(uint32_t)) {
Logger::log("Failed to read from STDIN");
return false;
}
uint32_t length = *reinterpret_cast<uint32_t*>(rawLength);
if (!length || length > Constants::MAX_MSG_SIZE) {
Logger::log("Failed to read from STDIN");
return false;
}
char* message = (char*)malloc(length);
if (!message) {
Logger::log("Failed to allocate the message buffer");
return false;
}
if (fread(message, sizeof(char), length, stdin) != length) {
Logger::log("Failed to read from STDIN");
free(message);
return false;
}
string m(message, message + length);
output = json::parse(m);
free(message);
return true;
}
// Serialize a message to STDOUT
// static
bool Handler::writeMessage(const json& body) {
string message = body.dump();
uint32_t length = (uint32_t)message.length();
char* rawLength = reinterpret_cast<char*>(&length);
if (fwrite(rawLength, sizeof(char), sizeof(uint32_t), stdout) !=
sizeof(uint32_t)) {
Logger::log("Failed to write to STDOUT");
return false;
}
if (fwrite(message.c_str(), sizeof(char), length, stdout) != length) {
Logger::log("Failed to write to STDOUT");
return false;
}
fflush(stdout);
return true;
}
// static
bool Handler::writeVpnNotConnected() {
return writeMessage({{"error", "vpn-client-down"}});
}
| 23.62449 | 79 | 0.620767 | vvalceanu |
0fc6df27917ae4f535ef158327091c558b4b8e56 | 221 | hh | C++ | firmware/src/MightyBoard/Motherboard/Compat.hh | 46cv8/Sailfish-MightyBoardFirmware | 4d8456e54c537dd32775095ed2715d41f5961e6c | [
"AAL"
] | 79 | 2015-01-13T21:00:15.000Z | 2022-03-22T14:40:41.000Z | firmware/src/MightyBoard/Motherboard/Compat.hh | 46cv8/Sailfish-MightyBoardFirmware | 4d8456e54c537dd32775095ed2715d41f5961e6c | [
"AAL"
] | 79 | 2015-04-23T18:25:49.000Z | 2021-10-03T14:42:07.000Z | firmware/src/MightyBoard/Motherboard/Compat.hh | 46cv8/Sailfish-MightyBoardFirmware | 4d8456e54c537dd32775095ed2715d41f5961e6c | [
"AAL"
] | 66 | 2015-01-05T04:05:09.000Z | 2022-02-16T17:31:02.000Z | #ifndef __COMPAT_HH__
#define __COMPAT_HH__
#ifndef SIMULATOR
#include <avr/version.h>
#if __AVR_LIBC_VERSION__ >= 10800UL
#define __DELAY_BACKWARD_COMPATIBLE__ 1
#define __PROG_TYPES_COMPAT__ 1
#endif
#endif
#endif
| 13.8125 | 39 | 0.809955 | 46cv8 |
0fc8e8193b6099b0121e2f8b7ff42a03a7569383 | 10,776 | hpp | C++ | include/mango/simd/avx512_float128.hpp | ufoym/mango | 9732fc528f66439f50a3a7cb72d4ba42a59a3d54 | [
"Zlib"
] | 3 | 2021-02-27T10:29:37.000Z | 2022-02-16T16:31:26.000Z | include/mango/simd/avx512_float128.hpp | ufoym/mango | 9732fc528f66439f50a3a7cb72d4ba42a59a3d54 | [
"Zlib"
] | null | null | null | include/mango/simd/avx512_float128.hpp | ufoym/mango | 9732fc528f66439f50a3a7cb72d4ba42a59a3d54 | [
"Zlib"
] | 5 | 2021-03-22T11:06:00.000Z | 2022-02-22T02:53:19.000Z | /*
MANGO Multimedia Development Platform
Copyright (C) 2012-2021 Twilight Finland 3D Oy Ltd. All rights reserved.
*/
#pragma once
#include <mango/simd/simd.hpp>
namespace mango::simd
{
// -----------------------------------------------------------------
// f32x4
// -----------------------------------------------------------------
// shuffle
template <u32 x, u32 y, u32 z, u32 w>
static inline f32x4 shuffle(f32x4 a, f32x4 b)
{
static_assert(x < 4 && y < 4 && z < 4 && w < 4, "Index out of range.");
return _mm_shuffle_ps(a, b, _MM_SHUFFLE(w, z, y, x));
}
template <u32 x, u32 y, u32 z, u32 w>
static inline f32x4 shuffle(f32x4 v)
{
static_assert(x < 4 && y < 4 && z < 4 && w < 4, "Index out of range.");
return _mm_shuffle_ps(v, v, _MM_SHUFFLE(w, z, y, x));
}
template <>
inline f32x4 shuffle<0, 1, 2, 3>(f32x4 v)
{
// .xyzw
return v;
}
// indexed access
template <unsigned int Index>
static inline f32x4 set_component(f32x4 a, f32 s)
{
static_assert(Index < 4, "Index out of range.");
return _mm_insert_ps(a, _mm_set_ss(s), Index * 0x10);
}
template <int Index>
static inline f32 get_component(f32x4 a);
template <>
inline f32 get_component<0>(f32x4 a)
{
return _mm_cvtss_f32(a);
}
template <>
inline f32 get_component<1>(f32x4 a)
{
return _mm_cvtss_f32(shuffle<1, 1, 1, 1>(a));
}
template <>
inline f32 get_component<2>(f32x4 a)
{
return _mm_cvtss_f32(shuffle<2, 2, 2, 2>(a));
}
template <>
inline f32 get_component<3>(f32x4 a)
{
return _mm_cvtss_f32(shuffle<3, 3, 3, 3>(a));
}
static inline f32x4 f32x4_zero()
{
return _mm_setzero_ps();
}
static inline f32x4 f32x4_set(f32 s)
{
return _mm_set1_ps(s);
}
static inline f32x4 f32x4_set(f32 x, f32 y, f32 z, f32 w)
{
return _mm_setr_ps(x, y, z, w);
}
static inline f32x4 f32x4_uload(const f32* source)
{
return _mm_loadu_ps(source);
}
static inline void f32x4_ustore(f32* dest, f32x4 a)
{
_mm_storeu_ps(dest, a);
}
static inline f32x4 movelh(f32x4 a, f32x4 b)
{
return _mm_movelh_ps(a, b);
}
static inline f32x4 movehl(f32x4 a, f32x4 b)
{
return _mm_movehl_ps(a, b);
}
static inline f32x4 unpackhi(f32x4 a, f32x4 b)
{
return _mm_unpackhi_ps(a, b);
}
static inline f32x4 unpacklo(f32x4 a, f32x4 b)
{
return _mm_unpacklo_ps(a, b);
}
// bitwise
static inline f32x4 bitwise_nand(f32x4 a, f32x4 b)
{
return _mm_andnot_ps(a, b);
}
static inline f32x4 bitwise_and(f32x4 a, f32x4 b)
{
return _mm_and_ps(a, b);
}
static inline f32x4 bitwise_or(f32x4 a, f32x4 b)
{
return _mm_or_ps(a, b);
}
static inline f32x4 bitwise_xor(f32x4 a, f32x4 b)
{
return _mm_xor_ps(a, b);
}
static inline f32x4 bitwise_not(f32x4 a)
{
const __m128i s = _mm_castps_si128(a);
return _mm_castsi128_ps(_mm_ternarylogic_epi32(s, s, s, 0x01));
}
static inline f32x4 min(f32x4 a, f32x4 b)
{
return _mm_min_ps(a, b);
}
static inline f32x4 min(f32x4 a, f32x4 b, mask32x4 mask)
{
return _mm_maskz_min_ps(mask, a, b);
}
static inline f32x4 min(f32x4 a, f32x4 b, mask32x4 mask, f32x4 value)
{
return _mm_mask_min_ps(value, mask, a, b);
}
static inline f32x4 max(f32x4 a, f32x4 b)
{
return _mm_max_ps(a, b);
}
static inline f32x4 max(f32x4 a, f32x4 b, mask32x4 mask)
{
return _mm_maskz_max_ps(mask, a, b);
}
static inline f32x4 max(f32x4 a, f32x4 b, mask32x4 mask, f32x4 value)
{
return _mm_mask_max_ps(value, mask, a, b);
}
static inline f32x4 hmin(f32x4 a)
{
__m128 temp = _mm_min_ps(a, _mm_shuffle_ps(a, a, _MM_SHUFFLE(2, 3, 0, 1)));
return _mm_min_ps(temp, _mm_shuffle_ps(temp, temp, _MM_SHUFFLE(1, 0, 3, 2)));
}
static inline f32x4 hmax(f32x4 a)
{
__m128 temp = _mm_max_ps(a, _mm_shuffle_ps(a, a, _MM_SHUFFLE(2, 3, 0, 1)));
return _mm_max_ps(temp, _mm_shuffle_ps(temp, temp, _MM_SHUFFLE(1, 0, 3, 2)));
}
static inline f32x4 abs(f32x4 a)
{
return _mm_max_ps(a, _mm_sub_ps(_mm_setzero_ps(), a));
}
static inline f32x4 neg(f32x4 a)
{
return _mm_sub_ps(_mm_setzero_ps(), a);
}
static inline f32x4 sign(f32x4 a)
{
__m128 sign_mask = _mm_set1_ps(-0.0f);
__m128 value_mask = _mm_cmpneq_ps(a, _mm_setzero_ps());
__m128 sign_bits = _mm_and_ps(a, sign_mask);
__m128 value_bits = _mm_and_ps(_mm_set1_ps(1.0f), value_mask);
return _mm_or_ps(value_bits, sign_bits);
}
static inline f32x4 add(f32x4 a, f32x4 b)
{
return _mm_add_ps(a, b);
}
static inline f32x4 add(f32x4 a, f32x4 b, mask32x4 mask)
{
return _mm_maskz_add_ps(mask, a, b);
}
static inline f32x4 add(f32x4 a, f32x4 b, mask32x4 mask, f32x4 value)
{
return _mm_mask_add_ps(value, mask, a, b);
}
static inline f32x4 sub(f32x4 a, f32x4 b)
{
return _mm_sub_ps(a, b);
}
static inline f32x4 sub(f32x4 a, f32x4 b, mask32x4 mask)
{
return _mm_maskz_sub_ps(mask, a, b);
}
static inline f32x4 sub(f32x4 a, f32x4 b, mask32x4 mask, f32x4 value)
{
return _mm_mask_sub_ps(value, mask, a, b);
}
static inline f32x4 mul(f32x4 a, f32x4 b)
{
return _mm_mul_ps(a, b);
}
static inline f32x4 mul(f32x4 a, f32x4 b, mask32x4 mask)
{
return _mm_maskz_mul_ps(mask, a, b);
}
static inline f32x4 mul(f32x4 a, f32x4 b, mask32x4 mask, f32x4 value)
{
return _mm_mask_mul_ps(value, mask, a, b);
}
static inline f32x4 div(f32x4 a, f32x4 b)
{
return _mm_div_ps(a, b);
}
static inline f32x4 div(f32x4 a, f32x4 b, mask32x4 mask)
{
return _mm_maskz_div_ps(mask, a, b);
}
static inline f32x4 div(f32x4 a, f32x4 b, mask32x4 mask, f32x4 value)
{
return _mm_mask_div_ps(value, mask, a, b);
}
static inline f32x4 div(f32x4 a, f32 b)
{
return _mm_div_ps(a, _mm_set1_ps(b));
}
static inline f32x4 hadd(f32x4 a, f32x4 b)
{
return _mm_hadd_ps(a, b);
}
static inline f32x4 hsub(f32x4 a, f32x4 b)
{
return _mm_hsub_ps(a, b);
}
#if defined(MANGO_ENABLE_FMA3)
static inline f32x4 madd(f32x4 a, f32x4 b, f32x4 c)
{
// a + b * c
return _mm_fmadd_ps(b, c, a);
}
static inline f32x4 msub(f32x4 a, f32x4 b, f32x4 c)
{
// b * c - a
return _mm_fmsub_ps(b, c, a);
}
static inline f32x4 nmadd(f32x4 a, f32x4 b, f32x4 c)
{
// a - b * c
return _mm_fnmadd_ps(b, c, a);
}
static inline f32x4 nmsub(f32x4 a, f32x4 b, f32x4 c)
{
// -(a + b * c)
return _mm_fnmsub_ps(b, c, a);
}
#else
static inline f32x4 madd(f32x4 a, f32x4 b, f32x4 c)
{
return _mm_add_ps(a, _mm_mul_ps(b, c));
}
static inline f32x4 msub(f32x4 a, f32x4 b, f32x4 c)
{
return _mm_sub_ps(_mm_mul_ps(b, c), a);
}
static inline f32x4 nmadd(f32x4 a, f32x4 b, f32x4 c)
{
return _mm_sub_ps(a, _mm_mul_ps(b, c));
}
static inline f32x4 nmsub(f32x4 a, f32x4 b, f32x4 c)
{
return _mm_sub_ps(_mm_setzero_ps(), _mm_add_ps(a, _mm_mul_ps(b, c)));
}
#endif
static inline f32x4 lerp(f32x4 a, f32x4 b, f32x4 s)
{
// a * (1.0 - s) + b * s
// (a - a * s) + (b * s)
return madd(nmadd(a, a, s), b, s);
}
#if defined(MANGO_FAST_MATH)
static inline f32x4 rcp(f32x4 a)
{
return _mm_rcp14_ps(a);
}
static inline f32x4 rsqrt(f32x4 a)
{
return _mm_maskz_rsqrt14_ps(_mm_cmp_ps_mask(a, a, _CMP_EQ_OQ), a);
}
#else
static inline f32x4 rcp(f32x4 a)
{
f32x4 n = _mm_rcp_ps(a);
f32x4 m = _mm_mul_ps(_mm_mul_ps(n, n), a);
return _mm_sub_ps(_mm_add_ps(n, n), m);
}
static inline f32x4 rsqrt(f32x4 a)
{
f32x4 n = _mm_rsqrt_ps(a);
f32x4 e = _mm_mul_ps(_mm_mul_ps(n, n), a);
n = _mm_mul_ps(_mm_set_ps1(0.5f), n);
e = _mm_sub_ps(_mm_set_ps1(3.0f), e);
return _mm_mul_ps(n, e);
}
#endif
static inline f32x4 sqrt(f32x4 a)
{
return _mm_sqrt_ps(a);
}
static inline f32 dot3(f32x4 a, f32x4 b)
{
f32x4 s = _mm_dp_ps(a, b, 0x7f);
return get_component<0>(s);
}
static inline f32 dot4(f32x4 a, f32x4 b)
{
f32x4 s = _mm_dp_ps(a, b, 0xff);
return get_component<0>(s);
}
static inline f32x4 cross3(f32x4 a, f32x4 b)
{
f32x4 c = _mm_sub_ps(_mm_mul_ps(a, shuffle<1, 2, 0, 3>(b)),
_mm_mul_ps(b, shuffle<1, 2, 0, 3>(a)));
return shuffle<1, 2, 0, 3>(c);
}
// compare
static inline mask32x4 compare_neq(f32x4 a, f32x4 b)
{
return _mm_cmp_ps_mask(a, b, _CMP_NEQ_UQ);
}
static inline mask32x4 compare_eq(f32x4 a, f32x4 b)
{
return _mm_cmp_ps_mask(a, b, _CMP_EQ_OQ);
}
static inline mask32x4 compare_lt(f32x4 a, f32x4 b)
{
return _mm_cmp_ps_mask(a, b, _CMP_LT_OS);
}
static inline mask32x4 compare_le(f32x4 a, f32x4 b)
{
return _mm_cmp_ps_mask(a, b, _CMP_LE_OS);
}
static inline mask32x4 compare_gt(f32x4 a, f32x4 b)
{
return _mm_cmp_ps_mask(b, a, _CMP_LT_OS);
}
static inline mask32x4 compare_ge(f32x4 a, f32x4 b)
{
return _mm_cmp_ps_mask(b, a, _CMP_LE_OS);
}
static inline f32x4 select(mask32x4 mask, f32x4 a, f32x4 b)
{
return _mm_mask_blend_ps(mask, b, a);
}
// rounding
static inline f32x4 round(f32x4 s)
{
return _mm_round_ps(s, _MM_FROUND_TO_NEAREST_INT | _MM_FROUND_NO_EXC);
}
static inline f32x4 trunc(f32x4 s)
{
//return _mm_roundscale_ps(s, 0x13);
return _mm_round_ps(s, _MM_FROUND_TO_ZERO | _MM_FROUND_NO_EXC);
}
static inline f32x4 floor(f32x4 s)
{
//return _mm_roundscale_ps(s, 0x11);
return _mm_round_ps(s, _MM_FROUND_TO_NEG_INF | _MM_FROUND_NO_EXC);
}
static inline f32x4 ceil(f32x4 s)
{
//return _mm_roundscale_ps(s, 0x12);
return _mm_round_ps(s, _MM_FROUND_TO_POS_INF | _MM_FROUND_NO_EXC);
}
static inline f32x4 fract(f32x4 s)
{
return sub(s, floor(s));
}
} // namespace mango::simd
| 23.174194 | 85 | 0.577394 | ufoym |
0fcb0d654cd2ffa142d1cbe73dbeec0d082a43a2 | 34,154 | cpp | C++ | iRODS/server/api/src/rsServerReport.cpp | cyverse/irods | 4ea33f5f0e220b6e5d257a49b45e10d07ec02d75 | [
"BSD-3-Clause"
] | null | null | null | iRODS/server/api/src/rsServerReport.cpp | cyverse/irods | 4ea33f5f0e220b6e5d257a49b45e10d07ec02d75 | [
"BSD-3-Clause"
] | 7 | 2019-12-02T17:55:49.000Z | 2019-12-02T17:55:59.000Z | iRODS/server/api/src/rsServerReport.cpp | benlazarine/irods | 83f3c4a6f8f7fc6422a1e73a297b97796a961322 | [
"BSD-3-Clause"
] | 1 | 2019-12-02T05:44:10.000Z | 2019-12-02T05:44:10.000Z | #include "rsGlobalExtern.hpp"
#include "rodsErrorTable.h"
#include "miscServerFunct.hpp"
#include "reIn2p3SysRule.hpp"
#include "irods_lookup_table.hpp"
#include "irods_log.hpp"
#include "irods_plugin_name_generator.hpp"
#include "irods_home_directory.hpp"
#include "irods_plugin_home_directory.hpp"
#include "irods_resource_manager.hpp"
#include "irods_get_full_path_for_config_file.hpp"
#include "server_report.h"
#include "readServerConfig.hpp"
#include "irods_server_properties.hpp"
#include "irods_environment_properties.hpp"
#include "irods_load_plugin.hpp"
#include "jansson.h"
#include <fstream>
#include <boost/algorithm/string.hpp>
#include <boost/filesystem.hpp>
#include <boost/lexical_cast.hpp>
#include <boost/archive/iterators/base64_from_binary.hpp>
#include <boost/archive/iterators/insert_linebreaks.hpp>
#include <boost/archive/iterators/transform_width.hpp>
#include <boost/archive/iterators/ostream_iterator.hpp>
namespace fs = boost::filesystem;
#include <sys/utsname.h>
int _rsServerReport(
rsComm_t* _comm,
bytesBuf_t** _bbuf );
int rsServerReport(
rsComm_t* _comm,
bytesBuf_t** _bbuf ) {
// always execute this locally
int status = _rsServerReport(
_comm,
_bbuf );
if ( status < 0 ) {
rodsLog(
LOG_ERROR,
"rsServerReport: rcServerReport failed, status = %d",
status );
}
return status;
} // rsServerReport
irods::error make_file_set(
const std::string& _files,
json_t*& _object ) {
if ( _files.empty() ) {
return SUCCESS();
}
if ( _object ) {
return ERROR(
SYS_INVALID_INPUT_PARAM,
"json object is not null" );
}
std::vector<std::string> file_set;
boost::split( file_set, _files, boost::is_any_of( "," ) );
_object = json_array();
if ( !_object ) {
return ERROR(
SYS_MALLOC_ERR,
"allocation of json object failed" );
}
for ( size_t i = 0;
i < file_set.size();
++i ) {
json_t* obj = json_object();
if ( !obj ) {
return ERROR(
SYS_MALLOC_ERR,
"failed to allocate object" );
}
json_object_set( obj, "filename", json_string( file_set[ i ].c_str() ) );
json_array_append( _object, obj );
} // for i
return SUCCESS();
} // make_file_set
irods::error make_federation_set(
const std::vector< std::string >& _feds,
json_t*& _object ) {
if ( _feds.empty() ) {
return SUCCESS();
}
if ( _object ) {
return ERROR(
SYS_INVALID_INPUT_PARAM,
"json object is not null" );
}
_object = json_array();
if ( !_object ) {
return ERROR(
SYS_MALLOC_ERR,
"allocation of json object failed" );
}
for ( size_t i = 0;
i < _feds.size();
++i ) {
std::vector<std::string> zone_sid_vals;
boost::split( zone_sid_vals, _feds[ i ], boost::is_any_of( "-" ) );
if ( zone_sid_vals.size() > 2 ) {
rodsLog(
LOG_ERROR,
"multiple hyphens found in RemoteZoneSID [%s]",
_feds[ i ].c_str() );
continue;
}
json_t* fed_obj = json_object();
json_object_set( fed_obj, "zone_name", json_string( zone_sid_vals[ 0 ].c_str() ) );
json_object_set( fed_obj, "zone_key", json_string( "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" ) );
json_object_set( fed_obj, "negotiation_key", json_string( "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" ) );
json_array_append( _object, fed_obj );
} // for i
return SUCCESS();
} // make_federation_set
irods::error sanitize_server_config_keys(
json_t* _svr_cfg ) {
if ( !_svr_cfg ) {
return ERROR(
SYS_INVALID_INPUT_PARAM,
"null json object" );
}
// sanitize the top level keys
json_object_set(
_svr_cfg,
"zone_key",
json_string( "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" ) );
json_object_set(
_svr_cfg,
"negotiation_key",
json_string( "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" ) );
json_object_set(
_svr_cfg,
"server_control_plane_key",
json_string( "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" ) );
// get the federation object
json_t* fed_obj = json_object_get(
_svr_cfg,
"federation" );
if ( !fed_obj ) {
return SUCCESS();
}
// sanitize all federation keys
size_t idx = 0;
json_t* obj = 0;
json_array_foreach( fed_obj, idx, obj ) {
json_object_set(
obj,
"negotiation_key",
json_string( "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" ) );
json_object_set(
obj,
"zone_key",
json_string( "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" ) );
}
return SUCCESS();
} // sanitize_server_config_keys
irods::error convert_server_config(
json_t*& _svr_cfg ) {
// =-=-=-=-=-=-=-
// if json file exists, simply load that
std::string svr_cfg;
irods::error ret = irods::get_full_path_for_config_file(
"server_config.json",
svr_cfg );
if ( ret.ok() && fs::exists( svr_cfg ) ) {
json_error_t error;
_svr_cfg = json_load_file(
svr_cfg.c_str(),
0, &error );
if ( !_svr_cfg ) {
std::string msg( "failed to load file [" );
msg += svr_cfg;
msg += "] json error [";
msg += error.text;
msg += "]";
return ERROR(
-1,
msg );
}
else {
return sanitize_server_config_keys( _svr_cfg );
}
}
// =-=-=-=-=-=-=-
// otherwise, convert the old properties
irods::server_properties& props = irods::server_properties::getInstance();
props.capture_if_needed();
_svr_cfg = json_object();
if ( !_svr_cfg ) {
return ERROR(
SYS_MALLOC_ERR,
"json_object() failed" );
}
std::string s_val;
ret = props.get_property< std::string >( "icatHost", s_val );
if ( ret.ok() ) {
json_object_set( _svr_cfg, "icat_host", json_string( s_val.c_str() ) );
}
ret = props.get_property< std::string >( "KerberosName", s_val );
if ( ret.ok() ) {
json_object_set( _svr_cfg, "kerberos_name", json_string( s_val.c_str() ) );
}
bool b_val = false;
ret = props.get_property< bool >( "pam_no_extend", b_val );
if ( ret.ok() ) {
if ( b_val ) {
json_object_set( _svr_cfg, "pam_no_extend", json_string( "true" ) );
}
else {
json_object_set( _svr_cfg, "pam_no_extend", json_string( "false" ) );
}
}
ret = props.get_property< std::string >( "pam_password_min_time", s_val );
if ( ret.ok() ) {
int min_time = boost::lexical_cast< int >( s_val );
json_object_set( _svr_cfg, "pam_password_min_time", json_integer( min_time ) );
}
ret = props.get_property< std::string >( "pam_password_max_time", s_val );
if ( ret.ok() ) {
int max_time = boost::lexical_cast< int >( s_val );
json_object_set( _svr_cfg, "pam_password_max_time", json_integer( max_time ) );
}
size_t st_val = 0;
ret = props.get_property< size_t>( "pam_password_length", st_val );
if ( ret.ok() ) {
json_object_set( _svr_cfg, "pam_password_length", json_integer( st_val ) );
}
int i_val = 0;
ret = props.get_property< int >( "default_dir_mode", i_val );
if ( ret.ok() ) {
std::string mode = boost::lexical_cast< std::string >( i_val );
json_object_set( _svr_cfg, "default_dir_mode", json_string( mode.c_str() ) );
}
ret = props.get_property< int >( "default_file_mode", i_val );
if ( ret.ok() ) {
std::string mode = boost::lexical_cast< std::string >( i_val );
json_object_set( _svr_cfg, "default_file_mode", json_string( mode.c_str() ) );
}
ret = props.get_property< std::string >( "default_hash_scheme", s_val );
if ( ret.ok() ) {
json_object_set( _svr_cfg, "default_hash_scheme", json_string( s_val.c_str() ) );
}
ret = props.get_property< std::string >( "LocalZoneSID", s_val );
if ( ret.ok() ) {
json_object_set( _svr_cfg, "zone_key", json_string( "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" ) );
}
ret = props.get_property< std::string >( "agent_key", s_val );
if ( ret.ok() ) {
json_object_set( _svr_cfg, "negotiation_key", json_string( "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" ) );
}
ret = props.get_property< std::string >( "match_hash_policy", s_val );
if ( ret.ok() ) {
json_object_set( _svr_cfg, "match_hash_policy", json_string( s_val.c_str() ) );
}
else {
json_object_set( _svr_cfg, "match_hash_policy", json_string( "" ) );
}
ret = props.get_property< std::string >( "reRuleSet", s_val );
if ( ret.ok() ) {
json_t* arr = 0;
ret = make_file_set( s_val, arr );
if ( ret.ok() ) {
json_object_set( _svr_cfg, "re_rulebase_set", arr );
}
}
ret = props.get_property< std::string >( "reFuncMapSet", s_val );
if ( ret.ok() ) {
json_t* arr = 0;
ret = make_file_set( s_val, arr );
if ( ret.ok() ) {
json_object_set( _svr_cfg, "re_function_name_mapping_set", arr );
}
}
ret = props.get_property< std::string >( "reVariableMapSet", s_val );
if ( ret.ok() ) {
json_t* arr = 0;
ret = make_file_set( s_val, arr );
if ( ret.ok() ) {
json_object_set( _svr_cfg, "re_data_variable_mapping_set", arr );
}
}
std::vector< std::string > rem_sids;
ret = props.get_property< std::vector< std::string > >( "RemoteZoneSID", rem_sids );
if ( ret.ok() ) {
json_t* arr = 0;
ret = make_federation_set( rem_sids, arr );
if ( !ret.ok() ) {
irods::log( PASS( ret ) );
}
json_object_set( _svr_cfg, "federation", arr );
}
else {
// may not be federated, but it is required by the spec
json_t* arr = json_array();
json_object_set( _svr_cfg, "federation", arr );
}
return SUCCESS();
} // convert_server_config
irods::error convert_host_access_control(
json_t*& _host_ctrl ) {
std::string cfg_file;
irods::error ret = irods::get_full_path_for_config_file(
HOST_ACCESS_CONTROL_FILE,
cfg_file );
if ( !ret.ok() ) {
return PASS( ret );
}
json_error_t error;
_host_ctrl = json_load_file(
cfg_file.c_str(),
0, &error );
if ( !_host_ctrl ) {
std::string msg( "failed to load file [" );
msg += cfg_file;
msg += "] json error [";
msg += error.text;
msg += "]";
return ERROR(
-1,
msg );
}
return SUCCESS();
} // convert_host_access_control
irods::error convert_irods_host(
json_t*& _irods_host ) {
std::string cfg_file;
irods::error ret = irods::get_full_path_for_config_file(
HOST_CONFIG_FILE,
cfg_file );
if ( !ret.ok() ) {
return PASS( ret );
}
json_error_t error;
_irods_host = json_load_file(
cfg_file.c_str(),
0, &error );
if ( !_irods_host ) {
std::string msg( "failed to load file [" );
msg += cfg_file;
msg += "] json error [";
msg += error.text;
msg += "]";
return ERROR(
-1,
msg );
}
return SUCCESS();
} // convert_irods_host
irods::error convert_service_account(
json_t*& _svc_acct ) {
// =-=-=-=-=-=-=-
// if json file exists, simply load that
std::string env_file( irods::IRODS_HOME_DIRECTORY );
env_file += irods::environment_properties::JSON_ENV_FILE;
if ( fs::exists( env_file ) ) {
json_error_t error;
_svc_acct = json_load_file(
env_file.c_str(),
0, &error );
if ( !_svc_acct ) {
std::string msg( "failed to load file [" );
msg += env_file;
msg += "] json error [";
msg += error.text;
msg += "]";
return ERROR(
-1,
msg );
}
else {
// sanitize the keys
json_object_set(
_svc_acct,
"irods_server_control_plane_key",
json_string( "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" ) );
return SUCCESS();
}
}
// =-=-=-=-=-=-=-
// otherwise, convert the old properties
_svc_acct = json_object();
if ( !_svc_acct ) {
return ERROR(
SYS_MALLOC_ERR,
"json_object() failed" );
}
rodsEnv my_env;
int status = getRodsEnv( &my_env );
if ( status < 0 ) {
return ERROR(
status,
"failed in getRodsEnv" );
}
json_object_set( _svc_acct, "irods_host", json_string( my_env.rodsHost ) );
json_object_set( _svc_acct, "irods_port", json_integer( my_env.rodsPort ) );
json_object_set( _svc_acct, "irods_default_resource", json_string( my_env.rodsDefResource ) );
if ( my_env.rodsServerDn ) {
json_object_set( _svc_acct, "irods_server_dn", json_string( my_env.rodsServerDn ) );
}
else {
json_object_set( _svc_acct, "irods_server_dn", json_string( "" ) );
}
json_object_set( _svc_acct, "irods_log_level", json_integer( my_env.rodsPort ) );
json_object_set( _svc_acct, "irods_authentication_file", json_string( my_env.rodsAuthFile ) );
json_object_set( _svc_acct, "irods_debug", json_string( my_env.rodsDebug ) );
json_object_set( _svc_acct, "irods_home", json_string( my_env.rodsHome ) );
json_object_set( _svc_acct, "irods_cwd", json_string( my_env.rodsCwd ) );
json_object_set( _svc_acct, "irods_authentication_scheme", json_string( my_env.rodsAuthScheme ) );
json_object_set( _svc_acct, "irods_user_name", json_string( my_env.rodsUserName ) );
json_object_set( _svc_acct, "irods_zone_name", json_string( my_env.rodsZone ) );
json_object_set( _svc_acct, "irods_client_server_negotiation", json_string( my_env.rodsClientServerNegotiation ) );
json_object_set( _svc_acct, "irods_client_server_policy", json_string( my_env.rodsClientServerPolicy ) );
json_object_set( _svc_acct, "irods_encryption_key_size", json_integer( my_env.rodsEncryptionKeySize ) );
json_object_set( _svc_acct, "irods_encryption_salt_size", json_integer( my_env.rodsEncryptionSaltSize ) );
json_object_set( _svc_acct, "irods_encryption_num_hash_rounds", json_integer( my_env.rodsEncryptionNumHashRounds ) );
json_object_set( _svc_acct, "irods_encryption_algorithm", json_string( my_env.rodsEncryptionAlgorithm ) );
json_object_set( _svc_acct, "irods_default_hash_scheme", json_string( my_env.rodsDefaultHashScheme ) );
json_object_set( _svc_acct, "irods_match_hash_policy", json_string( my_env.rodsMatchHashPolicy ) );
return SUCCESS();
} // convert_service_account
irods::error add_plugin_type_to_json_array(
const std::string& _plugin_type,
const char* _type_name,
json_t*& _json_array ) {
std::string plugin_home;
irods::error ret = irods::resolve_plugin_path( _plugin_type, plugin_home );
if ( !ret.ok() ) {
return PASS( ret );
}
irods::plugin_name_generator name_gen;
irods::plugin_name_generator::plugin_list_t plugin_list;
ret = name_gen.list_plugins( plugin_home, plugin_list );
if ( !ret.ok() ) {
return PASS( ret );
}
for ( irods::plugin_name_generator::plugin_list_t::iterator itr = plugin_list.begin();
itr != plugin_list.end();
++itr ) {
json_t* plug = json_object();
json_object_set( plug, "name", json_string( itr->c_str() ) );
json_object_set( plug, "type", json_string( _type_name ) );
json_object_set( plug, "version", json_string( "" ) );
json_object_set( plug, "checksum_sha256", json_string( "" ) );
json_array_append( _json_array, plug );
}
return SUCCESS();
}
irods::error get_plugin_array(
json_t*& _plugins ) {
_plugins = json_array();
if ( !_plugins ) {
return ERROR(
SYS_MALLOC_ERR,
"json_object() failed" );
}
irods::error ret = add_plugin_type_to_json_array( irods::PLUGIN_TYPE_RESOURCE, "resource", _plugins );
if ( !ret.ok() ) {
return PASS( ret );
}
#ifdef RODS_CAT
ret = add_plugin_type_to_json_array( irods::PLUGIN_TYPE_DATABASE, "database", _plugins );
if ( !ret.ok() ) {
return PASS( ret );
}
#endif // RODS_CAT
ret = add_plugin_type_to_json_array( irods::PLUGIN_TYPE_AUTHENTICATION, "authentication", _plugins );
if ( !ret.ok() ) {
return PASS( ret );
}
ret = add_plugin_type_to_json_array( irods::PLUGIN_TYPE_NETWORK, "network", _plugins );
if ( !ret.ok() ) {
return PASS( ret );
}
ret = add_plugin_type_to_json_array( irods::PLUGIN_TYPE_API, "api", _plugins );
if ( !ret.ok() ) {
return PASS( ret );
}
ret = add_plugin_type_to_json_array( irods::PLUGIN_TYPE_MICROSERVICE, "microservice", _plugins );
if ( !ret.ok() ) {
return PASS( ret );
}
return SUCCESS();
} // get_plugin_array
irods::error get_uname_string(
std::string& _str ) {
struct utsname os_name;
memset( &os_name, 0, sizeof( os_name ) );
const int status = uname( &os_name );
if ( status != 0 ) {
return ERROR(
status,
"uname failed" );
}
_str.clear();
_str += "SYS_NAME=" ;
_str += os_name.sysname;
_str += ";NODE_NAME=";
_str += os_name.nodename;
_str += ";RELEASE=";
_str += os_name.release;
_str += ";VERSION=";
_str += os_name.version;
_str += ";MACHINE=";
_str += os_name.machine;
return SUCCESS();
} // get_uname_string
irods::error get_host_system_information(
json_t*& _host_system_information ) {
_host_system_information = json_object();
if ( !_host_system_information ) {
return ERROR(
SYS_MALLOC_ERR,
"json_object() failed" );
}
std::string uname_string;
irods::error ret = get_uname_string( uname_string );
if ( !ret.ok() ) {
irods::log( PASS( ret ) );
}
json_object_set( _host_system_information, "uname", json_string( uname_string.c_str() ) );
std::vector<std::string> args;
args.push_back( "os_distribution_name" );
std::string os_distribution_name;
ret = get_script_output_single_line( "python", "system_identification.py", args, os_distribution_name );
if ( !ret.ok() ) {
irods::log( PASS( ret ) );
}
json_object_set( _host_system_information, "os_distribution_name", json_string( os_distribution_name.c_str() ) );
args.clear();
args.push_back( "os_distribution_version" );
std::string os_distribution_version;
ret = get_script_output_single_line( "python", "system_identification.py", args, os_distribution_version );
if ( !ret.ok() ) {
irods::log( PASS( ret ) );
}
json_object_set( _host_system_information, "os_distribution_version", json_string( os_distribution_version.c_str() ) );
return SUCCESS();
} // get_host_system_information
irods::error get_resource_array(
json_t*& _resources ) {
_resources = json_array();
if ( !_resources ) {
return ERROR(
SYS_MALLOC_ERR,
"json_array() failed" );
}
rodsEnv my_env;
int status = getRodsEnv( &my_env );
if ( status < 0 ) {
return ERROR(
status,
"failed in getRodsEnv" );
}
const std::string local_host_name = my_env.rodsHost;
for ( irods::resource_manager::iterator itr = resc_mgr.begin();
itr != resc_mgr.end();
++itr ) {
irods::resource_ptr resc = itr->second;
rodsServerHost_t* tmp_host = 0;
irods::error ret = resc->get_property< rodsServerHost_t* >(
irods::RESOURCE_HOST,
tmp_host );
if ( !ret.ok() ) {
irods::log( PASS( ret ) );
continue;
}
if ( !tmp_host ) {
rodsLog( LOG_ERROR, "null tmp_host in get_resource_array" );
continue;
}
if ( LOCAL_HOST != tmp_host->localFlag ) {
continue;
}
std::string host_name;
ret = resc->get_property< std::string >( irods::RESOURCE_LOCATION, host_name );
if ( !ret.ok() ) {
irods::log( PASS( ret ) );
continue;
}
std::string name;
ret = resc->get_property< std::string >( irods::RESOURCE_NAME, name );
if ( !ret.ok() ) {
irods::log( PASS( ret ) );
continue;
}
if ( host_name != irods::EMPTY_RESC_HOST &&
std::string::npos == host_name.find( local_host_name ) &&
std::string::npos == local_host_name.find( host_name ) ) {
rodsLog(
LOG_DEBUG,
"get_resource_array - skipping non-local resource [%s] on [%s]",
name.c_str(),
host_name.c_str() );
continue;
}
std::string type;
ret = resc->get_property< std::string >( irods::RESOURCE_TYPE, type );
if ( !ret.ok() ) {
irods::log( PASS( ret ) );
continue;
}
std::string vault;
ret = resc->get_property< std::string >( irods::RESOURCE_PATH, vault );
if ( !ret.ok() ) {
irods::log( PASS( ret ) );
continue;
}
std::string context;
ret = resc->get_property< std::string >( irods::RESOURCE_CONTEXT, context );
if ( !ret.ok() ) {
irods::log( PASS( ret ) );
continue;
}
std::string parent;
ret = resc->get_property< std::string >( irods::RESOURCE_PARENT, parent );
if ( !ret.ok() ) {
irods::log( PASS( ret ) );
continue;
}
std::string children;
ret = resc->get_property< std::string >( irods::RESOURCE_CHILDREN, children );
if ( !ret.ok() ) {
irods::log( PASS( ret ) );
continue;
}
std::string object_count;
ret = resc->get_property< std::string >( irods::RESOURCE_OBJCOUNT, object_count );
if ( !ret.ok() ) {
irods::log( PASS( ret ) );
continue;
}
long freespace = 0;
ret = resc->get_property< long >( irods::RESOURCE_FREESPACE, freespace );
if ( !ret.ok() ) {
irods::log( PASS( ret ) );
continue;
}
int status = 0;
ret = resc->get_property< int >( irods::RESOURCE_STATUS, status );
if ( !ret.ok() ) {
irods::log( PASS( ret ) );
continue;
}
json_t* entry = json_object();
if ( !entry ) {
return ERROR(
SYS_MALLOC_ERR,
"failed to alloc entry" );
}
json_object_set( entry, "name", json_string( name.c_str() ) );
json_object_set( entry, "type", json_string( type.c_str() ) );
json_object_set( entry, "host", json_string( host_name.c_str() ) );
json_object_set( entry, "vault_path", json_string( vault.c_str() ) );
json_object_set( entry, "context_string", json_string( context.c_str() ) );
json_object_set( entry, "parent_resource", json_string( parent.c_str() ) );
int count = boost::lexical_cast< int >( object_count );
json_object_set( entry, "object_count", json_integer( count ) );
std::stringstream fs; fs << freespace;
json_object_set( entry, "free_space", json_string( fs.str().c_str() ) );
if ( status != INT_RESC_STATUS_DOWN ) {
json_object_set( entry, "status", json_string( "up" ) );
}
else {
json_object_set( entry, "status", json_string( "down" ) );
}
json_array_append( _resources, entry );
} // for itr
return SUCCESS();
} // get_resource_array
irods::error get_file_contents(
const std::string& _fn,
std::string& _cont ) {
std::ifstream f( _fn.c_str() );
std::stringstream ss;
ss << f.rdbuf();
f.close();
std::string in_s = ss.str();
namespace bitr = boost::archive::iterators;
std::stringstream o_str;
typedef
bitr::base64_from_binary < // convert binary values to base64 characters
bitr::transform_width < // retrieve 6 bit integers from a sequence of 8 bit bytes
const char *,
6,
8
>
>
base64_text; // compose all the above operations in to a new iterator
std::copy(
base64_text( in_s.c_str() ),
base64_text( in_s.c_str() + in_s.size() ),
bitr::ostream_iterator<char>( o_str )
);
_cont = o_str.str();
size_t pad = in_s.size() % 3;
_cont.insert( _cont.size(), ( 3 - pad ) % 3, '=' );
return SUCCESS();
} // get_file_contents
irods::error get_config_dir(
json_t*& _cfg_dir ) {
namespace fs = boost::filesystem;
_cfg_dir = json_object();
if ( !_cfg_dir ) {
return ERROR(
SYS_MALLOC_ERR,
"json_object() failed" );
}
json_t* file_arr = json_array();
if ( !file_arr ) {
return ERROR(
SYS_MALLOC_ERR,
"json_array() failed" );
}
std::string cfg_file;
irods::error ret = irods::get_full_path_for_config_file( SERVER_CONFIG_FILE, cfg_file );
if ( !ret.ok() ) {
irods::error ret = irods::get_full_path_for_config_file( LEGACY_SERVER_CONFIG_FILE, cfg_file );
if ( !ret.ok() ) {
return PASS( ret );
}
}
fs::path p( cfg_file );
std::string config_dir = p.parent_path().string();
json_object_set( _cfg_dir, "path", json_string( config_dir.c_str() ) );
for ( fs::directory_iterator itr( config_dir );
itr != fs::directory_iterator();
++itr ) {
if ( fs::is_regular_file( itr->path() ) ) {
const fs::path& p = itr->path();
const std::string& name = p.string();
if ( std::string::npos != name.find( SERVER_CONFIG_FILE ) ||
std::string::npos != name.find( LEGACY_SERVER_CONFIG_FILE ) ||
std::string::npos != name.find( HOST_CONFIG_FILE ) ||
std::string::npos != name.find( HOST_ACCESS_CONTROL_FILE ) ||
std::string::npos != name.find( "irods.config" )
) {
continue;
}
json_t* f_obj = json_object();
if ( !f_obj ) {
return ERROR(
SYS_MALLOC_ERR,
"failed to allocate f_obj" );
}
json_object_set( f_obj, "name", json_string( name.c_str() ) );
std::string contents;
ret = get_file_contents( name, contents );
if ( !ret.ok() ) {
irods::log( PASS( ret ) );
continue;
}
json_object_set(
f_obj,
"contents",
json_string( contents.c_str() ) );
json_array_append( file_arr, f_obj );
}
} // for itr
json_object_set( _cfg_dir, "files", file_arr );
return SUCCESS();
} // get_config_dir
irods::error load_version_file(
json_t*& _version ) {
// =-=-=-=-=-=-=-
// if json file exists, simply load that
std::string version_file( irods::IRODS_HOME_DIRECTORY );
version_file += "VERSION.json";
if ( fs::exists( version_file ) ) {
json_error_t error;
_version = json_load_file(
version_file.c_str(),
0, &error );
if ( !_version ) {
std::string msg( "failed to load file [" );
msg += version_file;
msg += "] json error [";
msg += error.text;
msg += "]";
return ERROR(
-1,
msg );
}
else {
return SUCCESS();
}
}
return SUCCESS();
} // load_version_file
#ifdef RODS_CAT
irods::error get_database_config(
json_t*& _db_cfg ) {
// =-=-=-=-=-=-=-
// if json file exists, simply load that
std::string db_cfg;
irods::error ret = irods::get_full_path_for_config_file(
"database_config.json",
db_cfg );
if ( ret.ok() && fs::exists( db_cfg ) ) {
json_error_t error;
_db_cfg = json_load_file(
db_cfg.c_str(),
0, &error );
if ( !_db_cfg ) {
std::string msg( "failed to load file [" );
msg += db_cfg;
msg += "] json error [";
msg += error.text;
msg += "]";
return ERROR(
-1,
msg );
}
else {
// sanitize passwords
json_object_set( _db_cfg, "db_password", json_string( "XXXXX" ) );
return SUCCESS();
}
}
irods::server_properties& props = irods::server_properties::getInstance();
props.capture_if_needed();
_db_cfg = json_object();
if ( !_db_cfg ) {
return ERROR(
SYS_MALLOC_ERR,
"allocation of json_object failed" );
}
std::string s_val;
ret = props.get_property< std::string >(
"catalog_database_type",
s_val );
if ( ret.ok() ) {
json_object_set(
_db_cfg,
"catalog_database_type",
json_string( s_val.c_str() ) );
}
ret = props.get_property< std::string >( "DBUsername", s_val );
if ( ret.ok() ) {
json_object_set( _db_cfg, "db_username", json_string( s_val.c_str() ) );
}
json_object_set( _db_cfg, "db_password", json_string( "XXXXX" ) );
return SUCCESS();
} // get_database_config
#endif
int _rsServerReport(
rsComm_t* _comm,
bytesBuf_t** _bbuf ) {
if ( !_comm || !_bbuf ) {
rodsLog(
LOG_ERROR,
"_rsServerReport: null comm or bbuf" );
return SYS_INVALID_INPUT_PARAM;
}
( *_bbuf ) = ( bytesBuf_t* ) malloc( sizeof( **_bbuf ) );
if ( !( *_bbuf ) ) {
rodsLog(
LOG_ERROR,
"_rsServerReport: failed to allocate _bbuf" );
return SYS_MALLOC_ERR;
}
json_t* resc_svr = json_object();
if ( !resc_svr ) {
rodsLog(
LOG_ERROR,
"_rsServerReport: failed to allocate resc_svr" );
return SYS_MALLOC_ERR;
}
json_t* version = 0;
irods::error ret = load_version_file(
version );
if ( !ret.ok() ) {
irods::log( PASS( ret ) );
}
json_object_set( resc_svr, "version", version );
json_t* host_system_information = 0;
ret = get_host_system_information( host_system_information );
if ( !ret.ok() ) {
irods::log( PASS( ret ) );
}
json_object_set( resc_svr, "host_system_information", host_system_information );
json_t* svr_cfg = 0;
ret = convert_server_config( svr_cfg );
if ( !ret.ok() ) {
irods::log( PASS( ret ) );
}
json_object_set( resc_svr, "server_config", svr_cfg );
json_t* host_ctrl = 0;
ret = convert_host_access_control( host_ctrl );
if ( !ret.ok() ) {
irods::log( PASS( ret ) );
}
json_object_set( resc_svr, "host_access_control_config", host_ctrl );
json_t* irods_host = 0;
ret = convert_irods_host( irods_host );
if ( !ret.ok() ) {
irods::log( PASS( ret ) );
}
json_object_set( resc_svr, "hosts_config", irods_host );
json_t* svc_acct = 0;
ret = convert_service_account( svc_acct );
if ( !ret.ok() ) {
irods::log( PASS( ret ) );
}
json_object_set( resc_svr, "service_account_environment", svc_acct );
json_t* plugins = 0;
ret = get_plugin_array( plugins );
if ( !ret.ok() ) {
irods::log( PASS( ret ) );
}
json_object_set( resc_svr, "plugins", plugins );
json_t* resources = 0;
ret = get_resource_array( resources );
if ( !ret.ok() ) {
irods::log( PASS( ret ) );
}
json_object_set( resc_svr, "resources", resources );
json_t* cfg_dir = 0;
ret = get_config_dir( cfg_dir );
if ( !ret.ok() ) {
irods::log( PASS( ret ) );
}
json_object_set( resc_svr, "configuration_directory", cfg_dir );
#ifdef RODS_CAT
json_t* db_cfg = 0;
ret = get_database_config( db_cfg );
if ( !ret.ok() ) {
irods::log( PASS( ret ) );
}
json_object_set( resc_svr, "database_config", db_cfg );
#endif
char* tmp_buf = json_dumps( resc_svr, JSON_INDENT( 4 ) );
// *SHOULD* free All The Things...
json_decref( resc_svr );
( *_bbuf )->buf = tmp_buf;
( *_bbuf )->len = strlen( tmp_buf );
return 0;
} // _rsServerReport
| 28.580753 | 123 | 0.555367 | cyverse |
Subsets and Splits