X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=Usermode%2FLibraries%2Flibc%2B%2B_extras.so_src%2FTEST_cprintf.cpp;h=b77b00400ddc98412c10a9cfda299bd929c59e14;hb=13078002b01ee4f63eb2001d2ef479a2a006ea32;hp=6c02bd2aaf977c29fa541af6fb1e8d29d19f11ed;hpb=4dfcb795680902dcf7f9b8789f4b7fab1a96875b;p=tpg%2Facess2.git diff --git a/Usermode/Libraries/libc++_extras.so_src/TEST_cprintf.cpp b/Usermode/Libraries/libc++_extras.so_src/TEST_cprintf.cpp index 6c02bd2a..b77b0040 100644 --- a/Usermode/Libraries/libc++_extras.so_src/TEST_cprintf.cpp +++ b/Usermode/Libraries/libc++_extras.so_src/TEST_cprintf.cpp @@ -2,15 +2,28 @@ */ #include #include +#include + +void my_puts(const char *str, size_t len) +{ + fwrite(str, 1, len, stdout); +} + +#define ASSERT_EXCEPTION(expr, Exception) do{bool _ok=false; try { expr; } catch(const Exception& e){_ok=true;}if(!_ok)throw ::std::runtime_error("Didn't throw "#Exception);}while(0) int main() { - ::cxxextras::cprintf( - [](const char *str, size_t len){printf("%.*s", (unsigned int)len, str); return len;}, - "%s %i %+#-010x", - "hello_world", - 1337, - 0x1234565); + printf("Success\n"); + cprintf(my_puts, "%s %i %+#-010x\n", "hello_world", 1337, 0x1234565); + + //printf("Too Few\n"); + //ASSERT_EXCEPTION( ::cxxextras::cprintf(my_puts, "%s %i %+#-010x\n"), ::cxxextras::cprintf_toofewargs ); + //printf("Too Many\n"); + //ASSERT_EXCEPTION( ::cxxextras::cprintf(my_puts, "%s\n", "tst", 12345), ::cxxextras::cprintf_toomanyargs ); + // + //printf("Bad Format\n"); + //ASSERT_EXCEPTION( ::cxxextras::cprintf(my_puts, "%-\n"), ::cxxextras::cprintf_badformat ); + return 0; }