| 12 | #include "fl/stl/string.h" |
| 13 | |
| 14 | FL_TEST_FILE(FL_FILEPATH) { |
| 15 | |
| 16 | |
| 17 | |
| 18 | |
| 19 | |
| 20 | // Test helper for capturing platform output |
| 21 | namespace test_helper { |
| 22 | // Forward declarations to satisfy -Werror=missing-declarations |
| 23 | void capture_print(const char* str); |
| 24 | void clear_capture(); |
| 25 | fl::string get_capture(); |
| 26 | |
| 27 | static fl::string captured_output; |
| 28 | |
| 29 | void capture_print(const char* str) { |
| 30 | captured_output += str; |
| 31 | } |
| 32 | |
| 33 | void clear_capture() { |
| 34 | captured_output.clear(); |
| 35 | } |
| 36 | |
| 37 | fl::string get_capture() { |
| 38 | return captured_output; |
| 39 | } |
| 40 | } |
| 41 | |
| 42 | FL_TEST_CASE("fl::printf basic functionality") { |
| 43 | // Setup capture for testing platform output |
| 44 | fl::inject_print_handler(test_helper::capture_print); |
| 45 | |
| 46 | FL_SUBCASE("simple string formatting") { |
| 47 | test_helper::clear_capture(); |
| 48 | fl::printf("Hello, %s!", "world"); |
| 49 | fl::string result = test_helper::get_capture(); |
| 50 | fl::string expected = fl::string("Hello, world!"); |
| 51 | |
| 52 | // Debug output to see what's happening |
| 53 | fl::cout << "[DEBUG] Result: '" << result.c_str() << "' (length: " << result.size() << ")" << fl::endl; |
| 54 | fl::cout << "[DEBUG] Expected: '" << expected.c_str() << "' (length: " << expected.size() << ")" << fl::endl; |
| 55 | |
| 56 | // Use basic string comparison |
| 57 | FL_REQUIRE_EQ(result.size(), expected.size()); |
| 58 | FL_REQUIRE_EQ(fl::strcmp(result.c_str(), expected.c_str()), 0); |
| 59 | } |
| 60 | |
| 61 | FL_SUBCASE("integer formatting") { |
| 62 | test_helper::clear_capture(); |
| 63 | fl::printf("Value: %d", 42); |
| 64 | fl::string result = test_helper::get_capture(); |
| 65 | fl::string expected = fl::string("Value: 42"); |
| 66 | FL_REQUIRE_EQ(fl::strcmp(result.c_str(), expected.c_str()), 0); |
| 67 | } |
| 68 | |
| 69 | FL_SUBCASE("multiple arguments") { |
| 70 | test_helper::clear_capture(); |
| 71 | fl::printf("Name: %s, Age: %d", "Alice", 25); |
nothing calls this directly
no test coverage detected