FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
cppcheck/test/testsimplifytokens.cpp at master · napcode/cppcheck · GitHub
cppcheck/test/testsimplifytokens.cpp at master · napcode/cppcheck · GitHub
Skip to content
Navigation Menu
Sign in
Appearance settings
AI CODE CREATION
GitHub Copilot
Write better code with AI
GitHub Copilot app
Direct agents from issue to merge
MCP Registry
Integrate external tools
DEVELOPER WORKFLOWS
Actions
Automate any workflow
Codespaces
Instant dev environments
Issues
Plan and track work
Code Review
Manage code changes
Code Quality
Enforce quality at merge
APPLICATION SECURITY
GitHub Advanced Security
Find and fix vulnerabilities
Code security
Secure your code as you build
Secret protection
Stop leaks before they start
EXPLORE
Why GitHub
Documentation
Blog
Changelog
Marketplace
View all features
BY COMPANY SIZE
Enterprises
Small and medium teams
Startups
Nonprofits
BY USE CASE
App Modernization
DevSecOps
DevOps
CI/CD
View all use cases
BY INDUSTRY
Healthcare
Financial services
Manufacturing
Government
View all industries
View all solutions
EXPLORE BY TOPIC
AI
Software Development
DevOps
Security
View all topics
EXPLORE BY TYPE
Customer stories
Events & webinars
Ebooks & reports
Business insights
GitHub Skills
SUPPORT & SERVICES
Documentation
Customer support
Community forum
Trust center
Partners
View all resources
COMMUNITY
GitHub Sponsors
Fund open source developers
PROGRAMS
Security Lab
Maintainer Community
Accelerator
GitHub Stars
Archive Program
REPOSITORIES
Topics
Trending
Collections
ENTERPRISE SOLUTIONS
Enterprise platform
AI-powered developer platform
AVAILABLE ADD-ONS
GitHub Advanced Security
Enterprise-grade security features
Copilot for Business
Enterprise-grade AI features
Premium Support
Enterprise-grade 24/7 support
Pricing
Sign in
Sign up
Appearance settings
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Dismiss alert
{{ message }}
napcode
/
cppcheck
Public
forked from
cppcheck-opensource/cppcheck
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
cppcheck
/
test
/
testsimplifytokens.cpp
Copy path
More file actions
More file actions
Latest commit
History
History
History
4958 lines (4349 loc) · 218 KB
Breadcrumbs
cppcheck
/
test
/
testsimplifytokens.cpp
Copy path
File metadata and controls
4958 lines (4349 loc) · 218 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
* Cppcheck - A tool for static C/C++ code analysis
* Copyright (C) 2007-2019 Cppcheck team.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#
include
"
platform.h
"
#
include
"
settings.h
"
#
include
"
testsuite.h
"
#
include
"
token.h
"
#
include
"
tokenize.h
"
#
include
"
tokenlist.h
"
#
include
<
ostream
>
#
include
<
string
>
class
TestSimplifyTokens
:
public
TestFixture
{
public:
TestSimplifyTokens
() : TestFixture(
"
TestSimplifyTokens
"
) {
}
private:
Settings settings0;
Settings settings1;
Settings settings_std;
Settings settings_windows;
void
run
() OVERRIDE {
LOAD_LIB_2
(settings_std.
library
,
"
std.cfg
"
);
LOAD_LIB_2
(settings_windows.
library
,
"
windows.cfg
"
);
settings0.
addEnabled
(
"
portability
"
);
settings1.
addEnabled
(
"
style
"
);
settings_windows.
addEnabled
(
"
portability
"
);
//
Make sure the Tokenizer::simplifyTokenList works.
//
The order of the simplifications is important. So this test
//
case shall make sure the simplifications are done in the
//
correct order
TEST_CASE
(simplifyTokenList1);
TEST_CASE
(simplifyMathFunctions_sqrt);
TEST_CASE
(simplifyMathFunctions_cbrt);
TEST_CASE
(simplifyMathFunctions_exp);
TEST_CASE
(simplifyMathFunctions_exp2);
TEST_CASE
(simplifyMathFunctions_logb);
TEST_CASE
(simplifyMathFunctions_log1p);
TEST_CASE
(simplifyMathFunctions_ilogb);
TEST_CASE
(simplifyMathFunctions_log10);
TEST_CASE
(simplifyMathFunctions_log);
TEST_CASE
(simplifyMathFunctions_log2);
TEST_CASE
(simplifyMathFunctions_pow);
TEST_CASE
(simplifyMathFunctions_fmin);
TEST_CASE
(simplifyMathFunctions_fmax);
TEST_CASE
(simplifyMathFunctions_acosh);
TEST_CASE
(simplifyMathFunctions_acos);
TEST_CASE
(simplifyMathFunctions_cosh);
TEST_CASE
(simplifyMathFunctions_cos);
TEST_CASE
(simplifyMathFunctions_erfc);
TEST_CASE
(simplifyMathFunctions_erf);
TEST_CASE
(simplifyMathFunctions_sin);
TEST_CASE
(simplifyMathFunctions_sinh);
TEST_CASE
(simplifyMathFunctions_asin);
TEST_CASE
(simplifyMathFunctions_asinh);
TEST_CASE
(simplifyMathFunctions_tan);
TEST_CASE
(simplifyMathFunctions_tanh);
TEST_CASE
(simplifyMathFunctions_atan);
TEST_CASE
(simplifyMathFunctions_atanh);
TEST_CASE
(simplifyMathFunctions_expm1);
TEST_CASE
(simplifyMathExpressions);
//
ticket #1620
//
foo(p = new char[10]); => p = new char[10]; foo(p);
TEST_CASE
(simplifyAssignmentInFunctionCall);
//
";a+=b;" => ";a=a+b;"
TEST_CASE
(simplifyCompoundAssignment);
TEST_CASE
(cast);
TEST_CASE
(iftruefalse);
TEST_CASE
(combine_strings);
TEST_CASE
(combine_wstrings);
TEST_CASE
(combine_ustrings);
TEST_CASE
(combine_Ustrings);
TEST_CASE
(combine_u8strings);
TEST_CASE
(combine_mixedstrings);
TEST_CASE
(double_plus);
TEST_CASE
(redundant_plus);
TEST_CASE
(redundant_plus_numbers);
TEST_CASE
(parentheses1);
TEST_CASE
(parenthesesVar);
//
Remove redundant parentheses around variable .. "( %name% )"
TEST_CASE
(declareVar);
TEST_CASE
(declareArray);
TEST_CASE
(dontRemoveIncrement);
TEST_CASE
(removePostIncrement);
TEST_CASE
(removePreIncrement);
TEST_CASE
(elseif1);
TEST_CASE
(sizeof_array);
TEST_CASE
(sizeof5);
TEST_CASE
(sizeof6);
TEST_CASE
(sizeof7);
TEST_CASE
(sizeof8);
TEST_CASE
(sizeof9);
TEST_CASE
(sizeof10);
TEST_CASE
(sizeof11);
TEST_CASE
(sizeof12);
TEST_CASE
(sizeof13);
TEST_CASE
(sizeof14);
TEST_CASE
(sizeof15);
TEST_CASE
(sizeof16);
TEST_CASE
(sizeof17);
TEST_CASE
(sizeof18);
TEST_CASE
(sizeof19);
//
#1891 - sizeof 'x'
TEST_CASE
(sizeof20);
//
#2024 - sizeof a)
TEST_CASE
(sizeof21);
//
#2232 - sizeof...(Args)
TEST_CASE
(sizeof22);
TEST_CASE
(sizeofsizeof);
TEST_CASE
(casting);
TEST_CASE
(strlen1);
TEST_CASE
(strlen2);
TEST_CASE
(namespaces);
//
Assignment in condition..
TEST_CASE
(ifassign1);
TEST_CASE
(ifAssignWithCast);
TEST_CASE
(whileAssign1);
TEST_CASE
(whileAssign2);
TEST_CASE
(whileAssign3);
//
varid
TEST_CASE
(whileAssign4);
//
links
TEST_CASE
(doWhileAssign);
//
varid
TEST_CASE
(test_4881);
//
similar to doWhileAssign (#4911), taken from #4881 with full code
//
Simplify "not" to "!" (#345)
TEST_CASE
(not1);
//
Simplify "and" to "&&" (#620)
TEST_CASE
(and1);
//
Simplify "or" to "||"
TEST_CASE
(or1);
TEST_CASE
(cAlternativeTokens);
TEST_CASE
(comma_keyword);
TEST_CASE
(remove_comma);
//
Simplify "?:"
TEST_CASE
(simplifyConditionOperator);
//
Simplify calculations
TEST_CASE
(calculations);
TEST_CASE
(comparisons);
//
remove dead code after flow control statements
TEST_CASE
(simplifyFlowControl);
TEST_CASE
(flowControl);
//
Simplify nested strcat() calls
TEST_CASE
(strcat1);
TEST_CASE
(strcat2);
TEST_CASE
(simplifyAtol)
TEST_CASE
(simplifyOperator1);
TEST_CASE
(simplifyOperator2);
TEST_CASE
(simplifyArrayAccessSyntax)
TEST_CASE
(simplify_numeric_condition)
TEST_CASE
(simplify_condition);
TEST_CASE
(pointeralias1);
TEST_CASE
(pointeralias2);
TEST_CASE
(pointeralias3);
TEST_CASE
(pointeralias4);
//
simplify "while (0)"
TEST_CASE
(while0);
//
ticket #3140
TEST_CASE
(while0for);
TEST_CASE
(while1);
TEST_CASE
(duplicateDefinition);
//
ticket #3565
//
remove "std::" on some standard functions
TEST_CASE
(removestd);
//
Tokenizer::simplifyInitVar
TEST_CASE
(simplifyInitVar);
//
Tokenizer::simplifyReference
TEST_CASE
(simplifyReference);
//
x = realloc(y,0); => free(y);x=0;
TEST_CASE
(simplifyRealloc);
//
while(f() && errno==EINTR) { } => while (f()) { }
TEST_CASE
(simplifyErrNoInWhile);
//
while(fclose(f)); => r = fclose(f); while(r){r=fclose(f);}
TEST_CASE
(simplifyFuncInWhile);
//
struct ABC { } abc; => struct ABC { }; ABC abc;
TEST_CASE
(simplifyStructDecl1);
TEST_CASE
(simplifyStructDecl2);
//
ticket #2579
TEST_CASE
(simplifyStructDecl3);
TEST_CASE
(simplifyStructDecl4);
TEST_CASE
(simplifyStructDecl6);
//
ticket #3732
TEST_CASE
(simplifyStructDecl7);
//
ticket #476 (static anonymous struct array)
TEST_CASE
(simplifyStructDecl8);
//
ticket #7698
//
register int var; => int var;
//
inline int foo() {} => int foo() {}
TEST_CASE
(removeUnwantedKeywords);
//
remove calling convention __cdecl, __stdcall, ...
TEST_CASE
(simplifyCallingConvention);
TEST_CASE
(simplifyFunctorCall);
TEST_CASE
(simplifyFunctionPointer);
//
ticket #5339 (simplify function pointer after comma)
TEST_CASE
(redundant_semicolon);
TEST_CASE
(simplifyFunctionReturn);
//
void foo(void) -> void foo()
TEST_CASE
(removeVoidFromFunction);
TEST_CASE
(return_strncat);
//
ticket # 2860 Returning value of strncat() reported as memory leak
//
#3069 : for loop with 1 iteration
//
for (x=0;x<1;x++) { .. }
//
The for is redundant
TEST_CASE
(removeRedundantFor);
TEST_CASE
(consecutiveBraces);
TEST_CASE
(undefinedSizeArray);
TEST_CASE
(simplifyArrayAddress);
//
Replace "&str[num]" => "(str + num)"
TEST_CASE
(simplifyCharAt);
TEST_CASE
(simplifyOverride);
//
ticket #5069
TEST_CASE
(simplifyNestedNamespace);
TEST_CASE
(simplifyNamespaceAliases);
}
std::string
tok
(
const
char
code[],
bool
simplify =
true
, Settings::PlatformType type = Settings::Native) {
errout.
str
(
"
"
);
settings0.
platform
(type);
Tokenizer
tokenizer
(&settings0,
this
);
std::istringstream
istr
(code);
tokenizer.
tokenize
(istr,
"
test.cpp
"
);
if
(simplify)
tokenizer.
simplifyTokenList2
();
return
tokenizer.
tokens
()->
stringifyList
(
nullptr
, !simplify);
}
std::string
tokWithWindows
(
const
char
code[],
bool
simplify =
true
, Settings::PlatformType type = Settings::Native) {
errout.
str
(
"
"
);
settings_windows.
platform
(type);
Tokenizer
tokenizer
(&settings_windows,
this
);
std::istringstream
istr
(code);
tokenizer.
tokenize
(istr,
"
test.cpp
"
);
if
(simplify)
tokenizer.
simplifyTokenList2
();
return
tokenizer.
tokens
()->
stringifyList
(
nullptr
, !simplify);
}
std::string
tok
(
const
char
code[],
const
char
filename[],
bool
simplify =
true
) {
errout.
str
(
"
"
);
Tokenizer
tokenizer
(&settings0,
this
);
std::istringstream
istr
(code);
tokenizer.
tokenize
(istr, filename);
if
(simplify)
tokenizer.
simplifyTokenList2
();
return
tokenizer.
tokens
()->
stringifyList
(
nullptr
,
false
);
}
std::string
tokWithNewlines
(
const
char
code[]) {
errout.
str
(
"
"
);
Tokenizer
tokenizer
(&settings0,
this
);
std::istringstream
istr
(code);
tokenizer.
tokenize
(istr,
"
test.cpp
"
);
tokenizer.
simplifyTokenList2
();
return
tokenizer.
tokens
()->
stringifyList
(
false
,
false
,
false
,
true
,
false
);
}
std::string
tokWithStdLib
(
const
char
code[]) {
errout.
str
(
"
"
);
Tokenizer
tokenizer
(&settings_std,
this
);
std::istringstream
istr
(code);
tokenizer.
tokenize
(istr,
"
test.cpp
"
);
tokenizer.
simplifyTokenList2
();
return
tokenizer.
tokens
()->
stringifyList
(
nullptr
,
false
);
}
std::string
tokenizeDebugListing
(
const
char
code[],
bool
simplify =
false
,
const
char
filename[] =
"
test.cpp
"
) {
errout.
str
(
"
"
);
Tokenizer
tokenizer
(&settings0,
this
);
std::istringstream
istr
(code);
tokenizer.
tokenize
(istr, filename);
if
(simplify)
tokenizer.
simplifyTokenList2
();
//
result..
return
tokenizer.
tokens
()->
stringifyList
(
true
);
}
void
simplifyTokenList1
() {
//
#1717 : The simplifyErrNoInWhile needs to be used before simplifyIfAndWhileAssign..
ASSERT_EQUALS
(
"
; x = f ( ) ; while ( x == -1 ) { x = f ( ) ; }
"
,
tok
(
"
;while((x=f())==-1 && errno==EINTR){}
"
,
true
));
}
void
simplifyMathFunctions_erfc
() {
//
verify erfc(), erfcf(), erfcl() - simplifcation
const
char
code_erfc[] =
"
void f(int x) {
\n
"
"
std::cout << erfc(x);
\n
"
//
do not simplify
"
std::cout << erfc(0L);
\n
"
//
simplify to 1
"
}
"
;
const
char
expected_erfc[] =
"
void f ( int x ) {
\n
"
"
std :: cout << erfc ( x ) ;
\n
"
"
std :: cout << 1 ;
\n
"
"
}
"
;
ASSERT_EQUALS
(expected_erfc,
tokWithNewlines
(code_erfc));
const
char
code_erfcf[] =
"
void f(float x) {
\n
"
"
std::cout << erfcf(x);
\n
"
//
do not simplify
"
std::cout << erfcf(0.0f);
\n
"
//
simplify to 1
"
}
"
;
const
char
expected_erfcf[] =
"
void f ( float x ) {
\n
"
"
std :: cout << erfcf ( x ) ;
\n
"
"
std :: cout << 1 ;
\n
"
"
}
"
;
ASSERT_EQUALS
(expected_erfcf,
tokWithNewlines
(code_erfcf));
const
char
code_erfcl[] =
"
void f(long double x) {
\n
"
"
std::cout << erfcl(x);
\n
"
//
do not simplify
"
std::cout << erfcl(0.0f);
\n
"
//
simplify to 1
"
}
"
;
const
char
expected_erfcl[] =
"
void f ( double x ) {
\n
"
"
std :: cout << erfcl ( x ) ;
\n
"
"
std :: cout << 1 ;
\n
"
"
}
"
;
ASSERT_EQUALS
(expected_erfcl,
tokWithNewlines
(code_erfcl));
}
void
simplifyMathFunctions_cos
() {
//
verify cos(), cosf(), cosl() - simplifcation
const
char
code_cos[] =
"
void f(int x) {
\n
"
"
std::cout << cos(x);
\n
"
//
do not simplify
"
std::cout << cos(0L);
\n
"
//
simplify to 1
"
}
"
;
const
char
expected_cos[] =
"
void f ( int x ) {
\n
"
"
std :: cout << cos ( x ) ;
\n
"
"
std :: cout << 1 ;
\n
"
"
}
"
;
ASSERT_EQUALS
(expected_cos,
tokWithNewlines
(code_cos));
const
char
code_cosf[] =
"
void f(float x) {
\n
"
"
std::cout << cosf(x);
\n
"
//
do not simplify
"
std::cout << cosf(0.0f);
\n
"
//
simplify to 1
"
}
"
;
const
char
expected_cosf[] =
"
void f ( float x ) {
\n
"
"
std :: cout << cosf ( x ) ;
\n
"
"
std :: cout << 1 ;
\n
"
"
}
"
;
ASSERT_EQUALS
(expected_cosf,
tokWithNewlines
(code_cosf));
const
char
code_cosl[] =
"
void f(long double x) {
\n
"
"
std::cout << cosl(x);
\n
"
//
do not simplify
"
std::cout << cosl(0.0f);
\n
"
//
simplify to 1
"
}
"
;
const
char
expected_cosl[] =
"
void f ( double x ) {
\n
"
"
std :: cout << cosl ( x ) ;
\n
"
"
std :: cout << 1 ;
\n
"
"
}
"
;
ASSERT_EQUALS
(expected_cosl,
tokWithNewlines
(code_cosl));
}
void
simplifyMathFunctions_cosh
() {
//
verify cosh(), coshf(), coshl() - simplifcation
const
char
code_cosh[] =
"
void f(int x) {
\n
"
"
std::cout << cosh(x);
\n
"
//
do not simplify
"
std::cout << cosh(0L);
\n
"
//
simplify to 1
"
}
"
;
const
char
expected_cosh[] =
"
void f ( int x ) {
\n
"
"
std :: cout << cosh ( x ) ;
\n
"
"
std :: cout << 1 ;
\n
"
"
}
"
;
ASSERT_EQUALS
(expected_cosh,
tokWithNewlines
(code_cosh));
const
char
code_coshf[] =
"
void f(float x) {
\n
"
"
std::cout << coshf(x);
\n
"
//
do not simplify
"
std::cout << coshf(0.0f);
\n
"
//
simplify to 1
"
}
"
;
const
char
expected_coshf[] =
"
void f ( float x ) {
\n
"
"
std :: cout << coshf ( x ) ;
\n
"
"
std :: cout << 1 ;
\n
"
"
}
"
;
ASSERT_EQUALS
(expected_coshf,
tokWithNewlines
(code_coshf));
const
char
code_coshl[] =
"
void f(long double x) {
\n
"
"
std::cout << coshl(x);
\n
"
//
do not simplify
"
std::cout << coshl(0.0f);
\n
"
//
simplify to 1
"
}
"
;
const
char
expected_coshl[] =
"
void f ( double x ) {
\n
"
"
std :: cout << coshl ( x ) ;
\n
"
"
std :: cout << 1 ;
\n
"
"
}
"
;
ASSERT_EQUALS
(expected_coshl,
tokWithNewlines
(code_coshl));
}
void
simplifyMathFunctions_acos
() {
//
verify acos(), acosf(), acosl() - simplifcation
const
char
code_acos[] =
"
void f(int x) {
\n
"
"
std::cout << acos(x);
\n
"
//
do not simplify
"
std::cout << acos(1L);
\n
"
//
simplify to 0
"
}
"
;
const
char
expected_acos[] =
"
void f ( int x ) {
\n
"
"
std :: cout << acos ( x ) ;
\n
"
"
std :: cout << 0 ;
\n
"
"
}
"
;
ASSERT_EQUALS
(expected_acos,
tokWithNewlines
(code_acos));
const
char
code_acosf[] =
"
void f(float x) {
\n
"
"
std::cout << acosf(x);
\n
"
//
do not simplify
"
std::cout << acosf(1.0f);
\n
"
//
simplify to 0
"
}
"
;
const
char
expected_acosf[] =
"
void f ( float x ) {
\n
"
"
std :: cout << acosf ( x ) ;
\n
"
"
std :: cout << 0 ;
\n
"
"
}
"
;
ASSERT_EQUALS
(expected_acosf,
tokWithNewlines
(code_acosf));
const
char
code_acosl[] =
"
void f(long double x) {
\n
"
"
std::cout << acosl(x);
\n
"
//
do not simplify
"
std::cout << acosl(1.0f);
\n
"
//
simplify to 0
"
}
"
;
const
char
expected_acosl[] =
"
void f ( double x ) {
\n
"
"
std :: cout << acosl ( x ) ;
\n
"
"
std :: cout << 0 ;
\n
"
"
}
"
;
ASSERT_EQUALS
(expected_acosl,
tokWithNewlines
(code_acosl));
}
void
simplifyMathFunctions_acosh
() {
//
verify acosh(), acoshf(), acoshl() - simplifcation
const
char
code_acosh[] =
"
void f(int x) {
\n
"
"
std::cout << acosh(x);
\n
"
//
do not simplify
"
std::cout << acosh(1L);
\n
"
//
simplify to 0
"
}
"
;
const
char
expected_acosh[] =
"
void f ( int x ) {
\n
"
"
std :: cout << acosh ( x ) ;
\n
"
"
std :: cout << 0 ;
\n
"
"
}
"
;
ASSERT_EQUALS
(expected_acosh,
tokWithNewlines
(code_acosh));
const
char
code_acoshf[] =
"
void f(float x) {
\n
"
"
std::cout << acoshf(x);
\n
"
//
do not simplify
"
std::cout << acoshf(1.0f);
\n
"
//
simplify to 0
"
}
"
;
const
char
expected_acoshf[] =
"
void f ( float x ) {
\n
"
"
std :: cout << acoshf ( x ) ;
\n
"
"
std :: cout << 0 ;
\n
"
"
}
"
;
ASSERT_EQUALS
(expected_acoshf,
tokWithNewlines
(code_acoshf));
const
char
code_acoshl[] =
"
void f(long double x) {
\n
"
"
std::cout << acoshl(x);
\n
"
//
do not simplify
"
std::cout << acoshl(1.0f);
\n
"
//
simplify to 0
"
}
"
;
const
char
expected_acoshl[] =
"
void f ( double x ) {
\n
"
"
std :: cout << acoshl ( x ) ;
\n
"
"
std :: cout << 0 ;
\n
"
"
}
"
;
ASSERT_EQUALS
(expected_acoshl,
tokWithNewlines
(code_acoshl));
}
void
simplifyMathFunctions_sqrt
() {
//
verify sqrt(), sqrtf(), sqrtl() - simplifcation
const
char
code_sqrt[] =
"
void f(int x) {
\n
"
"
std::cout << sqrt(x);
\n
"
//
do not simplify
"
std::cout << sqrt(-1);
\n
"
//
do not simplify
"
std::cout << sqrt(0L);
\n
"
//
simplify to 0
"
std::cout << sqrt(1L);
\n
"
//
simplify to 1
"
}
"
;
const
char
expected_sqrt[] =
"
void f ( int x ) {
\n
"
"
std :: cout << sqrt ( x ) ;
\n
"
"
std :: cout << sqrt ( -1 ) ;
\n
"
"
std :: cout << 0 ;
\n
"
"
std :: cout << 1 ;
\n
"
"
}
"
;
ASSERT_EQUALS
(expected_sqrt,
tokWithNewlines
(code_sqrt));
const
char
code_sqrtf[] =
"
void f(float x) {
\n
"
"
std::cout << sqrtf(x);
\n
"
//
do not simplify
"
std::cout << sqrtf(-1.0f);
\n
"
//
do not simplify
"
std::cout << sqrtf(0.0f);
\n
"
//
simplify to 0
"
std::cout << sqrtf(1.0);
\n
"
//
simplify to 1
"
}
"
;
const
char
expected_sqrtf[] =
"
void f ( float x ) {
\n
"
"
std :: cout << sqrtf ( x ) ;
\n
"
"
std :: cout << sqrtf ( -1.0f ) ;
\n
"
"
std :: cout << 0 ;
\n
"
"
std :: cout << 1 ;
\n
"
"
}
"
;
ASSERT_EQUALS
(expected_sqrtf,
tokWithNewlines
(code_sqrtf));
const
char
code_sqrtl[] =
"
void f(long double x) {
\n
"
"
std::cout << sqrtf(x);
\n
"
//
do not simplify
"
std::cout << sqrtf(-1.0);
\n
"
//
do not simplify
"
std::cout << sqrtf(0.0);
\n
"
//
simplify to 0
"
std::cout << sqrtf(1.0);
\n
"
//
simplify to 1
"
}
"
;
const
char
expected_sqrtl[] =
"
void f ( double x ) {
\n
"
"
std :: cout << sqrtf ( x ) ;
\n
"
"
std :: cout << sqrtf ( -1.0 ) ;
\n
"
"
std :: cout << 0 ;
\n
"
"
std :: cout << 1 ;
\n
"
"
}
"
;
ASSERT_EQUALS
(expected_sqrtl,
tokWithNewlines
(code_sqrtl));
}
void
simplifyMathFunctions_cbrt
() {
//
verify cbrt(), cbrtf(), cbrtl() - simplifcation
const
char
code_cbrt[] =
"
void f(int x) {
\n
"
"
std::cout << cbrt(x);
\n
"
//
do not simplify
"
std::cout << cbrt(-1);
\n
"
//
do not simplify
"
std::cout << cbrt(0L);
\n
"
//
simplify to 0
"
std::cout << cbrt(1L);
\n
"
//
simplify to 1
"
}
"
;
const
char
expected_cbrt[] =
"
void f ( int x ) {
\n
"
"
std :: cout << cbrt ( x ) ;
\n
"
"
std :: cout << cbrt ( -1 ) ;
\n
"
"
std :: cout << 0 ;
\n
"
"
std :: cout << 1 ;
\n
"
"
}
"
;
ASSERT_EQUALS
(expected_cbrt,
tokWithNewlines
(code_cbrt));
const
char
code_cbrtf[] =
"
void f(float x) {
\n
"
"
std::cout << cbrtf(x);
\n
"
//
do not simplify
"
std::cout << cbrtf(-1.0f);
\n
"
//
do not simplify
"
std::cout << cbrtf(0.0f);
\n
"
//
simplify to 0
"
std::cout << cbrtf(1.0);
\n
"
//
simplify to 1
"
}
"
;
const
char
expected_cbrtf[] =
"
void f ( float x ) {
\n
"
"
std :: cout << cbrtf ( x ) ;
\n
"
"
std :: cout << cbrtf ( -1.0f ) ;
\n
"
"
std :: cout << 0 ;
\n
"
"
std :: cout << 1 ;
\n
"
"
}
"
;
ASSERT_EQUALS
(expected_cbrtf,
tokWithNewlines
(code_cbrtf));
const
char
code_cbrtl[] =
"
void f(long double x) {
\n
"
"
std::cout << cbrtl(x);
\n
"
//
do not simplify
"
std::cout << cbrtl(-1.0);
\n
"
//
do not simplify
"
std::cout << cbrtl(0.0);
\n
"
//
simplify to 0
"
std::cout << cbrtl(1.0);
\n
"
//
simplify to 1
"
}
"
;
const
char
expected_cbrtl[] =
"
void f ( double x ) {
\n
"
"
std :: cout << cbrtl ( x ) ;
\n
"
"
std :: cout << cbrtl ( -1.0 ) ;
\n
"
"
std :: cout << 0 ;
\n
"
"
std :: cout << 1 ;
\n
"
"
}
"
;
ASSERT_EQUALS
(expected_cbrtl,
tokWithNewlines
(code_cbrtl));
}
void
simplifyMathFunctions_exp2
() {
//
verify exp2(), exp2f(), exp2l() - simplifcation
const
char
code_exp2[] =
"
void f(int x) {
\n
"
"
std::cout << exp2(x);
\n
"
//
do not simplify
"
std::cout << exp2(-1);
\n
"
//
do not simplify
"
std::cout << exp2(0L);
\n
"
//
simplify to 0
"
std::cout << exp2(1L);
\n
"
//
do not simplify
"
}
"
;
const
char
expected_exp2[] =
"
void f ( int x ) {
\n
"
"
std :: cout << exp2 ( x ) ;
\n
"
"
std :: cout << exp2 ( -1 ) ;
\n
"
"
std :: cout << 1 ;
\n
"
"
std :: cout << exp2 ( 1L ) ;
\n
"
"
}
"
;
ASSERT_EQUALS
(expected_exp2,
tokWithNewlines
(code_exp2));
const
char
code_exp2f[] =
"
void f(float x) {
\n
"
"
std::cout << exp2f(x);
\n
"
//
do not simplify
"
std::cout << exp2f(-1.0);
\n
"
//
do not simplify
"
std::cout << exp2f(0.0);
\n
"
//
simplify to 1
"
std::cout << exp2f(1.0);
\n
"
//
do not simplify
"
}
"
;
const
char
expected_exp2f[] =
"
void f ( float x ) {
\n
"
"
std :: cout << exp2f ( x ) ;
\n
"
"
std :: cout << exp2f ( -1.0 ) ;
\n
"
"
std :: cout << 1 ;
\n
"
"
std :: cout << exp2f ( 1.0 ) ;
\n
"
"
}
"
;
ASSERT_EQUALS
(expected_exp2f,
tokWithNewlines
(code_exp2f));
const
char
code_exp2l[] =
"
void f(long double x) {
\n
"
"
std::cout << exp2l(x);
\n
"
//
do not simplify
"
std::cout << exp2l(-1.0);
\n
"
//
do not simplify
"
std::cout << exp2l(0.0);
\n
"
//
simplify to 1
"
std::cout << exp2l(1.0);
\n
"
//
do not simplify
"
}
"
;
const
char
expected_exp2l[] =
"
void f ( double x ) {
\n
"
"
std :: cout << exp2l ( x ) ;
\n
"
"
std :: cout << exp2l ( -1.0 ) ;
\n
"
"
std :: cout << 1 ;
\n
"
"
std :: cout << exp2l ( 1.0 ) ;
\n
"
"
}
"
;
ASSERT_EQUALS
(expected_exp2l,
tokWithNewlines
(code_exp2l));
}
void
simplifyMathFunctions_exp
() {
//
verify exp(), expf(), expl() - simplifcation
const
char
code_exp[] =
"
void f(int x) {
\n
"
"
std::cout << exp(x);
\n
"
//
do not simplify
"
std::cout << exp(-1);
\n
"
//
do not simplify
"
std::cout << exp(0L);
\n
"
//
simplify to 1
"
std::cout << exp(1L);
\n
"
//
do not simplify
"
}
"
;
const
char
expected_exp[] =
"
void f ( int x ) {
\n
"
"
std :: cout << exp ( x ) ;
\n
"
"
std :: cout << exp ( -1 ) ;
\n
"
"
std :: cout << 1 ;
\n
"
"
std :: cout << exp ( 1L ) ;
\n
"
"
}
"
;
ASSERT_EQUALS
(expected_exp,
tokWithNewlines
(code_exp));
const
char
code_expf[] =
"
void f(float x) {
\n
"
"
std::cout << expf(x);
\n
"
//
do not simplify
"
std::cout << expf(-1.0);
\n
"
//
do not simplify
"
std::cout << expf(0.0);
\n
"
//
simplify to 1
"
std::cout << expf(1.0);
\n
"
//
do not simplify
"
}
"
;
const
char
expected_expf[] =
"
void f ( float x ) {
\n
"
"
std :: cout << expf ( x ) ;
\n
"
"
std :: cout << expf ( -1.0 ) ;
\n
"
"
std :: cout << 1 ;
\n
"
"
std :: cout << expf ( 1.0 ) ;
\n
"
"
}
"
;
ASSERT_EQUALS
(expected_expf,
tokWithNewlines
(code_expf));
const
char
code_expl[] =
"
void f(long double x) {
\n
"
"
std::cout << expl(x);
\n
"
//
do not simplify
"
std::cout << expl(-1.0);
\n
"
//
do not simplify
"
std::cout << expl(0.0);
\n
"
//
simplify to 1
"
std::cout << expl(1.0);
\n
"
//
do not simplify
"
}
"
;
const
char
expected_expl[] =
"
void f ( double x ) {
\n
"
"
std :: cout << expl ( x ) ;
\n
"
"
std :: cout << expl ( -1.0 ) ;
\n
"
"
std :: cout << 1 ;
\n
"
"
std :: cout << expl ( 1.0 ) ;
\n
"
"
}
"
;
ASSERT_EQUALS
(expected_expl,
tokWithNewlines
(code_expl));
}
void
simplifyMathFunctions_erf
() {
//
verify erf(), erff(), erfl() - simplifcation
const
char
code_erf[] =
"
void f(int x) {
\n
"
"
std::cout << erf(x);
\n
"
//
do not simplify
"
std::cout << erf(10);
\n
"
//
do not simplify
"
std::cout << erf(0L);
\n
"
//
simplify to 0
"
}
"
;
const
char
expected_erf[] =
"
void f ( int x ) {
\n
"
"
std :: cout << erf ( x ) ;
\n
"
"
std :: cout << erf ( 10 ) ;
\n
"
"
std :: cout << 0 ;
\n
"
"
}
"
;
ASSERT_EQUALS
(expected_erf,
tokWithNewlines
(code_erf));
const
char
code_erff[] =
"
void f(float x) {
\n
"
"
std::cout << erff(x);
\n
"
//
do not simplify
"
std::cout << erff(10);
\n
"
//
do not simplify
"
std::cout << erff(0.0f);
\n
"
//
simplify to 0
"
}
"
;
const
char
expected_erff[] =
"
void f ( float x ) {
\n
"
"
std :: cout << erff ( x ) ;
\n
"
"
std :: cout << erff ( 10 ) ;
\n
"
"
std :: cout << 0 ;
\n
"
"
}
"
;
ASSERT_EQUALS
(expected_erff,
tokWithNewlines
(code_erff));
const
char
code_erfl[] =
"
void f(long double x) {
\n
"
"
std::cout << erfl(x);
\n
"
//
do not simplify
"
std::cout << erfl(10.0f);
\n
"
//
do not simplify
"
std::cout << erfl(0.0f);
\n
"
//
simplify to 0
"
}
"
;
const
char
expected_erfl[] =
"
void f ( double x ) {
\n
"
"
std :: cout << erfl ( x ) ;
\n
"
"
std :: cout << erfl ( 10.0f ) ;
\n
"
"
std :: cout << 0 ;
\n
"
"
}
"
;
ASSERT_EQUALS
(expected_erfl,
tokWithNewlines
(code_erfl));
}
void
simplifyMathFunctions_atanh
() {
//
verify atanh(), atanhf(), atanhl() - simplifcation
const
char
code_atanh[] =
"
void f(int x) {
\n
"
"
std::cout << atanh(x);
\n
"
//
do not simplify
"
std::cout << atanh(10);
\n
"
//
do not simplify
"
std::cout << atanh(0L);
\n
"
//
simplify to 0
"
}
"
;
const
char
expected_atanh[] =
"
void f ( int x ) {
\n
"
"
std :: cout << atanh ( x ) ;
\n
"
"
std :: cout << atanh ( 10 ) ;
\n
"
"
std :: cout << 0 ;
\n
"
"
}
"
;
ASSERT_EQUALS
(expected_atanh,
tokWithNewlines
(code_atanh));
const
char
code_atanhf[] =
"
void f(float x) {
\n
"
"
std::cout << atanhf(x);
\n
"
//
do not simplify
"
std::cout << atanhf(10);
\n
"
//
do not simplify
"
std::cout << atanhf(0.0f);
\n
"
//
simplify to 0
"
}
"
;
const
char
expected_atanhf[] =
"
void f ( float x ) {
\n
"
"
std :: cout << atanhf ( x ) ;
\n
"
"
std :: cout << atanhf ( 10 ) ;
\n
"
"
std :: cout << 0 ;
\n
"
"
}
"
;
ASSERT_EQUALS
(expected_atanhf,
tokWithNewlines
(code_atanhf));
const
char
code_atanhl[] =
"
void f(long double x) {
\n
"
"
std::cout << atanhl(x);
\n
"
//
do not simplify
"
std::cout << atanhl(10.0f);
\n
"
//
do not simplify
"
std::cout << atanhl(0.0d);
\n
"
//
do not simplify - invalid number!
"
std::cout << atanhl(0.0f);
\n
"
//
simplify to 0
"
}
"
;
const
char
expected_atanhl[] =
"
void f ( double x ) {
\n
"
"
std :: cout << atanhl ( x ) ;
\n
"
"
std :: cout << atanhl ( 10.0f ) ;
\n
"
"
std :: cout << atanhl ( 0.0d ) ;
\n
"
"
std :: cout << 0 ;
\n
"
"
}
"
;
ASSERT_EQUALS
(expected_atanhl,
tokWithNewlines
(code_atanhl));
}
void
simplifyMathFunctions_atan
() {
//
verify atan(), atanf(), atanl() - simplifcation
const
char
code_atan[] =
"
void f(int x) {
\n
"
"
std::cout << atan(x);
\n
"
//
do not simplify
"
std::cout << atan(10);
\n
"
//
do not simplify
"
std::cout << atan(0L);
\n
"
//
simplify to 0
"
}
"
;
const
char
expected_atan[] =
"
void f ( int x ) {
\n
"
"
std :: cout << atan ( x ) ;
\n
"
"
std :: cout << atan ( 10 ) ;
\n
"
"
std :: cout << 0 ;
\n
"
"
}
"
;
ASSERT_EQUALS
(expected_atan,
tokWithNewlines
(code_atan));
const
char
code_atanf[] =
"
void f(float x) {
\n
"
"
std::cout << atanf(x);
\n
"
//
do not simplify
"
std::cout << atanf(10);
\n
"
//
do not simplify
"
std::cout << atanf(0.0f);
\n
"
//
simplify to 0
"
}
"
;
const
char
expected_atanf[] =
"
void f ( float x ) {
\n
"
"
std :: cout << atanf ( x ) ;
\n
"
"
std :: cout << atanf ( 10 ) ;
\n
"
"
std :: cout << 0 ;
\n
"
"
}
"
;
ASSERT_EQUALS
(expected_atanf,
tokWithNewlines
(code_atanf));
const
char
code_atanl[] =
"
void f(long double x) {
\n
"
"
std::cout << atanl(x);
\n
"
//
do not simplify
"
std::cout << atanl(10.0f);
\n
"
//
do not simplify
"
std::cout << atanl(0.0f);
\n
"
//
simplify to 0
"
}
"
;
const
char
expected_atanl[] =
"
void f ( double x ) {
\n
"
"
std :: cout << atanl ( x ) ;
\n
"
"
std :: cout << atanl ( 10.0f ) ;
\n
"
"
std :: cout << 0 ;
\n
"
"
}
"
;
ASSERT_EQUALS
(expected_atanl,
tokWithNewlines
(code_atanl));
}
void
simplifyMathFunctions_tanh
() {
//
verify tanh(), tanhf(), tanhl() - simplifcation
const
char
code_tanh[] =
"
void f(int x) {
\n
"
"
std::cout << tanh(x);
\n
"
//
do not simplify
"
std::cout << tanh(10);
\n
"
//
do not simplify
"
std::cout << tanh(0L);
\n
"
//
simplify to 0
"
}
"
;
const
char
expected_tanh[] =
"
void f ( int x ) {
\n
"
"
std :: cout << tanh ( x ) ;
\n
"
"
std :: cout << tanh ( 10 ) ;
\n
"
"
std :: cout << 0 ;
\n
"
"
}
"
;
ASSERT_EQUALS
(expected_tanh,
tokWithNewlines
(code_tanh));
const
char
code_tanhf[] =
"
void f(float x) {
\n
"
"
std::cout << tanhf(x);
\n
"
//
do not simplify
"
std::cout << tanhf(10);
\n
"
//
do not simplify
"
std::cout << tanhf(0.0f);
\n
"
//
simplify to 0
"
}
"
;
const
char
expected_tanhf[] =
"
void f ( float x ) {
\n
"
"
std :: cout << tanhf ( x ) ;
\n
"
"
std :: cout << tanhf ( 10 ) ;
\n
"
"
std :: cout << 0 ;
\n
"
"
}
"
;
ASSERT_EQUALS
(expected_tanhf,
tokWithNewlines
(code_tanhf));
const
char
code_tanhl[] =
"
void f(long double x) {
\n
"
"
std::cout << tanhl(x);
\n
"
//
do not simplify
"
std::cout << tanhl(10.0f);
\n
"
//
do not simplify
"
std::cout << tanhl(0.0f);
\n
"
//
simplify to 0
"
}
"
;
const
char
expected_tanhl[] =
"
void f ( double x ) {
\n
"
"
std :: cout << tanhl ( x ) ;
\n
"
"
std :: cout << tanhl ( 10.0f ) ;
\n
"
"
std :: cout << 0 ;
\n
"
"
}
"
;
ASSERT_EQUALS
(expected_tanhl,
tokWithNewlines
(code_tanhl));
}
void
simplifyMathFunctions_tan
() {
//
verify tan(), tanf(), tanl() - simplifcation
const
char
code_tan[] =
"
void f(int x) {
\n
"
"
std::cout << tan(x);
\n
"
//
do not simplify
"
std::cout << tan(10);
\n
"
//
do not simplify
"
std::cout << tan(0L);
\n
"
//
simplify to 0
"
}
"
;
const
char
expected_tan[] =
"
void f ( int x ) {
\n
"
"
std :: cout << tan ( x ) ;
\n
"
"
std :: cout << tan ( 10 ) ;
\n
"
"
std :: cout << 0 ;
\n
"
"
}
"
;
ASSERT_EQUALS
(expected_tan,
tokWithNewlines
(code_tan));
const
char
code_tanf[] =
"
void f(float x) {
\n
"
"
std::cout << tanf(x);
\n
"
//
do not simplify
"
std::cout << tanf(10);
\n
"
//
do not simplify
"
std::cout << tanf(0.0f);
\n
"
//
simplify to 0
"
}
"
;
const
char
expected_tanf[] =
"
void f ( float x ) {
\n
"
"
std :: cout << tanf ( x ) ;
\n
"
"
std :: cout << tanf ( 10 ) ;
\n
"
"
std :: cout << 0 ;
\n
"
"
}
"
;
ASSERT_EQUALS
(expected_tanf,
tokWithNewlines
(code_tanf));
const
char
code_tanl[] =
"
void f(long double x) {
\n
"
"
std::cout << tanl(x);
\n
"
//
do not simplify
"
std::cout << tanl(10.0f);
\n
"
//
do not simplify
"
std::cout << tanl(0.0f);
\n
"
//
simplify to 0
"
}
"
;
const
char
expected_tanl[] =
"
void f ( double x ) {
\n
"
"
std :: cout << tanl ( x ) ;
\n
"
"
std :: cout << tanl ( 10.0f ) ;
\n
"
"
std :: cout << 0 ;
\n
"
"
}
"
;
ASSERT_EQUALS
(expected_tanl,
tokWithNewlines
(code_tanl));
}
void
simplifyMathFunctions_expm1
() {
//
verify expm1(), expm1f(), expm1l() - simplifcation
const
char
code_expm1[] =
"
void f(int x) {
\n
"
"
std::cout << expm1(x);
\n
"
//
do not simplify
"
std::cout << expm1(10);
\n
"
//
do not simplify
"
std::cout << expm1(0L);
\n
"
//
simplify to 0
"
}
"
;
const
char
expected_expm1[] =
"
void f ( int x ) {
\n
"
"
std :: cout << expm1 ( x ) ;
\n
"
"
std :: cout << expm1 ( 10 ) ;
\n
"
"
std :: cout << 0 ;
\n
"
"
}
"
;
ASSERT_EQUALS
(expected_expm1,
tokWithNewlines
(code_expm1));
const
char
code_expm1f[] =
"
void f(float x) {
\n
"
"
std::cout << expm1f(x);
\n
"
//
do not simplify
"
std::cout << expm1f(10);
\n
"
//
do not simplify
"
std::cout << expm1f(0.0f);
\n
"
//
simplify to 0
"
}
"
;
const
char
expected_expm1f[] =
"
void f ( float x ) {
\n
"
"
std :: cout << expm1f ( x ) ;
\n
"
"
std :: cout << expm1f ( 10 ) ;
\n
"
"
std :: cout << 0 ;
\n
"
"
}
"
;
ASSERT_EQUALS
(expected_expm1f,
tokWithNewlines
(code_expm1f));
const
char
code_expm1l[] =
"
void f(long double x) {
\n
"
"
std::cout << expm1l(x);
\n
"
//
do not simplify
"
std::cout << expm1l(10.0f);
\n
"
//
do not simplify
"
std::cout << expm1l(0.0f);
\n
"
//
simplify to 0
"
}
"
;
const
char
expected_expm1l[] =
"
void f ( double x ) {
\n
"
"
std :: cout << expm1l ( x ) ;
\n
"
"
std :: cout << expm1l ( 10.0f ) ;
\n
"
"
std :: cout << 0 ;
\n
"
"
}
"
;
ASSERT_EQUALS
(expected_expm1l,
tokWithNewlines
(code_expm1l));
}
void
simplifyMathFunctions_asinh
() {
//
verify asinh(), asinhf(), asinhl() - simplifcation
const
char
code_asinh[] =
"
void f(int x) {
\n
"
"
std::cout << asinh(x);
\n
"
//
do not simplify
"
std::cout << asinh(10);
\n
"
//
do not simplify
"
std::cout << asinh(0L);
\n
"
//
simplify to 0
"
}
"
;
const
char
expected_asinh[] =
"
void f ( int x ) {
\n
"
"
std :: cout << asinh ( x ) ;
\n
"
"
std :: cout << asinh ( 10 ) ;
\n
"
"
std :: cout << 0 ;
\n
"
"
}
"
;
ASSERT_EQUALS
(expected_asinh,
tokWithNewlines
(code_asinh));
const
char
code_asinhf[] =
"
void f(float x) {
\n
"
"
std::cout << asinhf(x);
\n
"
//
do not simplify
"
std::cout << asinhf(10);
\n
"
//
do not simplify
"
std::cout << asinhf(0.0f);
\n
"
//
simplify to 0
"
}
"
;
const
char
expected_asinhf[] =
"
void f ( float x ) {
\n
"
"
std :: cout << asinhf ( x ) ;
\n
"
"
std :: cout << asinhf ( 10 ) ;
\n
"
"
std :: cout << 0 ;
\n
"
"
}
"
;
ASSERT_EQUALS
(expected_asinhf,
tokWithNewlines
(code_asinhf));
const
char
code_asinhl[] =
"
void f(long double x) {
\n
"
"
std::cout << asinhl(x);
\n
"
//
do not simplify
"
std::cout << asinhl(10.0f);
\n
"
//
do not simplify
"
std::cout << asinhl(0.0f);
\n
"
//
simplify to 0
"
}
"
;
const
char
expected_asinhl[] =
"
void f ( double x ) {
\n
"
"
std :: cout << asinhl ( x ) ;
\n
"
"
std :: cout << asinhl ( 10.0f ) ;
\n
"
"
std :: cout << 0 ;
\n
"
"
}
"
;
ASSERT_EQUALS
(expected_asinhl,
tokWithNewlines
(code_asinhl));
}
void
simplifyMathFunctions_asin
() {
//
verify asin(), asinf(), asinl() - simplifcation
const
char
code_asin[] =
"
void f(int x) {
\n
"
"
std::cout << asin(x);
\n
"
//
do not simplify
"
std::cout << asin(10);
\n
"
//
do not simplify
"
std::cout << asin(0L);
\n
"
//
simplify to 0
"
}
"
;
const
char
expected_asin[] =
"
void f ( int x ) {
\n
"
"
std :: cout << asin ( x ) ;
\n
"
"
std :: cout << asin ( 10 ) ;
\n
"
"
std :: cout << 0 ;
\n
"
"
}
"
;
ASSERT_EQUALS
(expected_asin,
tokWithNewlines
(code_asin));
const
char
code_asinf[] =
"
void f(float x) {
\n
"
"
std::cout << asinf(x);
\n
"
//
do not simplify
"
std::cout << asinf(10);
\n
"
//
do not simplify
"
std::cout << asinf(0.0f);
\n
"
//
simplify to 0
"
}
"
;
const
char
expected_asinf[] =
"
void f ( float x ) {
\n
"
"
std :: cout << asinf ( x ) ;
\n
"
"
std :: cout << asinf ( 10 ) ;
\n
"
"
std :: cout << 0 ;
\n
"
"
}
"
;
ASSERT_EQUALS
(expected_asinf,
tokWithNewlines
(code_asinf));
View remainder of file in raw view
Footer
© 2026 GitHub, Inc.
Footer navigation
Terms
Privacy
Security
Status
Community
Docs
Contact
You can’t perform that action at this time.
Back
|
FazBrowse Home
|
New Git URL