Skip to content

Commit 558dd2e

Browse files
more tests
1 parent 96fd1b8 commit 558dd2e

File tree

16 files changed

+67
-1
lines changed

16 files changed

+67
-1
lines changed

testlib.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4917,7 +4917,7 @@ static inline void __testlib_ensure(bool cond, const char *msg) {
49174917
}
49184918

49194919
#define ensure(cond) __testlib_ensure((cond), "Condition failed: \"" #cond "\"")
4920-
#define STRINGIZE_DETAIL(x) #x
4920+
#define STRINGIZE_DETAIL(x) (#x)
49214921
#define STRINGIZE(x) STRINGIZE_DETAIL((x))
49224922
#define ensure_ext(cond) __testlib_ensure((cond), "Line " STRINGIZE(__LINE__) ": Condition failed: \"" #cond "\"")
49234923

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#if (__cplusplus >= 202002L && __has_include(<format>))
2+
# include <format>
3+
#endif
4+
5+
#include "testlib.h"
6+
7+
using namespace std;
8+
9+
int main(int argc, char** argv) {
10+
registerGen(argc, argv, 1);
11+
12+
println(format("%d", 42));
13+
println(format("hello, %s!", "hat"));
14+
println(format("%s%d!", "'hat'", 42));
15+
println(format("%s%d!", "'%s'", 42));
16+
17+
ensure(format("%f", 42.5).substr(0, 4) == "42.5");
18+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#include "testlib.h"
2+
3+
#if (__cplusplus >= 202002L && __has_include(<format>))
4+
# include <format>
5+
#endif
6+
7+
using namespace std;
8+
9+
int main(int argc, char** argv) {
10+
registerGen(argc, argv, 1);
11+
12+
println(format("%d", 42));
13+
println(format("hello, %s!", "hat"));
14+
println(format("%s%d!", "'hat'", 42));
15+
println(format("%s%d!", "'%s'", 42));
16+
17+
ensure(format("%f", 42.5).substr(0, 4) == "42.5");
18+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
0

tests/test-008_format/refs/test-format-format1/r1/stderr

Whitespace-only changes.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
42
2+
hello, hat!
3+
'hat'42!
4+
'%s'42!
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
0

tests/test-008_format/refs/test-format-format1/r2/stderr

Whitespace-only changes.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
42
2+
hello, hat!
3+
'hat'42!
4+
'%s'42!
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
0

0 commit comments

Comments
 (0)