test-format-format2.cpp 416 B

123456789101112131415161718
  1. #include "testlib.h"
  2. #if (__cplusplus >= 202002L && __has_include(<format>))
  3. # include <format>
  4. #endif
  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. }