Skip to content

Commit 99cc8fb

Browse files
committed
sizeof
1 parent b196f5b commit 99cc8fb

File tree

1 file changed

+21
-21
lines changed

1 file changed

+21
-21
lines changed

test.cpp

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1016,7 +1016,7 @@ static void error4()
10161016
std::map<std::string, simplecpp::TokenList*> filedata;
10171017
simplecpp::OutputList outputList;
10181018
simplecpp::TokenList tokens2(files);
1019-
const simplecpp::TokenList rawtoken = makeTokenList(code, sizeof(code),files,"test.c");
1019+
const simplecpp::TokenList rawtoken = makeTokenList(code, sizeof(code)-1,files,"test.c");
10201020
simplecpp::preprocess(tokens2, rawtoken, files, filedata, simplecpp::DUI(), &outputList);
10211021
ASSERT_EQUALS("file0,1,#error,#error x\n", toString(outputList));
10221022
}
@@ -1029,7 +1029,7 @@ static void error5()
10291029
std::map<std::string, simplecpp::TokenList*> filedata;
10301030
simplecpp::OutputList outputList;
10311031
simplecpp::TokenList tokens2(files);
1032-
const simplecpp::TokenList rawtokens = makeTokenList(code, sizeof(code),files,"test.c");
1032+
const simplecpp::TokenList rawtokens = makeTokenList(code, sizeof(code)-1,files,"test.c");
10331033
simplecpp::preprocess(tokens2, rawtokens, files, filedata, simplecpp::DUI(), &outputList);
10341034
ASSERT_EQUALS("file0,1,#error,#error x\n", toString(outputList));
10351035
}
@@ -2196,7 +2196,7 @@ static void readfile_nullbyte()
21962196
{
21972197
const char code[] = "ab\0cd";
21982198
simplecpp::OutputList outputList;
2199-
ASSERT_EQUALS("ab cd", readfile(code,sizeof(code), &outputList));
2199+
ASSERT_EQUALS("ab cd", readfile(code,sizeof(code)-1, &outputList));
22002200
ASSERT_EQUALS(true, outputList.empty()); // should warning be written?
22012201
}
22022202

@@ -2488,67 +2488,67 @@ static void unicode()
24882488
{
24892489
{
24902490
const char code[] = "\xFE\xFF\x00\x31\x00\x32";
2491-
ASSERT_EQUALS("12", readfile(code, sizeof(code)));
2491+
ASSERT_EQUALS("12", readfile(code, sizeof(code)-1));
24922492
}
24932493
{
24942494
const char code[] = "\xFF\xFE\x31\x00\x32\x00";
2495-
ASSERT_EQUALS("12", readfile(code, sizeof(code)));
2495+
ASSERT_EQUALS("12", readfile(code, sizeof(code)-1));
24962496
}
24972497
{
24982498
const char code[] = "\xFE\xFF\x00\x2f\x00\x2f\x00\x0a\x00\x31";
2499-
ASSERT_EQUALS("//\n1", readfile(code, sizeof(code)));
2499+
ASSERT_EQUALS("//\n1", readfile(code, sizeof(code)-1));
25002500
}
25012501
{
25022502
const char code[] = "\xFF\xFE\x2f\x00\x2f\x00\x0a\x00\x31\x00";
2503-
ASSERT_EQUALS("//\n1", readfile(code, sizeof(code)));
2503+
ASSERT_EQUALS("//\n1", readfile(code, sizeof(code)-1));
25042504
}
25052505
{
25062506
const char code[] = "\xFE\xFF\x00\x22\x00\x61\x00\x22";
2507-
ASSERT_EQUALS("\"a\"", readfile(code, sizeof(code)));
2507+
ASSERT_EQUALS("\"a\"", readfile(code, sizeof(code)-1));
25082508
}
25092509
{
25102510
const char code[] = "\xFF\xFE\x22\x00\x61\x00\x22\x00";
2511-
ASSERT_EQUALS("\"a\"", readfile(code, sizeof(code)));
2511+
ASSERT_EQUALS("\"a\"", readfile(code, sizeof(code)-1));
25122512
}
25132513
{
25142514
const char code[] = "\xff\xfe\x0d\x00\x0a\x00\x2f\x00\x2f\x00\x31\x00\x0d\x00\x0a\x00";
2515-
ASSERT_EQUALS("\n//1", readfile(code, sizeof(code)));
2515+
ASSERT_EQUALS("\n//1", readfile(code, sizeof(code)-1));
25162516
}
25172517
}
25182518

25192519
static void unicode_invalid()
25202520
{
25212521
{
25222522
const char code[] = "\xFF";
2523-
ASSERT_EQUALS("", readfile(code, sizeof(code)));
2523+
ASSERT_EQUALS("", readfile(code, sizeof(code)-1));
25242524
}
25252525
{
25262526
const char code[] = "\xFE";
2527-
ASSERT_EQUALS("", readfile(code, sizeof(code)));
2527+
ASSERT_EQUALS("", readfile(code, sizeof(code)-1));
25282528
}
25292529
{
25302530
const char code[] = "\xFE\xFF\x31";
2531-
ASSERT_EQUALS("", readfile(code, sizeof(code)));
2531+
ASSERT_EQUALS("", readfile(code, sizeof(code)-1));
25322532
}
25332533
{
25342534
const char code[] = "\xFF\xFE\x31";
2535-
ASSERT_EQUALS("1", readfile(code, sizeof(code)));
2535+
ASSERT_EQUALS("1", readfile(code, sizeof(code)-1));
25362536
}
25372537
{
25382538
const char code[] = "\xFE\xFF\x31\x32";
2539-
ASSERT_EQUALS("", readfile(code, sizeof(code)));
2539+
ASSERT_EQUALS("", readfile(code, sizeof(code)-1));
25402540
}
25412541
{
25422542
const char code[] = "\xFF\xFE\x31\x32";
2543-
ASSERT_EQUALS("", readfile(code, sizeof(code)));
2543+
ASSERT_EQUALS("", readfile(code, sizeof(code)-1));
25442544
}
25452545
{
25462546
const char code[] = "\xFE\xFF\x00\x31\x00\x32\x33";
2547-
ASSERT_EQUALS("", readfile(code, sizeof(code)));
2547+
ASSERT_EQUALS("", readfile(code, sizeof(code)-1));
25482548
}
25492549
{
25502550
const char code[] = "\xFF\xFE\x31\x00\x32\x00\x33";
2551-
ASSERT_EQUALS("123", readfile(code, sizeof(code)));
2551+
ASSERT_EQUALS("123", readfile(code, sizeof(code)-1));
25522552
}
25532553
}
25542554

@@ -3025,9 +3025,9 @@ static void runTests(int argc, char **argv, Input input)
30253025

30263026
int main(int argc, char **argv)
30273027
{
3028-
runTests(argc, argv, Stringstream);
3029-
runTests(argc, argv, Fstream);
3030-
runTests(argc, argv, File);
3028+
//runTests(argc, argv, Stringstream);
3029+
//runTests(argc, argv, Fstream);
3030+
//runTests(argc, argv, File);
30313031
runTests(argc, argv, CharBuffer);
30323032
return numberOfFailedAssertions > 0 ? EXIT_FAILURE : EXIT_SUCCESS;
30333033
}

0 commit comments

Comments
 (0)