| 555 | } |
| 556 | |
| 557 | void setPlatformInfo() { |
| 558 | // read code with simplecpp.. |
| 559 | const char filedata[] = "#if sizeof(long) == 4\n" |
| 560 | "1\n" |
| 561 | "#else\n" |
| 562 | "2\n" |
| 563 | "#endif\n"; |
| 564 | |
| 565 | // preprocess code with unix32 platform.. |
| 566 | { |
| 567 | std::vector<std::string> files; |
| 568 | simplecpp::TokenList tokens(filedata, files, "test.c"); |
| 569 | const Settings settings = settingsBuilder().platform(Platform::Type::Unix32).build(); |
| 570 | Preprocessor preprocessor(tokens, settings, *this, Path::identify(tokens.getFiles()[0], false)); |
| 571 | preprocessor.setPlatformInfo(); |
| 572 | ASSERT_EQUALS("\n1", preprocessor.getcode("", files, false)); |
| 573 | } |
| 574 | |
| 575 | // preprocess code with unix64 platform.. |
| 576 | { |
| 577 | std::vector<std::string> files; |
| 578 | simplecpp::TokenList tokens(filedata, files, "test.c"); |
| 579 | const Settings settings = settingsBuilder().platform(Platform::Type::Unix64).build(); |
| 580 | Preprocessor preprocessor(tokens, settings, *this, Path::identify(tokens.getFiles()[0], false)); |
| 581 | preprocessor.setPlatformInfo(); |
| 582 | ASSERT_EQUALS("\n\n\n2", preprocessor.getcode("", files, false)); |
| 583 | } |
| 584 | } |
| 585 | |
| 586 | void includeguard1() { |
| 587 | // Handling include guards.. |