test-format-format1.cpp 416 B

123456789101112131415161718
  1. #if (__cplusplus >= 202002L && __has_include(<format>))
  2. # include <format>
  3. #endif
  4. #include "testlib.h"
  5. using namespace std;
  6. int main(int argc, char** argv) {
  7. registerGen(argc, argv, 1);
  8. println(format("%d", 42));
  9. println(format("hello, %s!", "hat"));
  10. println(format("%s%d!", "'hat'", 42));
  11. println(format("%s%d!", "'%s'", 42));
  12. ensure(format("%f", 42.5).substr(0, 4) == "42.5");
  13. }