Skip to content

Commit

Permalink
sizeof
Browse files Browse the repository at this point in the history
  • Loading branch information
firewave committed Mar 29, 2024
1 parent b196f5b commit 99cc8fb
Showing 1 changed file with 21 additions and 21 deletions.
42 changes: 21 additions & 21 deletions test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1016,7 +1016,7 @@ static void error4()
std::map<std::string, simplecpp::TokenList*> filedata;
simplecpp::OutputList outputList;
simplecpp::TokenList tokens2(files);
const simplecpp::TokenList rawtoken = makeTokenList(code, sizeof(code),files,"test.c");
const simplecpp::TokenList rawtoken = makeTokenList(code, sizeof(code)-1,files,"test.c");
simplecpp::preprocess(tokens2, rawtoken, files, filedata, simplecpp::DUI(), &outputList);
ASSERT_EQUALS("file0,1,#error,#error x\n", toString(outputList));
}
Expand All @@ -1029,7 +1029,7 @@ static void error5()
std::map<std::string, simplecpp::TokenList*> filedata;
simplecpp::OutputList outputList;
simplecpp::TokenList tokens2(files);
const simplecpp::TokenList rawtokens = makeTokenList(code, sizeof(code),files,"test.c");
const simplecpp::TokenList rawtokens = makeTokenList(code, sizeof(code)-1,files,"test.c");
simplecpp::preprocess(tokens2, rawtokens, files, filedata, simplecpp::DUI(), &outputList);
ASSERT_EQUALS("file0,1,#error,#error x\n", toString(outputList));
}
Expand Down Expand Up @@ -2196,7 +2196,7 @@ static void readfile_nullbyte()
{
const char code[] = "ab\0cd";
simplecpp::OutputList outputList;
ASSERT_EQUALS("ab cd", readfile(code,sizeof(code), &outputList));
ASSERT_EQUALS("ab cd", readfile(code,sizeof(code)-1, &outputList));
ASSERT_EQUALS(true, outputList.empty()); // should warning be written?
}

Expand Down Expand Up @@ -2488,67 +2488,67 @@ static void unicode()
{
{
const char code[] = "\xFE\xFF\x00\x31\x00\x32";
ASSERT_EQUALS("12", readfile(code, sizeof(code)));
ASSERT_EQUALS("12", readfile(code, sizeof(code)-1));
}
{
const char code[] = "\xFF\xFE\x31\x00\x32\x00";
ASSERT_EQUALS("12", readfile(code, sizeof(code)));
ASSERT_EQUALS("12", readfile(code, sizeof(code)-1));
}
{
const char code[] = "\xFE\xFF\x00\x2f\x00\x2f\x00\x0a\x00\x31";
ASSERT_EQUALS("//\n1", readfile(code, sizeof(code)));
ASSERT_EQUALS("//\n1", readfile(code, sizeof(code)-1));
}
{
const char code[] = "\xFF\xFE\x2f\x00\x2f\x00\x0a\x00\x31\x00";
ASSERT_EQUALS("//\n1", readfile(code, sizeof(code)));
ASSERT_EQUALS("//\n1", readfile(code, sizeof(code)-1));
}
{
const char code[] = "\xFE\xFF\x00\x22\x00\x61\x00\x22";
ASSERT_EQUALS("\"a\"", readfile(code, sizeof(code)));
ASSERT_EQUALS("\"a\"", readfile(code, sizeof(code)-1));
}
{
const char code[] = "\xFF\xFE\x22\x00\x61\x00\x22\x00";
ASSERT_EQUALS("\"a\"", readfile(code, sizeof(code)));
ASSERT_EQUALS("\"a\"", readfile(code, sizeof(code)-1));
}
{
const char code[] = "\xff\xfe\x0d\x00\x0a\x00\x2f\x00\x2f\x00\x31\x00\x0d\x00\x0a\x00";
ASSERT_EQUALS("\n//1", readfile(code, sizeof(code)));
ASSERT_EQUALS("\n//1", readfile(code, sizeof(code)-1));
}
}

static void unicode_invalid()
{
{
const char code[] = "\xFF";
ASSERT_EQUALS("", readfile(code, sizeof(code)));
ASSERT_EQUALS("", readfile(code, sizeof(code)-1));
}
{
const char code[] = "\xFE";
ASSERT_EQUALS("", readfile(code, sizeof(code)));
ASSERT_EQUALS("", readfile(code, sizeof(code)-1));
}
{
const char code[] = "\xFE\xFF\x31";
ASSERT_EQUALS("", readfile(code, sizeof(code)));
ASSERT_EQUALS("", readfile(code, sizeof(code)-1));
}
{
const char code[] = "\xFF\xFE\x31";
ASSERT_EQUALS("1", readfile(code, sizeof(code)));
ASSERT_EQUALS("1", readfile(code, sizeof(code)-1));
}
{
const char code[] = "\xFE\xFF\x31\x32";
ASSERT_EQUALS("", readfile(code, sizeof(code)));
ASSERT_EQUALS("", readfile(code, sizeof(code)-1));
}
{
const char code[] = "\xFF\xFE\x31\x32";
ASSERT_EQUALS("", readfile(code, sizeof(code)));
ASSERT_EQUALS("", readfile(code, sizeof(code)-1));
}
{
const char code[] = "\xFE\xFF\x00\x31\x00\x32\x33";
ASSERT_EQUALS("", readfile(code, sizeof(code)));
ASSERT_EQUALS("", readfile(code, sizeof(code)-1));
}
{
const char code[] = "\xFF\xFE\x31\x00\x32\x00\x33";
ASSERT_EQUALS("123", readfile(code, sizeof(code)));
ASSERT_EQUALS("123", readfile(code, sizeof(code)-1));
}
}

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

int main(int argc, char **argv)
{
runTests(argc, argv, Stringstream);
runTests(argc, argv, Fstream);
runTests(argc, argv, File);
//runTests(argc, argv, Stringstream);
//runTests(argc, argv, Fstream);
//runTests(argc, argv, File);
runTests(argc, argv, CharBuffer);
return numberOfFailedAssertions > 0 ? EXIT_FAILURE : EXIT_SUCCESS;
}

0 comments on commit 99cc8fb

Please sign in to comment.