blob_id
stringlengths
40
40
directory_id
stringlengths
40
40
path
stringlengths
3
264
content_id
stringlengths
40
40
detected_licenses
listlengths
0
85
license_type
stringclasses
2 values
repo_name
stringlengths
5
140
snapshot_id
stringlengths
40
40
revision_id
stringlengths
40
40
branch_name
stringclasses
905 values
visit_date
timestamp[us]date
2015-08-09 11:21:18
2023-09-06 10:45:07
revision_date
timestamp[us]date
1997-09-14 05:04:47
2023-09-17 19:19:19
committer_date
timestamp[us]date
1997-09-14 05:04:47
2023-09-06 06:22:19
github_id
int64
3.89k
681M
star_events_count
int64
0
209k
fork_events_count
int64
0
110k
gha_license_id
stringclasses
22 values
gha_event_created_at
timestamp[us]date
2012-06-07 00:51:45
2023-09-14 21:58:39
gha_created_at
timestamp[us]date
2008-03-27 23:40:48
2023-08-21 23:17:38
gha_language
stringclasses
141 values
src_encoding
stringclasses
34 values
language
stringclasses
1 value
is_vendor
bool
1 class
is_generated
bool
2 classes
length_bytes
int64
3
10.4M
extension
stringclasses
115 values
content
stringlengths
3
10.4M
authors
listlengths
1
1
author_id
stringlengths
0
158
9d5d64f342dc2448c92678ee12119c58f2aef7b0
b22588340d7925b614a735bbbde1b351ad657ffc
/athena/PhysicsAnalysis/DerivationFramework/DerivationFrameworkMuons/DerivationFrameworkMuons/CellsOfMuon.h
f22392753a6033d97d2833be75b263a2fbf58ec9
[]
no_license
rushioda/PIXELVALID_athena
90befe12042c1249cbb3655dde1428bb9b9a42ce
22df23187ef85e9c3120122c8375ea0e7d8ea440
refs/heads/master
2020-12-14T22:01:15.365949
2020-01-19T03:59:35
2020-01-19T03:59:35
234,836,993
1
0
null
null
null
null
UTF-8
C++
false
false
1,021
h
/* Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration */ // ====================================================================== // Cells of Muon // dongliang.zhang@cern.ch // Given an xAOD::Muon and an CaloCellContainer, checks // which calo cells are associated with muon. // Sets a mask accordingly. Intended for thinning use. // ====================================================================== #pragma once #include "xAODMuon/Muon.h" #include "CaloEvent/CaloCellContainer.h" #include "CaloEvent/CaloClusterCellLink.h" namespace DerivationFramework { struct CellsOfMuon{ void select(const xAOD::Muon* mu, std::vector<bool> &mask) { auto cluster = mu->cluster(); if(cluster){ const CaloClusterCellLink* links=cluster->getCellLinks(); unsigned int i(0); CaloClusterCellLink::const_iterator c=links->begin(); CaloClusterCellLink::const_iterator e=links->end(); for(; c!=e; ++c, i++) mask[c.index()] = true; } } }; }
[ "rushioda@lxplus754.cern.ch" ]
rushioda@lxplus754.cern.ch
79ebb42eab652cef949195353578e6787e38a823
54f352a242a8ad6ff5516703e91da61e08d9a9e6
/Source Codes/CodeJamData/09/51/9.cpp
f449bb14508796c414359af4304000372dd95efe
[]
no_license
Kawser-nerd/CLCDSA
5cbd8a4c3f65173e4e8e0d7ed845574c4770c3eb
aee32551795763b54acb26856ab239370cac4e75
refs/heads/master
2022-02-09T11:08:56.588303
2022-01-26T18:53:40
2022-01-26T18:53:40
211,783,197
23
9
null
null
null
null
UTF-8
C++
false
false
13,395
cpp
#include <vector> #include <list> #include <map> #include <set> #include <deque> #include <queue> #include <stack> #include <bitset> #include <algorithm> #include <functional> #include <numeric> #include <utility> #include <sstream> #include <iostream> #include <iomanip> #include <cstdio> #include <cmath> #include <cstdlib> #include <cctype> #include <string> #include <cstring> #include <cstdio> #include <cmath> #include <cstdlib> #include <ctime> using namespace std; //BEGINTEMPLATE_BY_ACRUSH_TOPCODER #define SIZE(X) ((int)(X.size()))//NOTES:SIZE( #define LENGTH(X) ((int)(X.length()))//NOTES:LENGTH( #define MP(X,Y) make_pair(X,Y)//NOTES:MP( typedef long long int64;//NOTES:int64 typedef unsigned long long uint64;//NOTES:uint64 #define two(X) (1<<(X))//NOTES:two( #define twoL(X) (((int64)(1))<<(X))//NOTES:twoL( #define contain(S,X) (((S)&two(X))!=0)//NOTES:contain( #define containL(S,X) (((S)&twoL(X))!=0)//NOTES:containL( const double pi=acos(-1.0);//NOTES:pi const double eps=1e-11;//NOTES:eps template<class T> inline void checkmin(T &a,T b){if(b<a) a=b;}//NOTES:checkmin( template<class T> inline void checkmax(T &a,T b){if(b>a) a=b;}//NOTES:checkmax( template<class T> inline T sqr(T x){return x*x;}//NOTES:sqr typedef pair<int,int> ipair;//NOTES:ipair template<class T> inline T lowbit(T n){return (n^(n-1))&n;}//NOTES:lowbit( template<class T> inline int countbit(T n){return (n==0)?0:(1+countbit(n&(n-1)));}//NOTES:countbit( //Numberic Functions template<class T> inline T gcd(T a,T b)//NOTES:gcd( {if(a<0)return gcd(-a,b);if(b<0)return gcd(a,-b);return (b==0)?a:gcd(b,a%b);} template<class T> inline T lcm(T a,T b)//NOTES:lcm( {if(a<0)return lcm(-a,b);if(b<0)return lcm(a,-b);return a*(b/gcd(a,b));} template<class T> inline T euclide(T a,T b,T &x,T &y)//NOTES:euclide( {if(a<0){T d=euclide(-a,b,x,y);x=-x;return d;} if(b<0){T d=euclide(a,-b,x,y);y=-y;return d;} if(b==0){x=1;y=0;return a;}else{T d=euclide(b,a%b,x,y);T t=x;x=y;y=t-(a/b)*y;return d;}} template<class T> inline vector<pair<T,int> > factorize(T n)//NOTES:factorize( {vector<pair<T,int> > R;for (T i=2;n>1;){if (n%i==0){int C=0;for (;n%i==0;C++,n/=i);R.push_back(make_pair(i,C));} i++;if (i>n/i) i=n;}if (n>1) R.push_back(make_pair(n,1));return R;} template<class T> inline bool isPrimeNumber(T n)//NOTES:isPrimeNumber( {if(n<=1)return false;for (T i=2;i*i<=n;i++) if (n%i==0) return false;return true;} template<class T> inline T eularFunction(T n)//NOTES:eularFunction( {vector<pair<T,int> > R=factorize(n);T r=n;for (int i=0;i<R.size();i++)r=r/R[i].first*(R[i].first-1);return r;} //Matrix Operations const int MaxMatrixSize=40;//NOTES:MaxMatrixSize template<class T> inline void showMatrix(int n,T A[MaxMatrixSize][MaxMatrixSize])//NOTES:showMatrix( {for (int i=0;i<n;i++){for (int j=0;j<n;j++)cout<<A[i][j];cout<<endl;}} template<class T> inline T checkMod(T n,T m) {return (n%m+m)%m;}//NOTES:checkMod( template<class T> inline void identityMatrix(int n,T A[MaxMatrixSize][MaxMatrixSize])//NOTES:identityMatrix( {for (int i=0;i<n;i++) for (int j=0;j<n;j++) A[i][j]=(i==j)?1:0;} template<class T> inline void addMatrix(int n,T C[MaxMatrixSize][MaxMatrixSize],T A[MaxMatrixSize][MaxMatrixSize],T B[MaxMatrixSize][MaxMatrixSize])//NOTES:addMatrix( {for (int i=0;i<n;i++) for (int j=0;j<n;j++) C[i][j]=A[i][j]+B[i][j];} template<class T> inline void subMatrix(int n,T C[MaxMatrixSize][MaxMatrixSize],T A[MaxMatrixSize][MaxMatrixSize],T B[MaxMatrixSize][MaxMatrixSize])//NOTES:subMatrix( {for (int i=0;i<n;i++) for (int j=0;j<n;j++) C[i][j]=A[i][j]-B[i][j];} template<class T> inline void mulMatrix(int n,T C[MaxMatrixSize][MaxMatrixSize],T _A[MaxMatrixSize][MaxMatrixSize],T _B[MaxMatrixSize][MaxMatrixSize])//NOTES:mulMatrix( { T A[MaxMatrixSize][MaxMatrixSize],B[MaxMatrixSize][MaxMatrixSize]; for (int i=0;i<n;i++) for (int j=0;j<n;j++) A[i][j]=_A[i][j],B[i][j]=_B[i][j],C[i][j]=0; for (int i=0;i<n;i++) for (int j=0;j<n;j++) for (int k=0;k<n;k++) C[i][j]+=A[i][k]*B[k][j];} template<class T> inline void addModMatrix(int n,T m,T C[MaxMatrixSize][MaxMatrixSize],T A[MaxMatrixSize][MaxMatrixSize],T B[MaxMatrixSize][MaxMatrixSize])//NOTES:addModMatrix( {for (int i=0;i<n;i++) for (int j=0;j<n;j++) C[i][j]=checkMod(A[i][j]+B[i][j],m);} template<class T> inline void subModMatrix(int n,T m,T C[MaxMatrixSize][MaxMatrixSize],T A[MaxMatrixSize][MaxMatrixSize],T B[MaxMatrixSize][MaxMatrixSize])//NOTES:subModMatrix( {for (int i=0;i<n;i++) for (int j=0;j<n;j++) C[i][j]=checkMod(A[i][j]-B[i][j],m);} template<class T> inline T multiplyMod(T a,T b,T m) {return (T)((((int64)(a)*(int64)(b)%(int64)(m))+(int64)(m))%(int64)(m));}//NOTES:multiplyMod( template<class T> inline void mulModMatrix(int n,T m,T C[MaxMatrixSize][MaxMatrixSize],T _A[MaxMatrixSize][MaxMatrixSize],T _B[MaxMatrixSize][MaxMatrixSize])//NOTES:mulModMatrix( { T A[MaxMatrixSize][MaxMatrixSize],B[MaxMatrixSize][MaxMatrixSize]; for (int i=0;i<n;i++) for (int j=0;j<n;j++) A[i][j]=_A[i][j],B[i][j]=_B[i][j],C[i][j]=0; for (int i=0;i<n;i++) for (int j=0;j<n;j++) for (int k=0;k<n;k++) C[i][j]=(C[i][j]+multiplyMod(A[i][k],B[k][j],m))%m;} template<class T> inline T powerMod(T p,int e,T m)//NOTES:powerMod( {if(e==0)return 1%m;else if(e%2==0){T t=powerMod(p,e/2,m);return multiplyMod(t,t,m);}else return multiplyMod(powerMod(p,e-1,m),p,m);} //Point&Line double dist(double x1,double y1,double x2,double y2){return sqrt(sqr(x1-x2)+sqr(y1-y2));}//NOTES:dist( double distR(double x1,double y1,double x2,double y2){return sqr(x1-x2)+sqr(y1-y2);}//NOTES:distR( template<class T> T cross(T x0,T y0,T x1,T y1,T x2,T y2){return (x1-x0)*(y2-y0)-(x2-x0)*(y1-y0);}//NOTES:cross( int crossOper(double x0,double y0,double x1,double y1,double x2,double y2)//NOTES:crossOper( {double t=(x1-x0)*(y2-y0)-(x2-x0)*(y1-y0);if (fabs(t)<=eps) return 0;return (t<0)?-1:1;} bool isIntersect(double x1,double y1,double x2,double y2,double x3,double y3,double x4,double y4)//NOTES:isIntersect( {return crossOper(x1,y1,x2,y2,x3,y3)*crossOper(x1,y1,x2,y2,x4,y4)<0 && crossOper(x3,y3,x4,y4,x1,y1)*crossOper(x3,y3,x4,y4,x2,y2)<0;} bool isMiddle(double s,double m,double t){return fabs(s-m)<=eps || fabs(t-m)<=eps || (s<m)!=(t<m);}//NOTES:isMiddle( //Translator bool isUpperCase(char c){return c>='A' && c<='Z';}//NOTES:isUpperCase( bool isLowerCase(char c){return c>='a' && c<='z';}//NOTES:isLowerCase( bool isLetter(char c){return c>='A' && c<='Z' || c>='a' && c<='z';}//NOTES:isLetter( bool isDigit(char c){return c>='0' && c<='9';}//NOTES:isDigit( char toLowerCase(char c){return (isUpperCase(c))?(c+32):c;}//NOTES:toLowerCase( char toUpperCase(char c){return (isLowerCase(c))?(c-32):c;}//NOTES:toUpperCase( template<class T> string toString(T n){ostringstream ost;ost<<n;ost.flush();return ost.str();}//NOTES:toString( int toInt(string s){int r=0;istringstream sin(s);sin>>r;return r;}//NOTES:toInt( int64 toInt64(string s){int64 r=0;istringstream sin(s);sin>>r;return r;}//NOTES:toInt64( double toDouble(string s){double r=0;istringstream sin(s);sin>>r;return r;}//NOTES:toDouble( template<class T> void stoa(string s,int &n,T A[]){n=0;istringstream sin(s);for(T v;sin>>v;A[n++]=v);}//NOTES:stoa( template<class T> void atos(int n,T A[],string &s){ostringstream sout;for(int i=0;i<n;i++){if(i>0)sout<<' ';sout<<A[i];}s=sout.str();}//NOTES:atos( template<class T> void atov(int n,T A[],vector<T> &vi){vi.clear();for (int i=0;i<n;i++) vi.push_back(A[i]);}//NOTES:atov( template<class T> void vtoa(vector<T> vi,int &n,T A[]){n=vi.size();for (int i=0;i<n;i++)A[i]=vi[i];}//NOTES:vtoa( template<class T> void stov(string s,vector<T> &vi){vi.clear();istringstream sin(s);for(T v;sin>>v;vi.push_bakc(v));}//NOTES:stov( template<class T> void vtos(vector<T> vi,string &s){ostringstream sout;for (int i=0;i<vi.size();i++){if(i>0)sout<<' ';sout<<vi[i];}s=sout.str();}//NOTES:vtos( //Fraction template<class T> struct Fraction{T a,b;Fraction(T a=0,T b=1);string toString();};//NOTES:Fraction template<class T> Fraction<T>::Fraction(T a,T b){T d=gcd(a,b);a/=d;b/=d;if (b<0) a=-a,b=-b;this->a=a;this->b=b;} template<class T> string Fraction<T>::toString(){ostringstream sout;sout<<a<<"/"<<b;return sout.str();} template<class T> Fraction<T> operator+(Fraction<T> p,Fraction<T> q){return Fraction<T>(p.a*q.b+q.a*p.b,p.b*q.b);} template<class T> Fraction<T> operator-(Fraction<T> p,Fraction<T> q){return Fraction<T>(p.a*q.b-q.a*p.b,p.b*q.b);} template<class T> Fraction<T> operator*(Fraction<T> p,Fraction<T> q){return Fraction<T>(p.a*q.a,p.b*q.b);} template<class T> Fraction<T> operator/(Fraction<T> p,Fraction<T> q){return Fraction<T>(p.a*q.b,p.b*q.a);} //ENDTEMPLATE_BY_ACRUSH_TOPCODER struct Point { int x,y; }; bool operator<(const Point &a,const Point &b) { return a.x<b.x || a.x==b.x && a.y<b.y; } Point B[10],P[10]; int nB,nP,n,m; int x[6],y[6],father[6]; char mapG[15][15]; int A[15][15]; map<string,int> M; vector<string> Q; int bx[6],by[6],mapH[15][15]; string src,dest; bool flag; int current_step; int getfather(int v) { return (father[v]<0)?v:(father[v]=getfather(father[v])); } void init() { scanf("%d%d",&n,&m); for (int i=0; i<n; i++) scanf("%s",mapG[i]); } string getId(Point A[],int len) { string R=""; for (int i=0;i<len;i++) { if (A[i].x<10) R=R+"0"+(char)(A[i].x+'0'); if (A[i].x==10) R=R+"10"; if (A[i].x==11) R=R+"11"; if (A[i].y<10) R=R+"0"+(char)(A[i].y+'0'); if (A[i].y==10) R=R+"10"; if (A[i].y==11) R=R+"11"; } return R; } bool checkIt(int n) { for (int i=0;i<n;i++) father[i]=-1; for (int i=0;i<n;i++) for (int j=i+1;j<n;j++) if (abs(bx[i]-bx[j])+abs(by[i]-by[j])==1) { int u=getfather(i),v=getfather(j); if (u!=v) father[u]=v; } for (int i=0; i<n; i++) if (getfather(i)!=getfather(0)) return false; return true; } void push(int K) { if (!flag && !checkIt(K)) return; int x[6],y[6]; for (int i=0;i<K;i++) x[i]=bx[i],y[i]=by[i]; for (int i=0;i<K;i++) for (int j=i+1;j<K;j++) if (x[j]<x[i] || (x[j]==x[i] && y[j]<y[i])) { swap(x[i],x[j]); swap(y[i],y[j]); } int step=current_step+1; string state=""; for (int i=0;i<K;i++) { if (x[i]<10) state=state+"0"+(char)(x[i]+'0'); if (x[i]==10) state=state+"10"; if (x[i]==11) state=state+"11"; if (y[i]<10) state=state+"0"+(char)(y[i]+'0'); if (y[i]==10) state=state+"10"; if (y[i]==11) state=state+"11"; } if (M.find(state)!=M.end()) return; M.insert(make_pair(state, step)); Q.push_back(state); } void BFS(string state) { memset(mapH,0,sizeof(mapH)); int K=LENGTH(state)/4; for (int i=0;i<K;i++) { bx[i]=(state[i*4]-'0')*10+state[i*4+1]-'0'; by[i]=(state[i*4+2]-'0')*10+state[i*4+3]-'0'; mapH[bx[i]][by[i]]=1; } for (int i=0;i<K;i++) { bool isGoodX=false; bool isGoodY=false; if (bx[i]>0 && bx[i]<n-1 && A[bx[i]-1][by[i]]==0 && A[bx[i]+1][by[i]]==0 && mapH[bx[i]-1][by[i]]==0 && mapH[bx[i]+1][by[i]]==0) isGoodX=true; if (by[i]>0 && by[i]<m-1 && A[bx[i]][by[i]-1]==0 && A[bx[i]][by[i]+1]==0 && mapH[bx[i]][by[i]-1]==0 && mapH[bx[i]][by[i]+1]==0) isGoodY=true; if (isGoodX) { bx[i]--; push(K); bx[i]++; bx[i]++; push(K); bx[i]--; } if (isGoodY) { by[i]--; push(K); by[i]++; by[i]++; push(K); by[i]--; } } } bool checkIt(string state) { int n=LENGTH(state)/4; for (int i=0;i<n;i++) { x[i]=(state[i*4]-'0')*10+state[i*4+1]-'0'; y[i]=(state[i*4+2]-'0')*10+state[i*4+3]-'0'; father[i]=-1; } for (int i=0; i<n; i++) for (int j=i+1; j<n; j++) if (abs(x[i]-x[j])+abs(y[i]-y[j])==1) { int x=getfather(i); int y=getfather(j); if (x!=y) father[x]=y; } for (int i=0; i<n; i++) if (getfather(i)!=getfather(0)) return false; return true; } int solve() { for (int i=0;i<n;i++) for (int j=0;j<m;j++) { if (mapG[i][j]=='.') A[i][j]=0; if (mapG[i][j]=='#') A[i][j]=-1; if (mapG[i][j]=='x') A[i][j]=2; if (mapG[i][j]=='o') A[i][j]=1; if (mapG[i][j]=='w') A[i][j]=3; } M.clear(); Q.clear(); nB=nP=0; for (int i=0;i<n;i++) for (int j=0;j<m;j++) if (A[i][j]>0) { if ((A[i][j]&1)==1) B[nB].x=i,B[nB++].y=j; if ((A[i][j]&2)==2) P[nP].x=i,P[nP++].y=j; if (A[i][j]>0) A[i][j]=0; } src=dest=""; sort(B,B+nB); sort(P,P+nP); if (nB!=nP) return -1; src=getId(B,nB); dest=getId(P,nP); Q.push_back(src); M.insert(make_pair(src, 0)); for (int cl=0;cl<SIZE(Q);cl++) { src=Q[cl]; if (src==dest) return M[src]; current_step=M[src]; flag=false; if (checkIt(src)) flag=true; BFS(src); } return -1; } int main() { // freopen("A.in","r",stdin); // freopen("A-small-attempt0.in","r",stdin);freopen("A-small-attempt0.out","w",stdout); // freopen("A-small-attempt1.in","r",stdin);freopen("A-small-attempt1.out","w",stdout); freopen("A-large.in","r",stdin);freopen("A-large.out","w",stdout); int testcase; scanf("%d",&testcase); for (int caseId=1;caseId<=testcase;caseId++) { printf("Case #%d: ",caseId); init(); int ret=solve(); printf("%d\n",ret); fflush(stdout); } return 0; }
[ "kwnafi@yahoo.com" ]
kwnafi@yahoo.com
e9cd210fe8c80ffee4a571ae0f1126b7304d88eb
d70f1ff10000f42463160ecfbb5dc4a11801a0b8
/Cetvrtak/Vjezbe06/map.cpp
f01f0e6525a07e04694d12376946bf3e34c05696
[]
no_license
jvujcic/RP1
4b5b7515faf390380b373c746a0e9a4d7dada1ec
557d2edb76d336e713dcf3e2402b6721fbc69083
refs/heads/master
2021-01-10T21:11:47.051942
2015-05-28T12:09:41
2015-05-28T12:09:41
31,650,233
0
0
null
null
null
null
UTF-8
C++
false
false
1,151
cpp
#include <iostream> #include <map> using namespace std; int main() { map<int, string> M; M[5] = "pmf"; M[1] = "rp1"; map<string, int> M1; M1["pmf"] = 11; M1["rp"] = 2; M1["rp"] = 3; M1["a"] = 11; M1["abc"]; // postavi na nulu cout << M[5] << endl; cout << M[2] << endl; // prazan string cout << M1["b"] << endl; map<string, int>::iterator it; it = M1.find("def"); if(it == M1.end()) cout << "Nema kljuca def" << endl; else cout << M1["def"] << endl; it = M1.find("pmf"); if(it == M1.end()) cout << "Nema pmf" << endl; else cout << M1["pmf"] << endl; //ispisati sve u mapi // it je tipa pair<string, int> for(it = M1.begin(); it != M1.end(); ++it) cout << it->first << " " << it->second << endl; // zelimo izbrisati sve kljuceve parne duljine for(it = M1.begin(); it != M1.end();) { if(it->first.size() % 2 == 0) M1.erase(it++); else ++it; } for(it = M1.begin(); it != M1.end(); ++it) cout << it->first << " " << it->second << endl; return 0; }
[ "jvujcic@gmail.com" ]
jvujcic@gmail.com
2023f7b1f012a2d625f81aed9334998c2a8af0d1
d63943b1e772e6daa27691a8f5d42dff232b77c4
/Weapons/WeaponFactory.h
9f6968da1cb041e64ba193ca0cafd4a68c3f1de8
[]
no_license
munro/csrl-cpp
c0b68b3c673bc44f2c31d39f8f4f43a988224d82
dbb73600343d9bd76f52f09bbd9ae63a6477f212
refs/heads/master
2020-04-05T12:55:29.132079
2009-12-23T19:31:00
2012-03-12T21:31:21
null
0
0
null
null
null
null
UTF-8
C++
false
false
193
h
#ifndef __WEAPONFACTORY_H__ #define __WEAPONFACTORY_H__ #include "Weapons/Weapon.h" class WeaponFactory { public: static Weapon *create(string name, int x, int y, int rotation); }; #endif
[ "felix@skylab.org" ]
felix@skylab.org
637f5ff68ef2266a33f51276941ba605fc9369d8
b8499de1a793500b47f36e85828f997e3954e570
/v2_3/build/Android/Debug/app/src/main/include/Fuse.Controls.IProxyH-158e5dc.h
828d0e90c4694db1e3786fb137390175b4783028
[]
no_license
shrivaibhav/boysinbits
37ccb707340a14f31bd57ea92b7b7ddc4859e989
04bb707691587b253abaac064317715adb9a9fe5
refs/heads/master
2020-03-24T05:22:21.998732
2018-07-26T20:06:00
2018-07-26T20:06:00
142,485,250
0
0
null
2018-07-26T20:03:22
2018-07-26T19:30:12
C++
UTF-8
C++
false
false
733
h
// This file was generated based on C:/Users/Vaibhav/AppData/Local/Fusetools/Packages/Fuse.Controls.Panels/1.9.0/GraphicsView.ux.uno. // WARNING: Changes might be lost if you edit this file directly. #pragma once #include <Uno.h> namespace g{namespace Fuse{namespace Controls{struct IProxyHostExtensions;}}} namespace g{namespace Fuse{struct Visual;}} namespace g{ namespace Fuse{ namespace Controls{ // internal static class IProxyHostExtensions :72 // { uClassType* IProxyHostExtensions_typeof(); void IProxyHostExtensions__FindProxyHost_fn(::g::Fuse::Visual* visual, uObject** __retval); struct IProxyHostExtensions : uObject { static uObject* FindProxyHost(::g::Fuse::Visual* visual); }; // } }}} // ::g::Fuse::Controls
[ "shubhamanandoist@gmail.com" ]
shubhamanandoist@gmail.com
703bdd183ebc6c7e157e8459f9053ccbc21545c4
22b43a6e5f61e769b0ae65dede218e3acc2ace1b
/Homework/Assignment_6/Gaddis_8thEd_Ch7_Pr14_LotteryApplication/main.cpp
d08aec0ffc512d0aba10e60fd55064f5aa115bf4
[]
no_license
PascualPhil/CSC-5_40107_Winter_2017
1df9c5f4e26edab097a82cc80f18b2cbab2708cd
944d5686a0d06f32cc9fcc6d827c0eb1fc8d518c
refs/heads/master
2021-01-12T02:58:53.473271
2017-02-09T19:05:18
2017-02-09T19:05:18
78,144,749
0
0
null
null
null
null
UTF-8
C++
false
false
2,013
cpp
/* File: main.cpp Author: Phillip Pascual Created on February 6, 2017, 12:00 PM Purpose: Lottery Application */ //System Libraries #include <iostream> #include <cstdlib> #include <ctime> using namespace std; //User Libraries //Global Constants //Such as PI, Vc, -> Math/Science values //as well as conversions from system of units to //another //Function Prototypes //Executable code begins here!!! int main(int argc, char** argv) { //Set RNG seed srand(static_cast<unsigned int>(time(0))); //Declare Variables const int SIZE=5;//Sets size of array int lottery[SIZE]; int picks[SIZE]; int match=0; //Input values cout<<"This program will allow you to enter five digits for a lottery"<<endl; cout<<"and will match the entered digits against the randomly picked"<<endl; cout<<"numbers. Please enter the required information when prompted."<<endl; cout<<endl; for(int pick=0;pick<=SIZE-1;pick++){ cout<<"Please enter your pick for number "<<pick+1<<": "; cin>>picks[pick]; while(picks[pick]>9&&picks[pick]<0){ cout<<"Please enter a number between 0 and 9: "; cin>>picks[pick]; } } //Process by mapping inputs to outputs for(int num=0;num<=SIZE-1;num++){ lottery[num]=rand()%10;//Generates random number between 0-9 and //inserts into array } for(int check=0;check<=SIZE-1;check++){ if(lottery[check]==picks[check])match++; } //Output values cout<<"Your numbers: "; for(int disp=0;disp<=SIZE-1;disp++){ cout<<picks[disp]<<" "; } cout<<endl; cout<<"Picked numbers: "; for(int disp1=0;disp1<=SIZE-1;disp1++){ cout<<lottery[disp1]<<" "; } cout<<endl; if(match==SIZE){ cout<<"CONGRATULATIONS! You win the grand prize!!"<<endl; }else{ cout<<"You picked "<<match<<" numbers correctly."<<endl; } //Exit stage right! return 0; }
[ "rcc" ]
rcc
fe789abf4075e7dca710ef4ae50b06c684e62adc
80d21e9040e370c5679907a3f526ee36a4071a20
/examples/futaba_servo/futaba_servo.ino
67eb2a628f62cc73dbde54febb5926705ed43a29
[]
no_license
branchvincent/battle-bot
e1db7083da97fd401dc636d7374ce87d4b94dece
2bf22969d7c50adc752d5591203eaaefe0ad8ea0
refs/heads/master
2020-03-26T10:21:00.428186
2016-10-03T07:19:54
2016-10-03T07:19:54
144,793,324
0
0
null
null
null
null
UTF-8
C++
false
false
326
ino
#include <Servo.h> Servo myservo; void setup() { // put your setup code here, to run once: myservo.attach(9); // connect servo to pin 9 } void loop() { // put your main code here, to run repeatedly: myservo.write(170); delay(2000); //probably write position for the servo myservo.write(10); delay(2000); }
[ "tedz2usa@gmail.com" ]
tedz2usa@gmail.com
bf9b05323c2ea2c2812eb22f6decc177e5a1347c
40d72afb2f81673a538fc9b6ecbdc1aa47aa9a84
/src/11.PositionableCamera/sphere.h
63839220a7dd602ae09d0b7277506cc2c2a9583f
[]
no_license
tusharsankhala/RayTracingInOneWeekend
756ea0405d17fcb7af825c65a99ee3ef5258c6c3
842bf95229edec77b3f67b3ca98709829ee819cf
refs/heads/master
2020-03-18T17:35:15.176717
2018-05-10T06:26:59
2018-05-10T06:26:59
null
0
0
null
null
null
null
UTF-8
C++
false
false
426
h
#ifndef SPHERE_H #define SPHERE_H #include "hitable.h" #include "material.h" class sphere : public hitable {//sphere为hitable的子类 public: Vec3 center; float Radius; material *ma; public: sphere() {}; sphere(Vec3 cen, float r, material * m) : center(cen), Radius(r),ma(m) {} virtual bool hit(const Ray & r , float tmin , float tmax , hit_record & rec ) const ; }; #endif // SPHERE_H
[ "312998164@qq.com" ]
312998164@qq.com
de0761ea7b4f305c0e8ca7f7fb00a01a6b450ace
e13cff6f7576dc05bc763b98d894888b6b76d055
/decoder/src/main/cpp/decoder.cpp
cb34449622a6b9a7e819c3021e8b4f7197429d60
[]
no_license
zhangruiyu/Silk_v3_decoder
c5e726a114b108a8ce8f3057aeae6fd85328cc2e
504a806e3ac5437f0da7ed63794dc9272163399b
refs/heads/master
2021-10-12T03:16:15.952134
2019-02-01T08:02:43
2019-02-01T08:02:43
null
0
0
null
null
null
null
UTF-8
C++
false
false
3,935
cpp
// // Created by ketian on 16-9-23. // #include <jni.h> #ifdef __cplusplus extern "C" { #endif #include "libwav/wav.h" #include "silk.h" #include "lame.h" #include "easy_mad.h" JNIEXPORT jint JNICALL Java_com_fulongbin_decoder_Silk_silkToMp3(JNIEnv *env, jclass clazz, jstring src, jstring dest, jstring tmp) { const char *src_c = env->GetStringUTFChars(src, 0); const char *dest_c = env->GetStringUTFChars(dest, 0); const char *tmp_c = env->GetStringUTFChars(tmp, 0); LOGD("convert %s to %s", src_c, dest_c); FILE *pcm = fopen(tmp_c, "wb+"); if (convertSilk2PCM(src_c, pcm) != 0) { LOGD("convert silk to pcm failed"); return -1; } fseek(pcm, 0, SEEK_SET); lame_t lame = lame_init(); lame_set_in_samplerate(lame, 24000); lame_set_out_samplerate(lame, 24000); lame_set_num_channels(lame, 1); lame_set_brate(lame, 128); lame_set_mode(lame, MONO); lame_set_quality(lame, 5); lame_init_params(lame); FILE *mp3 = fopen(dest_c, "wb+"); int read, write; const int PCM_SIZE = 8192; const int MP3_SIZE = 8192; short int pcm_buffer[PCM_SIZE]; unsigned char mp3_buffer[MP3_SIZE]; do { read = fread(pcm_buffer, sizeof(short int), PCM_SIZE, pcm); if (read == 0) { write = lame_encode_flush(lame, mp3_buffer, MP3_SIZE); } else { write = lame_encode_buffer(lame, pcm_buffer, NULL, read, mp3_buffer, MP3_SIZE); } fwrite(mp3_buffer, 1, write, mp3); } while (read != 0); lame_close(lame); fclose(mp3); fclose(pcm); return 0; } JNIEXPORT jint JNICALL Java_com_fulongbin_decoder_Silk_mp3ToSilk(JNIEnv *env, jclass clazz, jstring src, jstring dest, jstring tmpUrl) { const char *src_c = env->GetStringUTFChars(src, 0); const char *dest_c = env->GetStringUTFChars(dest, 0); const char *tmp = env->GetStringUTFChars(tmpUrl, 0); LOGD("convert %s to %s", src_c, dest_c); if (convertMP32PCM(src_c, tmp) == -1) { LOGD("mp3_decode failed", tmp); return -1; } FILE *silk = fopen(dest_c, "wb+"); if (convertPCM2Silk(tmp, silk) != 0) { LOGD("convert pcm to silk failed"); return -1; } fclose(silk); return 0; } JNIEXPORT jint JNICALL Java_com_fulongbin_decoder_Silk_silkToWav(JNIEnv *env, jclass clazz, jstring src, jstring dest, jstring tmp) { const char *src_c = env->GetStringUTFChars(src, 0); const char *dest_c = env->GetStringUTFChars(dest, 0); const char *tmp_c = env->GetStringUTFChars(tmp, 0); LOGD("convert %s to %s", src_c, dest_c); FILE *pcm = fopen(tmp_c, "wb+"); if (convertSilk2PCM(src_c, pcm) != 0) { LOGD("convert silk to pcm failed"); return -1; } FILE *wav = fopen(dest_c, "wb+"); if (convertPCM2WAV(pcm, wav) != 0) { LOGD("convert pcm to wav failed"); return -1; } fclose(wav); fclose(pcm); return 0; } JNIEXPORT jint JNICALL Java_com_fulongbin_decoder_Silk_wavToSilk(JNIEnv *env, jclass clazz, jstring src, jstring dest, jstring tmpUrl) { const char *src_c = env->GetStringUTFChars(src, 0); const char *dest_c = env->GetStringUTFChars(dest, 0); const char *tmp = env->GetStringUTFChars(tmpUrl, 0); LOGD("convert %s to %s", src_c, dest_c); FILE *wav = fopen(src_c, "rb"); FILE *pcm = fopen(tmp,"wb+"); if (convertWAV2PCM(wav, pcm) == -1) { LOGD("wav tp pcm failed", tmp); return -1; } FILE *silk = fopen(dest_c, "wb+"); if (convertPCM2Silk(tmp, silk) != 0) { LOGD("convert pcm to silk failed"); return -1; } fclose(wav); fclose(pcm); fclose(silk); return 0; } #ifdef __cplusplus } #endif
[ "flb1019@gmail.com" ]
flb1019@gmail.com
1dc03ac3381ddd5833879272ab9c2cc369fedeee
343991667d37fba873674d8dc157f59f108c4370
/bin/mac64.build/cpp/src/snow/api/Debug.cpp
775d22e2dd2f54e66a0efc5c2edee9433586ad11
[]
no_license
PlumpMath/StarSlam
7718152d348de29dc68c759a81fa9cfefe9647b9
4a05d1575a763ffab76db259050bfe3b9a16a910
refs/heads/master
2021-01-18T20:24:31.646389
2015-09-20T20:11:56
2015-09-20T20:11:56
null
0
0
null
null
null
null
UTF-8
C++
false
false
5,681
cpp
#include <hxcpp.h> #ifndef INCLUDED_snow_api_Debug #include <snow/api/Debug.h> #endif namespace snow{ namespace api{ Void Debug_obj::__construct() { return null(); } //Debug_obj::~Debug_obj() { } Dynamic Debug_obj::__CreateEmpty() { return new Debug_obj; } hx::ObjectPtr< Debug_obj > Debug_obj::__new() { hx::ObjectPtr< Debug_obj > _result_ = new Debug_obj(); _result_->__construct(); return _result_;} Dynamic Debug_obj::__Create(hx::DynamicArray inArgs) { hx::ObjectPtr< Debug_obj > _result_ = new Debug_obj(); _result_->__construct(); return _result_;} int Debug_obj::_level; Array< ::String > Debug_obj::_filter; Array< ::String > Debug_obj::_exclude; int Debug_obj::_log_width; ::String Debug_obj::_get_spacing( ::String _file){ HX_STACK_FRAME("snow.api.Debug","_get_spacing",0x9b233895,"snow.api.Debug._get_spacing","snow/api/Debug.hx",242,0x9e629c0c) HX_STACK_ARG(_file,"_file") HX_STACK_LINE(244) ::String _spaces = HX_HCSTRING("","\x00","\x00","\x00","\x00"); HX_STACK_VAR(_spaces,"_spaces"); HX_STACK_LINE(247) int tmp = (_file.length + (int)4); HX_STACK_VAR(tmp,"tmp"); HX_STACK_LINE(247) int _trace_length = tmp; HX_STACK_VAR(_trace_length,"_trace_length"); HX_STACK_LINE(248) int tmp1 = ::snow::api::Debug_obj::_log_width; HX_STACK_VAR(tmp1,"tmp1"); HX_STACK_LINE(248) int tmp2 = _trace_length; HX_STACK_VAR(tmp2,"tmp2"); HX_STACK_LINE(248) int tmp3 = (tmp1 - tmp2); HX_STACK_VAR(tmp3,"tmp3"); HX_STACK_LINE(248) int _diff = tmp3; HX_STACK_VAR(_diff,"_diff"); HX_STACK_LINE(249) bool tmp4 = (_diff > (int)0); HX_STACK_VAR(tmp4,"tmp4"); HX_STACK_LINE(249) if ((tmp4)){ HX_STACK_LINE(250) int _g = (int)0; HX_STACK_VAR(_g,"_g"); HX_STACK_LINE(250) while((true)){ HX_STACK_LINE(250) bool tmp5 = (_g < _diff); HX_STACK_VAR(tmp5,"tmp5"); HX_STACK_LINE(250) bool tmp6 = !(tmp5); HX_STACK_VAR(tmp6,"tmp6"); HX_STACK_LINE(250) if ((tmp6)){ HX_STACK_LINE(250) break; } HX_STACK_LINE(250) int tmp7 = (_g)++; HX_STACK_VAR(tmp7,"tmp7"); HX_STACK_LINE(250) int i = tmp7; HX_STACK_VAR(i,"i"); HX_STACK_LINE(251) hx::AddEq(_spaces,HX_HCSTRING(" ","\x20","\x00","\x00","\x00")); } } HX_STACK_LINE(255) ::String tmp5 = _spaces; HX_STACK_VAR(tmp5,"tmp5"); HX_STACK_LINE(255) return tmp5; } STATIC_HX_DEFINE_DYNAMIC_FUNC1(Debug_obj,_get_spacing,return ) Debug_obj::Debug_obj() { } bool Debug_obj::__GetStatic(const ::String &inName, Dynamic &outValue, hx::PropertyAccess inCallProp) { switch(inName.length) { case 6: if (HX_FIELD_EQ(inName,"_level") ) { outValue = _level; return true; } break; case 7: if (HX_FIELD_EQ(inName,"_filter") ) { outValue = _filter; return true; } break; case 8: if (HX_FIELD_EQ(inName,"_exclude") ) { outValue = _exclude; return true; } break; case 10: if (HX_FIELD_EQ(inName,"_log_width") ) { outValue = _log_width; return true; } break; case 12: if (HX_FIELD_EQ(inName,"_get_spacing") ) { outValue = _get_spacing_dyn(); return true; } } return false; } #if HXCPP_SCRIPTABLE static hx::StorageInfo *sMemberStorageInfo = 0; static hx::StaticInfo sStaticStorageInfo[] = { {hx::fsInt,(void *) &Debug_obj::_level,HX_HCSTRING("_level","\xc5","\x5c","\x4a","\x6e")}, {hx::fsObject /*Array< ::String >*/ ,(void *) &Debug_obj::_filter,HX_HCSTRING("_filter","\x57","\x31","\xac","\xf3")}, {hx::fsObject /*Array< ::String >*/ ,(void *) &Debug_obj::_exclude,HX_HCSTRING("_exclude","\x5b","\x18","\xeb","\xe4")}, {hx::fsInt,(void *) &Debug_obj::_log_width,HX_HCSTRING("_log_width","\x8c","\x08","\xc7","\xa7")}, { hx::fsUnknown, 0, null()} }; #endif static void sMarkStatics(HX_MARK_PARAMS) { HX_MARK_MEMBER_NAME(Debug_obj::__mClass,"__mClass"); HX_MARK_MEMBER_NAME(Debug_obj::_level,"_level"); HX_MARK_MEMBER_NAME(Debug_obj::_filter,"_filter"); HX_MARK_MEMBER_NAME(Debug_obj::_exclude,"_exclude"); HX_MARK_MEMBER_NAME(Debug_obj::_log_width,"_log_width"); }; #ifdef HXCPP_VISIT_ALLOCS static void sVisitStatics(HX_VISIT_PARAMS) { HX_VISIT_MEMBER_NAME(Debug_obj::__mClass,"__mClass"); HX_VISIT_MEMBER_NAME(Debug_obj::_level,"_level"); HX_VISIT_MEMBER_NAME(Debug_obj::_filter,"_filter"); HX_VISIT_MEMBER_NAME(Debug_obj::_exclude,"_exclude"); HX_VISIT_MEMBER_NAME(Debug_obj::_log_width,"_log_width"); }; #endif hx::Class Debug_obj::__mClass; static ::String sStaticFields[] = { HX_HCSTRING("_level","\xc5","\x5c","\x4a","\x6e"), HX_HCSTRING("_filter","\x57","\x31","\xac","\xf3"), HX_HCSTRING("_exclude","\x5b","\x18","\xeb","\xe4"), HX_HCSTRING("_log_width","\x8c","\x08","\xc7","\xa7"), HX_HCSTRING("_get_spacing","\x9b","\x41","\xbf","\x7d"), ::String(null()) }; void Debug_obj::__register() { hx::Static(__mClass) = new hx::Class_obj(); __mClass->mName = HX_HCSTRING("snow.api.Debug","\xb4","\x15","\xe8","\x33"); __mClass->mSuper = &super::__SGetClass(); __mClass->mConstructEmpty = &__CreateEmpty; __mClass->mConstructArgs = &__Create; __mClass->mGetStaticField = &Debug_obj::__GetStatic; __mClass->mSetStaticField = &hx::Class_obj::SetNoStaticField; __mClass->mMarkFunc = sMarkStatics; __mClass->mStatics = hx::Class_obj::dupFunctions(sStaticFields); __mClass->mMembers = hx::Class_obj::dupFunctions(0 /* sMemberFields */); __mClass->mCanCast = hx::TCanCast< Debug_obj >; #ifdef HXCPP_VISIT_ALLOCS __mClass->mVisitFunc = sVisitStatics; #endif #ifdef HXCPP_SCRIPTABLE __mClass->mMemberStorageInfo = sMemberStorageInfo; #endif #ifdef HXCPP_SCRIPTABLE __mClass->mStaticStorageInfo = sStaticStorageInfo; #endif hx::RegisterClass(__mClass->mName, __mClass); } void Debug_obj::__boot() { _level= (int)1; _log_width= (int)16; } } // end namespace snow } // end namespace api
[ "aledoux6@gatech.edu" ]
aledoux6@gatech.edu
79a34ca3a710686e1765badc2f627c769c41c388
8155e67b2eb36ec6e97d67a5944f98e15865a2e1
/草木灰公社模拟赛Ⅰ/边与边权/eaw.cpp
ded0be044d2ae31ef9c3a4a1416b365aa9043898
[]
no_license
gbakkk5951/OriginalProblems
6c1926f0502ebeb532ae6bc87de3a0d5150c3d29
cc03faa6efc6f0004d701bc101851e9384793fa7
refs/heads/main
2023-03-15T16:26:31.523650
2023-03-14T16:16:01
2023-03-14T16:16:01
115,530,948
3
0
null
null
null
null
UTF-8
C++
false
false
3,920
cpp
using namespace std; int main() {} #include <cstdio> #include <cctype> #include <cstring> #include <cstdlib> #include <algorithm> namespace OI { const int MXN = 100010; const int CHANGE = 1, INS = 2, DEL = 3; struct Node { Node *s[2], *f; int size, mn, val; }; struct Splay { Node pool[MXN << 1], *null, *root; int pidx; Node *new_(int v, Node *f) { Node *nd = &pool[pidx++]; nd->f = f; nd->size = 1; nd->val = nd->mn = v; nd->s[0] = nd->s[1] = null; return nd; } Splay() { null = new_(2, null); null->f = null->s[0] = null->s[1] = null; null->size = 0; } void rotate(Node *nd) { Node *f = nd->f, *gf = f->f, *s; nd->f = gf; gf->s[f == gf->s[1]] = nd; int spo = nd == f->s[1]; s = f->s[spo] = nd->s[spo ^ 1]; s->f = f; f->f = nd; nd->s[spo ^ 1] = f; update(f); update(nd); } void splay(Node *nd) { update(nd); Node *f; while ((f = nd->f) != null) { if (f->f != null) { if ((nd == f->s[1]) == (f == f->f->s[1])) { rotate(f); } else { rotate(nd); } } rotate(nd); } root = nd; } void update(Node *nd) { nd->size = 1, nd->mn = nd->val; for (int i = 0; i < 2; i++) { nd->mn = min(nd->mn, nd->s[i]->mn); nd->size += nd->s[i]->size; } } Node* build(int arr[], int l, int r, Node *f) { int mid = l + r >> 1; Node *nd = new_(arr[mid], f); if (l < mid) { nd->s[0] = build(arr, l, mid - 1, nd); } if (r > mid) { nd->s[1] = build(arr, mid + 1, r, nd); } update(nd); return nd; } void erase(int pos) { Node *nd = root; while (nd->s[0]->size != pos) { if (nd->s[0]->size < pos) { pos -= nd->s[0]->size + 1; nd = nd->s[1]; } else { nd = nd->s[0]; } } while (nd->s[0] != null && nd->s[1] != null) { rotate(nd->s[0]); } int spo = nd->s[0] == null; Node *f = nd->f; f->s[nd == f->s[1]] = nd->s[spo]; nd->s[spo]->f = f; if (f != null) { splay(f); } else { root = nd->s[spo]; } } void insert(int pos, int v) { Node *nd = root; int spo; while (1) { if (spo = nd->s[0]->size < pos) { pos -= nd->s[0]->size + 1; } if (nd->s[spo] != null) { nd = nd->s[spo]; } else { nd = nd->s[spo] = new_(v, nd); break; } } splay(nd); } void change(int pos, int v) { Node *nd = root; while (1) { if (nd->s[0]->size == pos) { nd->val = v; break; } else if (nd->s[0]->size > pos) { nd = nd->s[0]; } else { pos -= nd->s[0]->size + 1; nd = nd->s[1]; } } splay(nd); } int findside(int v, int side) { Node *nd = root; int ret = 0; while (1) { if (nd->s[side]->mn == v) { nd = nd->s[side]; } else if (nd->val == v) { ret += nd->s[side]->size; break; } else { ret += nd->s[side]->size + 1; nd = nd->s[side ^ 1]; } } splay(nd); return ret; } }tree; struct _Main { int arr[MXN]; void ask() { if (tree.root->mn == 0) { if (!(tree.findside(0, 0) & 1) || !(tree.findside(0, 1))) { printf("1\n"); } else { printf("0\n"); } } else if (tree.root->mn == 1) { if ((n & 1) || !(tree.findside(1, 0) & 1) || !(tree.findside(1, 1) & 1)) { printf("1\n"); } else { printf("0\n"); } } else { printf("%c\n", (char)(n & 1) + '0'); } } int n; _Main() { int Qn; int op, pos, val; read(n); read(Qn); for (int i = 1; i <= n; i++) { read(arr[i]); } arr[0] = 2; arr[n + 1] = 2; tree.root = tree.build(arr, 0, n + 1, tree.null); ask(); for (int Q = 1; Q <= Qn; Q++) { read(op); read(pos); if (op == CHANGE) { read(val); tree.change(pos, val); } else if (op == INS) { read(val); tree.insert(pos, val); ++n; } else if(op == DEL) { tree.erase(pos); --n; } ask(); } } template <typename Type> void read(Type &a) { char t; while (!isdigit(t = getchar())); a = t - '0'; while ( isdigit(t = getchar())) { a *= 10; a += t - '0'; } } }eaw; }
[ "526406038@qq.com" ]
526406038@qq.com
51cf899d6b4b9139ce7ad3850f548c02d88bc465
2f1a092537d8650cacbd274a3bd600e87a627e90
/thrift/compiler/test/fixtures/py3/gen-cpp2/DerivedServiceAsyncClient.cpp
84d8d0db57fd5f4d6bc0c8b54a9b6c7dab1c4b2e
[ "Apache-2.0" ]
permissive
ConnectionMaster/fbthrift
3aa7d095c00b04030fddbabffbf09a5adca29d42
d5d0fa3f72ee0eb4c7b955e9e04a25052678d740
refs/heads/master
2023-04-10T17:49:05.409858
2021-08-03T02:32:49
2021-08-03T02:33:57
187,603,239
1
1
Apache-2.0
2023-04-03T23:15:28
2019-05-20T08:49:29
C++
UTF-8
C++
false
false
9,105
cpp
/** * Autogenerated by Thrift for src/module.thrift * * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING * @generated */ #include "thrift/compiler/test/fixtures/py3/gen-cpp2/DerivedServiceAsyncClient.h" #include <thrift/lib/cpp2/gen/client_cpp.h> namespace py3 { namespace simple { typedef apache::thrift::ThriftPresult<false> DerivedService_get_six_pargs; typedef apache::thrift::ThriftPresult<true, apache::thrift::FieldData<0, ::apache::thrift::type_class::integral, ::std::int32_t*>> DerivedService_get_six_presult; template <typename Protocol_> void DerivedServiceAsyncClient::get_sixT(Protocol_* prot, const apache::thrift::RpcOptions& rpcOptions, std::shared_ptr<apache::thrift::transport::THeader> header, apache::thrift::ContextStack* contextStack, apache::thrift::RequestClientCallback::Ptr callback) { DerivedService_get_six_pargs args; auto sizer = [&](Protocol_* p) { return args.serializedSizeZC(p); }; auto writer = [&](Protocol_* p) { args.write(p); }; static ::apache::thrift::MethodMetadata::Data* methodMetadata = new ::apache::thrift::MethodMetadata::Data( "get_six", ::apache::thrift::FunctionQualifier::Unspecified); apache::thrift::clientSendT<apache::thrift::RpcKind::SINGLE_REQUEST_SINGLE_RESPONSE, Protocol_>(prot, rpcOptions, std::move(callback), contextStack, std::move(header), channel_.get(), ::apache::thrift::MethodMetadata::from_static(methodMetadata), writer, sizer); } void DerivedServiceAsyncClient::get_six(std::unique_ptr<apache::thrift::RequestCallback> callback) { ::apache::thrift::RpcOptions rpcOptions; get_six(rpcOptions, std::move(callback)); } void DerivedServiceAsyncClient::get_six(apache::thrift::RpcOptions& rpcOptions, std::unique_ptr<apache::thrift::RequestCallback> callback) { auto [ctx, header] = get_sixCtx(&rpcOptions); apache::thrift::RequestCallback::Context callbackContext; callbackContext.protocolId = apache::thrift::GeneratedAsyncClient::getChannel()->getProtocolId(); auto* contextStack = ctx.get(); if (callback) { callbackContext.ctx = std::move(ctx); } auto wrappedCallback = apache::thrift::toRequestClientCallbackPtr(std::move(callback), std::move(callbackContext)); get_sixImpl(rpcOptions, std::move(header), contextStack, std::move(wrappedCallback)); } void DerivedServiceAsyncClient::get_sixImpl(const apache::thrift::RpcOptions& rpcOptions, std::shared_ptr<apache::thrift::transport::THeader> header, apache::thrift::ContextStack* contextStack, apache::thrift::RequestClientCallback::Ptr callback) { switch (apache::thrift::GeneratedAsyncClient::getChannel()->getProtocolId()) { case apache::thrift::protocol::T_BINARY_PROTOCOL: { apache::thrift::BinaryProtocolWriter writer; get_sixT(&writer, rpcOptions, std::move(header), contextStack, std::move(callback)); break; } case apache::thrift::protocol::T_COMPACT_PROTOCOL: { apache::thrift::CompactProtocolWriter writer; get_sixT(&writer, rpcOptions, std::move(header), contextStack, std::move(callback)); break; } default: { apache::thrift::detail::ac::throw_app_exn("Could not find Protocol"); } } } std::pair<std::unique_ptr<::apache::thrift::ContextStack>, std::shared_ptr<::apache::thrift::transport::THeader>> DerivedServiceAsyncClient::get_sixCtx(apache::thrift::RpcOptions* rpcOptions) { auto header = std::make_shared<apache::thrift::transport::THeader>( apache::thrift::transport::THeader::ALLOW_BIG_FRAMES); header->setProtocolId(channel_->getProtocolId()); if (rpcOptions) { header->setHeaders(rpcOptions->releaseWriteHeaders()); } auto ctx = apache::thrift::ContextStack::createWithClientContext( handlers_, getServiceName(), "DerivedService.get_six", *header); return {std::move(ctx), std::move(header)}; } ::std::int32_t DerivedServiceAsyncClient::sync_get_six() { ::apache::thrift::RpcOptions rpcOptions; return sync_get_six(rpcOptions); } ::std::int32_t DerivedServiceAsyncClient::sync_get_six(apache::thrift::RpcOptions& rpcOptions) { apache::thrift::ClientReceiveState returnState; apache::thrift::ClientSyncCallback<false> callback(&returnState); auto protocolId = apache::thrift::GeneratedAsyncClient::getChannel()->getProtocolId(); auto evb = apache::thrift::GeneratedAsyncClient::getChannel()->getEventBase(); auto ctxAndHeader = get_sixCtx(&rpcOptions); auto wrappedCallback = apache::thrift::RequestClientCallback::Ptr(&callback); callback.waitUntilDone( evb, [&] { get_sixImpl(rpcOptions, std::move(ctxAndHeader.second), ctxAndHeader.first.get(), std::move(wrappedCallback)); }); if (returnState.isException()) { returnState.exception().throw_exception(); } returnState.resetProtocolId(protocolId); returnState.resetCtx(std::move(ctxAndHeader.first)); SCOPE_EXIT { if (returnState.header() && !returnState.header()->getHeaders().empty()) { rpcOptions.setReadHeaders(returnState.header()->releaseHeaders()); } }; return folly::fibers::runInMainContext([&] { return recv_get_six(returnState); }); } folly::Future<::std::int32_t> DerivedServiceAsyncClient::future_get_six() { ::apache::thrift::RpcOptions rpcOptions; return future_get_six(rpcOptions); } folly::SemiFuture<::std::int32_t> DerivedServiceAsyncClient::semifuture_get_six() { ::apache::thrift::RpcOptions rpcOptions; return semifuture_get_six(rpcOptions); } folly::Future<::std::int32_t> DerivedServiceAsyncClient::future_get_six(apache::thrift::RpcOptions& rpcOptions) { folly::Promise<::std::int32_t> promise; auto future = promise.getFuture(); auto callback = std::make_unique<apache::thrift::FutureCallback<::std::int32_t>>(std::move(promise), recv_wrapped_get_six, channel_); get_six(rpcOptions, std::move(callback)); return future; } folly::SemiFuture<::std::int32_t> DerivedServiceAsyncClient::semifuture_get_six(apache::thrift::RpcOptions& rpcOptions) { auto callbackAndFuture = makeSemiFutureCallback(recv_wrapped_get_six, channel_); auto callback = std::move(callbackAndFuture.first); get_six(rpcOptions, std::move(callback)); return std::move(callbackAndFuture.second); } folly::Future<std::pair<::std::int32_t, std::unique_ptr<apache::thrift::transport::THeader>>> DerivedServiceAsyncClient::header_future_get_six(apache::thrift::RpcOptions& rpcOptions) { folly::Promise<std::pair<::std::int32_t, std::unique_ptr<apache::thrift::transport::THeader>>> promise; auto future = promise.getFuture(); auto callback = std::make_unique<apache::thrift::HeaderFutureCallback<::std::int32_t>>(std::move(promise), recv_wrapped_get_six, channel_); get_six(rpcOptions, std::move(callback)); return future; } folly::SemiFuture<std::pair<::std::int32_t, std::unique_ptr<apache::thrift::transport::THeader>>> DerivedServiceAsyncClient::header_semifuture_get_six(apache::thrift::RpcOptions& rpcOptions) { auto callbackAndFuture = makeHeaderSemiFutureCallback(recv_wrapped_get_six, channel_); auto callback = std::move(callbackAndFuture.first); get_six(rpcOptions, std::move(callback)); return std::move(callbackAndFuture.second); } void DerivedServiceAsyncClient::get_six(folly::Function<void (::apache::thrift::ClientReceiveState&&)> callback) { get_six(std::make_unique<apache::thrift::FunctionReplyCallback>(std::move(callback))); } #if FOLLY_HAS_COROUTINES #endif // FOLLY_HAS_COROUTINES folly::exception_wrapper DerivedServiceAsyncClient::recv_wrapped_get_six(::std::int32_t& _return, ::apache::thrift::ClientReceiveState& state) { if (state.isException()) { return std::move(state.exception()); } if (!state.hasResponseBuffer()) { return folly::make_exception_wrapper<apache::thrift::TApplicationException>("recv_ called without result"); } using result = DerivedService_get_six_presult; switch (state.protocolId()) { case apache::thrift::protocol::T_BINARY_PROTOCOL: { apache::thrift::BinaryProtocolReader reader; return apache::thrift::detail::ac::recv_wrapped<result>( &reader, state, _return); } case apache::thrift::protocol::T_COMPACT_PROTOCOL: { apache::thrift::CompactProtocolReader reader; return apache::thrift::detail::ac::recv_wrapped<result>( &reader, state, _return); } default: { } } return folly::make_exception_wrapper<apache::thrift::TApplicationException>("Could not find Protocol"); } ::std::int32_t DerivedServiceAsyncClient::recv_get_six(::apache::thrift::ClientReceiveState& state) { ::std::int32_t _return; auto ew = recv_wrapped_get_six(_return, state); if (ew) { ew.throw_exception(); } return _return; } ::std::int32_t DerivedServiceAsyncClient::recv_instance_get_six(::apache::thrift::ClientReceiveState& state) { return recv_get_six(state); } folly::exception_wrapper DerivedServiceAsyncClient::recv_instance_wrapped_get_six(::std::int32_t& _return, ::apache::thrift::ClientReceiveState& state) { return recv_wrapped_get_six(_return, state); } }} // py3::simple
[ "facebook-github-bot@users.noreply.github.com" ]
facebook-github-bot@users.noreply.github.com
f4c499bf33b156bb09bb9b4b57d5bc0620721f1c
e4367ba3e07e2f958a8a972f93f04cdcbfd456f6
/BZOJ/1614.cpp
14823b0c97dd33ae707b1a2590acbb59d44deecd
[]
no_license
OIdiotLin/problemset
3454987bdfdca5430673381599e02f8bf4479e38
7201d1b19ea5546d55559c622ab2524d57c5bbf3
refs/heads/master
2021-01-12T00:23:02.515619
2017-03-02T13:22:50
2017-03-02T13:22:50
78,716,551
0
0
null
null
null
null
UTF-8
C++
false
false
1,975
cpp
/* Machine: Class4_B2 System: Windows7 SP1 32bit */ #include <cstdio> #include <iostream> #include <cstring> #include <cmath> #include <ctime> #include <queue> #include <algorithm> typedef long long LL; using namespace std; #define SpeedUp ios::sync_with_stdio(false) //#define Judge //#define Debug #define MAXM (20005) #define MAXN (1005) #define INF () const double PI=acos(-1); const int ZCY=1000000007; inline int getint(){ int x=0; char ch=getchar(); while(ch<'0'||ch>'9'){ch=getchar();} while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();} return x; } inline void outputint(int x){ if(x==-1) {puts("-1");return;} char ch[12]; int cnt=0; if(x==0) {putchar('0'); putchar(10);return;} while(x) ch[++cnt]=x%10,x/=10; while(cnt) putchar(ch[cnt--]+48); putchar(10); } #define print(x) outputint(x) #define read(x) x=getint() struct Edge{ int pre,next,w; }E[MAXM]; int G[MAXN],dist[MAXN]; bool vis[MAXN]; int N,P,K,tot; inline void Ins(int x,int y,int w){ E[++tot]=(Edge){y,G[x],w}; G[x]=tot; } void init(){ int x,y,w; #ifdef Judge freopen(".in","r",stdin); freopen(".out","w",stdout); SpeedUp; #endif read(N),read(P),read(K); for(int i=1;i<=P;i++){ read(x),read(y),read(w); Ins(x,y,w); Ins(y,x,w); } } bool check_SPFA(int x){ queue<int> Q; memset(dist,127,sizeof(dist)); dist[1]=0; Q.push(1); vis[1]=true; while(!Q.empty()){ int k=Q.front(); for(int u=G[k];u;u=E[u].next){ int v=E[u].pre; int s=(E[u].w>x ? dist[k]+1 : dist[k]); if(s<dist[v]){ dist[v]=s; if(!vis[v]){ Q.push(v); vis[v]=true; } } } Q.pop(); vis[k]=false; } return dist[N]<=K; } void work(){ int l=0,r=1000000,Ans=-1; while(l<=r){ int mid=(l+r)>>1; check_SPFA(mid) ? Ans=mid,r=mid-1 : l=mid+1; } print(Ans); } int main(){ init(); work(); #ifdef Debug cout<<"Time Used : "<<(double)clock()/CLOCKS_PER_SEC<<" s."<<endl; cout<<"Memory Used : "<<(double)(sizeof())/1048576<<" MB."<<endl; #endif return 0; }
[ "lhd1997@qq.com" ]
lhd1997@qq.com
753b4e56441a0895f9392b8f6a0f1971b0292d97
ed3b24ae57df21a5b089148235dd1b6d728e56f3
/abseil-cpp-78f9680225b9792c26dfdd99d0bd26c96de53dd4/absl/container/internal/raw_hash_set.cc
687bcb8a4d2e532a5857de09aa3f732964fe4cf2
[ "MIT" ]
permissive
michaeleisel/zld
36ce14511ca9e0a971a0ed614bbee5dac9bb6fa1
519197a3bf4dbe47ea5a3bbce609df166f6f976d
refs/heads/master
2023-08-23T13:46:50.509156
2023-02-15T06:02:03
2023-02-15T06:02:03
237,002,244
1,217
55
MIT
2023-02-15T06:00:43
2020-01-29T14:32:45
C++
UTF-8
C++
false
false
2,473
cc
// Copyright 2018 The Abseil Authors. // // 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 // // 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 "absl/container/internal/raw_hash_set.h" #include <atomic> #include <cstddef> #include "absl/base/config.h" namespace absl { ABSL_NAMESPACE_BEGIN namespace container_internal { alignas(16) ABSL_CONST_INIT ABSL_DLL const ctrl_t kEmptyGroup[16] = { ctrl_t::kSentinel, ctrl_t::kEmpty, ctrl_t::kEmpty, ctrl_t::kEmpty, ctrl_t::kEmpty, ctrl_t::kEmpty, ctrl_t::kEmpty, ctrl_t::kEmpty, ctrl_t::kEmpty, ctrl_t::kEmpty, ctrl_t::kEmpty, ctrl_t::kEmpty, ctrl_t::kEmpty, ctrl_t::kEmpty, ctrl_t::kEmpty, ctrl_t::kEmpty}; constexpr size_t Group::kWidth; // Returns "random" seed. inline size_t RandomSeed() { #ifdef ABSL_HAVE_THREAD_LOCAL static thread_local size_t counter = 0; size_t value = ++counter; #else // ABSL_HAVE_THREAD_LOCAL static std::atomic<size_t> counter(0); size_t value = counter.fetch_add(1, std::memory_order_relaxed); #endif // ABSL_HAVE_THREAD_LOCAL return value ^ static_cast<size_t>(reinterpret_cast<uintptr_t>(&counter)); } bool ShouldInsertBackwards(size_t hash, const ctrl_t* ctrl) { // To avoid problems with weak hashes and single bit tests, we use % 13. // TODO(kfm,sbenza): revisit after we do unconditional mixing return (H1(hash, ctrl) ^ RandomSeed()) % 13 > 6; } void ConvertDeletedToEmptyAndFullToDeleted(ctrl_t* ctrl, size_t capacity) { assert(ctrl[capacity] == ctrl_t::kSentinel); assert(IsValidCapacity(capacity)); for (ctrl_t* pos = ctrl; pos < ctrl + capacity; pos += Group::kWidth) { Group{pos}.ConvertSpecialToEmptyAndFullToDeleted(pos); } // Copy the cloned ctrl bytes. std::memcpy(ctrl + capacity + 1, ctrl, NumClonedBytes()); ctrl[capacity] = ctrl_t::kSentinel; } // Extern template instantiotion for inline function. template FindInfo find_first_non_full(const ctrl_t*, size_t, size_t); } // namespace container_internal ABSL_NAMESPACE_END } // namespace absl
[ "michael.eisel@gmail.com" ]
michael.eisel@gmail.com
4135c2dbcaf3cf363c5273a5a0d2e394f3757958
5589567f7435b2e609501bf361415d093ebcb7b9
/irlib_recieve.hpp
49ba5a50619d2cbec8472322a953b79578400bc4
[ "BSL-1.0" ]
permissive
bartbal/infrared_library
c4e96c023500efc9779670923e905585f2fca418
b3983b458f62a39a0a90a31d10d2fa12e91d4a00
refs/heads/master
2020-03-21T18:15:15.994032
2018-10-16T09:28:01
2018-10-16T09:28:01
138,880,511
0
0
null
null
null
null
UTF-8
C++
false
false
8,400
hpp
// ========================================================================== // // File : irlib_recieve.hpp // Copyright : bartvannetburg@hotmail.com 2018 // // 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) // // ========================================================================== // this file contains Doxygen lines /// @file #include <array> #include <algorithm> namespace irlib{ class recieve : public hwlib::pin_in { hwlib::target::pin_in reciever; int wait_us_time; public: /// \brief /// Recieve interface /// \details /// This class receives data that is being send with the irlib_transmit class. recieve(hwlib::target::pin_in & reciever, int wait_us_time = 600): reciever( reciever ), wait_us_time( wait_us_time ) {} /// \brief /// Get() override /// \details /// Get() had to be overridden. Function didn't change from original hwlib::pin_in.get(hwlib::buffering). bool get(hwlib::buffering) override{ return reciever.get(); } /// \brief /// Get unsigned int /// \details /// This function handels everything after the head for catching a simple unsigned int. To catch the head use the irlib::listen_for_head() function. unsigned int get_uint_data(){ int temp = 1; unsigned int data = 0; unsigned int i = 31; hwlib::wait_us(600); for(; i > 0; i--){ for(unsigned int j = 0; j < 2; j++){ hwlib::wait_us(100); temp = temp & !reciever.get(); hwlib::wait_us(500); } hwlib::wait_us(100); if(!reciever.get()){ break; } hwlib::wait_us(500); data += (temp<<i); temp = 1; } data = data>>(i+1); return data; } /// \brief /// Wait for the head signal and get uint /// \details /// This function checks for a head signal and gets the data that comes after and returns it as an unsigned int. unsigned int get_uint(){ unsigned int data = 0; while(1){ if(head()){ data = get_uint_data(); return data; } hwlib::wait_us(1); } } /// \brief /// Wait for the head signal and get char /// \details /// This function checks for a head signal and gets the data that comes after and returns it as a char. char get_char(){ return (char)get_uint(); } /// \brief /// Check for head signal /// \details /// This function checks for a head signal. Best to be used in a loop. int wiggle_time defines the minimal time for the first pulse of the head signal this is set at 200 by default. /// This is to still recieve the head even if it mist the beginning of the head pulse. The maximum for this number should be 800. Everything above 800 nolonger follows the bart protocol. bool head(unsigned int wiggle_time = 200){ uint_fast64_t now = hwlib::now_us(); if(!reciever.get()){ now = hwlib::now_us(); while(1){ if(reciever.get()){ if((hwlib::now_us() - now >= wiggle_time) && (hwlib::now_us() - now < 900)){ while(1){ if(!reciever.get()){ if((hwlib::now_us() - now >= 1580) && (hwlib::now_us() - now < 1680)){ while(1){ if(reciever.get()){ if((hwlib::now_us() - now >= 2380) && (hwlib::now_us() - now < 2480)){ return true; } else { break; } } } } else { break; } } } } else { break; } } } } return false; } /// \brief /// Get array with bytes /// \details /// This function handels everything after the head for catching an array with bytes. To catch the head use the irlib::listen_for_head() function. /// This function requires an array with the correct size to be passed as parameter. Also the length of this array has to be geven. /// Feel free to play with the timing. Decreasing or increasing it might give better results. Default timing is 387. unsigned int get_array_data(unsigned int *n, unsigned int lenght, int timing = 387){ std::fill(n, n+lenght, 0); bool end = false; int temp = 1; unsigned int data = 0; unsigned int i = 7; hwlib::wait_us(600); for(unsigned int h = 0; h < lenght+1; h++){ data = 0; for(; i > 0; i--){ for(unsigned int j = 0; j < 2; j++){ hwlib::wait_us(200); temp = temp & !reciever.get(); hwlib::wait_us(400); } hwlib::wait_us(200); if(!reciever.get()){ end = true; break; } hwlib::wait_us(timing); //default 387 us data += (temp<<i); temp = 1; } data = data>>(i+1); n[h] = data; i = 7; if(end){ break; } } return data; } /// \brief /// Get array with bytes /// \details /// This function handels everything for catching an array with bytes. /// This function requires an array with the correct size to be passed as parameter. Also the length of this array has to be given. /// Feel free to play with the timing. Decreasing or increasing it might give better results. Default timing is 387. void get_array(unsigned int *n, unsigned int lenght, int timing = 387){ while(1){ if(head()){ get_array_data(n, lenght, timing); break; } } } /// \brief /// Get array with chars /// \details /// This function handels everything for catching an array with chars. /// This function requires an array with the correct size to be passed as parameter. Also the length of this array has to be given. /// Feel free to play with the timing. Decreasing or increasing it might give better results. Default timing is 385. void get_string(char *n, unsigned int lenght, int timing = 385){ unsigned int data[lenght]; while(1){ if(head()){ get_array_data(data, lenght, timing); for(unsigned int i = 0; i < lenght; i++){ n[i] = (char)data[i]; } break; } } } }; }// end namespace irlib
[ "Pioneer12" ]
Pioneer12
98e0c9d175a6e50d70801fcc7c253aea4a321941
750df2f7a02d1bcf529e6375e6891f5e239d2fa9
/Project1/Display/Displayer.cpp
edb1176f134ddda7fe02e4561e47cf40aaa8b171
[]
no_license
xiaobaibaibaibai/ENB687
c7a6cee04c4a005fcf544c95594337822fe7062a
df9ec0dd2f5f8c4120595c62265828eac1190f85
refs/heads/master
2021-10-12T04:47:08.697195
2019-02-02T00:21:27
2019-02-02T00:21:27
165,991,136
0
0
null
null
null
null
UTF-8
C++
false
false
819
cpp
///////////////////////////////////////////////////////////////////// // Executive.cpp // // ver 1.0 // // Wentan Bai, CSE687 - Object Oriented Design, Spring 2019 // ///////////////////////////////////////////////////////////////////// #ifdef TEST_DISPLAYER #include "Displayer.h" int main() { std::string browser = "c:/Program Files (x86)/Google/Chrome/Application/chrome.exe"; // some testing htmls std::vector<std::string> htmls = { "../Display/htmls/c1.html", "../Display/htmls/h1.html" }; Displayer dis(browser, htmls); dis.displayPage(); // print aviable htmls std::vector<std::string> urls = dis.getAllHtmlPaths(); for (std::string url : urls) { std::cout << url << std::endl; } return 0; } #endif
[ "wentan1995@gmail.com" ]
wentan1995@gmail.com
781b328663ae230e9eff346715938218ca43949c
0eff74b05b60098333ad66cf801bdd93becc9ea4
/second/download/httpd/gumtree/httpd_repos_function_3105_httpd-2.2.22.cpp
a812af3e80266d56259e340c8bf64a27475c9c88
[]
no_license
niuxu18/logTracker-old
97543445ea7e414ed40bdc681239365d33418975
f2b060f13a0295387fe02187543db124916eb446
refs/heads/master
2021-09-13T21:39:37.686481
2017-12-11T03:36:34
2017-12-11T03:36:34
null
0
0
null
null
null
null
UTF-8
C++
false
false
79
cpp
int XMLCALL XML_GetIdAttributeIndex(XML_Parser parser) { return idAttIndex; }
[ "993273596@qq.com" ]
993273596@qq.com
6d4438c25f8586410ce6e1331139777f4744d2b5
d777a2f9ba2b542f05df3e191193f9e476550b98
/www/prog/BranchingRatio_Measurement.cpp
beabbc1e950348a9757ef16579a762a07b18c79d
[]
no_license
coruscating/Jarvis
7c1d53b2fcd57df8651a040078a89b4839e690ba
2ff6fd68c0f08f149bf9c3b34bde92ac8758b990
refs/heads/master
2021-01-19T10:38:54.813532
2017-10-08T18:57:30
2017-10-08T18:57:30
87,884,547
1
0
null
null
null
null
UTF-8
C++
false
false
2,418
cpp
#include "DDScon.h" #include "HELPERS.h" // DON'T USE--USE THE 25 US PULSE VERSION #define red d.Ch1 #define blue d.Ch0 #define ir1092 d.Ch2 #define ir1033 d.Digout #define qubit_transition F_Red_12_12 #define FRepump F_Red_n12_n12 int main() { // Initialize: DDScon d; //red.Disable(); int plotindex=0; uint32_t loop=0; int count =0; d.Pmt0.Enable(); uint32_t pmtcounts =0; int i=0; Clear_mem(d); uint32_t SPCounts=0; uint32_t ResetCounts=0; uint32_t Scattered_counts=0; uint32_t Dark_counts=0; uint32_t counts=0; red.SetAmp(A_Red); red.SetFreq(MHz(0)); red.Update(); red.Enable(); ir1033.Set(0); d.Pmt0.ClearCorr(); for( loop=0;loop<branching_ratio_loops;loop++) { //Doppler cool /*if(DopplerCool(d,ir1092,blue)==0){ break; }*/ d.Plot[loop-(loop>>11<<11)]=DopplerCool(d,ir1092,blue); //} /*blue.SetFreq(F_Blue_End); blue.SetAmp(A_Blue_End); blue.Update(); d.Timing.WaitForTime(us(20));*/ d.Write(loop); // mark what loop we are on //Turn off doppler blue.SetAmp(0); blue.SetFreq(0); blue.Update(); ir1092.SetAmp(A_1092_Det); ir1092.SetFreq(F_1092_Det); ir1092.Update(); //Prepare in S state d.Timing.WaitForTime(us(12)); ir1092.Disable(); d.Timing.WaitForTime(us(2)); //Prepare for measurement blue.SetAmp(A_Blue_Det); blue.SetFreq(branching_ratio_detuning); //Count photons until ion is shelved d.Timing.ZeroTime(); d.Pmt0.SyncCorr().Clear(); blue.Update(); blue.SetFreq(MHz(0)); d.Timing.WaitUntilTime(us(15)); blue.Update(); blue.SetFreq(F_Blue_Det); //Calibrate scattered counts d.Timing.WaitUntilTime(us(17)); blue.Update(); blue.SetFreq(0); d.Timing.WaitUntilTime(us(32)); blue.Update(); d.Timing.WaitUntilTime(us(34)); ir1092.Enable(); d.Timing.WaitUntilTime(us(46)); ir1092.Disable(); d.Timing.WaitUntilTime(us(48)); ir1092.Enable(); d.Timing.WaitUntilTime(us(60)); ir1092.Disable(); } DopplerCool(d,ir1092,blue); blue.SetFreq(F_Blue_End); blue.SetAmp(A_Blue_End); blue.Update(); red.Disable(); ir1033.Set(0); }
[ "halz@mit.edu" ]
halz@mit.edu
c40bac5c67e55779a463d370ce5c6a904b97925d
e0d9be79cd7cead17969bb6a62afa0e6ae0c60dd
/GUI/include/server.hpp
fcb28ac5cd14cfbb42c35678bf58ba781a6308d0
[]
no_license
PlotnikovAleksey/k_project
8ba1dc4afbc038731999e5b711ef52abec03de6e
5ebf9d8d887a08da20f35f0904fa3f55e690b7d6
refs/heads/master
2020-09-08T05:47:11.949531
2019-12-09T14:34:45
2019-12-09T14:34:45
221,033,896
0
0
null
2019-12-08T19:58:31
2019-11-11T17:27:24
C++
UTF-8
C++
false
false
1,561
hpp
// Copyright 2019 Plotnikov Aleksey <alex280201@gmail.com> #ifndef INCLUDE_SERVER_HPP_ #define INCLUDE_SERVER_HPP_ #define _CRT_SECURE_NO_WARNINGS #include <iostream> #include <boost/asio.hpp> #include <boost/enable_shared_from_this.hpp> #include <boost/thread/recursive_mutex.hpp> #include <boost/shared_ptr.hpp> #include <boost/bind.hpp> #include <string> #include <thread> #include <mutex> #include <fstream> #include "kp_analysis_from_dump.hpp" bool File_Exists(std::string filePath); void delete_front_whitespaces(std::string& s); void delete_back_whitespaces(std::string& s); struct talk_to_client : boost::enable_shared_from_this<talk_to_client> { private: boost::asio::ip::tcp::socket sock_; size_t already_read_; char buff_[2048]; std::string username_; unsigned long file_size; public: typedef boost::shared_ptr<talk_to_client> client_ptr; typedef std::vector<client_ptr> array; static array clients_list; talk_to_client(); std::string& username(); void answer_to_request(); boost::asio::ip::tcp::socket& sock(); bool timed_out() const; void stop(); void read_request(); void process_request(); void on_login(); void on_error(const std::string & msg); void on_capture(std::string & msg); void send_precol(); void write(const std::string & msg); }; typedef boost::shared_ptr<talk_to_client> client_ptr; typedef std::vector<client_ptr> array; void accept_thread(QMainWindow* main_w); void handle_clients_thread(); #endif // INCLUDE_SERVER_HPP_
[ "alex280201@gmail.com" ]
alex280201@gmail.com
2e28d50f2702b133b68e0e65728ec5c615da5955
61aa319732d3fa7912e28f5ff7768498f8dda005
/src/cpu/exetrace.hh
5dc3ff7e3008fb9982c364650797e6a9dbef8548
[ "BSD-3-Clause", "LicenseRef-scancode-proprietary-license", "LGPL-2.0-or-later", "MIT" ]
permissive
TeCSAR-UNCC/gem5-SALAM
37f2f7198c93b4c18452550df48c1a2ab14b14fb
c14c39235f4e376e64dc68b81bd2447e8a47ff65
refs/heads/main
2023-06-08T22:16:25.260792
2023-05-31T16:43:46
2023-05-31T16:43:46
154,335,724
62
22
BSD-3-Clause
2023-05-31T16:43:48
2018-10-23T13:45:44
C++
UTF-8
C++
false
false
2,885
hh
/* * Copyright (c) 2001-2005 The Regents of The University of Michigan * 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 copyright holders nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef __CPU_EXETRACE_HH__ #define __CPU_EXETRACE_HH__ #include "base/trace.hh" #include "base/types.hh" #include "cpu/static_inst.hh" #include "cpu/thread_context.hh" #include "debug/ExecEnable.hh" #include "params/ExeTracer.hh" #include "sim/insttracer.hh" namespace gem5 { class ThreadContext; namespace Trace { class ExeTracerRecord : public InstRecord { public: ExeTracerRecord(Tick _when, ThreadContext *_thread, const StaticInstPtr _staticInst, TheISA::PCState _pc, const StaticInstPtr _macroStaticInst = NULL) : InstRecord(_when, _thread, _staticInst, _pc, _macroStaticInst) { } void traceInst(const StaticInstPtr &inst, bool ran); void dump(); }; class ExeTracer : public InstTracer { public: typedef ExeTracerParams Params; ExeTracer(const Params &params) : InstTracer(params) {} InstRecord * getInstRecord(Tick when, ThreadContext *tc, const StaticInstPtr staticInst, TheISA::PCState pc, const StaticInstPtr macroStaticInst = NULL) { if (!debug::ExecEnable) return NULL; return new ExeTracerRecord(when, tc, staticInst, pc, macroStaticInst); } }; } // namespace Trace } // namespace gem5 #endif // __CPU_EXETRACE_HH__
[ "sroger48@uncc.edu" ]
sroger48@uncc.edu
bddea435e6154f3abb529e0aef3e40b96bfa033d
3a903028bdb3b0ce604588a2358fb3c1bc990baf
/vta/vtalib/include/arm_compute/core/NEON/kernels/NEHarrisCornersKernel.h
084dd7debaa5560bad87317c9a13beaa7006c061
[ "Apache-2.0" ]
permissive
snizzer/nest-compiler
21a8a069ede526bbf969d1dfe71950cd5698c853
c6ac790ed12807f2e0855e3aa0170cb149dc237d
refs/heads/main
2023-06-11T10:15:31.030619
2021-07-06T01:53:01
2021-07-06T01:53:01
null
0
0
null
null
null
null
UTF-8
C++
false
false
5,068
h
/* * Copyright (c) 2016-2020 Arm Limited. * * SPDX-License-Identifier: MIT * * 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. */ #ifndef ARM_COMPUTE_NEHARRISCORNERSKERNEL_H #define ARM_COMPUTE_NEHARRISCORNERSKERNEL_H #include "arm_compute/core/CPP/kernels/CPPCornerCandidatesKernel.h" #include "arm_compute/core/CPP/kernels/CPPSortEuclideanDistanceKernel.h" #include "arm_compute/core/IArray.h" #include "arm_compute/core/NEON/INEKernel.h" #include <cstdint> namespace arm_compute { class ITensor; using IImage = ITensor; /** Common interface for all Harris Score kernels */ class INEHarrisScoreKernel : public INEKernel { public: /** Default constructor */ INEHarrisScoreKernel(); /** Prevent instances of this class from being copied (As this class contains pointers) */ INEHarrisScoreKernel(const INEHarrisScoreKernel &) = delete; /** Prevent instances of this class from being copied (As this class contains pointers) */ INEHarrisScoreKernel &operator=(const INEHarrisScoreKernel &) = delete; /** Allow instances of this class to be moved */ INEHarrisScoreKernel(INEHarrisScoreKernel &&) = default; /** Allow instances of this class to be moved */ INEHarrisScoreKernel &operator=(INEHarrisScoreKernel &&) = default; /** Default destructor */ ~INEHarrisScoreKernel() = default; public: /** Setup the kernel parameters * * @param[in] input1 Source image (gradient X). Data types supported: S16/S32 * @param[in] input2 Source image (gradient Y). Data types supported: same as @ input1 * @param[out] output Destination image (harris score). Data types supported: F32 * @param[in] norm_factor Normalization factor to use accordingly with the gradient size (Must be different from 0) * @param[in] strength_thresh Minimum threshold with which to eliminate Harris Corner scores (computed using the normalized Sobel kernel). * @param[in] sensitivity Sensitivity threshold k from the Harris-Stephens equation * @param[in] border_undefined True if the border mode is undefined. False if it's replicate or constant. */ virtual void configure(const IImage *input1, const IImage *input2, IImage *output, float norm_factor, float strength_thresh, float sensitivity, bool border_undefined) = 0; protected: const IImage *_input1; /**< Source image - Gx component */ const IImage *_input2; /**< Source image - Gy component */ IImage *_output; /**< Source image - Harris score */ float _sensitivity; /**< Sensitivity value */ float _strength_thresh; /**< Threshold value */ float _norm_factor; /**< Normalization factor */ BorderSize _border_size; /**< Border size */ }; /** Template NEON kernel to perform Harris Score. * The implementation supports 3, 5, and 7 for the block_size */ template <int32_t block_size> class NEHarrisScoreKernel : public INEHarrisScoreKernel { public: const char *name() const override { return "NEHarrisScoreKernel"; } /** Default constructor */ NEHarrisScoreKernel(); // Inherited methods overridden: void configure(const IImage *input1, const IImage *input2, IImage *output, float norm_factor, float strength_thresh, float sensitivity, bool border_undefined) override; BorderSize border_size() const override; void run(const Window &window, const ThreadInfo &info) override; private: /** Common signature for all the specialised harris score functions */ using HarrisScoreFunction = void(const void *__restrict input1_ptr, const void *__restrict input2_ptr, void *__restrict output_ptr, int32_t input_stride, float norm_factor, float sensitivity, float strength_thresh); /** Harris Score function to use for the particular image types passed to configure() */ HarrisScoreFunction *_func; }; } // namespace arm_compute #endif /* ARM_COMPUTE_NEHARRISCORNERSKERNEL_H */
[ "yongin.kwon@etri.re.kr" ]
yongin.kwon@etri.re.kr
6f01295bd1fa5729a3077ccee5cdd4f565eeaf11
3febdac3fbc009bbf2e5912e55f59efd4dc45a9f
/Base/Source/ErrorLogger.cpp
807d6d284049c83bf82973bed74f956b69330b8c
[ "MIT" ]
permissive
TaylorClark/PrimeTime
95f440451434ded07c5dbd6008f03a3c21fcf66f
3c62f6c53e0494146a95be1412273de3cf05bcd2
refs/heads/master
2021-01-01T17:20:56.420438
2017-07-23T01:30:49
2017-07-23T01:30:49
98,057,599
0
0
null
null
null
null
UTF-8
C++
false
false
4,256
cpp
/*================================================================================================= ErrorLogger.cpp Gamers Floating Profile Saver \author Taylor Clark \Date October 12, 2005 =================================================================================================*/ #include <time.h> #include "ErrorLogger.h" using namespace std; // The file name for the log file, should be in the same directory as the executing app static const char* FILE_NAME = "errors.log"; // The max size allowed for the log file, must be greater than 2 so resizing doesn't have // issues #define MAX_LOG_SIZE 8192 /////////////////////////////////////////////////////////////////////////////////////////////////// // // ErrorLogger::OutputErrorString Public /// /// \param errorStr The error string to output /// \param addNewLine If we should add a new line after this line, defaults to true /// /// Output an error string to the log file. /// /////////////////////////////////////////////////////////////////////////////////////////////////// void ErrorLogger::OutputErrorString( std::string errorStr, bool addNewLine ) { // Have we opened the file yet if( !m_OutStream.is_open() ) { // Open the file m_OutStream.open( FILE_NAME, ios_base::out | ios_base::app ); // Make sure the file isn't too big MaintainLogFileSize(); } // If we are adding a new line then preface the error with data/time std::string sError; if( addNewLine ) { time_t curTime = time(NULL); char szTimeDate[128] = {0}; strftime(szTimeDate, 128, "%F at %T", localtime( &curTime ) ); sError = szTimeDate; sError += "-"; } // Add in the error string sError += errorStr; // If we are adding a new line if( addNewLine ) sError += "\n"; // Output the string m_OutStream.write( sError.c_str(), (std::streamsize)sError.length() ); } /////////////////////////////////////////////////////////////////////////////////////////////////// // // ErrorLogger::MaintainLogFileSize Private /// /// Size down the log file if it is too big. /// /////////////////////////////////////////////////////////////////////////////////////////////////// void ErrorLogger::MaintainLogFileSize() { // Get the size of the file m_OutStream.seekp( 0, ios_base::end ); int fileSize = (int)m_OutStream.tellp(); // If the file isn't too big then bail if( fileSize < MAX_LOG_SIZE ) return; // Close the file m_OutStream.close(); // Open the file for input and output ifstream logFileStream; logFileStream.open( FILE_NAME ); // If we failed to open the file then bail if( !logFileStream ) return; // Get to the half way point in the file int halfFilePos = (fileSize / 2); logFileStream.seekg( halfFilePos, ios_base::beg ); // Read until a new line character fstream::char_type charBuffer[1] = {0}; logFileStream.read( charBuffer, 1 ); while( charBuffer[0] != '\n' && logFileStream.good() ) logFileStream.read( charBuffer, 1 ); // If we failed to find the new line character fstream::char_type *szHalfFile; int bufferSize = 0; if( !logFileStream.good() ) { // Read in half of the file bufferSize = halfFilePos; szHalfFile = new fstream::char_type[ halfFilePos ]; logFileStream.seekg( halfFilePos, ios_base::beg ); logFileStream.read( szHalfFile, halfFilePos ); } // Else copy the last half of the file else { // Get the position in the file to start reading int filePos = logFileStream.tellg(); bufferSize = fileSize - filePos; // Read in the data szHalfFile = new fstream::char_type[ bufferSize ]; logFileStream.read( szHalfFile, bufferSize ); } // Close the file for reading logFileStream.close(); // Clear the log file and clear it m_OutStream.open( FILE_NAME, ios_base::out | ios_base::trunc ); // Write the last half of the old file m_OutStream.write( szHalfFile, bufferSize ); // Free the buffer delete [] szHalfFile; // Write out a line indicating the resize std::string sResize = "\n----- File resized on "; time_t curTime = time(NULL); char szTimeDate[128] = {0}; strftime(szTimeDate, 128, "%F at %T", localtime( &curTime ) ); sResize += szTimeDate; sResize += " -----\n"; // Write out the string m_OutStream.write( sResize.c_str(), (int)sResize.length() ); }
[ "taylor@taylorclarksoftware.com" ]
taylor@taylorclarksoftware.com
b53e2c63b16fa78a445922357653c010e5592986
cbaf03b608f2410abfac46354f069436fdf5fa73
/src/lib/diagnostics/stream/cpp/log_message.cc
d862e39be84db8bc150d8b6c15c6e2429bccac22
[ "BSD-2-Clause" ]
permissive
carbonatedcaffeine/zircon-rpi
d58f302bcd0bee9394c306133fd3b20156343844
b09b1eb3aa7a127c65568229fe10edd251869283
refs/heads/master
2023-03-01T19:42:04.300854
2021-02-13T02:24:09
2021-02-13T02:24:09
null
0
0
null
null
null
null
UTF-8
C++
false
false
7,058
cc
// Copyright 2020 The Fuchsia 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 <lib/zx/stream.h> #include <lib/zx/vmo.h> #include <zircon/types.h> #include <sstream> #include <rapidjson/document.h> #include <rapidjson/error/en.h> #include <rapidjson/pointer.h> #include <src/lib/diagnostics/stream/cpp/log_message.h> #include <src/lib/fsl/vmo/strings.h> using fuchsia::diagnostics::FormattedContent; using fuchsia::logger::LogMessage; namespace diagnostics::stream { namespace { const char kPidLabel[] = "pid"; const char kTidLabel[] = "tid"; const char kTagLabel[] = "tag"; const char kTagsLabel[] = "tags"; const char kMessageLabel[] = "message"; inline int32_t StringToSeverity(const std::string& input) { if (strcasecmp(input.c_str(), "trace") == 0) { return static_cast<int32_t>(fuchsia::logger::LogLevelFilter::TRACE); } else if (strcasecmp(input.c_str(), "debug") == 0) { return static_cast<int32_t>(fuchsia::logger::LogLevelFilter::DEBUG); } else if (strcasecmp(input.c_str(), "info") == 0) { return static_cast<int32_t>(fuchsia::logger::LogLevelFilter::INFO); } else if (strcasecmp(input.c_str(), "warn") == 0) { return static_cast<int32_t>(fuchsia::logger::LogLevelFilter::WARN); } else if (strcasecmp(input.c_str(), "error") == 0) { return static_cast<int32_t>(fuchsia::logger::LogLevelFilter::ERROR); } else if (strcasecmp(input.c_str(), "fatal") == 0) { return static_cast<int32_t>(fuchsia::logger::LogLevelFilter::FATAL); } return fuchsia::logger::LOG_LEVEL_DEFAULT; } inline fit::result<LogMessage, std::string> JsonToLogMessage(rapidjson::Value& value) { LogMessage ret = {}; std::stringstream kv_mapping; if (!value.IsObject()) { return fit::error("Value is not an object"); } auto metadata = value.FindMember("metadata"); auto payload = value.FindMember("payload"); if (metadata == value.MemberEnd() || payload == value.MemberEnd() || !metadata->value.IsObject() || !payload->value.IsObject()) { return fit::error("Expected metadata and payload objects"); } auto timestamp = metadata->value.FindMember("timestamp"); if (timestamp == metadata->value.MemberEnd() || !timestamp->value.IsUint64()) { return fit::error("Expected metadata.timestamp key"); } ret.time = timestamp->value.GetUint64(); auto severity = metadata->value.FindMember("severity"); if (severity == metadata->value.MemberEnd() || !severity->value.IsString()) { return fit::error("Expected metadata.severity key"); } ret.severity = StringToSeverity(severity->value.GetString()); auto moniker = value.FindMember("moniker"); std::string moniker_string; if (moniker != value.MemberEnd() && moniker->value.IsString()) { moniker_string = std::move(moniker->value.GetString()); } uint32_t dropped_logs = 0; if (metadata->value.HasMember("errors")) { auto& errors = metadata->value["errors"]; if (errors.IsArray()) { for (rapidjson::SizeType i = 0; i < errors.Size(); i++) { auto* val = rapidjson::Pointer("/dropped_logs/count").Get(errors[i]); if (val && val->IsUint()) { dropped_logs += val->GetUint(); } } } } // Flatten payloads containing a "root" node. // TODO(fxbug.dev/63409): Remove this when "root" is omitted from logs. if (payload->value.MemberCount() == 1 && payload->value.HasMember("root")) { payload = payload->value.FindMember("root"); if (!payload->value.IsObject()) { return fit::error("Expected payload.root to be an object if present"); } } for (auto it = payload->value.MemberBegin(); it != payload->value.MemberEnd(); ++it) { if (!it->name.IsString()) { return fit::error("A key is not a string"); } std::string name = it->name.GetString(); if (name == kMessageLabel && it->value.IsString()) { ret.msg = std::move(it->value.GetString()); } else if (name == kTagLabel) { // TODO(fxbug.dev/63007): Parse only "tags" if (!it->value.IsString()) { return fit::error("Tag field must contain a single string value"); } ret.tags.emplace_back(std::move(it->value.GetString())); } else if (name == kTagsLabel) { if (it->value.IsString()) { ret.tags.emplace_back(std::move(it->value.GetString())); } else if (it->value.IsArray()) { for (rapidjson::SizeType i = 0; i < it->value.Size(); ++i) { auto& val = it->value[i]; if (!val.IsString()) { return fit::error("Tags array must contain strings"); } ret.tags.emplace_back(std::move(val.GetString())); } } else { return fit::error("Tags must be a string or array of strings"); } } else if (name == kTidLabel && it->value.IsUint64()) { ret.tid = it->value.GetUint64(); } else if (name == kPidLabel && it->value.IsUint64()) { ret.pid = it->value.GetUint64(); } else { // If the name of the field is not a known special field, treat it as a key/value pair and // append to the message. kv_mapping << " " << std::move(name) << "="; if (it->value.IsInt64()) { kv_mapping << it->value.GetInt64(); } else if (it->value.IsUint64()) { kv_mapping << it->value.GetUint64(); } else if (it->value.IsDouble()) { kv_mapping << it->value.GetDouble(); } else if (it->value.IsString()) { kv_mapping << std::move(it->value.GetString()); } else { kv_mapping << "<unknown>"; } } } ret.msg += kv_mapping.str(); // If there are no tags, automatically tag with the component moniker. if (ret.tags.size() == 0 && !moniker_string.empty()) { ret.tags.emplace_back(std::move(moniker_string)); } if (dropped_logs > 0) { ret.dropped_logs = dropped_logs; } return fit::ok(std::move(ret)); } } // namespace fit::result<std::vector<fit::result<fuchsia::logger::LogMessage, std::string>>, std::string> ConvertFormattedContentToLogMessages(FormattedContent content) { std::vector<fit::result<LogMessage, std::string>> output; if (!content.is_json()) { // Expecting JSON in all cases. return fit::error("Expected json content"); } std::string data; if (!fsl::StringFromVmo(content.json(), &data)) { return fit::error("Failed to read string from VMO"); } content.json().vmo.reset(); rapidjson::Document d; d.Parse(std::move(data)); if (d.HasParseError()) { std::string error = "Failed to parse content as JSON. Offset " + std::to_string(d.GetErrorOffset()) + ": " + rapidjson::GetParseError_En(d.GetParseError()); return fit::error(std::move(error)); } if (!d.IsArray()) { return fit::error("Expected content to contain an array"); } for (rapidjson::SizeType i = 0; i < d.Size(); ++i) { output.emplace_back(JsonToLogMessage(d[i])); } return fit::ok(std::move(output)); } } // namespace diagnostics::stream
[ "commit-bot@chromium.org" ]
commit-bot@chromium.org
061fbfe4d50b68fb2922566218a1d6c08ce0a65d
d74d110022e6ba5b1e24525e21adb00e83933dc3
/src/private/ExampleApp.h
3c9bcb974077671c9560ef82337c9c2f76eba9c7
[ "LicenseRef-scancode-unknown-license-reference", "BSD-2-Clause" ]
permissive
alainlompo/ios-api
0bb8e8cb5690d6b0cd20d316972715a5d9821c4e
f1a0be3b863314176949b012c58f4b9d54775fd9
refs/heads/master
2021-01-19T07:16:14.876204
2017-01-23T09:30:37
2017-01-23T09:30:37
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,820
h
// Copyright eeGeo Ltd (2012-2014), All Rights Reserved #pragma once #include "GlobeCamera.h" #include "EegeoWorld.h" #include "ScreenProperties.h" #include "DefaultCameraControllerFactory.h" #include "AppInterface.h" #include "GlobeCameraController.h" class ExampleApp : private Eegeo::NonCopyable { private: Examples::DefaultCameraControllerFactory* m_pCameraControllerFactory; Eegeo::Camera::GlobeCamera::GlobeCameraTouchController* m_pCameraTouchController; Eegeo::Camera::GlobeCamera::GlobeCameraController* m_pCameraController; Eegeo::EegeoWorld* m_pWorld; Eegeo::Rendering::LoadingScreen* m_pLoadingScreen; Examples::ScreenPropertiesProvider m_screenPropertiesProvider; Eegeo::EegeoWorld& World() { return * m_pWorld; } void UpdateLoadingScreen(float dt); public: ExampleApp(Eegeo::EegeoWorld* pWorld, const Eegeo::Rendering::ScreenProperties& screenProperties); ~ExampleApp(); void OnPause(); void OnResume(); void Update (float dt); void Draw (float dt); void NotifyScreenPropertiesChanged(const Eegeo::Rendering::ScreenProperties& screenProperties); Eegeo::Camera::GlobeCamera::GlobeCameraController& GetGlobeCameraController() const { return *m_pCameraController; } void SetCameraView(const Eegeo::Space::EcefTangentBasis& cameraInterestBasis, float distanceToInterest); void SetCameraView(const Eegeo::Space::EcefTangentBasis& cameraInterestBasis, float distanceToInterest, float tiltAngleDegrees); Examples::DefaultCameraControllerFactory& GetDefaultCameraControllerFactory() const { return *m_pCameraControllerFactory; } Eegeo::Camera::GlobeCamera::GlobeCameraTouchController& GetTouchController() { return *m_pCameraTouchController; } const Examples::IScreenPropertiesProvider& GetScreenPropertiesProvider() const { return m_screenPropertiesProvider; } void Event_TouchRotate (const AppInterface::RotateData& data); void Event_TouchRotate_Start (const AppInterface::RotateData& data); void Event_TouchRotate_End (const AppInterface::RotateData& data); void Event_TouchPinch (const AppInterface::PinchData& data); void Event_TouchPinch_Start (const AppInterface::PinchData& data); void Event_TouchPinch_End (const AppInterface::PinchData& data); void Event_TouchPan (const AppInterface::PanData& data); void Event_TouchPan_Start (const AppInterface::PanData& data); void Event_TouchPan_End (const AppInterface::PanData& data); void Event_TouchTap (const AppInterface::TapData& data); void Event_TouchDoubleTap (const AppInterface::TapData& data); void Event_TouchDown (const AppInterface::TouchData& data); void Event_TouchMove (const AppInterface::TouchData& data); void Event_TouchUp (const AppInterface::TouchData& data); };
[ "scott.murray@eegeo.com" ]
scott.murray@eegeo.com
f8bd8364bbad27d359c0b69e2821eeb22910eff9
3528b67d00e87fbc141169712d59fc8520885afd
/MentalGame/SegmentDrawing.cpp
ffef98c1bb75310b1b73d3d2b2371a72ffaa537f
[]
no_license
salpieiev/MentalGame
41df09a538b2ee40f9e4f51f879b1fbac2693c38
b5267642024551867f4ce73d1c13ce9ba34471a9
refs/heads/master
2021-05-27T21:58:32.019020
2014-09-14T09:06:20
2014-09-14T09:06:20
null
0
0
null
null
null
null
UTF-8
C++
false
false
3,170
cpp
// // LineDrawing.cpp // MentalGame // // Created by Sergey Alpeev on 21.02.14. // Copyright (c) 2014 Sergey Alpeev. All rights reserved. // #include "SegmentDrawing.h" #include "ProgramContainer.h" #include "PositionColorInitializer.h" #include "ProjectionModelviewInitializer.h" #include "Vertex.h" #include "VertexBuffer.h" namespace Renderer { SegmentDrawing::SegmentDrawing (): m_start(Point3()), m_end(Point3()), m_startColor(Color(1.0, 1.0, 1.0)), m_endColor(Color(1.0, 1.0, 1.0)) { vector<Vertex1P1C> vertices; vertices.push_back(Vertex1P1C(m_start, m_startColor)); vertices.push_back(Vertex1P1C(m_end, m_endColor)); m_vertexBuffer = new VertexBuffer(); m_vertexBuffer->LoadBufferData(&vertices[0], sizeof(Vertex1P1C), vertices.size(), GLSL_BUFFER_USAGE_DYNAMIC_DRAW); m_attributeInitializer = new PositionColorInitializer(); m_uniformInitializer = new ProjectionModelviewInitializer(); m_drawRequest = new VertexBufferRequest(m_vertexBuffer); m_drawRequest->SetAttributeInitializer(m_attributeInitializer); m_drawRequest->SetUniformInitializer(m_uniformInitializer); m_drawRequest->SetRenderMode(RENDER_MODE_LINES); } SegmentDrawing::~SegmentDrawing() { delete m_attributeInitializer; delete m_uniformInitializer; delete m_vertexBuffer; delete m_drawRequest; } #pragma mark - Public Methods void SegmentDrawing::SetStartPoint(const Point3 &rStart) { m_start = rStart; m_vertexBuffer->LoadBufferSubData(&m_start, 0, sizeof(Point3)); } void SegmentDrawing::SetEndPoint(const Point3 &rEnd) { m_end = rEnd; GLintptr offset = sizeof(Point3) + sizeof(Color); m_vertexBuffer->LoadBufferSubData(&m_end, offset, sizeof(Point3)); } void SegmentDrawing::SetStartColor(const Color &rStartColor) { m_startColor = rStartColor; GLintptr offset = sizeof(Point3); m_vertexBuffer->LoadBufferSubData(&m_startColor, offset, sizeof(Color)); } void SegmentDrawing::SetEndColor(const Color &rEndColor) { m_endColor = rEndColor; GLintptr offset = sizeof(Point3) + sizeof(Color) + sizeof(Point3); m_vertexBuffer->LoadBufferSubData(&m_endColor, offset, sizeof(Color)); } Point3 SegmentDrawing::GetStartPoint() const { return m_start; } Point3 SegmentDrawing::GetEndPoint() const { return m_end; } Color SegmentDrawing::GetStartColor() const { return m_startColor; } Color SegmentDrawing::GetEndColor() const { return m_endColor; } #pragma mark - Private Methods void SegmentDrawing::Update(float interval) { } void SegmentDrawing::Draw(const Matrix4 &rProjectionMatrix) const { m_uniformInitializer->SetProjectionMatrix(rProjectionMatrix); Program *pProgram = ProgramContainer::SharedInstance().GetPerspectiveProgram(); pProgram->ExecuteDrawRequest(m_drawRequest); } }
[ "sergey.alpeev@gmaiil.com" ]
sergey.alpeev@gmaiil.com
b1ad078dc7da27629db0b5b56520d1aa0edb3785
9a9529e92db9080eeac812b43f744372faea3aa3
/test/normalize_to_nfc_014.cpp
aff422697ead145c084fd88ab4a4b168b5b84671
[ "LicenseRef-scancode-unknown-license-reference", "BSL-1.0" ]
permissive
LonghronShen/text
b14c17215d8ec6ead0cf1e09fa795470fc009159
797da04625e66901390dea013a74c2638df80f21
refs/heads/master
2020-04-08T08:36:51.197496
2019-03-06T08:54:32
2019-03-06T08:54:32
159,185,388
0
0
BSL-1.0
2018-11-26T14:49:32
2018-11-26T14:49:31
null
UTF-8
C++
false
false
732,474
cpp
// 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, nfc_014_000) { // AD80;AD80;1100 116E 11BB;AD80;1100 116E 11BB; // (궀; 궀; 궀; 궀; 궀; ) HANGUL SYLLABLE GUSS { std::array<uint32_t, 1> const c1 = {{ 0xAD80 }}; std::array<uint32_t, 1> const c2 = {{ 0xAD80 }}; std::array<uint32_t, 3> const c3 = {{ 0x1100, 0x116E, 0x11BB }}; std::array<uint32_t, 1> const c4 = {{ 0xAD80 }}; std::array<uint32_t, 3> const c5 = {{ 0x1100, 0x116E, 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_001) { // AD81;AD81;1100 116E 11BC;AD81;1100 116E 11BC; // (궁; 궁; 궁; 궁; 궁; ) HANGUL SYLLABLE GUNG { std::array<uint32_t, 1> const c1 = {{ 0xAD81 }}; std::array<uint32_t, 1> const c2 = {{ 0xAD81 }}; std::array<uint32_t, 3> const c3 = {{ 0x1100, 0x116E, 0x11BC }}; std::array<uint32_t, 1> const c4 = {{ 0xAD81 }}; std::array<uint32_t, 3> const c5 = {{ 0x1100, 0x116E, 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_002) { // AD82;AD82;1100 116E 11BD;AD82;1100 116E 11BD; // (궂; 궂; 궂; 궂; 궂; ) HANGUL SYLLABLE GUJ { std::array<uint32_t, 1> const c1 = {{ 0xAD82 }}; std::array<uint32_t, 1> const c2 = {{ 0xAD82 }}; std::array<uint32_t, 3> const c3 = {{ 0x1100, 0x116E, 0x11BD }}; std::array<uint32_t, 1> const c4 = {{ 0xAD82 }}; std::array<uint32_t, 3> const c5 = {{ 0x1100, 0x116E, 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_003) { // AD83;AD83;1100 116E 11BE;AD83;1100 116E 11BE; // (궃; 궃; 궃; 궃; 궃; ) HANGUL SYLLABLE GUC { std::array<uint32_t, 1> const c1 = {{ 0xAD83 }}; std::array<uint32_t, 1> const c2 = {{ 0xAD83 }}; std::array<uint32_t, 3> const c3 = {{ 0x1100, 0x116E, 0x11BE }}; std::array<uint32_t, 1> const c4 = {{ 0xAD83 }}; std::array<uint32_t, 3> const c5 = {{ 0x1100, 0x116E, 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_004) { // AD84;AD84;1100 116E 11BF;AD84;1100 116E 11BF; // (궄; 궄; 궄; 궄; 궄; ) HANGUL SYLLABLE GUK { std::array<uint32_t, 1> const c1 = {{ 0xAD84 }}; std::array<uint32_t, 1> const c2 = {{ 0xAD84 }}; std::array<uint32_t, 3> const c3 = {{ 0x1100, 0x116E, 0x11BF }}; std::array<uint32_t, 1> const c4 = {{ 0xAD84 }}; std::array<uint32_t, 3> const c5 = {{ 0x1100, 0x116E, 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_005) { // AD85;AD85;1100 116E 11C0;AD85;1100 116E 11C0; // (궅; 궅; 궅; 궅; 궅; ) HANGUL SYLLABLE GUT { std::array<uint32_t, 1> const c1 = {{ 0xAD85 }}; std::array<uint32_t, 1> const c2 = {{ 0xAD85 }}; std::array<uint32_t, 3> const c3 = {{ 0x1100, 0x116E, 0x11C0 }}; std::array<uint32_t, 1> const c4 = {{ 0xAD85 }}; std::array<uint32_t, 3> const c5 = {{ 0x1100, 0x116E, 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_006) { // AD86;AD86;1100 116E 11C1;AD86;1100 116E 11C1; // (궆; 궆; 궆; 궆; 궆; ) HANGUL SYLLABLE GUP { std::array<uint32_t, 1> const c1 = {{ 0xAD86 }}; std::array<uint32_t, 1> const c2 = {{ 0xAD86 }}; std::array<uint32_t, 3> const c3 = {{ 0x1100, 0x116E, 0x11C1 }}; std::array<uint32_t, 1> const c4 = {{ 0xAD86 }}; std::array<uint32_t, 3> const c5 = {{ 0x1100, 0x116E, 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_007) { // AD87;AD87;1100 116E 11C2;AD87;1100 116E 11C2; // (궇; 궇; 궇; 궇; 궇; ) HANGUL SYLLABLE GUH { std::array<uint32_t, 1> const c1 = {{ 0xAD87 }}; std::array<uint32_t, 1> const c2 = {{ 0xAD87 }}; std::array<uint32_t, 3> const c3 = {{ 0x1100, 0x116E, 0x11C2 }}; std::array<uint32_t, 1> const c4 = {{ 0xAD87 }}; std::array<uint32_t, 3> const c5 = {{ 0x1100, 0x116E, 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_008) { // AD88;AD88;1100 116F;AD88;1100 116F; // (궈; 궈; 궈; 궈; 궈; ) HANGUL SYLLABLE GWEO { std::array<uint32_t, 1> const c1 = {{ 0xAD88 }}; std::array<uint32_t, 1> const c2 = {{ 0xAD88 }}; std::array<uint32_t, 2> const c3 = {{ 0x1100, 0x116F }}; std::array<uint32_t, 1> const c4 = {{ 0xAD88 }}; std::array<uint32_t, 2> const c5 = {{ 0x1100, 0x116F }}; 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_009) { // AD89;AD89;1100 116F 11A8;AD89;1100 116F 11A8; // (궉; 궉; 궉; 궉; 궉; ) HANGUL SYLLABLE GWEOG { std::array<uint32_t, 1> const c1 = {{ 0xAD89 }}; std::array<uint32_t, 1> const c2 = {{ 0xAD89 }}; std::array<uint32_t, 3> const c3 = {{ 0x1100, 0x116F, 0x11A8 }}; std::array<uint32_t, 1> const c4 = {{ 0xAD89 }}; std::array<uint32_t, 3> const c5 = {{ 0x1100, 0x116F, 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_010) { // AD8A;AD8A;1100 116F 11A9;AD8A;1100 116F 11A9; // (궊; 궊; 궊; 궊; 궊; ) HANGUL SYLLABLE GWEOGG { std::array<uint32_t, 1> const c1 = {{ 0xAD8A }}; std::array<uint32_t, 1> const c2 = {{ 0xAD8A }}; std::array<uint32_t, 3> const c3 = {{ 0x1100, 0x116F, 0x11A9 }}; std::array<uint32_t, 1> const c4 = {{ 0xAD8A }}; std::array<uint32_t, 3> const c5 = {{ 0x1100, 0x116F, 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_011) { // AD8B;AD8B;1100 116F 11AA;AD8B;1100 116F 11AA; // (궋; 궋; 궋; 궋; 궋; ) HANGUL SYLLABLE GWEOGS { std::array<uint32_t, 1> const c1 = {{ 0xAD8B }}; std::array<uint32_t, 1> const c2 = {{ 0xAD8B }}; std::array<uint32_t, 3> const c3 = {{ 0x1100, 0x116F, 0x11AA }}; std::array<uint32_t, 1> const c4 = {{ 0xAD8B }}; std::array<uint32_t, 3> const c5 = {{ 0x1100, 0x116F, 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_012) { // AD8C;AD8C;1100 116F 11AB;AD8C;1100 116F 11AB; // (권; 권; 권; 권; 권; ) HANGUL SYLLABLE GWEON { std::array<uint32_t, 1> const c1 = {{ 0xAD8C }}; std::array<uint32_t, 1> const c2 = {{ 0xAD8C }}; std::array<uint32_t, 3> const c3 = {{ 0x1100, 0x116F, 0x11AB }}; std::array<uint32_t, 1> const c4 = {{ 0xAD8C }}; std::array<uint32_t, 3> const c5 = {{ 0x1100, 0x116F, 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_013) { // AD8D;AD8D;1100 116F 11AC;AD8D;1100 116F 11AC; // (궍; 궍; 궍; 궍; 궍; ) HANGUL SYLLABLE GWEONJ { std::array<uint32_t, 1> const c1 = {{ 0xAD8D }}; std::array<uint32_t, 1> const c2 = {{ 0xAD8D }}; std::array<uint32_t, 3> const c3 = {{ 0x1100, 0x116F, 0x11AC }}; std::array<uint32_t, 1> const c4 = {{ 0xAD8D }}; std::array<uint32_t, 3> const c5 = {{ 0x1100, 0x116F, 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_014) { // AD8E;AD8E;1100 116F 11AD;AD8E;1100 116F 11AD; // (궎; 궎; 궎; 궎; 궎; ) HANGUL SYLLABLE GWEONH { std::array<uint32_t, 1> const c1 = {{ 0xAD8E }}; std::array<uint32_t, 1> const c2 = {{ 0xAD8E }}; std::array<uint32_t, 3> const c3 = {{ 0x1100, 0x116F, 0x11AD }}; std::array<uint32_t, 1> const c4 = {{ 0xAD8E }}; std::array<uint32_t, 3> const c5 = {{ 0x1100, 0x116F, 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_015) { // AD8F;AD8F;1100 116F 11AE;AD8F;1100 116F 11AE; // (궏; 궏; 궏; 궏; 궏; ) HANGUL SYLLABLE GWEOD { std::array<uint32_t, 1> const c1 = {{ 0xAD8F }}; std::array<uint32_t, 1> const c2 = {{ 0xAD8F }}; std::array<uint32_t, 3> const c3 = {{ 0x1100, 0x116F, 0x11AE }}; std::array<uint32_t, 1> const c4 = {{ 0xAD8F }}; std::array<uint32_t, 3> const c5 = {{ 0x1100, 0x116F, 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_016) { // AD90;AD90;1100 116F 11AF;AD90;1100 116F 11AF; // (궐; 궐; 궐; 궐; 궐; ) HANGUL SYLLABLE GWEOL { std::array<uint32_t, 1> const c1 = {{ 0xAD90 }}; std::array<uint32_t, 1> const c2 = {{ 0xAD90 }}; std::array<uint32_t, 3> const c3 = {{ 0x1100, 0x116F, 0x11AF }}; std::array<uint32_t, 1> const c4 = {{ 0xAD90 }}; std::array<uint32_t, 3> const c5 = {{ 0x1100, 0x116F, 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_017) { // AD91;AD91;1100 116F 11B0;AD91;1100 116F 11B0; // (궑; 궑; 궑; 궑; 궑; ) HANGUL SYLLABLE GWEOLG { std::array<uint32_t, 1> const c1 = {{ 0xAD91 }}; std::array<uint32_t, 1> const c2 = {{ 0xAD91 }}; std::array<uint32_t, 3> const c3 = {{ 0x1100, 0x116F, 0x11B0 }}; std::array<uint32_t, 1> const c4 = {{ 0xAD91 }}; std::array<uint32_t, 3> const c5 = {{ 0x1100, 0x116F, 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_018) { // AD92;AD92;1100 116F 11B1;AD92;1100 116F 11B1; // (궒; 궒; 궒; 궒; 궒; ) HANGUL SYLLABLE GWEOLM { std::array<uint32_t, 1> const c1 = {{ 0xAD92 }}; std::array<uint32_t, 1> const c2 = {{ 0xAD92 }}; std::array<uint32_t, 3> const c3 = {{ 0x1100, 0x116F, 0x11B1 }}; std::array<uint32_t, 1> const c4 = {{ 0xAD92 }}; std::array<uint32_t, 3> const c5 = {{ 0x1100, 0x116F, 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_019) { // AD93;AD93;1100 116F 11B2;AD93;1100 116F 11B2; // (궓; 궓; 궓; 궓; 궓; ) HANGUL SYLLABLE GWEOLB { std::array<uint32_t, 1> const c1 = {{ 0xAD93 }}; std::array<uint32_t, 1> const c2 = {{ 0xAD93 }}; std::array<uint32_t, 3> const c3 = {{ 0x1100, 0x116F, 0x11B2 }}; std::array<uint32_t, 1> const c4 = {{ 0xAD93 }}; std::array<uint32_t, 3> const c5 = {{ 0x1100, 0x116F, 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_020) { // AD94;AD94;1100 116F 11B3;AD94;1100 116F 11B3; // (궔; 궔; 궔; 궔; 궔; ) HANGUL SYLLABLE GWEOLS { std::array<uint32_t, 1> const c1 = {{ 0xAD94 }}; std::array<uint32_t, 1> const c2 = {{ 0xAD94 }}; std::array<uint32_t, 3> const c3 = {{ 0x1100, 0x116F, 0x11B3 }}; std::array<uint32_t, 1> const c4 = {{ 0xAD94 }}; std::array<uint32_t, 3> const c5 = {{ 0x1100, 0x116F, 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_021) { // AD95;AD95;1100 116F 11B4;AD95;1100 116F 11B4; // (궕; 궕; 궕; 궕; 궕; ) HANGUL SYLLABLE GWEOLT { std::array<uint32_t, 1> const c1 = {{ 0xAD95 }}; std::array<uint32_t, 1> const c2 = {{ 0xAD95 }}; std::array<uint32_t, 3> const c3 = {{ 0x1100, 0x116F, 0x11B4 }}; std::array<uint32_t, 1> const c4 = {{ 0xAD95 }}; std::array<uint32_t, 3> const c5 = {{ 0x1100, 0x116F, 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_022) { // AD96;AD96;1100 116F 11B5;AD96;1100 116F 11B5; // (궖; 궖; 궖; 궖; 궖; ) HANGUL SYLLABLE GWEOLP { std::array<uint32_t, 1> const c1 = {{ 0xAD96 }}; std::array<uint32_t, 1> const c2 = {{ 0xAD96 }}; std::array<uint32_t, 3> const c3 = {{ 0x1100, 0x116F, 0x11B5 }}; std::array<uint32_t, 1> const c4 = {{ 0xAD96 }}; std::array<uint32_t, 3> const c5 = {{ 0x1100, 0x116F, 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_023) { // AD97;AD97;1100 116F 11B6;AD97;1100 116F 11B6; // (궗; 궗; 궗; 궗; 궗; ) HANGUL SYLLABLE GWEOLH { std::array<uint32_t, 1> const c1 = {{ 0xAD97 }}; std::array<uint32_t, 1> const c2 = {{ 0xAD97 }}; std::array<uint32_t, 3> const c3 = {{ 0x1100, 0x116F, 0x11B6 }}; std::array<uint32_t, 1> const c4 = {{ 0xAD97 }}; std::array<uint32_t, 3> const c5 = {{ 0x1100, 0x116F, 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_024) { // AD98;AD98;1100 116F 11B7;AD98;1100 116F 11B7; // (궘; 궘; 궘; 궘; 궘; ) HANGUL SYLLABLE GWEOM { std::array<uint32_t, 1> const c1 = {{ 0xAD98 }}; std::array<uint32_t, 1> const c2 = {{ 0xAD98 }}; std::array<uint32_t, 3> const c3 = {{ 0x1100, 0x116F, 0x11B7 }}; std::array<uint32_t, 1> const c4 = {{ 0xAD98 }}; std::array<uint32_t, 3> const c5 = {{ 0x1100, 0x116F, 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_025) { // AD99;AD99;1100 116F 11B8;AD99;1100 116F 11B8; // (궙; 궙; 궙; 궙; 궙; ) HANGUL SYLLABLE GWEOB { std::array<uint32_t, 1> const c1 = {{ 0xAD99 }}; std::array<uint32_t, 1> const c2 = {{ 0xAD99 }}; std::array<uint32_t, 3> const c3 = {{ 0x1100, 0x116F, 0x11B8 }}; std::array<uint32_t, 1> const c4 = {{ 0xAD99 }}; std::array<uint32_t, 3> const c5 = {{ 0x1100, 0x116F, 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_026) { // AD9A;AD9A;1100 116F 11B9;AD9A;1100 116F 11B9; // (궚; 궚; 궚; 궚; 궚; ) HANGUL SYLLABLE GWEOBS { std::array<uint32_t, 1> const c1 = {{ 0xAD9A }}; std::array<uint32_t, 1> const c2 = {{ 0xAD9A }}; std::array<uint32_t, 3> const c3 = {{ 0x1100, 0x116F, 0x11B9 }}; std::array<uint32_t, 1> const c4 = {{ 0xAD9A }}; std::array<uint32_t, 3> const c5 = {{ 0x1100, 0x116F, 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_027) { // AD9B;AD9B;1100 116F 11BA;AD9B;1100 116F 11BA; // (궛; 궛; 궛; 궛; 궛; ) HANGUL SYLLABLE GWEOS { std::array<uint32_t, 1> const c1 = {{ 0xAD9B }}; std::array<uint32_t, 1> const c2 = {{ 0xAD9B }}; std::array<uint32_t, 3> const c3 = {{ 0x1100, 0x116F, 0x11BA }}; std::array<uint32_t, 1> const c4 = {{ 0xAD9B }}; std::array<uint32_t, 3> const c5 = {{ 0x1100, 0x116F, 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_028) { // AD9C;AD9C;1100 116F 11BB;AD9C;1100 116F 11BB; // (궜; 궜; 궜; 궜; 궜; ) HANGUL SYLLABLE GWEOSS { std::array<uint32_t, 1> const c1 = {{ 0xAD9C }}; std::array<uint32_t, 1> const c2 = {{ 0xAD9C }}; std::array<uint32_t, 3> const c3 = {{ 0x1100, 0x116F, 0x11BB }}; std::array<uint32_t, 1> const c4 = {{ 0xAD9C }}; std::array<uint32_t, 3> const c5 = {{ 0x1100, 0x116F, 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_029) { // AD9D;AD9D;1100 116F 11BC;AD9D;1100 116F 11BC; // (궝; 궝; 궝; 궝; 궝; ) HANGUL SYLLABLE GWEONG { std::array<uint32_t, 1> const c1 = {{ 0xAD9D }}; std::array<uint32_t, 1> const c2 = {{ 0xAD9D }}; std::array<uint32_t, 3> const c3 = {{ 0x1100, 0x116F, 0x11BC }}; std::array<uint32_t, 1> const c4 = {{ 0xAD9D }}; std::array<uint32_t, 3> const c5 = {{ 0x1100, 0x116F, 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_030) { // AD9E;AD9E;1100 116F 11BD;AD9E;1100 116F 11BD; // (궞; 궞; 궞; 궞; 궞; ) HANGUL SYLLABLE GWEOJ { std::array<uint32_t, 1> const c1 = {{ 0xAD9E }}; std::array<uint32_t, 1> const c2 = {{ 0xAD9E }}; std::array<uint32_t, 3> const c3 = {{ 0x1100, 0x116F, 0x11BD }}; std::array<uint32_t, 1> const c4 = {{ 0xAD9E }}; std::array<uint32_t, 3> const c5 = {{ 0x1100, 0x116F, 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_031) { // AD9F;AD9F;1100 116F 11BE;AD9F;1100 116F 11BE; // (궟; 궟; 궟; 궟; 궟; ) HANGUL SYLLABLE GWEOC { std::array<uint32_t, 1> const c1 = {{ 0xAD9F }}; std::array<uint32_t, 1> const c2 = {{ 0xAD9F }}; std::array<uint32_t, 3> const c3 = {{ 0x1100, 0x116F, 0x11BE }}; std::array<uint32_t, 1> const c4 = {{ 0xAD9F }}; std::array<uint32_t, 3> const c5 = {{ 0x1100, 0x116F, 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_032) { // ADA0;ADA0;1100 116F 11BF;ADA0;1100 116F 11BF; // (궠; 궠; 궠; 궠; 궠; ) HANGUL SYLLABLE GWEOK { std::array<uint32_t, 1> const c1 = {{ 0xADA0 }}; std::array<uint32_t, 1> const c2 = {{ 0xADA0 }}; std::array<uint32_t, 3> const c3 = {{ 0x1100, 0x116F, 0x11BF }}; std::array<uint32_t, 1> const c4 = {{ 0xADA0 }}; std::array<uint32_t, 3> const c5 = {{ 0x1100, 0x116F, 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_033) { // ADA1;ADA1;1100 116F 11C0;ADA1;1100 116F 11C0; // (궡; 궡; 궡; 궡; 궡; ) HANGUL SYLLABLE GWEOT { std::array<uint32_t, 1> const c1 = {{ 0xADA1 }}; std::array<uint32_t, 1> const c2 = {{ 0xADA1 }}; std::array<uint32_t, 3> const c3 = {{ 0x1100, 0x116F, 0x11C0 }}; std::array<uint32_t, 1> const c4 = {{ 0xADA1 }}; std::array<uint32_t, 3> const c5 = {{ 0x1100, 0x116F, 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_034) { // ADA2;ADA2;1100 116F 11C1;ADA2;1100 116F 11C1; // (궢; 궢; 궢; 궢; 궢; ) HANGUL SYLLABLE GWEOP { std::array<uint32_t, 1> const c1 = {{ 0xADA2 }}; std::array<uint32_t, 1> const c2 = {{ 0xADA2 }}; std::array<uint32_t, 3> const c3 = {{ 0x1100, 0x116F, 0x11C1 }}; std::array<uint32_t, 1> const c4 = {{ 0xADA2 }}; std::array<uint32_t, 3> const c5 = {{ 0x1100, 0x116F, 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_035) { // ADA3;ADA3;1100 116F 11C2;ADA3;1100 116F 11C2; // (궣; 궣; 궣; 궣; 궣; ) HANGUL SYLLABLE GWEOH { std::array<uint32_t, 1> const c1 = {{ 0xADA3 }}; std::array<uint32_t, 1> const c2 = {{ 0xADA3 }}; std::array<uint32_t, 3> const c3 = {{ 0x1100, 0x116F, 0x11C2 }}; std::array<uint32_t, 1> const c4 = {{ 0xADA3 }}; std::array<uint32_t, 3> const c5 = {{ 0x1100, 0x116F, 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_036) { // ADA4;ADA4;1100 1170;ADA4;1100 1170; // (궤; 궤; 궤; 궤; 궤; ) HANGUL SYLLABLE GWE { std::array<uint32_t, 1> const c1 = {{ 0xADA4 }}; std::array<uint32_t, 1> const c2 = {{ 0xADA4 }}; std::array<uint32_t, 2> const c3 = {{ 0x1100, 0x1170 }}; std::array<uint32_t, 1> const c4 = {{ 0xADA4 }}; std::array<uint32_t, 2> const c5 = {{ 0x1100, 0x1170 }}; 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_037) { // ADA5;ADA5;1100 1170 11A8;ADA5;1100 1170 11A8; // (궥; 궥; 궥; 궥; 궥; ) HANGUL SYLLABLE GWEG { std::array<uint32_t, 1> const c1 = {{ 0xADA5 }}; std::array<uint32_t, 1> const c2 = {{ 0xADA5 }}; std::array<uint32_t, 3> const c3 = {{ 0x1100, 0x1170, 0x11A8 }}; std::array<uint32_t, 1> const c4 = {{ 0xADA5 }}; std::array<uint32_t, 3> const c5 = {{ 0x1100, 0x1170, 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_038) { // ADA6;ADA6;1100 1170 11A9;ADA6;1100 1170 11A9; // (궦; 궦; 궦; 궦; 궦; ) HANGUL SYLLABLE GWEGG { std::array<uint32_t, 1> const c1 = {{ 0xADA6 }}; std::array<uint32_t, 1> const c2 = {{ 0xADA6 }}; std::array<uint32_t, 3> const c3 = {{ 0x1100, 0x1170, 0x11A9 }}; std::array<uint32_t, 1> const c4 = {{ 0xADA6 }}; std::array<uint32_t, 3> const c5 = {{ 0x1100, 0x1170, 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_039) { // ADA7;ADA7;1100 1170 11AA;ADA7;1100 1170 11AA; // (궧; 궧; 궧; 궧; 궧; ) HANGUL SYLLABLE GWEGS { std::array<uint32_t, 1> const c1 = {{ 0xADA7 }}; std::array<uint32_t, 1> const c2 = {{ 0xADA7 }}; std::array<uint32_t, 3> const c3 = {{ 0x1100, 0x1170, 0x11AA }}; std::array<uint32_t, 1> const c4 = {{ 0xADA7 }}; std::array<uint32_t, 3> const c5 = {{ 0x1100, 0x1170, 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_040) { // ADA8;ADA8;1100 1170 11AB;ADA8;1100 1170 11AB; // (궨; 궨; 궨; 궨; 궨; ) HANGUL SYLLABLE GWEN { std::array<uint32_t, 1> const c1 = {{ 0xADA8 }}; std::array<uint32_t, 1> const c2 = {{ 0xADA8 }}; std::array<uint32_t, 3> const c3 = {{ 0x1100, 0x1170, 0x11AB }}; std::array<uint32_t, 1> const c4 = {{ 0xADA8 }}; std::array<uint32_t, 3> const c5 = {{ 0x1100, 0x1170, 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_041) { // ADA9;ADA9;1100 1170 11AC;ADA9;1100 1170 11AC; // (궩; 궩; 궩; 궩; 궩; ) HANGUL SYLLABLE GWENJ { std::array<uint32_t, 1> const c1 = {{ 0xADA9 }}; std::array<uint32_t, 1> const c2 = {{ 0xADA9 }}; std::array<uint32_t, 3> const c3 = {{ 0x1100, 0x1170, 0x11AC }}; std::array<uint32_t, 1> const c4 = {{ 0xADA9 }}; std::array<uint32_t, 3> const c5 = {{ 0x1100, 0x1170, 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_042) { // ADAA;ADAA;1100 1170 11AD;ADAA;1100 1170 11AD; // (궪; 궪; 궪; 궪; 궪; ) HANGUL SYLLABLE GWENH { std::array<uint32_t, 1> const c1 = {{ 0xADAA }}; std::array<uint32_t, 1> const c2 = {{ 0xADAA }}; std::array<uint32_t, 3> const c3 = {{ 0x1100, 0x1170, 0x11AD }}; std::array<uint32_t, 1> const c4 = {{ 0xADAA }}; std::array<uint32_t, 3> const c5 = {{ 0x1100, 0x1170, 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_043) { // ADAB;ADAB;1100 1170 11AE;ADAB;1100 1170 11AE; // (궫; 궫; 궫; 궫; 궫; ) HANGUL SYLLABLE GWED { std::array<uint32_t, 1> const c1 = {{ 0xADAB }}; std::array<uint32_t, 1> const c2 = {{ 0xADAB }}; std::array<uint32_t, 3> const c3 = {{ 0x1100, 0x1170, 0x11AE }}; std::array<uint32_t, 1> const c4 = {{ 0xADAB }}; std::array<uint32_t, 3> const c5 = {{ 0x1100, 0x1170, 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_044) { // ADAC;ADAC;1100 1170 11AF;ADAC;1100 1170 11AF; // (궬; 궬; 궬; 궬; 궬; ) HANGUL SYLLABLE GWEL { std::array<uint32_t, 1> const c1 = {{ 0xADAC }}; std::array<uint32_t, 1> const c2 = {{ 0xADAC }}; std::array<uint32_t, 3> const c3 = {{ 0x1100, 0x1170, 0x11AF }}; std::array<uint32_t, 1> const c4 = {{ 0xADAC }}; std::array<uint32_t, 3> const c5 = {{ 0x1100, 0x1170, 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_045) { // ADAD;ADAD;1100 1170 11B0;ADAD;1100 1170 11B0; // (궭; 궭; 궭; 궭; 궭; ) HANGUL SYLLABLE GWELG { std::array<uint32_t, 1> const c1 = {{ 0xADAD }}; std::array<uint32_t, 1> const c2 = {{ 0xADAD }}; std::array<uint32_t, 3> const c3 = {{ 0x1100, 0x1170, 0x11B0 }}; std::array<uint32_t, 1> const c4 = {{ 0xADAD }}; std::array<uint32_t, 3> const c5 = {{ 0x1100, 0x1170, 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_046) { // ADAE;ADAE;1100 1170 11B1;ADAE;1100 1170 11B1; // (궮; 궮; 궮; 궮; 궮; ) HANGUL SYLLABLE GWELM { std::array<uint32_t, 1> const c1 = {{ 0xADAE }}; std::array<uint32_t, 1> const c2 = {{ 0xADAE }}; std::array<uint32_t, 3> const c3 = {{ 0x1100, 0x1170, 0x11B1 }}; std::array<uint32_t, 1> const c4 = {{ 0xADAE }}; std::array<uint32_t, 3> const c5 = {{ 0x1100, 0x1170, 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_047) { // ADAF;ADAF;1100 1170 11B2;ADAF;1100 1170 11B2; // (궯; 궯; 궯; 궯; 궯; ) HANGUL SYLLABLE GWELB { std::array<uint32_t, 1> const c1 = {{ 0xADAF }}; std::array<uint32_t, 1> const c2 = {{ 0xADAF }}; std::array<uint32_t, 3> const c3 = {{ 0x1100, 0x1170, 0x11B2 }}; std::array<uint32_t, 1> const c4 = {{ 0xADAF }}; std::array<uint32_t, 3> const c5 = {{ 0x1100, 0x1170, 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_048) { // ADB0;ADB0;1100 1170 11B3;ADB0;1100 1170 11B3; // (궰; 궰; 궰; 궰; 궰; ) HANGUL SYLLABLE GWELS { std::array<uint32_t, 1> const c1 = {{ 0xADB0 }}; std::array<uint32_t, 1> const c2 = {{ 0xADB0 }}; std::array<uint32_t, 3> const c3 = {{ 0x1100, 0x1170, 0x11B3 }}; std::array<uint32_t, 1> const c4 = {{ 0xADB0 }}; std::array<uint32_t, 3> const c5 = {{ 0x1100, 0x1170, 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_049) { // ADB1;ADB1;1100 1170 11B4;ADB1;1100 1170 11B4; // (궱; 궱; 궱; 궱; 궱; ) HANGUL SYLLABLE GWELT { std::array<uint32_t, 1> const c1 = {{ 0xADB1 }}; std::array<uint32_t, 1> const c2 = {{ 0xADB1 }}; std::array<uint32_t, 3> const c3 = {{ 0x1100, 0x1170, 0x11B4 }}; std::array<uint32_t, 1> const c4 = {{ 0xADB1 }}; std::array<uint32_t, 3> const c5 = {{ 0x1100, 0x1170, 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_050) { // ADB2;ADB2;1100 1170 11B5;ADB2;1100 1170 11B5; // (궲; 궲; 궲; 궲; 궲; ) HANGUL SYLLABLE GWELP { std::array<uint32_t, 1> const c1 = {{ 0xADB2 }}; std::array<uint32_t, 1> const c2 = {{ 0xADB2 }}; std::array<uint32_t, 3> const c3 = {{ 0x1100, 0x1170, 0x11B5 }}; std::array<uint32_t, 1> const c4 = {{ 0xADB2 }}; std::array<uint32_t, 3> const c5 = {{ 0x1100, 0x1170, 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_051) { // ADB3;ADB3;1100 1170 11B6;ADB3;1100 1170 11B6; // (궳; 궳; 궳; 궳; 궳; ) HANGUL SYLLABLE GWELH { std::array<uint32_t, 1> const c1 = {{ 0xADB3 }}; std::array<uint32_t, 1> const c2 = {{ 0xADB3 }}; std::array<uint32_t, 3> const c3 = {{ 0x1100, 0x1170, 0x11B6 }}; std::array<uint32_t, 1> const c4 = {{ 0xADB3 }}; std::array<uint32_t, 3> const c5 = {{ 0x1100, 0x1170, 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_052) { // ADB4;ADB4;1100 1170 11B7;ADB4;1100 1170 11B7; // (궴; 궴; 궴; 궴; 궴; ) HANGUL SYLLABLE GWEM { std::array<uint32_t, 1> const c1 = {{ 0xADB4 }}; std::array<uint32_t, 1> const c2 = {{ 0xADB4 }}; std::array<uint32_t, 3> const c3 = {{ 0x1100, 0x1170, 0x11B7 }}; std::array<uint32_t, 1> const c4 = {{ 0xADB4 }}; std::array<uint32_t, 3> const c5 = {{ 0x1100, 0x1170, 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_053) { // ADB5;ADB5;1100 1170 11B8;ADB5;1100 1170 11B8; // (궵; 궵; 궵; 궵; 궵; ) HANGUL SYLLABLE GWEB { std::array<uint32_t, 1> const c1 = {{ 0xADB5 }}; std::array<uint32_t, 1> const c2 = {{ 0xADB5 }}; std::array<uint32_t, 3> const c3 = {{ 0x1100, 0x1170, 0x11B8 }}; std::array<uint32_t, 1> const c4 = {{ 0xADB5 }}; std::array<uint32_t, 3> const c5 = {{ 0x1100, 0x1170, 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_054) { // ADB6;ADB6;1100 1170 11B9;ADB6;1100 1170 11B9; // (궶; 궶; 궶; 궶; 궶; ) HANGUL SYLLABLE GWEBS { std::array<uint32_t, 1> const c1 = {{ 0xADB6 }}; std::array<uint32_t, 1> const c2 = {{ 0xADB6 }}; std::array<uint32_t, 3> const c3 = {{ 0x1100, 0x1170, 0x11B9 }}; std::array<uint32_t, 1> const c4 = {{ 0xADB6 }}; std::array<uint32_t, 3> const c5 = {{ 0x1100, 0x1170, 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_055) { // ADB7;ADB7;1100 1170 11BA;ADB7;1100 1170 11BA; // (궷; 궷; 궷; 궷; 궷; ) HANGUL SYLLABLE GWES { std::array<uint32_t, 1> const c1 = {{ 0xADB7 }}; std::array<uint32_t, 1> const c2 = {{ 0xADB7 }}; std::array<uint32_t, 3> const c3 = {{ 0x1100, 0x1170, 0x11BA }}; std::array<uint32_t, 1> const c4 = {{ 0xADB7 }}; std::array<uint32_t, 3> const c5 = {{ 0x1100, 0x1170, 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_056) { // ADB8;ADB8;1100 1170 11BB;ADB8;1100 1170 11BB; // (궸; 궸; 궸; 궸; 궸; ) HANGUL SYLLABLE GWESS { std::array<uint32_t, 1> const c1 = {{ 0xADB8 }}; std::array<uint32_t, 1> const c2 = {{ 0xADB8 }}; std::array<uint32_t, 3> const c3 = {{ 0x1100, 0x1170, 0x11BB }}; std::array<uint32_t, 1> const c4 = {{ 0xADB8 }}; std::array<uint32_t, 3> const c5 = {{ 0x1100, 0x1170, 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_057) { // ADB9;ADB9;1100 1170 11BC;ADB9;1100 1170 11BC; // (궹; 궹; 궹; 궹; 궹; ) HANGUL SYLLABLE GWENG { std::array<uint32_t, 1> const c1 = {{ 0xADB9 }}; std::array<uint32_t, 1> const c2 = {{ 0xADB9 }}; std::array<uint32_t, 3> const c3 = {{ 0x1100, 0x1170, 0x11BC }}; std::array<uint32_t, 1> const c4 = {{ 0xADB9 }}; std::array<uint32_t, 3> const c5 = {{ 0x1100, 0x1170, 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_058) { // ADBA;ADBA;1100 1170 11BD;ADBA;1100 1170 11BD; // (궺; 궺; 궺; 궺; 궺; ) HANGUL SYLLABLE GWEJ { std::array<uint32_t, 1> const c1 = {{ 0xADBA }}; std::array<uint32_t, 1> const c2 = {{ 0xADBA }}; std::array<uint32_t, 3> const c3 = {{ 0x1100, 0x1170, 0x11BD }}; std::array<uint32_t, 1> const c4 = {{ 0xADBA }}; std::array<uint32_t, 3> const c5 = {{ 0x1100, 0x1170, 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_059) { // ADBB;ADBB;1100 1170 11BE;ADBB;1100 1170 11BE; // (궻; 궻; 궻; 궻; 궻; ) HANGUL SYLLABLE GWEC { std::array<uint32_t, 1> const c1 = {{ 0xADBB }}; std::array<uint32_t, 1> const c2 = {{ 0xADBB }}; std::array<uint32_t, 3> const c3 = {{ 0x1100, 0x1170, 0x11BE }}; std::array<uint32_t, 1> const c4 = {{ 0xADBB }}; std::array<uint32_t, 3> const c5 = {{ 0x1100, 0x1170, 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_060) { // ADBC;ADBC;1100 1170 11BF;ADBC;1100 1170 11BF; // (궼; 궼; 궼; 궼; 궼; ) HANGUL SYLLABLE GWEK { std::array<uint32_t, 1> const c1 = {{ 0xADBC }}; std::array<uint32_t, 1> const c2 = {{ 0xADBC }}; std::array<uint32_t, 3> const c3 = {{ 0x1100, 0x1170, 0x11BF }}; std::array<uint32_t, 1> const c4 = {{ 0xADBC }}; std::array<uint32_t, 3> const c5 = {{ 0x1100, 0x1170, 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_061) { // ADBD;ADBD;1100 1170 11C0;ADBD;1100 1170 11C0; // (궽; 궽; 궽; 궽; 궽; ) HANGUL SYLLABLE GWET { std::array<uint32_t, 1> const c1 = {{ 0xADBD }}; std::array<uint32_t, 1> const c2 = {{ 0xADBD }}; std::array<uint32_t, 3> const c3 = {{ 0x1100, 0x1170, 0x11C0 }}; std::array<uint32_t, 1> const c4 = {{ 0xADBD }}; std::array<uint32_t, 3> const c5 = {{ 0x1100, 0x1170, 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_062) { // ADBE;ADBE;1100 1170 11C1;ADBE;1100 1170 11C1; // (궾; 궾; 궾; 궾; 궾; ) HANGUL SYLLABLE GWEP { std::array<uint32_t, 1> const c1 = {{ 0xADBE }}; std::array<uint32_t, 1> const c2 = {{ 0xADBE }}; std::array<uint32_t, 3> const c3 = {{ 0x1100, 0x1170, 0x11C1 }}; std::array<uint32_t, 1> const c4 = {{ 0xADBE }}; std::array<uint32_t, 3> const c5 = {{ 0x1100, 0x1170, 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_063) { // ADBF;ADBF;1100 1170 11C2;ADBF;1100 1170 11C2; // (궿; 궿; 궿; 궿; 궿; ) HANGUL SYLLABLE GWEH { std::array<uint32_t, 1> const c1 = {{ 0xADBF }}; std::array<uint32_t, 1> const c2 = {{ 0xADBF }}; std::array<uint32_t, 3> const c3 = {{ 0x1100, 0x1170, 0x11C2 }}; std::array<uint32_t, 1> const c4 = {{ 0xADBF }}; std::array<uint32_t, 3> const c5 = {{ 0x1100, 0x1170, 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_064) { // ADC0;ADC0;1100 1171;ADC0;1100 1171; // (귀; 귀; 귀; 귀; 귀; ) HANGUL SYLLABLE GWI { std::array<uint32_t, 1> const c1 = {{ 0xADC0 }}; std::array<uint32_t, 1> const c2 = {{ 0xADC0 }}; std::array<uint32_t, 2> const c3 = {{ 0x1100, 0x1171 }}; std::array<uint32_t, 1> const c4 = {{ 0xADC0 }}; std::array<uint32_t, 2> const c5 = {{ 0x1100, 0x1171 }}; 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_065) { // ADC1;ADC1;1100 1171 11A8;ADC1;1100 1171 11A8; // (귁; 귁; 귁; 귁; 귁; ) HANGUL SYLLABLE GWIG { std::array<uint32_t, 1> const c1 = {{ 0xADC1 }}; std::array<uint32_t, 1> const c2 = {{ 0xADC1 }}; std::array<uint32_t, 3> const c3 = {{ 0x1100, 0x1171, 0x11A8 }}; std::array<uint32_t, 1> const c4 = {{ 0xADC1 }}; std::array<uint32_t, 3> const c5 = {{ 0x1100, 0x1171, 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_066) { // ADC2;ADC2;1100 1171 11A9;ADC2;1100 1171 11A9; // (귂; 귂; 귂; 귂; 귂; ) HANGUL SYLLABLE GWIGG { std::array<uint32_t, 1> const c1 = {{ 0xADC2 }}; std::array<uint32_t, 1> const c2 = {{ 0xADC2 }}; std::array<uint32_t, 3> const c3 = {{ 0x1100, 0x1171, 0x11A9 }}; std::array<uint32_t, 1> const c4 = {{ 0xADC2 }}; std::array<uint32_t, 3> const c5 = {{ 0x1100, 0x1171, 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_067) { // ADC3;ADC3;1100 1171 11AA;ADC3;1100 1171 11AA; // (귃; 귃; 귃; 귃; 귃; ) HANGUL SYLLABLE GWIGS { std::array<uint32_t, 1> const c1 = {{ 0xADC3 }}; std::array<uint32_t, 1> const c2 = {{ 0xADC3 }}; std::array<uint32_t, 3> const c3 = {{ 0x1100, 0x1171, 0x11AA }}; std::array<uint32_t, 1> const c4 = {{ 0xADC3 }}; std::array<uint32_t, 3> const c5 = {{ 0x1100, 0x1171, 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_068) { // ADC4;ADC4;1100 1171 11AB;ADC4;1100 1171 11AB; // (귄; 귄; 귄; 귄; 귄; ) HANGUL SYLLABLE GWIN { std::array<uint32_t, 1> const c1 = {{ 0xADC4 }}; std::array<uint32_t, 1> const c2 = {{ 0xADC4 }}; std::array<uint32_t, 3> const c3 = {{ 0x1100, 0x1171, 0x11AB }}; std::array<uint32_t, 1> const c4 = {{ 0xADC4 }}; std::array<uint32_t, 3> const c5 = {{ 0x1100, 0x1171, 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_069) { // ADC5;ADC5;1100 1171 11AC;ADC5;1100 1171 11AC; // (귅; 귅; 귅; 귅; 귅; ) HANGUL SYLLABLE GWINJ { std::array<uint32_t, 1> const c1 = {{ 0xADC5 }}; std::array<uint32_t, 1> const c2 = {{ 0xADC5 }}; std::array<uint32_t, 3> const c3 = {{ 0x1100, 0x1171, 0x11AC }}; std::array<uint32_t, 1> const c4 = {{ 0xADC5 }}; std::array<uint32_t, 3> const c5 = {{ 0x1100, 0x1171, 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_070) { // ADC6;ADC6;1100 1171 11AD;ADC6;1100 1171 11AD; // (귆; 귆; 귆; 귆; 귆; ) HANGUL SYLLABLE GWINH { std::array<uint32_t, 1> const c1 = {{ 0xADC6 }}; std::array<uint32_t, 1> const c2 = {{ 0xADC6 }}; std::array<uint32_t, 3> const c3 = {{ 0x1100, 0x1171, 0x11AD }}; std::array<uint32_t, 1> const c4 = {{ 0xADC6 }}; std::array<uint32_t, 3> const c5 = {{ 0x1100, 0x1171, 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_071) { // ADC7;ADC7;1100 1171 11AE;ADC7;1100 1171 11AE; // (귇; 귇; 귇; 귇; 귇; ) HANGUL SYLLABLE GWID { std::array<uint32_t, 1> const c1 = {{ 0xADC7 }}; std::array<uint32_t, 1> const c2 = {{ 0xADC7 }}; std::array<uint32_t, 3> const c3 = {{ 0x1100, 0x1171, 0x11AE }}; std::array<uint32_t, 1> const c4 = {{ 0xADC7 }}; std::array<uint32_t, 3> const c5 = {{ 0x1100, 0x1171, 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_072) { // ADC8;ADC8;1100 1171 11AF;ADC8;1100 1171 11AF; // (귈; 귈; 귈; 귈; 귈; ) HANGUL SYLLABLE GWIL { std::array<uint32_t, 1> const c1 = {{ 0xADC8 }}; std::array<uint32_t, 1> const c2 = {{ 0xADC8 }}; std::array<uint32_t, 3> const c3 = {{ 0x1100, 0x1171, 0x11AF }}; std::array<uint32_t, 1> const c4 = {{ 0xADC8 }}; std::array<uint32_t, 3> const c5 = {{ 0x1100, 0x1171, 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_073) { // ADC9;ADC9;1100 1171 11B0;ADC9;1100 1171 11B0; // (귉; 귉; 귉; 귉; 귉; ) HANGUL SYLLABLE GWILG { std::array<uint32_t, 1> const c1 = {{ 0xADC9 }}; std::array<uint32_t, 1> const c2 = {{ 0xADC9 }}; std::array<uint32_t, 3> const c3 = {{ 0x1100, 0x1171, 0x11B0 }}; std::array<uint32_t, 1> const c4 = {{ 0xADC9 }}; std::array<uint32_t, 3> const c5 = {{ 0x1100, 0x1171, 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_074) { // ADCA;ADCA;1100 1171 11B1;ADCA;1100 1171 11B1; // (귊; 귊; 귊; 귊; 귊; ) HANGUL SYLLABLE GWILM { std::array<uint32_t, 1> const c1 = {{ 0xADCA }}; std::array<uint32_t, 1> const c2 = {{ 0xADCA }}; std::array<uint32_t, 3> const c3 = {{ 0x1100, 0x1171, 0x11B1 }}; std::array<uint32_t, 1> const c4 = {{ 0xADCA }}; std::array<uint32_t, 3> const c5 = {{ 0x1100, 0x1171, 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_075) { // ADCB;ADCB;1100 1171 11B2;ADCB;1100 1171 11B2; // (귋; 귋; 귋; 귋; 귋; ) HANGUL SYLLABLE GWILB { std::array<uint32_t, 1> const c1 = {{ 0xADCB }}; std::array<uint32_t, 1> const c2 = {{ 0xADCB }}; std::array<uint32_t, 3> const c3 = {{ 0x1100, 0x1171, 0x11B2 }}; std::array<uint32_t, 1> const c4 = {{ 0xADCB }}; std::array<uint32_t, 3> const c5 = {{ 0x1100, 0x1171, 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_076) { // ADCC;ADCC;1100 1171 11B3;ADCC;1100 1171 11B3; // (귌; 귌; 귌; 귌; 귌; ) HANGUL SYLLABLE GWILS { std::array<uint32_t, 1> const c1 = {{ 0xADCC }}; std::array<uint32_t, 1> const c2 = {{ 0xADCC }}; std::array<uint32_t, 3> const c3 = {{ 0x1100, 0x1171, 0x11B3 }}; std::array<uint32_t, 1> const c4 = {{ 0xADCC }}; std::array<uint32_t, 3> const c5 = {{ 0x1100, 0x1171, 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_077) { // ADCD;ADCD;1100 1171 11B4;ADCD;1100 1171 11B4; // (귍; 귍; 귍; 귍; 귍; ) HANGUL SYLLABLE GWILT { std::array<uint32_t, 1> const c1 = {{ 0xADCD }}; std::array<uint32_t, 1> const c2 = {{ 0xADCD }}; std::array<uint32_t, 3> const c3 = {{ 0x1100, 0x1171, 0x11B4 }}; std::array<uint32_t, 1> const c4 = {{ 0xADCD }}; std::array<uint32_t, 3> const c5 = {{ 0x1100, 0x1171, 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_078) { // ADCE;ADCE;1100 1171 11B5;ADCE;1100 1171 11B5; // (귎; 귎; 귎; 귎; 귎; ) HANGUL SYLLABLE GWILP { std::array<uint32_t, 1> const c1 = {{ 0xADCE }}; std::array<uint32_t, 1> const c2 = {{ 0xADCE }}; std::array<uint32_t, 3> const c3 = {{ 0x1100, 0x1171, 0x11B5 }}; std::array<uint32_t, 1> const c4 = {{ 0xADCE }}; std::array<uint32_t, 3> const c5 = {{ 0x1100, 0x1171, 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_079) { // ADCF;ADCF;1100 1171 11B6;ADCF;1100 1171 11B6; // (귏; 귏; 귏; 귏; 귏; ) HANGUL SYLLABLE GWILH { std::array<uint32_t, 1> const c1 = {{ 0xADCF }}; std::array<uint32_t, 1> const c2 = {{ 0xADCF }}; std::array<uint32_t, 3> const c3 = {{ 0x1100, 0x1171, 0x11B6 }}; std::array<uint32_t, 1> const c4 = {{ 0xADCF }}; std::array<uint32_t, 3> const c5 = {{ 0x1100, 0x1171, 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_080) { // ADD0;ADD0;1100 1171 11B7;ADD0;1100 1171 11B7; // (귐; 귐; 귐; 귐; 귐; ) HANGUL SYLLABLE GWIM { std::array<uint32_t, 1> const c1 = {{ 0xADD0 }}; std::array<uint32_t, 1> const c2 = {{ 0xADD0 }}; std::array<uint32_t, 3> const c3 = {{ 0x1100, 0x1171, 0x11B7 }}; std::array<uint32_t, 1> const c4 = {{ 0xADD0 }}; std::array<uint32_t, 3> const c5 = {{ 0x1100, 0x1171, 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_081) { // ADD1;ADD1;1100 1171 11B8;ADD1;1100 1171 11B8; // (귑; 귑; 귑; 귑; 귑; ) HANGUL SYLLABLE GWIB { std::array<uint32_t, 1> const c1 = {{ 0xADD1 }}; std::array<uint32_t, 1> const c2 = {{ 0xADD1 }}; std::array<uint32_t, 3> const c3 = {{ 0x1100, 0x1171, 0x11B8 }}; std::array<uint32_t, 1> const c4 = {{ 0xADD1 }}; std::array<uint32_t, 3> const c5 = {{ 0x1100, 0x1171, 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_082) { // ADD2;ADD2;1100 1171 11B9;ADD2;1100 1171 11B9; // (귒; 귒; 귒; 귒; 귒; ) HANGUL SYLLABLE GWIBS { std::array<uint32_t, 1> const c1 = {{ 0xADD2 }}; std::array<uint32_t, 1> const c2 = {{ 0xADD2 }}; std::array<uint32_t, 3> const c3 = {{ 0x1100, 0x1171, 0x11B9 }}; std::array<uint32_t, 1> const c4 = {{ 0xADD2 }}; std::array<uint32_t, 3> const c5 = {{ 0x1100, 0x1171, 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_083) { // ADD3;ADD3;1100 1171 11BA;ADD3;1100 1171 11BA; // (귓; 귓; 귓; 귓; 귓; ) HANGUL SYLLABLE GWIS { std::array<uint32_t, 1> const c1 = {{ 0xADD3 }}; std::array<uint32_t, 1> const c2 = {{ 0xADD3 }}; std::array<uint32_t, 3> const c3 = {{ 0x1100, 0x1171, 0x11BA }}; std::array<uint32_t, 1> const c4 = {{ 0xADD3 }}; std::array<uint32_t, 3> const c5 = {{ 0x1100, 0x1171, 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_084) { // ADD4;ADD4;1100 1171 11BB;ADD4;1100 1171 11BB; // (귔; 귔; 귔; 귔; 귔; ) HANGUL SYLLABLE GWISS { std::array<uint32_t, 1> const c1 = {{ 0xADD4 }}; std::array<uint32_t, 1> const c2 = {{ 0xADD4 }}; std::array<uint32_t, 3> const c3 = {{ 0x1100, 0x1171, 0x11BB }}; std::array<uint32_t, 1> const c4 = {{ 0xADD4 }}; std::array<uint32_t, 3> const c5 = {{ 0x1100, 0x1171, 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_085) { // ADD5;ADD5;1100 1171 11BC;ADD5;1100 1171 11BC; // (귕; 귕; 귕; 귕; 귕; ) HANGUL SYLLABLE GWING { std::array<uint32_t, 1> const c1 = {{ 0xADD5 }}; std::array<uint32_t, 1> const c2 = {{ 0xADD5 }}; std::array<uint32_t, 3> const c3 = {{ 0x1100, 0x1171, 0x11BC }}; std::array<uint32_t, 1> const c4 = {{ 0xADD5 }}; std::array<uint32_t, 3> const c5 = {{ 0x1100, 0x1171, 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_086) { // ADD6;ADD6;1100 1171 11BD;ADD6;1100 1171 11BD; // (귖; 귖; 귖; 귖; 귖; ) HANGUL SYLLABLE GWIJ { std::array<uint32_t, 1> const c1 = {{ 0xADD6 }}; std::array<uint32_t, 1> const c2 = {{ 0xADD6 }}; std::array<uint32_t, 3> const c3 = {{ 0x1100, 0x1171, 0x11BD }}; std::array<uint32_t, 1> const c4 = {{ 0xADD6 }}; std::array<uint32_t, 3> const c5 = {{ 0x1100, 0x1171, 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_087) { // ADD7;ADD7;1100 1171 11BE;ADD7;1100 1171 11BE; // (귗; 귗; 귗; 귗; 귗; ) HANGUL SYLLABLE GWIC { std::array<uint32_t, 1> const c1 = {{ 0xADD7 }}; std::array<uint32_t, 1> const c2 = {{ 0xADD7 }}; std::array<uint32_t, 3> const c3 = {{ 0x1100, 0x1171, 0x11BE }}; std::array<uint32_t, 1> const c4 = {{ 0xADD7 }}; std::array<uint32_t, 3> const c5 = {{ 0x1100, 0x1171, 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_088) { // ADD8;ADD8;1100 1171 11BF;ADD8;1100 1171 11BF; // (귘; 귘; 귘; 귘; 귘; ) HANGUL SYLLABLE GWIK { std::array<uint32_t, 1> const c1 = {{ 0xADD8 }}; std::array<uint32_t, 1> const c2 = {{ 0xADD8 }}; std::array<uint32_t, 3> const c3 = {{ 0x1100, 0x1171, 0x11BF }}; std::array<uint32_t, 1> const c4 = {{ 0xADD8 }}; std::array<uint32_t, 3> const c5 = {{ 0x1100, 0x1171, 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_089) { // ADD9;ADD9;1100 1171 11C0;ADD9;1100 1171 11C0; // (귙; 귙; 귙; 귙; 귙; ) HANGUL SYLLABLE GWIT { std::array<uint32_t, 1> const c1 = {{ 0xADD9 }}; std::array<uint32_t, 1> const c2 = {{ 0xADD9 }}; std::array<uint32_t, 3> const c3 = {{ 0x1100, 0x1171, 0x11C0 }}; std::array<uint32_t, 1> const c4 = {{ 0xADD9 }}; std::array<uint32_t, 3> const c5 = {{ 0x1100, 0x1171, 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_090) { // ADDA;ADDA;1100 1171 11C1;ADDA;1100 1171 11C1; // (귚; 귚; 귚; 귚; 귚; ) HANGUL SYLLABLE GWIP { std::array<uint32_t, 1> const c1 = {{ 0xADDA }}; std::array<uint32_t, 1> const c2 = {{ 0xADDA }}; std::array<uint32_t, 3> const c3 = {{ 0x1100, 0x1171, 0x11C1 }}; std::array<uint32_t, 1> const c4 = {{ 0xADDA }}; std::array<uint32_t, 3> const c5 = {{ 0x1100, 0x1171, 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_091) { // ADDB;ADDB;1100 1171 11C2;ADDB;1100 1171 11C2; // (귛; 귛; 귛; 귛; 귛; ) HANGUL SYLLABLE GWIH { std::array<uint32_t, 1> const c1 = {{ 0xADDB }}; std::array<uint32_t, 1> const c2 = {{ 0xADDB }}; std::array<uint32_t, 3> const c3 = {{ 0x1100, 0x1171, 0x11C2 }}; std::array<uint32_t, 1> const c4 = {{ 0xADDB }}; std::array<uint32_t, 3> const c5 = {{ 0x1100, 0x1171, 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_092) { // ADDC;ADDC;1100 1172;ADDC;1100 1172; // (규; 규; 규; 규; 규; ) HANGUL SYLLABLE GYU { std::array<uint32_t, 1> const c1 = {{ 0xADDC }}; std::array<uint32_t, 1> const c2 = {{ 0xADDC }}; std::array<uint32_t, 2> const c3 = {{ 0x1100, 0x1172 }}; std::array<uint32_t, 1> const c4 = {{ 0xADDC }}; std::array<uint32_t, 2> const c5 = {{ 0x1100, 0x1172 }}; 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_093) { // ADDD;ADDD;1100 1172 11A8;ADDD;1100 1172 11A8; // (귝; 귝; 귝; 귝; 귝; ) HANGUL SYLLABLE GYUG { std::array<uint32_t, 1> const c1 = {{ 0xADDD }}; std::array<uint32_t, 1> const c2 = {{ 0xADDD }}; std::array<uint32_t, 3> const c3 = {{ 0x1100, 0x1172, 0x11A8 }}; std::array<uint32_t, 1> const c4 = {{ 0xADDD }}; std::array<uint32_t, 3> const c5 = {{ 0x1100, 0x1172, 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_094) { // ADDE;ADDE;1100 1172 11A9;ADDE;1100 1172 11A9; // (귞; 귞; 귞; 귞; 귞; ) HANGUL SYLLABLE GYUGG { std::array<uint32_t, 1> const c1 = {{ 0xADDE }}; std::array<uint32_t, 1> const c2 = {{ 0xADDE }}; std::array<uint32_t, 3> const c3 = {{ 0x1100, 0x1172, 0x11A9 }}; std::array<uint32_t, 1> const c4 = {{ 0xADDE }}; std::array<uint32_t, 3> const c5 = {{ 0x1100, 0x1172, 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_095) { // ADDF;ADDF;1100 1172 11AA;ADDF;1100 1172 11AA; // (귟; 귟; 귟; 귟; 귟; ) HANGUL SYLLABLE GYUGS { std::array<uint32_t, 1> const c1 = {{ 0xADDF }}; std::array<uint32_t, 1> const c2 = {{ 0xADDF }}; std::array<uint32_t, 3> const c3 = {{ 0x1100, 0x1172, 0x11AA }}; std::array<uint32_t, 1> const c4 = {{ 0xADDF }}; std::array<uint32_t, 3> const c5 = {{ 0x1100, 0x1172, 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_096) { // ADE0;ADE0;1100 1172 11AB;ADE0;1100 1172 11AB; // (균; 균; 균; 균; 균; ) HANGUL SYLLABLE GYUN { std::array<uint32_t, 1> const c1 = {{ 0xADE0 }}; std::array<uint32_t, 1> const c2 = {{ 0xADE0 }}; std::array<uint32_t, 3> const c3 = {{ 0x1100, 0x1172, 0x11AB }}; std::array<uint32_t, 1> const c4 = {{ 0xADE0 }}; std::array<uint32_t, 3> const c5 = {{ 0x1100, 0x1172, 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_097) { // ADE1;ADE1;1100 1172 11AC;ADE1;1100 1172 11AC; // (귡; 귡; 귡; 귡; 귡; ) HANGUL SYLLABLE GYUNJ { std::array<uint32_t, 1> const c1 = {{ 0xADE1 }}; std::array<uint32_t, 1> const c2 = {{ 0xADE1 }}; std::array<uint32_t, 3> const c3 = {{ 0x1100, 0x1172, 0x11AC }}; std::array<uint32_t, 1> const c4 = {{ 0xADE1 }}; std::array<uint32_t, 3> const c5 = {{ 0x1100, 0x1172, 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_098) { // ADE2;ADE2;1100 1172 11AD;ADE2;1100 1172 11AD; // (귢; 귢; 귢; 귢; 귢; ) HANGUL SYLLABLE GYUNH { std::array<uint32_t, 1> const c1 = {{ 0xADE2 }}; std::array<uint32_t, 1> const c2 = {{ 0xADE2 }}; std::array<uint32_t, 3> const c3 = {{ 0x1100, 0x1172, 0x11AD }}; std::array<uint32_t, 1> const c4 = {{ 0xADE2 }}; std::array<uint32_t, 3> const c5 = {{ 0x1100, 0x1172, 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_099) { // ADE3;ADE3;1100 1172 11AE;ADE3;1100 1172 11AE; // (귣; 귣; 귣; 귣; 귣; ) HANGUL SYLLABLE GYUD { std::array<uint32_t, 1> const c1 = {{ 0xADE3 }}; std::array<uint32_t, 1> const c2 = {{ 0xADE3 }}; std::array<uint32_t, 3> const c3 = {{ 0x1100, 0x1172, 0x11AE }}; std::array<uint32_t, 1> const c4 = {{ 0xADE3 }}; std::array<uint32_t, 3> const c5 = {{ 0x1100, 0x1172, 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_100) { // ADE4;ADE4;1100 1172 11AF;ADE4;1100 1172 11AF; // (귤; 귤; 귤; 귤; 귤; ) HANGUL SYLLABLE GYUL { std::array<uint32_t, 1> const c1 = {{ 0xADE4 }}; std::array<uint32_t, 1> const c2 = {{ 0xADE4 }}; std::array<uint32_t, 3> const c3 = {{ 0x1100, 0x1172, 0x11AF }}; std::array<uint32_t, 1> const c4 = {{ 0xADE4 }}; std::array<uint32_t, 3> const c5 = {{ 0x1100, 0x1172, 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_101) { // ADE5;ADE5;1100 1172 11B0;ADE5;1100 1172 11B0; // (귥; 귥; 귥; 귥; 귥; ) HANGUL SYLLABLE GYULG { std::array<uint32_t, 1> const c1 = {{ 0xADE5 }}; std::array<uint32_t, 1> const c2 = {{ 0xADE5 }}; std::array<uint32_t, 3> const c3 = {{ 0x1100, 0x1172, 0x11B0 }}; std::array<uint32_t, 1> const c4 = {{ 0xADE5 }}; std::array<uint32_t, 3> const c5 = {{ 0x1100, 0x1172, 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_102) { // ADE6;ADE6;1100 1172 11B1;ADE6;1100 1172 11B1; // (귦; 귦; 귦; 귦; 귦; ) HANGUL SYLLABLE GYULM { std::array<uint32_t, 1> const c1 = {{ 0xADE6 }}; std::array<uint32_t, 1> const c2 = {{ 0xADE6 }}; std::array<uint32_t, 3> const c3 = {{ 0x1100, 0x1172, 0x11B1 }}; std::array<uint32_t, 1> const c4 = {{ 0xADE6 }}; std::array<uint32_t, 3> const c5 = {{ 0x1100, 0x1172, 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_103) { // ADE7;ADE7;1100 1172 11B2;ADE7;1100 1172 11B2; // (귧; 귧; 귧; 귧; 귧; ) HANGUL SYLLABLE GYULB { std::array<uint32_t, 1> const c1 = {{ 0xADE7 }}; std::array<uint32_t, 1> const c2 = {{ 0xADE7 }}; std::array<uint32_t, 3> const c3 = {{ 0x1100, 0x1172, 0x11B2 }}; std::array<uint32_t, 1> const c4 = {{ 0xADE7 }}; std::array<uint32_t, 3> const c5 = {{ 0x1100, 0x1172, 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_104) { // ADE8;ADE8;1100 1172 11B3;ADE8;1100 1172 11B3; // (귨; 귨; 귨; 귨; 귨; ) HANGUL SYLLABLE GYULS { std::array<uint32_t, 1> const c1 = {{ 0xADE8 }}; std::array<uint32_t, 1> const c2 = {{ 0xADE8 }}; std::array<uint32_t, 3> const c3 = {{ 0x1100, 0x1172, 0x11B3 }}; std::array<uint32_t, 1> const c4 = {{ 0xADE8 }}; std::array<uint32_t, 3> const c5 = {{ 0x1100, 0x1172, 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_105) { // ADE9;ADE9;1100 1172 11B4;ADE9;1100 1172 11B4; // (귩; 귩; 귩; 귩; 귩; ) HANGUL SYLLABLE GYULT { std::array<uint32_t, 1> const c1 = {{ 0xADE9 }}; std::array<uint32_t, 1> const c2 = {{ 0xADE9 }}; std::array<uint32_t, 3> const c3 = {{ 0x1100, 0x1172, 0x11B4 }}; std::array<uint32_t, 1> const c4 = {{ 0xADE9 }}; std::array<uint32_t, 3> const c5 = {{ 0x1100, 0x1172, 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_106) { // ADEA;ADEA;1100 1172 11B5;ADEA;1100 1172 11B5; // (귪; 귪; 귪; 귪; 귪; ) HANGUL SYLLABLE GYULP { std::array<uint32_t, 1> const c1 = {{ 0xADEA }}; std::array<uint32_t, 1> const c2 = {{ 0xADEA }}; std::array<uint32_t, 3> const c3 = {{ 0x1100, 0x1172, 0x11B5 }}; std::array<uint32_t, 1> const c4 = {{ 0xADEA }}; std::array<uint32_t, 3> const c5 = {{ 0x1100, 0x1172, 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_107) { // ADEB;ADEB;1100 1172 11B6;ADEB;1100 1172 11B6; // (귫; 귫; 귫; 귫; 귫; ) HANGUL SYLLABLE GYULH { std::array<uint32_t, 1> const c1 = {{ 0xADEB }}; std::array<uint32_t, 1> const c2 = {{ 0xADEB }}; std::array<uint32_t, 3> const c3 = {{ 0x1100, 0x1172, 0x11B6 }}; std::array<uint32_t, 1> const c4 = {{ 0xADEB }}; std::array<uint32_t, 3> const c5 = {{ 0x1100, 0x1172, 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_108) { // ADEC;ADEC;1100 1172 11B7;ADEC;1100 1172 11B7; // (귬; 귬; 귬; 귬; 귬; ) HANGUL SYLLABLE GYUM { std::array<uint32_t, 1> const c1 = {{ 0xADEC }}; std::array<uint32_t, 1> const c2 = {{ 0xADEC }}; std::array<uint32_t, 3> const c3 = {{ 0x1100, 0x1172, 0x11B7 }}; std::array<uint32_t, 1> const c4 = {{ 0xADEC }}; std::array<uint32_t, 3> const c5 = {{ 0x1100, 0x1172, 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_109) { // ADED;ADED;1100 1172 11B8;ADED;1100 1172 11B8; // (귭; 귭; 귭; 귭; 귭; ) HANGUL SYLLABLE GYUB { std::array<uint32_t, 1> const c1 = {{ 0xADED }}; std::array<uint32_t, 1> const c2 = {{ 0xADED }}; std::array<uint32_t, 3> const c3 = {{ 0x1100, 0x1172, 0x11B8 }}; std::array<uint32_t, 1> const c4 = {{ 0xADED }}; std::array<uint32_t, 3> const c5 = {{ 0x1100, 0x1172, 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_110) { // ADEE;ADEE;1100 1172 11B9;ADEE;1100 1172 11B9; // (귮; 귮; 귮; 귮; 귮; ) HANGUL SYLLABLE GYUBS { std::array<uint32_t, 1> const c1 = {{ 0xADEE }}; std::array<uint32_t, 1> const c2 = {{ 0xADEE }}; std::array<uint32_t, 3> const c3 = {{ 0x1100, 0x1172, 0x11B9 }}; std::array<uint32_t, 1> const c4 = {{ 0xADEE }}; std::array<uint32_t, 3> const c5 = {{ 0x1100, 0x1172, 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_111) { // ADEF;ADEF;1100 1172 11BA;ADEF;1100 1172 11BA; // (귯; 귯; 귯; 귯; 귯; ) HANGUL SYLLABLE GYUS { std::array<uint32_t, 1> const c1 = {{ 0xADEF }}; std::array<uint32_t, 1> const c2 = {{ 0xADEF }}; std::array<uint32_t, 3> const c3 = {{ 0x1100, 0x1172, 0x11BA }}; std::array<uint32_t, 1> const c4 = {{ 0xADEF }}; std::array<uint32_t, 3> const c5 = {{ 0x1100, 0x1172, 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_112) { // ADF0;ADF0;1100 1172 11BB;ADF0;1100 1172 11BB; // (귰; 귰; 귰; 귰; 귰; ) HANGUL SYLLABLE GYUSS { std::array<uint32_t, 1> const c1 = {{ 0xADF0 }}; std::array<uint32_t, 1> const c2 = {{ 0xADF0 }}; std::array<uint32_t, 3> const c3 = {{ 0x1100, 0x1172, 0x11BB }}; std::array<uint32_t, 1> const c4 = {{ 0xADF0 }}; std::array<uint32_t, 3> const c5 = {{ 0x1100, 0x1172, 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_113) { // ADF1;ADF1;1100 1172 11BC;ADF1;1100 1172 11BC; // (귱; 귱; 귱; 귱; 귱; ) HANGUL SYLLABLE GYUNG { std::array<uint32_t, 1> const c1 = {{ 0xADF1 }}; std::array<uint32_t, 1> const c2 = {{ 0xADF1 }}; std::array<uint32_t, 3> const c3 = {{ 0x1100, 0x1172, 0x11BC }}; std::array<uint32_t, 1> const c4 = {{ 0xADF1 }}; std::array<uint32_t, 3> const c5 = {{ 0x1100, 0x1172, 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_114) { // ADF2;ADF2;1100 1172 11BD;ADF2;1100 1172 11BD; // (귲; 귲; 귲; 귲; 귲; ) HANGUL SYLLABLE GYUJ { std::array<uint32_t, 1> const c1 = {{ 0xADF2 }}; std::array<uint32_t, 1> const c2 = {{ 0xADF2 }}; std::array<uint32_t, 3> const c3 = {{ 0x1100, 0x1172, 0x11BD }}; std::array<uint32_t, 1> const c4 = {{ 0xADF2 }}; std::array<uint32_t, 3> const c5 = {{ 0x1100, 0x1172, 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_115) { // ADF3;ADF3;1100 1172 11BE;ADF3;1100 1172 11BE; // (귳; 귳; 귳; 귳; 귳; ) HANGUL SYLLABLE GYUC { std::array<uint32_t, 1> const c1 = {{ 0xADF3 }}; std::array<uint32_t, 1> const c2 = {{ 0xADF3 }}; std::array<uint32_t, 3> const c3 = {{ 0x1100, 0x1172, 0x11BE }}; std::array<uint32_t, 1> const c4 = {{ 0xADF3 }}; std::array<uint32_t, 3> const c5 = {{ 0x1100, 0x1172, 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_116) { // ADF4;ADF4;1100 1172 11BF;ADF4;1100 1172 11BF; // (귴; 귴; 귴; 귴; 귴; ) HANGUL SYLLABLE GYUK { std::array<uint32_t, 1> const c1 = {{ 0xADF4 }}; std::array<uint32_t, 1> const c2 = {{ 0xADF4 }}; std::array<uint32_t, 3> const c3 = {{ 0x1100, 0x1172, 0x11BF }}; std::array<uint32_t, 1> const c4 = {{ 0xADF4 }}; std::array<uint32_t, 3> const c5 = {{ 0x1100, 0x1172, 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_117) { // ADF5;ADF5;1100 1172 11C0;ADF5;1100 1172 11C0; // (귵; 귵; 귵; 귵; 귵; ) HANGUL SYLLABLE GYUT { std::array<uint32_t, 1> const c1 = {{ 0xADF5 }}; std::array<uint32_t, 1> const c2 = {{ 0xADF5 }}; std::array<uint32_t, 3> const c3 = {{ 0x1100, 0x1172, 0x11C0 }}; std::array<uint32_t, 1> const c4 = {{ 0xADF5 }}; std::array<uint32_t, 3> const c5 = {{ 0x1100, 0x1172, 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_118) { // ADF6;ADF6;1100 1172 11C1;ADF6;1100 1172 11C1; // (귶; 귶; 귶; 귶; 귶; ) HANGUL SYLLABLE GYUP { std::array<uint32_t, 1> const c1 = {{ 0xADF6 }}; std::array<uint32_t, 1> const c2 = {{ 0xADF6 }}; std::array<uint32_t, 3> const c3 = {{ 0x1100, 0x1172, 0x11C1 }}; std::array<uint32_t, 1> const c4 = {{ 0xADF6 }}; std::array<uint32_t, 3> const c5 = {{ 0x1100, 0x1172, 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_119) { // ADF7;ADF7;1100 1172 11C2;ADF7;1100 1172 11C2; // (귷; 귷; 귷; 귷; 귷; ) HANGUL SYLLABLE GYUH { std::array<uint32_t, 1> const c1 = {{ 0xADF7 }}; std::array<uint32_t, 1> const c2 = {{ 0xADF7 }}; std::array<uint32_t, 3> const c3 = {{ 0x1100, 0x1172, 0x11C2 }}; std::array<uint32_t, 1> const c4 = {{ 0xADF7 }}; std::array<uint32_t, 3> const c5 = {{ 0x1100, 0x1172, 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_120) { // ADF8;ADF8;1100 1173;ADF8;1100 1173; // (그; 그; 그; 그; 그; ) HANGUL SYLLABLE GEU { std::array<uint32_t, 1> const c1 = {{ 0xADF8 }}; std::array<uint32_t, 1> const c2 = {{ 0xADF8 }}; std::array<uint32_t, 2> const c3 = {{ 0x1100, 0x1173 }}; std::array<uint32_t, 1> const c4 = {{ 0xADF8 }}; std::array<uint32_t, 2> const c5 = {{ 0x1100, 0x1173 }}; 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_121) { // ADF9;ADF9;1100 1173 11A8;ADF9;1100 1173 11A8; // (극; 극; 극; 극; 극; ) HANGUL SYLLABLE GEUG { std::array<uint32_t, 1> const c1 = {{ 0xADF9 }}; std::array<uint32_t, 1> const c2 = {{ 0xADF9 }}; std::array<uint32_t, 3> const c3 = {{ 0x1100, 0x1173, 0x11A8 }}; std::array<uint32_t, 1> const c4 = {{ 0xADF9 }}; std::array<uint32_t, 3> const c5 = {{ 0x1100, 0x1173, 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_122) { // ADFA;ADFA;1100 1173 11A9;ADFA;1100 1173 11A9; // (귺; 귺; 귺; 귺; 귺; ) HANGUL SYLLABLE GEUGG { std::array<uint32_t, 1> const c1 = {{ 0xADFA }}; std::array<uint32_t, 1> const c2 = {{ 0xADFA }}; std::array<uint32_t, 3> const c3 = {{ 0x1100, 0x1173, 0x11A9 }}; std::array<uint32_t, 1> const c4 = {{ 0xADFA }}; std::array<uint32_t, 3> const c5 = {{ 0x1100, 0x1173, 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_123) { // ADFB;ADFB;1100 1173 11AA;ADFB;1100 1173 11AA; // (귻; 귻; 귻; 귻; 귻; ) HANGUL SYLLABLE GEUGS { std::array<uint32_t, 1> const c1 = {{ 0xADFB }}; std::array<uint32_t, 1> const c2 = {{ 0xADFB }}; std::array<uint32_t, 3> const c3 = {{ 0x1100, 0x1173, 0x11AA }}; std::array<uint32_t, 1> const c4 = {{ 0xADFB }}; std::array<uint32_t, 3> const c5 = {{ 0x1100, 0x1173, 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_124) { // ADFC;ADFC;1100 1173 11AB;ADFC;1100 1173 11AB; // (근; 근; 근; 근; 근; ) HANGUL SYLLABLE GEUN { std::array<uint32_t, 1> const c1 = {{ 0xADFC }}; std::array<uint32_t, 1> const c2 = {{ 0xADFC }}; std::array<uint32_t, 3> const c3 = {{ 0x1100, 0x1173, 0x11AB }}; std::array<uint32_t, 1> const c4 = {{ 0xADFC }}; std::array<uint32_t, 3> const c5 = {{ 0x1100, 0x1173, 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_125) { // ADFD;ADFD;1100 1173 11AC;ADFD;1100 1173 11AC; // (귽; 귽; 귽; 귽; 귽; ) HANGUL SYLLABLE GEUNJ { std::array<uint32_t, 1> const c1 = {{ 0xADFD }}; std::array<uint32_t, 1> const c2 = {{ 0xADFD }}; std::array<uint32_t, 3> const c3 = {{ 0x1100, 0x1173, 0x11AC }}; std::array<uint32_t, 1> const c4 = {{ 0xADFD }}; std::array<uint32_t, 3> const c5 = {{ 0x1100, 0x1173, 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_126) { // ADFE;ADFE;1100 1173 11AD;ADFE;1100 1173 11AD; // (귾; 귾; 귾; 귾; 귾; ) HANGUL SYLLABLE GEUNH { std::array<uint32_t, 1> const c1 = {{ 0xADFE }}; std::array<uint32_t, 1> const c2 = {{ 0xADFE }}; std::array<uint32_t, 3> const c3 = {{ 0x1100, 0x1173, 0x11AD }}; std::array<uint32_t, 1> const c4 = {{ 0xADFE }}; std::array<uint32_t, 3> const c5 = {{ 0x1100, 0x1173, 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_127) { // ADFF;ADFF;1100 1173 11AE;ADFF;1100 1173 11AE; // (귿; 귿; 귿; 귿; 귿; ) HANGUL SYLLABLE GEUD { std::array<uint32_t, 1> const c1 = {{ 0xADFF }}; std::array<uint32_t, 1> const c2 = {{ 0xADFF }}; std::array<uint32_t, 3> const c3 = {{ 0x1100, 0x1173, 0x11AE }}; std::array<uint32_t, 1> const c4 = {{ 0xADFF }}; std::array<uint32_t, 3> const c5 = {{ 0x1100, 0x1173, 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_128) { // AE00;AE00;1100 1173 11AF;AE00;1100 1173 11AF; // (글; 글; 글; 글; 글; ) HANGUL SYLLABLE GEUL { std::array<uint32_t, 1> const c1 = {{ 0xAE00 }}; std::array<uint32_t, 1> const c2 = {{ 0xAE00 }}; std::array<uint32_t, 3> const c3 = {{ 0x1100, 0x1173, 0x11AF }}; std::array<uint32_t, 1> const c4 = {{ 0xAE00 }}; std::array<uint32_t, 3> const c5 = {{ 0x1100, 0x1173, 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_129) { // AE01;AE01;1100 1173 11B0;AE01;1100 1173 11B0; // (긁; 긁; 긁; 긁; 긁; ) HANGUL SYLLABLE GEULG { std::array<uint32_t, 1> const c1 = {{ 0xAE01 }}; std::array<uint32_t, 1> const c2 = {{ 0xAE01 }}; std::array<uint32_t, 3> const c3 = {{ 0x1100, 0x1173, 0x11B0 }}; std::array<uint32_t, 1> const c4 = {{ 0xAE01 }}; std::array<uint32_t, 3> const c5 = {{ 0x1100, 0x1173, 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_130) { // AE02;AE02;1100 1173 11B1;AE02;1100 1173 11B1; // (긂; 긂; 긂; 긂; 긂; ) HANGUL SYLLABLE GEULM { std::array<uint32_t, 1> const c1 = {{ 0xAE02 }}; std::array<uint32_t, 1> const c2 = {{ 0xAE02 }}; std::array<uint32_t, 3> const c3 = {{ 0x1100, 0x1173, 0x11B1 }}; std::array<uint32_t, 1> const c4 = {{ 0xAE02 }}; std::array<uint32_t, 3> const c5 = {{ 0x1100, 0x1173, 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_131) { // AE03;AE03;1100 1173 11B2;AE03;1100 1173 11B2; // (긃; 긃; 긃; 긃; 긃; ) HANGUL SYLLABLE GEULB { std::array<uint32_t, 1> const c1 = {{ 0xAE03 }}; std::array<uint32_t, 1> const c2 = {{ 0xAE03 }}; std::array<uint32_t, 3> const c3 = {{ 0x1100, 0x1173, 0x11B2 }}; std::array<uint32_t, 1> const c4 = {{ 0xAE03 }}; std::array<uint32_t, 3> const c5 = {{ 0x1100, 0x1173, 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_132) { // AE04;AE04;1100 1173 11B3;AE04;1100 1173 11B3; // (긄; 긄; 긄; 긄; 긄; ) HANGUL SYLLABLE GEULS { std::array<uint32_t, 1> const c1 = {{ 0xAE04 }}; std::array<uint32_t, 1> const c2 = {{ 0xAE04 }}; std::array<uint32_t, 3> const c3 = {{ 0x1100, 0x1173, 0x11B3 }}; std::array<uint32_t, 1> const c4 = {{ 0xAE04 }}; std::array<uint32_t, 3> const c5 = {{ 0x1100, 0x1173, 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_133) { // AE05;AE05;1100 1173 11B4;AE05;1100 1173 11B4; // (긅; 긅; 긅; 긅; 긅; ) HANGUL SYLLABLE GEULT { std::array<uint32_t, 1> const c1 = {{ 0xAE05 }}; std::array<uint32_t, 1> const c2 = {{ 0xAE05 }}; std::array<uint32_t, 3> const c3 = {{ 0x1100, 0x1173, 0x11B4 }}; std::array<uint32_t, 1> const c4 = {{ 0xAE05 }}; std::array<uint32_t, 3> const c5 = {{ 0x1100, 0x1173, 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_134) { // AE06;AE06;1100 1173 11B5;AE06;1100 1173 11B5; // (긆; 긆; 긆; 긆; 긆; ) HANGUL SYLLABLE GEULP { std::array<uint32_t, 1> const c1 = {{ 0xAE06 }}; std::array<uint32_t, 1> const c2 = {{ 0xAE06 }}; std::array<uint32_t, 3> const c3 = {{ 0x1100, 0x1173, 0x11B5 }}; std::array<uint32_t, 1> const c4 = {{ 0xAE06 }}; std::array<uint32_t, 3> const c5 = {{ 0x1100, 0x1173, 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_135) { // AE07;AE07;1100 1173 11B6;AE07;1100 1173 11B6; // (긇; 긇; 긇; 긇; 긇; ) HANGUL SYLLABLE GEULH { std::array<uint32_t, 1> const c1 = {{ 0xAE07 }}; std::array<uint32_t, 1> const c2 = {{ 0xAE07 }}; std::array<uint32_t, 3> const c3 = {{ 0x1100, 0x1173, 0x11B6 }}; std::array<uint32_t, 1> const c4 = {{ 0xAE07 }}; std::array<uint32_t, 3> const c5 = {{ 0x1100, 0x1173, 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_136) { // AE08;AE08;1100 1173 11B7;AE08;1100 1173 11B7; // (금; 금; 금; 금; 금; ) HANGUL SYLLABLE GEUM { std::array<uint32_t, 1> const c1 = {{ 0xAE08 }}; std::array<uint32_t, 1> const c2 = {{ 0xAE08 }}; std::array<uint32_t, 3> const c3 = {{ 0x1100, 0x1173, 0x11B7 }}; std::array<uint32_t, 1> const c4 = {{ 0xAE08 }}; std::array<uint32_t, 3> const c5 = {{ 0x1100, 0x1173, 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_137) { // AE09;AE09;1100 1173 11B8;AE09;1100 1173 11B8; // (급; 급; 급; 급; 급; ) HANGUL SYLLABLE GEUB { std::array<uint32_t, 1> const c1 = {{ 0xAE09 }}; std::array<uint32_t, 1> const c2 = {{ 0xAE09 }}; std::array<uint32_t, 3> const c3 = {{ 0x1100, 0x1173, 0x11B8 }}; std::array<uint32_t, 1> const c4 = {{ 0xAE09 }}; std::array<uint32_t, 3> const c5 = {{ 0x1100, 0x1173, 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_138) { // AE0A;AE0A;1100 1173 11B9;AE0A;1100 1173 11B9; // (긊; 긊; 긊; 긊; 긊; ) HANGUL SYLLABLE GEUBS { std::array<uint32_t, 1> const c1 = {{ 0xAE0A }}; std::array<uint32_t, 1> const c2 = {{ 0xAE0A }}; std::array<uint32_t, 3> const c3 = {{ 0x1100, 0x1173, 0x11B9 }}; std::array<uint32_t, 1> const c4 = {{ 0xAE0A }}; std::array<uint32_t, 3> const c5 = {{ 0x1100, 0x1173, 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_139) { // AE0B;AE0B;1100 1173 11BA;AE0B;1100 1173 11BA; // (긋; 긋; 긋; 긋; 긋; ) HANGUL SYLLABLE GEUS { std::array<uint32_t, 1> const c1 = {{ 0xAE0B }}; std::array<uint32_t, 1> const c2 = {{ 0xAE0B }}; std::array<uint32_t, 3> const c3 = {{ 0x1100, 0x1173, 0x11BA }}; std::array<uint32_t, 1> const c4 = {{ 0xAE0B }}; std::array<uint32_t, 3> const c5 = {{ 0x1100, 0x1173, 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_140) { // AE0C;AE0C;1100 1173 11BB;AE0C;1100 1173 11BB; // (긌; 긌; 긌; 긌; 긌; ) HANGUL SYLLABLE GEUSS { std::array<uint32_t, 1> const c1 = {{ 0xAE0C }}; std::array<uint32_t, 1> const c2 = {{ 0xAE0C }}; std::array<uint32_t, 3> const c3 = {{ 0x1100, 0x1173, 0x11BB }}; std::array<uint32_t, 1> const c4 = {{ 0xAE0C }}; std::array<uint32_t, 3> const c5 = {{ 0x1100, 0x1173, 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_141) { // AE0D;AE0D;1100 1173 11BC;AE0D;1100 1173 11BC; // (긍; 긍; 긍; 긍; 긍; ) HANGUL SYLLABLE GEUNG { std::array<uint32_t, 1> const c1 = {{ 0xAE0D }}; std::array<uint32_t, 1> const c2 = {{ 0xAE0D }}; std::array<uint32_t, 3> const c3 = {{ 0x1100, 0x1173, 0x11BC }}; std::array<uint32_t, 1> const c4 = {{ 0xAE0D }}; std::array<uint32_t, 3> const c5 = {{ 0x1100, 0x1173, 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_142) { // AE0E;AE0E;1100 1173 11BD;AE0E;1100 1173 11BD; // (긎; 긎; 긎; 긎; 긎; ) HANGUL SYLLABLE GEUJ { std::array<uint32_t, 1> const c1 = {{ 0xAE0E }}; std::array<uint32_t, 1> const c2 = {{ 0xAE0E }}; std::array<uint32_t, 3> const c3 = {{ 0x1100, 0x1173, 0x11BD }}; std::array<uint32_t, 1> const c4 = {{ 0xAE0E }}; std::array<uint32_t, 3> const c5 = {{ 0x1100, 0x1173, 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_143) { // AE0F;AE0F;1100 1173 11BE;AE0F;1100 1173 11BE; // (긏; 긏; 긏; 긏; 긏; ) HANGUL SYLLABLE GEUC { std::array<uint32_t, 1> const c1 = {{ 0xAE0F }}; std::array<uint32_t, 1> const c2 = {{ 0xAE0F }}; std::array<uint32_t, 3> const c3 = {{ 0x1100, 0x1173, 0x11BE }}; std::array<uint32_t, 1> const c4 = {{ 0xAE0F }}; std::array<uint32_t, 3> const c5 = {{ 0x1100, 0x1173, 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_144) { // AE10;AE10;1100 1173 11BF;AE10;1100 1173 11BF; // (긐; 긐; 긐; 긐; 긐; ) HANGUL SYLLABLE GEUK { std::array<uint32_t, 1> const c1 = {{ 0xAE10 }}; std::array<uint32_t, 1> const c2 = {{ 0xAE10 }}; std::array<uint32_t, 3> const c3 = {{ 0x1100, 0x1173, 0x11BF }}; std::array<uint32_t, 1> const c4 = {{ 0xAE10 }}; std::array<uint32_t, 3> const c5 = {{ 0x1100, 0x1173, 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_145) { // AE11;AE11;1100 1173 11C0;AE11;1100 1173 11C0; // (긑; 긑; 긑; 긑; 긑; ) HANGUL SYLLABLE GEUT { std::array<uint32_t, 1> const c1 = {{ 0xAE11 }}; std::array<uint32_t, 1> const c2 = {{ 0xAE11 }}; std::array<uint32_t, 3> const c3 = {{ 0x1100, 0x1173, 0x11C0 }}; std::array<uint32_t, 1> const c4 = {{ 0xAE11 }}; std::array<uint32_t, 3> const c5 = {{ 0x1100, 0x1173, 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_146) { // AE12;AE12;1100 1173 11C1;AE12;1100 1173 11C1; // (긒; 긒; 긒; 긒; 긒; ) HANGUL SYLLABLE GEUP { std::array<uint32_t, 1> const c1 = {{ 0xAE12 }}; std::array<uint32_t, 1> const c2 = {{ 0xAE12 }}; std::array<uint32_t, 3> const c3 = {{ 0x1100, 0x1173, 0x11C1 }}; std::array<uint32_t, 1> const c4 = {{ 0xAE12 }}; std::array<uint32_t, 3> const c5 = {{ 0x1100, 0x1173, 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_147) { // AE13;AE13;1100 1173 11C2;AE13;1100 1173 11C2; // (긓; 긓; 긓; 긓; 긓; ) HANGUL SYLLABLE GEUH { std::array<uint32_t, 1> const c1 = {{ 0xAE13 }}; std::array<uint32_t, 1> const c2 = {{ 0xAE13 }}; std::array<uint32_t, 3> const c3 = {{ 0x1100, 0x1173, 0x11C2 }}; std::array<uint32_t, 1> const c4 = {{ 0xAE13 }}; std::array<uint32_t, 3> const c5 = {{ 0x1100, 0x1173, 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_148) { // AE14;AE14;1100 1174;AE14;1100 1174; // (긔; 긔; 긔; 긔; 긔; ) HANGUL SYLLABLE GYI { std::array<uint32_t, 1> const c1 = {{ 0xAE14 }}; std::array<uint32_t, 1> const c2 = {{ 0xAE14 }}; std::array<uint32_t, 2> const c3 = {{ 0x1100, 0x1174 }}; std::array<uint32_t, 1> const c4 = {{ 0xAE14 }}; std::array<uint32_t, 2> const c5 = {{ 0x1100, 0x1174 }}; 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_149) { // AE15;AE15;1100 1174 11A8;AE15;1100 1174 11A8; // (긕; 긕; 긕; 긕; 긕; ) HANGUL SYLLABLE GYIG { std::array<uint32_t, 1> const c1 = {{ 0xAE15 }}; std::array<uint32_t, 1> const c2 = {{ 0xAE15 }}; std::array<uint32_t, 3> const c3 = {{ 0x1100, 0x1174, 0x11A8 }}; std::array<uint32_t, 1> const c4 = {{ 0xAE15 }}; std::array<uint32_t, 3> const c5 = {{ 0x1100, 0x1174, 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_150) { // AE16;AE16;1100 1174 11A9;AE16;1100 1174 11A9; // (긖; 긖; 긖; 긖; 긖; ) HANGUL SYLLABLE GYIGG { std::array<uint32_t, 1> const c1 = {{ 0xAE16 }}; std::array<uint32_t, 1> const c2 = {{ 0xAE16 }}; std::array<uint32_t, 3> const c3 = {{ 0x1100, 0x1174, 0x11A9 }}; std::array<uint32_t, 1> const c4 = {{ 0xAE16 }}; std::array<uint32_t, 3> const c5 = {{ 0x1100, 0x1174, 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_151) { // AE17;AE17;1100 1174 11AA;AE17;1100 1174 11AA; // (긗; 긗; 긗; 긗; 긗; ) HANGUL SYLLABLE GYIGS { std::array<uint32_t, 1> const c1 = {{ 0xAE17 }}; std::array<uint32_t, 1> const c2 = {{ 0xAE17 }}; std::array<uint32_t, 3> const c3 = {{ 0x1100, 0x1174, 0x11AA }}; std::array<uint32_t, 1> const c4 = {{ 0xAE17 }}; std::array<uint32_t, 3> const c5 = {{ 0x1100, 0x1174, 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_152) { // AE18;AE18;1100 1174 11AB;AE18;1100 1174 11AB; // (긘; 긘; 긘; 긘; 긘; ) HANGUL SYLLABLE GYIN { std::array<uint32_t, 1> const c1 = {{ 0xAE18 }}; std::array<uint32_t, 1> const c2 = {{ 0xAE18 }}; std::array<uint32_t, 3> const c3 = {{ 0x1100, 0x1174, 0x11AB }}; std::array<uint32_t, 1> const c4 = {{ 0xAE18 }}; std::array<uint32_t, 3> const c5 = {{ 0x1100, 0x1174, 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_153) { // AE19;AE19;1100 1174 11AC;AE19;1100 1174 11AC; // (긙; 긙; 긙; 긙; 긙; ) HANGUL SYLLABLE GYINJ { std::array<uint32_t, 1> const c1 = {{ 0xAE19 }}; std::array<uint32_t, 1> const c2 = {{ 0xAE19 }}; std::array<uint32_t, 3> const c3 = {{ 0x1100, 0x1174, 0x11AC }}; std::array<uint32_t, 1> const c4 = {{ 0xAE19 }}; std::array<uint32_t, 3> const c5 = {{ 0x1100, 0x1174, 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_154) { // AE1A;AE1A;1100 1174 11AD;AE1A;1100 1174 11AD; // (긚; 긚; 긚; 긚; 긚; ) HANGUL SYLLABLE GYINH { std::array<uint32_t, 1> const c1 = {{ 0xAE1A }}; std::array<uint32_t, 1> const c2 = {{ 0xAE1A }}; std::array<uint32_t, 3> const c3 = {{ 0x1100, 0x1174, 0x11AD }}; std::array<uint32_t, 1> const c4 = {{ 0xAE1A }}; std::array<uint32_t, 3> const c5 = {{ 0x1100, 0x1174, 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_155) { // AE1B;AE1B;1100 1174 11AE;AE1B;1100 1174 11AE; // (긛; 긛; 긛; 긛; 긛; ) HANGUL SYLLABLE GYID { std::array<uint32_t, 1> const c1 = {{ 0xAE1B }}; std::array<uint32_t, 1> const c2 = {{ 0xAE1B }}; std::array<uint32_t, 3> const c3 = {{ 0x1100, 0x1174, 0x11AE }}; std::array<uint32_t, 1> const c4 = {{ 0xAE1B }}; std::array<uint32_t, 3> const c5 = {{ 0x1100, 0x1174, 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_156) { // AE1C;AE1C;1100 1174 11AF;AE1C;1100 1174 11AF; // (긜; 긜; 긜; 긜; 긜; ) HANGUL SYLLABLE GYIL { std::array<uint32_t, 1> const c1 = {{ 0xAE1C }}; std::array<uint32_t, 1> const c2 = {{ 0xAE1C }}; std::array<uint32_t, 3> const c3 = {{ 0x1100, 0x1174, 0x11AF }}; std::array<uint32_t, 1> const c4 = {{ 0xAE1C }}; std::array<uint32_t, 3> const c5 = {{ 0x1100, 0x1174, 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_157) { // AE1D;AE1D;1100 1174 11B0;AE1D;1100 1174 11B0; // (긝; 긝; 긝; 긝; 긝; ) HANGUL SYLLABLE GYILG { std::array<uint32_t, 1> const c1 = {{ 0xAE1D }}; std::array<uint32_t, 1> const c2 = {{ 0xAE1D }}; std::array<uint32_t, 3> const c3 = {{ 0x1100, 0x1174, 0x11B0 }}; std::array<uint32_t, 1> const c4 = {{ 0xAE1D }}; std::array<uint32_t, 3> const c5 = {{ 0x1100, 0x1174, 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_158) { // AE1E;AE1E;1100 1174 11B1;AE1E;1100 1174 11B1; // (긞; 긞; 긞; 긞; 긞; ) HANGUL SYLLABLE GYILM { std::array<uint32_t, 1> const c1 = {{ 0xAE1E }}; std::array<uint32_t, 1> const c2 = {{ 0xAE1E }}; std::array<uint32_t, 3> const c3 = {{ 0x1100, 0x1174, 0x11B1 }}; std::array<uint32_t, 1> const c4 = {{ 0xAE1E }}; std::array<uint32_t, 3> const c5 = {{ 0x1100, 0x1174, 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_159) { // AE1F;AE1F;1100 1174 11B2;AE1F;1100 1174 11B2; // (긟; 긟; 긟; 긟; 긟; ) HANGUL SYLLABLE GYILB { std::array<uint32_t, 1> const c1 = {{ 0xAE1F }}; std::array<uint32_t, 1> const c2 = {{ 0xAE1F }}; std::array<uint32_t, 3> const c3 = {{ 0x1100, 0x1174, 0x11B2 }}; std::array<uint32_t, 1> const c4 = {{ 0xAE1F }}; std::array<uint32_t, 3> const c5 = {{ 0x1100, 0x1174, 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_160) { // AE20;AE20;1100 1174 11B3;AE20;1100 1174 11B3; // (긠; 긠; 긠; 긠; 긠; ) HANGUL SYLLABLE GYILS { std::array<uint32_t, 1> const c1 = {{ 0xAE20 }}; std::array<uint32_t, 1> const c2 = {{ 0xAE20 }}; std::array<uint32_t, 3> const c3 = {{ 0x1100, 0x1174, 0x11B3 }}; std::array<uint32_t, 1> const c4 = {{ 0xAE20 }}; std::array<uint32_t, 3> const c5 = {{ 0x1100, 0x1174, 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_161) { // AE21;AE21;1100 1174 11B4;AE21;1100 1174 11B4; // (긡; 긡; 긡; 긡; 긡; ) HANGUL SYLLABLE GYILT { std::array<uint32_t, 1> const c1 = {{ 0xAE21 }}; std::array<uint32_t, 1> const c2 = {{ 0xAE21 }}; std::array<uint32_t, 3> const c3 = {{ 0x1100, 0x1174, 0x11B4 }}; std::array<uint32_t, 1> const c4 = {{ 0xAE21 }}; std::array<uint32_t, 3> const c5 = {{ 0x1100, 0x1174, 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_162) { // AE22;AE22;1100 1174 11B5;AE22;1100 1174 11B5; // (긢; 긢; 긢; 긢; 긢; ) HANGUL SYLLABLE GYILP { std::array<uint32_t, 1> const c1 = {{ 0xAE22 }}; std::array<uint32_t, 1> const c2 = {{ 0xAE22 }}; std::array<uint32_t, 3> const c3 = {{ 0x1100, 0x1174, 0x11B5 }}; std::array<uint32_t, 1> const c4 = {{ 0xAE22 }}; std::array<uint32_t, 3> const c5 = {{ 0x1100, 0x1174, 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_163) { // AE23;AE23;1100 1174 11B6;AE23;1100 1174 11B6; // (긣; 긣; 긣; 긣; 긣; ) HANGUL SYLLABLE GYILH { std::array<uint32_t, 1> const c1 = {{ 0xAE23 }}; std::array<uint32_t, 1> const c2 = {{ 0xAE23 }}; std::array<uint32_t, 3> const c3 = {{ 0x1100, 0x1174, 0x11B6 }}; std::array<uint32_t, 1> const c4 = {{ 0xAE23 }}; std::array<uint32_t, 3> const c5 = {{ 0x1100, 0x1174, 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_164) { // AE24;AE24;1100 1174 11B7;AE24;1100 1174 11B7; // (긤; 긤; 긤; 긤; 긤; ) HANGUL SYLLABLE GYIM { std::array<uint32_t, 1> const c1 = {{ 0xAE24 }}; std::array<uint32_t, 1> const c2 = {{ 0xAE24 }}; std::array<uint32_t, 3> const c3 = {{ 0x1100, 0x1174, 0x11B7 }}; std::array<uint32_t, 1> const c4 = {{ 0xAE24 }}; std::array<uint32_t, 3> const c5 = {{ 0x1100, 0x1174, 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_165) { // AE25;AE25;1100 1174 11B8;AE25;1100 1174 11B8; // (긥; 긥; 긥; 긥; 긥; ) HANGUL SYLLABLE GYIB { std::array<uint32_t, 1> const c1 = {{ 0xAE25 }}; std::array<uint32_t, 1> const c2 = {{ 0xAE25 }}; std::array<uint32_t, 3> const c3 = {{ 0x1100, 0x1174, 0x11B8 }}; std::array<uint32_t, 1> const c4 = {{ 0xAE25 }}; std::array<uint32_t, 3> const c5 = {{ 0x1100, 0x1174, 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_166) { // AE26;AE26;1100 1174 11B9;AE26;1100 1174 11B9; // (긦; 긦; 긦; 긦; 긦; ) HANGUL SYLLABLE GYIBS { std::array<uint32_t, 1> const c1 = {{ 0xAE26 }}; std::array<uint32_t, 1> const c2 = {{ 0xAE26 }}; std::array<uint32_t, 3> const c3 = {{ 0x1100, 0x1174, 0x11B9 }}; std::array<uint32_t, 1> const c4 = {{ 0xAE26 }}; std::array<uint32_t, 3> const c5 = {{ 0x1100, 0x1174, 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_167) { // AE27;AE27;1100 1174 11BA;AE27;1100 1174 11BA; // (긧; 긧; 긧; 긧; 긧; ) HANGUL SYLLABLE GYIS { std::array<uint32_t, 1> const c1 = {{ 0xAE27 }}; std::array<uint32_t, 1> const c2 = {{ 0xAE27 }}; std::array<uint32_t, 3> const c3 = {{ 0x1100, 0x1174, 0x11BA }}; std::array<uint32_t, 1> const c4 = {{ 0xAE27 }}; std::array<uint32_t, 3> const c5 = {{ 0x1100, 0x1174, 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_168) { // AE28;AE28;1100 1174 11BB;AE28;1100 1174 11BB; // (긨; 긨; 긨; 긨; 긨; ) HANGUL SYLLABLE GYISS { std::array<uint32_t, 1> const c1 = {{ 0xAE28 }}; std::array<uint32_t, 1> const c2 = {{ 0xAE28 }}; std::array<uint32_t, 3> const c3 = {{ 0x1100, 0x1174, 0x11BB }}; std::array<uint32_t, 1> const c4 = {{ 0xAE28 }}; std::array<uint32_t, 3> const c5 = {{ 0x1100, 0x1174, 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_169) { // AE29;AE29;1100 1174 11BC;AE29;1100 1174 11BC; // (긩; 긩; 긩; 긩; 긩; ) HANGUL SYLLABLE GYING { std::array<uint32_t, 1> const c1 = {{ 0xAE29 }}; std::array<uint32_t, 1> const c2 = {{ 0xAE29 }}; std::array<uint32_t, 3> const c3 = {{ 0x1100, 0x1174, 0x11BC }}; std::array<uint32_t, 1> const c4 = {{ 0xAE29 }}; std::array<uint32_t, 3> const c5 = {{ 0x1100, 0x1174, 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_170) { // AE2A;AE2A;1100 1174 11BD;AE2A;1100 1174 11BD; // (긪; 긪; 긪; 긪; 긪; ) HANGUL SYLLABLE GYIJ { std::array<uint32_t, 1> const c1 = {{ 0xAE2A }}; std::array<uint32_t, 1> const c2 = {{ 0xAE2A }}; std::array<uint32_t, 3> const c3 = {{ 0x1100, 0x1174, 0x11BD }}; std::array<uint32_t, 1> const c4 = {{ 0xAE2A }}; std::array<uint32_t, 3> const c5 = {{ 0x1100, 0x1174, 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_171) { // AE2B;AE2B;1100 1174 11BE;AE2B;1100 1174 11BE; // (긫; 긫; 긫; 긫; 긫; ) HANGUL SYLLABLE GYIC { std::array<uint32_t, 1> const c1 = {{ 0xAE2B }}; std::array<uint32_t, 1> const c2 = {{ 0xAE2B }}; std::array<uint32_t, 3> const c3 = {{ 0x1100, 0x1174, 0x11BE }}; std::array<uint32_t, 1> const c4 = {{ 0xAE2B }}; std::array<uint32_t, 3> const c5 = {{ 0x1100, 0x1174, 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_172) { // AE2C;AE2C;1100 1174 11BF;AE2C;1100 1174 11BF; // (긬; 긬; 긬; 긬; 긬; ) HANGUL SYLLABLE GYIK { std::array<uint32_t, 1> const c1 = {{ 0xAE2C }}; std::array<uint32_t, 1> const c2 = {{ 0xAE2C }}; std::array<uint32_t, 3> const c3 = {{ 0x1100, 0x1174, 0x11BF }}; std::array<uint32_t, 1> const c4 = {{ 0xAE2C }}; std::array<uint32_t, 3> const c5 = {{ 0x1100, 0x1174, 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_173) { // AE2D;AE2D;1100 1174 11C0;AE2D;1100 1174 11C0; // (긭; 긭; 긭; 긭; 긭; ) HANGUL SYLLABLE GYIT { std::array<uint32_t, 1> const c1 = {{ 0xAE2D }}; std::array<uint32_t, 1> const c2 = {{ 0xAE2D }}; std::array<uint32_t, 3> const c3 = {{ 0x1100, 0x1174, 0x11C0 }}; std::array<uint32_t, 1> const c4 = {{ 0xAE2D }}; std::array<uint32_t, 3> const c5 = {{ 0x1100, 0x1174, 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_174) { // AE2E;AE2E;1100 1174 11C1;AE2E;1100 1174 11C1; // (긮; 긮; 긮; 긮; 긮; ) HANGUL SYLLABLE GYIP { std::array<uint32_t, 1> const c1 = {{ 0xAE2E }}; std::array<uint32_t, 1> const c2 = {{ 0xAE2E }}; std::array<uint32_t, 3> const c3 = {{ 0x1100, 0x1174, 0x11C1 }}; std::array<uint32_t, 1> const c4 = {{ 0xAE2E }}; std::array<uint32_t, 3> const c5 = {{ 0x1100, 0x1174, 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_175) { // AE2F;AE2F;1100 1174 11C2;AE2F;1100 1174 11C2; // (긯; 긯; 긯; 긯; 긯; ) HANGUL SYLLABLE GYIH { std::array<uint32_t, 1> const c1 = {{ 0xAE2F }}; std::array<uint32_t, 1> const c2 = {{ 0xAE2F }}; std::array<uint32_t, 3> const c3 = {{ 0x1100, 0x1174, 0x11C2 }}; std::array<uint32_t, 1> const c4 = {{ 0xAE2F }}; std::array<uint32_t, 3> const c5 = {{ 0x1100, 0x1174, 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_176) { // AE30;AE30;1100 1175;AE30;1100 1175; // (기; 기; 기; 기; 기; ) HANGUL SYLLABLE GI { std::array<uint32_t, 1> const c1 = {{ 0xAE30 }}; std::array<uint32_t, 1> const c2 = {{ 0xAE30 }}; std::array<uint32_t, 2> const c3 = {{ 0x1100, 0x1175 }}; std::array<uint32_t, 1> const c4 = {{ 0xAE30 }}; std::array<uint32_t, 2> const c5 = {{ 0x1100, 0x1175 }}; 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_177) { // AE31;AE31;1100 1175 11A8;AE31;1100 1175 11A8; // (긱; 긱; 긱; 긱; 긱; ) HANGUL SYLLABLE GIG { std::array<uint32_t, 1> const c1 = {{ 0xAE31 }}; std::array<uint32_t, 1> const c2 = {{ 0xAE31 }}; std::array<uint32_t, 3> const c3 = {{ 0x1100, 0x1175, 0x11A8 }}; std::array<uint32_t, 1> const c4 = {{ 0xAE31 }}; std::array<uint32_t, 3> const c5 = {{ 0x1100, 0x1175, 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_178) { // AE32;AE32;1100 1175 11A9;AE32;1100 1175 11A9; // (긲; 긲; 긲; 긲; 긲; ) HANGUL SYLLABLE GIGG { std::array<uint32_t, 1> const c1 = {{ 0xAE32 }}; std::array<uint32_t, 1> const c2 = {{ 0xAE32 }}; std::array<uint32_t, 3> const c3 = {{ 0x1100, 0x1175, 0x11A9 }}; std::array<uint32_t, 1> const c4 = {{ 0xAE32 }}; std::array<uint32_t, 3> const c5 = {{ 0x1100, 0x1175, 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_179) { // AE33;AE33;1100 1175 11AA;AE33;1100 1175 11AA; // (긳; 긳; 긳; 긳; 긳; ) HANGUL SYLLABLE GIGS { std::array<uint32_t, 1> const c1 = {{ 0xAE33 }}; std::array<uint32_t, 1> const c2 = {{ 0xAE33 }}; std::array<uint32_t, 3> const c3 = {{ 0x1100, 0x1175, 0x11AA }}; std::array<uint32_t, 1> const c4 = {{ 0xAE33 }}; std::array<uint32_t, 3> const c5 = {{ 0x1100, 0x1175, 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_180) { // AE34;AE34;1100 1175 11AB;AE34;1100 1175 11AB; // (긴; 긴; 긴; 긴; 긴; ) HANGUL SYLLABLE GIN { std::array<uint32_t, 1> const c1 = {{ 0xAE34 }}; std::array<uint32_t, 1> const c2 = {{ 0xAE34 }}; std::array<uint32_t, 3> const c3 = {{ 0x1100, 0x1175, 0x11AB }}; std::array<uint32_t, 1> const c4 = {{ 0xAE34 }}; std::array<uint32_t, 3> const c5 = {{ 0x1100, 0x1175, 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_181) { // AE35;AE35;1100 1175 11AC;AE35;1100 1175 11AC; // (긵; 긵; 긵; 긵; 긵; ) HANGUL SYLLABLE GINJ { std::array<uint32_t, 1> const c1 = {{ 0xAE35 }}; std::array<uint32_t, 1> const c2 = {{ 0xAE35 }}; std::array<uint32_t, 3> const c3 = {{ 0x1100, 0x1175, 0x11AC }}; std::array<uint32_t, 1> const c4 = {{ 0xAE35 }}; std::array<uint32_t, 3> const c5 = {{ 0x1100, 0x1175, 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_182) { // AE36;AE36;1100 1175 11AD;AE36;1100 1175 11AD; // (긶; 긶; 긶; 긶; 긶; ) HANGUL SYLLABLE GINH { std::array<uint32_t, 1> const c1 = {{ 0xAE36 }}; std::array<uint32_t, 1> const c2 = {{ 0xAE36 }}; std::array<uint32_t, 3> const c3 = {{ 0x1100, 0x1175, 0x11AD }}; std::array<uint32_t, 1> const c4 = {{ 0xAE36 }}; std::array<uint32_t, 3> const c5 = {{ 0x1100, 0x1175, 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_183) { // AE37;AE37;1100 1175 11AE;AE37;1100 1175 11AE; // (긷; 긷; 긷; 긷; 긷; ) HANGUL SYLLABLE GID { std::array<uint32_t, 1> const c1 = {{ 0xAE37 }}; std::array<uint32_t, 1> const c2 = {{ 0xAE37 }}; std::array<uint32_t, 3> const c3 = {{ 0x1100, 0x1175, 0x11AE }}; std::array<uint32_t, 1> const c4 = {{ 0xAE37 }}; std::array<uint32_t, 3> const c5 = {{ 0x1100, 0x1175, 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_184) { // AE38;AE38;1100 1175 11AF;AE38;1100 1175 11AF; // (길; 길; 길; 길; 길; ) HANGUL SYLLABLE GIL { std::array<uint32_t, 1> const c1 = {{ 0xAE38 }}; std::array<uint32_t, 1> const c2 = {{ 0xAE38 }}; std::array<uint32_t, 3> const c3 = {{ 0x1100, 0x1175, 0x11AF }}; std::array<uint32_t, 1> const c4 = {{ 0xAE38 }}; std::array<uint32_t, 3> const c5 = {{ 0x1100, 0x1175, 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_185) { // AE39;AE39;1100 1175 11B0;AE39;1100 1175 11B0; // (긹; 긹; 긹; 긹; 긹; ) HANGUL SYLLABLE GILG { std::array<uint32_t, 1> const c1 = {{ 0xAE39 }}; std::array<uint32_t, 1> const c2 = {{ 0xAE39 }}; std::array<uint32_t, 3> const c3 = {{ 0x1100, 0x1175, 0x11B0 }}; std::array<uint32_t, 1> const c4 = {{ 0xAE39 }}; std::array<uint32_t, 3> const c5 = {{ 0x1100, 0x1175, 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_186) { // AE3A;AE3A;1100 1175 11B1;AE3A;1100 1175 11B1; // (긺; 긺; 긺; 긺; 긺; ) HANGUL SYLLABLE GILM { std::array<uint32_t, 1> const c1 = {{ 0xAE3A }}; std::array<uint32_t, 1> const c2 = {{ 0xAE3A }}; std::array<uint32_t, 3> const c3 = {{ 0x1100, 0x1175, 0x11B1 }}; std::array<uint32_t, 1> const c4 = {{ 0xAE3A }}; std::array<uint32_t, 3> const c5 = {{ 0x1100, 0x1175, 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_187) { // AE3B;AE3B;1100 1175 11B2;AE3B;1100 1175 11B2; // (긻; 긻; 긻; 긻; 긻; ) HANGUL SYLLABLE GILB { std::array<uint32_t, 1> const c1 = {{ 0xAE3B }}; std::array<uint32_t, 1> const c2 = {{ 0xAE3B }}; std::array<uint32_t, 3> const c3 = {{ 0x1100, 0x1175, 0x11B2 }}; std::array<uint32_t, 1> const c4 = {{ 0xAE3B }}; std::array<uint32_t, 3> const c5 = {{ 0x1100, 0x1175, 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_188) { // AE3C;AE3C;1100 1175 11B3;AE3C;1100 1175 11B3; // (긼; 긼; 긼; 긼; 긼; ) HANGUL SYLLABLE GILS { std::array<uint32_t, 1> const c1 = {{ 0xAE3C }}; std::array<uint32_t, 1> const c2 = {{ 0xAE3C }}; std::array<uint32_t, 3> const c3 = {{ 0x1100, 0x1175, 0x11B3 }}; std::array<uint32_t, 1> const c4 = {{ 0xAE3C }}; std::array<uint32_t, 3> const c5 = {{ 0x1100, 0x1175, 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_189) { // AE3D;AE3D;1100 1175 11B4;AE3D;1100 1175 11B4; // (긽; 긽; 긽; 긽; 긽; ) HANGUL SYLLABLE GILT { std::array<uint32_t, 1> const c1 = {{ 0xAE3D }}; std::array<uint32_t, 1> const c2 = {{ 0xAE3D }}; std::array<uint32_t, 3> const c3 = {{ 0x1100, 0x1175, 0x11B4 }}; std::array<uint32_t, 1> const c4 = {{ 0xAE3D }}; std::array<uint32_t, 3> const c5 = {{ 0x1100, 0x1175, 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_190) { // AE3E;AE3E;1100 1175 11B5;AE3E;1100 1175 11B5; // (긾; 긾; 긾; 긾; 긾; ) HANGUL SYLLABLE GILP { std::array<uint32_t, 1> const c1 = {{ 0xAE3E }}; std::array<uint32_t, 1> const c2 = {{ 0xAE3E }}; std::array<uint32_t, 3> const c3 = {{ 0x1100, 0x1175, 0x11B5 }}; std::array<uint32_t, 1> const c4 = {{ 0xAE3E }}; std::array<uint32_t, 3> const c5 = {{ 0x1100, 0x1175, 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_191) { // AE3F;AE3F;1100 1175 11B6;AE3F;1100 1175 11B6; // (긿; 긿; 긿; 긿; 긿; ) HANGUL SYLLABLE GILH { std::array<uint32_t, 1> const c1 = {{ 0xAE3F }}; std::array<uint32_t, 1> const c2 = {{ 0xAE3F }}; std::array<uint32_t, 3> const c3 = {{ 0x1100, 0x1175, 0x11B6 }}; std::array<uint32_t, 1> const c4 = {{ 0xAE3F }}; std::array<uint32_t, 3> const c5 = {{ 0x1100, 0x1175, 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_192) { // AE40;AE40;1100 1175 11B7;AE40;1100 1175 11B7; // (김; 김; 김; 김; 김; ) HANGUL SYLLABLE GIM { std::array<uint32_t, 1> const c1 = {{ 0xAE40 }}; std::array<uint32_t, 1> const c2 = {{ 0xAE40 }}; std::array<uint32_t, 3> const c3 = {{ 0x1100, 0x1175, 0x11B7 }}; std::array<uint32_t, 1> const c4 = {{ 0xAE40 }}; std::array<uint32_t, 3> const c5 = {{ 0x1100, 0x1175, 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_193) { // AE41;AE41;1100 1175 11B8;AE41;1100 1175 11B8; // (깁; 깁; 깁; 깁; 깁; ) HANGUL SYLLABLE GIB { std::array<uint32_t, 1> const c1 = {{ 0xAE41 }}; std::array<uint32_t, 1> const c2 = {{ 0xAE41 }}; std::array<uint32_t, 3> const c3 = {{ 0x1100, 0x1175, 0x11B8 }}; std::array<uint32_t, 1> const c4 = {{ 0xAE41 }}; std::array<uint32_t, 3> const c5 = {{ 0x1100, 0x1175, 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_194) { // AE42;AE42;1100 1175 11B9;AE42;1100 1175 11B9; // (깂; 깂; 깂; 깂; 깂; ) HANGUL SYLLABLE GIBS { std::array<uint32_t, 1> const c1 = {{ 0xAE42 }}; std::array<uint32_t, 1> const c2 = {{ 0xAE42 }}; std::array<uint32_t, 3> const c3 = {{ 0x1100, 0x1175, 0x11B9 }}; std::array<uint32_t, 1> const c4 = {{ 0xAE42 }}; std::array<uint32_t, 3> const c5 = {{ 0x1100, 0x1175, 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_195) { // AE43;AE43;1100 1175 11BA;AE43;1100 1175 11BA; // (깃; 깃; 깃; 깃; 깃; ) HANGUL SYLLABLE GIS { std::array<uint32_t, 1> const c1 = {{ 0xAE43 }}; std::array<uint32_t, 1> const c2 = {{ 0xAE43 }}; std::array<uint32_t, 3> const c3 = {{ 0x1100, 0x1175, 0x11BA }}; std::array<uint32_t, 1> const c4 = {{ 0xAE43 }}; std::array<uint32_t, 3> const c5 = {{ 0x1100, 0x1175, 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_196) { // AE44;AE44;1100 1175 11BB;AE44;1100 1175 11BB; // (깄; 깄; 깄; 깄; 깄; ) HANGUL SYLLABLE GISS { std::array<uint32_t, 1> const c1 = {{ 0xAE44 }}; std::array<uint32_t, 1> const c2 = {{ 0xAE44 }}; std::array<uint32_t, 3> const c3 = {{ 0x1100, 0x1175, 0x11BB }}; std::array<uint32_t, 1> const c4 = {{ 0xAE44 }}; std::array<uint32_t, 3> const c5 = {{ 0x1100, 0x1175, 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_197) { // AE45;AE45;1100 1175 11BC;AE45;1100 1175 11BC; // (깅; 깅; 깅; 깅; 깅; ) HANGUL SYLLABLE GING { std::array<uint32_t, 1> const c1 = {{ 0xAE45 }}; std::array<uint32_t, 1> const c2 = {{ 0xAE45 }}; std::array<uint32_t, 3> const c3 = {{ 0x1100, 0x1175, 0x11BC }}; std::array<uint32_t, 1> const c4 = {{ 0xAE45 }}; std::array<uint32_t, 3> const c5 = {{ 0x1100, 0x1175, 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_198) { // AE46;AE46;1100 1175 11BD;AE46;1100 1175 11BD; // (깆; 깆; 깆; 깆; 깆; ) HANGUL SYLLABLE GIJ { std::array<uint32_t, 1> const c1 = {{ 0xAE46 }}; std::array<uint32_t, 1> const c2 = {{ 0xAE46 }}; std::array<uint32_t, 3> const c3 = {{ 0x1100, 0x1175, 0x11BD }}; std::array<uint32_t, 1> const c4 = {{ 0xAE46 }}; std::array<uint32_t, 3> const c5 = {{ 0x1100, 0x1175, 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.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, nfc_014_199) { // AE47;AE47;1100 1175 11BE;AE47;1100 1175 11BE; // (깇; 깇; 깇; 깇; 깇; ) HANGUL SYLLABLE GIC { std::array<uint32_t, 1> const c1 = {{ 0xAE47 }}; std::array<uint32_t, 1> const c2 = {{ 0xAE47 }}; std::array<uint32_t, 3> const c3 = {{ 0x1100, 0x1175, 0x11BE }}; std::array<uint32_t, 1> const c4 = {{ 0xAE47 }}; std::array<uint32_t, 3> const c5 = {{ 0x1100, 0x1175, 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c2.begin(), c2.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c3.begin(), c3.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c2.size()); auto c2_it = c2.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c2_it) << "iteration " << i; ++c2_it; ++i; } } { boost::text::string str = boost::text::to_string(c4.begin(), c4.end()); boost::text::normalize_to_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 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_nfc(str); boost::text::utf32_range utf32_range(str); EXPECT_EQ(std::distance(utf32_range.begin(), utf32_range.end()), c4.size()); auto c4_it = c4.begin(); int i = 0; for (auto x : utf32_range) { EXPECT_EQ(x, *c4_it) << "iteration " << i; ++c4_it; ++i; } } } }
[ "whatwasthataddress@gmail.com" ]
whatwasthataddress@gmail.com
f00ed4510fe8cfb41c00a4b57cd378b0c894a5b5
f6fca6c43ad746c45c8321541178eb02e2cb555e
/1cpp/Source/OXY_Value.h
f7c5fe0c3ac910e6209ba82cb80edb81218c4ac5
[]
no_license
Asakra/alterplast
da271c590b32767953f09266fed1569831aa78cb
682e1c2d2f4246183e9b8284d8cf2dbc14f6e228
refs/heads/master
2023-06-22T04:16:34.924155
2021-07-16T06:20:20
2021-07-16T06:20:20
null
0
0
null
null
null
null
UTF-8
C++
false
false
880
h
// OXY_Value.h: interface for the COXY_Value class. // ////////////////////////////////////////////////////////////////////// #if !defined(AFX_OXY_VALUE_H__D74E228B_7046_40C7_9C2E_882F84A10F5F__INCLUDED_) #define AFX_OXY_VALUE_H__D74E228B_7046_40C7_9C2E_882F84A10F5F__INCLUDED_ #if _MSC_VER > 1000 #pragma once #endif // _MSC_VER > 1000 //#include "1CHEADERS\bkend.h" /* class COXY_Value : public CValue { public: COXY_Value() : CValue() {} COXY_Value(class CValue const & par) : CValue(par) {} COXY_Value(class CNumeric const & par) : CValue(par) {} COXY_Value(class CType const & par) : CValue(par) {} COXY_Value(long par) : CValue(par) {} COXY_Value(char const * par) : CValue(par) {} COXY_Value(class CDate par) : CValue(par) {} virtual ~COXY_Value() {} }; */ #endif // !defined(AFX_OXY_VALUE_H__D74E228B_7046_40C7_9C2E_882F84A10F5F__INCLUDED_)
[ "trdmval@gmail.com" ]
trdmval@gmail.com
aec4072a90a45b14d9c4e56628830a83cefecc54
a23ce4e463e0118fd8d36afb74832ac8134b4f8c
/DataStructure/Array/215_kth_largest_element_in_array.cpp
6e0989ea473796e511d5d069d1f15a358f75f36f
[ "MIT" ]
permissive
xtstc131/mall0x_Leetcode
89cc07a9bfa67536f02533219e1123c5e09e99ff
db528f2a78808d4123785c35218cce00906166dd
refs/heads/master
2021-07-23T20:14:10.338547
2021-07-19T03:38:35
2021-07-19T03:38:35
229,400,307
1
0
null
2020-01-03T00:55:54
2019-12-21T08:40:06
C++
UTF-8
C++
false
false
1,087
cpp
#include"header.hpp" class Solution { public: int findKthLargest(vector<int> &nums, int k) { auto partition = [&](int left, int right) { int pivot = nums[left]; int l = left + 1, r = right; while (l <= r) { if (nums[l] < pivot and nums[r] > pivot) { swap(nums[l++], nums[r--]); } if (nums[l] >= pivot) l++; if (nums[r] <= pivot) r--; } swap(nums[left], nums[r]); return r; }; int left = 0; int right = nums.size() - 1; int result = 0; while (true) { int idx = partition(left, right); if (idx == k - 1) { result = nums[idx]; break; } else if (idx > k - 1) { right = idx - 1; } else left = idx + 1; } return result; } };
[ "mallxia@163.com" ]
mallxia@163.com
8f89383e77e6ab12e7b61aaa62f9cd05e0607bc0
0462c24f45d17055d514ad01cccd4757c4220275
/AudioFile/IAudioFile.h
4a43e64ff44884c85837aef1f5b809ec132a2e1f
[ "BSD-3-Clause" ]
permissive
AlexHarker/HISSTools_Library
1943b0009f498bc4cc18f4031bd70fa17b6f0d68
99ea94fb47b38d7ebf3374c391b9f3456f2c7760
refs/heads/main
2023-08-31T10:17:23.019599
2023-03-21T16:45:45
2023-03-21T16:45:45
168,504,770
41
6
BSD-3-Clause
2023-09-13T08:37:44
2019-01-31T10:14:02
C++
UTF-8
C++
false
false
3,522
h
#ifndef _HISSTOOLS_IAUDIOFILE_ #define _HISSTOOLS_IAUDIOFILE_ #include "BaseAudioFile.h" #include <fstream> namespace HISSTools { // FIX - check types, errors and returns class IAudioFile : public BaseAudioFile { enum AiffTag { AIFC_TAG_UNKNOWN = 0x0, AIFC_TAG_VERSION = 0x1, AIFC_TAG_COMMON = 0x2, AIFC_TAG_AUDIO = 0x4 }; enum AifcCompression { AIFC_COMPRESSION_UNKNOWN, AIFC_COMPRESSION_NONE, AIFC_COMPRESSION_LITTLE_ENDIAN, AIFC_COMPRESSION_FLOAT }; public: // Constructor and Destructor IAudioFile(const std::string& = std::string()); ~IAudioFile(); // File Open / Close void open(const std::string& i); void close(); bool isOpen(); // File Position void seek(FrameCount position = 0); FrameCount getPosition(); // File Reading void readRaw(void* output, FrameCount numFrames); void readInterleaved(double* output, FrameCount numFrames); void readInterleaved(float* output, FrameCount numFrames); void readChannel(double* output, FrameCount numFrames, uint16_t channel); void readChannel(float* output, FrameCount numFrames, uint16_t channel); private: // Internal File Handling bool readInternal(char* buffer, ByteCount numBytes); bool seekInternal(ByteCount position); bool advanceInternal(ByteCount offset); ByteCount positionInternal(); // Extracting Single Values uint64_t getU64(const char* bytes, Endianness fileEndianness) const; uint32_t getU32(const char* bytes, Endianness fileEndianness) const; uint32_t getU24(const char* bytes, Endianness fileEndianness) const; uint32_t getU16(const char* bytes, Endianness fileEndianness) const; // Conversion double extendedToDouble(const char* bytes) const; template <class T> void u32ToOutput(T* output, uint32_t value); template <class T> void u8ToOutput(T* output, uint8_t value); template <class T> void float32ToOutput(T* output, uint32_t value); template <class T> void float64ToOutput(T* output, uint64_t value); // Chunk Reading static bool matchTag(const char* a, const char* b); bool readChunkHeader(char* tag, uint32_t& chunkSize); bool findChunk(const char* searchTag, uint32_t& chunkSize); bool readChunk(char* data, uint32_t readSize, uint32_t chunkSize); // PCM Format Helpers static Error findPCMFormat(uint16_t, NumberFormat, PCMFormat&); void setPCMFormat(uint16_t bitDepth, NumberFormat format); // AIFF Helpers bool getAIFFChunkHeader(AiffTag& enumeratedTag, uint32_t& chunkSize); AifcCompression getAIFCCompression(const char* tag, uint16_t& bitDepth) const; // Parse Headers void parseHeader(); void parseAIFFHeader(const char* fileSubtype); void parseWaveHeader(const char* fileType); // Internal Typed Audio Read template <class T> void readAudio(T* output, FrameCount numFrames, int32_t channel = -1); // Data std::ifstream mFile; char *mBuffer; }; } #endif
[ "ajharker@gmail.com" ]
ajharker@gmail.com
6be00ad8fe652edfef65cd742cf0d26d3fa406ac
5c3bad3e7b0c8b712a6195afd19f0feaf744d044
/code-samples/Introduction/Exercise_5.cpp
de30c583ecbdbf47df31a7f0f8e55c67775eb35c
[ "Apache-2.0" ]
permissive
csdeptku/cs141
f961e395976c43f70470f983ad9941584bad5017
befd96cb22bccc9b1561224967c9feafd2a550e4
refs/heads/main
2023-08-03T03:16:41.196695
2021-10-04T22:17:25
2021-10-04T22:17:25
413,307,225
0
0
null
null
null
null
UTF-8
C++
false
false
440
cpp
/* Write a C++ program that reads a two-digit integer and prints the sum and the product of its digits. */ #include <iostream> using namespace std; int main() { int n; int d1, d2; cout << "Enter a 2-digit integer: "; cin >> n; d2 = n % 10; d1 = n / 10; cout << "The sum of the 2 digits is: " << d1 + d2 << endl; cout << "The product of the 2 digits is: " << d1 * d2 << endl; return 0; }
[ "Mo7amadsalman@hotmail.com" ]
Mo7amadsalman@hotmail.com
e48ddeb22519a60649895d956b333bc2e897703d
c322279e4155ca257a4a78c4130efbac2ae1380a
/剑指offer/Task43_numberOf1Between1AndN.cpp
dc07afc2379630a5a27055eed36eb0ffe0c100e0
[]
no_license
xieliang555/leetcode
43c87087ad358ca1a3faa7e74e3849e55052a00e
09f6ff8e34ac9db6c59b0e2c244a2ba93b0ae8ed
refs/heads/master
2020-06-27T06:06:21.642472
2019-08-30T07:14:20
2019-08-30T07:14:20
199,864,278
0
0
null
null
null
null
UTF-8
C++
false
false
623
cpp
#include<iostream> class Task43_numberOf1Between1AndN { public: Task43_numberOf1Between1AndN(){} ~Task43_numberOf1Between1AndN(){} int NumberOf1Between1AndN(int n){ int count=0; int i=1; while(n/i!=0){ int lowBits=n%i; int highBits=n/(i*10); int currentBit=(n/i)%10; if(currentBit==0){ count+=highBits*i; } else if(currentBit==1){ count+=highBits*i+lowBits+1; } else count+=(highBits+1)*i; i*=10; } return count; } }; int main(int argc, char const *argv[]) { Task43_numberOf1Between1AndN t; std::cout<<t.NumberOf1Between1AndN(12)<<std::endl; return 0; }
[ "xieliang555@gmail.com" ]
xieliang555@gmail.com
504dd258fb45b6ebdc5ade43863aae9f461fae91
5c6dcbe7be840fefc890a21925d0d252aafef6d6
/src/graph/TestAddEdgeSameVertexFAIL.cpp
bb883f3122e49af91f846b491242984682f41e8b
[]
no_license
hschu12/Graph-AdjacencyList
6176cc49b9df7331db9532b7631fa5428e04ad27
2da7f98f4f9b38f1d26db479660665a9bd2dbbb9
refs/heads/master
2021-03-27T00:52:47.071412
2017-01-31T18:30:23
2017-01-31T18:30:23
80,359,890
0
0
null
null
null
null
UTF-8
C++
false
false
1,050
cpp
#include "include/adjacency_list.hpp" #include "include/properties.hpp" #include "include/tags.hpp" #include "include/depth_first_search.hpp" #include "include/topological_sort.hpp" #include <iostream> int main() { using edgedirection = graph::tags::Bidirectional; using vertexProp = graph::vertexProp::Capacity; using edgeProp = graph::edgeProp::Cost; graph::AdjacencyList<edgedirection, vertexProp, edgeProp> graf = graph::AdjacencyList<edgedirection, vertexProp, edgeProp>(4); auto v1 = addVertex(graph::vertexProp::Capacity(10), graf); auto v2 = addVertex(graph::vertexProp::Capacity(15), graf); auto v3 = addVertex(graph::vertexProp::Capacity(20), graf); auto v4 = addVertex(graph::vertexProp::Capacity(25), graf); auto e1 = addEdge(v1, v1, graph::edgeProp::Cost(10), graf); auto e2 = addEdge(v1, v2, graph::edgeProp::Cost(10), graf); auto e3 = addEdge(v2, v3, graph::edgeProp::Cost(10), graf); auto e4 = addEdge(v2, v4, graph::edgeProp::Cost(10), graf); auto e5 = addEdge(v3, v4, graph::edgeProp::Cost(10), graf); return 0; }
[ "Henrikschulz@hotmail.com" ]
Henrikschulz@hotmail.com
19f72db921ef2a94d22201405a60e6b2b4da8278
df95ee8612c1b19712b97584d2de21219cf40b0c
/pool_info/MethodHandlePoolInfo.cpp
a77b57e70a62f7ab079cefd7406d95b55d740831
[]
no_license
lolilofit/JavaConstantPoolParser
ad7243fe3559d3b9f834f692142238ab1b000704
1df4c395643918b70fa43a3f99d65e23bf56da9e
refs/heads/master
2023-03-11T15:59:56.437399
2021-02-28T18:22:07
2021-02-28T18:22:07
296,648,556
0
0
null
null
null
null
UTF-8
C++
false
false
75
cpp
// // Created by User on 18.09.2020. // #include "MethodHandlePoolInfo.h"
[ "usovadasha@myttk.ru" ]
usovadasha@myttk.ru
b4fe8fec6e344fc92fbbdb30b73227d10172cc2a
7705a494efb69226fbb1cf5c44a467c183dcbf4f
/system/sampleDict.streamwise
9586e7e75efabc0a91636704336beaaf9abf079b
[]
no_license
petebachant/actuatorSurface-OpenFOAM
f92d4398d667383927a74198804678667db9065b
28f5f2f8e3dab502a0929142bceaedc5daac3088
refs/heads/master
2021-01-18T23:26:42.531974
2016-03-29T22:01:12
2016-03-29T22:01:12
19,945,853
3
3
null
null
null
null
UTF-8
C++
false
false
1,086
streamwise
/*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | | \\ / O peration | Version: 2.3.x | | \\ / A nd | Web: www.OpenFOAM.org | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ FoamFile { version 2.0; format ascii; class dictionary; object sampleDict; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // setFormat raw; interpolationScheme cellPoint; sets ( streamwise { type uniform; axis x; start (-1.999 0 0); end (8 0 0); nPoints 101; } ); fields ( U ); // *********************************************************************** //
[ "petebachant@gmail.com" ]
petebachant@gmail.com
bedf90d21fd40af1230cc9a01ff6a251c1992ef3
22e09278b9059fd87c080e2f721014ea48fa2b97
/statistics/pair_distribution_function/mts0_io/mts0_io.h
80a89a81633cbd019f80ed12006772223b3f74bd
[]
no_license
FSund/master
c7bb5dfedf6ae1717b4a23038fa793f7d3b8a4df
0cecb6f6ae3bd29dd8e80b2aa071a3532ff11d54
refs/heads/master
2021-01-25T08:28:43.173939
2014-05-14T09:03:09
2014-05-14T09:03:09
null
0
0
null
null
null
null
UTF-8
C++
false
false
3,163
h
/* mts0_io.cpp mts0_io.h Created by Jørgen Trømborg and Anders Hafreager on 15.04.13. Copyright (c) 2013 Universitetet i Oslo. All rights reserved. load_atoms(nx, ny, nz, velocities, positions, atom_type, h_matrix, mts0_directory) save_atoms(nx, ny, nz, velocities, positions, atom_type, h_matrix, mts0_directory) nx, ny, nz - number of cpus [int]. velocities - atom velocities [vector<vector<double> >], dimension num_atoms x 3, units unknown positions - atom positions [vector<vector<double> >], dimension num_atoms x 3, units Ångström atom_types - atom types [vector<int>], dimension num_atoms, {1-Si,2-A,3-H,4-O,5-Na,6-Cl,7-X} atom_ids - atom ids [vector<int>], dimension num_atoms h_matrix - h-matrix [vector<vector<vector<double> > >], dimension 2 x (3 x 3) mts0_directory - mts0-directory [string] */ #pragma once #include <fstream> #include <vector> #include <string> #include <iostream> #include <cstdlib> using namespace std; class Mts0_io { private: const double bohr; void read_data(ifstream *file, void *value); void write_data(ofstream *file, void *value, int &N); void read_mts(char *filename, vector<int> &atom_types_local, vector<int> &atom_ids_local, vector<vector<double> > &positions_local, vector<vector<double> > &velocities_local); void write_mts(char *filename, vector<int> &atom_types_local, vector<int> &atom_ids_local, vector<vector<double> > &positions_local, vector<vector<double> > &velocities_local); void is_all_atoms_inside_system(); bool next_atom_id_is_known; bool atom_type_masses_is_known; bool did_remove_at_least_one_atom; int next_atom_id; vector<double> atom_type_masses; vector<vector<vector<double> > > h_matrix; public: int nx, ny, nz; vector<vector<double> > positions; vector<vector<double> > velocities; vector<int> atom_ids; vector<int> atom_types; vector<bool> atom_is_removed; Mts0_io(int nx_, int ny_, int nz_); vector<vector<int> > create_neighbor_list(const double &neighbor_list_radius); int add_atom(int atom_type, vector<double> position, vector<double> velocity); void remove_atom(int atom_to_be_removed_index); void remove_atoms(vector<int> &atoms_to_be_removed_indices); void bring_removed_atoms_back(vector<int> &atoms_to_be_removed_indices); void rearrange_vectors_by_moving_atoms_from_end_to_locations_where_atoms_have_been_removed(); void set_atom_type_masses(vector<double> atom_type_masses_); int get_number_of_atoms(); vector<double> get_lx_ly_lz(); double get_volume(); vector<int> get_number_of_atoms_of_each_type(); int get_next_atom_id(); vector<double> get_momentum_of_atom(int atom_index); vector<double> get_momentum_of_atoms(vector<int> atom_indices); double get_mass_of_atom(int atom_index); double get_squared_distance_between_atoms(int atom_index_0, int atom_index_1); double get_min_distance_between_atom_types(int wanted_atom_type_0, int wanted_atom_type_1, double max_min_distance); void load_atoms(string mts0_directory, vector<int> node_id_list = vector<int>()); void save_atoms(string mts0_directory); void write_to_lammps(string lammps_filename); };
[ "filipsu@fys.uio.no" ]
filipsu@fys.uio.no
c4a18cdbc61436700e8ac641ed0283074a439051
7b0a12d6e9d9dce71244551c4c320dfa7b33f42e
/CCE-ALLOCATION/C/CCE_Allocation/cutscallback.cpp
90cf6f1fd43298c021f66f257146f116e41b6ddb
[]
no_license
matheusota/MO648
572d6423c626b8ee63e5819e52b1ad93759d2575
76bd855c3bf4c1e16c06252a1fed780d548a1d04
refs/heads/master
2020-03-28T14:59:36.816909
2019-10-23T17:55:24
2019-10-23T17:55:24
148,544,539
0
0
null
null
null
null
UTF-8
C++
false
false
3,564
cpp
#include "cutscallback.h" CutsCallback::CutsCallback(vector<User> &users, int R, map<int, map<int, GRBVar>> &x): users(users), x(x){ this->R = R; } // callback function // Implements Van den Akker algorithm void CutsCallback::callback(){ // integer solution if (where == GRB_CB_MIPSOL){ solution_value = &CutsCallback::getSolution; } // fractional solution else if ((where == GRB_CB_MIPNODE) && (getIntInfo(GRB_CB_MIPNODE_STATUS) == GRB_OPTIMAL)){ solution_value = &CutsCallback::getNodeRel; } else{ return; } map<int, int> countSize; countSize[1] = 0; countSize[2] = 0; countSize[4] = 0; countSize[8] = 0; for(auto user: users){ countSize[user.size]++; } for(auto user : users){ countSize[user.size]--; int maxSize = 0; for(int s = 8; s >= 1; s /= 2){ if(countSize[s] > 0){ maxSize = s; break; } } for(int l = user.size - 1; l < R; l++){ if(find(user.begins.begin(), user.begins.end(), l) != user.begins.end() && ((this ->*solution_value)(x[user.id][l]) >= 0.1) && ((this ->*solution_value)(x[user.id][l]) <= 0.9)){ for(int u = l + 1; u < l + maxSize; u++){ if(find(user.begins.begin(), user.begins.end(), u) != user.begins.end() && ((this ->*solution_value)(x[user.id][u]) >= 0.1) && ((this ->*solution_value)(x[user.id][u]) <= 0.9)){ double sum1 = 0; for(int s = max(0, l - user.size); s <= u; s++){ if(find(user.begins.begin(), user.begins.end(), s) != user.begins.end()){ sum1 += (this ->*solution_value)(x[user.id][s]); } } double sum2 = 0; for(auto user2 : users){ if(user2.id != user.id){ for(int s = max(0, u - user2.size); s <= l; s++){ if(find(user2.begins.begin(), user2.begins.end(), s) != user2.begins.end()){ sum2 += (this ->*solution_value)(x[user2.id][s]); } } } } // violation found, add the cut if(sum1 + sum2 > 1){ GRBLinExpr expr; for(int s = max(0, l - user.size); s <= u; s++){ if(find(user.begins.begin(), user.begins.end(), s) != user.begins.end()){ expr += x[user.id][s]; } } for(auto user2 : users){ if(user2.id != user.id){ for(int s = max(0, u - user2.size); s <= l; s++){ if(find(user2.begins.begin(), user2.begins.end(), s) != user2.begins.end()){ expr += x[user2.id][s]; } } } } addLazy(expr <= 1); } } } } } } }
[ "matheusota@gmail.com" ]
matheusota@gmail.com
82b3b42fbee2f3e2ae2342fd2e5031b6b450d772
f46471e44e7ccd3393fcb021db7edd63cb4c13ae
/src/encoder/encode_tree.cc
6a98043ee6e509429ceb60baca31938342ba9c22
[]
no_license
keithw/alfalfa-1
b7743cf917083c7b44b7b8aa4d8996021fda70fa
2a65b20a4ddcf0e721dfb82df37db7886fe891d6
refs/heads/master
2021-01-15T10:14:49.469507
2014-01-18T09:16:58
2014-01-18T09:16:58
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,058
cc
#include <vector> #include "bool_encoder.hh" #include "vp8_header_structures.hh" template <class enumeration, uint8_t alphabet_size, const TreeArray< alphabet_size > & nodes > static void encode( BoolEncoder & encoder, const Tree< enumeration, alphabet_size, nodes > & value, const ProbabilityArray< alphabet_size > & probs ) { /* reverse the tree */ SafeArray< uint8_t, 128 + nodes.size() > value_to_index; for ( uint8_t i = 0; i < nodes.size(); i++ ) { value_to_index.at( 128 + nodes.at( i ) - 1 ) = i; } std::vector< std::pair< bool, Probability > > bits; /* find the path to the node */ uint8_t node_index = value_to_index.at( 128 - value - 1 ); bits.emplace_back( node_index & 1, probs.at( node_index >> 1 ) ); while ( node_index > 1 ) { node_index = value_to_index.at( 128 + (node_index & 0xfe) - 1 ); bits.emplace_back( node_index & 1, probs.at( node_index >> 1 ) ); } /* encode the path */ for ( auto it = bits.rbegin(); it != bits.rend(); it++ ) { encoder.put( it->first, it->second ); } }
[ "keithw@mit.edu" ]
keithw@mit.edu
5d6ab16aab9cc3457c3f3e6ef8ab7109536cb7b6
de8174218e5218c463733e26528758face8ee9d0
/vnoj/predhbb21_key.cpp
4599126cce7acd04b500e317ede741d0423b3bf3
[ "MIT" ]
permissive
tiozo/Training
297552c72ef366abaf0c52b0b0d3d53c1b2bd4b1
02cc8c4fcf68e07c16520fd05fcbfa524c171b6b
refs/heads/main
2023-07-18T09:53:21.049680
2021-09-05T23:58:38
2021-09-05T23:58:38
400,692,883
1
0
null
null
null
null
UTF-8
C++
false
false
551
cpp
#include<bits/stdc++.h> using namespace std; int main() { int N; cin >> N; for (int i=1;i<=N;++i) {string s; cin >> s; int n = s.size(); string t(s.rbegin(),s.rend()); int Bst_L = 0, Bst_R = -1; for (int l = 0,r = 0;l<n;l=max(l,r)+1) { for (r = l - 1; r + 1 < n && s[r+1]==t[r+1]; ++r); if (Bst_R-Bst_L < r-l) { Bst_L = l; Bst_R = r; } } cout << s.substr(Bst_L, Bst_R - Bst_L + 1) << '\n';} return 0; }
[ "azinz850@gmail.com" ]
azinz850@gmail.com
a39fe68b45ba183d5034c768fe822fd02b3e4ee0
a84b013cd995870071589cefe0ab060ff3105f35
/webdriver/branches/android/third_party/gecko-1.9.0.11/win32/include/nsIServiceManager.h
268bb849fec0b5a5c7d1a7b4317234f1f8eb4a4f
[ "Apache-2.0" ]
permissive
vdt/selenium
137bcad58b7184690b8785859d77da0cd9f745a0
30e5e122b068aadf31bcd010d00a58afd8075217
refs/heads/master
2020-12-27T21:35:06.461381
2009-08-18T15:56:32
2009-08-18T15:56:32
13,650,409
1
0
null
null
null
null
UTF-8
C++
false
false
8,056
h
/* * DO NOT EDIT. THIS FILE IS GENERATED FROM e:/xr19rel/WINNT_5.2_Depend/mozilla/xpcom/components/nsIServiceManager.idl */ #ifndef __gen_nsIServiceManager_h__ #define __gen_nsIServiceManager_h__ #ifndef __gen_nsISupports_h__ #include "nsISupports.h" #endif /* For IDL files that don't want to include root IDL files. */ #ifndef NS_NO_VTABLE #define NS_NO_VTABLE #endif /* starting interface: nsIServiceManager */ #define NS_ISERVICEMANAGER_IID_STR "8bb35ed9-e332-462d-9155-4a002ab5c958" #define NS_ISERVICEMANAGER_IID \ {0x8bb35ed9, 0xe332, 0x462d, \ { 0x91, 0x55, 0x4a, 0x00, 0x2a, 0xb5, 0xc9, 0x58 }} /** * The nsIServiceManager manager interface provides a means to obtain * global services in an application. The service manager depends on the * repository to find and instantiate factories to obtain services. * * Users of the service manager must first obtain a pointer to the global * service manager by calling NS_GetServiceManager. After that, * they can request specific services by calling GetService. When they are * finished they can NS_RELEASE() the service as usual. * * A user of a service may keep references to particular services indefinitely * and only must call Release when it shuts down. * * @status FROZEN */ class NS_NO_VTABLE NS_SCRIPTABLE nsIServiceManager : public nsISupports { public: NS_DECLARE_STATIC_IID_ACCESSOR(NS_ISERVICEMANAGER_IID) /** * getServiceByContractID * * Returns the instance that implements aClass or aContractID and the * interface aIID. This may result in the instance being created. * * @param aClass or aContractID : aClass or aContractID of object * instance requested * @param aIID : IID of interface requested * @param result : resulting service */ /* void getService (in nsCIDRef aClass, in nsIIDRef aIID, [iid_is (aIID), retval] out nsQIResult result); */ NS_SCRIPTABLE NS_IMETHOD GetService(const nsCID & aClass, const nsIID & aIID, void * *result) = 0; /* void getServiceByContractID (in string aContractID, in nsIIDRef aIID, [iid_is (aIID), retval] out nsQIResult result); */ NS_SCRIPTABLE NS_IMETHOD GetServiceByContractID(const char *aContractID, const nsIID & aIID, void * *result) = 0; /** * isServiceInstantiated * * isServiceInstantiated will return a true if the service has already * been created, otherwise false * * @param aClass or aContractID : aClass or aContractID of object * instance requested * @param aIID : IID of interface requested * @param aIID : IID of interface requested */ /* boolean isServiceInstantiated (in nsCIDRef aClass, in nsIIDRef aIID); */ NS_SCRIPTABLE NS_IMETHOD IsServiceInstantiated(const nsCID & aClass, const nsIID & aIID, PRBool *_retval) = 0; /* boolean isServiceInstantiatedByContractID (in string aContractID, in nsIIDRef aIID); */ NS_SCRIPTABLE NS_IMETHOD IsServiceInstantiatedByContractID(const char *aContractID, const nsIID & aIID, PRBool *_retval) = 0; }; NS_DEFINE_STATIC_IID_ACCESSOR(nsIServiceManager, NS_ISERVICEMANAGER_IID) /* Use this macro when declaring classes that implement this interface. */ #define NS_DECL_NSISERVICEMANAGER \ NS_SCRIPTABLE NS_IMETHOD GetService(const nsCID & aClass, const nsIID & aIID, void * *result); \ NS_SCRIPTABLE NS_IMETHOD GetServiceByContractID(const char *aContractID, const nsIID & aIID, void * *result); \ NS_SCRIPTABLE NS_IMETHOD IsServiceInstantiated(const nsCID & aClass, const nsIID & aIID, PRBool *_retval); \ NS_SCRIPTABLE NS_IMETHOD IsServiceInstantiatedByContractID(const char *aContractID, const nsIID & aIID, PRBool *_retval); /* Use this macro to declare functions that forward the behavior of this interface to another object. */ #define NS_FORWARD_NSISERVICEMANAGER(_to) \ NS_SCRIPTABLE NS_IMETHOD GetService(const nsCID & aClass, const nsIID & aIID, void * *result) { return _to GetService(aClass, aIID, result); } \ NS_SCRIPTABLE NS_IMETHOD GetServiceByContractID(const char *aContractID, const nsIID & aIID, void * *result) { return _to GetServiceByContractID(aContractID, aIID, result); } \ NS_SCRIPTABLE NS_IMETHOD IsServiceInstantiated(const nsCID & aClass, const nsIID & aIID, PRBool *_retval) { return _to IsServiceInstantiated(aClass, aIID, _retval); } \ NS_SCRIPTABLE NS_IMETHOD IsServiceInstantiatedByContractID(const char *aContractID, const nsIID & aIID, PRBool *_retval) { return _to IsServiceInstantiatedByContractID(aContractID, aIID, _retval); } /* Use this macro to declare functions that forward the behavior of this interface to another object in a safe way. */ #define NS_FORWARD_SAFE_NSISERVICEMANAGER(_to) \ NS_SCRIPTABLE NS_IMETHOD GetService(const nsCID & aClass, const nsIID & aIID, void * *result) { return !_to ? NS_ERROR_NULL_POINTER : _to->GetService(aClass, aIID, result); } \ NS_SCRIPTABLE NS_IMETHOD GetServiceByContractID(const char *aContractID, const nsIID & aIID, void * *result) { return !_to ? NS_ERROR_NULL_POINTER : _to->GetServiceByContractID(aContractID, aIID, result); } \ NS_SCRIPTABLE NS_IMETHOD IsServiceInstantiated(const nsCID & aClass, const nsIID & aIID, PRBool *_retval) { return !_to ? NS_ERROR_NULL_POINTER : _to->IsServiceInstantiated(aClass, aIID, _retval); } \ NS_SCRIPTABLE NS_IMETHOD IsServiceInstantiatedByContractID(const char *aContractID, const nsIID & aIID, PRBool *_retval) { return !_to ? NS_ERROR_NULL_POINTER : _to->IsServiceInstantiatedByContractID(aContractID, aIID, _retval); } #if 0 /* Use the code below as a template for the implementation class for this interface. */ /* Header file */ class nsServiceManager : public nsIServiceManager { public: NS_DECL_ISUPPORTS NS_DECL_NSISERVICEMANAGER nsServiceManager(); private: ~nsServiceManager(); protected: /* additional members */ }; /* Implementation file */ NS_IMPL_ISUPPORTS1(nsServiceManager, nsIServiceManager) nsServiceManager::nsServiceManager() { /* member initializers and constructor code */ } nsServiceManager::~nsServiceManager() { /* destructor code */ } /* void getService (in nsCIDRef aClass, in nsIIDRef aIID, [iid_is (aIID), retval] out nsQIResult result); */ NS_IMETHODIMP nsServiceManager::GetService(const nsCID & aClass, const nsIID & aIID, void * *result) { return NS_ERROR_NOT_IMPLEMENTED; } /* void getServiceByContractID (in string aContractID, in nsIIDRef aIID, [iid_is (aIID), retval] out nsQIResult result); */ NS_IMETHODIMP nsServiceManager::GetServiceByContractID(const char *aContractID, const nsIID & aIID, void * *result) { return NS_ERROR_NOT_IMPLEMENTED; } /* boolean isServiceInstantiated (in nsCIDRef aClass, in nsIIDRef aIID); */ NS_IMETHODIMP nsServiceManager::IsServiceInstantiated(const nsCID & aClass, const nsIID & aIID, PRBool *_retval) { return NS_ERROR_NOT_IMPLEMENTED; } /* boolean isServiceInstantiatedByContractID (in string aContractID, in nsIIDRef aIID); */ NS_IMETHODIMP nsServiceManager::IsServiceInstantiatedByContractID(const char *aContractID, const nsIID & aIID, PRBool *_retval) { return NS_ERROR_NOT_IMPLEMENTED; } /* End of implementation class template. */ #endif #define NS_ERROR_SERVICE_NOT_AVAILABLE NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_XPCOM, 22) /** * @status DEPRECATED */ #define NS_ERROR_SERVICE_NOT_FOUND NS_ERROR_GENERATE_SUCCESS(NS_ERROR_MODULE_XPCOM, 22) /** * @status DEPRECATED */ #define NS_ERROR_SERVICE_IN_USE NS_ERROR_GENERATE_SUCCESS(NS_ERROR_MODULE_XPCOM, 23) // Observing xpcom autoregistration. Topics will be 'start' and 'stop'. #define NS_XPCOM_AUTOREGISTRATION_OBSERVER_ID "xpcom-autoregistration" #ifdef MOZILLA_INTERNAL_API #include "nsXPCOM.h" #include "nsServiceManagerUtils.h" #include "nsIServiceManagerObsolete.h" #endif #endif /* __gen_nsIServiceManager_h__ */
[ "alexber@07704840-8298-11de-bf8c-fd130f914ac9" ]
alexber@07704840-8298-11de-bf8c-fd130f914ac9
14645ffa95e6245e23b556cd798b650405fec341
12cc19461c3c4f2cac0105ada2baae26bd58bc9e
/src/demos/msvc/oscillator/stdafx.cpp
1fb66d40a71a82e81fa9de9966ad37214b2bdac0
[ "BSD-3-Clause" ]
permissive
giovannifortese/chrono
b3fc96882ace6fdf0ff1a9fc266a553e90d05e41
16204177fd72b48c2eb7cc3f7a0e702e831d6234
refs/heads/develop
2021-01-16T21:38:57.995094
2015-02-03T22:41:02
2015-02-03T22:41:02
30,302,090
1
0
null
2015-02-04T14:17:47
2015-02-04T14:17:46
null
UTF-8
C++
false
false
203
cpp
// stdafx.cpp : source file that includes just the standard includes // oscillator.pch will be the pre-compiled header // stdafx.obj will contain the pre-compiled type information #include "stdafx.h"
[ "tasora@ied.unipr.it" ]
tasora@ied.unipr.it
443587cc4d9b93be5f3b0d81a5dd8b3d9c5b6343
a05bc2e91eb1a8b1c28b098c9ff3d6ebcb494001
/src/core/relations.cpp
ceb1ca4923ef0d36244b51826c19715d42bc5d77
[ "MIT" ]
permissive
VB6Hobbyst7/polymgen
02d010abaea87697fd173398b80b3fbd22a97d38
2de7a7803302fb9955b46e9d39ab71e32caaa457
refs/heads/master
2022-02-08T23:09:19.720177
2019-08-09T14:57:42
2019-08-09T14:57:42
null
0
0
null
null
null
null
UTF-8
C++
false
false
424
cpp
#include "relations.h" pmg::Edge* pmg::relations::adjacent_by_edge(const pmg::Face* face0, const pmg::Face* face1) { std::size_t inters = 0; pmg::Edge* res = nullptr; for (auto& edge0 : face0->edges) for (auto& edge1 : face1->edges) if (edge0 == edge1) { inters++; res = edge0; break; } return inters == 1 ? res : nullptr; }
[ "tokarev28.art@gmail.com" ]
tokarev28.art@gmail.com
47167b07b495828379a9aa26a212b725876b8725
b36ee7cb6287b60d4d212bc25f9821c0eb8c7066
/src/qt/addresstablemodel.cpp
95fc6a590be4d17504ca5efdffe6189059ae5e14
[ "MIT" ]
permissive
ethercryptocoin/source
16e59c06dd7c0788ca6061e9a27e91e8cddb27a1
dbca44738b5764179aadfbb5305e404225132fe2
refs/heads/master
2021-07-14T22:31:42.389663
2017-10-21T11:50:30
2017-10-21T11:50:30
107,775,766
0
0
null
null
null
null
UTF-8
C++
false
false
12,865
cpp
#include "addresstablemodel.h" #include "guiutil.h" #include "walletmodel.h" #include "wallet.h" #include "base58.h" #include <QFont> const QString AddressTableModel::Send = "S"; const QString AddressTableModel::Receive = "R"; struct AddressTableEntry { enum Type { Sending, Receiving }; Type type; QString label; QString address; AddressTableEntry() {} AddressTableEntry(Type type, const QString &label, const QString &address): type(type), label(label), address(address) {} }; struct AddressTableEntryLessThan { bool operator()(const AddressTableEntry &a, const AddressTableEntry &b) const { return a.address < b.address; } bool operator()(const AddressTableEntry &a, const QString &b) const { return a.address < b; } bool operator()(const QString &a, const AddressTableEntry &b) const { return a < b.address; } }; // Private implementation class AddressTablePriv { public: CWallet *wallet; QList<AddressTableEntry> cachedAddressTable; AddressTableModel *parent; AddressTablePriv(CWallet *wallet, AddressTableModel *parent): wallet(wallet), parent(parent) {} void refreshAddressTable() { cachedAddressTable.clear(); { LOCK(wallet->cs_wallet); BOOST_FOREACH(const PAIRTYPE(CTxDestination, std::string)& item, wallet->mapAddressBook) { const CBitcoinAddress& address = item.first; const std::string& strName = item.second; bool fMine = IsMine(*wallet, address.Get()); cachedAddressTable.append(AddressTableEntry(fMine ? AddressTableEntry::Receiving : AddressTableEntry::Sending, QString::fromStdString(strName), QString::fromStdString(address.ToString()))); } } // qLowerBound() and qUpperBound() require our cachedAddressTable list to be sorted in asc order qSort(cachedAddressTable.begin(), cachedAddressTable.end(), AddressTableEntryLessThan()); } void updateEntry(const QString &address, const QString &label, bool isMine, int status) { // Find address / label in model QList<AddressTableEntry>::iterator lower = qLowerBound( cachedAddressTable.begin(), cachedAddressTable.end(), address, AddressTableEntryLessThan()); QList<AddressTableEntry>::iterator upper = qUpperBound( cachedAddressTable.begin(), cachedAddressTable.end(), address, AddressTableEntryLessThan()); int lowerIndex = (lower - cachedAddressTable.begin()); int upperIndex = (upper - cachedAddressTable.begin()); bool inModel = (lower != upper); AddressTableEntry::Type newEntryType = isMine ? AddressTableEntry::Receiving : AddressTableEntry::Sending; switch(status) { case CT_NEW: if(inModel) { OutputDebugStringF("Warning: AddressTablePriv::updateEntry: Got CT_NOW, but entry is already in model\n"); break; } parent->beginInsertRows(QModelIndex(), lowerIndex, lowerIndex); cachedAddressTable.insert(lowerIndex, AddressTableEntry(newEntryType, label, address)); parent->endInsertRows(); break; case CT_UPDATED: if(!inModel) { OutputDebugStringF("Warning: AddressTablePriv::updateEntry: Got CT_UPDATED, but entry is not in model\n"); break; } lower->type = newEntryType; lower->label = label; parent->emitDataChanged(lowerIndex); break; case CT_DELETED: if(!inModel) { OutputDebugStringF("Warning: AddressTablePriv::updateEntry: Got CT_DELETED, but entry is not in model\n"); break; } parent->beginRemoveRows(QModelIndex(), lowerIndex, upperIndex-1); cachedAddressTable.erase(lower, upper); parent->endRemoveRows(); break; } } int size() { return cachedAddressTable.size(); } AddressTableEntry *index(int idx) { if(idx >= 0 && idx < cachedAddressTable.size()) { return &cachedAddressTable[idx]; } else { return 0; } } }; AddressTableModel::AddressTableModel(CWallet *wallet, WalletModel *parent) : QAbstractTableModel(parent),walletModel(parent),wallet(wallet),priv(0) { columns << tr("Label") << tr("Address"); priv = new AddressTablePriv(wallet, this); priv->refreshAddressTable(); } AddressTableModel::~AddressTableModel() { delete priv; } int AddressTableModel::rowCount(const QModelIndex &parent) const { Q_UNUSED(parent); return priv->size(); } int AddressTableModel::columnCount(const QModelIndex &parent) const { Q_UNUSED(parent); return columns.length(); } QVariant AddressTableModel::data(const QModelIndex &index, int role) const { if(!index.isValid()) return QVariant(); AddressTableEntry *rec = static_cast<AddressTableEntry*>(index.internalPointer()); if(role == Qt::DisplayRole || role == Qt::EditRole) { switch(index.column()) { case Label: if(rec->label.isEmpty() && role == Qt::DisplayRole) { return tr("(no label)"); } else { return rec->label; } case Address: return rec->address; } } else if (role == Qt::FontRole) { QFont font; if(index.column() == Address) { font = GUIUtil::bitcoinAddressFont(); } return font; } else if (role == TypeRole) { switch(rec->type) { case AddressTableEntry::Sending: return Send; case AddressTableEntry::Receiving: return Receive; default: break; } } return QVariant(); } bool AddressTableModel::setData(const QModelIndex &index, const QVariant &value, int role) { if(!index.isValid()) return false; AddressTableEntry *rec = static_cast<AddressTableEntry*>(index.internalPointer()); editStatus = OK; if(role == Qt::EditRole) { switch(index.column()) { case Label: // Do nothing, if old label == new label if(rec->label == value.toString()) { editStatus = NO_CHANGES; return false; } wallet->SetAddressBookName(CBitcoinAddress(rec->address.toStdString()).Get(), value.toString().toStdString()); break; case Address: // Do nothing, if old address == new address if(CBitcoinAddress(rec->address.toStdString()) == CBitcoinAddress(value.toString().toStdString())) { editStatus = NO_CHANGES; return false; } // Refuse to set invalid address, set error status and return false else if(!walletModel->validateAddress(value.toString())) { editStatus = INVALID_ADDRESS; return false; } // Check for duplicate addresses to prevent accidental deletion of addresses, if you try // to paste an existing address over another address (with a different label) else if(wallet->mapAddressBook.count(CBitcoinAddress(value.toString().toStdString()).Get())) { editStatus = DUPLICATE_ADDRESS; return false; } // Double-check that we're not overwriting a receiving address else if(rec->type == AddressTableEntry::Sending) { { LOCK(wallet->cs_wallet); // Remove old entry wallet->DelAddressBookName(CBitcoinAddress(rec->address.toStdString()).Get()); // Add new entry with new address wallet->SetAddressBookName(CBitcoinAddress(value.toString().toStdString()).Get(), rec->label.toStdString()); } } break; } return true; } return false; } QVariant AddressTableModel::headerData(int section, Qt::Orientation orientation, int role) const { if(orientation == Qt::Horizontal) { if(role == Qt::DisplayRole) { return columns[section]; } } return QVariant(); } Qt::ItemFlags AddressTableModel::flags(const QModelIndex &index) const { if(!index.isValid()) return 0; AddressTableEntry *rec = static_cast<AddressTableEntry*>(index.internalPointer()); Qt::ItemFlags retval = Qt::ItemIsSelectable | Qt::ItemIsEnabled; // Can edit address and label for sending addresses, // and only label for receiving addresses. if(rec->type == AddressTableEntry::Sending || (rec->type == AddressTableEntry::Receiving && index.column()==Label)) { retval |= Qt::ItemIsEditable; } return retval; } QModelIndex AddressTableModel::index(int row, int column, const QModelIndex &parent) const { Q_UNUSED(parent); AddressTableEntry *data = priv->index(row); if(data) { return createIndex(row, column, priv->index(row)); } else { return QModelIndex(); } } void AddressTableModel::updateEntry(const QString &address, const QString &label, bool isMine, int status) { // Update address book model from EtherCryptoCoin core priv->updateEntry(address, label, isMine, status); } QString AddressTableModel::addRow(const QString &type, const QString &label, const QString &address) { std::string strLabel = label.toStdString(); std::string strAddress = address.toStdString(); editStatus = OK; if(type == Send) { if(!walletModel->validateAddress(address)) { editStatus = INVALID_ADDRESS; return QString(); } // Check for duplicate addresses { LOCK(wallet->cs_wallet); if(wallet->mapAddressBook.count(CBitcoinAddress(strAddress).Get())) { editStatus = DUPLICATE_ADDRESS; return QString(); } } } else if(type == Receive) { // Generate a new address to associate with given label WalletModel::UnlockContext ctx(walletModel->requestUnlock()); if(!ctx.isValid()) { // Unlock wallet failed or was cancelled editStatus = WALLET_UNLOCK_FAILURE; return QString(); } CPubKey newKey; if(!wallet->GetKeyFromPool(newKey, true)) { editStatus = KEY_GENERATION_FAILURE; return QString(); } strAddress = CBitcoinAddress(newKey.GetID()).ToString(); } else { return QString(); } // Add entry { LOCK(wallet->cs_wallet); wallet->SetAddressBookName(CBitcoinAddress(strAddress).Get(), strLabel); } return QString::fromStdString(strAddress); } bool AddressTableModel::removeRows(int row, int count, const QModelIndex &parent) { Q_UNUSED(parent); AddressTableEntry *rec = priv->index(row); if(count != 1 || !rec || rec->type == AddressTableEntry::Receiving) { // Can only remove one row at a time, and cannot remove rows not in model. // Also refuse to remove receiving addresses. return false; } { LOCK(wallet->cs_wallet); wallet->DelAddressBookName(CBitcoinAddress(rec->address.toStdString()).Get()); } return true; } /* Look up label for address in address book, if not found return empty string. */ QString AddressTableModel::labelForAddress(const QString &address) const { { LOCK(wallet->cs_wallet); CBitcoinAddress address_parsed(address.toStdString()); std::map<CTxDestination, std::string>::iterator mi = wallet->mapAddressBook.find(address_parsed.Get()); if (mi != wallet->mapAddressBook.end()) { return QString::fromStdString(mi->second); } } return QString(); } int AddressTableModel::lookupAddress(const QString &address) const { QModelIndexList lst = match(index(0, Address, QModelIndex()), Qt::EditRole, address, 1, Qt::MatchExactly); if(lst.isEmpty()) { return -1; } else { return lst.at(0).row(); } } void AddressTableModel::emitDataChanged(int idx) { emit dataChanged(index(idx, 0, QModelIndex()), index(idx, columns.length()-1, QModelIndex())); }
[ "32086588+asianwebcoin@users.noreply.github.com" ]
32086588+asianwebcoin@users.noreply.github.com
587be5cf1f43fcd8a56fd9695264c1e498a77cd8
042ed236ec05177714ceb502098c98ba3b99c7f8
/calculator/calculator/token.cpp
0e0216455b22028cad95390242f75060a0feccec
[]
no_license
vlargius/calculator
a9e1044f4433f23778ef216eda84f1508038e697
a0d8d32db3bbb35d14f48eb528f41f07abadc348
refs/heads/master
2020-03-24T21:25:30.395684
2018-11-20T19:32:45
2018-11-20T19:32:45
143,031,596
0
0
null
null
null
null
UTF-8
C++
false
false
2,150
cpp
#include <iostream> #include <string> #include "token.h" #include "exceptions.h" #include "service_char.h" using namespace std; Token::Token(char c) : type(c) {} Token::Token(double d) : type(number), value(d) {} Token::Token(char type, string name) : type(type), name(name) {} Token Tokenstream::get() { if (!is_free()) { Token t = buff.top(); buff.pop(); return t; } if (in->peek() == EOF) { set_default_stream(); } char ch; while (in->get(ch) && isspace(ch)) {} switch (ch) { case next_str: { return Token(print); } case print: case sep: case '=': case '+': case '-': case '*': case '/': case '%': case '!': case '(': case ')': case '{': case '}': case '<': case '>': case '&': case '|': case '^': case '~': { return Token(ch); } case '.': case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': { in->putback(ch); // return back digit of the number double val; *in >> val; return Token(val); } default: if (isalpha(ch)) { string s; s += ch; //get a full name of the variable while (in->get(ch) && (isalpha(ch) || isdigit(ch) || ch == '_')) { s += ch; } in->putback(ch); if (s == exitkey) { return Token(quit_prog); } if (s == helpkey) { return Token(helpcall); } if (s == fromkey) { return Token(fromcall); } if (s == tokey) { return Token(tocall); } if (s == declkey) { return Token(let); } if (s == constkey) { return Token(const_tok); } if (s == sqrtkey) { return Token(func_type, s); } if (s == powkey) { return Token(func_type, s); } if (s == sinkey) { return Token(func_type, s); } if (s == bshowkey) { return Token(proc_type, s); } return Token(variable, s); } if (ch == '#') { string s; s += ch; if (s == declkey) { return Token(let); } } throw BadToken(ch); } } //ignoring tokens until c void Tokenstream::ignore(char c) { while (!is_free()) { if (buff.top().type == c) { return; } buff.pop(); } char ch{ 0 }; while (in->get(ch) && ch != next_str) { if (ch == c) { return; } } } void Tokenstream::put_back(Token t) { buff.push(t); }
[ "vlargius@gmail.com" ]
vlargius@gmail.com
c0a63a5e9ceaf1c4e55541b7d1e4b62f1c34d6a6
a7764174fb0351ea666faa9f3b5dfe304390a011
/src/RWStepGeom/RWStepGeom_RWSurfaceCurveAndBoundedCurve.cxx
d4111491389abd8a3f5f9db9ead4702917a4655b
[]
no_license
uel-dataexchange/Opencascade_uel
f7123943e9d8124f4fa67579e3cd3f85cfe52d91
06ec93d238d3e3ea2881ff44ba8c21cf870435cd
refs/heads/master
2022-11-16T07:40:30.837854
2020-07-08T01:56:37
2020-07-08T01:56:37
276,290,778
0
0
null
null
null
null
UTF-8
C++
false
false
5,092
cxx
// File: RWStepGeom_RWSurfaceCurveAndBoundedCurve.cxx // Created: Mon Feb 15 10:53:18 1999 // Author: Andrey BETENEV // <abv@doomox.nnov.matra-dtv.fr> //S4132: reading complex type bounded_curve + surface_curve // which is necessary for reading curve_bounded_surfaces // This class is based on RWSurfaceCurve #include <RWStepGeom_RWSurfaceCurveAndBoundedCurve.ixx> #include <RWStepGeom_RWSurfaceCurve.ixx> #include <StepGeom_Curve.hxx> #include <StepGeom_BoundedCurve.hxx> #include <StepGeom_HArray1OfPcurveOrSurface.hxx> #include <StepGeom_PcurveOrSurface.hxx> #include <StepGeom_PreferredSurfaceCurveRepresentation.hxx> #include <Interface_EntityIterator.hxx> #include <StepGeom_SurfaceCurveAndBoundedCurve.hxx> #include <TCollection_AsciiString.hxx> // --- Enum : PreferredSurfaceCurveRepresentation --- static TCollection_AsciiString pscrPcurveS2(".PCURVE_S2."); static TCollection_AsciiString pscrPcurveS1(".PCURVE_S1."); static TCollection_AsciiString pscrCurve3d(".CURVE_3D."); RWStepGeom_RWSurfaceCurveAndBoundedCurve::RWStepGeom_RWSurfaceCurveAndBoundedCurve () {} void RWStepGeom_RWSurfaceCurveAndBoundedCurve::ReadStep (const Handle(StepData_StepReaderData)& data, const Standard_Integer num, Handle(Interface_Check)& ach, const Handle(StepGeom_SurfaceCurveAndBoundedCurve)& ent) const { // BOUNDED_CURVE: skip Standard_Integer num1 = num; // CURVE: skip num1 = data->NextForComplex (num1); // GEOMETRIC_REPRESENTATION_ITEM: skip num1 = data->NextForComplex (num1); // REPRESENTATION_ITEM: read name num1 = data->NextForComplex (num1); if ( ! data->CheckNbParams ( num1, 1, ach, "representation_item" ) ) return; Handle(TCollection_HAsciiString) aName; data->ReadString ( num1, 1, "name", ach, aName ); // SURFACE_CURVE: read data num1 = data->NextForComplex (num1); if ( ! data->CheckNbParams ( num1, 3, ach, "surface_curve" ) ) return; // --- own field : curve3d --- Handle(StepGeom_Curve) aCurve3d; data->ReadEntity ( num1, 1, "curve_3d", ach, STANDARD_TYPE(StepGeom_Curve), aCurve3d ); // --- own field : associatedGeometry --- Handle(StepGeom_HArray1OfPcurveOrSurface) aAssociatedGeometry; StepGeom_PcurveOrSurface aAssociatedGeometryItem; Standard_Integer nsub3; if ( data->ReadSubList ( num1, 2, "associated_geometry", ach, nsub3 ) ) { Standard_Integer nb3 = data->NbParams(nsub3); aAssociatedGeometry = new StepGeom_HArray1OfPcurveOrSurface (1, nb3); for (Standard_Integer i3 = 1; i3 <= nb3; i3 ++) { //szv#4:S4163:12Mar99 `Standard_Boolean stat3 =` not needed if (data->ReadEntity (nsub3,i3,"associated_geometry",ach,aAssociatedGeometryItem)) aAssociatedGeometry->SetValue(i3,aAssociatedGeometryItem); } } // --- own field : masterRepresentation --- StepGeom_PreferredSurfaceCurveRepresentation aMasterRepresentation = StepGeom_pscrCurve3d; if ( data->ParamType ( num1, 3 ) == Interface_ParamEnum ) { Standard_CString text = data->ParamCValue ( num1, 3 ); if (pscrPcurveS2.IsEqual(text)) aMasterRepresentation = StepGeom_pscrPcurveS2; else if (pscrPcurveS1.IsEqual(text)) aMasterRepresentation = StepGeom_pscrPcurveS1; else if ( pscrCurve3d.IsEqual(text)) aMasterRepresentation = StepGeom_pscrCurve3d; else ach->AddFail("Enumeration preferred_surface_curve_representation has not an allowed value"); } else ach->AddFail("Parameter #3 (master_representation) is not an enumeration"); //--- Initialisation of the read entity --- ent->Init(aName, aCurve3d, aAssociatedGeometry, aMasterRepresentation); ent->BoundedCurve() = new StepGeom_BoundedCurve; ent->BoundedCurve()->Init (aName); } void RWStepGeom_RWSurfaceCurveAndBoundedCurve::WriteStep (StepData_StepWriter& SW, const Handle(StepGeom_SurfaceCurveAndBoundedCurve)& ent) const { SW.StartEntity("BOUNDED_CURVE"); SW.StartEntity("CURVE"); SW.StartEntity("GEOMETRIC_REPRESENTATION_ITEM"); SW.StartEntity("REPRESENTATION_ITEM"); SW.Send(ent->Name()); // --- Instance of plex componant BoundedCurve --- SW.StartEntity("SURFACE_CURVE"); // --- own field : curve3d --- SW.Send(ent->Curve3d()); // --- own field : associatedGeometry --- SW.OpenSub(); for (Standard_Integer i3 = 1; i3 <= ent->NbAssociatedGeometry(); i3 ++) { if (!ent->AssociatedGeometryValue(i3).Value().IsNull()) { SW.Send(ent->AssociatedGeometryValue(i3).Value()); } } SW.CloseSub(); // --- own field : masterRepresentation --- switch(ent->MasterRepresentation()) { case StepGeom_pscrPcurveS2 : SW.SendEnum (pscrPcurveS2); break; case StepGeom_pscrPcurveS1 : SW.SendEnum (pscrPcurveS1); break; case StepGeom_pscrCurve3d : SW.SendEnum (pscrCurve3d); break; } } void RWStepGeom_RWSurfaceCurveAndBoundedCurve::Share(const Handle(StepGeom_SurfaceCurveAndBoundedCurve)& ent, Interface_EntityIterator& iter) const { RWStepGeom_RWSurfaceCurve tool; tool.Share ( ent, iter ); }
[ "shoka.sho2@excel.co.jp" ]
shoka.sho2@excel.co.jp
8e1cb671cc2aecaca903b0000be50b5da21c7edb
68e1b7d070ce1f12f4d84fcbd8370836b78d8ed2
/InputDeviceServer/Application.h
be49e359b736972501736eca1f1ee8b53b87bbcf
[]
no_license
iwatake2222/InputDeviceServer
ac75e6a082a36bc1f172d9c4b56e75f845bb0091
7b75a31e9679679fb95c63560b70785b5bae0a21
refs/heads/master
2021-06-01T01:04:22.545383
2016-04-10T15:23:09
2016-04-10T15:23:09
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,941
h
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ /* * File: Application.h * Author: takeshi * * Created on April 7, 2016, 2:17 AM */ #include <stdint.h> #include <pthread.h> #include "./DriverLcdST7735R/DriverLcdST7735R.h" #include "./DriverLcdST7735R/DriverLcdST7735RText.h" #include "./DriverOledSSD1306/DriverOledSSD1306.h" #include "./DriverOledSSD1306/DriverOledSSD1306Text.h" #include "./InputDevices/InputDevices.h" #ifndef APPLICATION_H #define APPLICATION_H class Application { /*** Config and interface ***/ private: const static uint32_t SLEEP_TIME_MS = 20; /*** Methods ***/ public: static Application* getInstance(); RET start(); RET stopRendezvous(); private: Application(); Application(const Application& orig); virtual ~Application(); static void* threadMainLoopWrapper(void* pParam); void* threadMainLoop(); void initDriverLcdST7735R(); void initDriverOledSSD1306(); void inputKeyCB (InputDevices::INPUT_STATUS *inputStatus); void inputRotaryCB (InputDevices::INPUT_STATUS *inputStatus); void inputTapCB (InputDevices::INPUT_STATUS *inputStatus); static void inputKeyCBWrapper (InputDevices::INPUT_STATUS *inputStatus); static void inputRotaryCBWrapper (InputDevices::INPUT_STATUS *inputStatus); static void inputTapCBWrapper (InputDevices::INPUT_STATUS *inputStatus); void printLcd(const char *str, uint32_t x, uint32_t y); /*** Attributes ***/ private: bool m_isExit; pthread_t m_tidMainLoop; pthread_mutex_t m_mutexPrint; DriverLcdST7735R* m_driverLcdST7735R; DriverLcdST7735RText* m_driverLcdST7735RText; DriverOledSSD1306* m_driverOledSSD1306; DriverOledSSD1306Text* m_driverOledSSD1306Text; }; #endif /* APPLICATION_H */ // Callback functions for Input
[ "take.iwiw2222@gmail.com" ]
take.iwiw2222@gmail.com
ac0b06ea67aa0851daa6bdf259f1c427dd1977d5
b167407960a3b69b16752590def1a62b297a4b0c
/scripting/js-bindings/spidermonkey/include/win32/mozilla/WindowsVersion.h
fcf24acc2e92c2e64de35ddc3da8669bc410d108
[ "MIT" ]
permissive
xcode1986/nineck.ca
543d1be2066e88a7db3745b483f61daedf5f378a
637dfec24407d220bb745beacebea4a375bfd78f
refs/heads/master
2020-04-15T14:48:08.551821
2019-01-15T07:36:06
2019-01-15T07:36:06
164,768,581
1
1
MIT
2019-01-15T08:30:27
2019-01-09T02:09:21
C++
UTF-8
C++
false
false
3,261
h
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* 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/. */ #ifndef mozilla_WindowsVersion_h #define mozilla_WindowsVersion_h #include "mozilla/Attributes.h" #include <stdint.h> #include <windows.h> namespace mozilla { inline bool IsWindowsVersionOrLater(uint32_t aVersion) { static uint32_t minVersion = 0; static uint32_t maxVersion = UINT32_MAX; if (minVersion >= aVersion) { return true; } if (aVersion >= maxVersion) { return false; } OSVERSIONINFOEX info; ZeroMemory(&info, sizeof(OSVERSIONINFOEX)); info.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX); info.dwMajorVersion = aVersion >> 24; info.dwMinorVersion = (aVersion >> 16) & 0xFF; info.wServicePackMajor = (aVersion >> 8) & 0xFF; info.wServicePackMinor = aVersion & 0xFF; DWORDLONG conditionMask = 0; VER_SET_CONDITION(conditionMask, VER_MAJORVERSION, VER_GREATER_EQUAL); VER_SET_CONDITION(conditionMask, VER_MINORVERSION, VER_GREATER_EQUAL); VER_SET_CONDITION(conditionMask, VER_SERVICEPACKMAJOR, VER_GREATER_EQUAL); VER_SET_CONDITION(conditionMask, VER_SERVICEPACKMINOR, VER_GREATER_EQUAL); if (VerifyVersionInfo(&info, VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR, conditionMask)) { minVersion = aVersion; return true; } maxVersion = aVersion; return false; } inline bool IsWindowsBuildOrLater(uint32_t aBuild) { static uint32_t minBuild = 0; static uint32_t maxBuild = UINT32_MAX; if (minBuild >= aBuild) { return true; } if (aBuild >= maxBuild) { return false; } OSVERSIONINFOEX info; ZeroMemory(&info, sizeof(OSVERSIONINFOEX)); info.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX); info.dwBuildNumber = aBuild; DWORDLONG conditionMask = 0; VER_SET_CONDITION(conditionMask, VER_BUILDNUMBER, VER_GREATER_EQUAL); if (VerifyVersionInfo(&info, VER_BUILDNUMBER, conditionMask)) { minBuild = aBuild; return true; } maxBuild = aBuild; return false; } MOZ_ALWAYS_INLINE bool IsXPSP3OrLater() { return IsWindowsVersionOrLater(0x05010300ul); } MOZ_ALWAYS_INLINE bool IsWin2003OrLater() { return IsWindowsVersionOrLater(0x05020000ul); } MOZ_ALWAYS_INLINE bool IsWin2003SP2OrLater() { return IsWindowsVersionOrLater(0x05020200ul); } MOZ_ALWAYS_INLINE bool IsVistaOrLater() { return IsWindowsVersionOrLater(0x06000000ul); } MOZ_ALWAYS_INLINE bool IsVistaSP1OrLater() { return IsWindowsVersionOrLater(0x06000100ul); } MOZ_ALWAYS_INLINE bool IsWin7OrLater() { return IsWindowsVersionOrLater(0x06010000ul); } MOZ_ALWAYS_INLINE bool IsWin7SP1OrLater() { return IsWindowsVersionOrLater(0x06010100ul); } MOZ_ALWAYS_INLINE bool IsWin8OrLater() { return IsWindowsVersionOrLater(0x06020000ul); } MOZ_ALWAYS_INLINE bool IsNotWin7PreRTM() { return IsWin7SP1OrLater() || !IsWin7OrLater() || IsWindowsBuildOrLater(7600); } } // namespace mozilla #endif /* mozilla_WindowsVersion_h */
[ "278688386@qq.com" ]
278688386@qq.com
bfa51eace2561a4dbf1206e9bab064b36b2601d9
7847bf00ed4b8462b0cc34186b2b1de1b9a592f2
/Hmwk/Assignment 5 HMWK/CustomerData.h
e07845057c47fd99dc412b67791767c19da04b59
[]
no_license
nickLehr/CardinalNick_CSC17a_43950
1743d2d9b1c87ac4c3d893eaf30001f335446c56
41961574ec9324979e52e3c6fcfdf2e46c0297da
refs/heads/master
2021-01-15T23:02:13.121454
2015-06-12T06:10:55
2015-06-12T06:10:55
32,040,008
0
0
null
null
null
null
UTF-8
C++
false
false
778
h
/* * File: CustomerData.h * Author: Owner * * Created on May 22, 2015, 7:03 PM */ #ifndef CUSTOMERDATA_H #define CUSTOMERDATA_H #include "PersonData.h" #include <iostream> using std::cout; using std::endl; class CustomerData : public PersonData{ private: int customerNumber; bool mailingList; public: void setCustNum(int n) {customerNumber = n;} void setML(bool m) { mailingList = m; if(m != 0 && m!=1){ cout << "You didn't do as told." << endl; cout << "Sorry but you have been added to the mailing list!"<<endl; } } int getCustNum(){return customerNumber;} bool getML(){return mailingList;} }; #endif /* CUSTOMERDATA_H */
[ "nickcardinal95@gmail.com" ]
nickcardinal95@gmail.com
3742d311a2e05e6c83ba2d26df13a51887d13885
e07c8b17d0ff1465539e522250d8cadf4253a854
/Source/HordeMode/Public/Components/HMCharacterMovementComponent.h
e5ae92ee7958cf9dbd7e41969d5252d4dd552b83
[ "MIT" ]
permissive
trdwll/HordeMode
e1fa1a68e1e732960a1e1f9e31af5a674c0ce9d2
6e5415eafbbcb28c7db00b0228164caad1518aa6
refs/heads/master
2022-12-26T00:02:34.794069
2020-09-22T04:14:53
2020-09-22T04:14:53
245,854,351
1
2
null
null
null
null
UTF-8
C++
false
false
455
h
// Copyright (c) 2020 Russ 'trdwll' Treadwell #pragma once #include "CoreMinimal.h" #include "GameFramework/CharacterMovementComponent.h" #include "HMCharacterMovementComponent.generated.h" /** * */ UCLASS() class HORDEMODE_API UHMCharacterMovementComponent : public UCharacterMovementComponent { GENERATED_BODY() public: UHMCharacterMovementComponent(const FObjectInitializer& ObjectInitializer); virtual float GetMaxSpeed() const override; };
[ "git@trdwll.com" ]
git@trdwll.com
96c5cdaa75fd7cfc661fd6b686f9eee549bad683
9bdd58cc75b495e67ec6c186802c81121199c064
/amsr-vector-fs-libvac/lib/include/vac/iterators/range.h
3fd480bf41fac9a133f1c9c6db8176940b9a9189
[]
no_license
flankersky/vector_ap_bsw
3bac290b569dd2f72d4d4971fcb8f96b8e188914
b8f667356126a4f76a79109b02ee14ae1cd16a58
refs/heads/master
2022-01-14T03:38:29.499494
2019-07-04T04:15:02
2019-07-04T04:15:02
null
0
0
null
null
null
null
UTF-8
C++
false
false
10,560
h
/********************************************************************************************************************** * COPYRIGHT * ------------------------------------------------------------------------------------------------------------------- * \verbatim * Copyright (c) 2018 by VeInformatik GmbH. All rights reserved. * * This software is copyright protected and proprietary to VeInformatik GmbH. * VeInformatik GmbH grants to you only those rights as set out in the license conditions. * All other rights remain with VeInformatik GmbH. * \endverbatim * ------------------------------------------------------------------------------------------------------------------- * FILE DESCRIPTION * -----------------------------------------------------------------------------------------------------------------*/ /** \file range.h * \brief Contains a Range iterator * * \details This class can replace most simple for loops by using the range in combination * with the range-based for loop and represents a half closed interval of integers. * *********************************************************************************************************************/ #ifndef LIB_INCLUDE_VAC_ITERATORS_RANGE_H_ #define LIB_INCLUDE_VAC_ITERATORS_RANGE_H_ /********************************************************************************************************************** * INCLUDES *********************************************************************************************************************/ #include <cstddef> #include <iostream> #include <iterator> #include <limits> #include <stdexcept> namespace vac { namespace iterators { /** * \brief Calculate end ONCE and pass the calculated value to the iterator * \details If the step is only +1, then skip it and take the last element -1. * Else remove the remainder of the last step from the last element * \param begin is the start value of the range * \param end is the exclusive end value of the range. * \param step is the step size for each iteration. * \returns the calculated end that will be hit via a iteration * \pre step must not be equal to zero */ template <typename I> inline auto calculate_end(I begin, I end, I step) -> I { if (end == begin) { // Empty range return begin; } if (step == 0) { throw std::invalid_argument("Step size must not be 0!"); } if (step == 1) { // Optimization: Standard use case: step_ is 1 if (end < begin) { // Empty range return begin; } else { // Nonempty range return end; } } else if (step > 1) { if (end < begin) { // Empty range return begin; } else { I const distance = I(end - begin); // Get the last step width I const remainder = I(distance % step); if (remainder != 0) { // The new end that will be hit by a step return I(end - remainder + step); } else { return end; } } } else { // Step is smaller than 0 if (end > begin) { // Empty range return begin; } else { I const distance = I(begin - end); // Get the last step width I const remainder = I(distance % step); if (remainder == 0) { return end; } else { // The new end that will be hit by a step return I(end + remainder + step); } } } } /** * \brief Creates a range iterator with [start, end) with an optional step * \details start will be included in the range, end will not * * A range object like Pythons - can be configured with an optional step * Example: for (auto n : range(1,10)) { cout << n; } */ template <typename I = std::size_t> class Range final { /** * \brief Start value for the iterator */ I const begin_; /** * \brief Step size for the iterator */ I const step_; /** * \brief Given end value for the iterator */ I const end_; /** * \brief Real end value for the iterator */ I const real_end_; static_assert(std::numeric_limits<I>::is_integer, "Type I needs to be a integer"); public: /** * \brief Constructor from initial value, end value and step size. * \details The range * \param begin The initial value * \param end The end value. Defaults to the maximum of that type * \param step The step size. Defaults to 1. */ Range(I begin, I end, I step) : begin_{begin}, step_{step}, end_{end}, real_end_{calculate_end(begin, end, step)} {} /** * \brief Internal class providing the c++ iterator interface * * Provides everything for a normal forward iterator, so it can be used in algorithms & range-based for */ class iterator final { /** * \brief The real Range object */ Range const range_; /** * \brief the value of the current iteration */ I current_; auto step_val() const & -> I { return range_.step_; } public: /** * \brief Self type as defined in iterator interface */ using self_type = iterator; /** * \brief Value Type as defined in iterator interface */ using value_type = I; /** * \brief Difference type as defined in iterator interface */ using difference_type = I; /** * \brief Pointer type as defined in iterator interface */ using pointer = value_type *; /** * \brief Const pointer type as defined in iterator interface */ using const_pointer = value_type const *; /** * \brief Reference type as defined in iterator interface */ using reference = value_type &; /** * \brief Const reference type as defined in iterator interface */ using const_reference = value_type const &; /** * \brief Iterator category as defined in iterator interface * Enables only forward iteration */ using iterator_category = std::forward_iterator_tag; /** * \brief Default (& empty) constructor as defined in iterator interface * * Required for: Forward Iterator */ iterator() : range_{0, 0, 1}, current_{0} {} /** * \brief Copy constructor as defined in iterator interface * \param it Original iterator to copy from * * Required for: Iterator */ iterator(iterator const &it) = default; /** * \brief Copy assignment as defined in iterator interface * \param it Original iterator to copy from * \returns the copied iterator * * Required for: Iterator */ auto operator=(iterator const &it) -> self_type & = default; /** * \brief Default Destructor as defined in iterator interface * * Required for: Iterator */ ~iterator() = default; /** * \brief Constructor from Range object (const ref) * \param r Range object which contains all constant information * \param b the start value for this iterator */ iterator(Range const &r, I b) : range_{r}, current_{b} {} /** * \brief Constructor from Range object (move) * \param r Range object which contains all constant information * \param b the start value for this iterator */ iterator(Range &&r, I b) : range_{r}, current_{b} {} /** * \brief Dereferences the iterator to its value * \returns the value of the current iteration by reference * * Required for: Input/Output Iterator */ auto operator*() -> reference { return current_; } /** * \brief Dereferences the iterator to its value * \returns the value of the current iteration by value * * Required for: Forward Iterator */ auto operator*() const -> value_type { return current_; } /** * \brief Dereferences the iterator to a pointer to its value * \returns the value of the current iteration as pointer to const * * Required for: Forward Iterator */ auto operator-> () const -> const_pointer { return &current_; } /** * \brief Sets the iterator to its next iteration step * \returns a reference to the iterator * * Required for: Iterator */ auto operator++() -> self_type & { current_ = value_type(current_ + step_val()); return *this; } /** * \brief Sets the iterator to its next iteration step * \returns a reference to the iterator * * Required for: Iterator */ auto operator++(int) -> self_type { self_type temp{*this}; ++(*this); return temp; } /** * \brief Compares two range iterators for equality * \param other the other iterator which to compare * \returns true if both are the same * * Required for: Input/Output Iterator */ auto operator==(self_type const &other) const -> bool { return this->current_ == other.current_; } /** * \brief Compares two range iterators for inequality * \param other the other iterator which to compare * \returns false if both are the same * * Required for: Input/Output Iterator */ auto operator!=(self_type const &other) const -> bool { return !(*this == other); } }; /** * \brief Create iterator from start * \returns an range iterator object */ auto begin() -> iterator { return iterator{*this, begin_}; } /** * \brief Create iterator from end * \returns an range iterator object */ auto end() -> iterator { return iterator{*this, real_end_}; } }; /** * \brief Creates a Range of integers which can be used as iterator * \param end_ is the exclusive end value of the range. * \returns a Range of integers that starts with 0 and stepsize 1 */ template <typename I> inline auto range(I end_ = std::numeric_limits<I>::max()) -> Range<I> { static_assert(std::numeric_limits<I>::is_integer, "Type I needs to be an integer"); return Range<I>{0, end_, 1}; } /** * \brief Creates a Range of integers which can be used as iterator * \param begin_ is the start value of the range * \param end_ is the exclusive end value of the range. * \param step_ is the step size for each iteration. Can be set to any integer except 0. Defaults to 1. * \returns a Range of integers */ template <typename I> inline auto range(I begin_, I end_, I step_ = 1) -> Range<I> { static_assert(std::numeric_limits<I>::is_integer, "Type I needs to be an integer"); return Range<I>{begin_, end_, step_}; } } // namespace iterators } // namespace vac #endif // LIB_INCLUDE_VAC_ITERATORS_RANGE_H_
[ "catfish416@126.com" ]
catfish416@126.com
14679fc7c8ecff1082d061ba3c3f9b85ea019a35
25598276f2826550a303a2a8303a058d92f54982
/Week 2/AI/BaseUnit.h
da102714e5003ddf8042ab18a2b08db3d56581dc
[]
no_license
stefkee94/AI
dde85959adf9124df60309b1565b9b491f04a59a
1f341fd6f66db7b2a05b3229fd5930537bb2fcbf
refs/heads/master
2016-09-06T19:04:03.769156
2015-01-05T19:49:55
2015-01-05T19:49:55
26,532,807
0
0
null
null
null
null
UTF-8
C++
false
false
571
h
#pragma once #include <memory> #include <qstring.h> #include "EnumState.h" #include "BehaviorState.h" class Vertex; class Graph; class Cow; class Hare; class BaseUnit { public: virtual void Move(std::shared_ptr<Graph> graph) = 0; void ChangeState(EnumState state); virtual EnumState GetState() = 0; virtual QString GetImageLink() = 0; virtual void SetVertex(std::shared_ptr<Vertex> p_vertex) = 0; virtual std::shared_ptr<Vertex> GetVertex() = 0; protected: BehaviorState* behavior; EnumState currentState; std::shared_ptr<Vertex> vertex; QString img_link; };
[ "stefan10pas@hotmail.com" ]
stefan10pas@hotmail.com
afe8a4e55649b96904634850568d91034594750f
4ee685aab189f3f87583c74d27e9e0b894c00538
/Dependencies/Flann/include/flann/util/result_set.h
cc5c12d2fbe4327d1465fa1cadc1649aec304054
[ "MIT" ]
permissive
dddExperiments/OpenSynther
85c0be4aeed8102fe61dd32c8aad8db632f721aa
6ef31dcba8d1ed00d97f63cd365d551ed6646c1a
refs/heads/master
2021-01-22T07:06:33.184197
2011-05-05T15:44:03
2011-05-05T15:44:03
1,700,380
8
4
null
null
null
null
UTF-8
C++
false
false
4,933
h
/*********************************************************************** * Software License Agreement (BSD License) * * Copyright 2008-2009 Marius Muja (mariusm@cs.ubc.ca). All rights reserved. * Copyright 2008-2009 David G. Lowe (lowe@cs.ubc.ca). All rights reserved. * * THE BSD LICENSE * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *************************************************************************/ #ifndef RESULTSET_H #define RESULTSET_H #include <algorithm> #include <limits> #include <vector> namespace flann { /* This record represents a branch point when finding neighbors in the tree. It contains a record of the minimum distance to the query point, as well as the node at which the search resumes. */ template <typename T, typename DistanceType> struct BranchStruct { T node; /* Tree node at which search resumes */ DistanceType mindist; /* Minimum distance to query for all nodes below. */ BranchStruct() {} BranchStruct(const T& aNode, DistanceType dist) : node(aNode), mindist(dist) {} bool operator<(const BranchStruct<T, DistanceType>& rhs) { return mindist<rhs.mindist; } }; template <typename DistanceType> class ResultSet { public: virtual ~ResultSet() {} virtual bool full() const = 0; virtual void addPoint(DistanceType dist, int index) = 0; virtual DistanceType worstDist() const = 0; }; template <typename DistanceType> class KNNResultSet : public ResultSet<DistanceType> { int* indices; DistanceType* dists; int capacity; int count; public: KNNResultSet(int capacity_) : capacity(capacity_), count(0) { } void init(int* indices_, DistanceType* dists_) { indices = indices_; dists = dists_; count = 0; dists[capacity-1] = (std::numeric_limits<DistanceType>::max)(); } size_t size() const { return count; } bool full() const { return count == capacity; } void addPoint(DistanceType dist, int index) { int i; for (i=count; i>0; --i) { #ifdef FLANN_FIRST_MATCH if ( (dists[i-1]>dist) || ((dist==dists[i-1])&&(indices[i-1]>index)) ) { #else if (dists[i-1]>dist) { #endif if (i<capacity) { dists[i] = dists[i-1]; indices[i] = indices[i-1]; } } else break; } if (i<capacity) { dists[i] = dist; indices[i] = index; } if (count<capacity) count++; } DistanceType worstDist() const { return dists[capacity-1]; } }; /** * A result-set class used when performing a radius based search. */ template <typename DistanceType> class RadiusResultSet : public ResultSet<DistanceType> { DistanceType radius; int* indices; DistanceType* dists; size_t capacity; size_t count; public: RadiusResultSet(DistanceType radius_, int* indices_, DistanceType* dists_, int capacity_) : radius(radius_), indices(indices_), dists(dists_), capacity(capacity_) { init(); } ~RadiusResultSet() { } void init() { count = 0; } size_t size() const { return count; } bool full() const { return true; } void addPoint(DistanceType dist, int index) { if (dist<radius) { if ((capacity>0)&&(count < capacity)) { dists[count] = dist; indices[count] = index; } count++; } } DistanceType worstDist() const { return radius; } }; } #endif //RESULTSET_H
[ "astre.henri@visual-experiments.com" ]
astre.henri@visual-experiments.com
8a2ebe5fdcc9c1c66aa6c54c748e62af69cb146d
c30d20ffd5522d4fe3e9fca3fb30e19931ab9e97
/Versionen/2021_06_15/RMF/rmf_ws/install/rmf_fleet_msgs/include/rmf_fleet_msgs/msg/detail/dock_parameter__type_support.cpp
a330439d4e4a57a7ffa47d00f552fd48b8fc3291
[ "MIT" ]
permissive
flitzmo-hso/flitzmo_agv_control_system
557f1200c0f060264e4d6ea688e104cabd9d0568
99e8006920c03afbd93e4c7d38b4efff514c7069
refs/heads/main
2023-06-19T08:18:30.282776
2021-07-09T18:05:09
2021-07-09T18:05:09
358,238,668
0
2
null
null
null
null
UTF-8
C++
false
false
5,795
cpp
// generated from rosidl_typesupport_introspection_cpp/resource/idl__type_support.cpp.em // with input from rmf_fleet_msgs:msg/DockParameter.idl // generated code does not contain a copyright notice #include "array" #include "cstddef" #include "string" #include "vector" #include "rosidl_runtime_c/message_type_support_struct.h" #include "rosidl_typesupport_cpp/message_type_support.hpp" #include "rosidl_typesupport_interface/macros.h" #include "rmf_fleet_msgs/msg/detail/dock_parameter__struct.hpp" #include "rosidl_typesupport_introspection_cpp/field_types.hpp" #include "rosidl_typesupport_introspection_cpp/identifier.hpp" #include "rosidl_typesupport_introspection_cpp/message_introspection.hpp" #include "rosidl_typesupport_introspection_cpp/message_type_support_decl.hpp" #include "rosidl_typesupport_introspection_cpp/visibility_control.h" namespace rmf_fleet_msgs { namespace msg { namespace rosidl_typesupport_introspection_cpp { void DockParameter_init_function( void * message_memory, rosidl_runtime_cpp::MessageInitialization _init) { new (message_memory) rmf_fleet_msgs::msg::DockParameter(_init); } void DockParameter_fini_function(void * message_memory) { auto typed_message = static_cast<rmf_fleet_msgs::msg::DockParameter *>(message_memory); typed_message->~DockParameter(); } size_t size_function__DockParameter__path(const void * untyped_member) { const auto * member = reinterpret_cast<const std::vector<rmf_fleet_msgs::msg::Location> *>(untyped_member); return member->size(); } const void * get_const_function__DockParameter__path(const void * untyped_member, size_t index) { const auto & member = *reinterpret_cast<const std::vector<rmf_fleet_msgs::msg::Location> *>(untyped_member); return &member[index]; } void * get_function__DockParameter__path(void * untyped_member, size_t index) { auto & member = *reinterpret_cast<std::vector<rmf_fleet_msgs::msg::Location> *>(untyped_member); return &member[index]; } void resize_function__DockParameter__path(void * untyped_member, size_t size) { auto * member = reinterpret_cast<std::vector<rmf_fleet_msgs::msg::Location> *>(untyped_member); member->resize(size); } static const ::rosidl_typesupport_introspection_cpp::MessageMember DockParameter_message_member_array[3] = { { "start", // name ::rosidl_typesupport_introspection_cpp::ROS_TYPE_STRING, // type 0, // upper bound of string nullptr, // members of sub message false, // is array 0, // array size false, // is upper bound offsetof(rmf_fleet_msgs::msg::DockParameter, start), // bytes offset in struct nullptr, // default value nullptr, // size() function pointer nullptr, // get_const(index) function pointer nullptr, // get(index) function pointer nullptr // resize(index) function pointer }, { "finish", // name ::rosidl_typesupport_introspection_cpp::ROS_TYPE_STRING, // type 0, // upper bound of string nullptr, // members of sub message false, // is array 0, // array size false, // is upper bound offsetof(rmf_fleet_msgs::msg::DockParameter, finish), // bytes offset in struct nullptr, // default value nullptr, // size() function pointer nullptr, // get_const(index) function pointer nullptr, // get(index) function pointer nullptr // resize(index) function pointer }, { "path", // name ::rosidl_typesupport_introspection_cpp::ROS_TYPE_MESSAGE, // type 0, // upper bound of string ::rosidl_typesupport_introspection_cpp::get_message_type_support_handle<rmf_fleet_msgs::msg::Location>(), // members of sub message true, // is array 0, // array size false, // is upper bound offsetof(rmf_fleet_msgs::msg::DockParameter, path), // bytes offset in struct nullptr, // default value size_function__DockParameter__path, // size() function pointer get_const_function__DockParameter__path, // get_const(index) function pointer get_function__DockParameter__path, // get(index) function pointer resize_function__DockParameter__path // resize(index) function pointer } }; static const ::rosidl_typesupport_introspection_cpp::MessageMembers DockParameter_message_members = { "rmf_fleet_msgs::msg", // message namespace "DockParameter", // message name 3, // number of fields sizeof(rmf_fleet_msgs::msg::DockParameter), DockParameter_message_member_array, // message members DockParameter_init_function, // function to initialize message memory (memory has to be allocated) DockParameter_fini_function // function to terminate message instance (will not free memory) }; static const rosidl_message_type_support_t DockParameter_message_type_support_handle = { ::rosidl_typesupport_introspection_cpp::typesupport_identifier, &DockParameter_message_members, get_message_typesupport_handle_function, }; } // namespace rosidl_typesupport_introspection_cpp } // namespace msg } // namespace rmf_fleet_msgs namespace rosidl_typesupport_introspection_cpp { template<> ROSIDL_TYPESUPPORT_INTROSPECTION_CPP_PUBLIC const rosidl_message_type_support_t * get_message_type_support_handle<rmf_fleet_msgs::msg::DockParameter>() { return &::rmf_fleet_msgs::msg::rosidl_typesupport_introspection_cpp::DockParameter_message_type_support_handle; } } // namespace rosidl_typesupport_introspection_cpp #ifdef __cplusplus extern "C" { #endif ROSIDL_TYPESUPPORT_INTROSPECTION_CPP_PUBLIC const rosidl_message_type_support_t * ROSIDL_TYPESUPPORT_INTERFACE__MESSAGE_SYMBOL_NAME(rosidl_typesupport_introspection_cpp, rmf_fleet_msgs, msg, DockParameter)() { return &::rmf_fleet_msgs::msg::rosidl_typesupport_introspection_cpp::DockParameter_message_type_support_handle; } #ifdef __cplusplus } #endif
[ "msauer1@hs-offenburg.de" ]
msauer1@hs-offenburg.de
0e8a6a929c3d3844738dbb870b5977541c2c20a0
eb8ad721287a65eb9d01c05316993b4ee7ce1bf8
/ADI/diffusion2d_AVX_mt.cpp
9711ce5638974477dcb843adca816bfdb2ebf28b
[]
no_license
bepierre/diffusion-solver
628963037cf33728f00071c48e805ee62e976d05
b35216e376fdfa4ccb047d58ab869f7dc465d85d
refs/heads/master
2020-03-07T10:17:16.959696
2018-03-30T12:51:20
2018-03-30T12:51:20
127,427,865
0
0
null
null
null
null
UTF-8
C++
false
false
11,564
cpp
#include <iostream> #include <algorithm> #include <string.h> #include <fstream> #include <cassert> #include <vector> #include <cmath> #include <x86intrin.h> #include "inc/timer.hpp" typedef double value_type; typedef std::size_t size_type; #ifndef M_PI #define M_PI (3.1415926535897) #endif class Diffusion2D { public: Diffusion2D(const value_type D, const value_type L, const size_type N, const value_type dt, const value_type tmax) : D_(D), L_(L), N_(N), Ntot_(N_ * N_), dt_(dt), tmax_(tmax) { /// real space grid spacing dr_ = L_ / (N_ - 1); /// stencil factor fac_ = dt_ * D_ / (dr_ * dr_); rho_.resize(Ntot_, 0.); rho_tmp.resize(Ntot_, 0.); //Thomas algorithm paramters initialize_thomas(); //initialize density initialize_density(); } void run() { value_type time = 0; std::vector<value_type> d_p_; d_p_.resize(4*(N_-3),0.); #pragma omp parallel firstprivate(d_p_) { while (time < tmax_) { #pragma omp single { std::swap(rho_tmp, rho_); } // First half-step // 4 at a time so that the compiler can vectorize #pragma omp for nowait for (size_type i = 1; i < N_-4; i+=4) { // First elements d_p_[0] = (rho_tmp[i*N_+1]+0.5*fac_*(-2*rho_tmp[i*N_+1]+rho_tmp[i*N_+2]))/b_; d_p_[1] = (rho_tmp[(i+1)*N_+1]+0.5*fac_*(-2*rho_tmp[(i+1)*N_+1]+rho_tmp[(i+1)*N_+2]))/b_; d_p_[2] = (rho_tmp[(i+2)*N_+1]+0.5*fac_*(-2*rho_tmp[(i+2)*N_+1]+rho_tmp[(i+2)*N_+2]))/b_; d_p_[3] = (rho_tmp[(i+3)*N_+1]+0.5*fac_*(-2*rho_tmp[(i+3)*N_+1]+rho_tmp[(i+3)*N_+2]))/b_; // Other elements for (size_type j = 1; j < N_-3; ++j) { d_p_[4*j] = ( rho_tmp[i*N_ + 1 + j] + 0.5*fac_*(rho_tmp[i*N_ + j]-2*rho_tmp[i*N_ + 1 + j]+rho_tmp[i*N_ + 2 + j]) - a_*d_p_[4*(j-1)]) * denom_[j-1]; d_p_[4*j+1] = ( rho_tmp[(i+1)*N_ + 1 + j] + 0.5*fac_*(rho_tmp[(i+1)*N_ + j]-2*rho_tmp[(i+1)*N_ + 1 + j]+rho_tmp[(i+1)*N_ + 2 + j]) - a_*d_p_[4*(j-1)+1]) * denom_[j-1]; d_p_[4*j+2] = ( rho_tmp[(i+2)*N_ + 1 + j] + 0.5*fac_*(rho_tmp[(i+2)*N_ + j]-2*rho_tmp[(i+2)*N_ + 1 + j]+rho_tmp[(i+2)*N_ + 2 + j]) - a_*d_p_[4*(j-1)+2]) * denom_[j-1]; d_p_[4*j+3] = ( rho_tmp[(i+3)*N_ + 1 + j] + 0.5*fac_*(rho_tmp[(i+3)*N_ + j]-2*rho_tmp[(i+3)*N_ + 1 + j]+rho_tmp[(i+3)*N_ + 2 + j]) - a_*d_p_[4*(j-1)+3]) * denom_[j-1]; } // Last element rho_[i*N_+(N_-2)] = (rho_tmp[i*N_ + 1 + N_-3] + 0.5*fac_*(rho_tmp[i*N_ + N_-3]-2*rho_tmp[i*N_ + 1 + N_-3]) - a_*d_p_[4*(N_-3)-4]) * denom_[N_-5]; rho_[(i+1)*N_+(N_-2)] = (rho_tmp[(i+1)*N_ + 1 + N_-3] + 0.5*fac_*(rho_tmp[(i+1)*N_ + N_-3]-2*rho_tmp[(i+1)*N_ + 1 + N_-3]) - a_*d_p_[4*(N_-3)-3]) * denom_[N_-5]; rho_[(i+2)*N_+(N_-2)] = (rho_tmp[(i+2)*N_ + 1 + N_-3] + 0.5*fac_*(rho_tmp[(i+2)*N_ + N_-3]-2*rho_tmp[(i+2)*N_ + 1 + N_-3]) - a_*d_p_[4*(N_-3)-2]) * denom_[N_-5]; rho_[(i+3)*N_+(N_-2)] = (rho_tmp[(i+3)*N_ + 1 + N_-3] + 0.5*fac_*(rho_tmp[(i+3)*N_ + N_-3]-2*rho_tmp[(i+3)*N_ + 1 + N_-3]) - a_*d_p_[4*(N_-3)-1]) * denom_[N_-5]; // Backsubstitution //std::cout << i << std::endl; for (size_type j = N_ - 3; j > 0; --j) { rho_[i*N_ + j] = d_p_[4*(j-1)] - c_p_[j-1] * rho_[i*N_+(j+1)]; rho_[(i+1)*N_ + j] = d_p_[4*(j-1)+1] - c_p_[j-1] * rho_[(i+1)*N_+(j+1)]; rho_[(i+2)*N_ + j] = d_p_[4*(j-1)+2] - c_p_[j-1] * rho_[(i+2)*N_+(j+1)]; rho_[(i+3)*N_ + j] = d_p_[4*(j-1)+3] - c_p_[j-1] * rho_[(i+3)*N_+(j+1)]; } } // Extra lines #pragma omp single for (size_type i = N_-1 - (N_-1)%4; i < N_-1; ++i) { // First elements d_p_[0] = (rho_tmp[i*N_+1]+0.5*fac_*(-2*rho_tmp[i*N_+1]+rho_tmp[i*N_+2]))/b_; // Other elements for (size_type j = 1; j < N_-3; ++j) { c_p_[j] = c_ / (b_ - a_ * c_p_[j-1]); d_p_[j] = ( rho_tmp[i*N_ + 1 + j] + 0.5*fac_*(rho_tmp[i*N_ + j]-2*rho_tmp[i*N_ + 1 + j]+rho_tmp[i*N_ + 2 + j]) - a_*d_p_[j-1]) * denom_[j-1]; } // Last element rho_[i*N_+(N_-2)] = (rho_tmp[i*N_ + 1 + N_-3] + 0.5*fac_*(rho_tmp[i*N_ + N_-3]-2*rho_tmp[i*N_ + 1 + N_-3]) - a_*d_p_[N_-4]) * denom_[N_-5]; // Backsubstitution for (size_type j = N_ - 3; j > 0; --j) { rho_[i*N_ + j] = d_p_[j-1] - c_p_[j-1] * rho_[i*N_+(j+1)]; } } // Second half-step // 4 at a time so that the compiler can vectorize //AVX vectors for thomas algorithm __m256d factor_1 = _mm256_set1_pd((1-fac_)/b_); __m256d factor_2 = _mm256_set1_pd(0.5*fac_/b_); __m256d factor_3 = _mm256_set1_pd(1-fac_); __m256d factor_4 = _mm256_set1_pd(0.5*fac_); __m256d factor_m_a = _mm256_set1_pd(-a_); #pragma omp single { std::swap(rho_tmp, rho_); } #pragma omp for nowait for(size_type j = 1; j < N_-4; j+=4) { // avx loading __m256d current = _mm256_loadu_pd(rho_tmp.data() + N_+j); __m256d under = _mm256_loadu_pd(rho_tmp.data() + 2*N_+j); __m256d above; __m256d after; __m256d denom; __m256d c_p_vec; // First elements __m256d d_p_tmp = _mm256_fmadd_pd (factor_1, current, _mm256_mul_pd(factor_2, under)); _mm256_storeu_pd(d_p_.data(), d_p_tmp); // Other elements for (size_type i = 1; i < N_-3; ++i) { // avx loading current = _mm256_loadu_pd(rho_tmp.data() + (i+1)*N_+j); under = _mm256_loadu_pd(rho_tmp.data() + (i+2)*N_+j); above = _mm256_loadu_pd(rho_tmp.data() + (i )*N_+j); denom = _mm256_set1_pd(denom_[i-1]); d_p_tmp = _mm256_mul_pd(_mm256_fmadd_pd(factor_m_a, d_p_tmp, _mm256_fmadd_pd(factor_4, _mm256_add_pd(under, above), _mm256_mul_pd(factor_3, current))), denom); _mm256_storeu_pd(d_p_.data()+4*i, d_p_tmp); } // Last element // AVX loading current = _mm256_loadu_pd(rho_tmp.data() + (N_-2)*N_+j); above = _mm256_loadu_pd(rho_tmp.data() + (N_-3)*N_+j); denom = _mm256_set1_pd(denom_[N_-5]); _mm256_storeu_pd(rho_.data() + (N_-2)*N_+j,_mm256_mul_pd(_mm256_fmadd_pd(factor_m_a, d_p_tmp, _mm256_fmadd_pd(factor_4,above, _mm256_mul_pd(factor_3, current))), denom)); // Backsubstitution for (size_type i = N_-3; i > 0; --i) { c_p_vec = _mm256_set1_pd(-c_p_[i-1]); after = _mm256_loadu_pd(rho_.data()+(i+1)*N_+j); d_p_tmp = _mm256_loadu_pd(d_p_.data()+4*(i-1)); _mm256_storeu_pd(rho_.data()+i*N_+j, _mm256_fmadd_pd(c_p_vec,after,d_p_tmp)); } } // Extra columns #pragma omp single nowait for (size_type j = N_-1 -(N_-1)%4; j < N_-1; ++j) { // First elements d_p_[0] = (rho_tmp[N_+j]+0.5*fac_*(-2*rho_tmp[N_+j]+rho_tmp[2*N_+j]))/b_; // Other elements for (size_type i = 1; i < N_-3; ++i) { c_p_[i] = c_ / (b_ - a_ * c_p_[i-1]); d_p_[i] = (rho_tmp[(i+1)*N_+j] + 0.5*fac_*(rho_tmp[i*N_+j]-2*rho_tmp[(i+1)*N_+j]+rho_tmp[(i+2)*N_+j])-a_*d_p_[i-1]) * denom_[i-1]; } // Last element rho_[(N_-2)*N_ + j] = (rho_tmp[(N_-2)*N_ + j] + 0.5*fac_*(rho_tmp[(N_-3)*N_+j]-2*rho_tmp[(N_-2)*N_+j])-a_*d_p_[N_-4]) * denom_[N_-5]; // Backsubstitution for (size_type i = N_-3; i > 0; --i) { rho_[i*N_+j] = d_p_[i-1] - c_p_[i-1] * rho_[(i+1)*N_+j]; } } #pragma omp single { time +=dt_; } } } } void write_density(std::string const &filename) const { std::ofstream out_file(filename, std::ios::out); for (size_type i = 0; i < N_; ++i) { for (size_type j = 0; j < N_; ++j) out_file << (i * dr_ - L_ / 2.) << '\t' << (j * dr_ - L_ / 2.) << '\t' << rho_[i * N_ + j] << "\n"; out_file << "\n"; } out_file.close(); } double exact_rho(size_type i, size_type j, double t) { return sin(M_PI*i*dr_)*sin(M_PI*j*dr_)*exp(-2*D_*M_PI*M_PI*t); } std::vector<value_type> get_rho() { return rho_; } private: void initialize_density() { /// initialize rho(x,y,t=0) for (size_type i = 1; i < N_-1; ++i) { for (size_type j = 1; j < N_-1; ++j) { rho_[i * N_ + j] = sin(M_PI * i * dr_) * sin(M_PI * j * dr_); } } } void initialize_thomas() { a_ = c_ = -0.5*fac_; b_ = 1 + fac_; c_p_.resize((N_-3), 0.); //d_p_.resize(4*(N_-3), 0.); denom_.resize((N_-4), 0.); c_p_[0] = c_/b_; for (size_type i = 1; i < N_-3; ++i) { denom_[i-1] = 1 / (b_ - a_ * c_p_[i-1]); c_p_[i] = c_ * denom_[i-1]; } } value_type D_, L_; size_type N_, Ntot_; value_type dr_, dt_, fac_, a_, b_, c_, tmax_; std::vector <value_type> rho_, rho_tmp, c_p_, denom_; }; double compute_error(Diffusion2D system, size_type N, double T) { std::vector<value_type> rho_h = system.get_rho(); double rms = 0; for (value_type i = 0; i < N; ++i) { for (value_type j = 0; j < N; ++j) { rms += pow((rho_h[i*N+j] - system.exact_rho(i,j,T)),2); } } return sqrt(rms/(N*N)); } int main(int argc, char *argv[]) { if (argc < 7) { std::cerr << "Usage: " << argv[0] << "option D L dt T N" << std::endl; return 1; } else if (strcmp(argv[1],"-d")==0) { const value_type D = std::stod(argv[2]); const value_type L = std::stod(argv[3]); const value_type dt = std::stod(argv[4]); const value_type tmax = std::stod(argv[5]); const size_type N = std::stoul(argv[6]); Diffusion2D system(D, L, N, dt, tmax); system.write_density("data/density_000_N" + std::to_string(N) + "_dt" + std::to_string(dt) + ".dat"); timer t; t.start(); system.run(); t.stop(); std::cout << "Timing : " << N << " " << 1 << " " << t.get_timing() << std::endl; system.write_density("data/density_AVX_mt_N" + std::to_string(N) + "_dt" + std::to_string(dt) + ".dat"); } else if (strcmp(argv[1],"-c")==0) { // Convergence study const value_type D = std::stod(argv[2]); const value_type L = std::stod(argv[3]); const value_type dt = std::stod(argv[4]); const value_type tmax = std::stod(argv[5]); size_type Nmin = std::stoul(argv[6]); size_type Nmax = std::stoul(argv[7]); std::ofstream out_file("data/conv_AVX_mt_" + std::to_string(Nmin) + "_" + std::to_string(Nmax) + ".dat", std::ios::out); for (size_type i = Nmin; i <= Nmax; ++i) { const size_type N = pow(2, i); Diffusion2D system(D, L, N, dt, tmax); system.run(); double rms_error = compute_error(system, N, tmax); out_file << N << '\t' << rms_error << "\n"; } out_file.close(); } return 0; }
[ "pierrebeckmann@gmail.com" ]
pierrebeckmann@gmail.com
e5fa026c64a1d7401515da4b87984b68e4cedc61
c68f791005359cfec81af712aae0276c70b512b0
/0-unclassified/users.cpp
7119f6eb36a13aaf40f76261861c6e03551c3185
[]
no_license
luqmanarifin/cp
83b3435ba2fdd7e4a9db33ab47c409adb088eb90
08c2d6b6dd8c4eb80278ec34dc64fd4db5878f9f
refs/heads/master
2022-10-16T14:30:09.683632
2022-10-08T20:35:42
2022-10-08T20:35:42
51,346,488
106
46
null
2017-04-16T11:06:18
2016-02-09T04:26:58
C++
UTF-8
C++
false
false
1,265
cpp
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 5; int dp[N][2], k; vector<int> edge[N]; void dfs(int now) { dp[now][0] = dp[now][1] = 1; vector<pair<int, int>> live, dead; for(auto it : edge[now]) { dfs(it); live.emplace_back(dp[it][1], it); dead.emplace_back(dp[it][0], it); } sort(live.begin(), live.end()); sort(dead.begin(), dead.end()); reverse(live.begin(), live.end()); reverse(dead.begin(), dead.end()); for(int i = 0; i < live.size() && i < k - 1; i++) { dp[now][1] += live[i].first; } set<int> good; int cur = 0, lst = -1; for(int i = 0; i < live.size() && i < k; i++) { good.insert(live[i].second); cur += live[i].first; lst = live[i].first; } int maxi = cur; for(int i = 0; i < dead.size(); i++) { int at = dead[i].second; if(good.count(at)) { maxi = max(maxi, cur - dp[at][1] + dp[at][0]); } else { maxi = max(maxi, cur - lst + dp[at][0]); } } dp[now][0] += maxi; } int main() { int n; scanf("%d %d", &n, &k); for(int i = 1; i <= n; i++) { int m; scanf("%d", &m); while(m--) { int c; scanf("%d", &c); edge[i].push_back(c); } } dfs(1); printf("%d\n", max(dp[1][0], dp[1][1])); return 0; }
[ "l.arifin.siswanto@gmail.com" ]
l.arifin.siswanto@gmail.com
d8654025cca3c0d4da6c42944d978238ef070f00
72e915468eea207ed0125b87f28186e54b10bd92
/UserDev/DisplayTool/TruthViewer/DrawMCTruth.cxx
cab10f7971a96233cd582f42024213d33880e954
[]
no_license
hgreenlee/larlite
37834d3105d21e4a475776763e349c15faa2d644
a7e88ac08d89ffe195651e251037d9e1bfe64b2e
refs/heads/trunk
2020-12-30T14:46:48.894003
2019-09-24T22:01:49
2019-09-24T22:01:49
91,092,510
0
0
null
2017-05-12T13:07:06
2017-05-12T13:07:06
null
UTF-8
C++
false
false
3,226
cxx
#ifndef LARLITE_DRAWDrawMCTRUTH_CXX #define LARLITE_DRAWDrawMCTRUTH_CXX #include "DrawMCTruth.h" namespace evd { bool DrawMCTruth::initialize() { // // This function is called in the beggining of event loop // Do all variable initialization you wish to do here. // If you have a histogram to fill in the event loop, for example, // here is a good place to create one on the heap (i.e. "new TH1D"). // return true; } bool DrawMCTruth::analyze(larlite::storage_manager* storage) { // // Do your event-by-event analysis here. This function is called for // each event in the loop. You have "storage" pointer which contains // event-wise data. To see what is available, check the "Manual.pdf": // // http://microboone-docdb.fnal.gov:8080/cgi-bin/ShowDocument?docid=3183 // // Or you can refer to Base/DataFormatConstants.hh for available data type // enum values. Here is one example of getting PMT waveform collection. // // event_fifo* my_pmtfifo_v = (event_fifo*)(storage->get_data(DATA::PMFIFO)); // // if( event_fifo ) // // std::cout << "Event ID: " << my_pmtfifo_v->event_id() << std::endl; // // For now, only taking one mcinfo per event. So build it and quit: _this_info = MCInfoSummary(); // Get the Drawmctruth info: auto ev_mctruth = storage -> get_data<larlite::event_mctruth>(_producer); if (ev_mctruth -> size() == 0) return false; auto _mctruth = ev_mctruth -> front(); _this_info._vertex = _mctruth.GetNeutrino().Lepton().Trajectory().front().Position().Vect(); // std::cout << "Neutrino trajectory is :\n" ; // for (auto & point : _mctruth.GetNeutrino().Nu().Trajectory() ) { // std::cout << " ( " << point.X() // << ", " << point.Y() // << ", " << point.Z() // << ")\n"; // } // std::cout << "Vertex is ( " << _this_info.vertex().X() // << ", " << _this_info.vertex().Y() // << ", " << _this_info.vertex().Z() // << ")\n"; // Fill out the MCInfoSummary object _this_info._isCC = _mctruth.GetNeutrino().CCNC(); _this_info._incoming_lepton_pdg = _mctruth.GetNeutrino().Nu().PdgCode(); _this_info._outgoing_lepton_pdg = _mctruth.GetNeutrino().Lepton().PdgCode(); _this_info._target_pdg = _mctruth.GetNeutrino().Target(); _this_info._outgoing_pdg_list.reserve(_mctruth.GetParticles().size()); for (auto & part : _mctruth.GetParticles() ) { _this_info._outgoing_pdg_list.push_back(part.PdgCode()); } return true; } bool DrawMCTruth::finalize() { // This function is called at the end of event loop. // Do all variable finalization you wish to do here. // If you need, you can store your ROOT class instance in the output // file. You have an access to the output file through "_fout" pointer. // // Say you made a histogram pointer h1 to store. You can do this: // // if(_fout) { _fout->cd(); h1->Write(); } // // else // print(MSG::ERROR,__FUNCTION__,"Did not find an output file pointer!!! File not opened?"); // return true; } } #endif
[ "corey.adams@yale.edu" ]
corey.adams@yale.edu
61dc88e742ce67548220e3dd59b7776bc0524bcc
37596f223cf5115178a5a218fecf422bc545de78
/hashing.cpp
857133ad8d361dcbe7c7ec2d586c8282f986e424
[]
no_license
fahim-ahmed-7861/competitive-programming
85cc4a61ce643d07446c36848b1f55789ee978f3
7c3e649756a426cceb588b5b119d40a5a94c80b4
refs/heads/master
2022-12-31T10:45:15.798645
2020-10-21T14:37:38
2020-10-21T14:37:38
306,051,853
0
0
null
null
null
null
UTF-8
C++
false
false
1,609
cpp
#include<bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<ll,int>pp; #define sf(a) scanf("%d",&a) #define pf(a) printf("%d\n",a) #define mp make_pair #define pb push_back #define p pop_back #define ischar(x) (('a' <= x && x <= 'z') || ('A' <= x && x <= 'Z')) #define fastread() (ios_base:: sync_with_stdio(false),cin.tie(NULL)); #define mod 1000000007; #define MAX 100000 int failure[MAX]; void failure_func(string pattern,int m) { ll i,j; failure[0]=0; failure[1]=0; for(i=2; i<=m; i++) { j=failure[i-1]; while(true) { if(pattern[j]==pattern[i-1]) { failure[i]=j+1; break; } if(j==0) { failure[i]=0; break; } j=failure[j]; } } } bool kmp(string text, string pattern) { int n,m,i=0,j=0; n=text.size(); m=pattern.size(); failure_func(pattern,m); while(true) { if(j==n) return false; if(text[j]==pattern[i]) { i++; j++; if(i==m) { cout<<j-m<<endl; return true; } } else { if(i==0) { j++; } else i=failure[i]; } } return false; } int main() { string t,p; cin>>t; p=t; reverse(p.begin(),p.end()); cout<<kmp(t,p)<<endl; cout<<failure[p.size()]<<endl; }
[ "fahimahmedshojib109@gmail.com" ]
fahimahmedshojib109@gmail.com
cb48ee802be1c601e8e3eb7185fb3ec7ed768716
6923f79f1eaaba0ab28b25337ba6cb56be97d32d
/GPU-Gems-Book-Source-Code/GPU-Gems-3-CD-Content/content/20/demo/lobepainter.cpp
a232bdc203005955e74c2fd3e8db733fcd64e540
[]
no_license
burakbayramli/books
9fe7ba0cabf06e113eb125d62fe16d4946f4a4f0
5e9a0e03aa7ddf5e5ddf89943ccc68d94b539e95
refs/heads/master
2023-08-17T05:31:08.885134
2023-08-14T10:05:37
2023-08-14T10:05:37
72,460,321
223
174
null
2022-10-24T12:15:06
2016-10-31T17:24:00
Jupyter Notebook
UTF-8
C++
false
false
7,934
cpp
// // lobepainter.cpp // Last Updated: 05.01.07 // // Mark Colbert & Jaroslav Krivanek // colbert@cs.ucf.edu // // Copyright (c) 2007. // // The following code is freely distributed "as is" and comes with // no guarantees or required support by the authors. Any use of // the code for commercial purposes requires explicit written consent // by the authors. // #include <GL/glew.h> #include "lobepainter.h" #include "brdfgraph.h" extern CGprofile FragmentProfile, VertexProfile; extern CGcontext context; extern GLuint glMeshId[3]; extern int currMesh; /// Simple function from nVidia for checking the FBO status void CheckFramebufferStatus() { GLenum status; status = (GLenum) glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT); switch(status) { case GL_FRAMEBUFFER_COMPLETE_EXT: break; case GL_FRAMEBUFFER_UNSUPPORTED_EXT: printf("Unsupported framebuffer format\n"); break; case GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT: printf("Framebuffer incomplete, missing attachment\n"); break; case GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT: printf("Framebuffer incomplete, attached images must have same dimensions\n"); break; case GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT: printf("Framebuffer incomplete, attached images must have same format\n"); break; case GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT: printf("Framebuffer incomplete, missing draw buffer\n"); break; case GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT: printf("Framebuffer incomplete, missing read buffer\n"); break; default: exit(-1); } } LobePainter::LobePainter(BRDFGraph *_brdfGraph, int _offsetX, int y, int displayWidth, int _resWidth) : Container(_offsetX, y, displayWidth, displayWidth), brdfGraph(_brdfGraph), offsetX(_offsetX), resWidth(_resWidth), cxy("c_xy", 30, -1.f, -1.05f, 1.05f, 5, 15, displayWidth-10, 10), cz("c_z", 30, 1.f, 0.f, 1.f, 5, 30, displayWidth-10, 10), n("n", 30, 1.2f, 1.f, 3.2f, 5, 45, displayWidth-10, 10), weight("weight", 30, 0.5f, 0.1f, 1.0f, 5, 60, displayWidth-10, 10), diffuse("diffuse", 30, 0.5f, 0.f, 1.f, 5, 75, displayWidth-10, 10), size("size", 30, 0.1f, 0.f, 0.5f, 5, 90, displayWidth-10, 10) { controls = new WidgetGroup("Lobe Painter", offsetX, y+displayWidth+5, displayWidth, 105, WidgetGroup::RIGHT); controls->AddWidget(&cxy); controls->AddWidget(&cz); controls->AddWidget(&n); controls->AddWidget(&weight); controls->AddWidget(&diffuse); controls->AddWidget(&size); controls->Compile(); InitCg(); InitQuad(); InitFramebuffers(); size.SetValue(1.f); Paint(0.5f,0.5f); size.SetValue(0.1f); } LobePainter::~LobePainter() { delete controls; glDeleteFramebuffersEXT(2, fb); glDeleteTextures(2, fbTex); cgDestroyProgram(paintProg); cgDestroyProgram(displayProg); cgDestroyProgram(uvProg); } void LobePainter::Display() { glPushAttrib(GL_VIEWPORT_BIT); glViewport(d.x,fy,d.w,d.h); // display the texture glMatrixMode(GL_PROJECTION); glPushMatrix(); glLoadIdentity(); gluOrtho2D(0,resWidth,resWidth, 0); glMatrixMode(GL_MODELVIEW); glPushMatrix(); glLoadIdentity(); glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D, fbTex[currTex]); cgGLBindProgram(displayProg); cgGLEnableProfile(FragmentProfile); glCallList(quadId); cgGLDisableProfile(FragmentProfile); glDisable(GL_TEXTURE_2D); // display the mesh glLineWidth(1.f); glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); cgGLBindProgram(uvProg); cgGLEnableProfile(VertexProfile); glCallList(glMeshId[currMesh]); cgGLDisableProfile(VertexProfile); glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); glPopAttrib(); glPopMatrix(); glMatrixMode(GL_PROJECTION); glPopMatrix(); glMatrixMode(GL_MODELVIEW); // display the controls controls->Display(); } void LobePainter::updateGraph() { float exp = powf(10,n.GetValue()); float scale = powf(weight.GetValue(), 1.f/exp); brdfGraph->setLobe(scale*cxy.GetValue(), scale*cz.GetValue(), exp, 1.f); brdfGraph->setDiffuse(diffuse.GetValue()); } bool LobePainter::Click(int button, int state, int x, int y) { if (state == GLUT_DOWN) { if (Contains(x,y)) { float rx = ((float) x-d.x)/((float) d.w); float ry = ((float) y-d.y)/((float) d.h); Paint(rx,ry); return true; } else if (controls->Click(button,state,x,y)) { updateGraph(); return true; } } return false; } bool LobePainter::Motion(int x, int y) { if (Contains(x,y)) { float rx = ((float) x-d.x)/((float) d.w); float ry = ((float) y-d.y)/((float) d.h); Paint(rx,ry); return true; } else if (controls->Motion(x,y)) { updateGraph(); return true; } return false; } void LobePainter::Paint(float x, float y) { glPushAttrib(GL_VIEWPORT_BIT); // set up the framebuffer glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fb[!currTex]); glViewport(0,0,256,256); glDisable(GL_BLEND); glClear(GL_COLOR_BUFFER_BIT); // set up the matrix glMatrixMode(GL_PROJECTION); glPushMatrix(); glLoadIdentity(); gluOrtho2D(0,resWidth, 0.f, resWidth); glMatrixMode(GL_MODELVIEW); glPushMatrix(); glLoadIdentity(); cgGLBindProgram(paintProg); cgGLEnableProfile(FragmentProfile); // set up the painting parameters cgGLSetParameter3f(posParam, x,y,1.f/(0.5f*(size.GetValue()*size.GetValue()))); float exp = powf(10,n.GetValue()); float scale = powf(weight.GetValue(), 1.f/exp); cgGLSetParameter4f(lobeParam, scale*cxy.GetValue(), scale*cz.GetValue(), exp, diffuse.GetValue()); glEnable(GL_TEXTURE_2D); // bind the previous rendered texture glBindTexture(GL_TEXTURE_2D, fbTex[currTex]); glCallList(quadId); glDisable(GL_TEXTURE_2D); cgGLDisableProfile(FragmentProfile); glPopMatrix(); glMatrixMode(GL_PROJECTION); glPopMatrix(); glMatrixMode(GL_MODELVIEW); glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); glPopAttrib(); glEnable(GL_BLEND); // swap which buffer we read from currTex = !currTex; } void LobePainter::InitFramebuffers() { glGenFramebuffersEXT(2, fb); glGenTextures(2, fbTex); for (int i=0; i < 2; i++) { // create the GPU memory glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fb[i]); { // create texture glBindTexture(GL_TEXTURE_2D, fbTex[i]); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA16F_ARB, resWidth, resWidth, 0, GL_RGBA, GL_FLOAT, NULL); 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); // attach the color channel to the frame buffer glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, fbTex[i], 0); } // check for problems CheckFramebufferStatus(); } glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); glClearColor(0,0,0,0); } void LobePainter::InitQuad() { quadId = glGenLists(1); glNewList(quadId, GL_COMPILE); glBegin(GL_QUADS); glTexCoord2f(0.f,0.f); glVertex2i(0,0); glTexCoord2f(0.f,1.f); glVertex2i(0,resWidth); glTexCoord2f(1.f,1.f); glVertex2i(resWidth,resWidth); glTexCoord2f(1.f,0.f); glVertex2i(resWidth,0); glEnd(); glEndList(); } void LobePainter::InitCg() { displayProg = cgCreateProgramFromFile(context, CG_SOURCE, "lobepaint.cg", FragmentProfile, "FalseColorDisplay", NULL); cgGLLoadProgram(displayProg); paintProg = cgCreateProgramFromFile(context, CG_SOURCE, "lobepaint.cg", FragmentProfile, "Paint", NULL); cgGLLoadProgram(paintProg); lobeParam = cgGetNamedParameter(paintProg, "lobe"); posParam = cgGetNamedParameter(paintProg, "pos"); uvProg = cgCreateProgramFromFile(context, CG_SOURCE, "lobepaint.cg", VertexProfile, "UVDisplay", NULL); cgGLLoadProgram(uvProg); }
[ "me@yomama.com" ]
me@yomama.com
68e880490b3206c652b19ae338d43802bbac41ee
d859f41509a55cdc773fa14925069240006153a2
/src/main.cpp
1233a63c10342e82d5f82c3e3e1feca9dcab1b08
[]
no_license
yagiken0525/prismFootPrint
1936d8bdf25b61fdbd324e80d7a58e9d8b895ac2
2c9c5ae3f26a4def3b0f53baf994160981eb299b
refs/heads/master
2020-04-04T19:21:27.721208
2019-02-04T09:42:04
2019-02-04T09:42:04
156,202,624
0
0
null
null
null
null
UTF-8
C++
false
false
7,507
cpp
#include <iostream> #include "FootPrint.h" #include "videoToImage/trimVideo.h" using namespace std; using namespace cv; int main() { FootPrint footPrint("AH"); footPrint.VIDEO_TYPE = ".mp4"; // 動画拡張子 footPrint.FOOTSIZE = 26; //足のサイズ(cm) footPrint.USE_WEBCAM = false; // webカメラ使うか footPrint.USE_HOMOGRAPHY = true; // webカメラ使うか footPrint.RESULT_SCALE = 0.3; // 接地判定のための投票数しきい値 footPrint.IMAGE_HEIGHT = 320; footPrint.IMAGE_WIDTH = 640; // footPrint.RESULT_SCALE = 0.2; // 接地判定のための投票数しきい値 footPrint.SHOW_IMAGE_PATH = "../Data/Images/shows/"; footPrint.STEP_THRESHOLD = 5; // 接地判定のための投票数しきい値 footPrint.VOTE_RANGE = 5; // 近接何ピクセルまで投票するか(px) footPrint.MIN_STRIDE = 30; // 一歩とカウントする際の最小歩幅(cm) footPrint.VISUALIZE_FRAMES = 50; // 近傍何フレーム分の接地点を表示するか footPrint.CAMERA_NUM = 1; // 接地カメラ個数 footPrint.CAMERA_FIRST_ID = 12; // 接地カメラの最小ID footPrint.FINISH_FRAME = 600; //何フレームまで実行するか footPrint.VIDEO_FPS = 30; // 動画fps footPrint.SELECT_TRACKER_BY_CLICKING = false; // tracking対象を手動で指定するか footPrint.SHOW_TRACKING_RESULT = false; // tracking結果を表示するか // footPrint.CHECKER_BOARD_CALIBRATION = true; // チェッカーボードでキャリブレーション行うか footPrint.PLANE_WIDTH = 150; // 点群領域1辺の1/2 // footPrint.AREA_W = 1.5; // 点群領域1辺の1/2 // footPrint.AREA_H = 1.5; // 点群領域1辺の1/2 footPrint.POINT_DIST = 10; // 点群の領域分割幅(mm) footPrint.SHOW_TRAJECTORY = true; // trajectory表示 footPrint.TARGET_AREA_WIDTH = 1.3; // 可視化領域の横幅(m) footPrint.TARGET_AREA_HEIGHT = 1.3; // 可視化領域の縦幅(px) footPrint.RESULT_IMAGE_WIDTH = 300; // 俯瞰マップの横幅(px) footPrint.RESULT_IMAGE_HEIGHT = 300; // 俯瞰マップの縦幅(m) footPrint.SHOW_TRAJECTORY = true; // trajectory表示 footPrint.TRACKING_MAX_PROB = false; // trajectory表示 footPrint.TRACKING_CLICKED = true; // trajectory表示 // footPrint.PLOT_ON_WARPED_IMAGE = true; // 床画像に足あと投影 footPrint.ESTIMATE_RT = false; // Rt求めるか // footPrint.SHOW_REPROJECT_RESULT = false; // 点群の再投影結果を表示するか footPrint.SHOW_REPROJECT_RESULT = true; // 点群の再投影結果を表示するか footPrint.RIGHT_FOOT_COLOR = cv::Vec3b(0,0,255); footPrint.LEFT_FOOT_COLOR = cv::Vec3b(255,0,0); cv::Mat3f plane = footPrint.generatePointCloudsAsMatrix(footPrint.PLANE_WIDTH, footPrint.POINT_DIST); //床平面の点群生成 footPrint.loadFootImages(); // videoToImage::trimVideo(footPrint._project_name, // footPrint._projects_path, // footPrint._projects_path, // footPrint._projects_path, // footPrint.VIDEO_TYPE); if(footPrint.USE_WEBCAM) { footPrint.trajectoryMap = cv::Mat::ones(footPrint.PLANE_WIDTH * 2, footPrint.PLANE_WIDTH * 2, CV_8UC3); footPrint.stepMap = cv::Mat::ones(footPrint.PLANE_WIDTH * 2, footPrint.PLANE_WIDTH * 2, CV_8UC3); footPrint.HeatMap = cv::Mat::ones(footPrint.PLANE_WIDTH * 2, footPrint.PLANE_WIDTH * 2, CV_8UC3); footPrint.HeatVoteMap = cv::Mat::zeros(footPrint.PLANE_WIDTH * 2, footPrint.PLANE_WIDTH * 2, CV_32F); footPrint.estimateStepWithWebCam(); }else if(footPrint.USE_HOMOGRAPHY){ footPrint.estimateStepUsingHomography(); }else { footPrint.estimateStepWithMultipleCameras(); } return 0; } //3次元復元 // footPrint.loadAllImages(); // footPrint.reconstruct3Dpose(); // }else if(command == "ESTIMATE_STEP_POINTS"){ // } if(1){ // footPrint.right_vote.resize(footPrint.model.vertices_num); // footPrint.left_vote.resize(footPrint.model.vertices_num); // footPrint.loadImages(footPrint._sfm_projects_path + "imagelist.txt"); // footPrint.loadCameraParam(footPrint._data_path + "camera_param.txt"); // footPrint.loadMultipleCameraRts(footPrint._sfm_projects_path + "camerapose.txt"); // footPrint.loadOpenPoseData(footPrint._sfm_projects_path + "human_pose_info.txt"); // footPrint.votedFrameInit(); // // footPrint.trackTargetPerson(); // footPrint.findFootPrint(); // footPrint.paintFootPrint(); // footPrint.printVoteRecord(); // // }else if(command == "EXTRACT_STEP_AREA") { // // //色ついた部分の抽出 // footPrint.color = cv::Scalar(0, 0, 255); // footPrint.model.readModelWithColor(footPrint._projects_path + "result/result_mesh.ply", footPrint.color); // footPrint.savePointClouds(); // footPrint.calculateSteppedFrame(0); // footPrint.savePlytoTxt(0); // footPrint.model.vertices.clear(); // // footPrint.color = cv::Scalar(0, 255, 0); // footPrint.model.readModelWithColor(footPrint._projects_path + "result/result_mesh.ply", footPrint.color); // footPrint.savePointClouds(); // footPrint.calculateSteppedFrame(1); // footPrint.savePlytoTxt(1); // } // cv::VideoCapture cap(0);//デバイスのオープン // //cap.open(0);//こっちでも良い. // // if(!cap.isOpened())//カメラデバイスが正常にオープンしたか確認. // { // //読み込みに失敗したときの処理 // return -1; // } // // while(1)//無限ループ // { // cv::Mat frame; // cap >> frame; // get a new frame from camera // // // // //取得したフレーム画像に対して,クレースケール変換や2値化などの処理を書き込む. // // // // cv::imshow("window", frame);//画像を表示. // // int key = cv::waitKey(1); // if(key == 113)//qボタンが押されたとき // { // break;//whileループから抜ける. // } // else if(key == 115)//sが押されたとき // { // //フレーム画像を保存する. // cv::imwrite("img.png", frame); // } // } // cv::destroyAllWindows(); // return 0; // // カメラパラメータ(3x3の3次元座標を2次元画像平面へ投影するための行列) // double k_elms[] = { 9.803769e+02, 0.000000e+00, 6.900000e+02, 0.000000e+00, 9.757217e+02, 2.441228e+02, 0.000000e+00, 0.000000e+00, 1.000000e+00 }; // Matx33d K(k_elms); // // // カメラウィジェット作成(青) // viz::WCameraPosition wcamera(K, 1.0, viz::Color::blue()); // // // 画面にカメラ追加 // myWindow.showWidget("Camera", wcamera); // // カメラの姿勢を設定 // Mat T = Mat::eye(4, 4, CV_32FC1); // T.at<float>(2, 3) = -2.0; // Z座標の設定 // myWindow.setWidgetPose("Camera", cv::Affine3f(T)); // footPrint.generatePlaneModel(); // for(int i = 0; i < plane.cols; i++){ // for(int j = 0; j < plane.rows; j++){ // cout << plane(cv::Point(j,i)) << endl; // } // } //plyファイルの読み込み // footPrint.model.readModel(footPrint._projects_path + "planePoints.ply"); //plyファイルをブロックに分割
[ "yagi@hvrl.ics.keio.ac.jp" ]
yagi@hvrl.ics.keio.ac.jp
3eb1a91043a1ced0b9b14c35ddc56134abcbf9b6
29be7c52e05d32a4b02e6c0a1a6424abb2f60d57
/fuse-qreader/Example/build/Android/Preview/app/src/main/include/Uno.Time.LocalDateTime.h
27963931a326417f841b57cce612312aefd0a90e
[ "MIT" ]
permissive
redtree0/CITOS-APP
3b8cbc86fd88f6adb5b480035788eac08290c7a6
624f69770d8573dffc174f1f9540c22f19c71f14
refs/heads/master
2020-03-29T05:42:49.041569
2018-09-25T14:24:55
2018-09-25T14:24:55
149,594,359
0
0
null
2018-09-20T10:47:57
2018-09-20T10:47:57
null
UTF-8
C++
false
false
5,946
h
// This file was generated based on C:/Users/채재윤융합IT학부/AppData/Local/Fusetools/Packages/UnoCore/1.9.0/Source/Uno/Time/LocalDateTime.uno. // WARNING: Changes might be lost if you edit this file directly. #pragma once #include <Uno.Object.h> #include <Uno.Time.Instant.h> namespace g{namespace Uno{namespace Time{struct CalendarSystem;}}} namespace g{namespace Uno{namespace Time{struct LocalDateTime;}}} namespace g{ namespace Uno{ namespace Time{ // public struct LocalDateTime :6 // { uStructType* LocalDateTime_typeof(); void LocalDateTime__ctor_1_fn(LocalDateTime* __this, int32_t* year, int32_t* month, int32_t* day, int32_t* hour, int32_t* minute, int32_t* second); void LocalDateTime__ctor_2_fn(LocalDateTime* __this, int32_t* year, int32_t* month, int32_t* day, int32_t* hour, int32_t* minute, int32_t* second, int32_t* millisecond); void LocalDateTime__ctor_4_fn(LocalDateTime* __this, int32_t* year, int32_t* month, int32_t* day, int32_t* hour, int32_t* minute, int32_t* second, int32_t* millisecond, int32_t* tickWithinMillisecond, ::g::Uno::Time::CalendarSystem* calendar); void LocalDateTime__ctor_6_fn(LocalDateTime* __this, int32_t* year, int32_t* month, int32_t* day, int32_t* hour, int32_t* minute, int32_t* second, ::g::Uno::Time::CalendarSystem* calendar); void LocalDateTime__ctor_7_fn(LocalDateTime* __this, int32_t* year, int32_t* month, int32_t* day, int32_t* hour, int32_t* minute, ::g::Uno::Time::CalendarSystem* calendar); void LocalDateTime__ctor_8_fn(LocalDateTime* __this, ::g::Uno::Time::Instant* instant); void LocalDateTime__ctor_9_fn(LocalDateTime* __this, ::g::Uno::Time::Instant* instant, ::g::Uno::Time::CalendarSystem* calendar); void LocalDateTime__get_Calendar_fn(LocalDateTime* __this, ::g::Uno::Time::CalendarSystem** __retval); void LocalDateTime__get_Day_fn(LocalDateTime* __this, int32_t* __retval); void LocalDateTime__Equals_fn(LocalDateTime* __this, uType* __type, uObject* obj, bool* __retval); void LocalDateTime__Equals2_fn(LocalDateTime* __this, LocalDateTime* other, bool* __retval); void LocalDateTime__GetHashCode_fn(LocalDateTime* __this, uType* __type, int32_t* __retval); void LocalDateTime__get_Hour_fn(LocalDateTime* __this, int32_t* __retval); void LocalDateTime__get_Instant_fn(LocalDateTime* __this, ::g::Uno::Time::Instant* __retval); void LocalDateTime__get_Millisecond_fn(LocalDateTime* __this, int32_t* __retval); void LocalDateTime__get_Minute_fn(LocalDateTime* __this, int32_t* __retval); void LocalDateTime__get_Month_fn(LocalDateTime* __this, int32_t* __retval); void LocalDateTime__New2_fn(int32_t* year, int32_t* month, int32_t* day, int32_t* hour, int32_t* minute, int32_t* second, LocalDateTime* __retval); void LocalDateTime__New3_fn(int32_t* year, int32_t* month, int32_t* day, int32_t* hour, int32_t* minute, int32_t* second, int32_t* millisecond, LocalDateTime* __retval); void LocalDateTime__New8_fn(int32_t* year, int32_t* month, int32_t* day, int32_t* hour, int32_t* minute, ::g::Uno::Time::CalendarSystem* calendar, LocalDateTime* __retval); void LocalDateTime__New9_fn(::g::Uno::Time::Instant* instant, LocalDateTime* __retval); void LocalDateTime__New10_fn(::g::Uno::Time::Instant* instant, ::g::Uno::Time::CalendarSystem* calendar, LocalDateTime* __retval); void LocalDateTime__op_Equality_fn(LocalDateTime* left, LocalDateTime* right, bool* __retval); void LocalDateTime__get_Second_fn(LocalDateTime* __this, int32_t* __retval); void LocalDateTime__ToString_fn(LocalDateTime* __this, uType* __type, uString** __retval); void LocalDateTime__get_Year_fn(LocalDateTime* __this, int32_t* __retval); struct LocalDateTime { uStrong< ::g::Uno::Time::CalendarSystem*> _calendar; ::g::Uno::Time::Instant _instant; void ctor_1(int32_t year, int32_t month, int32_t day, int32_t hour, int32_t minute, int32_t second); void ctor_2(int32_t year, int32_t month, int32_t day, int32_t hour, int32_t minute, int32_t second, int32_t millisecond); void ctor_4(int32_t year, int32_t month, int32_t day, int32_t hour, int32_t minute, int32_t second, int32_t millisecond, int32_t tickWithinMillisecond, ::g::Uno::Time::CalendarSystem* calendar); void ctor_6(int32_t year, int32_t month, int32_t day, int32_t hour, int32_t minute, int32_t second, ::g::Uno::Time::CalendarSystem* calendar); void ctor_7(int32_t year, int32_t month, int32_t day, int32_t hour, int32_t minute, ::g::Uno::Time::CalendarSystem* calendar); void ctor_8(::g::Uno::Time::Instant instant); void ctor_9(::g::Uno::Time::Instant instant, ::g::Uno::Time::CalendarSystem* calendar); ::g::Uno::Time::CalendarSystem* Calendar(); int32_t Day(); bool Equals(uType* __type, uObject* obj) { bool __retval; return LocalDateTime__Equals_fn(this, __type, obj, &__retval), __retval; } bool Equals2(LocalDateTime other); int32_t GetHashCode(uType* __type) { int32_t __retval; return LocalDateTime__GetHashCode_fn(this, __type, &__retval), __retval; } int32_t Hour(); ::g::Uno::Time::Instant Instant(); int32_t Millisecond(); int32_t Minute(); int32_t Month(); int32_t Second(); uString* ToString(uType* __type) { uString* __retval; return LocalDateTime__ToString_fn(this, __type, &__retval), __retval; } int32_t Year(); }; LocalDateTime LocalDateTime__New2(int32_t year, int32_t month, int32_t day, int32_t hour, int32_t minute, int32_t second); LocalDateTime LocalDateTime__New3(int32_t year, int32_t month, int32_t day, int32_t hour, int32_t minute, int32_t second, int32_t millisecond); LocalDateTime LocalDateTime__New8(int32_t year, int32_t month, int32_t day, int32_t hour, int32_t minute, ::g::Uno::Time::CalendarSystem* calendar); LocalDateTime LocalDateTime__New9(::g::Uno::Time::Instant instant); LocalDateTime LocalDateTime__New10(::g::Uno::Time::Instant instant, ::g::Uno::Time::CalendarSystem* calendar); bool LocalDateTime__op_Equality(LocalDateTime left, LocalDateTime right); // } }}} // ::g::Uno::Time
[ "moter74@naver.com" ]
moter74@naver.com
3fc01e91688a76ffcb95f438f519de16be7aebdc
efc52aabcde1e37f7f3206e9bc85cfff5c8a8780
/src/nodes/NRung.hpp
f0dda63b0509e0743a5f7fea8b61bf289f9694eb
[]
no_license
00mjk/hashigo
0e3174751a3db7074617f7d4bcc0968be8a7d6b5
9f8bcb61c979a52b6c6dd0bd73fc85b61b2e44d1
refs/heads/master
2023-05-10T00:55:40.941150
2018-02-24T19:33:13
2018-02-24T19:33:13
null
0
0
null
null
null
null
UTF-8
C++
false
false
9,702
hpp
#ifndef NRUNG_HPP_ #define NRUNG_HPP_ #include "Node.hpp" #include "NBlock.hpp" #include "NBlockish.hpp" #include "NSequence.hpp" #include "NSegment.hpp" #include "NParallel.hpp" #include "SymTable.h" #include "Outputter.h" #include "Block2Verilog.h" #include <memory> #include <utility> #include <vector> #include <queue> #include <string> struct NRung : public Node { /* Constructors, Destructor, and Assignment operators {{{ */ // Default constructor NRung(); NRung(const NBlockish* b, const unsigned rung_count); // Copy constructor NRung(const NRung& other); // Move constructor NRung(NRung&& other); // Destructor ~NRung(); // Assignment operator NRung& operator=(const NRung& other); // Move assignment operator NRung& operator=(NRung&& other); /* }}} */ virtual SymTable& populate_symtable(SymTable& symtable) const override; /** * Determines the inputs and outputs of this rung. */ void populate_in_out(); /** * Overload so that the rung can append to the Outputter. * * Since the job of this method is to append to the Outputter, nothing is * returned. */ void to_verilog(Outputter& outputter, const SymTable& symtable) const; virtual std::string to_dot(Outputter& outputter, const SymTable& symtable) const override; NBlockish* block; /** * The LHS and the RHS of the rung. * For example, if we had: * * XIC(Foo) XIC(Bar) OTE(Baz) * * This will become an NSequence that contains {XIC(Foo), XIC(Bar} and the * outputs will become a vector of length 1 with {OTE(Baz)}. This is done * so that when converting to Verilog, the to_verilog method of the input * only needs to be called. The `outputs' is a vector because we could * have multiple outputs in parallel in a rung. However, note that we do * not currently allow multiple outputs in series. * * OK: * XIC(Foo) [OTE(Bar), OTE(Baz)] * NG: * XIC(Foo) [OTE(Bar) OTE(Baz)] * * The output Verilog will probably be weird if the latter is used. * TODO: Error message * * Also note that `inputs' is not in the AST (the AST contains data with * `inputs' and `outputs' connected together but not separately). * Separation is done in populate_in_out, which should be called some time * after the AST was constructed. */ std::shared_ptr<NBlockish> inputs; std::vector<NBlock*> outputs; private: /** * Finds the closest NSequence block in the AST. * In a proper Ladder Logic program, the nearest NSequence is almost * always the member variable `block' because a rung needs to have at * least one input and one output in series. */ NSequence* find_nearest_sequence() const; /** * Decomposes the NBlockish passed in and returns a vector of all NBlock * contained as children. */ std::vector<NBlock*> extract_blocks(NBlockish* blockish) const; std::string timer_module_verilog(const NBlock* output, const SymTable& symtable) const; }; /* Constructors, Destructor, and Assignment operators {{{ */ // Default constructor inline NRung::NRung() : Node{0} , block{nullptr} { } inline NRung::NRung(const NBlockish* b, const unsigned rung_count) : Node{rung_count} , block{const_cast<NBlockish*>(b)} { } // Copy constructor inline NRung::NRung(const NRung& other) : Node{other} , block{other.block} { } // Move constructor inline NRung::NRung(NRung&& other) : Node{std::move(other)} , block{std::move(other.block)} { } // Destructor inline NRung::~NRung() { } // Assignment operator inline NRung& NRung::operator=(const NRung& other) { Node::operator=(other); block = other.block; return *this; } // Move assignment operator inline NRung& NRung::operator=(NRung&& other) { Node::operator=(std::move(other)); block = std::move(other.block); return *this; } /* }}} */ inline SymTable& NRung::populate_symtable(SymTable& symtable) const { return block->populate_symtable(symtable); } inline void NRung::populate_in_out() { // TODO: extract_blocks, find_nearest_sequence std::vector<NBlockish*> nearest_sequence = find_nearest_sequence()->blocks; // Reverse traverse sequence to find all outputs auto blockish_it = nearest_sequence.rbegin(); // Expect this loop to run only one iteration while (blockish_it != nearest_sequence.rend()) { auto& blockish_ptr = *blockish_it; if (blockish_ptr->is_output()) { for (const auto& block : extract_blocks(blockish_ptr)) { outputs.insert(outputs.begin(), block); } } else { break; } blockish_it++; } // Rest is all inputs std::vector<NBlockish*> tmp_inputs; while (blockish_it != nearest_sequence.rend()) { tmp_inputs.insert(tmp_inputs.begin(), *blockish_it); blockish_it++; } // If tmp_inputs has only one element, use that as `inputs'. // Otherwise, make a new NSequence from all NBlockish in tmp_inputs if (tmp_inputs.size() == 1) { inputs = std::shared_ptr<NBlockish>{tmp_inputs.front()}; } else { auto seq = new NSequence{rung_count}; seq->blocks = std::move(tmp_inputs); inputs = std::shared_ptr<NBlockish>{seq}; } } inline void NRung::to_verilog(Outputter& outputter, const SymTable& symtable) const { for (const auto& output : outputs) { auto verilog = Block2Verilog(output->inst->name)(inputs.get(), output, symtable); outputter.append("rungs", verilog); // Add Timer modules if (output->inst->name == "TON" || output->inst->name == "TOF") { auto modules = timer_module_verilog(output,symtable); outputter.append("modules", modules); } } } inline std::string NRung::to_dot(Outputter& outputter, const SymTable& symtable) const { // TODO: Implement me! ignore_unused_warnings(outputter); ignore_unused_warnings(symtable); return "Sorry, unimplemented"; } inline NSequence* NRung::find_nearest_sequence() const { if (block->type == NBlockish::BlockType::SEQUENCE) { // This block is most likely going to be executed return dynamic_cast<NSequence*>(block); } else { // Do a BFS std::queue<NBlockish*> q; q.push(block); while (!q.empty()) { auto b = q.front(); q.pop(); if (b->type == NBlockish::BlockType::SEQUENCE) { return dynamic_cast<NSequence*>(b); } if (b->type == NBlockish::BlockType::PARALLEL) { auto p_block = dynamic_cast<NParallel*>(b); for (const auto& block : p_block->blocks) { q.push(block); } } else if (b->type == NBlockish::BlockType::SEGMENT) { q.push(dynamic_cast<NSegment*>(b)->block); } else if (b->type == NBlockish::BlockType::BLOCK) { // Do nothing } else { throw std::runtime_error{"Unknown block type"}; } } throw std::runtime_error{"No NSequence node found"}; } } inline std::vector<NBlock*> NRung::extract_blocks(NBlockish* blockish) const { std::vector<NBlock*> to_ret; // Do a BFS std::queue<NBlockish*> q; q.push(blockish); while (!q.empty()) { auto b = q.front(); q.pop(); switch (b->type) { case NBlockish::BlockType::SEQUENCE: for (const auto& block : dynamic_cast<NSequence*>(b)->blocks) { q.push(block); } break; case NBlockish::BlockType::PARALLEL: for (const auto& block : dynamic_cast<NParallel*>(b)->blocks) { q.push(block); } break; case NBlockish::BlockType::SEGMENT: q.push(dynamic_cast<NSegment*>(b)->block); break; case NBlockish::BlockType::BLOCK: to_ret.push_back(dynamic_cast<NBlock*>(b)); break; default: throw std::runtime_error{"Unknown block type"}; } } return to_ret; } inline std::string NRung::timer_module_verilog(const NBlock* output, const SymTable& symtable) const { /* Sample output Verilog: * wire n_timer_2_done_wire; * Timer t2(clk, rst, tick, 5000, main_wash, n_timer_2_done_wire); */ auto timer_name = symtable[output->addresses[0]].var_name; // Milliseconds to wait auto preset = symtable[output->addresses[1]].var_name; auto enable_addr = symtable[output->addresses[3]].var_name; auto done_addr = symtable[output->addresses[5]].var_name; std::string wire_name = "n_" + done_addr + "_wire"; std::stringstream oss; // Declare wire oss << "wire " << wire_name << ";" << std::endl; // Stamp out module char buf[512]; // TODO: method to append _m for modules std::sprintf(buf, "Timer %s(clk, rst, tick, %s, %s, %s);", (timer_name + "_m").c_str(), preset.c_str(), enable_addr.c_str(), wire_name.c_str()); oss << buf; return oss.str(); } #endif /* end of include guard */
[ "nigorojr@gmail.com" ]
nigorojr@gmail.com
f907e8a7a0724550fc375ba7bb51579d8b63d8fe
d875107c7a919cacdf1f1cbf4efec4d2fa270fb8
/RayTracing/Light/Tracer/AreaLights.h
ec1d6e2ad94879008acc9e641dd241f7e0c264be
[]
no_license
terraritto/RayTracing
c2d451c4d53d093e383be7e755adcda07538d97e
d4a47772241fcec26c3662ef151934c7cfd0b1f9
refs/heads/master
2021-07-04T03:49:43.054692
2020-11-19T07:17:32
2020-11-19T07:17:32
200,249,837
0
0
null
2019-11-14T15:28:42
2019-08-02T14:34:58
C++
UTF-8
C++
false
false
204
h
#pragma once #include "Tracer.h" class AreaLights : public Tracer { public: AreaLights(); AreaLights(World* world); ~AreaLights(); RGBColor TraceRay(const Ray ray, const int depth) const override; };
[ "28126083+terraritto@users.noreply.github.com" ]
28126083+terraritto@users.noreply.github.com
2959c0f09b7fb060c24bda047a1b1973635b6eaf
cec3c851b4db12287f73ca79b36aa178be8546a0
/SurfColBug/SurfColBug.cpp
29fac0924110756871d3cf38d1c65de5a8cfc6f7
[]
no_license
jhurdlow/SurfCol
21080172fe08bd5665039c3268c628d33ca42c3e
2fa5f0856c499b49607197f881890db4d055c7fb
refs/heads/master
2020-04-08T21:24:35.445201
2018-11-30T00:05:00
2018-11-30T00:05:00
159,742,923
0
0
null
null
null
null
UTF-8
C++
false
false
3,223
cpp
#include <unordered_set> #include <string> #include "lwmMesh.h" #include "lwmCommand.h" #include <lwsurf.h> #include <lwmodeler.h> // activate function extern "C" { XCALL_(int) Activate(long version, GlobalFunc * global, void * local, void * user) { LWStateQueryFuncs *query = (LWStateQueryFuncs*)global(LWSTATEQUERYFUNCS_GLOBAL, GFUSE_TRANSIENT); LWSurfaceFuncs *surfFuncs = (LWSurfaceFuncs *)(*global) (LWSURFACEFUNCS_GLOBAL, GFUSE_TRANSIENT); lwmCommand* cmd = new lwmCommand((LWModCommand*)local); lwmMesh* mesh = new lwmMesh(cmd->EditBegin(OPSEL_GLOBAL)); std::unordered_set<std::string> surfaces; const char* objectName = query->object(); if (objectName == nullptr) objectName = "Unnamed"; LWSurfaceID* surfsArray = surfFuncs->byObject(objectName); // get array of surface names for this object. int s = 0; LWSurfaceID thisSurf = surfsArray[s++]; while (thisSurf != nullptr) { std::string name = surfFuncs->name(thisSurf); if (surfaces.find(name) == surfaces.end()) { surfaces.insert(name); } thisSurf = surfsArray[s++]; } const int c = 3; std::string surfName[c] = { "RedSurf", "GreenSurf", "BlueSurf" }; // Draw 3 polygons, each with a different surface and color for (int i = 0; i < c; i++) { // Create a new surface (if it doesn't exist) if (surfaces.find(surfName[i]) == surfaces.end()) { surfFuncs->create(objectName, surfName[i].c_str()); } // Make it the current surface for our object. cmd->SurfSetSurf(surfName[i].c_str(), objectName); // Set the color of the current surface (our new one, if we created it) // Comment back in the conditional for this block to prevent us from resetting the color if the surface // already exists. When the surface already exists we see really strange behavior on subsequent runs, // such as getting the wrong colors on surfaces. Appears to be a bug in Modeler. /// if (surfaces.find(surfName[i]) == surfaces.end()) { float rgb[3] = { 0.5, 0.5, 0.5 }; rgb[i] = 1.0; // should make the first red, the second green, the third blue. cmd->SurfSetColor(rgb); // !! Modeler 2018 does not seem to actually set the surface color here... !! // Also, strangely the first surface gets a roughness value, where subsequent surfs don't. /// } // Draw a poly double rawPnts[4][3] = { {0.0, 0.0, 0.0}, {0.0, 1.0, 0.0}, {1.0, 1.0, 0.0}, {1.0, 0.0, 0.0} }; LWPntID pntIds[4]; for (int p = 0; p < 4; p++) { double* pnt = rawPnts[p]; pnt[0] += (double)i; // shift each poly in the x plane pntIds[p] = mesh->addPoint(pnt); } mesh->addPoly(LWPOLTYPE_FACE, surfName[i].c_str(), 4, pntIds); } mesh->done(EDERR_NONE, EDSELM_CLEARCURRENT); if (mesh) { delete (mesh); } if (cmd) { delete (cmd); } return AFUNC_OK; } #pragma optimize("", off) void * Startup(void) { return ((void *)1); } void Shutdown(void * user) { } ServerTagInfo ServerTags[] = { {"SurfColsBug", SRVTAG_USERNAME}, {"SurfColsBug", SRVTAG_BUTTONNAME}, {"BugRepro", SRVTAG_CMDGROUP}, {"Surface Colors SDK Bug Repro", SRVTAG_DESCRIPTION | LANGID_USENGLISH}, }; ServerRecord ServerDesc[] = { { "CommandSequence", "SurfColsBug", Activate, ServerTags}, { NULL } }; #pragma optimize("", on) } // extern "C"
[ "jhurdlow@gmail.com" ]
jhurdlow@gmail.com
b7b968de1ce4d3b522d8393e450a2a2b48b5103c
0c0ce7515462afe5290e7265570c85edcbf5d494
/Interpolation/Codes/DividedDifferenceInterpolator.cpp
ddfd7f061c74cd7116f13620843f0b501b6f95de
[]
no_license
shuchitgandhi/Numerical-Computational-Codes
8e38de54f5a358789533b01f729598dc0be78592
b572c3d24342d27a87c3be4795ab629e71a291df
refs/heads/master
2021-01-10T03:16:23.983987
2016-01-30T09:32:57
2016-01-30T09:32:57
50,718,380
0
0
null
null
null
null
UTF-8
C++
false
false
1,407
cpp
#include <iostream> #include <fstream> using namespace std; double **divided_difference_table(double *, double *, int); double divided_difference_interpolator(double *, double **, int, double); int main(int argc, char const *argv[]) { int i, n; double *x, *f, **DD, input, ans; fstream fin; fin.open("DividedDifferenceInterpolator.dat", ios::in); fin>>n; x = new double[n]; f = new double[n]; for(i=0;i<n;i++) fin>>x[i]; for(i=0;i<n;i++) fin>>f[i]; DD = divided_difference_table(x, f, n); cout<<"Enter any value between ["<<x[0]<<", "<<x[n-1]<<"] : "; cin>>input; ans = divided_difference_interpolator(x, DD, n, input); cout<<"The interpolated value for x="<<input<<" is "<<ans<<"\n"; return 0; } double **divided_difference_table(double *x, double *f, int n) { double **DD; int i, j; /* Allocate memory for forward differences table */ DD = new double*[n]; for(i=0;i<n;i++) DD[i] = new double[n]; /* Insert first column as values of f(x) */ for(i=0;i<n;i++) DD[i][0] = f[i]; /* Create forward differences table */ for(j=1;j<n;j++) { for(i=0;i<n-j;i++) DD[i][j] = (DD[i+1][j-1] - DD[i][j-1])/(x[i+j] - x[i]); } return DD; } double divided_difference_interpolator(double *x, double **DD, int n, double input) { int i, j; double ans = 0, term; for(i=0;i<n;i++) { term = DD[0][i]; for(j=0;j<i;j++) term *= (input - x[j]); ans += term; } return ans; }
[ "shuchit95@gmail.com" ]
shuchit95@gmail.com
9000b7cd44b2080dce81362a38d53fc67b838562
bf83fbb1839ec90f1b8931c7aea4fdf7cddcf5f6
/frontiers/include/frontiers.h
c08df83b89c95311855dea1642ac3e223fb29111
[ "MIT" ]
permissive
maheshmmk/FlyingOctomap_code
0a644c936f8908cfca59ee1a9aa71effa0007376
b4ce50993daa2bd566b662d0e20701c13167e4ac
refs/heads/master
2020-06-17T19:24:08.417175
2018-09-30T15:45:21
2018-09-30T15:45:21
null
0
0
null
null
null
null
UTF-8
C++
false
false
3,479
h
#ifndef FRONTIERS_H #define FRONTIERS_H #include <vector> #include <cmath> #include <sstream> #include <iostream> #include <fstream> #include <ros/ros.h> #include <octomap/OcTree.h> #include <octomap/math/Vector3.h> #include <chrono> #include <algorithm> #include <marker_publishing_utils.h> #include <geometry_msgs/Point.h> #include <frontiers_msgs/FrontierReply.h> #include <frontiers_msgs/FrontierRequest.h> namespace Frontiers{ class Voxel { public: double x, y, z, size; Voxel() : x(0), y(0), z(0), size(0) {} Voxel(double x, double y, double z, double size) : x(x), y(y), z(z), size(size) {} Voxel(frontiers_msgs::VoxelMsg const& msg) : x(msg.xyz_m.x), y(msg.xyz_m.y), z(msg.xyz_m.z), size(msg.size) {} bool isInZlevel(float z_level) const { float max_z = z + (size/2); float min_z = z -(size/2); if(max_z >= z_level && min_z <= z_level) { return true; } else { return false; } } /// Operators bool operator==(Voxel const& otherVoxel) const { return (x == otherVoxel.x && y == otherVoxel.y && z == otherVoxel.z && size == otherVoxel.size); } /// Display and << std::string displayString() const { return "(" + std::to_string(x) + "; "+ std::to_string(y) + " )"; } std::ostream& displayString(std::ostream& stream_out) const { stream_out << "(" << x << "; " << y << "; "<< z << " ) x "<<size ; stream_out.precision(3); return stream_out; } frontiers_msgs::VoxelMsg toMsg(frontiers_msgs::VoxelMsg& msg) { msg.xyz_m.x = x; msg.xyz_m.y = y; msg.xyz_m.z = z; msg.size = size; } }; const int d3 = 3; void calculate_closer_position(octomath::Vector3 & sensing_position, octomath::Vector3 const& n_coordinates, double const safety_margin); bool isCenterGoodGoal(double voxel_side, double octree_resolution, double sensing_distance); bool processFrontiersRequest(octomap::OcTree const& octree, frontiers_msgs::FrontierRequest const& request, frontiers_msgs::FrontierReply& reply, ros::Publisher const& marker_pub, bool publish = true); bool meetsOperationalRequirements(octomath::Vector3 const& candidate, double min_distance, octomath::Vector3 const& current_position, octomap::OcTree const& octree, double safety_distance, geometry_msgs::Point geofence_min, geometry_msgs::Point geofence_max, ros::Publisher const& marker_pub, bool publish); bool isOccupied(octomath::Vector3 const& grid_coordinates_toTest, octomap::OcTree const& octree); bool isExplored(octomath::Vector3 const& grid_coordinates_toTest, octomap::OcTree const& octree); bool isFrontier(octomap::OcTree& octree, octomath::Vector3 const& candidate, double sensor_angle); bool isFrontierTooCloseToObstacles(octomath::Vector3 const& frontier, double safety_margin, octomap::OcTree const& octree, ros::Publisher const& marker_pub, bool publish = true); } #endif // FRONTIERS_H
[ "margaridaCostaFaria@gmail.com" ]
margaridaCostaFaria@gmail.com
bec08bda075d8e829d2e65e7f6749827d56fb30c
fc9200cb85ed13e5d026f6f9ae3cc6a82b377a21
/libs/core/resiliency/tests/unit/dataflow_replay_executor.cpp
6148e691d7078fc32a26e479968b52699e59e9c7
[ "BSL-1.0", "LicenseRef-scancode-free-unknown" ]
permissive
gonidelis/hpx
147d636d2a63d2178becc340cd253c9b8a0e776d
db2efee3c36f70e610555bc86c22cc8006724079
refs/heads/master
2023-08-17T03:25:03.450931
2022-02-01T16:37:32
2022-02-01T16:37:32
275,136,168
0
0
BSL-1.0
2022-05-17T03:35:17
2020-06-26T11:06:04
C++
UTF-8
C++
false
false
3,619
cpp
// Copyright (c) 2019 National Technology & Engineering Solutions of Sandia, // LLC (NTESS). // Copyright (c) 2018-2020 Hartmut Kaiser // Copyright (c) 2018-2019 Adrian Serio // Copyright (c) 2019 Nikunj Gupta // // SPDX-License-Identifier: BSL-1.0 // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) #include <hpx/local/init.hpp> #include <hpx/modules/execution.hpp> #include <hpx/modules/futures.hpp> #include <hpx/modules/resiliency.hpp> #include <hpx/modules/testing.hpp> #include <atomic> #include <stdexcept> std::atomic<int> answer(35); struct vogon_exception : std::exception { }; int universal_answer() { return ++answer; } bool validate(int result) { return result == 42; } int no_answer() { throw hpx::resiliency::experimental::abort_replay_exception(); } int deep_thought() { static int ans = 35; ++ans; if (ans == 42) return ans; else throw vogon_exception(); } int hpx_main() { { hpx::execution::parallel_executor exec; // successful replay hpx::future<int> f = hpx::resiliency::experimental::dataflow_replay( exec, 10, &deep_thought); HPX_TEST(f.get() == 42); // successful replay validate f = hpx::resiliency::experimental::dataflow_replay_validate( exec, 10, &validate, &universal_answer); HPX_TEST(f.get() == 42); // unsuccessful replay f = hpx::resiliency::experimental::dataflow_replay( exec, 6, &deep_thought); bool exception_caught = false; try { f.get(); HPX_TEST(false); } catch (vogon_exception const&) { exception_caught = true; } catch (...) { HPX_TEST(false); } HPX_TEST(exception_caught); // unsuccessful replay validate f = hpx::resiliency::experimental::dataflow_replay_validate( exec, 6, &validate, &universal_answer); exception_caught = false; try { f.get(); HPX_TEST(false); } catch (hpx::resiliency::experimental::abort_replay_exception const&) { exception_caught = true; } catch (...) { HPX_TEST(false); } HPX_TEST(exception_caught); // aborted replay f = hpx::resiliency::experimental::dataflow_replay(exec, 1, &no_answer); exception_caught = false; try { f.get(); HPX_TEST(false); } catch (hpx::resiliency::experimental::abort_replay_exception const&) { exception_caught = true; } catch (...) { HPX_TEST(false); } HPX_TEST(exception_caught); // aborted replay validate f = hpx::resiliency::experimental::dataflow_replay_validate( exec, 1, &validate, &no_answer); exception_caught = false; try { f.get(); } catch (hpx::resiliency::experimental::abort_replay_exception const&) { exception_caught = true; } catch (...) { HPX_TEST(false); } HPX_TEST(exception_caught); } return hpx::local::finalize(); } int main(int argc, char* argv[]) { // Initialize and run HPX HPX_TEST(hpx::local::init(hpx_main, argc, argv) == 0); return hpx::util::report_errors(); }
[ "mikael.simberg@iki.fi" ]
mikael.simberg@iki.fi
223e30297932f7530eb156f7e5b1f35c9d26b7af
8fe2e38fd3f23f58dd0f35d1f351601f8a723e07
/3party/boost/boost/multi_index/detail/ord_index_impl.hpp
ffd1e01923b19d74e3f7dfc9bedb8786d38cfb69
[ "Apache-2.0", "BSL-1.0" ]
permissive
ruilin/RLMap
cb139b7fb3020b163a6857cfa6b98f0c930f2a45
e16b52f77d165e719b3af20b097f227959e8e374
refs/heads/master
2022-10-06T10:11:39.760428
2019-11-22T01:03:27
2019-11-22T01:03:27
97,201,756
2
1
Apache-2.0
2022-10-04T23:29:25
2017-07-14T06:39:33
C++
UTF-8
C++
false
false
46,950
hpp
/* Copyright 2003-2015 Joaquin M Lopez Munoz. * Distributed under the Boost Software License, Version 1.0. * (See accompanying file LICENSE_1_0.txt or copy at * http://www.boost.org/LICENSE_1_0.txt) * * See http://www.boost.org/libs/multi_index for library home page. * * The internal implementation of red-black trees is based on that of SGI STL * stl_tree.h file: * * Copyright (c) 1996,1997 * Silicon Graphics Computer Systems, Inc. * * Permission to use, copy, modify, distribute and sell this software * and its documentation for any purpose is hereby granted without fee, * provided that the above copyright notice appear in all copies and * that both that copyright notice and this permission notice appear * in supporting documentation. Silicon Graphics makes no * representations about the suitability of this software for any * purpose. It is provided "as is" without express or implied warranty. * * * Copyright (c) 1994 * Hewlett-Packard Company * * Permission to use, copy, modify, distribute and sell this software * and its documentation for any purpose is hereby granted without fee, * provided that the above copyright notice appear in all copies and * that both that copyright notice and this permission notice appear * in supporting documentation. Hewlett-Packard Company makes no * representations about the suitability of this software for any * purpose. It is provided "as is" without express or implied warranty. * */ #ifndef BOOST_MULTI_INDEX_DETAIL_ORD_INDEX_IMPL_HPP #define BOOST_MULTI_INDEX_DETAIL_ORD_INDEX_IMPL_HPP #if defined(_MSC_VER) #pragma once #endif #include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */ #include <algorithm> #include <boost/call_traits.hpp> #include <boost/detail/no_exceptions_support.hpp> #include <boost/detail/workaround.hpp> #include <boost/foreach_fwd.hpp> #include <boost/iterator/reverse_iterator.hpp> #include <boost/move/core.hpp> #include <boost/mpl/bool.hpp> #include <boost/mpl/if.hpp> #include <boost/mpl/push_front.hpp> #include <boost/multi_index/detail/access_specifier.hpp> #include <boost/multi_index/detail/bidir_node_iterator.hpp> #include <boost/multi_index/detail/do_not_copy_elements_tag.hpp> #include <boost/multi_index/detail/index_node_base.hpp> #include <boost/multi_index/detail/modify_key_adaptor.hpp> #include <boost/multi_index/detail/ord_index_node.hpp> #include <boost/multi_index/detail/ord_index_ops.hpp> #include <boost/multi_index/detail/safe_mode.hpp> #include <boost/multi_index/detail/scope_guard.hpp> #include <boost/multi_index/detail/unbounded.hpp> #include <boost/multi_index/detail/value_compare.hpp> #include <boost/multi_index/detail/vartempl_support.hpp> #include <boost/multi_index/detail/ord_index_impl_fwd.hpp> #include <boost/ref.hpp> #include <boost/tuple/tuple.hpp> #include <boost/type_traits/is_same.hpp> #include <utility> #if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST) #include <initializer_list> #endif #if !defined(BOOST_MULTI_INDEX_DISABLE_SERIALIZATION) #include <boost/archive/archive_exception.hpp> #include <boost/bind.hpp> #include <boost/multi_index/detail/duplicates_iterator.hpp> #include <boost/throw_exception.hpp> #endif #if defined(BOOST_MULTI_INDEX_ENABLE_INVARIANT_CHECKING) #define BOOST_MULTI_INDEX_ORD_INDEX_CHECK_INVARIANT_OF(x) \ detail::scope_guard BOOST_JOIN(check_invariant_,__LINE__)= \ detail::make_obj_guard(x,&ordered_index_impl::check_invariant_); \ BOOST_JOIN(check_invariant_,__LINE__).touch(); #define BOOST_MULTI_INDEX_ORD_INDEX_CHECK_INVARIANT \ BOOST_MULTI_INDEX_ORD_INDEX_CHECK_INVARIANT_OF(*this) #else #define BOOST_MULTI_INDEX_ORD_INDEX_CHECK_INVARIANT_OF(x) #define BOOST_MULTI_INDEX_ORD_INDEX_CHECK_INVARIANT #endif namespace boost{ namespace multi_index{ namespace detail{ /* ordered_index adds a layer of ordered indexing to a given Super and accepts * an augmenting policy for optional addition of order statistics. */ /* Most of the implementation of unique and non-unique indices is * shared. We tell from one another on instantiation time by using * these tags. */ struct ordered_unique_tag{}; struct ordered_non_unique_tag{}; template< typename KeyFromValue,typename Compare, typename SuperMeta,typename TagList,typename Category,typename AugmentPolicy > class ordered_index; template< typename KeyFromValue,typename Compare, typename SuperMeta,typename TagList,typename Category,typename AugmentPolicy > class ordered_index_impl: BOOST_MULTI_INDEX_PROTECTED_IF_MEMBER_TEMPLATE_FRIENDS SuperMeta::type #if defined(BOOST_MULTI_INDEX_ENABLE_SAFE_MODE) ,public safe_mode::safe_container< ordered_index_impl< KeyFromValue,Compare,SuperMeta,TagList,Category,AugmentPolicy> > #endif { #if defined(BOOST_MULTI_INDEX_ENABLE_INVARIANT_CHECKING)&&\ BOOST_WORKAROUND(__MWERKS__,<=0x3003) /* The "ISO C++ Template Parser" option in CW8.3 has a problem with the * lifetime of const references bound to temporaries --precisely what * scopeguards are. */ #pragma parse_mfunc_templ off #endif typedef typename SuperMeta::type super; protected: typedef ordered_index_node< AugmentPolicy,typename super::node_type> node_type; protected: /* for the benefit of AugmentPolicy::augmented_interface */ typedef typename node_type::impl_type node_impl_type; typedef typename node_impl_type::pointer node_impl_pointer; public: /* types */ typedef typename KeyFromValue::result_type key_type; typedef typename node_type::value_type value_type; typedef KeyFromValue key_from_value; typedef Compare key_compare; typedef value_comparison< value_type,KeyFromValue,Compare> value_compare; typedef tuple<key_from_value,key_compare> ctor_args; typedef typename super::final_allocator_type allocator_type; typedef typename allocator_type::reference reference; typedef typename allocator_type::const_reference const_reference; #if defined(BOOST_MULTI_INDEX_ENABLE_SAFE_MODE) typedef safe_mode::safe_iterator< bidir_node_iterator<node_type>, ordered_index_impl> iterator; #else typedef bidir_node_iterator<node_type> iterator; #endif typedef iterator const_iterator; typedef std::size_t size_type; typedef std::ptrdiff_t difference_type; typedef typename allocator_type::pointer pointer; typedef typename allocator_type::const_pointer const_pointer; typedef typename boost::reverse_iterator<iterator> reverse_iterator; typedef typename boost::reverse_iterator<const_iterator> const_reverse_iterator; typedef TagList tag_list; protected: typedef typename super::final_node_type final_node_type; typedef tuples::cons< ctor_args, typename super::ctor_args_list> ctor_args_list; typedef typename mpl::push_front< typename super::index_type_list, ordered_index< KeyFromValue,Compare, SuperMeta,TagList,Category,AugmentPolicy > >::type index_type_list; typedef typename mpl::push_front< typename super::iterator_type_list, iterator>::type iterator_type_list; typedef typename mpl::push_front< typename super::const_iterator_type_list, const_iterator>::type const_iterator_type_list; typedef typename super::copy_map_type copy_map_type; #if !defined(BOOST_MULTI_INDEX_DISABLE_SERIALIZATION) typedef typename super::index_saver_type index_saver_type; typedef typename super::index_loader_type index_loader_type; #endif protected: #if defined(BOOST_MULTI_INDEX_ENABLE_SAFE_MODE) typedef safe_mode::safe_container< ordered_index_impl> safe_super; #endif typedef typename call_traits< value_type>::param_type value_param_type; typedef typename call_traits< key_type>::param_type key_param_type; /* Needed to avoid commas in BOOST_MULTI_INDEX_OVERLOADS_TO_VARTEMPL * expansion. */ typedef std::pair<iterator,bool> emplace_return_type; public: /* construct/copy/destroy * Default and copy ctors are in the protected section as indices are * not supposed to be created on their own. No range ctor either. * Assignment operators defined at ordered_index rather than here. */ allocator_type get_allocator()const BOOST_NOEXCEPT { return this->final().get_allocator(); } /* iterators */ iterator begin()BOOST_NOEXCEPT{return make_iterator(leftmost());} const_iterator begin()const BOOST_NOEXCEPT{return make_iterator(leftmost());} iterator end()BOOST_NOEXCEPT{return make_iterator(header());} const_iterator end()const BOOST_NOEXCEPT{return make_iterator(header());} reverse_iterator rbegin()BOOST_NOEXCEPT{return boost::make_reverse_iterator(end());} const_reverse_iterator rbegin()const BOOST_NOEXCEPT{return boost::make_reverse_iterator(end());} reverse_iterator rend()BOOST_NOEXCEPT{return boost::make_reverse_iterator(begin());} const_reverse_iterator rend()const BOOST_NOEXCEPT{return boost::make_reverse_iterator(begin());} const_iterator cbegin()const BOOST_NOEXCEPT{return begin();} const_iterator cend()const BOOST_NOEXCEPT{return end();} const_reverse_iterator crbegin()const BOOST_NOEXCEPT{return rbegin();} const_reverse_iterator crend()const BOOST_NOEXCEPT{return rend();} iterator iterator_to(const value_type& x) { return make_iterator(node_from_value<node_type>(&x)); } const_iterator iterator_to(const value_type& x)const { return make_iterator(node_from_value<node_type>(&x)); } /* capacity */ bool empty()const BOOST_NOEXCEPT{return this->final_empty_();} size_type size()const BOOST_NOEXCEPT{return this->final_size_();} size_type max_size()const BOOST_NOEXCEPT{return this->final_max_size_();} /* modifiers */ BOOST_MULTI_INDEX_OVERLOADS_TO_VARTEMPL( emplace_return_type,emplace,emplace_impl) BOOST_MULTI_INDEX_OVERLOADS_TO_VARTEMPL_EXTRA_ARG( iterator,emplace_hint,emplace_hint_impl,iterator,position) std::pair<iterator,bool> insert(const value_type& x) { BOOST_MULTI_INDEX_ORD_INDEX_CHECK_INVARIANT; std::pair<final_node_type*,bool> p=this->final_insert_(x); return std::pair<iterator,bool>(make_iterator(p.first),p.second); } std::pair<iterator,bool> insert(BOOST_RV_REF(value_type) x) { BOOST_MULTI_INDEX_ORD_INDEX_CHECK_INVARIANT; std::pair<final_node_type*,bool> p=this->final_insert_rv_(x); return std::pair<iterator,bool>(make_iterator(p.first),p.second); } iterator insert(iterator position,const value_type& x) { BOOST_MULTI_INDEX_CHECK_VALID_ITERATOR(position); BOOST_MULTI_INDEX_CHECK_IS_OWNER(position,*this); BOOST_MULTI_INDEX_ORD_INDEX_CHECK_INVARIANT; std::pair<final_node_type*,bool> p=this->final_insert_( x,static_cast<final_node_type*>(position.get_node())); return make_iterator(p.first); } iterator insert(iterator position,BOOST_RV_REF(value_type) x) { BOOST_MULTI_INDEX_CHECK_VALID_ITERATOR(position); BOOST_MULTI_INDEX_CHECK_IS_OWNER(position,*this); BOOST_MULTI_INDEX_ORD_INDEX_CHECK_INVARIANT; std::pair<final_node_type*,bool> p=this->final_insert_rv_( x,static_cast<final_node_type*>(position.get_node())); return make_iterator(p.first); } template<typename InputIterator> void insert(InputIterator first,InputIterator last) { BOOST_MULTI_INDEX_ORD_INDEX_CHECK_INVARIANT; node_type* hint=header(); /* end() */ for(;first!=last;++first){ hint=this->final_insert_ref_( *first,static_cast<final_node_type*>(hint)).first; node_type::increment(hint); } } #if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST) void insert(std::initializer_list<value_type> list) { insert(list.begin(),list.end()); } #endif iterator erase(iterator position) { BOOST_MULTI_INDEX_CHECK_VALID_ITERATOR(position); BOOST_MULTI_INDEX_CHECK_DEREFERENCEABLE_ITERATOR(position); BOOST_MULTI_INDEX_CHECK_IS_OWNER(position,*this); BOOST_MULTI_INDEX_ORD_INDEX_CHECK_INVARIANT; this->final_erase_(static_cast<final_node_type*>(position++.get_node())); return position; } size_type erase(key_param_type x) { BOOST_MULTI_INDEX_ORD_INDEX_CHECK_INVARIANT; std::pair<iterator,iterator> p=equal_range(x); size_type s=0; while(p.first!=p.second){ p.first=erase(p.first); ++s; } return s; } iterator erase(iterator first,iterator last) { BOOST_MULTI_INDEX_CHECK_VALID_ITERATOR(first); BOOST_MULTI_INDEX_CHECK_VALID_ITERATOR(last); BOOST_MULTI_INDEX_CHECK_IS_OWNER(first,*this); BOOST_MULTI_INDEX_CHECK_IS_OWNER(last,*this); BOOST_MULTI_INDEX_CHECK_VALID_RANGE(first,last); BOOST_MULTI_INDEX_ORD_INDEX_CHECK_INVARIANT; while(first!=last){ first=erase(first); } return first; } bool replace(iterator position,const value_type& x) { BOOST_MULTI_INDEX_CHECK_VALID_ITERATOR(position); BOOST_MULTI_INDEX_CHECK_DEREFERENCEABLE_ITERATOR(position); BOOST_MULTI_INDEX_CHECK_IS_OWNER(position,*this); BOOST_MULTI_INDEX_ORD_INDEX_CHECK_INVARIANT; return this->final_replace_( x,static_cast<final_node_type*>(position.get_node())); } bool replace(iterator position,BOOST_RV_REF(value_type) x) { BOOST_MULTI_INDEX_CHECK_VALID_ITERATOR(position); BOOST_MULTI_INDEX_CHECK_DEREFERENCEABLE_ITERATOR(position); BOOST_MULTI_INDEX_CHECK_IS_OWNER(position,*this); BOOST_MULTI_INDEX_ORD_INDEX_CHECK_INVARIANT; return this->final_replace_rv_( x,static_cast<final_node_type*>(position.get_node())); } template<typename Modifier> bool modify(iterator position,Modifier mod) { BOOST_MULTI_INDEX_CHECK_VALID_ITERATOR(position); BOOST_MULTI_INDEX_CHECK_DEREFERENCEABLE_ITERATOR(position); BOOST_MULTI_INDEX_CHECK_IS_OWNER(position,*this); BOOST_MULTI_INDEX_ORD_INDEX_CHECK_INVARIANT; #if defined(BOOST_MULTI_INDEX_ENABLE_SAFE_MODE) /* MSVC++ 6.0 optimizer on safe mode code chokes if this * this is not added. Left it for all compilers as it does no * harm. */ position.detach(); #endif return this->final_modify_( mod,static_cast<final_node_type*>(position.get_node())); } template<typename Modifier,typename Rollback> bool modify(iterator position,Modifier mod,Rollback back_) { BOOST_MULTI_INDEX_CHECK_VALID_ITERATOR(position); BOOST_MULTI_INDEX_CHECK_DEREFERENCEABLE_ITERATOR(position); BOOST_MULTI_INDEX_CHECK_IS_OWNER(position,*this); BOOST_MULTI_INDEX_ORD_INDEX_CHECK_INVARIANT; #if defined(BOOST_MULTI_INDEX_ENABLE_SAFE_MODE) /* MSVC++ 6.0 optimizer on safe mode code chokes if this * this is not added. Left it for all compilers as it does no * harm. */ position.detach(); #endif return this->final_modify_( mod,back_,static_cast<final_node_type*>(position.get_node())); } template<typename Modifier> bool modify_key(iterator position,Modifier mod) { BOOST_MULTI_INDEX_CHECK_VALID_ITERATOR(position); BOOST_MULTI_INDEX_CHECK_DEREFERENCEABLE_ITERATOR(position); BOOST_MULTI_INDEX_CHECK_IS_OWNER(position,*this); BOOST_MULTI_INDEX_ORD_INDEX_CHECK_INVARIANT; return modify( position,modify_key_adaptor<Modifier,value_type,KeyFromValue>(mod,key)); } template<typename Modifier,typename Rollback> bool modify_key(iterator position,Modifier mod,Rollback back_) { BOOST_MULTI_INDEX_CHECK_VALID_ITERATOR(position); BOOST_MULTI_INDEX_CHECK_DEREFERENCEABLE_ITERATOR(position); BOOST_MULTI_INDEX_CHECK_IS_OWNER(position,*this); BOOST_MULTI_INDEX_ORD_INDEX_CHECK_INVARIANT; return modify( position, modify_key_adaptor<Modifier,value_type,KeyFromValue>(mod,key), modify_key_adaptor<Rollback,value_type,KeyFromValue>(back_,key)); } void swap( ordered_index< KeyFromValue,Compare,SuperMeta,TagList,Category,AugmentPolicy>& x) { BOOST_MULTI_INDEX_ORD_INDEX_CHECK_INVARIANT; BOOST_MULTI_INDEX_ORD_INDEX_CHECK_INVARIANT_OF(x); this->final_swap_(x.final()); } void clear()BOOST_NOEXCEPT { BOOST_MULTI_INDEX_ORD_INDEX_CHECK_INVARIANT; this->final_clear_(); } /* observers */ key_from_value key_extractor()const{return key;} key_compare key_comp()const{return comp_;} value_compare value_comp()const{return value_compare(key,comp_);} /* set operations */ /* Internally, these ops rely on const_iterator being the same * type as iterator. */ template<typename CompatibleKey> iterator find(const CompatibleKey& x)const { return make_iterator(ordered_index_find(root(),header(),key,x,comp_)); } template<typename CompatibleKey,typename CompatibleCompare> iterator find( const CompatibleKey& x,const CompatibleCompare& comp)const { return make_iterator(ordered_index_find(root(),header(),key,x,comp)); } template<typename CompatibleKey> size_type count(const CompatibleKey& x)const { return count(x,comp_); } template<typename CompatibleKey,typename CompatibleCompare> size_type count(const CompatibleKey& x,const CompatibleCompare& comp)const { std::pair<iterator,iterator> p=equal_range(x,comp); size_type n=std::distance(p.first,p.second); return n; } template<typename CompatibleKey> iterator lower_bound(const CompatibleKey& x)const { return make_iterator( ordered_index_lower_bound(root(),header(),key,x,comp_)); } template<typename CompatibleKey,typename CompatibleCompare> iterator lower_bound( const CompatibleKey& x,const CompatibleCompare& comp)const { return make_iterator( ordered_index_lower_bound(root(),header(),key,x,comp)); } template<typename CompatibleKey> iterator upper_bound(const CompatibleKey& x)const { return make_iterator( ordered_index_upper_bound(root(),header(),key,x,comp_)); } template<typename CompatibleKey,typename CompatibleCompare> iterator upper_bound( const CompatibleKey& x,const CompatibleCompare& comp)const { return make_iterator( ordered_index_upper_bound(root(),header(),key,x,comp)); } template<typename CompatibleKey> std::pair<iterator,iterator> equal_range( const CompatibleKey& x)const { std::pair<node_type*,node_type*> p= ordered_index_equal_range(root(),header(),key,x,comp_); return std::pair<iterator,iterator>( make_iterator(p.first),make_iterator(p.second)); } template<typename CompatibleKey,typename CompatibleCompare> std::pair<iterator,iterator> equal_range( const CompatibleKey& x,const CompatibleCompare& comp)const { std::pair<node_type*,node_type*> p= ordered_index_equal_range(root(),header(),key,x,comp); return std::pair<iterator,iterator>( make_iterator(p.first),make_iterator(p.second)); } /* range */ template<typename LowerBounder,typename UpperBounder> std::pair<iterator,iterator> range(LowerBounder lower,UpperBounder upper)const { typedef typename mpl::if_< is_same<LowerBounder,unbounded_type>, BOOST_DEDUCED_TYPENAME mpl::if_< is_same<UpperBounder,unbounded_type>, both_unbounded_tag, lower_unbounded_tag >::type, BOOST_DEDUCED_TYPENAME mpl::if_< is_same<UpperBounder,unbounded_type>, upper_unbounded_tag, none_unbounded_tag >::type >::type dispatch; return range(lower,upper,dispatch()); } BOOST_MULTI_INDEX_PROTECTED_IF_MEMBER_TEMPLATE_FRIENDS: ordered_index_impl(const ctor_args_list& args_list,const allocator_type& al): super(args_list.get_tail(),al), key(tuples::get<0>(args_list.get_head())), comp_(tuples::get<1>(args_list.get_head())) { empty_initialize(); } ordered_index_impl( const ordered_index_impl< KeyFromValue,Compare,SuperMeta,TagList,Category,AugmentPolicy>& x): super(x), #if defined(BOOST_MULTI_INDEX_ENABLE_SAFE_MODE) safe_super(), #endif key(x.key), comp_(x.comp_) { /* Copy ctor just takes the key and compare objects from x. The rest is * done in a subsequent call to copy_(). */ } ordered_index_impl( const ordered_index_impl< KeyFromValue,Compare,SuperMeta,TagList,Category,AugmentPolicy>& x, do_not_copy_elements_tag): super(x,do_not_copy_elements_tag()), #if defined(BOOST_MULTI_INDEX_ENABLE_SAFE_MODE) safe_super(), #endif key(x.key), comp_(x.comp_) { empty_initialize(); } ~ordered_index_impl() { /* the container is guaranteed to be empty by now */ } #if defined(BOOST_MULTI_INDEX_ENABLE_SAFE_MODE) iterator make_iterator(node_type* node){return iterator(node,this);} const_iterator make_iterator(node_type* node)const {return const_iterator(node,const_cast<ordered_index_impl*>(this));} #else iterator make_iterator(node_type* node){return iterator(node);} const_iterator make_iterator(node_type* node)const {return const_iterator(node);} #endif void copy_( const ordered_index_impl< KeyFromValue,Compare,SuperMeta,TagList,Category,AugmentPolicy>& x, const copy_map_type& map) { if(!x.root()){ empty_initialize(); } else{ header()->color()=x.header()->color(); AugmentPolicy::copy(x.header()->impl(),header()->impl()); node_type* root_cpy=map.find(static_cast<final_node_type*>(x.root())); header()->parent()=root_cpy->impl(); node_type* leftmost_cpy=map.find( static_cast<final_node_type*>(x.leftmost())); header()->left()=leftmost_cpy->impl(); node_type* rightmost_cpy=map.find( static_cast<final_node_type*>(x.rightmost())); header()->right()=rightmost_cpy->impl(); typedef typename copy_map_type::const_iterator copy_map_iterator; for(copy_map_iterator it=map.begin(),it_end=map.end();it!=it_end;++it){ node_type* org=it->first; node_type* cpy=it->second; cpy->color()=org->color(); AugmentPolicy::copy(org->impl(),cpy->impl()); node_impl_pointer parent_org=org->parent(); if(parent_org==node_impl_pointer(0))cpy->parent()=node_impl_pointer(0); else{ node_type* parent_cpy=map.find( static_cast<final_node_type*>(node_type::from_impl(parent_org))); cpy->parent()=parent_cpy->impl(); if(parent_org->left()==org->impl()){ parent_cpy->left()=cpy->impl(); } else if(parent_org->right()==org->impl()){ /* header() does not satisfy this nor the previous check */ parent_cpy->right()=cpy->impl(); } } if(org->left()==node_impl_pointer(0)) cpy->left()=node_impl_pointer(0); if(org->right()==node_impl_pointer(0)) cpy->right()=node_impl_pointer(0); } } super::copy_(x,map); } template<typename Variant> final_node_type* insert_( value_param_type v,final_node_type*& x,Variant variant) { link_info inf; if(!link_point(key(v),inf,Category())){ return static_cast<final_node_type*>(node_type::from_impl(inf.pos)); } final_node_type* res=super::insert_(v,x,variant); if(res==x){ node_impl_type::link( static_cast<node_type*>(x)->impl(),inf.side,inf.pos,header()->impl()); } return res; } template<typename Variant> final_node_type* insert_( value_param_type v,node_type* position,final_node_type*& x,Variant variant) { link_info inf; if(!hinted_link_point(key(v),position,inf,Category())){ return static_cast<final_node_type*>(node_type::from_impl(inf.pos)); } final_node_type* res=super::insert_(v,position,x,variant); if(res==x){ node_impl_type::link( static_cast<node_type*>(x)->impl(),inf.side,inf.pos,header()->impl()); } return res; } void erase_(node_type* x) { node_impl_type::rebalance_for_erase( x->impl(),header()->parent(),header()->left(),header()->right()); super::erase_(x); #if defined(BOOST_MULTI_INDEX_ENABLE_SAFE_MODE) detach_iterators(x); #endif } void delete_all_nodes_() { delete_all_nodes(root()); } void clear_() { super::clear_(); empty_initialize(); #if defined(BOOST_MULTI_INDEX_ENABLE_SAFE_MODE) safe_super::detach_dereferenceable_iterators(); #endif } void swap_( ordered_index_impl< KeyFromValue,Compare,SuperMeta,TagList,Category,AugmentPolicy>& x) { std::swap(key,x.key); std::swap(comp_,x.comp_); #if defined(BOOST_MULTI_INDEX_ENABLE_SAFE_MODE) safe_super::swap(x); #endif super::swap_(x); } void swap_elements_( ordered_index_impl< KeyFromValue,Compare,SuperMeta,TagList,Category,AugmentPolicy>& x) { #if defined(BOOST_MULTI_INDEX_ENABLE_SAFE_MODE) safe_super::swap(x); #endif super::swap_elements_(x); } template<typename Variant> bool replace_(value_param_type v,node_type* x,Variant variant) { if(in_place(v,x,Category())){ return super::replace_(v,x,variant); } node_type* next=x; node_type::increment(next); node_impl_type::rebalance_for_erase( x->impl(),header()->parent(),header()->left(),header()->right()); BOOST_TRY{ link_info inf; if(link_point(key(v),inf,Category())&&super::replace_(v,x,variant)){ node_impl_type::link(x->impl(),inf.side,inf.pos,header()->impl()); return true; } node_impl_type::restore(x->impl(),next->impl(),header()->impl()); return false; } BOOST_CATCH(...){ node_impl_type::restore(x->impl(),next->impl(),header()->impl()); BOOST_RETHROW; } BOOST_CATCH_END } bool modify_(node_type* x) { bool b; BOOST_TRY{ b=in_place(x->value(),x,Category()); } BOOST_CATCH(...){ erase_(x); BOOST_RETHROW; } BOOST_CATCH_END if(!b){ node_impl_type::rebalance_for_erase( x->impl(),header()->parent(),header()->left(),header()->right()); BOOST_TRY{ link_info inf; if(!link_point(key(x->value()),inf,Category())){ super::erase_(x); #if defined(BOOST_MULTI_INDEX_ENABLE_SAFE_MODE) detach_iterators(x); #endif return false; } node_impl_type::link(x->impl(),inf.side,inf.pos,header()->impl()); } BOOST_CATCH(...){ super::erase_(x); #if defined(BOOST_MULTI_INDEX_ENABLE_SAFE_MODE) detach_iterators(x); #endif BOOST_RETHROW; } BOOST_CATCH_END } BOOST_TRY{ if(!super::modify_(x)){ node_impl_type::rebalance_for_erase( x->impl(),header()->parent(),header()->left(),header()->right()); #if defined(BOOST_MULTI_INDEX_ENABLE_SAFE_MODE) detach_iterators(x); #endif return false; } else return true; } BOOST_CATCH(...){ node_impl_type::rebalance_for_erase( x->impl(),header()->parent(),header()->left(),header()->right()); #if defined(BOOST_MULTI_INDEX_ENABLE_SAFE_MODE) detach_iterators(x); #endif BOOST_RETHROW; } BOOST_CATCH_END } bool modify_rollback_(node_type* x) { if(in_place(x->value(),x,Category())){ return super::modify_rollback_(x); } node_type* next=x; node_type::increment(next); node_impl_type::rebalance_for_erase( x->impl(),header()->parent(),header()->left(),header()->right()); BOOST_TRY{ link_info inf; if(link_point(key(x->value()),inf,Category())&& super::modify_rollback_(x)){ node_impl_type::link(x->impl(),inf.side,inf.pos,header()->impl()); return true; } node_impl_type::restore(x->impl(),next->impl(),header()->impl()); return false; } BOOST_CATCH(...){ node_impl_type::restore(x->impl(),next->impl(),header()->impl()); BOOST_RETHROW; } BOOST_CATCH_END } #if !defined(BOOST_MULTI_INDEX_DISABLE_SERIALIZATION) /* serialization */ template<typename Archive> void save_( Archive& ar,const unsigned int version,const index_saver_type& sm)const { save_(ar,version,sm,Category()); } template<typename Archive> void load_(Archive& ar,const unsigned int version,const index_loader_type& lm) { load_(ar,version,lm,Category()); } #endif #if defined(BOOST_MULTI_INDEX_ENABLE_INVARIANT_CHECKING) /* invariant stuff */ bool invariant_()const { if(size()==0||begin()==end()){ if(size()!=0||begin()!=end()|| header()->left()!=header()->impl()|| header()->right()!=header()->impl())return false; } else{ if((size_type)std::distance(begin(),end())!=size())return false; std::size_t len=node_impl_type::black_count( leftmost()->impl(),root()->impl()); for(const_iterator it=begin(),it_end=end();it!=it_end;++it){ node_type* x=it.get_node(); node_type* left_x=node_type::from_impl(x->left()); node_type* right_x=node_type::from_impl(x->right()); if(x->color()==red){ if((left_x&&left_x->color()==red)|| (right_x&&right_x->color()==red))return false; } if(left_x&&comp_(key(x->value()),key(left_x->value())))return false; if(right_x&&comp_(key(right_x->value()),key(x->value())))return false; if(!left_x&&!right_x&& node_impl_type::black_count(x->impl(),root()->impl())!=len) return false; if(!AugmentPolicy::invariant(x->impl()))return false; } if(leftmost()->impl()!=node_impl_type::minimum(root()->impl())) return false; if(rightmost()->impl()!=node_impl_type::maximum(root()->impl())) return false; } return super::invariant_(); } /* This forwarding function eases things for the boost::mem_fn construct * in BOOST_MULTI_INDEX_ORD_INDEX_CHECK_INVARIANT. Actually, * final_check_invariant is already an inherited member function of * ordered_index_impl. */ void check_invariant_()const{this->final_check_invariant_();} #endif protected: /* for the benefit of AugmentPolicy::augmented_interface */ node_type* header()const{return this->final_header();} node_type* root()const{return node_type::from_impl(header()->parent());} node_type* leftmost()const{return node_type::from_impl(header()->left());} node_type* rightmost()const{return node_type::from_impl(header()->right());} private: void empty_initialize() { header()->color()=red; /* used to distinguish header() from root, in iterator.operator++ */ header()->parent()=node_impl_pointer(0); header()->left()=header()->impl(); header()->right()=header()->impl(); } struct link_info { /* coverity[uninit_ctor]: suppress warning */ link_info():side(to_left){} ordered_index_side side; node_impl_pointer pos; }; bool link_point(key_param_type k,link_info& inf,ordered_unique_tag) { node_type* y=header(); node_type* x=root(); bool c=true; while(x){ y=x; c=comp_(k,key(x->value())); x=node_type::from_impl(c?x->left():x->right()); } node_type* yy=y; if(c){ if(yy==leftmost()){ inf.side=to_left; inf.pos=y->impl(); return true; } else node_type::decrement(yy); } if(comp_(key(yy->value()),k)){ inf.side=c?to_left:to_right; inf.pos=y->impl(); return true; } else{ inf.pos=yy->impl(); return false; } } bool link_point(key_param_type k,link_info& inf,ordered_non_unique_tag) { node_type* y=header(); node_type* x=root(); bool c=true; while (x){ y=x; c=comp_(k,key(x->value())); x=node_type::from_impl(c?x->left():x->right()); } inf.side=c?to_left:to_right; inf.pos=y->impl(); return true; } bool lower_link_point(key_param_type k,link_info& inf,ordered_non_unique_tag) { node_type* y=header(); node_type* x=root(); bool c=false; while (x){ y=x; c=comp_(key(x->value()),k); x=node_type::from_impl(c?x->right():x->left()); } inf.side=c?to_right:to_left; inf.pos=y->impl(); return true; } bool hinted_link_point( key_param_type k,node_type* position,link_info& inf,ordered_unique_tag) { if(position->impl()==header()->left()){ if(size()>0&&comp_(k,key(position->value()))){ inf.side=to_left; inf.pos=position->impl(); return true; } else return link_point(k,inf,ordered_unique_tag()); } else if(position==header()){ if(comp_(key(rightmost()->value()),k)){ inf.side=to_right; inf.pos=rightmost()->impl(); return true; } else return link_point(k,inf,ordered_unique_tag()); } else{ node_type* before=position; node_type::decrement(before); if(comp_(key(before->value()),k)&&comp_(k,key(position->value()))){ if(before->right()==node_impl_pointer(0)){ inf.side=to_right; inf.pos=before->impl(); return true; } else{ inf.side=to_left; inf.pos=position->impl(); return true; } } else return link_point(k,inf,ordered_unique_tag()); } } bool hinted_link_point( key_param_type k,node_type* position,link_info& inf,ordered_non_unique_tag) { if(position->impl()==header()->left()){ if(size()>0&&!comp_(key(position->value()),k)){ inf.side=to_left; inf.pos=position->impl(); return true; } else return lower_link_point(k,inf,ordered_non_unique_tag()); } else if(position==header()){ if(!comp_(k,key(rightmost()->value()))){ inf.side=to_right; inf.pos=rightmost()->impl(); return true; } else return link_point(k,inf,ordered_non_unique_tag()); } else{ node_type* before=position; node_type::decrement(before); if(!comp_(k,key(before->value()))){ if(!comp_(key(position->value()),k)){ if(before->right()==node_impl_pointer(0)){ inf.side=to_right; inf.pos=before->impl(); return true; } else{ inf.side=to_left; inf.pos=position->impl(); return true; } } else return lower_link_point(k,inf,ordered_non_unique_tag()); } else return link_point(k,inf,ordered_non_unique_tag()); } } void delete_all_nodes(node_type* x) { if(!x)return; delete_all_nodes(node_type::from_impl(x->left())); delete_all_nodes(node_type::from_impl(x->right())); this->final_delete_node_(static_cast<final_node_type*>(x)); } bool in_place(value_param_type v,node_type* x,ordered_unique_tag) { node_type* y; if(x!=leftmost()){ y=x; node_type::decrement(y); if(!comp_(key(y->value()),key(v)))return false; } y=x; node_type::increment(y); return y==header()||comp_(key(v),key(y->value())); } bool in_place(value_param_type v,node_type* x,ordered_non_unique_tag) { node_type* y; if(x!=leftmost()){ y=x; node_type::decrement(y); if(comp_(key(v),key(y->value())))return false; } y=x; node_type::increment(y); return y==header()||!comp_(key(y->value()),key(v)); } #if defined(BOOST_MULTI_INDEX_ENABLE_SAFE_MODE) void detach_iterators(node_type* x) { iterator it=make_iterator(x); safe_mode::detach_equivalent_iterators(it); } #endif template<BOOST_MULTI_INDEX_TEMPLATE_PARAM_PACK> std::pair<iterator,bool> emplace_impl(BOOST_MULTI_INDEX_FUNCTION_PARAM_PACK) { BOOST_MULTI_INDEX_ORD_INDEX_CHECK_INVARIANT; std::pair<final_node_type*,bool>p= this->final_emplace_(BOOST_MULTI_INDEX_FORWARD_PARAM_PACK); return std::pair<iterator,bool>(make_iterator(p.first),p.second); } template<BOOST_MULTI_INDEX_TEMPLATE_PARAM_PACK> iterator emplace_hint_impl( iterator position,BOOST_MULTI_INDEX_FUNCTION_PARAM_PACK) { BOOST_MULTI_INDEX_CHECK_VALID_ITERATOR(position); BOOST_MULTI_INDEX_CHECK_IS_OWNER(position,*this); BOOST_MULTI_INDEX_ORD_INDEX_CHECK_INVARIANT; std::pair<final_node_type*,bool>p= this->final_emplace_hint_( static_cast<final_node_type*>(position.get_node()), BOOST_MULTI_INDEX_FORWARD_PARAM_PACK); return make_iterator(p.first); } template<typename LowerBounder,typename UpperBounder> std::pair<iterator,iterator> range(LowerBounder lower,UpperBounder upper,none_unbounded_tag)const { node_type* y=header(); node_type* z=root(); while(z){ if(!lower(key(z->value()))){ z=node_type::from_impl(z->right()); } else if(!upper(key(z->value()))){ y=z; z=node_type::from_impl(z->left()); } else{ return std::pair<iterator,iterator>( make_iterator( lower_range(node_type::from_impl(z->left()),z,lower)), make_iterator( upper_range(node_type::from_impl(z->right()),y,upper))); } } return std::pair<iterator,iterator>(make_iterator(y),make_iterator(y)); } template<typename LowerBounder,typename UpperBounder> std::pair<iterator,iterator> range(LowerBounder,UpperBounder upper,lower_unbounded_tag)const { return std::pair<iterator,iterator>( begin(), make_iterator(upper_range(root(),header(),upper))); } template<typename LowerBounder,typename UpperBounder> std::pair<iterator,iterator> range(LowerBounder lower,UpperBounder,upper_unbounded_tag)const { return std::pair<iterator,iterator>( make_iterator(lower_range(root(),header(),lower)), end()); } template<typename LowerBounder,typename UpperBounder> std::pair<iterator,iterator> range(LowerBounder,UpperBounder,both_unbounded_tag)const { return std::pair<iterator,iterator>(begin(),end()); } template<typename LowerBounder> node_type * lower_range(node_type* top,node_type* y,LowerBounder lower)const { while(top){ if(lower(key(top->value()))){ y=top; top=node_type::from_impl(top->left()); } else top=node_type::from_impl(top->right()); } return y; } template<typename UpperBounder> node_type * upper_range(node_type* top,node_type* y,UpperBounder upper)const { while(top){ if(!upper(key(top->value()))){ y=top; top=node_type::from_impl(top->left()); } else top=node_type::from_impl(top->right()); } return y; } #if !defined(BOOST_MULTI_INDEX_DISABLE_SERIALIZATION) template<typename Archive> void save_( Archive& ar,const unsigned int version,const index_saver_type& sm, ordered_unique_tag)const { super::save_(ar,version,sm); } template<typename Archive> void load_( Archive& ar,const unsigned int version,const index_loader_type& lm, ordered_unique_tag) { super::load_(ar,version,lm); } template<typename Archive> void save_( Archive& ar,const unsigned int version,const index_saver_type& sm, ordered_non_unique_tag)const { typedef duplicates_iterator<node_type,value_compare> dup_iterator; sm.save( dup_iterator(begin().get_node(),end().get_node(),value_comp()), dup_iterator(end().get_node(),value_comp()), ar,version); super::save_(ar,version,sm); } template<typename Archive> void load_( Archive& ar,const unsigned int version,const index_loader_type& lm, ordered_non_unique_tag) { lm.load( ::boost::bind( &ordered_index_impl::rearranger,this, ::boost::arg<1>(),::boost::arg<2>()), ar,version); super::load_(ar,version,lm); } void rearranger(node_type* position,node_type *x) { if(!position||comp_(key(position->value()),key(x->value()))){ position=lower_bound(key(x->value())).get_node(); } else if(comp_(key(x->value()),key(position->value()))){ /* inconsistent rearrangement */ throw_exception( archive::archive_exception( archive::archive_exception::other_exception)); } else node_type::increment(position); if(position!=x){ node_impl_type::rebalance_for_erase( x->impl(),header()->parent(),header()->left(),header()->right()); node_impl_type::restore( x->impl(),position->impl(),header()->impl()); } } #endif /* serialization */ protected: /* for the benefit of AugmentPolicy::augmented_interface */ key_from_value key; key_compare comp_; #if defined(BOOST_MULTI_INDEX_ENABLE_INVARIANT_CHECKING)&&\ BOOST_WORKAROUND(__MWERKS__,<=0x3003) #pragma parse_mfunc_templ reset #endif }; template< typename KeyFromValue,typename Compare, typename SuperMeta,typename TagList,typename Category,typename AugmentPolicy > class ordered_index: public AugmentPolicy::template augmented_interface< ordered_index_impl< KeyFromValue,Compare,SuperMeta,TagList,Category,AugmentPolicy > >::type { typedef typename AugmentPolicy::template augmented_interface< ordered_index_impl< KeyFromValue,Compare, SuperMeta,TagList,Category,AugmentPolicy > >::type super; public: typedef typename super::ctor_args_list ctor_args_list; typedef typename super::allocator_type allocator_type; typedef typename super::iterator iterator; /* construct/copy/destroy * Default and copy ctors are in the protected section as indices are * not supposed to be created on their own. No range ctor either. */ ordered_index& operator=(const ordered_index& x) { this->final()=x.final(); return *this; } #if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST) ordered_index& operator=( std::initializer_list<BOOST_DEDUCED_TYPENAME super::value_type> list) { this->final()=list; return *this; } #endif protected: ordered_index( const ctor_args_list& args_list,const allocator_type& al): super(args_list,al){} ordered_index(const ordered_index& x):super(x){}; ordered_index(const ordered_index& x,do_not_copy_elements_tag): super(x,do_not_copy_elements_tag()){}; }; /* comparison */ template< typename KeyFromValue1,typename Compare1, typename SuperMeta1,typename TagList1,typename Category1, typename AugmentPolicy1, typename KeyFromValue2,typename Compare2, typename SuperMeta2,typename TagList2,typename Category2, typename AugmentPolicy2 > bool operator==( const ordered_index< KeyFromValue1,Compare1,SuperMeta1,TagList1,Category1,AugmentPolicy1>& x, const ordered_index< KeyFromValue2,Compare2,SuperMeta2,TagList2,Category2,AugmentPolicy2>& y) { return x.size()==y.size()&&std::equal(x.begin(),x.end(),y.begin()); } template< typename KeyFromValue1,typename Compare1, typename SuperMeta1,typename TagList1,typename Category1, typename AugmentPolicy1, typename KeyFromValue2,typename Compare2, typename SuperMeta2,typename TagList2,typename Category2, typename AugmentPolicy2 > bool operator<( const ordered_index< KeyFromValue1,Compare1,SuperMeta1,TagList1,Category1,AugmentPolicy1>& x, const ordered_index< KeyFromValue2,Compare2,SuperMeta2,TagList2,Category2,AugmentPolicy2>& y) { return std::lexicographical_compare(x.begin(),x.end(),y.begin(),y.end()); } template< typename KeyFromValue1,typename Compare1, typename SuperMeta1,typename TagList1,typename Category1, typename AugmentPolicy1, typename KeyFromValue2,typename Compare2, typename SuperMeta2,typename TagList2,typename Category2, typename AugmentPolicy2 > bool operator!=( const ordered_index< KeyFromValue1,Compare1,SuperMeta1,TagList1,Category1,AugmentPolicy1>& x, const ordered_index< KeyFromValue2,Compare2,SuperMeta2,TagList2,Category2,AugmentPolicy2>& y) { return !(x==y); } template< typename KeyFromValue1,typename Compare1, typename SuperMeta1,typename TagList1,typename Category1, typename AugmentPolicy1, typename KeyFromValue2,typename Compare2, typename SuperMeta2,typename TagList2,typename Category2, typename AugmentPolicy2 > bool operator>( const ordered_index< KeyFromValue1,Compare1,SuperMeta1,TagList1,Category1,AugmentPolicy1>& x, const ordered_index< KeyFromValue2,Compare2,SuperMeta2,TagList2,Category2,AugmentPolicy2>& y) { return y<x; } template< typename KeyFromValue1,typename Compare1, typename SuperMeta1,typename TagList1,typename Category1, typename AugmentPolicy1, typename KeyFromValue2,typename Compare2, typename SuperMeta2,typename TagList2,typename Category2, typename AugmentPolicy2 > bool operator>=( const ordered_index< KeyFromValue1,Compare1,SuperMeta1,TagList1,Category1,AugmentPolicy1>& x, const ordered_index< KeyFromValue2,Compare2,SuperMeta2,TagList2,Category2,AugmentPolicy2>& y) { return !(x<y); } template< typename KeyFromValue1,typename Compare1, typename SuperMeta1,typename TagList1,typename Category1, typename AugmentPolicy1, typename KeyFromValue2,typename Compare2, typename SuperMeta2,typename TagList2,typename Category2, typename AugmentPolicy2 > bool operator<=( const ordered_index< KeyFromValue1,Compare1,SuperMeta1,TagList1,Category1,AugmentPolicy1>& x, const ordered_index< KeyFromValue2,Compare2,SuperMeta2,TagList2,Category2,AugmentPolicy2>& y) { return !(x>y); } /* specialized algorithms */ template< typename KeyFromValue,typename Compare, typename SuperMeta,typename TagList,typename Category,typename AugmentPolicy > void swap( ordered_index< KeyFromValue,Compare,SuperMeta,TagList,Category,AugmentPolicy>& x, ordered_index< KeyFromValue,Compare,SuperMeta,TagList,Category,AugmentPolicy>& y) { x.swap(y); } } /* namespace multi_index::detail */ } /* namespace multi_index */ } /* namespace boost */ /* Boost.Foreach compatibility */ template< typename KeyFromValue,typename Compare, typename SuperMeta,typename TagList,typename Category,typename AugmentPolicy > inline boost::mpl::true_* boost_foreach_is_noncopyable( boost::multi_index::detail::ordered_index< KeyFromValue,Compare,SuperMeta,TagList,Category,AugmentPolicy>*&, boost::foreach::tag) { return 0; } #undef BOOST_MULTI_INDEX_ORD_INDEX_CHECK_INVARIANT #undef BOOST_MULTI_INDEX_ORD_INDEX_CHECK_INVARIANT_OF #endif
[ "zruilin@126.com" ]
zruilin@126.com
bd6606b8411b3ce8aedffd31d55deeacf48b1bd0
5eba8331c5ae0c71610fc3a7b6306ee2530da7ed
/OOConsoleChess/Pawn.cpp
4fb3f2f1c1643f034999b4fec6279e6b8272dcd6
[]
no_license
sifudiep/OOConsoleChess
46f6d5c47a1d5ddc521b5e18cf2471b7905ac910
3fe9f4468b0d44d84de46cbdbf0e5f562bf9d602
refs/heads/master
2023-02-09T03:32:23.060170
2021-01-09T14:13:12
2021-01-09T14:13:12
328,170,213
0
0
null
null
null
null
UTF-8
C++
false
false
18
cpp
#include "Pawn.h"
[ "code.sifudiep@gmail.com" ]
code.sifudiep@gmail.com
f9ccf07145cd1a47d73696a11173fcb1e5cc58a7
f05155d1c9c41fcc6e31686505f856fd2fbc06de
/2020/August/A. Boboniu Likes to Color Balls.cpp
3224da4954b514b08c788bea84e9d574db4dd4e2
[]
no_license
T-tasir/Competetive-Programming
22308db58c827a8dfa9d2f879f7a1c135f3ab96a
b56ab712fd2147a69b90b7300e281b9b6ed85852
refs/heads/main
2023-08-18T07:35:22.656508
2021-10-14T13:20:33
2021-10-14T13:20:33
368,572,215
0
0
null
null
null
null
UTF-8
C++
false
false
2,704
cpp
#include<bits/stdc++.h> using namespace std; typedef long long ll; typedef long double dl; typedef unsigned long long ull; #define pb push_back #define PB pop_back #define nn "\n" #define O_O ios_base::sync_with_stdio(false); cin.tie(NULL) #define all(p) p.begin(),p.end() #define zz(v) (ll)v.size() #define ss ' ' #define MEM(a,b) memset(a,(b),sizeof(a)) #define CLR(p) memset(p,0,sizeof(p)) #define f0(i,b) for(int i=0;i<(b);i++) #define f1(i,b) for(int i=1;i<=(b);i++) #define f2(i,a,b) for(int i=(a);i<=(b);i++) #define fr(i,b,a) for(int i=(b);i>=(a);i--) #define rep(i,a,b,c) for(int i=(a);i!=(b);i+=(c)) #define arrsize(a) (sizeof(a)/sizeof(a[0])) //#define arrsize(a) (sizeof(a)/sizeof(*a)) #define S(a) scanf("%lld",&a) #define SS(a,b) scanf("%lld %lld",&a,&b) #define SSS(a,b,c) scanf("%lld %lld %lld",&a,&b,&c) #define gcd(a,b) __gcd(a,b) #define lcm(a,b) (a*b)/gcd(a,b) #define pi acos(-1.0) #define ff first #define sc second typedef pair <int, int> pii; typedef pair <ll, ll> pll; typedef vector< pair <ll, ll> > vpll; typedef vector<ll> vll; typedef map<string,ll> msl; typedef map<ll,ll> mll; #define yes cout << "YES\n" #define no cout<<"NO\n" //memset(ar,-1,sizeof(ar)); //#define sort(x) sort(x.begin(), x.end()) //sort(a,a+n,greater<ll>()) //for (auto it = mp.begin(); it != mp.end(); ++it){} // string x(w.size(),'1'); #define MAX 1000005 #define precision(a) fixed << setprecision(a) #define mod 1000000007 ll ar[MAX]; int main() { //O_O ; ll t; cin>>t; while(t--){ ll x=0; for(ll i=0;i<4;i++){ cin>>ar[i]; } sort(ar,ar+3); ar[2]-=ar[0],ar[1]-=ar[0],ar[3]+=(3*ar[0]); ll c=0; if(ar[1]&1) c++; if(ar[2]&1) c++; if(ar[3]&1) c++; if(c==1||c==0) cout<<"Yes"<<nn; else { ll temp3=max(0LL,ar[0]-1); ar[2]+=ar[0],ar[1]+=ar[0],ar[3]-=(3*ar[0]); ar[2]-=temp3,ar[1]-=temp3,ar[3]-=(3*temp3); ar[0]-=temp3; ll c=0; if(ar[1]&1) c++; if(ar[2]&1) c++; if(ar[3]&1) c++; if(ar[0]&1) c++; if(c==1||c==0) cout<<"Yes"<<nn; else cout<<"No"<<nn; } } return 0; }
[ "allmoontasir256@gmail.com" ]
allmoontasir256@gmail.com
77212d713510b646d08c8467932634a3f7994eb5
c22920af4d1f47ba81b82b7e4da1fb88bfcdb35a
/Generic_Quicksort/quicksort.cpp
b54a2ea5cb7001d6621e982322f923530f8859ee
[]
no_license
BigRedT/Visual_Cpp_APIs
6cef66c11280005ed71a002e4e96405e2fd9c665
d3290a3092681ef52bdac1a6caadb551f2084686
refs/heads/master
2016-09-10T10:36:40.281945
2014-06-13T11:34:10
2014-06-13T11:34:10
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,009
cpp
#include <iostream> #include "quicksort.h" //template <class Item> bool Quicksort<Item>::less(Item x, Item y) { return x.compareTo(y)<0;} //template <class Item> void Quicksort <Item>::exch(Item itemArray[], int i, int j) { Item temp=itemArray[i]; itemArray[i]=itemArray[j]; itemArray[j]=temp; } //template <class Item> int Quicksort<Item>::partition(Item itemArray[], int lo, int hi) { int i=lo; int j=hi+1; while(true) { while(less(itemArray[++i],itemArray[lo])) { if(i==hi) { break;} } while(less(itemArray[lo],itemArray[--j])) { if(j==lo) { break;} } if(j<=i) { break;} exch(itemArray,i,j); } exch(itemArray,lo,j); return j; } //template <class Item> void Quicksort<Item>::sort(Item itemArray[], int lo, int hi) { if(lo>=hi) {return;} int j=partition(itemArray,lo,hi); sort(itemArray,lo,j-1); sort(itemArray,j+1,hi); } //template <class Item> void Quicksort<Item>::length(Item itemArray[]) { int len=sizeof(itemArray)/sizeof(Item); std::cout<<len<<itemArray[0].val; }
[ "tanmay2099@gmail.com" ]
tanmay2099@gmail.com
2cf5362d65292611ef3e2e64668c3ed38a2b7053
d0c44dd3da2ef8c0ff835982a437946cbf4d2940
/cmake-build-debug/programs_tiling/function14679/function14679_schedule_3/function14679_schedule_3_wrapper.cpp
3bd51f163a996f0053d6214e7b36a3bc4b528e5e
[]
no_license
IsraMekki/tiramisu_code_generator
8b3f1d63cff62ba9f5242c019058d5a3119184a3
5a259d8e244af452e5301126683fa4320c2047a3
refs/heads/master
2020-04-29T17:27:57.987172
2019-04-23T16:50:32
2019-04-23T16:50:32
176,297,755
1
2
null
null
null
null
UTF-8
C++
false
false
1,458
cpp
#include "Halide.h" #include "function14679_schedule_3_wrapper.h" #include "tiramisu/utils.h" #include <cstdlib> #include <iostream> #include <time.h> #include <fstream> #include <chrono> #define MAX_RAND 200 int main(int, char **){ Halide::Buffer<int32_t> buf00(1024); Halide::Buffer<int32_t> buf01(65536); Halide::Buffer<int32_t> buf02(1024); Halide::Buffer<int32_t> buf03(1024); Halide::Buffer<int32_t> buf04(65536); Halide::Buffer<int32_t> buf05(1024); Halide::Buffer<int32_t> buf06(1024); Halide::Buffer<int32_t> buf07(1024); Halide::Buffer<int32_t> buf08(65536); Halide::Buffer<int32_t> buf0(1024, 65536); init_buffer(buf0, (int32_t)0); auto t1 = std::chrono::high_resolution_clock::now(); function14679_schedule_3(buf00.raw_buffer(), buf01.raw_buffer(), buf02.raw_buffer(), buf03.raw_buffer(), buf04.raw_buffer(), buf05.raw_buffer(), buf06.raw_buffer(), buf07.raw_buffer(), buf08.raw_buffer(), buf0.raw_buffer()); auto t2 = std::chrono::high_resolution_clock::now(); std::chrono::duration<double> diff = t2 - t1; std::ofstream exec_times_file; exec_times_file.open("../data/programs/function14679/function14679_schedule_3/exec_times.txt", std::ios_base::app); if (exec_times_file.is_open()){ exec_times_file << diff.count() * 1000000 << "us" <<std::endl; exec_times_file.close(); } return 0; }
[ "ei_mekki@esi.dz" ]
ei_mekki@esi.dz
40c6bdf2f2f0ed181ceb830065332f1c7507e743
79edbfb898c02c92559f7b0a63a713f1dbb77518
/cparser/cgui.cpp
8055367c909dbede7134efe56fa5b9766da06f28
[ "MIT" ]
permissive
bajdcc/clibalgserver_mac
9cd076a5444ca80aaee82369364c9ed5ec3fb2e7
7a55d14eea3a2dab86cd0c73fbe7ae27bfd2e3b5
refs/heads/master
2020-08-07T10:03:21.960396
2019-10-08T04:07:49
2019-10-08T04:07:49
213,403,402
4
1
null
null
null
null
UTF-8
C++
false
false
38,371
cpp
// // Project: cliblisp // Created by bajdcc // #include <regex> #include <iostream> #include <fstream> #include <sstream> #include <sys/stat.h> #include "cgui.h" #include "cexception.h" #include "crev.h" #include "../rapidjson/document.h" #include "../rapidjson/writer.h" #include "../rapidjson/stringbuffer.h" #define ATLTRACE printf #ifdef REPORT_ERROR #undef REPORT_ERROR #endif #define REPORT_ERROR 0 #ifdef REPORT_ERROR_FILE #undef REPORT_ERROR_FILE #endif #define REPORT_ERROR_FILE "runtime.log" #define AST_FILE "ast.log" #define LOG_AST 0 #define LOG_DEP 0 #define ENTRY_FILE "/sys/entry" #define MAIN_FILE "/usr/main" using BYTE = uint8_t; using WORD = uint16_t; using DWORD = uint32_t; #define MAKE_ARGB(a, r, g, b) ((uint32_t)(((BYTE)(r)|((WORD)((BYTE)(g))<<8))|(((DWORD)(BYTE)(b))<<16)|(((DWORD)(BYTE)(a))<<24))) #define MAKE_RGB(r, g, b) MAKE_ARGB(255,r,g,b) #define GET_R(rgb) (LOBYTE(rgb)) #define GET_G(rgb) (LOBYTE(((WORD)(rgb)) >> 8)) #define GET_B(rgb) (LOBYTE((WORD)((rgb)>>16))) #define GET_A(rgb) (LOBYTE((rgb)>>24)) extern int g_argc; extern char **g_argv; namespace clib { cgui::cgui() { buffer = memory.alloc_array<char>((uint) size); assert(buffer); memset(buffer, 0, (uint) size); colors_bg = memory.alloc_array<uint32_t>((uint) size); assert(colors_bg); color_bg = 0; std::fill(colors_bg, colors_bg + size, color_bg); colors_fg = memory.alloc_array<uint32_t>((uint) size); assert(colors_fg); color_fg = MAKE_RGB(255, 255, 255); std::fill(colors_fg, colors_fg + size, color_fg); color_bg_stack.push_back(color_bg); color_fg_stack.push_back(color_fg); } string_t cgui::load_file(const string_t &name) { std::smatch res; string_t path; if (std::regex_match(name, res, re_path)) { path = FILE_ROOT + res[0].str() + ".cpp"; } if (path.empty()) error("file not exists: " + name); std::ifstream t(path); if (t) { std::stringstream buffer; buffer << t.rdbuf(); auto str = buffer.str(); std::vector<byte> data(str.begin(), str.end()); vm->as_root(true); vm->write_vfs(name, data); vm->as_root(false); return str; } std::vector<byte> data; if (vm->read_vfs(name, data)) { return string_t(data.begin(), data.end()); } error("file not exists: " + name); return ""; } bool cgui::exist_file(const string_t &name) { std::smatch res; string_t path; if (std::regex_match(name, res, re_path)) { path = FILE_ROOT + res[0].str() + ".cpp"; } if (path.empty()) return false; std::ifstream t(path); if (t) { return true; } if (vm->exist_vfs(name)) { return true; } return false; } bool cgui::exist_bin(const string_t &name) { std::smatch res; string_t path; if (std::regex_match(name, res, re_path)) { path = BIN_ROOT + res[0].str() + ".bin"; } if (path.empty()) return false; std::ifstream t(path); if (!t) { return false; } if (cache.find(name) != cache.end()) return true; std::ifstream ifs(path, std::ios::binary); if (ifs) { auto p = ifs.rdbuf(); auto size = p->pubseekoff(0, std::ios::end, std::ios::in); p->pubseekpos(0, std::ios::in); std::vector<byte> data; data.resize((size_t) size); p->sgetn((char *) data.data(), size); if (data.size() < 12) { return false; } if (strncmp((const char *) data.data(), "CCOS", 4) == 0) { if (strncmp((const char *) data.data() + 4, "TEXT", 4) == 0) { auto size2 = *((size_t *) (data.data() + 8)); if (size2 != data.size() - 12) return false; data.erase(data.begin(), data.begin() + 12); cache.insert(std::make_pair(name, data)); vm->as_root(true); vm->write_vfs(name + ".bin", crev::conv(data)); vm->as_root(false); return true; } } } return false; } bool cgui::save_bin(const string_t &name) { std::smatch res; string_t path; if (std::regex_match(name, res, re_path)) { path = BIN_ROOT + res[0].str() + ".bin"; } if (path.empty()) return false; std::ofstream ofs(path, std::ios::binary); if (ofs) { const auto &data = cache.at(name); vm->as_root(true); vm->write_vfs(name + ".bin", crev::conv(data)); vm->as_root(false); ofs.write("CCOSTEXT", 8); size = data.size(); ofs.write((const char *) &size, 4); ofs.write((const char *) data.data(), data.size()); return true; } return false; } long cgui::get_fs_time(const string_t &name, const string_t &ext) const { std::smatch res; string_t path; if (std::regex_match(name, res, re_path)) { path = BIN_ROOT + res[0].str() + ext; } if (path.empty()) return false; struct stat buf; FILE *pFile; pFile = fopen(path.c_str(), "r"); int fd = fileno(pFile); fstat(fd, &buf); long time = buf.st_mtime; fclose(pFile); return time; } void cgui::reset() { if (vm) { vm.reset(); gen.reset(); cvm::global_state.input_lock = -1; cvm::global_state.input_content.clear(); cvm::global_state.input_waiting_list.clear(); cvm::global_state.input_read_ptr = -1; cvm::global_state.input_success = false; cvm::global_state.input_code = 0; input_state = false; reset_cmd(); reset_cycles(); reset_ips(); } running = false; exited = false; } void cgui::draw(bool paused, decimal fps) { if (!paused) { if (cvm::global_state.interrupt) { cycle = GUI_CYCLES; } else if (cycle_set) { // ... } else if (cycle_stable > 0) { if (fps > GUI_MAX_FPS_RATE) { cycle = std::min(cycle << 1, GUI_MAX_CYCLE); } else if (fps < GUI_MIN_FPS_RATE) { cycle_stable--; } } else if (fps > GUI_MAX_FPS_RATE) { if (cycle_speed >= 0) { cycle_speed = std::min(cycle_speed + 1, GUI_MAX_SPEED); cycle = std::min(cycle << cycle_speed, GUI_MAX_CYCLE); } else { cycle_speed = 0; } } else if (fps < GUI_MIN_FPS_RATE) { if (cycle_speed <= 0) { cycle_speed = std::max(cycle_speed - 1, -GUI_MAX_SPEED); cycle = std::max(cycle >> (-cycle_speed), GUI_MIN_CYCLE); } else { cycle_speed = 0; } } else { if (cycle_stable == 0) { cycle_speed = 0; cycle_stable = GUI_CYCLE_STABLE; } } reset_ips(); for (int i = 0; i < ticks + cycle_speed; ++i) { tick(); } } } void cgui::reset_ips() { if (vm) vm->reset_ips(); } void cgui::tick() { if (exited) return; if (running) { try { if (!vm->run(cycle, cycles)) { running = false; exited = true; vm.reset(); gen.reset(); } } catch (const cexception &e) { ATLTRACE("[SYSTEM] ERR | RUNTIME ERROR: %s\n", e.message().c_str()); #if REPORT_ERROR { std::ofstream log(REPORT_ERROR_FILE, std::ios::app | std::ios::out); log << "[SYSTEM] ERR | RUNTIME ERROR: " << e.message() << std::endl; } #endif exited = true; running = false; //vm.reset(); //gen.reset(); //running = false; } } else { if (!vm) { vm = std::make_unique<cvm>(); vm->set_gui(this); { std::vector<byte> d(main_code.begin(), main_code.end()); vm->write_vfs(MAIN_FILE, d); } std::vector<string_t> args; if (g_argc > 0) { args.emplace_back(ENTRY_FILE); for (int i = 1; i < g_argc; ++i) { args.emplace_back(g_argv[i]); } } if (compile(ENTRY_FILE, args, decltype(args)()) != -1) { running = true; } } } } void cgui::put_string(const string_t &str) { for (auto &s : str) { put_char(s); } } void cgui::put_char(int c) { if (cmd_state) { if (c == '\033') { static string_t pat{R"([A-Za-z][0-9a-f]{1,8})"}; static std::regex re(pat); std::smatch res; string_t s(cmd_string.begin(), cmd_string.end()); if (std::regex_search(s, res, re)) { try { exec_cmd(s); } catch (const std::invalid_argument &) { // '/dev/random' : cause error } } cmd_string.clear(); cmd_state = false; } else { cmd_string.push_back(c); } return; } else if (c == '\033') { cmd_state = true; return; } if (c == 0) return; if (c == '\n') { ptr_x = 0; if (ptr_y == rows - 1) { new_line(); } else { ptr_y++; } } else if (c == '\b') { auto ascii = true; if (ptr_x != 0 || ptr_y != 0) { auto cc = buffer[ptr_y * cols + ptr_x - 1]; if (cc < 0) { WORD wd = (((BYTE) cc) << 8) | ((BYTE) buffer[ptr_y * cols + ptr_x]); if (wd >= 0x8140 && wd <= 0xFEFE) { // GBK ascii = false; } } } if (ptr_mx == -1 && ptr_my == -1 && ptr_x > 0) { forward(ptr_x, ptr_y, false); draw_char('\u0000'); if (!ascii) { forward(ptr_x, ptr_y, false); draw_char('\u0000'); } } else { if (ptr_mx + ptr_my * cols < ptr_x + ptr_y * cols) { forward(ptr_x, ptr_y, false); draw_char('\u0000'); if (!ascii) { forward(ptr_x, ptr_y, false); draw_char('\u0000'); } if (!(ptr_x == ptr_rx && ptr_y == ptr_ry)) { for (auto i = ptr_y * cols + ptr_x; i < ptr_ry * cols + ptr_rx; ++i) { buffer[i] = buffer[i + 1]; colors_bg[i] = colors_bg[i + 1]; colors_fg[i] = colors_fg[i + 1]; } buffer[ptr_ry * cols + ptr_rx] = '\0'; colors_bg[ptr_ry * cols + ptr_rx] = color_bg; colors_fg[ptr_ry * cols + ptr_rx] = color_fg; } forward(ptr_rx, ptr_ry, false); if (!ascii) { forward(ptr_rx, ptr_ry, false); } } } } else if (c == 0xff) { if (ptr_rx + ptr_ry * cols > ptr_x + ptr_y * cols) { move(false); put_char('\b'); } } else if (c == '\u0002') { ptr_x--; while (ptr_x >= 0) { draw_char('\u0000'); ptr_x--; } ptr_x = 0; } else if (c == '\r') { ptr_x = 0; } else if (c == '\f') { ptr_x = 0; ptr_y = 0; ptr_mx = 0; ptr_my = 0; ptr_rx = 0; ptr_ry = 0; memset(buffer, 0, (uint) size); std::fill(colors_bg, colors_bg + size, color_bg); std::fill(colors_fg, colors_fg + size, color_fg); } else { auto rx = ptr_rx == -1 ? ptr_x : ptr_rx; auto ry = ptr_ry == -1 ? ptr_y : ptr_ry; auto end = rx == cols - 1 && ry == rows - 1; auto nl = rx == ptr_x && rx == cols - 1; if (end) { if (nl) { draw_char(c); new_line(); ptr_x = 0; } else { new_line(); ptr_y--; draw_char(c); ptr_x++; } } else { draw_char(c); forward(ptr_x, ptr_y, true); } } } void cgui::input_char(char c) { input(c); } void cgui::new_line() { if (ptr_my != -1) { if (ptr_my == 0) { ptr_mx = ptr_my = 0; } else { ptr_my--; } } memcpy(buffer, buffer + cols, (uint) cols * (rows - 1)); memset(&buffer[cols * (rows - 1)], 0, (uint) cols); memcpy(colors_bg, colors_bg + cols, (uint) cols * (rows - 1) * sizeof(uint32_t)); std::fill(&colors_bg[cols * (rows - 1)], &colors_bg[cols * (rows)], color_bg); memcpy(colors_fg, colors_fg + cols, (uint) cols * (rows - 1) * sizeof(uint32_t)); std::fill(&colors_fg[cols * (rows - 1)], &colors_fg[cols * (rows)], color_fg); } void cgui::draw_char(const char &c) { if (input_state && c) { forward(ptr_rx, ptr_ry, true); if (!(ptr_x == ptr_rx && ptr_y == ptr_ry)) { for (auto i = ptr_ry * cols + ptr_rx; i > ptr_y * cols + ptr_x; --i) { buffer[i] = buffer[i - 1]; colors_bg[i] = colors_bg[i - 1]; colors_fg[i] = colors_fg[i - 1]; } } } buffer[ptr_y * cols + ptr_x] = c; colors_bg[ptr_y * cols + ptr_x] = color_bg; colors_fg[ptr_y * cols + ptr_x] = color_fg; } void cgui::error(const string_t &str) { throw cexception(ex_gui, str); } void cgui::set_cycle(int cycle) { if (cycle == 0) { cycle_set = false; this->cycle = GUI_CYCLES; } else { cycle_set = true; this->cycle = cycle; } } void cgui::set_ticks(int ticks) { this->ticks = ticks; } void cgui::move(bool left) { if (left) { if (ptr_mx + ptr_my * cols < ptr_x + ptr_y * cols) { forward(ptr_x, ptr_y, false); } } else { if (ptr_x + ptr_y * cols < ptr_rx + ptr_ry * cols) { forward(ptr_x, ptr_y, true); } } } void cgui::forward(int &x, int &y, bool forward) { if (forward) { if (x == cols - 1) { x = 0; if (y != rows - 1) { y++; } } else { x++; } } else { if (y == 0) { if (x != 0) { x--; } } else { if (x != 0) { x--; } else { x = cols - 1; y--; } } } } string_t cgui::input_buffer() const { auto begin = ptr_mx + ptr_my * cols; auto end = ptr_x + ptr_y * cols; std::stringstream ss; for (int i = begin; i <= end; ++i) { if (buffer[i]) ss << buffer[i]; } return ss.str(); } void cgui::resize(int r, int c) { if (r == 0 && c == 0) { r = GUI_ROWS; c = GUI_COLS; } auto old_rows = rows; auto old_cols = cols; rows = std::max(10, std::min(r, 60)); cols = std::max(20, std::min(c, 200)); ATLTRACE("[SYSTEM] GUI | Resize: from (%d, %d) to (%d, %d)\n", old_rows, old_cols, rows, cols); size = rows * cols; auto old_buffer = buffer; buffer = memory.alloc_array<char>((uint) size); assert(buffer); if (!buffer) error("gui memory overflow"); memset(buffer, 0, (uint) size); auto old_bg = colors_bg; colors_bg = memory.alloc_array<uint32_t>((uint) size); assert(colors_bg); if (!colors_bg) error("gui memory overflow"); std::fill(colors_bg, colors_bg + size, 0); auto old_fg = colors_fg; colors_fg = memory.alloc_array<uint32_t>((uint) size); assert(colors_fg); if (!colors_fg) error("gui memory overflow"); std::fill(colors_fg, colors_fg + size, MAKE_RGB(255, 255, 255)); auto min_rows = std::min(old_rows, rows); auto min_cols = std::min(old_cols, cols); auto delta_rows = old_rows - min_rows; for (int i = 0; i < min_rows; ++i) { for (int j = 0; j < min_cols; ++j) { buffer[i * cols + j] = old_buffer[(delta_rows + i) * old_cols + j]; colors_bg[i * cols + j] = old_bg[(delta_rows + i) * old_cols + j]; colors_fg[i * cols + j] = old_fg[(delta_rows + i) * old_cols + j]; } } ptr_x = std::min(ptr_x, cols); ptr_y = std::min(ptr_y, rows); ptr_mx = std::min(ptr_mx, cols); ptr_my = std::min(ptr_my, rows); ptr_rx = std::min(ptr_rx, cols); ptr_ry = std::min(ptr_ry, rows); memory.free(old_buffer); memory.free(old_fg); memory.free(old_bg); } std::unordered_set<string_t> cgui::get_dep(string_t &path) const { auto f = cache_code.find(path); if (f != cache_code.end()) { return cache_dep.at(path); } return std::unordered_set<string_t>(); } void cgui::set_main(const std::string &data) { main_code = data; } bool cgui::is_running() const { return !exited; } void cgui::load_dep(string_t &path, std::unordered_set<string_t> &deps) { auto f = cache_code.find(path); if (f != cache_code.end()) { deps.insert(cache_dep[path].begin(), cache_dep[path].end()); return; } auto code = load_file(path); static string_t pat_inc{"#include[ ]+\"([/A-Za-z0-9_-]+?)\""}; static std::regex re_inc(pat_inc); std::smatch res; auto begin = code.cbegin(); auto end = code.cend(); std::vector<std::tuple<int, int, string_t>> records; { auto offset = 0; while (std::regex_search(begin, end, res, re_inc)) { if (res[1].str() == path) { error("cannot include self: " + path); } if (offset + res.position() > 0) { if (code[offset + res.position() - 1] != '\n') { error("invalid include: " + res[1].str()); } } records.emplace_back(offset + res.position(), offset + res.position() + res.length(), res[1].str()); offset += std::distance(begin, res[0].second); begin = res[0].second; } } if (!records.empty()) { // has #include directive std::unordered_set<string_t> _deps; for (auto &r : records) { auto &include_path = std::get<2>(r); load_dep(include_path, _deps); _deps.insert(include_path); } std::stringstream sc; int prev = 0; for (auto &r : records) { auto &start = std::get<0>(r); auto &length = std::get<1>(r); if (prev < start) { auto frag = code.substr((uint) prev, (uint) (start - prev)); sc << frag; } auto incs = code.substr((uint) start, (uint) (length - start)); sc << "// => " << incs; prev = length; } if (prev < (int) code.length()) { auto frag = code.substr((uint) prev, code.length() - (uint) prev); sc << frag; } cache_code.insert(std::make_pair(path, sc.str())); cache_dep.insert(std::make_pair(path, _deps)); } else { // no #include directive cache_code.insert(std::make_pair(path, code)); cache_dep.insert(std::make_pair(path, std::unordered_set<string_t>())); } load_dep(path, deps); } string_t cgui::do_include(string_t &path) { // DAG solution for include std::vector<string_t> v; // VERTEX(Map id to name) std::unordered_map<string_t, int> deps; // VERTEX(Map name to id) { std::unordered_set<string_t> _deps; load_dep(path, _deps); if (_deps.empty()) return cache_code[path]; // no include _deps.insert(path); v.resize(_deps.size()); std::copy(_deps.begin(), _deps.end(), v.begin()); int i = 0; for (auto &d : v) { deps.insert(std::make_pair(d, i++)); } } auto n = v.size(); std::vector<std::vector<bool>> DAG(n); // DAG(Map id to id) std::unordered_set<size_t> deleted; std::vector<size_t> topo; // 拓扑排序 for (size_t i = 0; i < n; ++i) { DAG[i].resize(n); for (size_t j = 0; j < n; ++j) { auto &_d = cache_dep[v[i]]; if (_d.find(v[j]) != _d.end()) DAG[i][j] = true; } } // DAG[i][j] == true => i 包含 j for (size_t i = 0; i < n; ++i) { // 每次找出零入度点并删除 size_t right = n; for (size_t j = 0; j < n; ++j) { // 找出零入度点 if (deleted.find(j) == deleted.end()) { bool success = true; for (size_t k = 0; k < n; ++k) { if (DAG[j][k]) { success = false; break; } } if (success) { // 找到 right = j; break; } } } if (right != n) { for (size_t k = 0; k < n; ++k) { // 删除点 DAG[k][right] = false; } topo.push_back(right); deleted.insert(right); } } if (topo.size() != n) { error("topo failed: " + path); } #if LOG_DEP ATLTRACE("[SYSTEM] DEP | ---------------\n"); ATLTRACE("[SYSTEM] DEP | PATH: %s\n", path.c_str()); for (size_t i = 0; i < n; ++i) { ATLTRACE("[SYSTEM] DEP | [%d] ==> %s\n", i, v[topo[i]].c_str()); } ATLTRACE("[SYSTEM] DEP | ---------------\n"); #endif std::stringstream ss; for (auto &tp : topo) { ss << "pragma \"note:" << v[tp] << "\";" << std::endl; ss << cache_code[v[tp]] << std::endl; } return ss.str(); } int cgui::compile(const string_t &path, const std::vector<string_t> &args, const std::vector<string_t> &paths) { if (path.empty()) return -1; auto fail_errno = -1; auto new_path = path; auto bin_exist = false; if (path[0] != '/') { for (auto &p : paths) { auto pp = p == "/" ? ('/' + path) : (p + '/' + path); if (exist_bin(pp)) { new_path = pp; bin_exist = true; break; } } } else if (exist_bin(new_path)) { bin_exist = true; } if (bin_exist) { // 判断生成的二进制文件是否最新 // 即:生成时间大于代码修改时间 // 失败的话,就删除cache缓存 if (get_fs_time(new_path, ".cpp") > get_fs_time(new_path, ".bin")) { // FAILED cache.erase(new_path); } } else if (path[0] != '/') { for (auto &p : paths) { auto pp = p + '/' + path; if (exist_file(pp)) { new_path = pp; break; } } } try { auto c = cache.find(new_path); if (c != cache.end()) { return vm->load(new_path, c->second, args); } auto code = do_include(new_path); fail_errno = -2; gen.reset(); auto root = p.parse(code, &gen); #if LOG_AST { std::ofstream log(AST_FILE, std::ios::app | std::ios::out); log << std::endl << std::endl; cast::print(root, 0, log); log << std::endl << std::endl; } #endif gen.gen(new_path, root); auto file = gen.file(); p.clear_ast(); cache.insert(std::make_pair(new_path, file)); save_bin(new_path); return vm->load(new_path, file, args); } catch (const cexception &e) { gen.reset(); ATLTRACE("[SYSTEM] ERR | PATH: %s, %s\n", new_path.c_str(), e.message().c_str()); #if REPORT_ERROR { std::ofstream log(REPORT_ERROR_FILE, std::ios::app | std::ios::out); log << "[SYSTEM] ERR | PATH: " << new_path << ", " << e.message() << std::endl; } #endif return fail_errno; } } void cgui::input_set(bool valid) { if (valid) { input_state = true; ptr_mx = ptr_x; ptr_my = ptr_y; ptr_rx = ptr_x; ptr_ry = ptr_y; } else { input_state = false; ptr_mx = -1; ptr_my = -1; ptr_rx = -1; ptr_ry = -1; } input_ticks = 0; input_caret = false; } void cgui::input(int c) { if (c == 3) { cvm::global_state.interrupt = true; cmd_state = false; if (input_state) { ptr_x = ptr_rx; ptr_y = ptr_ry; put_char('\n'); cvm::global_state.input_content.clear(); cvm::global_state.input_read_ptr = 0; cvm::global_state.input_success = true; cvm::global_state.input_code = 0; input_state = false; cvm::global_state.input_single = false; } return; } if (!input_state) return; if (cvm::global_state.input_single) { if (c > 0 && c < 256 && (std::isprint(c) || c == '\r')) { if (c == '\r') c = '\n'; put_char(c); ptr_x = ptr_rx; ptr_y = ptr_ry; string_t s; s += c; cvm::global_state.input_content = s; cvm::global_state.input_read_ptr = 0; cvm::global_state.input_success = true; cvm::global_state.input_code = 0; cvm::global_state.input_single = false; input_state = false; } return; } if (c < 0) { put_char(c); return; } if (c < 0xffff && c > 0xff) { return; } if (!((c & GUI_SPECIAL_MASK) || std::isprint(c) || c == '\b' || c == '\n' || c == '\r' || c == 4 || c == 7 || c == 26 || c == 22)) { return; } if (c == '\b') { put_char('\b'); return; } if (c == '\r' || c == 4 || c == 26) { ptr_x = ptr_rx; ptr_y = ptr_ry; put_char('\n'); cvm::global_state.input_content = input_buffer(); cvm::global_state.input_read_ptr = 0; cvm::global_state.input_success = true; cvm::global_state.input_code = 0; input_state = false; return; } if (c & GUI_SPECIAL_MASK) { cvm::global_state.input_content = input_buffer(); cvm::global_state.input_read_ptr = 0; cvm::global_state.input_success = true; cvm::global_state.input_code = -9; input_state = false; auto begin = ptr_mx + ptr_my * cols; auto end = ptr_x + ptr_y * cols; for (int i = begin; i <= end; ++i) { buffer[i] = 0; colors_bg[i] = color_bg; colors_fg[i] = color_fg; } ptr_x = ptr_mx; ptr_y = ptr_my; ptr_rx = ptr_mx; ptr_ry = ptr_my; } else if (c == 22) { // Ctrl+V } else { put_char((char) (c & 0xff)); } } void cgui::reset_cmd() { cmd_state = false; cmd_string.clear(); } int cgui::reset_cycles() { auto c = cycles; cycles = 0; return c; } void cgui::exec_cmd(const string_t &s) { switch (s[0]) { case 'B': { // 设置背景色 color_bg = (uint32_t) std::stoul(s.substr(1), nullptr, 16); } break; case 'F': { // 设置前景色 color_fg = (uint32_t) std::stoul(s.substr(1), nullptr, 16); } break; case 'S': { // 设置 int cfg; cfg = (uint32_t) std::stoul(s.substr(1), nullptr, 10); switch (cfg) { case 0: { // 换行 if (ptr_x > 0) { ptr_x = 0; if (ptr_y == rows - 1) { new_line(); } else { ptr_y++; } } } break; case 1: // 保存背景色 color_bg_stack.push_back(color_bg); break; case 2: // 保存前景色 color_fg_stack.push_back(color_fg); break; case 3: // 恢复背景色 color_bg = color_bg_stack.back(); if (color_bg_stack.size() > 1) color_bg_stack.pop_back(); break; case 4: // 恢复前景色 color_fg = color_fg_stack.back(); if (color_fg_stack.size() > 1) color_fg_stack.pop_back(); break; default: break; } } break; default: break; } } static inline std::string &ltrim(std::string &s) { s.erase(s.begin(), std::find_if(s.begin(), s.end(), std::not1(std::ptr_fun<int, int>(std::isspace)))); return s; } static inline std::string &rtrim(std::string &s) { s.erase(std::find_if(s.rbegin(), s.rend(), std::not1(std::ptr_fun<int, int>(std::isspace))).base(), s.end()); return s; } static inline std::string &trim(std::string &s) { return ltrim(rtrim(s)); } std::string cgui::output() const { std::stringstream ss; for (auto i = 0; i < rows; ++i) { for (auto j = 0; j < cols; ++j) { auto c = buffer[i * cols + j]; if (c > 0) { if (std::isprint(buffer[i * cols + j])) { ss << buffer[i * cols + j]; } else { ss << " "; } } else if (c < 0) { ss << c; } } ss << std::endl; } auto output = ss.str(); return trim(output); } std::string cgui::tracer() const { enum trace_type { T_CHAR, T_INT, }; std::stringstream ss; char sz[256]; for (const auto &r : trace_records) { if (r.method == T_MESSAGE) { ss << "Message: " << r.message << std::endl; continue; } ss << "Name: " << r.name << ", "; if (r.method == T_UPDATE) ss << " Method: Update, "; else if (r.method == T_CREATE) ss << " Method: Create, "; else if (r.method == T_DESTROY) { ss << " Method: Destroy" << std::endl; continue; } if (r.type == T_INT) snprintf(sz, sizeof(sz), "Type: int, Value: %d", r.data._i); else if (r.type == T_CHAR) snprintf(sz, sizeof(sz), "Type: char, Value: %c", r.data._c); else continue; ss << sz; if (!r.loc.empty()) { auto N = r.loc.size(); if (N == 1) { snprintf(sz, sizeof(sz), ", Index: %d", r.loc[0]); } else if (N == 2) { snprintf(sz, sizeof(sz), ", Index: %d,%d", r.loc[0], r.loc[1]); } ss << sz; } ss << std::endl; } return ss.str(); } std::string cgui::tracer_json() const { using namespace rapidjson; Document d; auto &allocator = d.GetAllocator(); d.SetObject(); if (trace_records.empty()) { auto o = output(); if (o.empty()) { return "{\"code\":400,\"error\":\"empty tracer and output\"}"; } d.AddMember("code", Value(400), allocator); d.AddMember("error", StringRef(o.c_str()), allocator); StringBuffer buffer; Writer<StringBuffer> writer(buffer); d.Accept(writer); return buffer.GetString(); } d.AddMember("code", Value(200), allocator); enum trace_type { T_CHAR, T_INT, }; Value arr(kArrayType); for (const auto &r : trace_records) { Value obj(kObjectType); auto method = StringRef("method"); auto type = StringRef("type"); auto value = StringRef("value"); if (r.method == T_MESSAGE) { obj.AddMember(method, "msg", allocator); obj.AddMember(value, StringRef(r.message.c_str()), allocator); arr.PushBack(obj, allocator); continue; } if (r.method == T_DELAY) { obj.AddMember(method, "delay", allocator); arr.PushBack(obj, allocator); continue; } obj.AddMember("name", StringRef(r.name.c_str()), allocator); if (r.method == T_UPDATE) { obj.AddMember(method, "update", allocator); if (r.rapid) obj.AddMember("rapid", Value(true), allocator); } else if (r.method == T_CREATE) { obj.AddMember(method, "create", allocator); if (r.chart && r.type == T_INT) obj.AddMember("chart", Value(r.chart), allocator); if (!r.message.empty()) obj.AddMember(value, StringRef(r.message.c_str()), allocator); } else if (r.method == T_DESTROY) { obj.AddMember(method, "destroy", allocator); arr.PushBack(obj, allocator); continue; } if (r.type == T_INT) { obj.AddMember(type, "int", allocator); if (r.method == T_UPDATE) obj.AddMember(value, r.data._i, allocator); } else if (r.type == T_CHAR) { obj.AddMember(type, "char", allocator); if (r.method == T_UPDATE) obj.AddMember(value, r.data._c, allocator); } else continue; if (!r.loc.empty()) { Value loc(kArrayType); for (auto &l : r.loc) { loc.PushBack(Value(l), allocator); } obj.AddMember("loc", loc, allocator); } arr.PushBack(obj, allocator); } d.AddMember("data", arr, allocator); StringBuffer buffer; Writer<StringBuffer> writer(buffer); d.Accept(writer); return buffer.GetString(); } }
[ "bajdcc@foxmail.com" ]
bajdcc@foxmail.com
63624a3fbe66499fb9b4c46b345a523a9384d55b
6b2a8dd202fdce77c971c412717e305e1caaac51
/solutions_6404600001200128_0/C++/MiroB/A.cpp
387ee693dced16f80323a843ea6c66edfb47df1d
[]
no_license
alexandraback/datacollection
0bc67a9ace00abbc843f4912562f3a064992e0e9
076a7bc7693f3abf07bfdbdac838cb4ef65ccfcf
refs/heads/master
2021-01-24T18:27:24.417992
2017-05-23T09:23:38
2017-05-23T09:23:38
84,313,442
2
4
null
null
null
null
UTF-8
C++
false
false
624
cpp
#include<iostream> #include<vector> #include<set> #include<queue> #include<algorithm> #include<map> #include<string> using namespace std; #define REP(i,n) for(int i=0;i<(int)n;++i) void solve() { int n;cin>>n; vector<int> a(n);REP(i,n) cin>>a[i]; int rval1=0; int rval2=0; vector<int> b; int md=0; REP(i,n) if(i) { int delta=a[i]-a[i-1]; md=max(md, -delta); if(delta<0) rval1-=delta; } REP(i,n-1) { rval2+=min(md,a[i]); } cout<<rval1<<" "<<rval2; } int main() { int T;cin>>T; REP(i,T) { cout<<"Case #"<<(i+1)<<": "; solve(); cout<<endl; } }
[ "eewestman@gmail.com" ]
eewestman@gmail.com
c6914f05bab781ff25c7bc1d8f257fc013e4594e
2cf3ebedd9f0c5a23fe14dd61e15fad9ba3b916f
/Programming Assignment 2/Programming Assignment 2/Math Tutor.cpp
57c5c2e3bbad57d8570dac416c7e3daaa866e422
[]
no_license
Slidejiveman/Programming1
395deaae6de0ff7d6ad4733a7d962af3247c7385
273d21641b0f498bf24996438b52ad64aece0c54
refs/heads/master
2021-08-19T07:04:44.097280
2017-11-25T03:07:40
2017-11-25T03:07:40
111,948,546
0
0
null
null
null
null
UTF-8
C++
false
false
1,275
cpp
//==================================================================== // Ryder Dale Walton //9-26-14 //Programming Assignment #2 //Description: Math Tutor //==================================================================== /*This program performs basic addition using random numbers in a way conducive to pedagogy by displaying two numbers for the student to add. The answer is not shown until return is pressed.*/ #include <iostream> #include <iomanip> #include <cstdlib> #include <ctime> using namespace std; int main() { int number1, number2; //to store random numbers to be added int sum; //to store the total after addition unsigned seed = time(0); //to hold system time and generate truer rands const int MIN_VALUE = 1; //to hold the lower end of random number range const int MAX_VALUE = 99; //to hold higher end as per instructions srand(seed); number1 = (rand() % (MAX_VALUE - MIN_VALUE + 1)) + MIN_VALUE; number2 = (rand() % (MAX_VALUE - MIN_VALUE + 1)) + MIN_VALUE; cout << setw(4) << right << number1 << endl; cout << left << "+" << setw(3) << right << number2 << endl; cout << right << "____" << endl; cin.get(); //calculate the sum of the two numbers sum = number1 + number2; cout << setw(4) << right << sum << endl; return 0; }
[ "rdnotlaw91@outlook.com" ]
rdnotlaw91@outlook.com
208ac33085554bac2d90050cbace76af841bafaf
1174bf984d3a4fe1dddd67dd58cb0509770f6049
/mcu/lab8-2/src/lab8-2.cpp
1cd133ae562695486d805c7012898aad1c3753c9
[]
no_license
arsiarola/amk-year3
cad86350c89b68be35f49293d56d6f27e3bb846f
74af15226358776fda7eba5a4923071270559cdd
refs/heads/main
2023-04-12T08:19:49.433668
2021-04-29T18:07:28
2021-04-29T18:07:28
305,695,580
0
0
null
null
null
null
UTF-8
C++
false
false
6,369
cpp
/* =============================================================================== Name : main.c Author : $(author) Version : Copyright : $(copyright) Description : main definition =============================================================================== */ #if defined (__USE_LPCOPEN) #if defined(NO_BOARD_LIB) #include "chip.h" #else #include "board.h" #endif #endif #include <stdio.h> #include <string.h> #include <cr_section_macros.h> #include "FreeRTOS.h" #include "semphr.h" #include "ITM_write.h" #include "DigitalIoPin.h" #include "LpcUart.h" LpcPinMap none = { .port = -1, .pin = -1}; // unused pin has negative values in it LpcPinMap txpin1 = { .port = 0, .pin = 18 }; // transmit pin LpcPinMap rxpin1 = { .port = 0, .pin = 13 }; // receive pin LpcUartConfig cfg1 = { .pUART = LPC_USART0, .speed = 115200, .data = UART_CFG_DATALEN_8 | UART_CFG_PARITY_NONE | UART_CFG_STOPLEN_1, .rs485 = false, .tx = txpin1, .rx = rxpin1, .rts = none, .cts = none }; LpcUart *uart; static QueueHandle_t queue; static TickType_t filter = 50; // ms static void prvSetupHardware(void) { SystemCoreClockUpdate(); Board_Init(); /* Initial LED0 state is off */ Board_LED_Set(0, false); } typedef struct ButtonPress_t { int buttonNum; TickType_t tick; } ButtonPress; static void handleButton(int isrNum, int buttonNum) { Chip_PININT_ClearIntStatus(LPC_GPIO_PIN_INT, PININTCH(isrNum)); portBASE_TYPE xHigherPriorityWoken = pdFALSE; ButtonPress press = { .buttonNum = buttonNum, .tick = xTaskGetTickCountFromISR() }; xQueueSendToBack(queue, &(press), 0); portEND_SWITCHING_ISR(xHigherPriorityWoken); } extern "C" { void PIN_INT0_IRQHandler(void) { handleButton(0, 1); } void PIN_INT1_IRQHandler(void) { handleButton(1, 2); } void PIN_INT2_IRQHandler(void) { handleButton(2, 3); } } static void msToString(char *buffer, int size, int ms) { if (ms < 1000) snprintf(buffer, size, "%dms", ms); else if (ms >= 1000) snprintf(buffer, size, "%.2fs", (float)ms/1000); else if (ms >= 60000) snprintf(buffer, size, "%.2fm", (float)ms/60000); } static void task1(void *pvParameters) { TickType_t lastPress = 0; ButtonPress press; char time[8]; while (1) { if (xQueueReceive(queue, &press, portMAX_DELAY) == pdPASS) { TickType_t pressTime = press.tick - lastPress; msToString(time, 8, pressTime); if (pressTime > filter) { ITM_print("Button %d, %s\n", press.buttonNum, time); } else { ITM_print("Too fast press %s\n", time); } lastPress = press.tick; } } } #define STR_SIZE 80 #define BUF_SIZE 128 #define CMD_SIZE 32 #define MSG_SIZE 64 static void task2(void *pvParameters) { char str[STR_SIZE] = ""; char buf[BUF_SIZE] = ""; char cmd[CMD_SIZE] = ""; char msg[MSG_SIZE] = ""; int received; uint8_t index = 0; char c; while (1) { // reading one at a time just so we can have backspace functioning correctly // in the terminal (doesnt erase the character by default just moves cursor back) received = uart->read(c); if (received > 0) { uart->write(c); // Backspace functionality for better usability // 8 ascii = backspace if (c == 8 && index > 0) { uart->write(' '); uart->write(8); --index; } else buf[index++] = c; if (c != '\n' && c != '\r' && index < BUF_SIZE-1) { continue; } uart->write("\n\r"); buf[index] = '\0'; // buf hasnt been terminated yet ITM_print("buf: %s\n", buf); TickType_t value; if (sscanf(buf, "%s", cmd) == 1 && strcmp(cmd, "filter") == 0) { if (sscanf(buf, "%*s %u", &value) == 1) { filter = value; snprintf(msg, MSG_SIZE, "Filter updated to %u\n\r", filter); uart->write(msg); } } buf[0] = '\0'; index = 0; } } } int main(void) { prvSetupHardware(); ITM_init(); queue = xQueueCreate(10, sizeof(ButtonPress)); uart = new LpcUart(cfg1); Chip_PININT_Init(LPC_GPIO_PIN_INT); Chip_Clock_EnablePeriphClock(SYSCTL_CLOCK_PININT); Chip_SYSCTL_PeriphReset(RESET_PININT); /* Confiure interrupts */ // sw1 Chip_IOCON_PinMuxSet(LPC_IOCON, 0, 17, IOCON_DIGMODE_EN | IOCON_MODE_INACT | IOCON_MODE_PULLUP); Chip_INMUX_PinIntSel(0, 0, 17); Chip_PININT_ClearIntStatus(LPC_GPIO_PIN_INT, PININTCH(0)); Chip_PININT_SetPinModeEdge(LPC_GPIO_PIN_INT, PININTCH(0)); Chip_PININT_EnableIntLow(LPC_GPIO_PIN_INT, PININTCH(0)); NVIC_ClearPendingIRQ(PIN_INT0_IRQn); NVIC_EnableIRQ(PIN_INT0_IRQn); // sw2 Chip_IOCON_PinMuxSet(LPC_IOCON, 1, 11, IOCON_DIGMODE_EN | IOCON_MODE_INACT | IOCON_MODE_PULLUP); Chip_INMUX_PinIntSel(1, 1, 11); Chip_PININT_ClearIntStatus(LPC_GPIO_PIN_INT, PININTCH(1)); Chip_PININT_SetPinModeEdge(LPC_GPIO_PIN_INT, PININTCH(1)); Chip_PININT_EnableIntLow(LPC_GPIO_PIN_INT, PININTCH(1)); NVIC_ClearPendingIRQ(PIN_INT1_IRQn); NVIC_EnableIRQ(PIN_INT1_IRQn); // sw3 Chip_INMUX_PinIntSel(2, 1, 9); Chip_IOCON_PinMuxSet(LPC_IOCON, 1, 9, IOCON_DIGMODE_EN | IOCON_MODE_INACT | IOCON_MODE_PULLUP); Chip_PININT_ClearIntStatus(LPC_GPIO_PIN_INT, PININTCH(2)); Chip_PININT_SetPinModeEdge(LPC_GPIO_PIN_INT, PININTCH(2)); Chip_PININT_EnableIntLow(LPC_GPIO_PIN_INT, PININTCH(2)); NVIC_ClearPendingIRQ(PIN_INT2_IRQn); NVIC_EnableIRQ(PIN_INT2_IRQn); xTaskCreate(task1, "task1", configMINIMAL_STACK_SIZE + 512, NULL, (tskIDLE_PRIORITY + 2UL),(TaskHandle_t *) NULL); xTaskCreate(task2, "read", configMINIMAL_STACK_SIZE + 512, NULL, (tskIDLE_PRIORITY + 2UL),(TaskHandle_t *) NULL); /* Start the scheduler */ vTaskStartScheduler(); return 1; }
[ "1andre234@gmail.com" ]
1andre234@gmail.com
f21fd71df3bae6ca305bf62ed0972ef74e1621ad
9f2296f21b08bb8f62b1710ecaf1eaad573e3bf8
/DFS BFS/DFS와 BFS.cpp
5b956f73918ae5cb5985a893f6f9edef40b2948a
[]
no_license
esm712/alcuk
b0ea0ee2fa506db57da539e665c9123a22f4be22
855d44cfe923359db1849971adaad5dbad175384
refs/heads/master
2023-03-27T08:20:42.967301
2021-03-26T15:03:33
2021-03-26T15:03:33
345,849,926
0
0
null
null
null
null
UTF-8
C++
false
false
1,140
cpp
#include<iostream> #include<algorithm> #include<vector> #include<queue> using namespace std; vector<int> graph[1001]; int visited_dfs[1001]; int visited_bfs[1001]; queue<int> out; void dfs(int num){ visited_dfs[num]=1; cout << num << " "; for(int i=0; i<graph[num].size(); i++){ int a=graph[num][i]; if(visited_dfs[a]==0){ dfs(a); } } } void bfs(int num){ visited_bfs[num]=1; out.push(num); while(out.empty()==0){ int check_1=out.front(); out.pop(); cout << check_1 << " "; for(int i=0; i<graph[check_1].size(); i++){ int check_2=graph[check_1][i]; if(visited_bfs[check_2]==0){ visited_bfs[check_2]=1; out.push(check_2); } } } } int main(void){ int N, M, V; cin >> N >> M >> V; for(int i=0; i<M; i++){ int x, y; cin >> x >> y; graph[x].push_back(y); graph[y].push_back(x); } for(int i=1; i<=N; i++){ sort(graph[i].begin(),graph[i].end()); } dfs(V); cout << "\n"; bfs(V); return 0; }
[ "712esm@hanmail.net" ]
712esm@hanmail.net
af13b91cb1f2cc16e7d024534bba5b589c561950
4a0d837d1a5fb6542513f629e975d89ab3898928
/cpp/school/cw1.cpp
952cbab906a1b0c9be6c22593a1b4559824b2f50
[]
no_license
kubajestem/kody
c9b00c9adafc766f1858594626d98fd848eb656e
d59b56b94b3fd849ba859067f1729cac54389f31
refs/heads/master
2021-01-25T17:05:25.966422
2019-03-04T12:09:41
2019-03-04T12:09:41
102,843,651
0
0
null
null
null
null
UTF-8
C++
false
false
718
cpp
/* * sumuj.cpp * */ // iteracja - powtarzanie czegoś // for - powatarzanie czegos - petla // klamry wyodrebiają blok kodu #include <iostream> using namespace std; int main(int argc, char **argv) { // iteracja int i; int kwadrat = 0; // suma kolejnych liczb int liczba = 0; //liczba wprowadzana cout << "Ile liczb podasz?"; cin >> ile_razy; for (i = 0; i >= 0; i++) // powtarza okresloną ilosc razy 1. wartosc zmiennej 2.warunek, 3. co ma sie stac { cout << "Podaj liczbę całkowitą dodatnią: " << endl; cin >> liczba; kwadrat = liczba * liczba } cout << "kwadrat: " << kwadrat << endl; return 0; }
[ "kubacpsz@op.pl" ]
kubacpsz@op.pl
2d8e134195693034503ec17ccf9308e5f40f3052
307573c28f79bbaff172f22b9e18124b4e04dfbc
/source/Dtool.h
e41566783c17e9e3cc32336f503a8b19b4ddced5
[]
no_license
anoano/SnapPRS
a2f5103aeec7ed6ed82605e1b1bb13cf728b9564
b329d0bdd8f9ee7d5f60ebed853b90dd23c98bee
refs/heads/master
2021-01-23T12:25:54.624728
2017-06-06T15:56:37
2017-06-06T15:56:37
38,923,281
0
0
null
null
null
null
SHIFT_JIS
C++
false
false
8,350
h
#ifndef _DTOOL_H_ #define _DTOOL_H_ #include "c4d_symbols.h" #include "c4d.h" #include "lib_collider.h" #include "lib_clipmap.h" #include "SnapTransfer.h" #include "SnapRotate.h" #include "SnapScale.h" #include "c4d_descriptiondialog.h" #include "operatingsystem.h" #include "lib_splinehelp.h" #include "lib_selectionchanger.h" #include "c4d_snapdata.h" #include "lib_sculpt.h" #include "lib_ngon.h" #include <cmath> #include "c4d_quaternion.h" #include "ge_sort.h" #include "lib_modeling.h" #define sn_size 16 #define ID_BITMAPBTN_SAVE 22000000 struct Mobj { Vector *vv; //ポイント座標 Matrix Mmg; Int32 scnt; //選択ポイント数 Int32 *pnum; //選択ポリゴンを構成するポイントイID用配列 Int32 *Snum; //選択ポリゴンID格納用配列 Int32 Fcnt; //選択ポリゴン数 Int32 Ecnt; //選択エッジ数 Int32 *Enum; //選択エッジID UChar* emap; Int32 SEcnt; BaseObject *op; }; ////////////////////////////////////////////////////////////////// //クラス定義 class DTOOL { private: public: DTOOL(); // DTOOL( Matrix *mg, Vector *P1, Vector *P2, Vector *P3, Int32 *STEP, Int32 *SFlag, Vector *nvec, Vector *Snp, Vector *Gmpoint, BaseObject *obj); virtual ~DTOOL(); void printcheck( String st,Vector p); void printcheckR( String st,Vector p); Bool FuzzyPointInRange(BaseContainer &data, BaseDraw *bd, Vector &p, Float mx = 0, Float my = 0); Bool CheckSnpPoint( BaseDraw *bd, BaseContainer &data, BaseObject *obj, Float mx, Float my, Int32 *ID_POINT); Bool GetObjectFace(BaseDocument *doc, BaseDraw *bd, BaseContainer& data, Float x, Float y ,Int32 *Pindex, Int32 *PointID ); BaseObject* GetObjectFaceOBJ(BaseDocument *doc, BaseDraw *bd, BaseContainer& data, Float x, Float y ,Int32 *Pindex, Bool flag); //Bool SetGridPlane(BaseDocument *doc, BaseContainer &data, BaseDraw *bd, BaseDrawHelp* bh, Matrix mg); //Vector GetPointNormalVector( BaseObject *mo ,Int32 index); Bool Get3PointNormMg( Vector a, Vector b, Vector c ); Bool GetLineEdge( BaseDraw *bd, BaseContainer &data, BaseObject *obj, Float mx, Float my, Int32 *index ); Bool DispMarker(BaseDocument *doc, BaseDraw *bd, BaseDrawHelp *bh, BaseContainer &data, Matrix EndMg, Vector G_markpoint, Bool PlaneSet_Flag, Bool G_SnapFlag, Bool PlaneSet_BTNFlag, Matrix FaceMg, Float mx, Float my, Int32 type); Bool DrawTextA(String text,Vector xpos, Float p, BaseDraw *bd, Int32 EdgeID ); Vector ScreenToWorld(const Vector& pp, BaseDraw* bd, Int32 projection); //Vector SnapMouseVector( BaseDocument *doc, BaseContainer &data,BaseDraw *bd, Float x, Float y, Vector G_basePos, Matrix G_mg, Int32 *G_SnapFlag, Int32 G_STEP, Vector G_markpoint, Vector G_P2, Vector *G_nvec, Bool PlaneSet_Flag, Matrix* SNmg, BaseObject** _Starget, Int32* SnapID); BaseObject* GetObjectFaceID(BaseDocument *doc, BaseDraw *bd, BaseContainer& data, Float x, Float y ,Int32 *Pindex); Vector NonObjCursor( BaseDocument *doc, BaseDraw *bd, BaseContainer &data, Float px, Float py, Matrix Amg, Int32 G_STEP, Vector P1, Vector P2, Vector *G_nvec,Bool PL_flag); void search_hierarchy(BaseObject *obj1, BaseObject *obj2,AtomArray *arr); Vector GetNormlVector(Matrix Mtg); Bool ViewSet( BaseDraw *bd,Vector *vm ); Vector GetZpoint( BaseDocument *doc, BaseContainer &data, BaseDraw *bdd, Vector Nplane, Float *mx, Float *my, Vector Bpos, Int32 step, Vector nov); Vector ConstAngleFase( BaseDocument *doc, BaseContainer &data, Vector v1, Vector v2, Float Ang, Matrix mg ); Vector ConstAngle( BaseDocument *doc, BaseContainer &data, Vector v1, Vector v2, Vector v3, Float Ang, Matrix mg ); Bool SetGridPoint( BaseDocument *doc, BaseDraw *bd, BaseContainer &data, Vector G_point, Matrix mg, Float x, Float y, Int32 G_STEP, Bool PL_flag, Matrix PLmg, Vector* G_markpoint); Bool SetGridLine(BaseDocument* doc, BaseContainer& data); Bool SP_CrossSnap( BaseDocument *doc, BaseDraw *bd, BaseContainer &data, Float mx, Float my, Vector *Vspos, Matrix *Amg ); Bool CrossSection( Vector As, Vector Ae, Vector Bs, Vector Be, Vector *cross, BaseContainer &data, Float &t1, Float &t2, Matrix *Amg ); Bool KeyCoodCheck( Int32 SERIAL_SIZE ); Bool GetNumber( String &st, Int32 &NUM); String GetPSN(const Int32 csn); String ExchangeKye(Int32 num); Vector GetDrawVec( BaseDocument *doc, BaseContainer &data, Vector v1, Vector v2, Matrix mg ); String geneSN( Int32 sn, Float ch, String s1, String s2); Float VectorToRad(Vector v1, Vector v2, Matrix mg); Bool CheckSnapSetting( BaseDocument* doc, BaseContainer& data); void SetCHECKUP(BaseDocument* doc, BaseContainer& data, Bool flag); //void SetObjectPlane(BaseDocument* doc, BaseDraw* bd, BaseContainer& data, Bool flag, Matrix* Amg); void init(BaseDocument* doc, BaseContainer& data); //ポイントIDから法線ベクトルを返す Vector GetVertexNormal(Int32 PointIndex, PolygonObject *op, Neighbor *neighbor); Vector GetScaleForMatrix(Matrix mg); Float Vector2AngleLocal(Vector vv1, Vector vv2, Matrix mg, Int32 &flag); BaseObject* GetTargetObj(BaseDocument* doc, BaseObject* TGobj); Vector LockAngle( BaseDocument *doc, BaseContainer &data, Vector v1, Float Ang, Vector GP1, Vector GP2,Matrix Amg); Bool Snap90Plane( BaseDocument *doc,BaseContainer &data, BaseDraw *bd,BaseDrawHelp *bh, Vector G_markpoint, Matrix SNmg ); void search_hierarchyDEL(BaseObject *obj1, BaseObject *obj2); void QSortK( Mobj *x, Int32 left, Int32 right); void SwapK( Mobj *x, Int32 i, Int32 j); Bool CrossSectionB( Vector As, Vector Ae, Vector Bs, Vector Be, Vector *crossA, Vector *crossB, BaseContainer &data, Matrix Amg ); Float firstPoint(Float *Gpos, Float A1, Float A2, Float A3, Float A4, Float A6, Float A7, Float A8, Float A9, Float A10); Vector SnapEdgeVector( BaseDocument *doc, BaseContainer &data,BaseDraw *bd, Float x, Float y, Vector G_basePos, Matrix G_mg, Int32 *G_SnapFlag, Int32 G_STEP, Vector G_markpoint, Vector G_P2, Vector *G_nvec, Matrix* SNmg, Vector* va, Vector* vb); void GetLayerListdata(LayerObject *layer, Bool* flag, LayerObject ** Slayer); void SerchiOBJ(BaseObject* op, BaseObject** tg); Bool PointerToAXISEdgeCheck( BaseDraw* bd,BaseContainer &data, Float x, Float y, Vector* AP, Vector center, Int32* Num); Bool ClingCheck(BaseDocument* doc, BaseObject* op, Int32 id); //スナップ先エレメント情報の取得 Bool GetPolyErementInfo(BaseDocument* doc, BaseDraw *bd, BaseObject* getOBJ, SnapResult Snapres, Int32* G_SnapFlag, Float x, Float y, Matrix* G_mg); Vector GetFlatVectorPOS(BaseDocument *doc, BaseDraw *bd, BaseContainer &data, Float x, Float y, Matrix G_mg, Int32 G_STEP, Vector G_markpoint, Vector P1, Bool PL_flag); Vector GetZpointNew(BaseDocument *doc, BaseContainer &data, BaseDraw *bdd, Vector Nplane, Float mx, Float my, Vector Bpos, Int32 step, Vector nov); Bool GetSnapFaceMatrix(BaseDocument* doc, BaseDraw* bd, Matrix* AxMg, Int32 id, BaseObject* op); Vector GetFaceNormal(Vector *vv, CPolygon *pArr, Int32 index); Vector GetFaceCenterPos(Vector *vv, CPolygon *pArr, Int32 index); Bool Get3PointNormMg(Vector a, Vector b, Vector c, Matrix* MMG); void printcheckS(String st, Matrix mg); Matrix GetPlaneMatrix(BaseDocument* doc, BaseDraw* bd, BaseContainer& data, Bool PlaneSet_Flag, Matrix mg); //void SetObjectPlane2(BaseDocument* doc, BaseDraw* bd, BaseContainer& data, Bool Pflag, Matrix Amg); //************************************************************* Bool SnapSync(BaseDocument* doc, BaseContainer& data, Bool PlaneSet_BTNFlag); BaseObject* SnapMouseVectorObj(BaseDocument *doc, BaseContainer &data, BaseDraw *bd, SnapCore*_snap, Float x, Float y, Matrix G_mg, Int32 *G_SnapFlag, Int32 G_STEP, Vector G_markpoint, Vector G_P2, Vector *G_nvec, Bool PlaneSet_Flag, Matrix* ViewMg, Float *mx, Float *my, Int32* SnapID, Vector& pos); Bool ResetPlaneAxis(BaseDocument* doc); Matrix SetPlaneGetMg(BaseDocument* doc, BaseDraw* bd, BaseContainer& data, Bool Pflag, Matrix FaceMg, Int32 num); Vector SnapMouseVector(BaseDocument *doc, BaseContainer &data, BaseDraw *bd, SnapCore*_snap, Float x, Float y, Matrix G_mg, Int32 *G_SnapFlag, Int32 G_STEP, Vector G_markpoint, Vector G_P2, Vector *G_nvec, Bool PlaneSet_Flag, Matrix* ViewMg, Float *mx, Float *my); Vector ReMgVector(BaseDraw* bd, Matrix mg , Vector pos); }; #endif // _DTOOL_H_
[ "coffeestock.anoano@gmail.com" ]
coffeestock.anoano@gmail.com
e2fe70e77f220b537bb5f9ccd5fa8ec74f490fae
f70097d8e4ac47b90522ad37194caec84ff966de
/CUDA/include/Algorithms.h
87517af4dbadfebec5bfd83b37c1fce5e6989b1d
[ "MIT" ]
permissive
zxwglzi/libcgt
d007e0fd1b3c0930327c343759742082a0da5a64
52b7d1c32ea2827f3452acd74beb205299bfc5de
refs/heads/master
2020-12-25T22:06:53.993153
2012-08-27T07:51:59
2012-08-27T07:51:59
null
0
0
null
null
null
null
UTF-8
C++
false
false
188
h
#pragma once namespace libcgt { namespace cuda { template< typename T > __inline__ __device__ void swap( T& a, T& b ) { T x = a; a = b; b = x; } } }
[ "jiawen@csail.mit.edu" ]
jiawen@csail.mit.edu
6d8941a2cba42dd7fcf3cb185bcec9432695af55
c3f47181552aa993e88bbff91bf8711bf2ead215
/ResourceManager/ResourceManager/Core/include/Core/Components/ModelComponent.h
9b983aed8abc6cf4ae61eb197fa2e12ca6f258cd
[]
no_license
fantunes-ds/Multithreaded-Parser
0ae91c3482b45644e3054316f86bb85e95a39b06
802bc6fdd6ef8eee50f8a17c0ac0cce3b7facf53
refs/heads/master
2021-05-24T11:49:43.336024
2019-10-08T21:13:19
2019-10-08T21:13:19
253,546,029
0
0
null
null
null
null
UTF-8
C++
false
false
771
h
#pragma once #include <memory> #include <Core/GameObject.h> #include <Core/Components/IComponent.h> #include <Rendering/Resources/Model.h> namespace Core::Components { class ModelComponent : public IComponent { public: ModelComponent(GameObject& p_gameObject); ModelComponent(GameObject& p_gameObject, const std::string& p_path); ~ModelComponent(); ModelComponent(const ModelComponent& p_other); const std::string GetType() const override; void Update() override; const std::shared_ptr<Rendering::Resources::Mesh>& GetMesh() const; const std::shared_ptr<Rendering::Resources::Model>& GetModel() const; private: std::string m_type = "ModelComponent"; std::shared_ptr<Rendering::Resources::Model> m_model; Core::GameObject& m_gameObject; }; }
[ "f.antunesdasilva@student.isartdigital.com" ]
f.antunesdasilva@student.isartdigital.com
bcbfa0ead028f3f76ab3431315fd920be0748ec8
6ab8480d5f8cd211e4e5517a424bd3e04f776926
/LinkList.h
1ae06b47925d8a577d057bb975297e06a9da47a1
[]
no_license
Eltom777/Linked_list
32c19d6dc23833824e9f696def1c6779460300ad
11442997042a984787750c9732545cdbadf93b63
refs/heads/master
2020-05-20T16:50:27.226343
2019-05-08T20:19:04
2019-05-08T20:19:04
185,673,779
0
0
null
null
null
null
UTF-8
C++
false
false
3,557
h
/* LinkList.h Teng Zhao 40089560 Thomas Flynn 40034877 */ #pragma once #include "Node.h" #include "ourExceptions.h" using namespace std; template<class T> class LinkList { private: Node<T>* head; Node<T>* tail; int n; // number of elements in linkedlist public: LinkList() { head = nullptr; tail = nullptr; n = 0; } ~LinkList() { } void addElement(T t) { Node<T>* temp = new Node<T>(t); if (head == nullptr) { head = temp; tail = temp; } else { tail->setNextNode(temp); tail = tail->getNextNode(); } n++; } void deleteElement(T t) { //Search element position Node<T>* tempA = head; int p = 1; bool isFound = false; while(tempA != nullptr){ if (tempA->getElement() == t) { isFound = true; break; } else { tempA = tempA->getNextNode(); p++; } } if (isFound != true) { notFound nf; throw nf; } else{ this->removeNode(p); } } void insertNode(T t, int pos){ // assume pos is strictly positive, if (pos <= n) { Node<T>* temp = new Node<T>(t); //create new node Node<T>* temp2 = head; // will hold node at pos Node<T>* temp3 = nullptr; // will hold node at pos+1 for (int i = 1; i < pos - 1; i++) //find insert node position temp2 = temp2->getNextNode(); temp3 = temp2->getNextNode(); temp2->setNextNode(temp);//set the node position's next node to new node temp->setNextNode(temp3);//set the new node's next node to the original node's next node n++; } else { outOfRange oOR; throw oOR; } } void removeNode(int pos) //remove an element located at a certain poisiton { if (pos == 1) { // changing head Node<T>* tempA = head; Node<T>* tempB = tempA->getNextNode(); tempA->setNextNodeNull(); head = tempB; delete tempA; n--; } else if (pos <n) { Node<T>* tempA = head; //control node pos-1 Node<T>* tempB = nullptr; //control node pos Node<T>* tempC = nullptr; //control node pos+1 for (int i = 1; i < pos - 1; i++) //find remove node position-1 tempA = tempA->getNextNode(); tempB = tempA->getNextNode(); tempC = tempB->getNextNode(); tempA->setNextNode(tempC); tempB->setNextNodeNull(); delete tempB; n--; } else if (pos == n){ //changing tail Node<T>* tempA = head; Node<T>* tempB = nullptr; for (int i = 1; i < pos -1; i++) //find remove node position-1 tempA = tempA->getNextNode(); tempB = tempA->getNextNode(); tail = tempA; tempA->setNextNodeNull(); delete tempB; n--; } else { outOfRange oOR; throw oOR; } } T getNodeValue(int pos) { Node<T>* tempA = head; for (int i = 1; i < pos ; i++) tempA = tempA->getNextNode(); return tempA->getElement(); } bool searchNode(T ele) //search for an element { Node<T>* temp = head; while (temp != nullptr) { // crashed here, we'll fix it tomorrow if (temp->getElement() == ele) { return true; } temp = temp->getNextNode(); } return false; } friend ostream& operator<<(ostream& output, const LinkList<T>& L) { Node<T>* p = L.getHead(); //at pos one, node is head int pos = 1; while (p != nullptr) { cout <<"At position "<< pos<< ":" << p->getElement() << endl; p = p->getNextNode(); pos++; } return output; } void printLinkList() { Node<T>* p = head; //at pos one, node is head int pos = 1; while (p != nullptr) { cout << "At position " << pos << ":" << p->getElement() << endl; p = p->getNextNode(); pos++; } } Node<T>* getHead()const { return head; } };
[ "lthomas.flynn@gmail.com" ]
lthomas.flynn@gmail.com
d6d16e5334986583bea107e4f58f62f70010b9ba
a35554a195d76e7241c916720110d0ce6e2d0272
/node3d/trunk/tool/WorldEditor/Dialog/DlgFile.cpp
cb5caa52a3ee23e5379d3deab27e6a6822a9a987
[]
no_license
khuyendev/Mu
0fa50b3b78ec23724b94cd411972f7bda7a0e0cd
e4d63188422e45562f9fccad32173e9c160cb67f
refs/heads/master
2020-07-25T19:09:45.517848
2019-09-14T05:45:10
2019-09-14T05:45:10
208,395,302
0
0
null
null
null
null
UTF-8
C++
false
false
5,969
cpp
#include "DlgFile.h" #include "FileSystem.h" #include "IORead.h" CDlgFile::CDlgFile(): m_eOperatingType(OPERATING_TYPE_MAX) { } CDlgFile::~CDlgFile() { } void CDlgFile::OnControlRegister() { CUIDialog::OnControlRegister(); RegisterControl("IDC_LIST_BOX_FOLDER", m_ListBoxFolder); RegisterControl("IDC_EDIT_BOX_FILE", m_EditBoxFile); RegisterControl("IDC_BTN_NEW", m_BtnNew); RegisterControl("IDC_BTN_OPEN", m_BtnOpen); RegisterControl("IDC_BTN_SAVE", m_BtnSave); RegisterControl("IDC_CMB_FILE_TYPE", m_ComboBoxFileType); RegisterControlEvent("IDC_LIST_BOX_FOLDER", (PEVENT)&CDlgFile::OnListBoxFolderSelection, EVENT_LISTBOX_SELECTION); RegisterControlEvent("IDC_LIST_BOX_FOLDER", (PEVENT)&CDlgFile::OnListBoxFolderItemDblClk, EVENT_LISTBOX_ITEM_DBLCLK); //RegisterControlEvent("IDC_EDIT_BOX_FILE", (PEVENT)&CDlgFile::OnEditBoxFile, EVENT_LISTBOX_SELECTION); RegisterControlEvent("IDC_BTN_UP", (PEVENT)&CDlgFile::OnBtnUp); RegisterControlEvent("IDC_BTN_BACK", (PEVENT)&CDlgFile::OnBtnBack); RegisterControlEvent("IDC_BTN_NEW", (PEVENT)&CDlgFile::OnBtnNew); RegisterControlEvent("IDC_BTN_OPEN", (PEVENT)&CDlgFile::OnBtnOpen); RegisterControlEvent("IDC_BTN_SAVE", (PEVENT)&CDlgFile::OnBtnSave); RegisterControlEvent("IDC_BTN_CANCEL", (PEVENT)&CDlgFile::OnBtnCancel); RegisterControlEvent("IDC_CMB_FILE_TYPE", (PEVENT)&CDlgFile::OnCmbFileTypeSelect); } void CDlgFile::SetVisible(bool bVisible) { CUIDialog::SetVisible(bVisible); m_BtnNew.SetVisible(false); m_BtnOpen.SetVisible(false); m_BtnSave.SetVisible(false); m_EditBoxFile.ClearText(); } void CDlgFile::OnListBoxFolderSelection() { std::wstring wstrFilename = m_ListBoxFolder.GetSelectedItem()->wstrText; if (wstrFilename.length()>0&&wstrFilename[0]!=L'\\') { m_EditBoxFile.SetText(wstrFilename.c_str()); } } void CDlgFile::OnListBoxFolderItemDblClk() { std::wstring wstrFolder = m_ListBoxFolder.GetSelectedItem()->wstrText; if (wstrFolder.length()>0&&wstrFolder[0]==L'\\') { if (L"\\.."==wstrFolder) { m_wstrDir = GetParentPath(m_wstrDir); } else { m_wstrDir = GetChildPath(m_wstrDir,wstrFolder.substr(1)); } if(false == OpenPath(m_wstrDir)) { OpenPath(L""); } } else { switch(m_eOperatingType) { case OPERATING_TYPE_NEW: OnBtnNew(); case OPERATING_TYPE_OPEN: OnBtnOpen(); break; case OPERATING_TYPE_SAVE: OnBtnSave(); break; default:break; } } } void CDlgFile::OnBtnUp() { m_wstrDir = GetParentPath(m_wstrDir); OpenPath(m_wstrDir); //if(false == OpenPath(m_wstrDir)) //{ // OpenPath(L""); //} } void CDlgFile::OnBtnBack() { if (m_setRecentPath.size()>1) { size_t uSize = m_setRecentPath.size(); m_wstrDir = m_setRecentPath[uSize-2]; OpenPath(m_wstrDir); m_setRecentPath.resize(uSize-1); } } void CDlgFile::OnBtnNew() { if (wcslen(m_EditBoxFile.GetText())==0) { return; } std::wstring wstrFilename = GetChildPath(m_wstrDir,m_EditBoxFile.GetText()); if(IOReadBase::Exists(ws2s(wstrFilename))) { //!! m_wstrFilename = wstrFilename; } else if (IOReadBase::Exists(ws2s(m_EditBoxFile.GetText()))) { //!! m_wstrFilename = m_EditBoxFile.GetText(); } else { //OpenPath(m_EditBoxFile.GetText()); //return; m_wstrFilename = wstrFilename; } m_wstrFilename=ChangeExtension(m_wstrFilename,m_wstrFileType); SendEvent( EVENT_NEW); SetVisible(false); } void CDlgFile::OnBtnOpen() { if (wcslen(m_EditBoxFile.GetText())==0) { return; } std::wstring wstrFilename = GetChildPath(m_wstrDir,m_EditBoxFile.GetText()); if(IOReadBase::Exists(ws2s(wstrFilename))) { m_wstrFilename = wstrFilename; } else if (IOReadBase::Exists(ws2s(m_EditBoxFile.GetText()))) { m_wstrFilename = m_EditBoxFile.GetText(); } else { OpenPath(m_EditBoxFile.GetText()); return; } SendEvent( EVENT_OPEN); SetVisible(false); } void CDlgFile::OnBtnSave() { m_wstrFilename = m_wstrDir+m_EditBoxFile.GetText(); SendEvent( EVENT_SAVE); SetVisible(false); } void CDlgFile::OnBtnCancel() { SendEvent( EVENT_CANCEL); SetVisible(false); } void CDlgFile::OnCmbFileTypeSelect() { m_wstrFileType = m_ComboBoxFileType.GetText(); OpenPath(m_wstrDir); } bool CDlgFile::OpenPath(const std::wstring& wstrPath) { if (wstrPath.length()==0) { m_wstrDir=getCurrentDirectory(); } else { m_wstrDir = wstrPath; } SetCaptionText(m_wstrDir); CDir dir; if(false == dir.ReadDir(m_wstrDir)) { return false; } // Add a path to the list of recent paths. m_setRecentPath.push_back(m_wstrDir); // m_ListBoxFolder.RemoveAllItems(); for (size_t i=0; i<dir.m_FileInfo.size(); i++) { if (dir.m_FileInfo[i].IsDirectory()) { if(dir.m_FileInfo[i].wstrFilename!=L".") { m_ListBoxFolder.AddItem((L"\\"+dir.m_FileInfo[i].wstrFilename).c_str()); } } } for (size_t i=0; i<dir.m_FileInfo.size(); i++) { if (!dir.m_FileInfo[i].IsDirectory()) { if (m_wstrFileType.find(GetExtension(dir.m_FileInfo[i].wstrFilename))!=std::wstring::npos) { m_ListBoxFolder.AddItem(dir.m_FileInfo[i].wstrFilename.c_str()); } } } return true; } void CDlgFile::setFileType(const std::wstring& wstrFileType) { m_ComboBoxFileType.getListBox().RemoveAllItems(); m_setFileType.clear(); TokenizerW(wstrFileType,m_setFileType,L"|"); for (size_t i=0;i<m_setFileType.size();++i) { m_ComboBoxFileType.AddItem(m_setFileType[i].c_str()); } } void CDlgFile::NewFile(const std::wstring& wstrPath) { SetVisible(true); m_eOperatingType = OPERATING_TYPE_NEW; m_BtnNew.SetVisible(true); if(false == OpenPath(wstrPath)) { OpenPath(L""); } } void CDlgFile::OpenFile(const std::wstring& wstrPath) { SetVisible(true); m_eOperatingType = OPERATING_TYPE_OPEN; m_BtnOpen.SetVisible(true); if(false == OpenPath(wstrPath)) { OpenPath(L""); } } void CDlgFile::SaveFile(const std::wstring& wstrPath) { SetVisible(true); m_eOperatingType = OPERATING_TYPE_SAVE; m_BtnSave.SetVisible(true); m_wstrDir = wstrPath; if(false == OpenPath(m_wstrDir)) { OpenPath(L""); } }
[ "nguyen.khuyen@framgia.com" ]
nguyen.khuyen@framgia.com
2628585cbc0ca03f6d0cd1fad971aadcd42ca7de
2c5e6a833394d6e9fef94d357e64f1ee90a6acba
/important_problems/1865_wormholes.cpp
c33fc2838fe55387dc149fc98ae53fd8cc9209a6
[]
no_license
oikkoikk/ALOHA
f2fa91863a01997464f106a65704a6382bc49bd9
36b33211ee5d0b350f6d6e6f577bf8922c3e1782
refs/heads/master
2023-04-11T19:45:01.017321
2023-03-15T15:15:24
2023-03-15T15:15:24
254,006,898
2
0
null
null
null
null
UTF-8
C++
false
false
2,413
cpp
//음수가중치 -> 벨만-포드! #include <iostream> #include <vector> using namespace std; const int INF = 987654321; int TC, N, M, W, S, E, T; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cin >> TC; while (TC--) { bool flag = true; // 음수 사이클 발견하면 false로! vector<int> dist(501, INF); //거리 저장하는 배열(INF로 초기화) vector<pair<int, int>> Edges[501]; cin >> N >> M >> W; for (int i = 1; i <= M; i++) { cin >> S >> E >> T; //T는 가중치 Edges[S].push_back(make_pair(E, T)); //도로는 Edges[E].push_back(make_pair(S, T)); //양방향! } for (int i = 1; i <= W; i++) { cin >> S >> E >> T; Edges[S].push_back(make_pair(E, -T)); //웜홀은 시간이 줄어드니까 -T! } //벨만-포드 dist[1] = 0; for (int i = 1; i <= N; i++) //최단 거리 Relax(N-1시도 까지!) + 음수 사이클 찾기(N번째 도는데 Relax되면 음의 사이클을 돌고 있는 것!) { for (int from = 1; from <= N; from++) { for (auto p : Edges[from]) { int to = p.first; int weight = p.second; //주의) 이 문제에서는 사이클의 유무만 판단하면 되므로, 아래와 같은 INF 비교를 하지 않는다!! /* if (dist[from] == INF) //출발지에서 가지 못하는 곳이면 패스! { continue; } 반례) 1 3 2 0 2 3 -1 3 2 -1 */ if (dist[to] > dist[from] + weight) { if (i == N) { flag = false; //N번 째일 때 Relax 되면 음수 사이클! } dist[to] = dist[from] + weight; } } } } if (flag == false) { cout << "YES\n"; } else { cout << "NO\n"; } } return 0; }
[ "ljjun0702@gmail.com" ]
ljjun0702@gmail.com
3adca744bc94fc4182f410a4c218d03ae714948f
6490f9e691cbc53008466bbd47c565e8c7caaea4
/tree.h
97d173ded7fdf929aae47b8bbddce2b5e840ddbd
[]
no_license
131071/octo-comp
7cacf89c6f1c70763400a5c345d36531ccc0b906
4e09f95be79e587109de65d601c0cd4878a48b2a
refs/heads/master
2021-03-19T07:32:07.870149
2017-06-15T01:24:51
2017-06-15T01:24:51
94,373,623
0
0
null
null
null
null
UTF-8
C++
false
false
105
h
class tree{ private: class node; node root; public: string parseTree(); void unpackTree(string); }
[ "charly.dont.surf@gmail.com" ]
charly.dont.surf@gmail.com
da570b7e76e1427b4c3e4602048df681182b3882
fa1445f3f23d2dcee4938ff73a543d9aae235799
/SDK/FN_PBWA_W1_HalfWallDoor_classes.hpp
b873115ebae8fb919f5222f1ff335b6c3525fa04
[]
no_license
chuhanpu/FNFUN
ac6d750037514bdfb3b1baa50830c9bce60ed85a
8326ae28b844f4d9ee38f3c64bb056e81106fdd3
refs/heads/master
2021-07-15T07:18:42.180136
2017-10-18T20:24:55
2017-10-18T20:24:55
107,524,245
0
0
null
null
null
null
UTF-8
C++
false
false
609
hpp
#pragma once // Fortnite SDK #ifdef _MSC_VER #pragma pack(push, 0x8) #endif namespace SDK { //--------------------------------------------------------------------------- //Classes //--------------------------------------------------------------------------- // BlueprintGeneratedClass PBWA_W1_HalfWallDoor.PBWA_W1_HalfWallDoor_C // 0x0000 (0x10B0 - 0x10B0) class APBWA_W1_HalfWallDoor_C : public ABuildingWall { public: static UClass* StaticClass() { static UClass* ptr = nullptr; if (!ptr) ptr = UObject::FindClass(0x55b6bd5f); return ptr; } }; } #ifdef _MSC_VER #pragma pack(pop) #endif
[ "tj8@live.com.au" ]
tj8@live.com.au
3d57e33bfaeddb67dcd201d4307297b974b21d3b
3ff1fe3888e34cd3576d91319bf0f08ca955940f
/dnspod/src/v20210323/model/DescribeRecordExistExceptDefaultNSResponse.cpp
b349db5c29c9955e1e5b290d3c9b5aa6706b81f0
[ "Apache-2.0" ]
permissive
TencentCloud/tencentcloud-sdk-cpp
9f5df8220eaaf72f7eaee07b2ede94f89313651f
42a76b812b81d1b52ec6a217fafc8faa135e06ca
refs/heads/master
2023-08-30T03:22:45.269556
2023-08-30T00:45:39
2023-08-30T00:45:39
188,991,963
55
37
Apache-2.0
2023-08-17T03:13:20
2019-05-28T08:56:08
C++
UTF-8
C++
false
false
3,924
cpp
/* * Copyright (c) 2017-2019 THL A29 Limited, a Tencent company. 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 <tencentcloud/dnspod/v20210323/model/DescribeRecordExistExceptDefaultNSResponse.h> #include <tencentcloud/core/utils/rapidjson/document.h> #include <tencentcloud/core/utils/rapidjson/writer.h> #include <tencentcloud/core/utils/rapidjson/stringbuffer.h> using TencentCloud::CoreInternalOutcome; using namespace TencentCloud::Dnspod::V20210323::Model; using namespace std; DescribeRecordExistExceptDefaultNSResponse::DescribeRecordExistExceptDefaultNSResponse() : m_existHasBeenSet(false) { } CoreInternalOutcome DescribeRecordExistExceptDefaultNSResponse::Deserialize(const string &payload) { rapidjson::Document d; d.Parse(payload.c_str()); if (d.HasParseError() || !d.IsObject()) { return CoreInternalOutcome(Core::Error("response not json format")); } if (!d.HasMember("Response") || !d["Response"].IsObject()) { return CoreInternalOutcome(Core::Error("response `Response` is null or not object")); } rapidjson::Value &rsp = d["Response"]; if (!rsp.HasMember("RequestId") || !rsp["RequestId"].IsString()) { return CoreInternalOutcome(Core::Error("response `Response.RequestId` is null or not string")); } string requestId(rsp["RequestId"].GetString()); SetRequestId(requestId); if (rsp.HasMember("Error")) { if (!rsp["Error"].IsObject() || !rsp["Error"].HasMember("Code") || !rsp["Error"]["Code"].IsString() || !rsp["Error"].HasMember("Message") || !rsp["Error"]["Message"].IsString()) { return CoreInternalOutcome(Core::Error("response `Response.Error` format error").SetRequestId(requestId)); } string errorCode(rsp["Error"]["Code"].GetString()); string errorMsg(rsp["Error"]["Message"].GetString()); return CoreInternalOutcome(Core::Error(errorCode, errorMsg).SetRequestId(requestId)); } if (rsp.HasMember("Exist") && !rsp["Exist"].IsNull()) { if (!rsp["Exist"].IsBool()) { return CoreInternalOutcome(Core::Error("response `Exist` IsBool=false incorrectly").SetRequestId(requestId)); } m_exist = rsp["Exist"].GetBool(); m_existHasBeenSet = true; } return CoreInternalOutcome(true); } string DescribeRecordExistExceptDefaultNSResponse::ToJsonString() const { rapidjson::Document value; value.SetObject(); rapidjson::Document::AllocatorType& allocator = value.GetAllocator(); if (m_existHasBeenSet) { rapidjson::Value iKey(rapidjson::kStringType); string key = "Exist"; iKey.SetString(key.c_str(), allocator); value.AddMember(iKey, m_exist, allocator); } rapidjson::Value iKey(rapidjson::kStringType); string key = "RequestId"; iKey.SetString(key.c_str(), allocator); value.AddMember(iKey, rapidjson::Value().SetString(GetRequestId().c_str(), allocator), allocator); rapidjson::StringBuffer buffer; rapidjson::Writer<rapidjson::StringBuffer> writer(buffer); value.Accept(writer); return buffer.GetString(); } bool DescribeRecordExistExceptDefaultNSResponse::GetExist() const { return m_exist; } bool DescribeRecordExistExceptDefaultNSResponse::ExistHasBeenSet() const { return m_existHasBeenSet; }
[ "tencentcloudapi@tencent.com" ]
tencentcloudapi@tencent.com
8e75dda41a8a424cd10fcbd8a58a4b249c53b737
31f6f5b47389c07bdcc2dbaef131def8ec3e054f
/src/code_elements/code_run.cpp
2d2b061a361f8f63bd167b04471f99a0270cff58
[ "MIT" ]
permissive
zakgodwin/decompiler
00aa30c7ebf8d508c04e39ba8f12d11769e429b2
a0e78ccff7ea838c0321572eea92253a1b43e359
refs/heads/master
2020-03-27T16:17:59.009343
2018-03-28T12:07:37
2018-03-28T12:07:37
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,962
cpp
#include "code_run.h" #include "related_code.h" #include "helpers.h" class register_run { public: register_run() { related_code::register_code_element_maker(code_run::simplify); } }; static register_run make_it_so; code_run::code_run() { } code_run::~code_run() { } code_element *code_run::simplify(std::vector<code_element *> grp, code_element *end) { code_run *ret = 0; //all elements must be non-branching bool all_nonbranch = true; for (unsigned int i = 0; i < grp.size(); i++) { if (grp[i]->is_branch()) { all_nonbranch = false; } } if (grp.size() == 1) { all_nonbranch = false; } if (all_nonbranch) { ret = new code_run(); code_element *temp = grp[0]; do { ret->add_element(temp); temp = temp->a; } while (temp != end); ret->a = end; ret->b = 0; std::vector<bool>grp_elements_used; for (unsigned int i = 0; i < grp.size(); i++) { grp_elements_used.push_back(false); } for (unsigned int i = 0; i < ret->els.size(); i++) { unsigned int temp = get_index(grp, ret->els[i]); if (temp < grp.size()) { grp_elements_used[temp] = true; } } for (unsigned int i = 0; i < grp_elements_used.size(); i++) { if (!grp_elements_used[i]) { delete ret; ret = 0; } } } return ret; } void code_run::get_calls(std::vector<address> &c) { for (unsigned int i = 0; i < els.size(); i++) { els[i]->get_calls(c); } } void code_run::add_element(code_element *add) { els.push_back(add); if (els.size() == 1) { s = add->gets(); } } void code_run::done() { a = els.back()->a; b = els.back()->b; } void code_run::fprint(std::ostream &dest, int depth) { unsigned int i; for (i = 0; i < els.size(); i++) { els[i]->fprint(dest, depth); } } #ifdef PROVE_SIMPLIFY void code_run::print_graph(std::ostream &dest) { dest << "#run " << this->gets() << "\n"; for (int i = 0; i < els.size(); i++) els[i]->print_graph(dest); dest << "#end run\n"; } #endif
[ "thomas.epperson@gmail.com" ]
thomas.epperson@gmail.com
d99160dc5d47054c06e8e884721c77141fbd56ae
a31349460eda9e0aba3846344048490c1a108c24
/MRML/vtkMRMLEMSSegmenterNode.cxx
6031d1bf183f742866fc88ada44922661ead451c
[]
no_license
jcfr/EMSegment3
58ce9f01a3dd86aff67b02226ae8710c6a49d8b1
44d4f1d5a3e442d70adc98f0227ceff559c91038
refs/heads/master
2021-03-12T23:02:21.886633
2011-04-28T21:15:35
2011-04-28T21:15:35
1,667,722
1
0
null
null
null
null
UTF-8
C++
false
false
7,397
cxx
#include "vtkMRMLEMSSegmenterNode.h" #include <sstream> #include "vtkMRMLScene.h" #include "vtkMRMLScalarVolumeNode.h" #include "vtkMRMLEMSWorkingDataNode.h" #include "vtkMRMLEMSTemplateNode.h" //----------------------------------------------------------------------------- vtkMRMLEMSSegmenterNode* vtkMRMLEMSSegmenterNode:: New() { // First try to create the object from the vtkObjectFactory vtkObject* ret = vtkObjectFactory::CreateInstance("vtkMRMLEMSSegmenterNode"); if(ret) { return (vtkMRMLEMSSegmenterNode*)ret; } // If the factory was unable to create the object, then create it here. return new vtkMRMLEMSSegmenterNode; } //----------------------------------------------------------------------------- vtkMRMLNode* vtkMRMLEMSSegmenterNode:: CreateNodeInstance() { // First try to create the object from the vtkObjectFactory vtkObject* ret = vtkObjectFactory::CreateInstance("vtkMRMLEMSSegmenterNode"); if(ret) { return (vtkMRMLEMSSegmenterNode*)ret; } // If the factory was unable to create the object, then create it here. return new vtkMRMLEMSSegmenterNode; } //----------------------------------------------------------------------------- vtkMRMLEMSSegmenterNode::vtkMRMLEMSSegmenterNode() { this->TemplateNodeID = NULL; this->OutputVolumeNodeID = NULL; this->WorkingDataNodeID = NULL; this->WorkingDirectory = NULL; } //----------------------------------------------------------------------------- vtkMRMLEMSSegmenterNode::~vtkMRMLEMSSegmenterNode() { this->SetTemplateNodeID(NULL); this->SetOutputVolumeNodeID(NULL); this->SetWorkingDataNodeID(NULL); this->SetWorkingDirectory(NULL); } //----------------------------------------------------------------------------- void vtkMRMLEMSSegmenterNode::WriteXML(ostream& of, int nIndent) { Superclass::WriteXML(of, nIndent); vtkIndent indent(nIndent); of << indent << " TemplateNodeID=\"" << (this->TemplateNodeID ? this->TemplateNodeID : "NULL") << "\" "; of << indent << "OutputVolumeNodeID=\"" << (this->OutputVolumeNodeID ? this->OutputVolumeNodeID : "NULL") << "\" "; of << indent << "WorkingDataNodeID=\"" << (this->WorkingDataNodeID ? this->WorkingDataNodeID : "NULL") << "\" "; of << indent << "WorkingDirectory=\"" << (this->WorkingDirectory ? this->WorkingDirectory : "NULL") << "\" "; } //----------------------------------------------------------------------------- void vtkMRMLEMSSegmenterNode:: UpdateReferenceID(const char* oldID, const char* newID) { if (this->TemplateNodeID && !strcmp(oldID, this->TemplateNodeID)) { this->SetTemplateNodeID(newID); } if (this->OutputVolumeNodeID && !strcmp(oldID, this->OutputVolumeNodeID)) { this->SetOutputVolumeNodeID(newID); } if (this->WorkingDataNodeID && !strcmp(oldID, this->WorkingDataNodeID)) { this->SetWorkingDataNodeID(newID); } } //----------------------------------------------------------------------------- void vtkMRMLEMSSegmenterNode:: UpdateReferences() { Superclass::UpdateReferences(); if (this->TemplateNodeID != NULL && this->Scene->GetNodeByID(this->TemplateNodeID) == NULL) { this->SetTemplateNodeID(NULL); } if (this->OutputVolumeNodeID != NULL && this->Scene->GetNodeByID(this->OutputVolumeNodeID) == NULL) { this->SetOutputVolumeNodeID(NULL); } if (this->WorkingDataNodeID != NULL && this->Scene->GetNodeByID(this->WorkingDataNodeID) == NULL) { this->SetWorkingDataNodeID(NULL); } } //----------------------------------------------------------------------------- void vtkMRMLEMSSegmenterNode::ReadXMLAttributes(const char** attrs) { Superclass::ReadXMLAttributes(attrs); // // we assume an even number of elements // const char* key; const char* val; while (*attrs != NULL) { key = *attrs++; val = *attrs++; if (!strcmp(key, "TemplateNodeID")) { this->SetTemplateNodeID(val); cout << "WARNING: vtkMRMLEMSSegmenterNode::ReadXMLAttributes:EMSSegmenterNode is outdated since Slicer 3.6.3 - please update your MRML file" << endl; } else if (!strcmp(key, "OutputVolumeNodeID")) { this->SetOutputVolumeNodeID(val); cout << "WARNING: vtkMRMLEMSSegmenterNode::ReadXMLAttributes:EMSSegmenterNode is outdated since Slicer 3.6.3 - please update your MRML file" << endl; } else if (!strcmp(key, "WorkingDataNodeID")) { this->SetWorkingDataNodeID(val); cout << "WARNING: vtkMRMLEMSSegmenterNode::ReadXMLAttributes:EMSSegmenterNode is outdated since Slicer 3.6.3 - please update your MRML file" << endl; } else if (!strcmp(key, "WorkingDirectory")) { this->SetWorkingDirectory(val); cout << "WARNING: vtkMRMLEMSSegmenterNode::ReadXMLAttributes:EMSSegmenterNode is outdated since Slicer 3.6.3 - please update your MRML file" << endl; } } } //----------------------------------------------------------------------------- void vtkMRMLEMSSegmenterNode::Copy(vtkMRMLNode *rhs) { Superclass::Copy(rhs); vtkMRMLEMSSegmenterNode* node = (vtkMRMLEMSSegmenterNode*) rhs; this->SetTemplateNodeID(node->TemplateNodeID); this->SetOutputVolumeNodeID(node->OutputVolumeNodeID); this->SetWorkingDataNodeID(node->WorkingDataNodeID); this->SetWorkingDirectory(node->WorkingDirectory); } //----------------------------------------------------------------------------- void vtkMRMLEMSSegmenterNode::PrintSelf(ostream& os, vtkIndent indent) { Superclass::PrintSelf(os, indent); os << indent << "TemplateNodeID: " << (this->TemplateNodeID ? this->TemplateNodeID : "(none)") << "\n"; os << indent << "OutputVolumeNodeID: " << (this->OutputVolumeNodeID ? this->OutputVolumeNodeID : "(none)" ) << "\n"; os << indent << "WorkingDataNodeID: " << (this->WorkingDataNodeID ? this->WorkingDataNodeID : "(none)" ) << "\n"; os << indent << "WorkingDirectory: " << (this->WorkingDirectory ? this->WorkingDirectory : "(none)" ) << "\n"; } //----------------------------------------------------------------------------- vtkMRMLEMSTemplateNode* vtkMRMLEMSSegmenterNode:: GetTemplateNode() { vtkMRMLEMSTemplateNode* node = NULL; if (this->GetScene() && this->GetTemplateNodeID() ) { vtkMRMLNode* snode = this->GetScene()->GetNodeByID(this->TemplateNodeID); node = vtkMRMLEMSTemplateNode::SafeDownCast(snode); } return node; } //----------------------------------------------------------------------------- vtkMRMLScalarVolumeNode* vtkMRMLEMSSegmenterNode:: GetOutputVolumeNode() { vtkMRMLScalarVolumeNode* node = NULL; if (this->GetScene() && this->GetOutputVolumeNodeID() ) { vtkMRMLNode* snode = this->GetScene()->GetNodeByID(this->OutputVolumeNodeID); node = vtkMRMLScalarVolumeNode::SafeDownCast(snode); } return node; } //----------------------------------------------------------------------------- vtkMRMLEMSWorkingDataNode* vtkMRMLEMSSegmenterNode:: GetWorkingDataNode() { vtkMRMLEMSWorkingDataNode* node = NULL; if (this->GetScene() && this->GetWorkingDataNodeID() ) { vtkMRMLNode* snode = this->GetScene()->GetNodeByID(this->WorkingDataNodeID); node = vtkMRMLEMSWorkingDataNode::SafeDownCast(snode); } return node; }
[ "dh@randi2.de" ]
dh@randi2.de
436b69851ffc11a6735f3c4348adb09d1e260efd
463f26a2c04deb215d38d1f1279189f587185251
/include/Huobi/SubscriptionClient.h
7a5074e9020966d01e368ffba001b45a5644adcb
[ "Apache-2.0" ]
permissive
stonejiang208/huobi_Cpp
927e023c260451ed522af94773a05142979e32ba
1bb86b7cabb1047d571850de64ed91d4e8b9b366
refs/heads/master
2020-08-27T15:30:17.636588
2020-02-14T13:48:25
2020-02-14T13:48:25
217,421,954
0
0
Apache-2.0
2019-10-25T00:58:14
2019-10-25T00:58:14
null
UTF-8
C++
false
false
9,321
h
#ifndef SUBSCRIPTIONCLIENT_H #define SUBSCRIPTIONCLIENT_H #include <string> #include <functional> #include "Huobi/Enums.h" #include "Huobi/AccountEvent.h" #include "Huobi/HuobiApiException.h" #include "Huobi/CandlestickEvent.h" #include "Huobi/TradeEvent.h" #include "Huobi/PriceDepthEvent.h" #include "Huobi/OrderUpdateEvent.h" #include "Huobi/TradeStatisticsEvent.h" #include "Huobi/AccountListEvent.h" #include "Huobi/MarketBBOEvent.h" #include "SubscriptionOptions.h" namespace Huobi { /*** * The subscription client interface, it is used for subscribing any market data update and * account change, it is asynchronous, so you must implement the SubscriptionListener interface. * The server will push any update to the client. if client get the update, the onReceive method * will be called. */ struct SubscriptionClient { /** * Subscribe candlestick/kline event. If the candlestick/kline is updated, server will send the * data to client and onReceive in callback will be called. * * \param symbols The symbols, like "btcusdt". Use comma to separate multi symbols, like * "btcusdt,ethusdt". * \param interval The candlestick/kline interval, MIN1, MIN5, DAY1 etc. * \param callback The implementation is required. onReceive will be called if receive server's * update. * \param errorHandler The error handler will be called if subscription failed or error happen * between client and Huobi server. */ virtual void subscribeCandlestickEvent( const char* symbols, CandlestickInterval interval, const std::function<void(const CandlestickEvent&) >& callback, const std::function<void(HuobiApiException&)>& errorHandler = std::function<void(HuobiApiException&)>()) = 0; /** * Subscribe price depth event. If the price depth is updated, server will send the data to client * and onReceive in callback will be called. * * \param symbols The symbols, like "btcusdt". Use comma to separate multi symbols, like * "btcusdt,ethusdt". * \param callback The implementation is required. onReceive will be called if receive server's * update. * \param errorHandler The error handler will be called if subscription failed or error happen * between client and Huobi server. */ virtual void subscribeTradeEvent( const char* symbols, const std::function<void(const TradeEvent&) >& callback, const std::function<void(HuobiApiException&)>& errorHandler = std::function<void(HuobiApiException&)>()) = 0; /** * Subscribe price depth event. If the price depth is updated, server will send the data to client * and onReceive in callback will be called. * * \param symbols The symbols, like "btcusdt". Use comma to separate multi symbols, like * "btcusdt,ethusdt". * \param callback The implementation is required. onReceive will be called if receive server's * update. * \param errorHandler The error handler will be called if subscription failed or error happen * between client and Huobi server. */ virtual void subscribePriceDepthEvent( const char* symbols, const std::function<void(const PriceDepthEvent&) >& callback, const std::function<void(HuobiApiException&)>& errorHandler = std::function<void(HuobiApiException&)>()) = 0; /** * Subscribe 24 hours trade statistics event. If statistics is generated, server will send the * data to client and onReceive in callback will be called. * * \param symbols The symbols, like "btcusdt". Use comma to separate multi symbols, like * "btcusdt,ethusdt". * \param errorHandler The error handler will be called if subscription failed or error happen * between client and Huobi server. */ virtual void subscribe24HTradeStatisticsEvent( const char* symbols, const std::function<void(const TradeStatisticsEvent&) >& callback, const std::function<void(HuobiApiException&)>& errorHandler = std::function<void(HuobiApiException&)>()) = 0; /** * Subscribe order changing event. If a order is created, canceled etc, server will send the data * to client and onReceive in callback will be called. * * \param symbols The symbols, like "btcusdt". Use comma to separate multi symbols, like * "btcusdt,ethusdt". * \param errorHandler The error handler will be called if subscription failed or error happen * between client and Huobi server. */ virtual void subscribeOrderUpdateEvent( const char* symbols, const std::function<void(const OrderUpdateEvent&) >& callback, const std::function<void(HuobiApiException&)>& errorHandler = std::function<void(HuobiApiException&)>()) = 0; /** * Subscribe account changing event. If the balance is updated, server will send the data to * client and onReceive in callback will be called. * * \param mode when mode is AVAILABLE, balance refers to available balance; when mode is TOTAL, * balance refers to TOTAL balance for trade sub account (available+frozen). * \param callback The implementation is required. onReceive will be called if receive server's * update. * \param errorHandler The error handler will be called if subscription failed or error happen * between client and Huobi server. */ virtual void subscribeAccountEvent( const BalanceMode& mode, const std::function<void(const AccountEvent&) >& callback, const std::function<void(HuobiApiException&)>& errorHandler = std::function<void(HuobiApiException&)>()) = 0; /** * Subscribe order changing event. If a order is created, canceled etc, server will send the data * to client and onReceive in callback will be called. It is faster than subscribeOrderUpdateEvent * * \param symbols The symbols, like "btcusdt". Use comma to separate multi symbols, like * "btcusdt,ethusdt". * \param errorHandler The error handler will be called if subscription failed or error happen * between client and Huobi server. */ virtual void subscribeOrderUpdateNewEvent( const char* symbols, const std::function<void(const OrderUpdateEvent&) >& callback, const std::function<void(HuobiApiException&)>& errorHandler = std::function<void(HuobiApiException&)>()) = 0; /** * Subscribe price depth event. If the price depth is updated, server will send the data to client * and onReceive in callback will be called. * * \param symbols The symbols, like "btcusdt". Use comma to separate multi symbols, like * "btcusdt,ethusdt". * \param step The aggregation depth type,step0,step1,etc. * \param callback The implementation is required. onReceive will be called if receive server's * update. * \param errorHandler The error handler will be called if subscription failed or error happen * between client and Huobi server. */ virtual void subscribePriceDepthEvent( const char* symbols, DepthStep step, const std::function<void(const PriceDepthEvent&) >& callback, const std::function<void(HuobiApiException&)>& errorHandler = std::function<void(HuobiApiException&)>()) = 0; /** * Subscribe market bo event. If the bbo is updated, server will send the data to client * and onReceive in callback will be called. * * \param symbols The symbols, like "btcusdt". Use comma to separate multi symbols, like * "btcusdt,ethusdt". * \param callback The implementation is required. onReceive will be called if receive server's * update. * \param errorHandler The error handler will be called if subscription failed or error happen * between client and Huobi server. */ virtual void subscribeMarketBBOEvent( const char* symbols, const std::function<void(const MarketBBOEvent&) >& callback, const std::function<void(HuobiApiException&)>& errorHandler = std::function<void(HuobiApiException&)>()) = 0; /* * start sub,must excute after sub-function. */ virtual void startService() = 0; }; SubscriptionClient* createSubscriptionClient(const char* apiKey, const char* secretKey, SubscriptionOptions&op); SubscriptionClient* createSubscriptionClient(SubscriptionOptions&op); SubscriptionClient* createSubscriptionClient(); SubscriptionClient* createSubscriptionClient(const char* apiKey, const char* secretKey); } #endif /* SUBSCRIPTIONCLIENT_H */
[ "yuanxueqi@huobi.com" ]
yuanxueqi@huobi.com
69a96ca8c3f60c65803d993da6d93a724945d5c2
be281439ac14f5e3264d1db51f1cd4b259e84739
/FacebookHackerCup/2017_QR/fighting_the_zombie.cpp
10d785db2e93294b14a494e1358f20c186da451b
[]
no_license
anothernguyen/Programming
2e8067a73862eb5a59846e0b2d4d32f21dc93026
090c076f3020018ed46dd067c4b2d54ae87cf4b3
refs/heads/master
2021-01-02T09:32:17.045455
2017-01-14T20:19:00
2017-01-14T20:19:00
78,698,127
0
0
null
null
null
null
UTF-8
C++
false
false
2,627
cpp
#include <iostream> #include <cmath> #include <algorithm> #include <fstream> #include <cstring> #include <iomanip> using namespace std; double calProb(int nSides, int nRolling, double extra, double minDamage) { double sum[21][401]; int w = nSides*nRolling; int h = nRolling; for (int iw=0; iw<w; iw++) { sum[1][iw] = 0; } for (int i = 1; i<=nSides; i++) { sum[1][i] = 1; } for (int ih = 2; ih<=h; ih++) { for (int iw=0; iw<ih; iw++) { sum[ih][iw]=0; } for (int iw=ih; iw<=w; iw++) { sum[ih][iw] = 0; for (int i=iw-1; (i>=iw-nSides) && (i>=0); i--) { sum[ih][iw]+=sum[ih-1][i]; } } } double nCases = 0; for (int i=nRolling; i<=w; i++) { nCases += sum[h][i]; } double nTrueCases = 0; double targetScore = minDamage-extra; for (int i=targetScore; i<=w; i++) { nTrueCases += sum[h][i]; } double prob = nTrueCases/nCases; return prob; } int main() { ifstream fin("fighting_the_zombie.txt"); ofstream fout("fighting_the_zombie_output.txt"); int T, H, S; int nSides, nRolling, nExtra; unsigned long posd, poss; double prob = 0; string st; fin >>T; for (int i=1; i<=T; i++) { prob=0; fin >> H >> S; fout << "Case #" <<i<<": "; for (int j=0; j<S; j++) { fin >> st; if (prob==1) continue; posd = st.find('d', 0); nRolling = atoi(st.substr(0, posd).c_str()); poss = st.find('+', posd+2); if (poss == st.npos) poss = st.find('-', posd+2); if (poss== st.npos) { nExtra = 0; nSides = atoi(st.substr(posd+1, st.length()-posd-1).c_str()); } else { nExtra = atoi(st.substr(poss+1, st.length()-poss-1).c_str()); if (st[poss] == '-') nExtra = -nExtra; nSides = atoi(st.substr(posd+1, poss-posd-1).c_str()); } double p = 0; if (H-nExtra <= nRolling) p=1; else if (H-nExtra > nRolling*nSides) { p=0; } else p = calProb(nSides, nRolling, nExtra, H); if (p>prob) prob = p; } fout << prob << endl; } fin.close(); fout.close(); return 0; }
[ "hletrum@gmail.com" ]
hletrum@gmail.com
23915b03371311c15588984afaf2494f598f4bd0
bbf262aa60fd389152ba849859e95a99860f9c7d
/class_test1202/class_test1202/string练习.cpp
d2bf9e7794bd11aa919879c8e0cc34ee57143330
[]
no_license
Deut-hangd/learn_cpp
14e23fa9b9cc0a472c9130d74f816ea0eef6622f
0bda018c9103499c026a8ae5b57878e9f8d72656
refs/heads/master
2023-03-16T06:24:27.206331
2021-03-18T15:55:53
2021-03-18T15:55:53
324,787,537
0
0
null
null
null
null
UTF-8
C++
false
false
822
cpp
#include "head.h" #include <string> using std::string; void test1() { string s1("abc"); cout << s1 << endl; cout << s1.size() << endl; cout << s1.length() << endl; cout << s1.capacity() << endl; s1.clear(); cout << s1 << endl; cout << s1.size() << endl; cout << s1.length() << endl; cout << s1.capacity() << endl; s1.resize(10, 'a'); cout << s1 << endl; cout << s1.size() << endl; cout << s1.length() << endl; cout << s1.capacity() << endl; s1.resize(15); cout << s1 << endl; cout << s1.size() << endl; cout << s1.length() << endl; cout << s1.capacity() << endl; } void test2() { string s; s.reserve(100); cout << s.size() << endl; cout << s.capacity() << endl; s.reserve(50); cout << s.size() << endl; cout << s.capacity() << endl; } int main() { test2(); system("pause"); return 0; }
[ "deuthangd@163.com" ]
deuthangd@163.com
da14fd2b7f79ac646ce3b7c64262e91b12824b8a
bbb9236f374b8a055b4404f0403ae204a8e55978
/main.cpp
e44070bd0bbf33eb991820dc87c21ea72305e441
[]
no_license
stesim/vulkan-test
8b091b28b2c751eded0a6f1c96b8177674c81507
8daccbb3ef15c31b2076f433dd3dd20f35435304
refs/heads/master
2021-07-18T22:39:39.497664
2017-10-26T22:44:58
2017-10-26T22:44:58
107,979,558
0
0
null
null
null
null
UTF-8
C++
false
false
1,579
cpp
#include "common.h" #include "window.h" #include "windowsurface.h" #include "renderer.h" #include <string> void renderCallback( Window& window, void* userData ) { Renderer& renderer = *reinterpret_cast<Renderer*>( userData ); uint32_t imageIndex = renderer.renderFrame(); if( imageIndex != Renderer::INVALID_FRAME ) { renderer.presentFrame( imageIndex ); } else { log_warning( "Dropping invalid frame." ); } renderer.waitForIdle(); // TODO: remove? renderer.updateUniforms(); } void resizeCallback( Window& window, uint32_t width, uint32_t height, void* userData ) { log_info( "Window resized to:" ); log_info( std::to_string( width ) + "x" + std::to_string( height ) ); if( width > 0 && height > 0 ) { //Renderer& renderer = *reinterpret_cast<Renderer*>( userData ); // window resize results in out-of-date swap chain // recreating here may result in unnecessary swap chain recreation // (possibly depends on windowing system?) //renderer.recreateSwapchain(); } } int main() { if( Window::initializeWindowSystem() && Renderer::initializeRenderingSystem( Window::queryRequiredRendererExtensions() ) ) { Window window; { WindowSurface windowSurface( window ); Renderer renderer( windowSurface ); window.setMainLoopCallback( renderCallback, &renderer ); window.setResizeCallback( resizeCallback, &renderer ); window.startMainLoop(); renderer.waitForIdle(); } Renderer::terminateRenderingSystem(); Window::terminateWindowSystem(); } else { log_error( "Cannot initialize GLFW." ); } return 0; }
[ "simeonov.stefan@gmail.com" ]
simeonov.stefan@gmail.com
975695ea7f78b01f616420f51bd9e0eadfa8767c
f7e8786b1e62222bd1cedcb58383a0576c36a2a2
/src/gpu/command_buffer/service/program_manager_unittest.cc
8e837023970eae59378be28b9af78bd714bfbe8c
[ "BSD-3-Clause" ]
permissive
amplab/ray-core
656915553742302915a363e42b7497037985a91e
89a278ec589d98bcbc7e57e0b80d055667cca62f
refs/heads/master
2023-07-07T20:45:40.883095
2016-08-06T23:52:23
2016-08-06T23:52:23
61,343,320
4
5
null
2016-08-06T23:52:24
2016-06-17T03:35:34
C++
UTF-8
C++
false
false
83,901
cc
// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "gpu/command_buffer/service/program_manager.h" #include <algorithm> #include "base/memory/scoped_ptr.h" #include "base/strings/string_number_conversions.h" #include "base/strings/string_util.h" #include "gpu/command_buffer/common/gles2_cmd_format.h" #include "gpu/command_buffer/common/gles2_cmd_utils.h" #include "gpu/command_buffer/service/common_decoder.h" #include "gpu/command_buffer/service/feature_info.h" #include "gpu/command_buffer/service/gpu_service_test.h" #include "gpu/command_buffer/service/mocks.h" #include "gpu/command_buffer/service/shader_manager.h" #include "gpu/command_buffer/service/test_helper.h" #include "testing/gtest/include/gtest/gtest.h" #include "ui/gl/gl_mock.h" using ::testing::_; using ::testing::DoAll; using ::testing::InSequence; using ::testing::MatcherCast; using ::testing::Pointee; using ::testing::Return; using ::testing::ReturnRef; using ::testing::SetArrayArgument; using ::testing::SetArgPointee; using ::testing::StrEq; namespace gpu { namespace gles2 { namespace { const uint32 kMaxVaryingVectors = 8; void ShaderCacheCb(const std::string& key, const std::string& shader) {} uint32 ComputeOffset(const void* start, const void* position) { return static_cast<const uint8*>(position) - static_cast<const uint8*>(start); } } // namespace anonymous class ProgramManagerTest : public GpuServiceTest { public: ProgramManagerTest() : manager_(NULL, kMaxVaryingVectors) { } ~ProgramManagerTest() override { manager_.Destroy(false); } protected: ProgramManager manager_; }; TEST_F(ProgramManagerTest, Basic) { const GLuint kClient1Id = 1; const GLuint kService1Id = 11; const GLuint kClient2Id = 2; // Check we can create program. manager_.CreateProgram(kClient1Id, kService1Id); // Check program got created. Program* program1 = manager_.GetProgram(kClient1Id); ASSERT_TRUE(program1 != NULL); GLuint client_id = 0; EXPECT_TRUE(manager_.GetClientId(program1->service_id(), &client_id)); EXPECT_EQ(kClient1Id, client_id); // Check we get nothing for a non-existent program. EXPECT_TRUE(manager_.GetProgram(kClient2Id) == NULL); } TEST_F(ProgramManagerTest, Destroy) { const GLuint kClient1Id = 1; const GLuint kService1Id = 11; // Check we can create program. Program* program0 = manager_.CreateProgram(kClient1Id, kService1Id); ASSERT_TRUE(program0 != NULL); // Check program got created. Program* program1 = manager_.GetProgram(kClient1Id); ASSERT_EQ(program0, program1); EXPECT_CALL(*gl_, DeleteProgram(kService1Id)) .Times(1) .RetiresOnSaturation(); manager_.Destroy(true); // Check the resources were released. program1 = manager_.GetProgram(kClient1Id); ASSERT_TRUE(program1 == NULL); } TEST_F(ProgramManagerTest, DeleteBug) { ShaderManager shader_manager; const GLuint kClient1Id = 1; const GLuint kClient2Id = 2; const GLuint kService1Id = 11; const GLuint kService2Id = 12; // Check we can create program. scoped_refptr<Program> program1( manager_.CreateProgram(kClient1Id, kService1Id)); scoped_refptr<Program> program2( manager_.CreateProgram(kClient2Id, kService2Id)); // Check program got created. ASSERT_TRUE(program1.get()); ASSERT_TRUE(program2.get()); manager_.UseProgram(program1.get()); manager_.MarkAsDeleted(&shader_manager, program1.get()); // Program will be deleted when last ref is released. EXPECT_CALL(*gl_, DeleteProgram(kService2Id)) .Times(1) .RetiresOnSaturation(); manager_.MarkAsDeleted(&shader_manager, program2.get()); EXPECT_TRUE(manager_.IsOwned(program1.get())); EXPECT_FALSE(manager_.IsOwned(program2.get())); } TEST_F(ProgramManagerTest, Program) { const GLuint kClient1Id = 1; const GLuint kService1Id = 11; // Check we can create program. Program* program1 = manager_.CreateProgram( kClient1Id, kService1Id); ASSERT_TRUE(program1); EXPECT_EQ(kService1Id, program1->service_id()); EXPECT_FALSE(program1->InUse()); EXPECT_FALSE(program1->IsValid()); EXPECT_FALSE(program1->IsDeleted()); EXPECT_FALSE(program1->CanLink()); EXPECT_TRUE(program1->log_info() == NULL); } class ProgramManagerWithShaderTest : public GpuServiceTest { public: ProgramManagerWithShaderTest() : manager_(NULL, kMaxVaryingVectors), program_(NULL) { } ~ProgramManagerWithShaderTest() override { manager_.Destroy(false); shader_manager_.Destroy(false); } static const GLint kNumVertexAttribs = 16; static const GLuint kClientProgramId = 123; static const GLuint kServiceProgramId = 456; static const GLuint kVertexShaderClientId = 201; static const GLuint kFragmentShaderClientId = 202; static const GLuint kVertexShaderServiceId = 301; static const GLuint kFragmentShaderServiceId = 302; static const char* kAttrib1Name; static const char* kAttrib2Name; static const char* kAttrib3Name; static const GLint kAttrib1Size = 1; static const GLint kAttrib2Size = 1; static const GLint kAttrib3Size = 1; static const GLenum kAttrib1Precision = GL_MEDIUM_FLOAT; static const GLenum kAttrib2Precision = GL_HIGH_FLOAT; static const GLenum kAttrib3Precision = GL_LOW_FLOAT; static const bool kAttribStaticUse = true; static const GLint kAttrib1Location = 0; static const GLint kAttrib2Location = 1; static const GLint kAttrib3Location = 2; static const GLenum kAttrib1Type = GL_FLOAT_VEC4; static const GLenum kAttrib2Type = GL_FLOAT_VEC2; static const GLenum kAttrib3Type = GL_FLOAT_VEC3; static const GLint kInvalidAttribLocation = 30; static const GLint kBadAttribIndex = kNumVertexAttribs; static const char* kUniform1Name; static const char* kUniform2Name; static const char* kUniform2NameWithArrayIndex; static const char* kUniform3Name; static const char* kUniform3NameWithArrayIndex; static const GLint kUniform1Size = 1; static const GLint kUniform2Size = 3; static const GLint kUniform3Size = 2; static const int kUniform1Precision = GL_LOW_FLOAT; static const int kUniform2Precision = GL_MEDIUM_INT; static const int kUniform3Precision = GL_HIGH_FLOAT; static const int kUniform1StaticUse = 1; static const int kUniform2StaticUse = 1; static const int kUniform3StaticUse = 1; static const GLint kUniform1FakeLocation = 0; // These are hard coded static const GLint kUniform2FakeLocation = 1; // to match static const GLint kUniform3FakeLocation = 2; // ProgramManager. static const GLint kUniform1RealLocation = 11; static const GLint kUniform2RealLocation = 22; static const GLint kUniform3RealLocation = 33; static const GLint kUniform1DesiredLocation = -1; static const GLint kUniform2DesiredLocation = -1; static const GLint kUniform3DesiredLocation = -1; static const GLenum kUniform1Type = GL_FLOAT_VEC4; static const GLenum kUniform2Type = GL_INT_VEC2; static const GLenum kUniform3Type = GL_FLOAT_VEC3; static const GLint kInvalidUniformLocation = 30; static const GLint kBadUniformIndex = 1000; static const size_t kNumAttribs; static const size_t kNumUniforms; protected: typedef TestHelper::AttribInfo AttribInfo; typedef TestHelper::UniformInfo UniformInfo; typedef enum { kVarUniform, kVarVarying, kVarAttribute } VarCategory; typedef struct { GLenum type; GLint size; GLenum precision; bool static_use; std::string name; VarCategory category; } VarInfo; void SetUp() override { // Need to be at leat 3.1 for UniformBlock related GL APIs. GpuServiceTest::SetUpWithGLVersion("3.1", NULL); SetupDefaultShaderExpectations(); Shader* vertex_shader = shader_manager_.CreateShader( kVertexShaderClientId, kVertexShaderServiceId, GL_VERTEX_SHADER); Shader* fragment_shader = shader_manager_.CreateShader( kFragmentShaderClientId, kFragmentShaderServiceId, GL_FRAGMENT_SHADER); ASSERT_TRUE(vertex_shader != NULL); ASSERT_TRUE(fragment_shader != NULL); TestHelper::SetShaderStates(gl_.get(), vertex_shader, true); TestHelper::SetShaderStates(gl_.get(), fragment_shader, true); program_ = manager_.CreateProgram( kClientProgramId, kServiceProgramId); ASSERT_TRUE(program_ != NULL); program_->AttachShader(&shader_manager_, vertex_shader); program_->AttachShader(&shader_manager_, fragment_shader); program_->Link(NULL, Program::kCountOnlyStaticallyUsed, base::Bind(&ShaderCacheCb)); } void SetupShader(AttribInfo* attribs, size_t num_attribs, UniformInfo* uniforms, size_t num_uniforms, GLuint service_id) { TestHelper::SetupShader( gl_.get(), attribs, num_attribs, uniforms, num_uniforms, service_id); } void SetupDefaultShaderExpectations() { SetupShader(kAttribs, kNumAttribs, kUniforms, kNumUniforms, kServiceProgramId); } void SetupExpectationsForClearingUniforms( UniformInfo* uniforms, size_t num_uniforms) { TestHelper::SetupExpectationsForClearingUniforms( gl_.get(), uniforms, num_uniforms); } // Return true if link status matches expected_link_status bool LinkAsExpected(Program* program, bool expected_link_status) { GLuint service_id = program->service_id(); if (expected_link_status) { SetupShader(kAttribs, kNumAttribs, kUniforms, kNumUniforms, service_id); } program->Link(NULL, Program::kCountOnlyStaticallyUsed, base::Bind(&ShaderCacheCb)); GLint link_status; program->GetProgramiv(GL_LINK_STATUS, &link_status); return (static_cast<bool>(link_status) == expected_link_status); } Program* SetupShaderVariableTest(const VarInfo* vertex_variables, size_t vertex_variable_size, const VarInfo* fragment_variables, size_t fragment_variable_size) { // Set up shader const GLuint kVShaderClientId = 1; const GLuint kVShaderServiceId = 11; const GLuint kFShaderClientId = 2; const GLuint kFShaderServiceId = 12; AttributeMap vertex_attrib_map; UniformMap vertex_uniform_map; VaryingMap vertex_varying_map; for (size_t ii = 0; ii < vertex_variable_size; ++ii) { switch (vertex_variables[ii].category) { case kVarAttribute: vertex_attrib_map[vertex_variables[ii].name] = TestHelper::ConstructAttribute( vertex_variables[ii].type, vertex_variables[ii].size, vertex_variables[ii].precision, vertex_variables[ii].static_use, vertex_variables[ii].name); break; case kVarUniform: vertex_uniform_map[vertex_variables[ii].name] = TestHelper::ConstructUniform( vertex_variables[ii].type, vertex_variables[ii].size, vertex_variables[ii].precision, vertex_variables[ii].static_use, vertex_variables[ii].name); break; case kVarVarying: vertex_varying_map[vertex_variables[ii].name] = TestHelper::ConstructVarying( vertex_variables[ii].type, vertex_variables[ii].size, vertex_variables[ii].precision, vertex_variables[ii].static_use, vertex_variables[ii].name); break; default: NOTREACHED(); } } AttributeMap frag_attrib_map; UniformMap frag_uniform_map; VaryingMap frag_varying_map; for (size_t ii = 0; ii < fragment_variable_size; ++ii) { switch (fragment_variables[ii].category) { case kVarAttribute: frag_attrib_map[fragment_variables[ii].name] = TestHelper::ConstructAttribute( fragment_variables[ii].type, fragment_variables[ii].size, fragment_variables[ii].precision, fragment_variables[ii].static_use, fragment_variables[ii].name); break; case kVarUniform: frag_uniform_map[fragment_variables[ii].name] = TestHelper::ConstructUniform( fragment_variables[ii].type, fragment_variables[ii].size, fragment_variables[ii].precision, fragment_variables[ii].static_use, fragment_variables[ii].name); break; case kVarVarying: frag_varying_map[fragment_variables[ii].name] = TestHelper::ConstructVarying( fragment_variables[ii].type, fragment_variables[ii].size, fragment_variables[ii].precision, fragment_variables[ii].static_use, fragment_variables[ii].name); break; default: NOTREACHED(); } } // Check we can create shader. Shader* vshader = shader_manager_.CreateShader( kVShaderClientId, kVShaderServiceId, GL_VERTEX_SHADER); Shader* fshader = shader_manager_.CreateShader( kFShaderClientId, kFShaderServiceId, GL_FRAGMENT_SHADER); // Check shader got created. EXPECT_TRUE(vshader != NULL && fshader != NULL); // Set Status TestHelper::SetShaderStates( gl_.get(), vshader, true, NULL, NULL, &vertex_attrib_map, &vertex_uniform_map, &vertex_varying_map, NULL); TestHelper::SetShaderStates( gl_.get(), fshader, true, NULL, NULL, &frag_attrib_map, &frag_uniform_map, &frag_varying_map, NULL); // Set up program const GLuint kClientProgramId = 6666; const GLuint kServiceProgramId = 8888; Program* program = manager_.CreateProgram(kClientProgramId, kServiceProgramId); EXPECT_TRUE(program != NULL); EXPECT_TRUE(program->AttachShader(&shader_manager_, vshader)); EXPECT_TRUE(program->AttachShader(&shader_manager_, fshader)); return program; } static AttribInfo kAttribs[]; static UniformInfo kUniforms[]; ProgramManager manager_; Program* program_; ShaderManager shader_manager_; }; ProgramManagerWithShaderTest::AttribInfo ProgramManagerWithShaderTest::kAttribs[] = { { kAttrib1Name, kAttrib1Size, kAttrib1Type, kAttrib1Location, }, { kAttrib2Name, kAttrib2Size, kAttrib2Type, kAttrib2Location, }, { kAttrib3Name, kAttrib3Size, kAttrib3Type, kAttrib3Location, }, }; // GCC requires these declarations, but MSVC requires they not be present #ifndef COMPILER_MSVC const GLint ProgramManagerWithShaderTest::kNumVertexAttribs; const GLuint ProgramManagerWithShaderTest::kClientProgramId; const GLuint ProgramManagerWithShaderTest::kServiceProgramId; const GLuint ProgramManagerWithShaderTest::kVertexShaderClientId; const GLuint ProgramManagerWithShaderTest::kFragmentShaderClientId; const GLuint ProgramManagerWithShaderTest::kVertexShaderServiceId; const GLuint ProgramManagerWithShaderTest::kFragmentShaderServiceId; const GLint ProgramManagerWithShaderTest::kAttrib1Size; const GLint ProgramManagerWithShaderTest::kAttrib2Size; const GLint ProgramManagerWithShaderTest::kAttrib3Size; const GLint ProgramManagerWithShaderTest::kAttrib1Location; const GLint ProgramManagerWithShaderTest::kAttrib2Location; const GLint ProgramManagerWithShaderTest::kAttrib3Location; const GLenum ProgramManagerWithShaderTest::kAttrib1Type; const GLenum ProgramManagerWithShaderTest::kAttrib2Type; const GLenum ProgramManagerWithShaderTest::kAttrib3Type; const GLint ProgramManagerWithShaderTest::kInvalidAttribLocation; const GLint ProgramManagerWithShaderTest::kBadAttribIndex; const GLint ProgramManagerWithShaderTest::kUniform1Size; const GLint ProgramManagerWithShaderTest::kUniform2Size; const GLint ProgramManagerWithShaderTest::kUniform3Size; const GLint ProgramManagerWithShaderTest::kUniform1FakeLocation; const GLint ProgramManagerWithShaderTest::kUniform2FakeLocation; const GLint ProgramManagerWithShaderTest::kUniform3FakeLocation; const GLint ProgramManagerWithShaderTest::kUniform1RealLocation; const GLint ProgramManagerWithShaderTest::kUniform2RealLocation; const GLint ProgramManagerWithShaderTest::kUniform3RealLocation; const GLint ProgramManagerWithShaderTest::kUniform1DesiredLocation; const GLint ProgramManagerWithShaderTest::kUniform2DesiredLocation; const GLint ProgramManagerWithShaderTest::kUniform3DesiredLocation; const GLenum ProgramManagerWithShaderTest::kUniform1Type; const GLenum ProgramManagerWithShaderTest::kUniform2Type; const GLenum ProgramManagerWithShaderTest::kUniform3Type; const GLint ProgramManagerWithShaderTest::kInvalidUniformLocation; const GLint ProgramManagerWithShaderTest::kBadUniformIndex; #endif const size_t ProgramManagerWithShaderTest::kNumAttribs = arraysize(ProgramManagerWithShaderTest::kAttribs); ProgramManagerWithShaderTest::UniformInfo ProgramManagerWithShaderTest::kUniforms[] = { { kUniform1Name, kUniform1Size, kUniform1Type, kUniform1FakeLocation, kUniform1RealLocation, kUniform1DesiredLocation, kUniform1Name, }, { kUniform2Name, kUniform2Size, kUniform2Type, kUniform2FakeLocation, kUniform2RealLocation, kUniform2DesiredLocation, kUniform2NameWithArrayIndex, }, { kUniform3Name, kUniform3Size, kUniform3Type, kUniform3FakeLocation, kUniform3RealLocation, kUniform3DesiredLocation, kUniform3NameWithArrayIndex, }, }; const size_t ProgramManagerWithShaderTest::kNumUniforms = arraysize(ProgramManagerWithShaderTest::kUniforms); const char* ProgramManagerWithShaderTest::kAttrib1Name = "attrib1"; const char* ProgramManagerWithShaderTest::kAttrib2Name = "attrib2"; const char* ProgramManagerWithShaderTest::kAttrib3Name = "attrib3"; const char* ProgramManagerWithShaderTest::kUniform1Name = "uniform1"; const char* ProgramManagerWithShaderTest::kUniform2Name = "uniform2"; const char* ProgramManagerWithShaderTest::kUniform2NameWithArrayIndex = "uniform2[0]"; const char* ProgramManagerWithShaderTest::kUniform3Name = "uniform3"; const char* ProgramManagerWithShaderTest::kUniform3NameWithArrayIndex = "uniform3[0]"; TEST_F(ProgramManagerWithShaderTest, GetAttribInfos) { const Program* program = manager_.GetProgram(kClientProgramId); ASSERT_TRUE(program != NULL); const Program::AttribInfoVector& infos = program->GetAttribInfos(); ASSERT_EQ(kNumAttribs, infos.size()); for (size_t ii = 0; ii < kNumAttribs; ++ii) { const Program::VertexAttrib& info = infos[ii]; const AttribInfo& expected = kAttribs[ii]; EXPECT_EQ(expected.size, info.size); EXPECT_EQ(expected.type, info.type); EXPECT_EQ(expected.location, info.location); EXPECT_STREQ(expected.name, info.name.c_str()); } } TEST_F(ProgramManagerWithShaderTest, GetAttribInfo) { const GLint kValidIndex = 1; const GLint kInvalidIndex = 1000; const Program* program = manager_.GetProgram(kClientProgramId); ASSERT_TRUE(program != NULL); const Program::VertexAttrib* info = program->GetAttribInfo(kValidIndex); ASSERT_TRUE(info != NULL); EXPECT_EQ(kAttrib2Size, info->size); EXPECT_EQ(kAttrib2Type, info->type); EXPECT_EQ(kAttrib2Location, info->location); EXPECT_STREQ(kAttrib2Name, info->name.c_str()); EXPECT_TRUE(program->GetAttribInfo(kInvalidIndex) == NULL); } TEST_F(ProgramManagerWithShaderTest, GetAttribLocation) { const char* kInvalidName = "foo"; const Program* program = manager_.GetProgram(kClientProgramId); ASSERT_TRUE(program != NULL); EXPECT_EQ(kAttrib2Location, program->GetAttribLocation(kAttrib2Name)); EXPECT_EQ(-1, program->GetAttribLocation(kInvalidName)); } TEST_F(ProgramManagerWithShaderTest, GetUniformInfo) { const GLint kInvalidIndex = 1000; const Program* program = manager_.GetProgram(kClientProgramId); ASSERT_TRUE(program != NULL); const Program::UniformInfo* info = program->GetUniformInfo(0); ASSERT_TRUE(info != NULL); EXPECT_EQ(kUniform1Size, info->size); EXPECT_EQ(kUniform1Type, info->type); EXPECT_EQ(kUniform1RealLocation, info->element_locations[0]); EXPECT_STREQ(kUniform1Name, info->name.c_str()); info = program->GetUniformInfo(1); ASSERT_TRUE(info != NULL); EXPECT_EQ(kUniform2Size, info->size); EXPECT_EQ(kUniform2Type, info->type); EXPECT_EQ(kUniform2RealLocation, info->element_locations[0]); EXPECT_STREQ(kUniform2NameWithArrayIndex, info->name.c_str()); info = program->GetUniformInfo(2); // We emulate certain OpenGL drivers by supplying the name without // the array spec. Our implementation should correctly add the required spec. ASSERT_TRUE(info != NULL); EXPECT_EQ(kUniform3Size, info->size); EXPECT_EQ(kUniform3Type, info->type); EXPECT_EQ(kUniform3RealLocation, info->element_locations[0]); EXPECT_STREQ(kUniform3NameWithArrayIndex, info->name.c_str()); EXPECT_TRUE(program->GetUniformInfo(kInvalidIndex) == NULL); } TEST_F(ProgramManagerWithShaderTest, AttachDetachShader) { static const GLuint kClientProgramId = 124; static const GLuint kServiceProgramId = 457; Program* program = manager_.CreateProgram( kClientProgramId, kServiceProgramId); ASSERT_TRUE(program != NULL); EXPECT_FALSE(program->CanLink()); const GLuint kVShaderClientId = 2001; const GLuint kFShaderClientId = 2002; const GLuint kVShaderServiceId = 3001; const GLuint kFShaderServiceId = 3002; Shader* vshader = shader_manager_.CreateShader( kVShaderClientId, kVShaderServiceId, GL_VERTEX_SHADER); ASSERT_TRUE(vshader != NULL); TestHelper::SetShaderStates(gl_.get(), vshader, true); Shader* fshader = shader_manager_.CreateShader( kFShaderClientId, kFShaderServiceId, GL_FRAGMENT_SHADER); ASSERT_TRUE(fshader != NULL); TestHelper::SetShaderStates(gl_.get(), fshader, true); EXPECT_TRUE(program->AttachShader(&shader_manager_, vshader)); EXPECT_FALSE(program->CanLink()); EXPECT_TRUE(program->AttachShader(&shader_manager_, fshader)); EXPECT_TRUE(program->CanLink()); program->DetachShader(&shader_manager_, vshader); EXPECT_FALSE(program->CanLink()); EXPECT_TRUE(program->AttachShader(&shader_manager_, vshader)); EXPECT_TRUE(program->CanLink()); program->DetachShader(&shader_manager_, fshader); EXPECT_FALSE(program->CanLink()); EXPECT_FALSE(program->AttachShader(&shader_manager_, vshader)); EXPECT_FALSE(program->CanLink()); EXPECT_TRUE(program->AttachShader(&shader_manager_, fshader)); EXPECT_TRUE(program->CanLink()); TestHelper::SetShaderStates(gl_.get(), vshader, false); EXPECT_FALSE(program->CanLink()); TestHelper::SetShaderStates(gl_.get(), vshader, true); EXPECT_TRUE(program->CanLink()); TestHelper::SetShaderStates(gl_.get(), fshader, false); EXPECT_FALSE(program->CanLink()); TestHelper::SetShaderStates(gl_.get(), fshader, true); EXPECT_TRUE(program->CanLink()); EXPECT_TRUE(program->DetachShader(&shader_manager_, fshader)); EXPECT_FALSE(program->DetachShader(&shader_manager_, fshader)); } TEST_F(ProgramManagerWithShaderTest, GetUniformFakeLocation) { const Program* program = manager_.GetProgram(kClientProgramId); ASSERT_TRUE(program != NULL); // Emulate the situation that uniform3[1] isn't used and optimized out by // a driver, so it's location is -1. Program::UniformInfo* uniform = const_cast<Program::UniformInfo*>( program->GetUniformInfo(2)); ASSERT_TRUE(uniform != NULL && kUniform3Size == 2); EXPECT_EQ(kUniform3Size, uniform->size); uniform->element_locations[1] = -1; EXPECT_EQ(kUniform1FakeLocation, program->GetUniformFakeLocation(kUniform1Name)); EXPECT_EQ(kUniform2FakeLocation, program->GetUniformFakeLocation(kUniform2Name)); EXPECT_EQ(kUniform3FakeLocation, program->GetUniformFakeLocation(kUniform3Name)); // Check we can get uniform2 as "uniform2" even though the name is // "uniform2[0]" EXPECT_EQ(kUniform2FakeLocation, program->GetUniformFakeLocation("uniform2")); // Check we can get uniform3 as "uniform3[0]" even though we simulated GL // returning "uniform3" EXPECT_EQ(kUniform3FakeLocation, program->GetUniformFakeLocation(kUniform3NameWithArrayIndex)); // Check that we can get the locations of the array elements > 1 EXPECT_EQ(ProgramManager::MakeFakeLocation(kUniform2FakeLocation, 1), program->GetUniformFakeLocation("uniform2[1]")); EXPECT_EQ(ProgramManager::MakeFakeLocation(kUniform2FakeLocation, 2), program->GetUniformFakeLocation("uniform2[2]")); EXPECT_EQ(-1, program->GetUniformFakeLocation("uniform2[3]")); EXPECT_EQ(-1, program->GetUniformFakeLocation("uniform3[1]")); EXPECT_EQ(-1, program->GetUniformFakeLocation("uniform3[2]")); } TEST_F(ProgramManagerWithShaderTest, GetUniformInfoByFakeLocation) { const GLint kInvalidLocation = 1234; const Program::UniformInfo* info; const Program* program = manager_.GetProgram(kClientProgramId); GLint real_location = -1; GLint array_index = -1; ASSERT_TRUE(program != NULL); info = program->GetUniformInfoByFakeLocation( kUniform2FakeLocation, &real_location, &array_index); EXPECT_EQ(kUniform2RealLocation, real_location); EXPECT_EQ(0, array_index); ASSERT_TRUE(info != NULL); EXPECT_EQ(kUniform2Type, info->type); real_location = -1; array_index = -1; info = program->GetUniformInfoByFakeLocation( kInvalidLocation, &real_location, &array_index); EXPECT_TRUE(info == NULL); EXPECT_EQ(-1, real_location); EXPECT_EQ(-1, array_index); GLint loc = program->GetUniformFakeLocation("uniform2[2]"); info = program->GetUniformInfoByFakeLocation( loc, &real_location, &array_index); ASSERT_TRUE(info != NULL); EXPECT_EQ(kUniform2RealLocation + 2 * 2, real_location); EXPECT_EQ(2, array_index); } // Some GL drivers incorrectly return gl_DepthRange and possibly other uniforms // that start with "gl_". Our implementation catches these and does not allow // them back to client. TEST_F(ProgramManagerWithShaderTest, GLDriverReturnsGLUnderscoreUniform) { static const char* kUniform2Name = "gl_longNameWeCanCheckFor"; static ProgramManagerWithShaderTest::UniformInfo kUniforms[] = { { kUniform1Name, kUniform1Size, kUniform1Type, kUniform1FakeLocation, kUniform1RealLocation, kUniform1DesiredLocation, kUniform1Name, }, { kUniform2Name, kUniform2Size, kUniform2Type, kUniform2FakeLocation, kUniform2RealLocation, kUniform2DesiredLocation, kUniform2NameWithArrayIndex, }, { kUniform3Name, kUniform3Size, kUniform3Type, kUniform3FakeLocation, kUniform3RealLocation, kUniform3DesiredLocation, kUniform3NameWithArrayIndex, }, }; const size_t kNumUniforms = arraysize(kUniforms); static const GLuint kClientProgramId = 1234; static const GLuint kServiceProgramId = 5679; const GLuint kVShaderClientId = 2001; const GLuint kFShaderClientId = 2002; const GLuint kVShaderServiceId = 3001; const GLuint kFShaderServiceId = 3002; SetupShader( kAttribs, kNumAttribs, kUniforms, kNumUniforms, kServiceProgramId); Shader* vshader = shader_manager_.CreateShader( kVShaderClientId, kVShaderServiceId, GL_VERTEX_SHADER); ASSERT_TRUE(vshader != NULL); TestHelper::SetShaderStates(gl_.get(), vshader, true); Shader* fshader = shader_manager_.CreateShader( kFShaderClientId, kFShaderServiceId, GL_FRAGMENT_SHADER); ASSERT_TRUE(fshader != NULL); TestHelper::SetShaderStates(gl_.get(), fshader, true); Program* program = manager_.CreateProgram(kClientProgramId, kServiceProgramId); ASSERT_TRUE(program != NULL); EXPECT_TRUE(program->AttachShader(&shader_manager_, vshader)); EXPECT_TRUE(program->AttachShader(&shader_manager_, fshader)); program->Link(NULL, Program::kCountOnlyStaticallyUsed, base::Bind(&ShaderCacheCb)); GLint value = 0; program->GetProgramiv(GL_ACTIVE_ATTRIBUTES, &value); EXPECT_EQ(3, value); // Check that we skipped the "gl_" uniform. program->GetProgramiv(GL_ACTIVE_UNIFORMS, &value); EXPECT_EQ(2, value); // Check that our max length adds room for the array spec and is not as long // as the "gl_" uniform we skipped. // +4u is to account for "gl_" and NULL terminator. program->GetProgramiv(GL_ACTIVE_UNIFORM_MAX_LENGTH, &value); EXPECT_EQ(strlen(kUniform3Name) + 4u, static_cast<size_t>(value)); } // Test the bug comparing similar array names is fixed. TEST_F(ProgramManagerWithShaderTest, SimilarArrayNames) { static const char* kUniform2Name = "u_nameLong[0]"; static const char* kUniform3Name = "u_name[0]"; static const GLint kUniform2Size = 2; static const GLint kUniform3Size = 2; static ProgramManagerWithShaderTest::UniformInfo kUniforms[] = { { kUniform1Name, kUniform1Size, kUniform1Type, kUniform1FakeLocation, kUniform1RealLocation, kUniform1DesiredLocation, kUniform1Name, }, { kUniform2Name, kUniform2Size, kUniform2Type, kUniform2FakeLocation, kUniform2RealLocation, kUniform2DesiredLocation, kUniform2Name, }, { kUniform3Name, kUniform3Size, kUniform3Type, kUniform3FakeLocation, kUniform3RealLocation, kUniform3DesiredLocation, kUniform3Name, }, }; const size_t kNumUniforms = arraysize(kUniforms); static const GLuint kClientProgramId = 1234; static const GLuint kServiceProgramId = 5679; const GLuint kVShaderClientId = 2001; const GLuint kFShaderClientId = 2002; const GLuint kVShaderServiceId = 3001; const GLuint kFShaderServiceId = 3002; SetupShader( kAttribs, kNumAttribs, kUniforms, kNumUniforms, kServiceProgramId); Shader* vshader = shader_manager_.CreateShader( kVShaderClientId, kVShaderServiceId, GL_VERTEX_SHADER); ASSERT_TRUE(vshader != NULL); TestHelper::SetShaderStates(gl_.get(), vshader, true); Shader* fshader = shader_manager_.CreateShader( kFShaderClientId, kFShaderServiceId, GL_FRAGMENT_SHADER); ASSERT_TRUE(fshader != NULL); TestHelper::SetShaderStates(gl_.get(), fshader, true); Program* program = manager_.CreateProgram(kClientProgramId, kServiceProgramId); ASSERT_TRUE(program != NULL); EXPECT_TRUE(program->AttachShader(&shader_manager_, vshader)); EXPECT_TRUE(program->AttachShader(&shader_manager_, fshader)); program->Link(NULL, Program::kCountOnlyStaticallyUsed, base::Bind(&ShaderCacheCb)); // Check that we get the correct locations. EXPECT_EQ(kUniform2FakeLocation, program->GetUniformFakeLocation(kUniform2Name)); EXPECT_EQ(kUniform3FakeLocation, program->GetUniformFakeLocation(kUniform3Name)); } // Some GL drivers incorrectly return the wrong type. For example they return // GL_FLOAT_VEC2 when they should return GL_FLOAT_MAT2. Check we handle this. TEST_F(ProgramManagerWithShaderTest, GLDriverReturnsWrongTypeInfo) { static GLenum kAttrib2BadType = GL_FLOAT_VEC2; static GLenum kAttrib2GoodType = GL_FLOAT_MAT2; static GLenum kUniform2BadType = GL_FLOAT_VEC3; static GLenum kUniform2GoodType = GL_FLOAT_MAT3; AttributeMap attrib_map; UniformMap uniform_map; VaryingMap varying_map; attrib_map[kAttrib1Name] = TestHelper::ConstructAttribute( kAttrib1Type, kAttrib1Size, kAttrib1Precision, kAttribStaticUse, kAttrib1Name); attrib_map[kAttrib2Name] = TestHelper::ConstructAttribute( kAttrib2GoodType, kAttrib2Size, kAttrib2Precision, kAttribStaticUse, kAttrib2Name); attrib_map[kAttrib3Name] = TestHelper::ConstructAttribute( kAttrib3Type, kAttrib3Size, kAttrib3Precision, kAttribStaticUse, kAttrib3Name); uniform_map[kUniform1Name] = TestHelper::ConstructUniform( kUniform1Type, kUniform1Size, kUniform1Precision, kUniform1StaticUse, kUniform1Name); uniform_map[kUniform2Name] = TestHelper::ConstructUniform( kUniform2GoodType, kUniform2Size, kUniform2Precision, kUniform2StaticUse, kUniform2Name); uniform_map[kUniform3Name] = TestHelper::ConstructUniform( kUniform3Type, kUniform3Size, kUniform3Precision, kUniform3StaticUse, kUniform3Name); const GLuint kVShaderClientId = 2001; const GLuint kFShaderClientId = 2002; const GLuint kVShaderServiceId = 3001; const GLuint kFShaderServiceId = 3002; Shader* vshader = shader_manager_.CreateShader( kVShaderClientId, kVShaderServiceId, GL_VERTEX_SHADER); ASSERT_TRUE(vshader != NULL); TestHelper::SetShaderStates( gl_.get(), vshader, true, NULL, NULL, &attrib_map, &uniform_map, &varying_map, NULL); Shader* fshader = shader_manager_.CreateShader( kFShaderClientId, kFShaderServiceId, GL_FRAGMENT_SHADER); ASSERT_TRUE(fshader != NULL); TestHelper::SetShaderStates( gl_.get(), fshader, true, NULL, NULL, &attrib_map, &uniform_map, &varying_map, NULL); static ProgramManagerWithShaderTest::AttribInfo kAttribs[] = { { kAttrib1Name, kAttrib1Size, kAttrib1Type, kAttrib1Location, }, { kAttrib2Name, kAttrib2Size, kAttrib2BadType, kAttrib2Location, }, { kAttrib3Name, kAttrib3Size, kAttrib3Type, kAttrib3Location, }, }; static ProgramManagerWithShaderTest::UniformInfo kUniforms[] = { { kUniform1Name, kUniform1Size, kUniform1Type, kUniform1FakeLocation, kUniform1RealLocation, kUniform1DesiredLocation, kUniform1Name, }, { kUniform2Name, kUniform2Size, kUniform2BadType, kUniform2FakeLocation, kUniform2RealLocation, kUniform2DesiredLocation, kUniform2NameWithArrayIndex, }, { kUniform3Name, kUniform3Size, kUniform3Type, kUniform3FakeLocation, kUniform3RealLocation, kUniform3DesiredLocation, kUniform3NameWithArrayIndex, }, }; const size_t kNumAttribs= arraysize(kAttribs); const size_t kNumUniforms = arraysize(kUniforms); static const GLuint kClientProgramId = 1234; static const GLuint kServiceProgramId = 5679; SetupShader(kAttribs, kNumAttribs, kUniforms, kNumUniforms, kServiceProgramId); Program* program = manager_.CreateProgram( kClientProgramId, kServiceProgramId); ASSERT_TRUE(program!= NULL); EXPECT_TRUE(program->AttachShader(&shader_manager_, vshader)); EXPECT_TRUE(program->AttachShader(&shader_manager_, fshader)); program->Link(NULL, Program::kCountOnlyStaticallyUsed, base::Bind(&ShaderCacheCb)); // Check that we got the good type, not the bad. // Check Attribs for (unsigned index = 0; index < kNumAttribs; ++index) { const Program::VertexAttrib* attrib_info = program->GetAttribInfo(index); ASSERT_TRUE(attrib_info != NULL); size_t pos = attrib_info->name.find_first_of("[."); std::string top_name; if (pos == std::string::npos) top_name = attrib_info->name; else top_name = attrib_info->name.substr(0, pos); AttributeMap::const_iterator it = attrib_map.find(top_name); ASSERT_TRUE(it != attrib_map.end()); const sh::ShaderVariable* info; std::string original_name; EXPECT_TRUE(it->second.findInfoByMappedName( attrib_info->name, &info, &original_name)); EXPECT_EQ(info->type, attrib_info->type); EXPECT_EQ(static_cast<GLint>(info->arraySize), attrib_info->size); EXPECT_EQ(original_name, attrib_info->name); } // Check Uniforms for (unsigned index = 0; index < kNumUniforms; ++index) { const Program::UniformInfo* uniform_info = program->GetUniformInfo(index); ASSERT_TRUE(uniform_info != NULL); size_t pos = uniform_info->name.find_first_of("[."); std::string top_name; if (pos == std::string::npos) top_name = uniform_info->name; else top_name = uniform_info->name.substr(0, pos); UniformMap::const_iterator it = uniform_map.find(top_name); ASSERT_TRUE(it != uniform_map.end()); const sh::ShaderVariable* info; std::string original_name; EXPECT_TRUE(it->second.findInfoByMappedName( uniform_info->name, &info, &original_name)); EXPECT_EQ(info->type, uniform_info->type); EXPECT_EQ(static_cast<GLint>(info->arraySize), uniform_info->size); EXPECT_EQ(original_name, uniform_info->name); } } TEST_F(ProgramManagerWithShaderTest, ProgramInfoUseCount) { static const GLuint kClientProgramId = 124; static const GLuint kServiceProgramId = 457; Program* program = manager_.CreateProgram( kClientProgramId, kServiceProgramId); ASSERT_TRUE(program != NULL); EXPECT_FALSE(program->CanLink()); const GLuint kVShaderClientId = 2001; const GLuint kFShaderClientId = 2002; const GLuint kVShaderServiceId = 3001; const GLuint kFShaderServiceId = 3002; Shader* vshader = shader_manager_.CreateShader( kVShaderClientId, kVShaderServiceId, GL_VERTEX_SHADER); ASSERT_TRUE(vshader != NULL); TestHelper::SetShaderStates(gl_.get(), vshader, true); Shader* fshader = shader_manager_.CreateShader( kFShaderClientId, kFShaderServiceId, GL_FRAGMENT_SHADER); ASSERT_TRUE(fshader != NULL); TestHelper::SetShaderStates(gl_.get(), fshader, true); EXPECT_FALSE(vshader->InUse()); EXPECT_FALSE(fshader->InUse()); EXPECT_TRUE(program->AttachShader(&shader_manager_, vshader)); EXPECT_TRUE(vshader->InUse()); EXPECT_TRUE(program->AttachShader(&shader_manager_, fshader)); EXPECT_TRUE(fshader->InUse()); EXPECT_TRUE(program->CanLink()); EXPECT_FALSE(program->InUse()); EXPECT_FALSE(program->IsDeleted()); manager_.UseProgram(program); EXPECT_TRUE(program->InUse()); manager_.UseProgram(program); EXPECT_TRUE(program->InUse()); manager_.MarkAsDeleted(&shader_manager_, program); EXPECT_TRUE(program->IsDeleted()); Program* info2 = manager_.GetProgram(kClientProgramId); EXPECT_EQ(program, info2); manager_.UnuseProgram(&shader_manager_, program); EXPECT_TRUE(program->InUse()); // this should delete the info. EXPECT_CALL(*gl_, DeleteProgram(kServiceProgramId)) .Times(1) .RetiresOnSaturation(); manager_.UnuseProgram(&shader_manager_, program); info2 = manager_.GetProgram(kClientProgramId); EXPECT_TRUE(info2 == NULL); EXPECT_FALSE(vshader->InUse()); EXPECT_FALSE(fshader->InUse()); } TEST_F(ProgramManagerWithShaderTest, ProgramInfoUseCount2) { static const GLuint kClientProgramId = 124; static const GLuint kServiceProgramId = 457; Program* program = manager_.CreateProgram( kClientProgramId, kServiceProgramId); ASSERT_TRUE(program != NULL); EXPECT_FALSE(program->CanLink()); const GLuint kVShaderClientId = 2001; const GLuint kFShaderClientId = 2002; const GLuint kVShaderServiceId = 3001; const GLuint kFShaderServiceId = 3002; Shader* vshader = shader_manager_.CreateShader( kVShaderClientId, kVShaderServiceId, GL_VERTEX_SHADER); ASSERT_TRUE(vshader != NULL); TestHelper::SetShaderStates(gl_.get(), vshader, true); Shader* fshader = shader_manager_.CreateShader( kFShaderClientId, kFShaderServiceId, GL_FRAGMENT_SHADER); ASSERT_TRUE(fshader != NULL); TestHelper::SetShaderStates(gl_.get(), fshader, true); EXPECT_FALSE(vshader->InUse()); EXPECT_FALSE(fshader->InUse()); EXPECT_TRUE(program->AttachShader(&shader_manager_, vshader)); EXPECT_TRUE(vshader->InUse()); EXPECT_TRUE(program->AttachShader(&shader_manager_, fshader)); EXPECT_TRUE(fshader->InUse()); EXPECT_TRUE(program->CanLink()); EXPECT_FALSE(program->InUse()); EXPECT_FALSE(program->IsDeleted()); manager_.UseProgram(program); EXPECT_TRUE(program->InUse()); manager_.UseProgram(program); EXPECT_TRUE(program->InUse()); manager_.UnuseProgram(&shader_manager_, program); EXPECT_TRUE(program->InUse()); manager_.UnuseProgram(&shader_manager_, program); EXPECT_FALSE(program->InUse()); Program* info2 = manager_.GetProgram(kClientProgramId); EXPECT_EQ(program, info2); // this should delete the program. EXPECT_CALL(*gl_, DeleteProgram(kServiceProgramId)) .Times(1) .RetiresOnSaturation(); manager_.MarkAsDeleted(&shader_manager_, program); info2 = manager_.GetProgram(kClientProgramId); EXPECT_TRUE(info2 == NULL); EXPECT_FALSE(vshader->InUse()); EXPECT_FALSE(fshader->InUse()); } TEST_F(ProgramManagerWithShaderTest, ProgramInfoGetProgramInfo) { CommonDecoder::Bucket bucket; const Program* program = manager_.GetProgram(kClientProgramId); ASSERT_TRUE(program != NULL); program->GetProgramInfo(&manager_, &bucket); ProgramInfoHeader* header = bucket.GetDataAs<ProgramInfoHeader*>(0, sizeof(ProgramInfoHeader)); ASSERT_TRUE(header != NULL); EXPECT_EQ(1u, header->link_status); EXPECT_EQ(arraysize(kAttribs), header->num_attribs); EXPECT_EQ(arraysize(kUniforms), header->num_uniforms); const ProgramInput* inputs = bucket.GetDataAs<const ProgramInput*>( sizeof(*header), sizeof(ProgramInput) * (header->num_attribs + header->num_uniforms)); ASSERT_TRUE(inputs != NULL); const ProgramInput* input = inputs; // TODO(gman): Don't assume these are in order. for (uint32 ii = 0; ii < header->num_attribs; ++ii) { const AttribInfo& expected = kAttribs[ii]; EXPECT_EQ(expected.size, input->size); EXPECT_EQ(expected.type, input->type); const int32* location = bucket.GetDataAs<const int32*>( input->location_offset, sizeof(int32)); ASSERT_TRUE(location != NULL); EXPECT_EQ(expected.location, *location); const char* name_buf = bucket.GetDataAs<const char*>( input->name_offset, input->name_length); ASSERT_TRUE(name_buf != NULL); std::string name(name_buf, input->name_length); EXPECT_STREQ(expected.name, name.c_str()); ++input; } // TODO(gman): Don't assume these are in order. for (uint32 ii = 0; ii < header->num_uniforms; ++ii) { const UniformInfo& expected = kUniforms[ii]; EXPECT_EQ(expected.size, input->size); EXPECT_EQ(expected.type, input->type); const int32* locations = bucket.GetDataAs<const int32*>( input->location_offset, sizeof(int32) * input->size); ASSERT_TRUE(locations != NULL); for (int32 jj = 0; jj < input->size; ++jj) { EXPECT_EQ( ProgramManager::MakeFakeLocation(expected.fake_location, jj), locations[jj]); } const char* name_buf = bucket.GetDataAs<const char*>( input->name_offset, input->name_length); ASSERT_TRUE(name_buf != NULL); std::string name(name_buf, input->name_length); EXPECT_STREQ(expected.good_name, name.c_str()); ++input; } EXPECT_EQ(header->num_attribs + header->num_uniforms, static_cast<uint32>(input - inputs)); } TEST_F(ProgramManagerWithShaderTest, ProgramInfoGetUniformBlocksNone) { CommonDecoder::Bucket bucket; const Program* program = manager_.GetProgram(kClientProgramId); ASSERT_TRUE(program != NULL); // The program's previous link failed. EXPECT_CALL(*(gl_.get()), GetProgramiv(kServiceProgramId, GL_LINK_STATUS, _)) .WillOnce(SetArgPointee<2>(GL_FALSE)) .RetiresOnSaturation(); EXPECT_TRUE(program->GetUniformBlocks(&bucket)); EXPECT_EQ(sizeof(UniformBlocksHeader), bucket.size()); UniformBlocksHeader* header = bucket.GetDataAs<UniformBlocksHeader*>(0, sizeof(UniformBlocksHeader)); EXPECT_TRUE(header != NULL); EXPECT_EQ(0u, header->num_uniform_blocks); // Zero uniform blocks. EXPECT_CALL(*(gl_.get()), GetProgramiv(kServiceProgramId, GL_LINK_STATUS, _)) .WillOnce(SetArgPointee<2>(GL_TRUE)) .RetiresOnSaturation(); EXPECT_CALL(*(gl_.get()), GetProgramiv(kServiceProgramId, GL_ACTIVE_UNIFORM_BLOCKS, _)) .WillOnce(SetArgPointee<2>(0)) .RetiresOnSaturation(); EXPECT_TRUE(program->GetUniformBlocks(&bucket)); EXPECT_EQ(sizeof(UniformBlocksHeader), bucket.size()); header = bucket.GetDataAs<UniformBlocksHeader*>(0, sizeof(UniformBlocksHeader)); EXPECT_TRUE(header != NULL); EXPECT_EQ(0u, header->num_uniform_blocks); } TEST_F(ProgramManagerWithShaderTest, ProgramInfoGetUniformBlocksValid) { CommonDecoder::Bucket bucket; const Program* program = manager_.GetProgram(kClientProgramId); ASSERT_TRUE(program != NULL); struct Data { UniformBlocksHeader header; UniformBlockInfo entry[2]; char name0[4]; uint32_t indices0[2]; char name1[8]; uint32_t indices1[1]; }; Data data; // The names needs to be of size 4*k-1 to avoid padding in the struct Data. // This is a testing only problem. const char* kName[] = { "cow", "chicken" }; const uint32_t kIndices0[] = { 1, 2 }; const uint32_t kIndices1[] = { 3 }; const uint32_t* kIndices[] = { kIndices0, kIndices1 }; data.header.num_uniform_blocks = 2; data.entry[0].binding = 0; data.entry[0].data_size = 8; data.entry[0].name_offset = ComputeOffset(&data, data.name0); data.entry[0].name_length = arraysize(data.name0); data.entry[0].active_uniforms = arraysize(data.indices0); data.entry[0].active_uniform_offset = ComputeOffset(&data, data.indices0); data.entry[0].referenced_by_vertex_shader = static_cast<uint32_t>(true); data.entry[0].referenced_by_fragment_shader = static_cast<uint32_t>(false); data.entry[1].binding = 1; data.entry[1].data_size = 4; data.entry[1].name_offset = ComputeOffset(&data, data.name1); data.entry[1].name_length = arraysize(data.name1); data.entry[1].active_uniforms = arraysize(data.indices1); data.entry[1].active_uniform_offset = ComputeOffset(&data, data.indices1); data.entry[1].referenced_by_vertex_shader = static_cast<uint32_t>(false); data.entry[1].referenced_by_fragment_shader = static_cast<uint32_t>(true); memcpy(data.name0, kName[0], arraysize(data.name0)); data.indices0[0] = kIndices[0][0]; data.indices0[1] = kIndices[0][1]; memcpy(data.name1, kName[1], arraysize(data.name1)); data.indices1[0] = kIndices[1][0]; EXPECT_CALL(*(gl_.get()), GetProgramiv(kServiceProgramId, GL_LINK_STATUS, _)) .WillOnce(SetArgPointee<2>(GL_TRUE)) .RetiresOnSaturation(); EXPECT_CALL(*(gl_.get()), GetProgramiv(kServiceProgramId, GL_ACTIVE_UNIFORM_BLOCKS, _)) .WillOnce(SetArgPointee<2>(data.header.num_uniform_blocks)) .RetiresOnSaturation(); EXPECT_CALL(*(gl_.get()), GetProgramiv(kServiceProgramId, GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH, _)) .WillOnce(SetArgPointee<2>( 1 + std::max(strlen(kName[0]), strlen(kName[1])))) .RetiresOnSaturation(); for (uint32_t ii = 0; ii < data.header.num_uniform_blocks; ++ii) { EXPECT_CALL(*(gl_.get()), GetActiveUniformBlockiv( kServiceProgramId, ii, GL_UNIFORM_BLOCK_BINDING, _)) .WillOnce(SetArgPointee<3>(data.entry[ii].binding)) .RetiresOnSaturation(); EXPECT_CALL(*(gl_.get()), GetActiveUniformBlockiv( kServiceProgramId, ii, GL_UNIFORM_BLOCK_DATA_SIZE, _)) .WillOnce(SetArgPointee<3>(data.entry[ii].data_size)) .RetiresOnSaturation(); EXPECT_CALL(*(gl_.get()), GetActiveUniformBlockiv( kServiceProgramId, ii, GL_UNIFORM_BLOCK_NAME_LENGTH, _)) .WillOnce(SetArgPointee<3>(data.entry[ii].name_length)) .RetiresOnSaturation(); EXPECT_CALL(*(gl_.get()), GetActiveUniformBlockName( kServiceProgramId, ii, data.entry[ii].name_length, _, _)) .WillOnce(DoAll( SetArgPointee<3>(strlen(kName[ii])), SetArrayArgument<4>( kName[ii], kName[ii] + data.entry[ii].name_length))) .RetiresOnSaturation(); EXPECT_CALL(*(gl_.get()), GetActiveUniformBlockiv( kServiceProgramId, ii, GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS, _)) .WillOnce(SetArgPointee<3>(data.entry[ii].active_uniforms)) .RetiresOnSaturation(); EXPECT_CALL(*(gl_.get()), GetActiveUniformBlockiv( kServiceProgramId, ii, GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER, _)) .WillOnce(SetArgPointee<3>(data.entry[ii].referenced_by_vertex_shader)) .RetiresOnSaturation(); EXPECT_CALL(*(gl_.get()), GetActiveUniformBlockiv( kServiceProgramId, ii, GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER, _)) .WillOnce(SetArgPointee<3>( data.entry[ii].referenced_by_fragment_shader)) .RetiresOnSaturation(); } for (uint32_t ii = 0; ii < data.header.num_uniform_blocks; ++ii) { EXPECT_CALL(*(gl_.get()), GetActiveUniformBlockiv( kServiceProgramId, ii, GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES, _)) .WillOnce(SetArrayArgument<3>( kIndices[ii], kIndices[ii] + data.entry[ii].active_uniforms)) .RetiresOnSaturation(); } program->GetUniformBlocks(&bucket); EXPECT_EQ(sizeof(Data), bucket.size()); Data* bucket_data = bucket.GetDataAs<Data*>(0, sizeof(Data)); EXPECT_TRUE(bucket_data != NULL); EXPECT_EQ(0, memcmp(&data, bucket_data, sizeof(Data))); } TEST_F(ProgramManagerWithShaderTest, ProgramInfoGetTransformFeedbackVaryingsNone) { CommonDecoder::Bucket bucket; const Program* program = manager_.GetProgram(kClientProgramId); ASSERT_TRUE(program != NULL); // The program's previous link failed. EXPECT_CALL(*(gl_.get()), GetProgramiv(kServiceProgramId, GL_LINK_STATUS, _)) .WillOnce(SetArgPointee<2>(GL_FALSE)) .RetiresOnSaturation(); EXPECT_TRUE(program->GetTransformFeedbackVaryings(&bucket)); EXPECT_EQ(sizeof(TransformFeedbackVaryingsHeader), bucket.size()); TransformFeedbackVaryingsHeader* header = bucket.GetDataAs<TransformFeedbackVaryingsHeader*>( 0, sizeof(TransformFeedbackVaryingsHeader)); EXPECT_TRUE(header != NULL); EXPECT_EQ(0u, header->num_transform_feedback_varyings); // Zero uniform blocks. EXPECT_CALL(*(gl_.get()), GetProgramiv(kServiceProgramId, GL_LINK_STATUS, _)) .WillOnce(SetArgPointee<2>(GL_TRUE)) .RetiresOnSaturation(); EXPECT_CALL(*(gl_.get()), GetProgramiv( kServiceProgramId, GL_TRANSFORM_FEEDBACK_VARYINGS, _)) .WillOnce(SetArgPointee<2>(0)) .RetiresOnSaturation(); EXPECT_TRUE(program->GetTransformFeedbackVaryings(&bucket)); EXPECT_EQ(sizeof(TransformFeedbackVaryingsHeader), bucket.size()); header = bucket.GetDataAs<TransformFeedbackVaryingsHeader*>( 0, sizeof(TransformFeedbackVaryingsHeader)); EXPECT_TRUE(header != NULL); EXPECT_EQ(0u, header->num_transform_feedback_varyings); } TEST_F(ProgramManagerWithShaderTest, ProgramInfoGetTransformFeedbackVaryingsValid) { CommonDecoder::Bucket bucket; const Program* program = manager_.GetProgram(kClientProgramId); ASSERT_TRUE(program != NULL); struct Data { TransformFeedbackVaryingsHeader header; TransformFeedbackVaryingInfo entry[2]; char name0[4]; char name1[8]; }; Data data; // The names needs to be of size 4*k-1 to avoid padding in the struct Data. // This is a testing only problem. const char* kName[] = { "cow", "chicken" }; data.header.num_transform_feedback_varyings = 2; data.entry[0].size = 1; data.entry[0].type = GL_FLOAT_VEC2; data.entry[0].name_offset = ComputeOffset(&data, data.name0); data.entry[0].name_length = arraysize(data.name0); data.entry[1].size = 2; data.entry[1].type = GL_FLOAT; data.entry[1].name_offset = ComputeOffset(&data, data.name1); data.entry[1].name_length = arraysize(data.name1); memcpy(data.name0, kName[0], arraysize(data.name0)); memcpy(data.name1, kName[1], arraysize(data.name1)); EXPECT_CALL(*(gl_.get()), GetProgramiv(kServiceProgramId, GL_LINK_STATUS, _)) .WillOnce(SetArgPointee<2>(GL_TRUE)) .RetiresOnSaturation(); EXPECT_CALL(*(gl_.get()), GetProgramiv( kServiceProgramId, GL_TRANSFORM_FEEDBACK_VARYINGS, _)) .WillOnce(SetArgPointee<2>(data.header.num_transform_feedback_varyings)) .RetiresOnSaturation(); GLsizei max_length = 1 + std::max(strlen(kName[0]), strlen(kName[1])); EXPECT_CALL(*(gl_.get()), GetProgramiv(kServiceProgramId, GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH, _)) .WillOnce(SetArgPointee<2>(max_length)) .RetiresOnSaturation(); for (uint32_t ii = 0; ii < data.header.num_transform_feedback_varyings; ++ii) { EXPECT_CALL(*(gl_.get()), GetTransformFeedbackVarying( kServiceProgramId, ii, max_length, _, _, _, _)) .WillOnce(DoAll( SetArgPointee<3>(data.entry[ii].name_length - 1), SetArgPointee<4>(data.entry[ii].size), SetArgPointee<5>(data.entry[ii].type), SetArrayArgument<6>( kName[ii], kName[ii] + data.entry[ii].name_length))) .RetiresOnSaturation(); } program->GetTransformFeedbackVaryings(&bucket); EXPECT_EQ(sizeof(Data), bucket.size()); Data* bucket_data = bucket.GetDataAs<Data*>(0, sizeof(Data)); EXPECT_TRUE(bucket_data != NULL); EXPECT_EQ(0, memcmp(&data, bucket_data, sizeof(Data))); } TEST_F(ProgramManagerWithShaderTest, ProgramInfoGetUniformsES3None) { CommonDecoder::Bucket bucket; const Program* program = manager_.GetProgram(kClientProgramId); ASSERT_TRUE(program != NULL); // The program's previous link failed. EXPECT_CALL(*(gl_.get()), GetProgramiv(kServiceProgramId, GL_LINK_STATUS, _)) .WillOnce(SetArgPointee<2>(GL_FALSE)) .RetiresOnSaturation(); EXPECT_TRUE(program->GetUniformsES3(&bucket)); EXPECT_EQ(sizeof(UniformsES3Header), bucket.size()); UniformsES3Header* header = bucket.GetDataAs<UniformsES3Header*>(0, sizeof(UniformsES3Header)); EXPECT_TRUE(header != NULL); EXPECT_EQ(0u, header->num_uniforms); // Zero uniform blocks. EXPECT_CALL(*(gl_.get()), GetProgramiv(kServiceProgramId, GL_LINK_STATUS, _)) .WillOnce(SetArgPointee<2>(GL_TRUE)) .RetiresOnSaturation(); EXPECT_CALL(*(gl_.get()), GetProgramiv(kServiceProgramId, GL_ACTIVE_UNIFORMS, _)) .WillOnce(SetArgPointee<2>(0)) .RetiresOnSaturation(); EXPECT_TRUE(program->GetUniformsES3(&bucket)); EXPECT_EQ(sizeof(UniformsES3Header), bucket.size()); header = bucket.GetDataAs<UniformsES3Header*>(0, sizeof(UniformsES3Header)); EXPECT_TRUE(header != NULL); EXPECT_EQ(0u, header->num_uniforms); } TEST_F(ProgramManagerWithShaderTest, ProgramInfoGetUniformsES3Valid) { CommonDecoder::Bucket bucket; const Program* program = manager_.GetProgram(kClientProgramId); ASSERT_TRUE(program != NULL); struct Data { UniformsES3Header header; UniformES3Info entry[2]; }; Data data; const GLint kBlockIndex[] = { -1, 2 }; const GLint kOffset[] = { 3, 4 }; const GLint kArrayStride[] = { 7, 8 }; const GLint kMatrixStride[] = { 9, 10 }; const GLint kIsRowMajor[] = { 0, 1 }; data.header.num_uniforms = 2; for (uint32_t ii = 0; ii < data.header.num_uniforms; ++ii) { data.entry[ii].block_index = kBlockIndex[ii]; data.entry[ii].offset = kOffset[ii]; data.entry[ii].array_stride = kArrayStride[ii]; data.entry[ii].matrix_stride = kMatrixStride[ii]; data.entry[ii].is_row_major = kIsRowMajor[ii]; } EXPECT_CALL(*(gl_.get()), GetProgramiv(kServiceProgramId, GL_LINK_STATUS, _)) .WillOnce(SetArgPointee<2>(GL_TRUE)) .RetiresOnSaturation(); EXPECT_CALL(*(gl_.get()), GetProgramiv(kServiceProgramId, GL_ACTIVE_UNIFORMS, _)) .WillOnce(SetArgPointee<2>(data.header.num_uniforms)) .RetiresOnSaturation(); const GLenum kPname[] = { GL_UNIFORM_BLOCK_INDEX, GL_UNIFORM_OFFSET, GL_UNIFORM_ARRAY_STRIDE, GL_UNIFORM_MATRIX_STRIDE, GL_UNIFORM_IS_ROW_MAJOR, }; const GLint* kParams[] = { kBlockIndex, kOffset, kArrayStride, kMatrixStride, kIsRowMajor, }; const size_t kNumIterations = arraysize(kPname); for (size_t ii = 0; ii < kNumIterations; ++ii) { EXPECT_CALL(*(gl_.get()), GetActiveUniformsiv( kServiceProgramId, data.header.num_uniforms, _, kPname[ii], _)) .WillOnce(SetArrayArgument<4>( kParams[ii], kParams[ii] + data.header.num_uniforms)) .RetiresOnSaturation(); } program->GetUniformsES3(&bucket); EXPECT_EQ(sizeof(Data), bucket.size()); Data* bucket_data = bucket.GetDataAs<Data*>(0, sizeof(Data)); EXPECT_TRUE(bucket_data != NULL); EXPECT_EQ(0, memcmp(&data, bucket_data, sizeof(Data))); } // Some drivers optimize out unused uniform array elements, so their // location would be -1. TEST_F(ProgramManagerWithShaderTest, UnusedUniformArrayElements) { CommonDecoder::Bucket bucket; const Program* program = manager_.GetProgram(kClientProgramId); ASSERT_TRUE(program != NULL); // Emulate the situation that only the first element has a valid location. // TODO(zmo): Don't assume these are in order. for (size_t ii = 0; ii < arraysize(kUniforms); ++ii) { Program::UniformInfo* uniform = const_cast<Program::UniformInfo*>( program->GetUniformInfo(ii)); ASSERT_TRUE(uniform != NULL); EXPECT_EQ(static_cast<size_t>(kUniforms[ii].size), uniform->element_locations.size()); for (GLsizei jj = 1; jj < uniform->size; ++jj) uniform->element_locations[jj] = -1; } program->GetProgramInfo(&manager_, &bucket); ProgramInfoHeader* header = bucket.GetDataAs<ProgramInfoHeader*>(0, sizeof(ProgramInfoHeader)); ASSERT_TRUE(header != NULL); EXPECT_EQ(1u, header->link_status); EXPECT_EQ(arraysize(kAttribs), header->num_attribs); EXPECT_EQ(arraysize(kUniforms), header->num_uniforms); const ProgramInput* inputs = bucket.GetDataAs<const ProgramInput*>( sizeof(*header), sizeof(ProgramInput) * (header->num_attribs + header->num_uniforms)); ASSERT_TRUE(inputs != NULL); const ProgramInput* input = inputs + header->num_attribs; for (uint32 ii = 0; ii < header->num_uniforms; ++ii) { const UniformInfo& expected = kUniforms[ii]; EXPECT_EQ(expected.size, input->size); const int32* locations = bucket.GetDataAs<const int32*>( input->location_offset, sizeof(int32) * input->size); ASSERT_TRUE(locations != NULL); EXPECT_EQ( ProgramManager::MakeFakeLocation(expected.fake_location, 0), locations[0]); for (int32 jj = 1; jj < input->size; ++jj) EXPECT_EQ(-1, locations[jj]); ++input; } } TEST_F(ProgramManagerWithShaderTest, BindAttribLocationConflicts) { // Set up shader const GLuint kVShaderClientId = 1; const GLuint kVShaderServiceId = 11; const GLuint kFShaderClientId = 2; const GLuint kFShaderServiceId = 12; AttributeMap attrib_map; for (uint32 ii = 0; ii < kNumAttribs; ++ii) { attrib_map[kAttribs[ii].name] = TestHelper::ConstructAttribute( kAttribs[ii].type, kAttribs[ii].size, GL_MEDIUM_FLOAT, kAttribStaticUse, kAttribs[ii].name); } const char kAttribMatName[] = "matAttrib"; attrib_map[kAttribMatName] = TestHelper::ConstructAttribute( GL_FLOAT_MAT2, 1, GL_MEDIUM_FLOAT, kAttribStaticUse, kAttribMatName); // Check we can create shader. Shader* vshader = shader_manager_.CreateShader( kVShaderClientId, kVShaderServiceId, GL_VERTEX_SHADER); Shader* fshader = shader_manager_.CreateShader( kFShaderClientId, kFShaderServiceId, GL_FRAGMENT_SHADER); // Check shader got created. ASSERT_TRUE(vshader != NULL && fshader != NULL); // Set Status TestHelper::SetShaderStates( gl_.get(), vshader, true, NULL, NULL, &attrib_map, NULL, NULL, NULL); // Check attrib infos got copied. for (AttributeMap::const_iterator it = attrib_map.begin(); it != attrib_map.end(); ++it) { const sh::Attribute* variable_info = vshader->GetAttribInfo(it->first); ASSERT_TRUE(variable_info != NULL); EXPECT_EQ(it->second.type, variable_info->type); EXPECT_EQ(it->second.arraySize, variable_info->arraySize); EXPECT_EQ(it->second.precision, variable_info->precision); EXPECT_EQ(it->second.staticUse, variable_info->staticUse); EXPECT_EQ(it->second.name, variable_info->name); } TestHelper::SetShaderStates( gl_.get(), fshader, true, NULL, NULL, &attrib_map, NULL, NULL, NULL); // Set up program const GLuint kClientProgramId = 6666; const GLuint kServiceProgramId = 8888; Program* program = manager_.CreateProgram(kClientProgramId, kServiceProgramId); ASSERT_TRUE(program != NULL); EXPECT_TRUE(program->AttachShader(&shader_manager_, vshader)); EXPECT_TRUE(program->AttachShader(&shader_manager_, fshader)); EXPECT_FALSE(program->DetectAttribLocationBindingConflicts()); EXPECT_TRUE(LinkAsExpected(program, true)); program->SetAttribLocationBinding(kAttrib1Name, 0); EXPECT_FALSE(program->DetectAttribLocationBindingConflicts()); EXPECT_CALL(*(gl_.get()), BindAttribLocation(_, 0, _)) .Times(1) .RetiresOnSaturation(); EXPECT_TRUE(LinkAsExpected(program, true)); program->SetAttribLocationBinding("xxx", 0); EXPECT_FALSE(program->DetectAttribLocationBindingConflicts()); EXPECT_CALL(*(gl_.get()), BindAttribLocation(_, 0, _)) .Times(1) .RetiresOnSaturation(); EXPECT_TRUE(LinkAsExpected(program, true)); program->SetAttribLocationBinding(kAttrib2Name, 1); EXPECT_FALSE(program->DetectAttribLocationBindingConflicts()); EXPECT_CALL(*(gl_.get()), BindAttribLocation(_, _, _)) .Times(2) .RetiresOnSaturation(); EXPECT_TRUE(LinkAsExpected(program, true)); program->SetAttribLocationBinding(kAttrib2Name, 0); EXPECT_TRUE(program->DetectAttribLocationBindingConflicts()); EXPECT_TRUE(LinkAsExpected(program, false)); program->SetAttribLocationBinding(kAttribMatName, 1); program->SetAttribLocationBinding(kAttrib2Name, 3); EXPECT_CALL(*(gl_.get()), BindAttribLocation(_, _, _)) .Times(3) .RetiresOnSaturation(); EXPECT_FALSE(program->DetectAttribLocationBindingConflicts()); EXPECT_TRUE(LinkAsExpected(program, true)); program->SetAttribLocationBinding(kAttrib2Name, 2); EXPECT_TRUE(program->DetectAttribLocationBindingConflicts()); EXPECT_TRUE(LinkAsExpected(program, false)); } TEST_F(ProgramManagerWithShaderTest, UniformsPrecisionMismatch) { // Set up shader const GLuint kVShaderClientId = 1; const GLuint kVShaderServiceId = 11; const GLuint kFShaderClientId = 2; const GLuint kFShaderServiceId = 12; UniformMap vertex_uniform_map; vertex_uniform_map["a"] = TestHelper::ConstructUniform( GL_FLOAT, 3, GL_MEDIUM_FLOAT, true, "a"); UniformMap frag_uniform_map; frag_uniform_map["a"] = TestHelper::ConstructUniform( GL_FLOAT, 3, GL_LOW_FLOAT, true, "a"); // Check we can create shader. Shader* vshader = shader_manager_.CreateShader( kVShaderClientId, kVShaderServiceId, GL_VERTEX_SHADER); Shader* fshader = shader_manager_.CreateShader( kFShaderClientId, kFShaderServiceId, GL_FRAGMENT_SHADER); // Check shader got created. ASSERT_TRUE(vshader != NULL && fshader != NULL); // Set Status TestHelper::SetShaderStates( gl_.get(), vshader, true, NULL, NULL, NULL, &vertex_uniform_map, NULL, NULL); TestHelper::SetShaderStates( gl_.get(), fshader, true, NULL, NULL, NULL, &frag_uniform_map, NULL, NULL); // Set up program const GLuint kClientProgramId = 6666; const GLuint kServiceProgramId = 8888; Program* program = manager_.CreateProgram(kClientProgramId, kServiceProgramId); ASSERT_TRUE(program != NULL); EXPECT_TRUE(program->AttachShader(&shader_manager_, vshader)); EXPECT_TRUE(program->AttachShader(&shader_manager_, fshader)); std::string conflicting_name; EXPECT_TRUE(program->DetectUniformsMismatch(&conflicting_name)); EXPECT_EQ("a", conflicting_name); EXPECT_TRUE(LinkAsExpected(program, false)); } // If a varying has different type in the vertex and fragment // shader, linking should fail. TEST_F(ProgramManagerWithShaderTest, VaryingTypeMismatch) { const VarInfo kVertexVarying = { GL_FLOAT_VEC3, 1, GL_MEDIUM_FLOAT, true, "a", kVarVarying }; const VarInfo kFragmentVarying = { GL_FLOAT_VEC4, 1, GL_MEDIUM_FLOAT, true, "a", kVarVarying }; Program* program = SetupShaderVariableTest( &kVertexVarying, 1, &kFragmentVarying, 1); std::string conflicting_name; EXPECT_TRUE(program->DetectVaryingsMismatch(&conflicting_name)); EXPECT_EQ("a", conflicting_name); EXPECT_TRUE(LinkAsExpected(program, false)); } // If a varying has different array size in the vertex and fragment // shader, linking should fail. TEST_F(ProgramManagerWithShaderTest, VaryingArraySizeMismatch) { const VarInfo kVertexVarying = { GL_FLOAT, 2, GL_MEDIUM_FLOAT, true, "a", kVarVarying }; const VarInfo kFragmentVarying = { GL_FLOAT, 3, GL_MEDIUM_FLOAT, true, "a", kVarVarying }; Program* program = SetupShaderVariableTest( &kVertexVarying, 1, &kFragmentVarying, 1); std::string conflicting_name; EXPECT_TRUE(program->DetectVaryingsMismatch(&conflicting_name)); EXPECT_EQ("a", conflicting_name); EXPECT_TRUE(LinkAsExpected(program, false)); } // If a varying has different precision in the vertex and fragment // shader, linking should succeed. TEST_F(ProgramManagerWithShaderTest, VaryingPrecisionMismatch) { const VarInfo kVertexVarying = { GL_FLOAT, 2, GL_HIGH_FLOAT, true, "a", kVarVarying }; const VarInfo kFragmentVarying = { GL_FLOAT, 2, GL_MEDIUM_FLOAT, true, "a", kVarVarying }; Program* program = SetupShaderVariableTest( &kVertexVarying, 1, &kFragmentVarying, 1); std::string conflicting_name; EXPECT_FALSE(program->DetectVaryingsMismatch(&conflicting_name)); EXPECT_TRUE(conflicting_name.empty()); EXPECT_TRUE(LinkAsExpected(program, true)); } // If a varying is statically used in fragment shader but not // declared in vertex shader, link should fail. TEST_F(ProgramManagerWithShaderTest, VaryingMissing) { const VarInfo kFragmentVarying = { GL_FLOAT, 3, GL_MEDIUM_FLOAT, true, "a", kVarVarying }; Program* program = SetupShaderVariableTest( NULL, 0, &kFragmentVarying, 1); std::string conflicting_name; EXPECT_TRUE(program->DetectVaryingsMismatch(&conflicting_name)); EXPECT_EQ("a", conflicting_name); EXPECT_TRUE(LinkAsExpected(program, false)); } // If a varying is declared but not statically used in fragment // shader, even if it's not declared in vertex shader, link should // succeed. TEST_F(ProgramManagerWithShaderTest, InactiveVarying) { const VarInfo kFragmentVarying = { GL_FLOAT, 3, GL_MEDIUM_FLOAT, false, "a", kVarVarying }; Program* program = SetupShaderVariableTest( NULL, 0, &kFragmentVarying, 1); std::string conflicting_name; EXPECT_FALSE(program->DetectVaryingsMismatch(&conflicting_name)); EXPECT_TRUE(conflicting_name.empty()); EXPECT_TRUE(LinkAsExpected(program, true)); } // Uniforms and attributes are both global variables, thus sharing // the same namespace. Any name conflicts should cause link // failure. TEST_F(ProgramManagerWithShaderTest, AttribUniformNameConflict) { const VarInfo kVertexAttribute = { GL_FLOAT_VEC4, 1, GL_MEDIUM_FLOAT, true, "a", kVarAttribute }; const VarInfo kFragmentUniform = { GL_FLOAT_VEC4, 1, GL_MEDIUM_FLOAT, true, "a", kVarUniform }; Program* program = SetupShaderVariableTest( &kVertexAttribute, 1, &kFragmentUniform, 1); std::string conflicting_name; EXPECT_TRUE(program->DetectGlobalNameConflicts(&conflicting_name)); EXPECT_EQ("a", conflicting_name); EXPECT_TRUE(LinkAsExpected(program, false)); } // Varyings go over 8 rows. TEST_F(ProgramManagerWithShaderTest, TooManyVaryings) { const VarInfo kVertexVaryings[] = { { GL_FLOAT_VEC4, 4, GL_MEDIUM_FLOAT, true, "a", kVarVarying }, { GL_FLOAT_VEC4, 5, GL_MEDIUM_FLOAT, true, "b", kVarVarying } }; const VarInfo kFragmentVaryings[] = { { GL_FLOAT_VEC4, 4, GL_MEDIUM_FLOAT, true, "a", kVarVarying }, { GL_FLOAT_VEC4, 5, GL_MEDIUM_FLOAT, true, "b", kVarVarying } }; Program* program = SetupShaderVariableTest( kVertexVaryings, 2, kFragmentVaryings, 2); EXPECT_FALSE( program->CheckVaryingsPacking(Program::kCountOnlyStaticallyUsed)); EXPECT_TRUE(LinkAsExpected(program, false)); } // Varyings go over 8 rows but some are inactive TEST_F(ProgramManagerWithShaderTest, TooManyInactiveVaryings) { const VarInfo kVertexVaryings[] = { { GL_FLOAT_VEC4, 4, GL_MEDIUM_FLOAT, true, "a", kVarVarying }, { GL_FLOAT_VEC4, 5, GL_MEDIUM_FLOAT, true, "b", kVarVarying } }; const VarInfo kFragmentVaryings[] = { { GL_FLOAT_VEC4, 4, GL_MEDIUM_FLOAT, false, "a", kVarVarying }, { GL_FLOAT_VEC4, 5, GL_MEDIUM_FLOAT, true, "b", kVarVarying } }; Program* program = SetupShaderVariableTest( kVertexVaryings, 2, kFragmentVaryings, 2); EXPECT_TRUE( program->CheckVaryingsPacking(Program::kCountOnlyStaticallyUsed)); EXPECT_TRUE(LinkAsExpected(program, true)); } // Varyings go over 8 rows but some are inactive. // However, we still fail the check if kCountAll option is used. TEST_F(ProgramManagerWithShaderTest, CountAllVaryingsInPacking) { const VarInfo kVertexVaryings[] = { { GL_FLOAT_VEC4, 4, GL_MEDIUM_FLOAT, true, "a", kVarVarying }, { GL_FLOAT_VEC4, 5, GL_MEDIUM_FLOAT, true, "b", kVarVarying } }; const VarInfo kFragmentVaryings[] = { { GL_FLOAT_VEC4, 4, GL_MEDIUM_FLOAT, false, "a", kVarVarying }, { GL_FLOAT_VEC4, 5, GL_MEDIUM_FLOAT, true, "b", kVarVarying } }; Program* program = SetupShaderVariableTest( kVertexVaryings, 2, kFragmentVaryings, 2); EXPECT_FALSE(program->CheckVaryingsPacking(Program::kCountAll)); } TEST_F(ProgramManagerWithShaderTest, ClearWithSamplerTypes) { const GLuint kVShaderClientId = 2001; const GLuint kFShaderClientId = 2002; const GLuint kVShaderServiceId = 3001; const GLuint kFShaderServiceId = 3002; Shader* vshader = shader_manager_.CreateShader( kVShaderClientId, kVShaderServiceId, GL_VERTEX_SHADER); ASSERT_TRUE(vshader != NULL); TestHelper::SetShaderStates(gl_.get(), vshader, true); Shader* fshader = shader_manager_.CreateShader( kFShaderClientId, kFShaderServiceId, GL_FRAGMENT_SHADER); ASSERT_TRUE(fshader != NULL); TestHelper::SetShaderStates(gl_.get(), fshader, true); static const GLuint kClientProgramId = 1234; static const GLuint kServiceProgramId = 5679; Program* program = manager_.CreateProgram( kClientProgramId, kServiceProgramId); ASSERT_TRUE(program != NULL); EXPECT_TRUE(program->AttachShader(&shader_manager_, vshader)); EXPECT_TRUE(program->AttachShader(&shader_manager_, fshader)); static const GLenum kSamplerTypes[] = { GL_SAMPLER_2D, GL_SAMPLER_CUBE, GL_SAMPLER_EXTERNAL_OES, GL_SAMPLER_3D_OES, GL_SAMPLER_2D_RECT_ARB, }; const size_t kNumSamplerTypes = arraysize(kSamplerTypes); for (size_t ii = 0; ii < kNumSamplerTypes; ++ii) { static ProgramManagerWithShaderTest::AttribInfo kAttribs[] = { { kAttrib1Name, kAttrib1Size, kAttrib1Type, kAttrib1Location, }, { kAttrib2Name, kAttrib2Size, kAttrib2Type, kAttrib2Location, }, { kAttrib3Name, kAttrib3Size, kAttrib3Type, kAttrib3Location, }, }; ProgramManagerWithShaderTest::UniformInfo kUniforms[] = { { kUniform1Name, kUniform1Size, kUniform1Type, kUniform1FakeLocation, kUniform1RealLocation, kUniform1DesiredLocation, kUniform1Name, }, { kUniform2Name, kUniform2Size, kSamplerTypes[ii], kUniform2FakeLocation, kUniform2RealLocation, kUniform2DesiredLocation, kUniform2NameWithArrayIndex, }, { kUniform3Name, kUniform3Size, kUniform3Type, kUniform3FakeLocation, kUniform3RealLocation, kUniform3DesiredLocation, kUniform3NameWithArrayIndex, }, }; const size_t kNumAttribs = arraysize(kAttribs); const size_t kNumUniforms = arraysize(kUniforms); SetupShader(kAttribs, kNumAttribs, kUniforms, kNumUniforms, kServiceProgramId); program->Link(NULL, Program::kCountOnlyStaticallyUsed, base::Bind(&ShaderCacheCb)); SetupExpectationsForClearingUniforms(kUniforms, kNumUniforms); manager_.ClearUniforms(program); } } TEST_F(ProgramManagerWithShaderTest, BindUniformLocation) { const GLuint kVShaderClientId = 2001; const GLuint kFShaderClientId = 2002; const GLuint kVShaderServiceId = 3001; const GLuint kFShaderServiceId = 3002; const GLint kUniform1DesiredLocation = 10; const GLint kUniform2DesiredLocation = -1; const GLint kUniform3DesiredLocation = 5; Shader* vshader = shader_manager_.CreateShader( kVShaderClientId, kVShaderServiceId, GL_VERTEX_SHADER); ASSERT_TRUE(vshader != NULL); TestHelper::SetShaderStates(gl_.get(), vshader, true); Shader* fshader = shader_manager_.CreateShader( kFShaderClientId, kFShaderServiceId, GL_FRAGMENT_SHADER); ASSERT_TRUE(fshader != NULL); TestHelper::SetShaderStates(gl_.get(), fshader, true); static const GLuint kClientProgramId = 1234; static const GLuint kServiceProgramId = 5679; Program* program = manager_.CreateProgram( kClientProgramId, kServiceProgramId); ASSERT_TRUE(program != NULL); EXPECT_TRUE(program->AttachShader(&shader_manager_, vshader)); EXPECT_TRUE(program->AttachShader(&shader_manager_, fshader)); EXPECT_TRUE(program->SetUniformLocationBinding( kUniform1Name, kUniform1DesiredLocation)); EXPECT_TRUE(program->SetUniformLocationBinding( kUniform3Name, kUniform3DesiredLocation)); static ProgramManagerWithShaderTest::AttribInfo kAttribs[] = { { kAttrib1Name, kAttrib1Size, kAttrib1Type, kAttrib1Location, }, { kAttrib2Name, kAttrib2Size, kAttrib2Type, kAttrib2Location, }, { kAttrib3Name, kAttrib3Size, kAttrib3Type, kAttrib3Location, }, }; ProgramManagerWithShaderTest::UniformInfo kUniforms[] = { { kUniform1Name, kUniform1Size, kUniform1Type, kUniform1FakeLocation, kUniform1RealLocation, kUniform1DesiredLocation, kUniform1Name, }, { kUniform2Name, kUniform2Size, kUniform2Type, kUniform2FakeLocation, kUniform2RealLocation, kUniform2DesiredLocation, kUniform2NameWithArrayIndex, }, { kUniform3Name, kUniform3Size, kUniform3Type, kUniform3FakeLocation, kUniform3RealLocation, kUniform3DesiredLocation, kUniform3NameWithArrayIndex, }, }; const size_t kNumAttribs = arraysize(kAttribs); const size_t kNumUniforms = arraysize(kUniforms); SetupShader(kAttribs, kNumAttribs, kUniforms, kNumUniforms, kServiceProgramId); program->Link(NULL, Program::kCountOnlyStaticallyUsed, base::Bind(&ShaderCacheCb)); EXPECT_EQ(kUniform1DesiredLocation, program->GetUniformFakeLocation(kUniform1Name)); EXPECT_EQ(kUniform3DesiredLocation, program->GetUniformFakeLocation(kUniform3Name)); EXPECT_EQ(kUniform3DesiredLocation, program->GetUniformFakeLocation(kUniform3NameWithArrayIndex)); } class ProgramManagerWithCacheTest : public GpuServiceTest { public: static const GLuint kClientProgramId = 1; static const GLuint kServiceProgramId = 10; static const GLuint kVertexShaderClientId = 2; static const GLuint kFragmentShaderClientId = 20; static const GLuint kVertexShaderServiceId = 3; static const GLuint kFragmentShaderServiceId = 30; ProgramManagerWithCacheTest() : cache_(new MockProgramCache()), manager_(cache_.get(), kMaxVaryingVectors), vertex_shader_(NULL), fragment_shader_(NULL), program_(NULL) { } ~ProgramManagerWithCacheTest() override { manager_.Destroy(false); shader_manager_.Destroy(false); } protected: void SetUp() override { GpuServiceTest::SetUp(); vertex_shader_ = shader_manager_.CreateShader( kVertexShaderClientId, kVertexShaderServiceId, GL_VERTEX_SHADER); fragment_shader_ = shader_manager_.CreateShader( kFragmentShaderClientId, kFragmentShaderServiceId, GL_FRAGMENT_SHADER); ASSERT_TRUE(vertex_shader_ != NULL); ASSERT_TRUE(fragment_shader_ != NULL); vertex_shader_->set_source("lka asjf bjajsdfj"); fragment_shader_->set_source("lka asjf a fasgag 3rdsf3 bjajsdfj"); program_ = manager_.CreateProgram( kClientProgramId, kServiceProgramId); ASSERT_TRUE(program_ != NULL); program_->AttachShader(&shader_manager_, vertex_shader_); program_->AttachShader(&shader_manager_, fragment_shader_); } void SetShadersCompiled() { TestHelper::SetShaderStates(gl_.get(), vertex_shader_, true); TestHelper::SetShaderStates(gl_.get(), fragment_shader_, true); } void SetProgramCached() { cache_->LinkedProgramCacheSuccess( vertex_shader_->source(), fragment_shader_->source(), &program_->bind_attrib_location_map(), program_->transform_feedback_varyings(), program_->transform_feedback_buffer_mode()); } void SetExpectationsForProgramCached() { SetExpectationsForProgramCached(program_, vertex_shader_, fragment_shader_); } void SetExpectationsForProgramCached( Program* program, Shader* vertex_shader, Shader* fragment_shader) { EXPECT_CALL(*cache_.get(), SaveLinkedProgram( program->service_id(), vertex_shader, fragment_shader, &program->bind_attrib_location_map(), program_->transform_feedback_varyings(), program_->transform_feedback_buffer_mode(), _)).Times(1); } void SetExpectationsForNotCachingProgram() { SetExpectationsForNotCachingProgram(program_, vertex_shader_, fragment_shader_); } void SetExpectationsForNotCachingProgram( Program* program, Shader* vertex_shader, Shader* fragment_shader) { EXPECT_CALL(*cache_.get(), SaveLinkedProgram( program->service_id(), vertex_shader, fragment_shader, &program->bind_attrib_location_map(), program_->transform_feedback_varyings(), program_->transform_feedback_buffer_mode(), _)).Times(0); } void SetExpectationsForProgramLoad(ProgramCache::ProgramLoadResult result) { SetExpectationsForProgramLoad(kServiceProgramId, program_, vertex_shader_, fragment_shader_, result); } void SetExpectationsForProgramLoad( GLuint service_program_id, Program* program, Shader* vertex_shader, Shader* fragment_shader, ProgramCache::ProgramLoadResult result) { EXPECT_CALL(*cache_.get(), LoadLinkedProgram(service_program_id, vertex_shader, fragment_shader, &program->bind_attrib_location_map(), program_->transform_feedback_varyings(), program_->transform_feedback_buffer_mode(), _)) .WillOnce(Return(result)); } void SetExpectationsForProgramLoadSuccess() { SetExpectationsForProgramLoadSuccess(kServiceProgramId); } void SetExpectationsForProgramLoadSuccess(GLuint service_program_id) { TestHelper::SetupProgramSuccessExpectations(gl_.get(), NULL, 0, NULL, 0, service_program_id); } void SetExpectationsForProgramLink() { SetExpectationsForProgramLink(kServiceProgramId); } void SetExpectationsForProgramLink(GLuint service_program_id) { TestHelper::SetupShader(gl_.get(), NULL, 0, NULL, 0, service_program_id); if (gfx::g_driver_gl.ext.b_GL_ARB_get_program_binary) { EXPECT_CALL(*gl_.get(), ProgramParameteri(service_program_id, PROGRAM_BINARY_RETRIEVABLE_HINT, GL_TRUE)).Times(1); } } void SetExpectationsForSuccessCompile( const Shader* shader) { const GLuint shader_id = shader->service_id(); const char* src = shader->source().c_str(); EXPECT_CALL(*gl_.get(), ShaderSource(shader_id, 1, Pointee(src), NULL)).Times(1); EXPECT_CALL(*gl_.get(), CompileShader(shader_id)).Times(1); EXPECT_CALL(*gl_.get(), GetShaderiv(shader_id, GL_COMPILE_STATUS, _)) .WillOnce(SetArgPointee<2>(GL_TRUE)); } void SetExpectationsForNoCompile(const Shader* shader) { const GLuint shader_id = shader->service_id(); const char* src = shader->source().c_str(); EXPECT_CALL(*gl_.get(), ShaderSource(shader_id, 1, Pointee(src), NULL)).Times(0); EXPECT_CALL(*gl_.get(), CompileShader(shader_id)).Times(0); EXPECT_CALL(*gl_.get(), GetShaderiv(shader_id, GL_COMPILE_STATUS, _)) .Times(0); } void SetExpectationsForErrorCompile(const Shader* shader) { const GLuint shader_id = shader->service_id(); const char* src = shader->source().c_str(); EXPECT_CALL(*gl_.get(), ShaderSource(shader_id, 1, Pointee(src), NULL)).Times(1); EXPECT_CALL(*gl_.get(), CompileShader(shader_id)).Times(1); EXPECT_CALL(*gl_.get(), GetShaderiv(shader_id, GL_COMPILE_STATUS, _)) .WillOnce(SetArgPointee<2>(GL_FALSE)); EXPECT_CALL(*gl_.get(), GetShaderiv(shader_id, GL_INFO_LOG_LENGTH, _)) .WillOnce(SetArgPointee<2>(0)); EXPECT_CALL(*gl_.get(), GetShaderInfoLog(shader_id, 0, _, _)) .Times(1); } scoped_ptr<MockProgramCache> cache_; ProgramManager manager_; Shader* vertex_shader_; Shader* fragment_shader_; Program* program_; ShaderManager shader_manager_; }; // GCC requires these declarations, but MSVC requires they not be present #ifndef COMPILER_MSVC const GLuint ProgramManagerWithCacheTest::kClientProgramId; const GLuint ProgramManagerWithCacheTest::kServiceProgramId; const GLuint ProgramManagerWithCacheTest::kVertexShaderClientId; const GLuint ProgramManagerWithCacheTest::kFragmentShaderClientId; const GLuint ProgramManagerWithCacheTest::kVertexShaderServiceId; const GLuint ProgramManagerWithCacheTest::kFragmentShaderServiceId; #endif TEST_F(ProgramManagerWithCacheTest, CacheProgramOnSuccessfulLink) { SetShadersCompiled(); SetExpectationsForProgramLink(); SetExpectationsForProgramCached(); EXPECT_TRUE(program_->Link(NULL, Program::kCountOnlyStaticallyUsed, base::Bind(&ShaderCacheCb))); } TEST_F(ProgramManagerWithCacheTest, LoadProgramOnProgramCacheHit) { SetShadersCompiled(); SetProgramCached(); SetExpectationsForNoCompile(vertex_shader_); SetExpectationsForNoCompile(fragment_shader_); SetExpectationsForProgramLoad(ProgramCache::PROGRAM_LOAD_SUCCESS); SetExpectationsForNotCachingProgram(); SetExpectationsForProgramLoadSuccess(); EXPECT_TRUE(program_->Link(NULL, Program::kCountOnlyStaticallyUsed, base::Bind(&ShaderCacheCb))); } } // namespace gles2 } // namespace gpu
[ "pcmoritz@gmail.com" ]
pcmoritz@gmail.com
226d4961be3ab2d147525a0725bb806118dbebce
73185944d6e7ec558dd7da69d3f5edefa64c1c96
/books/exploreC++11/experience/doxygen.cpp
bcc84f868660b87355e5d1b63b083aef0e07cdb8
[ "BSD-2-Clause" ]
permissive
Bingwen-Hu/hackaway
b5a233b6a1a4865389f0be04bcb63db88809e4c7
69727d76fd652390d9660e9ea4354ba5cc76dd5c
refs/heads/master
2020-08-06T01:17:39.135931
2019-10-28T11:46:55
2019-10-28T11:46:55
212,782,128
0
0
BSD-2-Clause
2019-10-28T11:46:57
2019-10-04T09:43:01
Python
UTF-8
C++
false
false
3,097
cpp
/** @file * @brief Test strings to see whether they are palindromes. * Read lines from the input, strip non-letters, and check whether * the result is a palindrome. Ignore case differences when checking. * Echo palindromes to the standard output. */ /** @mainpage Palindromes * Test input strings to see whether they are palindromes. * * A _palindrome_ is a string that reads the same forward and backward. * To test for palindromes, this program needs to strip punctuation and * other non-essential characters from the string, and compare letters without * regard to case differences. * * This program reads lines of text from the standard input and echoes * to the standard output those lines that are palindromes. * * Source file: [palindrome.cpp](palindrome.cpp) * * @date 27-July-2013 * @author Ray Lischner * @version 2.0 */ #include <algorithm> #include <iostream> #include <iterator> #include <locale> #include <string> /** @brief Test for non-letter. * Test the character @p ch in the global locale. * @param ch the character to test * @return true if @p ch is not a letter */ bool non_letter(char ch) { return not std::isalnum(ch, std::locale{}); } /** @brief Convert to lowercase. * Use a canonical form by converting to uppercase first, * and then to lowercase. This approach does not solve the eszet * problem (German eszet is a lowercase character that converts * to two uppercase characters), but it's the best we can do in * standard C++. * * All conversions use the global locale. * * @param ch the character to test * @return the character converted to lowercase */ char lowercase(char ch) { return std::tolower(ch, std::locale{}); } /** @brief Compare two characters without regard to case. * The comparison is limited by the `lowercase()` function. * @param a one character to compare * @param b the other character to compare * @return `true` if the characters are the same in lowercase, * * `false` if they are different. */ bool is_same_char(char a, char b) { return lowercase(a) == lowercase(b); } /** @brief Determine whether @p str is a palindrome. * Only letter characters are tested. Spaces and punctuation don't count. * Empty strings are not palindromes because that's just too easy. * @param str the string to test * @return `true` if @p str is the same forward and backward and * * `not str.empty()` */ bool is_palindrome(std::string str) { std::string::iterator end{std::remove_if(str.begin(), str.end(), non_letter)}; std::string rev{str.begin(), end}; std::reverse(rev.begin(), rev.end()); return not rev.empty() and std::equal(str.begin(), end, rev.begin(), is_same_char); } /** @brief Main program. * Set the global locale to the user's native locale. Then imbue the I/O streams * with the native locale. */ int main() { std::locale::global(std::locale{""}); std::cin.imbue(std::locale{}); std::cout.imbue(std::locale{}); std::string line{}; while (std::getline(std::cin, line)) if (is_palindrome(line)) std::cout << line << '\n'; }
[ "mory2016@126.com" ]
mory2016@126.com
9ba6af4e99e9946454f8f314cd22b8df66cd40b0
88bb7f63aae8dce437c9813feb3ada8483256e72
/BOJ/7785_회사에 있는 사람.cpp
2aaa0017addbdeaa756fc3b73206fd7904bdd79f
[]
no_license
BluesHaru/Practice
adc9234930c89fd0c05bf55e2fb7d09930f059b7
b9a600bcf2e813c78b06ae5e8d7d7a3772e2a771
refs/heads/master
2020-08-14T14:34:14.854685
2020-01-21T13:23:35
2020-01-21T13:23:35
215,184,487
0
0
null
null
null
null
UHC
C++
false
false
1,216
cpp
/*--------------------------------------------------- 7785 회사에 있는 사람 자료구조, 문자열 문제정보 : 로그가 주어졌을 때, 현재 회사에 있는 모든 사람을 구하는 프로그램을 작성하시오. 조건 : Input) 로그에 기록된 출입 기록의 수 n (2 ≤ n ≤ 10^6) 출입 기록이 순서대로 주어지며, 각 사람의 이름이 주어지고 "enter"나 "leave"가 주어진다. "enter"인 경우는 출근, "leave"인 경우는 퇴근이다. Output) 현재 회사에 있는 사람의 이름을 사전 순의 역순으로 한 줄에 한 명씩 출력한다. ----------------------------------------------------*/ #pragma warning(disable:4996) #include <set> #include <string> #include <iostream> #include <sstream> #include <functional> using namespace std; int main() { int n; cin >> n; set<string, greater<string>> temp; stringstream ss; cin.ignore(); for (int i = 0; i < n; ++i) { string str = ""; getline(cin, str); ss.str(str); string word, input; ss >> word >> input; if (input == "enter") temp.emplace(word); else temp.erase(word); ss.clear(); } for (auto s : temp) cout << s << '\n'; return 0; }
[ "guinn0098@gmail.com" ]
guinn0098@gmail.com
170f8906318ffa97fff9ed8a78e91a34d134dc9a
ada4c1a3558bddbcaf07cab3ea65dfcc36f73ad5
/string_C/strlen.cpp
a566ff2eff78eea4b0e7e6a5cef682c65669d082
[]
no_license
littesss/test_code
2de9423c95b408cd88ae16d67e3d5299c6cb9d96
989b49816dc8d7504106f1054d406de7924f9bdc
refs/heads/master
2021-09-19T16:02:58.688001
2018-07-29T03:27:23
2018-07-29T03:27:23
104,223,586
0
0
null
null
null
null
UTF-8
C++
false
false
382
cpp
/************************************************************************* > File Name: strlen.cpp > Created Time: Tue 10 Oct 2017 08:40:28 PM CST ************************************************************************/ #include <iostream> using namespace std; #include <string.h> int main() { int i = strlen("%%\"abcdef\"\\"); cout << i << endl; return 0; }
[ "liushaohua_2017@163.com" ]
liushaohua_2017@163.com
277a664838b79021069e36b52ba3f26da4166426
9c88fc13ad63e657bd7701463e93fc3f63971ceb
/Engine/Component.h
270f8bde0deb9e19768f56dceee42d04bc7a7fa9
[]
no_license
RensAlthuis/Bob
bc986a37816f1b9b25c98bd5196026586272c2c3
a0c58990518f2e5ebfde282af15eed04f795b740
refs/heads/master
2021-08-25T06:21:29.889856
2018-11-06T19:28:08
2018-11-06T19:28:08
149,507,666
1
0
null
null
null
null
UTF-8
C++
false
false
219
h
#pragma once #include "Object.h" namespace Engine { class Component { public: Object *parent; virtual void update(){}; virtual void start(){}; Component(){}; virtual ~Component(){}; }; }; // namespace Engine
[ "rens.althuis@gmail.com" ]
rens.althuis@gmail.com
508ac2e94db64ba9244310925daae7651e0c8ff0
2be340092a026aef8f1c2c3c5e970cbdb441f319
/include/hades/detail/has_key_attr.hpp
ccc5beaff183147f2fb0c0425087908f3d243abf
[]
no_license
jamesg/hades
8fcea3256bbb5eb8f019bc578452d39c38876431
a160e098d2a005d0104da41cc4f30b70a891f2c1
refs/heads/master
2021-01-17T09:52:54.917887
2015-08-10T19:02:05
2015-08-10T19:02:05
29,496,552
0
0
null
null
null
null
UTF-8
C++
false
false
751
hpp
#ifndef HADES_HAS_KEY_HPP #define HADES_HAS_KEY_HPP #include <type_traits> #include "styx/object.hpp" namespace hades { namespace detail { template<const char *Attribute> class has_key_attr; template<typename DbType, const char *Attribute> typename std::enable_if<std::is_base_of<has_key_attr<Attribute>, DbType>::value, styx::int_type&>::type get_key(DbType& db) { return db.get_int(Attribute); //return 1; } /*! * Give a DB type one key attribute. Multiple keys can be added to * a type to form a candidate key. */ template<const char *Attribute> class has_key_attr { }; } } #endif
[ "james@uwcs.co.uk" ]
james@uwcs.co.uk
fd9d88b3d23dcfab83d46c9c23900597ac3d8269
78ad1e44f0d0af91a5e2abe9a54c1316367f6266
/3rdParty/V8/v5.7.492.77/test/fuzzer/parser.cc
4ce4acb8bdb35c9700f4c0840c70d01eaf2fd2c5
[ "BSD-3-Clause", "bzip2-1.0.6", "SunPro", "Apache-2.0", "ICU", "Zlib", "GPL-1.0-or-later", "LicenseRef-scancode-autoconf-simple-exception", "LicenseRef-scancode-pcre", "WTFPL", "ISC", "MIT", "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-proprietary-license", "Unlic...
permissive
surajpatel11/arangodb
dbfb12cb84d02430c9ee52c831a87ac87bec2391
e6e02233f4eed4f01232a30a1a630fe538aaf457
refs/heads/devel
2020-04-09T16:43:54.309659
2018-12-04T21:55:57
2018-12-04T22:10:14
160,461,475
0
1
Apache-2.0
2018-12-05T04:56:28
2018-12-05T04:38:18
C++
UTF-8
C++
false
false
1,586
cc
// Copyright 2016 the V8 project 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 <limits.h> #include <stddef.h> #include <stdint.h> #include "include/v8.h" #include "src/objects-inl.h" #include "src/objects.h" #include "src/parsing/parse-info.h" #include "src/parsing/parsing.h" #include "src/parsing/preparser.h" #include "test/fuzzer/fuzzer-support.h" extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { v8_fuzzer::FuzzerSupport* support = v8_fuzzer::FuzzerSupport::Get(); v8::Isolate* isolate = support->GetIsolate(); v8::Isolate::Scope isolate_scope(isolate); v8::HandleScope handle_scope(isolate); v8::Context::Scope context_scope(support->GetContext()); v8::TryCatch try_catch(isolate); v8::internal::Isolate* i_isolate = reinterpret_cast<v8::internal::Isolate*>(isolate); v8::internal::Factory* factory = i_isolate->factory(); if (size > INT_MAX) return 0; v8::internal::MaybeHandle<v8::internal::String> source = factory->NewStringFromOneByte( v8::internal::Vector<const uint8_t>(data, static_cast<int>(size))); if (source.is_null()) return 0; v8::internal::Handle<v8::internal::Script> script = factory->NewScript(source.ToHandleChecked()); v8::internal::Zone zone(i_isolate->allocator(), ZONE_NAME); v8::internal::ParseInfo info(&zone, script); v8::internal::parsing::ParseProgram(&info); isolate->RequestGarbageCollectionForTesting( v8::Isolate::kFullGarbageCollection); return 0; }
[ "willi@arangodb.com" ]
willi@arangodb.com
115c2c3e12de0c3af59e3c043337afcd08a64449
062e15bf0f33c9cde8027548f760a2b3c6839090
/07/MISC/MORLET.CPP
9f8f3373a5f22e5182d4baa0cc035629483662a3
[]
no_license
dumpinfo/DNNCudatest
5098e994fff209c9cf95ac164fab025e9a829f6c
c1f3e1fb3a9e74870360143ee9b44d7a4d53cb66
refs/heads/master
2023-02-03T02:31:26.454713
2020-12-24T20:21:18
2020-12-24T20:21:18
324,229,439
0
0
null
null
null
null
UTF-8
C++
false
false
15,605
cpp
// Copyright (c) 1994 John Wiley & Sons, Inc. All rights reserved. // Reproduction or translation of this work beyond that permitted in // section 117 of the 1976 United States Copyright Act without the // express written permission of the copyright owner is unlawful. // Requests for further information should be addressed to the // Permission Department, John Wiley & Sons, Inc. The purchaser may // make backup copies for his/her own use only and not for distribution // or resale. The publisher assumes no responsibility for errors, // omissions, or damages, caused by the use of these programs or from // the use of the information contained herein. /******************************************************************************/ /* */ /* MORLET - Morlet wavelet */ /* */ /******************************************************************************/ #include <math.h> #include <stdlib.h> /* -------------------------------------------------------------------------------- Morlet - Construct and compute Morlet wavelet The constructor computes and saves all wavelet coefficients. It also returns several parameters that the user may find useful. The function "transform" actually performs the transform. It may be called as many times as desired after the constructor has been called. >>> The following parameters are in the constructor parameter list: shape - The shape of the mother wavelet is expressed as the ratio of its center frequency to the radius of its frequency-domain window (which is 0.5 / (sqrt(2) * pi), or about 0.1125). This must never be less than 6 or so, as normalization suffers. A typical value, used by Morlet himself, is 7.54. About 4 voices are recommended for that value. Values much larger than that can require many voices for thorough coverage. rate - This is the sample rate expressed as a multiple of the Nyquist limit. Thus, this parameter cannot be less than 1. Setting it equal to 1 enables resolution at the smallest scale physically possible, but also generates much output data. Further, the smallest-scale coefficients are slightly uncentered, leading to tiny but annoying leakage from lower frequencies. Also, the discrete shape of this wavelet does not well approximate the continuous mother wavelet. Values larger than 1 are recommended unless the tiniest-scale resolution is needed. Even using 1.5 helps a lot, and a value of 2 is as large as needed to avoid all problems. Twice the rate is the period (sample points per cycle) of the center of response of the smallest-scale wavelet. nvoices - The number of voices used includes the basic wavelet at each scale, so this parameter must be at least one. Larger values are always needed to have a decent frame. At least 3 or 4 are necessary for small values of the shape parameter, with more needed as the shape parameter increases. nscales - The number of scales includes the mother wavelet, which is the smallest scale. Thus, this parameter must be at least 1. When actual data is transformed, all of these scales may not be computed if the data array is too short. But this sets the upper limit for how many can be done. border - This is returned as the number of points that will be skipped at the beginning and end of the input series for the smallest-scale wavelet. Larger scales will skip more. The smallest-scale h(t) vector that is dotted with the input has length = 2 * border + 1, so border is its half-length. So that the entire vector is used, the transform will start at x[border] and will go no further than x[nx-border-1], centering the filter at points separated by the distance specified when the transform is called. samprate - This is returned as the sample rate: the number of sample points per unit time in the basic wavelet equation. The primary reason for returning this value is that rounding it to the nearest integer gives a good value for the time-domain spacing parameter for the transform routine. voicefac - The period of each successive voice at a given scale is multipled by this returned quantity. It is the nvoices'th root of two. ok - This is returned 1 if all went well, and 0 if there was insufficient memory for storing the FIR filter coefficients or if the user specified nonsense parameters. >>> The following parameters are in the "transform" parameter list: nx - This is the length of the time series input vector x. x - Input vector spacing - This many sample points will separate each of the smallest-scale wavelets in the time domain. A good value will be near the sample rate returned by the constructor. Smaller values will generate unneeded quantities of data. Larger values cause deterioration of frame quality. Values greater than about 1.75 times the sample rate result in serious information gaps in the time domain. starts - This returned vector is 'nscales' long. For each scale (0 being the smallest), this specifies the subscript in the x array where the first wavelet of that scale is centered. Starts[0] will equal 'border', that filter's half-length, as the first wavelet starts as soon as possible. The filter half-length doubles for each successive scale, so the starting point must move in at least that much. It may be even more, as each longer scale starts at a starting point of the previous (smaller) scale to assure uniformity. counts - This returned vector is 'nscales' long. For each scale (0 being the smallest), this specifies the number of wavelets computed at that scale. nout - This is returned as the total of all of the elements of counts. Thus, the total number of complex outputs is nout times nvoices. rt - Real part of output transform. It contains nout * nvoices elements. it - Imaginary part of transform as above. The constructor will need to allocate a work area to hold the FIR filter coefficients. This will be 2 * nvoicess * border * 2**(nscales-1) doubles. (The filter is complex, symmetric, and the center coefficient is the same for all frequencies, so is not stored here.) -------------------------------------------------------------------------------- */ static double two_pi = 2. * 3.141592653589793 ; static double root2 = sqrt ( 2.0 ) ; class Morlet { public: Morlet ( double shape , double rate , int nvoices , int nscales , int *border , double *samprate , double *voicefac , int *ok ) ; ~Morlet () ; void transform ( int nx , double *x , int spacing , int *starts , int *counts , int *nout , double *rt , double *it ) ; private: double kparam ; // "Frequency" shape parameter k double srate ; // Sample rate (samples per unit time) int nv ; // Number of voices int ns ; // Number of scales int hl ; // Shortest filter half length (=border) int npv ; // Number of coefs per voice (for longest filter) double gconst ; // Normalizing constant for Gaussian double *coefs ; // FIR coefficients for all frequencies } ; /* -------------------------------------------------------------------------------- Constructor, destructor -------------------------------------------------------------------------------- */ Morlet::Morlet ( double shape , // f/delta, Morlet used 7.54 double rate , // Multiple of Nyquist, at least 1.0 int nvoices , // Number of voices, at least 1 int nscales , // Number of scales to prepare, at least 1 int *border , // Half-length of shortest filter double *samprate , // Samples per unit time double *voicefac , // Factor by which period is multiplied for voices int *ok // Parameters and memory allocation ok? ) { int i, iv ; double window_radius, weight, *cptr, fac, x, con, vfac, rfac ; coefs = NULL ; // So destructor doesn't do bad free if failure here /* Verify that parameters are legal. If the shape-determining frequency is very low, normalization is poor unless the sample rate is well above the Nyquist limit. (This is a crude check, but it inspires more care than no check at all.) The specified sample rate must be at least 1.0 times that limit. The number of voices and scales must be at least 1. */ *ok = 0 ; if ((shape < 6.2) && (rate < 2.0)) return ; if (rate < 1.0) return ; if (nvoices < 1) return ; if (nscales < 1) return ; /* The user specified the shape as a multiple of the frequency-dimension window radius. Use that to find k. Multiply k by 2 pi right now to avoid having to do it later for trig functions. The sample rate is the Nyquist frequency (twice the shape frequency) times the user's multiple (which must be at least 1.0). */ window_radius = 1.0 / (root2 * two_pi) ; kparam = window_radius * shape * two_pi ; *samprate = srate = window_radius * shape * 2.0 * rate ; *voicefac = pow ( 2.0 , 1.0 / (double) nvoices ) ; /* Save other user parameters in private storage area. Compute the filter half-length such that the weight goes to about 1.e-12 times its max by the end of the filter. If multiple voices are used, remember that we must accomodate the largest voice. */ nv = nvoices ; ns = nscales ; *border = hl = 1 + 7.4 * srate * pow ( 2.0 , (double) (nv-1) / (double) nv ); /* Allocate memory for the FIR filter coefficients that make up the wavelet family. We store each voice separately. For each voice, store the coefficients for the largest scale member of that family. Smaller scale members will be derived by decimation. The number of coefficients needed for that longest filter is the half-length of the shortest filter times the largest scale (2 ** (ns-1)). Then we have a set for each voice, and real and imaginary parts. */ npv = hl ; // Length of shortest filter i = ns ; // Number of scales while (--i) // Compute 2 ** (ns-1) npv *= 2 ; // to get length of longest filter coefs = (double *) malloc ( 2 * nv * npv * sizeof(double) ) ; if (coefs == NULL) return ; // We already initialized ok to 0 *ok = 1 ; /* Compute the filter coefficients. The center coefficient for all real parts is the voice factor times gconst, the Gaussian multiplier. The center of the imaginary part is always 0 (sin 0). The sample rate for a voice is the smallest-scale sample rate, srate, times the scale of the largest-scale member (since we compute and save only its coefs) times the rate factor for that voice. The unit time change per point is the reciprocal of that sample rate. */ fac = 1.0 / (srate * pow ( 2.0 , (double) (ns-1))) ;// Largest-scale rate rfac = sqrt ( fac ) ; gconst = pow ( 3.141592653589793 , -0.25 ) ; // Pi to the -1/4 power gconst *= rfac ; // Scaling con = exp ( -0.5 * kparam * kparam ) ; // Centering constant for (iv=0 ; iv<nv ; iv++) { // For all voices vfac = pow ( 2.0 , -(double) iv / (double) nv ) ; // Voice factor cptr = coefs + iv * 2 * npv ; // Point to this voice's coef area for (i=1 ; i<=npv ; i++) { // Right half of filter x = vfac * fac * i ; weight = vfac * gconst * exp ( -0.5 * x * x ) ; // Data window *cptr++ = (cos ( kparam * x ) - con) * weight ; // Real part of filter *cptr++ = sin ( kparam * x ) * weight ; // And imaginary part } } } Morlet::~Morlet () { if (coefs != NULL) free ( coefs ) ; } void Morlet::transform ( int nx , // Length of input vector double *x , // Input vector int spacing , // Space between smallest-scale time lattice points int *starts , // Starts[i] is x subscript of center of first scale i output int *counts , // Counts[i] is number of outputs at scale i int *nout , // Total number of outputs (sum of counts) double *rt , // Real outputs double *it // Imaginary outputs ) { int i, n, iscale, iv, itime, decim, flen ; double *cptr, *xptr, rsum, isum, vfac, scafac ; for (iscale=0 ; iscale<ns ; iscale++) // Init to all 0 in case x is starts[iscale] = counts[iscale] = 0 ; // too short to do all scales *nout = 0 ; decim = npv / hl ; // Decimate longest filter to get current filter flen = hl ; // Half length of current filter scafac = pow ( 2.0 , 0.5 * (double) (ns-1) ) ; // Scale factor for h(t) for (iscale=0 ; iscale<ns ; iscale++) { // Start with shortest filter if (iscale) { // This start must line up with previous and be >= flen for (n=starts[iscale-1] ; n<flen ; n+=spacing/2) ; starts[iscale] = n ; } else // First scale's start is as early as possible starts[0] = flen ; n = nx - starts[iscale] - flen ; // This many x's filterable if (n > 0) { n = counts[iscale] = 1 + (n - 1) / spacing ; // This many resolved *nout += n ; } else break ; // Input is too short given filter length for (itime=0 ; itime<n ; itime++) { // All time slots xptr = x + starts[iscale] + itime * spacing ; // Center of this filter position for (iv=0 ; iv<nv ; iv++) { // All voices vfac = pow ( 2.0 , -(double) iv / (double) nv ) ; // Voice factor rsum = vfac * gconst * *xptr ; // Center real coef is constant isum = 0.0 ; // Center imaginary coef is 0 cptr = coefs + iv * 2 * npv - 2 ; // Point to this voice coef area for (i=1 ; i<=flen ; i++) { // Right half of filter cptr += 2 * decim ; // Coef 0 not saved in coefs! rsum += *cptr * xptr[i] ; // Sum real part of right half isum += *(cptr+1) * xptr[i] ; // And imaginary part } cptr = coefs + iv * 2 * npv - 2 ; // Point to this voice coef area for (i=1 ; i<=flen ; i++) { // Left half of filter cptr += 2 * decim ; // Coef 0 not saved in coefs! rsum += *cptr * xptr[-i] ; // Sum real part of left half isum -= *(cptr+1) * xptr[-i] ; // And imaginary part } *rt++ = scafac * rsum ; // Output real part of Morlet transform *it++ = scafac * isum ; // And imaginary part } } decim /= 2 ; // Decimation for stored filter coefs flen *= 2 ; // Half-length of current filter spacing *= 2 ; // Time-domain spacing of filters scafac *= sqrt ( 0.5 ) ; // Scale factor for h(t) } } 
[ "ubuntu@localhost.localdomain" ]
ubuntu@localhost.localdomain
1db8f71c8af80b77d5a930bb0094224c2755e9e8
d2249116413e870d8bf6cd133ae135bc52021208
/skinscrollbar_demo/SkinComboBox.cpp
673dd99f18fe638156d45112c63a96c024a392b0
[]
no_license
Unknow-man/mfc-4
ecbdd79cc1836767ab4b4ca72734bc4fe9f5a0b5
b58abf9eb4c6d90ef01b9f1203b174471293dfba
refs/heads/master
2023-02-17T18:22:09.276673
2021-01-20T07:46:14
2021-01-20T07:46:14
null
0
0
null
null
null
null
GB18030
C++
false
false
1,604
cpp
// SkinComboBox.cpp : 实现文件 // #include "stdafx.h" #include "SkinComboBox.h" #include "skinscrollwnd.h" // CSkinComboBox IMPLEMENT_DYNAMIC(CSkinComboBox, CComboBox) CSkinComboBox::CSkinComboBox() { m_hWndList=NULL; } CSkinComboBox::~CSkinComboBox() { } BEGIN_MESSAGE_MAP(CSkinComboBox, CComboBox) ON_CONTROL_REFLECT(CBN_CLOSEUP, OnCbnCloseup) ON_CONTROL_REFLECT(CBN_DROPDOWN, OnCbnDropdown) ON_WM_CTLCOLOR() END_MESSAGE_MAP() // CSkinComboBox 消息处理程序 void CSkinComboBox::OnCbnCloseup() { // TODO: 在此添加控件通知处理程序代码 if(!m_hWndList) return ; ::ShowWindow(::GetParent(::GetParent(m_hWndList)),SW_HIDE); } void CSkinComboBox::OnCbnDropdown() { // TODO: 在此添加控件通知处理程序代码 if(!m_hWndList) return ; CWnd *pFrame=CWnd::FromHandle(::GetParent(::GetParent(m_hWndList))); CRect rc; GetWindowRect(&rc); CRect rc2; this->GetDroppedControlRect(&rc2); int nHei; int nLineHei=GetItemHeight(0); if(nLineHei*GetCount()<rc2.Height()-2) nHei=nLineHei*GetCount()+2; else nHei=rc2.Height(); pFrame->SetWindowPos(&wndTopMost,rc.left,rc.bottom,rc2.Width(),nHei,0); pFrame->ShowWindow(SW_SHOW); } HBRUSH CSkinComboBox::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) { HBRUSH hbr = CComboBox::OnCtlColor(pDC, pWnd, nCtlColor); if (nCtlColor == CTLCOLOR_LISTBOX && !m_hWndList && m_hBmpScroll) { //第一次弹出下拉列表,先隐藏列表 pWnd->ShowWindow(SW_HIDE); SkinWndScroll(pWnd,m_hBmpScroll); m_hWndList=pWnd->m_hWnd; } return hbr; }
[ "chenchao0632@163.com" ]
chenchao0632@163.com